sp_c32.c 1.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904
  1. /* sp.c
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* Implementation by Sean Parkinson. */
  22. #ifdef HAVE_CONFIG_H
  23. #include <config.h>
  24. #endif
  25. #include <wolfssl/wolfcrypt/settings.h>
  26. #if defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH) || \
  27. defined(WOLFSSL_HAVE_SP_ECC)
  28. #include <wolfssl/wolfcrypt/error-crypt.h>
  29. #include <wolfssl/wolfcrypt/cpuid.h>
  30. #ifdef NO_INLINE
  31. #include <wolfssl/wolfcrypt/misc.h>
  32. #else
  33. #define WOLFSSL_MISC_INCLUDED
  34. #include <wolfcrypt/src/misc.c>
  35. #endif
  36. #ifdef RSA_LOW_MEM
  37. #ifndef SP_RSA_PRIVATE_EXP_D
  38. #define SP_RSA_PRIVATE_EXP_D
  39. #endif
  40. #ifndef WOLFSSL_SP_SMALL
  41. #define WOLFSSL_SP_SMALL
  42. #endif
  43. #endif
  44. #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SP_NO_MALLOC)
  45. #undef WOLFSSL_SP_SMALL_STACK
  46. #define WOLFSSL_SP_SMALL_STACK
  47. #endif
  48. #include <wolfssl/wolfcrypt/sp.h>
  49. #ifdef __IAR_SYSTEMS_ICC__
  50. #define __asm__ asm
  51. #define __volatile__ volatile
  52. #define WOLFSSL_NO_VAR_ASSIGN_REG
  53. #endif /* __IAR_SYSTEMS_ICC__ */
  54. #ifdef __KEIL__
  55. #define __asm__ __asm
  56. #define __volatile__ volatile
  57. #endif
  58. #ifndef WOLFSSL_SP_ASM
  59. #if SP_WORD_SIZE == 32
  60. #define SP_PRINT_NUM(var, name, total, words, bits) \
  61. do { \
  62. int ii; \
  63. byte nb[(bits + 7) / 8]; \
  64. sp_digit _s[words]; \
  65. XMEMCPY(_s, var, sizeof(_s)); \
  66. sp_##total##_norm_##words(_s); \
  67. sp_##total##_to_bin_##words(_s, nb); \
  68. fprintf(stderr, name "=0x"); \
  69. for (ii=0; ii<(bits + 7) / 8; ii++) \
  70. fprintf(stderr, "%02x", nb[ii]); \
  71. fprintf(stderr, "\n"); \
  72. } while (0)
  73. #define SP_PRINT_VAL(var, name) \
  74. fprintf(stderr, name "=0x" SP_PRINT_FMT "\n", var)
  75. #define SP_PRINT_INT(var, name) \
  76. fprintf(stderr, name "=%d\n", var)
  77. #if ((defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)) && \
  78. ((!defined(WC_NO_CACHE_RESISTANT) && \
  79. (defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH))) || \
  80. (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP))) && \
  81. !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || (defined(WOLFSSL_SP_SMALL) && \
  82. defined(WOLFSSL_HAVE_SP_ECC) && (!defined(WOLFSSL_SP_NO_256) || \
  83. defined(WOLFSSL_SP_384) || defined(WOLFSSL_SP_521) || \
  84. defined(WOLFSSL_SP_1024)))
  85. /* Mask for address to obfuscate which of the two address will be used. */
  86. static const size_t addr_mask[2] = { 0, (size_t)-1 };
  87. #endif
  88. #if defined(WOLFSSL_SP_NONBLOCK) && (!defined(WOLFSSL_SP_NO_MALLOC) || \
  89. !defined(WOLFSSL_SP_SMALL))
  90. #error SP non-blocking requires small and no-malloc (WOLFSSL_SP_SMALL and WOLFSSL_SP_NO_MALLOC)
  91. #endif
  92. #if defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)
  93. #ifndef WOLFSSL_SP_NO_2048
  94. /* Read big endian unsigned byte array into r.
  95. *
  96. * r A single precision integer.
  97. * size Maximum number of bytes to convert
  98. * a Byte array.
  99. * n Number of bytes in array to read.
  100. */
  101. static void sp_2048_from_bin(sp_digit* r, int size, const byte* a, int n)
  102. {
  103. int i;
  104. int j = 0;
  105. word32 s = 0;
  106. r[0] = 0;
  107. for (i = n-1; i >= 0; i--) {
  108. r[j] |= (((sp_digit)a[i]) << s);
  109. if (s >= 21U) {
  110. r[j] &= 0x1fffffff;
  111. s = 29U - s;
  112. if (j + 1 >= size) {
  113. break;
  114. }
  115. r[++j] = (sp_digit)a[i] >> s;
  116. s = 8U - s;
  117. }
  118. else {
  119. s += 8U;
  120. }
  121. }
  122. for (j++; j < size; j++) {
  123. r[j] = 0;
  124. }
  125. }
  126. /* Convert an mp_int to an array of sp_digit.
  127. *
  128. * r A single precision integer.
  129. * size Maximum number of bytes to convert
  130. * a A multi-precision integer.
  131. */
  132. static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
  133. {
  134. #if DIGIT_BIT == 29
  135. int i;
  136. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  137. int o = 0;
  138. for (i = 0; i < size; i++) {
  139. sp_digit mask = (sp_digit)0 - (j >> 28);
  140. r[i] = a->dp[o] & mask;
  141. j++;
  142. o += (int)(j >> 28);
  143. }
  144. #elif DIGIT_BIT > 29
  145. unsigned int i;
  146. int j = 0;
  147. word32 s = 0;
  148. r[0] = 0;
  149. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  150. r[j] |= ((sp_digit)a->dp[i] << s);
  151. r[j] &= 0x1fffffff;
  152. s = 29U - s;
  153. if (j + 1 >= size) {
  154. break;
  155. }
  156. /* lint allow cast of mismatch word32 and mp_digit */
  157. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  158. while ((s + 29U) <= (word32)DIGIT_BIT) {
  159. s += 29U;
  160. r[j] &= 0x1fffffff;
  161. if (j + 1 >= size) {
  162. break;
  163. }
  164. if (s < (word32)DIGIT_BIT) {
  165. /* lint allow cast of mismatch word32 and mp_digit */
  166. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  167. }
  168. else {
  169. r[++j] = (sp_digit)0;
  170. }
  171. }
  172. s = (word32)DIGIT_BIT - s;
  173. }
  174. for (j++; j < size; j++) {
  175. r[j] = 0;
  176. }
  177. #else
  178. unsigned int i;
  179. int j = 0;
  180. int s = 0;
  181. r[0] = 0;
  182. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  183. r[j] |= ((sp_digit)a->dp[i]) << s;
  184. if (s + DIGIT_BIT >= 29) {
  185. r[j] &= 0x1fffffff;
  186. if (j + 1 >= size) {
  187. break;
  188. }
  189. s = 29 - s;
  190. if (s == DIGIT_BIT) {
  191. r[++j] = 0;
  192. s = 0;
  193. }
  194. else {
  195. r[++j] = a->dp[i] >> s;
  196. s = DIGIT_BIT - s;
  197. }
  198. }
  199. else {
  200. s += DIGIT_BIT;
  201. }
  202. }
  203. for (j++; j < size; j++) {
  204. r[j] = 0;
  205. }
  206. #endif
  207. }
  208. /* Write r as big endian to byte array.
  209. * Fixed length number of bytes written: 256
  210. *
  211. * r A single precision integer.
  212. * a Byte array.
  213. */
  214. static void sp_2048_to_bin_72(sp_digit* r, byte* a)
  215. {
  216. int i;
  217. int j;
  218. int s = 0;
  219. int b;
  220. for (i=0; i<71; i++) {
  221. r[i+1] += r[i] >> 29;
  222. r[i] &= 0x1fffffff;
  223. }
  224. j = 2055 / 8 - 1;
  225. a[j] = 0;
  226. for (i=0; i<71 && j>=0; i++) {
  227. b = 0;
  228. /* lint allow cast of mismatch sp_digit and int */
  229. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  230. b += 8 - s;
  231. if (j < 0) {
  232. break;
  233. }
  234. while (b < 29) {
  235. a[j--] = (byte)(r[i] >> b);
  236. b += 8;
  237. if (j < 0) {
  238. break;
  239. }
  240. }
  241. s = 8 - (b - 29);
  242. if (j >= 0) {
  243. a[j] = 0;
  244. }
  245. if (s != 0) {
  246. j++;
  247. }
  248. }
  249. }
  250. #if (defined(WOLFSSL_HAVE_SP_RSA) && (!defined(WOLFSSL_RSA_PUBLIC_ONLY) || !defined(WOLFSSL_SP_SMALL))) || defined(WOLFSSL_HAVE_SP_DH)
  251. /* Normalize the values in each word to 29 bits.
  252. *
  253. * a Array of sp_digit to normalize.
  254. */
  255. static void sp_2048_norm_36(sp_digit* a)
  256. {
  257. #ifdef WOLFSSL_SP_SMALL
  258. int i;
  259. for (i = 0; i < 35; i++) {
  260. a[i+1] += a[i] >> 29;
  261. a[i] &= 0x1fffffff;
  262. }
  263. #else
  264. int i;
  265. for (i = 0; i < 32; i += 8) {
  266. a[i+1] += a[i+0] >> 29; a[i+0] &= 0x1fffffff;
  267. a[i+2] += a[i+1] >> 29; a[i+1] &= 0x1fffffff;
  268. a[i+3] += a[i+2] >> 29; a[i+2] &= 0x1fffffff;
  269. a[i+4] += a[i+3] >> 29; a[i+3] &= 0x1fffffff;
  270. a[i+5] += a[i+4] >> 29; a[i+4] &= 0x1fffffff;
  271. a[i+6] += a[i+5] >> 29; a[i+5] &= 0x1fffffff;
  272. a[i+7] += a[i+6] >> 29; a[i+6] &= 0x1fffffff;
  273. a[i+8] += a[i+7] >> 29; a[i+7] &= 0x1fffffff;
  274. }
  275. a[33] += a[32] >> 29; a[32] &= 0x1fffffff;
  276. a[34] += a[33] >> 29; a[33] &= 0x1fffffff;
  277. a[35] += a[34] >> 29; a[34] &= 0x1fffffff;
  278. #endif /* WOLFSSL_SP_SMALL */
  279. }
  280. #endif /* (WOLFSSL_HAVE_SP_RSA && (!WOLFSSL_RSA_PUBLIC_ONLY || !WOLFSSL_SP_SMALL)) || WOLFSSL_HAVE_SP_DH */
  281. /* Normalize the values in each word to 29 bits.
  282. *
  283. * a Array of sp_digit to normalize.
  284. */
  285. static void sp_2048_norm_72(sp_digit* a)
  286. {
  287. #ifdef WOLFSSL_SP_SMALL
  288. int i;
  289. for (i = 0; i < 71; i++) {
  290. a[i+1] += a[i] >> 29;
  291. a[i] &= 0x1fffffff;
  292. }
  293. #else
  294. int i;
  295. for (i = 0; i < 64; i += 8) {
  296. a[i+1] += a[i+0] >> 29; a[i+0] &= 0x1fffffff;
  297. a[i+2] += a[i+1] >> 29; a[i+1] &= 0x1fffffff;
  298. a[i+3] += a[i+2] >> 29; a[i+2] &= 0x1fffffff;
  299. a[i+4] += a[i+3] >> 29; a[i+3] &= 0x1fffffff;
  300. a[i+5] += a[i+4] >> 29; a[i+4] &= 0x1fffffff;
  301. a[i+6] += a[i+5] >> 29; a[i+5] &= 0x1fffffff;
  302. a[i+7] += a[i+6] >> 29; a[i+6] &= 0x1fffffff;
  303. a[i+8] += a[i+7] >> 29; a[i+7] &= 0x1fffffff;
  304. }
  305. a[65] += a[64] >> 29; a[64] &= 0x1fffffff;
  306. a[66] += a[65] >> 29; a[65] &= 0x1fffffff;
  307. a[67] += a[66] >> 29; a[66] &= 0x1fffffff;
  308. a[68] += a[67] >> 29; a[67] &= 0x1fffffff;
  309. a[69] += a[68] >> 29; a[68] &= 0x1fffffff;
  310. a[70] += a[69] >> 29; a[69] &= 0x1fffffff;
  311. a[71] += a[70] >> 29; a[70] &= 0x1fffffff;
  312. #endif /* WOLFSSL_SP_SMALL */
  313. }
  314. #ifndef WOLFSSL_SP_SMALL
  315. /* Multiply a and b into r. (r = a * b)
  316. *
  317. * r A single precision integer.
  318. * a A single precision integer.
  319. * b A single precision integer.
  320. */
  321. SP_NOINLINE static void sp_2048_mul_12(sp_digit* r, const sp_digit* a,
  322. const sp_digit* b)
  323. {
  324. sp_uint64 t0;
  325. sp_uint64 t1;
  326. sp_digit t[12];
  327. t0 = ((sp_uint64)a[ 0]) * b[ 0];
  328. t1 = ((sp_uint64)a[ 0]) * b[ 1]
  329. + ((sp_uint64)a[ 1]) * b[ 0];
  330. t[ 0] = t0 & 0x1fffffff; t1 += t0 >> 29;
  331. t0 = ((sp_uint64)a[ 0]) * b[ 2]
  332. + ((sp_uint64)a[ 1]) * b[ 1]
  333. + ((sp_uint64)a[ 2]) * b[ 0];
  334. t[ 1] = t1 & 0x1fffffff; t0 += t1 >> 29;
  335. t1 = ((sp_uint64)a[ 0]) * b[ 3]
  336. + ((sp_uint64)a[ 1]) * b[ 2]
  337. + ((sp_uint64)a[ 2]) * b[ 1]
  338. + ((sp_uint64)a[ 3]) * b[ 0];
  339. t[ 2] = t0 & 0x1fffffff; t1 += t0 >> 29;
  340. t0 = ((sp_uint64)a[ 0]) * b[ 4]
  341. + ((sp_uint64)a[ 1]) * b[ 3]
  342. + ((sp_uint64)a[ 2]) * b[ 2]
  343. + ((sp_uint64)a[ 3]) * b[ 1]
  344. + ((sp_uint64)a[ 4]) * b[ 0];
  345. t[ 3] = t1 & 0x1fffffff; t0 += t1 >> 29;
  346. t1 = ((sp_uint64)a[ 0]) * b[ 5]
  347. + ((sp_uint64)a[ 1]) * b[ 4]
  348. + ((sp_uint64)a[ 2]) * b[ 3]
  349. + ((sp_uint64)a[ 3]) * b[ 2]
  350. + ((sp_uint64)a[ 4]) * b[ 1]
  351. + ((sp_uint64)a[ 5]) * b[ 0];
  352. t[ 4] = t0 & 0x1fffffff; t1 += t0 >> 29;
  353. t0 = ((sp_uint64)a[ 0]) * b[ 6]
  354. + ((sp_uint64)a[ 1]) * b[ 5]
  355. + ((sp_uint64)a[ 2]) * b[ 4]
  356. + ((sp_uint64)a[ 3]) * b[ 3]
  357. + ((sp_uint64)a[ 4]) * b[ 2]
  358. + ((sp_uint64)a[ 5]) * b[ 1]
  359. + ((sp_uint64)a[ 6]) * b[ 0];
  360. t[ 5] = t1 & 0x1fffffff; t0 += t1 >> 29;
  361. t1 = ((sp_uint64)a[ 0]) * b[ 7]
  362. + ((sp_uint64)a[ 1]) * b[ 6]
  363. + ((sp_uint64)a[ 2]) * b[ 5]
  364. + ((sp_uint64)a[ 3]) * b[ 4]
  365. + ((sp_uint64)a[ 4]) * b[ 3]
  366. + ((sp_uint64)a[ 5]) * b[ 2]
  367. + ((sp_uint64)a[ 6]) * b[ 1]
  368. + ((sp_uint64)a[ 7]) * b[ 0];
  369. t[ 6] = t0 & 0x1fffffff; t1 += t0 >> 29;
  370. t0 = ((sp_uint64)a[ 0]) * b[ 8]
  371. + ((sp_uint64)a[ 1]) * b[ 7]
  372. + ((sp_uint64)a[ 2]) * b[ 6]
  373. + ((sp_uint64)a[ 3]) * b[ 5]
  374. + ((sp_uint64)a[ 4]) * b[ 4]
  375. + ((sp_uint64)a[ 5]) * b[ 3]
  376. + ((sp_uint64)a[ 6]) * b[ 2]
  377. + ((sp_uint64)a[ 7]) * b[ 1]
  378. + ((sp_uint64)a[ 8]) * b[ 0];
  379. t[ 7] = t1 & 0x1fffffff; t0 += t1 >> 29;
  380. t1 = ((sp_uint64)a[ 0]) * b[ 9]
  381. + ((sp_uint64)a[ 1]) * b[ 8]
  382. + ((sp_uint64)a[ 2]) * b[ 7]
  383. + ((sp_uint64)a[ 3]) * b[ 6]
  384. + ((sp_uint64)a[ 4]) * b[ 5]
  385. + ((sp_uint64)a[ 5]) * b[ 4]
  386. + ((sp_uint64)a[ 6]) * b[ 3]
  387. + ((sp_uint64)a[ 7]) * b[ 2]
  388. + ((sp_uint64)a[ 8]) * b[ 1]
  389. + ((sp_uint64)a[ 9]) * b[ 0];
  390. t[ 8] = t0 & 0x1fffffff; t1 += t0 >> 29;
  391. t0 = ((sp_uint64)a[ 0]) * b[10]
  392. + ((sp_uint64)a[ 1]) * b[ 9]
  393. + ((sp_uint64)a[ 2]) * b[ 8]
  394. + ((sp_uint64)a[ 3]) * b[ 7]
  395. + ((sp_uint64)a[ 4]) * b[ 6]
  396. + ((sp_uint64)a[ 5]) * b[ 5]
  397. + ((sp_uint64)a[ 6]) * b[ 4]
  398. + ((sp_uint64)a[ 7]) * b[ 3]
  399. + ((sp_uint64)a[ 8]) * b[ 2]
  400. + ((sp_uint64)a[ 9]) * b[ 1]
  401. + ((sp_uint64)a[10]) * b[ 0];
  402. t[ 9] = t1 & 0x1fffffff; t0 += t1 >> 29;
  403. t1 = ((sp_uint64)a[ 0]) * b[11]
  404. + ((sp_uint64)a[ 1]) * b[10]
  405. + ((sp_uint64)a[ 2]) * b[ 9]
  406. + ((sp_uint64)a[ 3]) * b[ 8]
  407. + ((sp_uint64)a[ 4]) * b[ 7]
  408. + ((sp_uint64)a[ 5]) * b[ 6]
  409. + ((sp_uint64)a[ 6]) * b[ 5]
  410. + ((sp_uint64)a[ 7]) * b[ 4]
  411. + ((sp_uint64)a[ 8]) * b[ 3]
  412. + ((sp_uint64)a[ 9]) * b[ 2]
  413. + ((sp_uint64)a[10]) * b[ 1]
  414. + ((sp_uint64)a[11]) * b[ 0];
  415. t[10] = t0 & 0x1fffffff; t1 += t0 >> 29;
  416. t0 = ((sp_uint64)a[ 1]) * b[11]
  417. + ((sp_uint64)a[ 2]) * b[10]
  418. + ((sp_uint64)a[ 3]) * b[ 9]
  419. + ((sp_uint64)a[ 4]) * b[ 8]
  420. + ((sp_uint64)a[ 5]) * b[ 7]
  421. + ((sp_uint64)a[ 6]) * b[ 6]
  422. + ((sp_uint64)a[ 7]) * b[ 5]
  423. + ((sp_uint64)a[ 8]) * b[ 4]
  424. + ((sp_uint64)a[ 9]) * b[ 3]
  425. + ((sp_uint64)a[10]) * b[ 2]
  426. + ((sp_uint64)a[11]) * b[ 1];
  427. t[11] = t1 & 0x1fffffff; t0 += t1 >> 29;
  428. t1 = ((sp_uint64)a[ 2]) * b[11]
  429. + ((sp_uint64)a[ 3]) * b[10]
  430. + ((sp_uint64)a[ 4]) * b[ 9]
  431. + ((sp_uint64)a[ 5]) * b[ 8]
  432. + ((sp_uint64)a[ 6]) * b[ 7]
  433. + ((sp_uint64)a[ 7]) * b[ 6]
  434. + ((sp_uint64)a[ 8]) * b[ 5]
  435. + ((sp_uint64)a[ 9]) * b[ 4]
  436. + ((sp_uint64)a[10]) * b[ 3]
  437. + ((sp_uint64)a[11]) * b[ 2];
  438. r[12] = t0 & 0x1fffffff; t1 += t0 >> 29;
  439. t0 = ((sp_uint64)a[ 3]) * b[11]
  440. + ((sp_uint64)a[ 4]) * b[10]
  441. + ((sp_uint64)a[ 5]) * b[ 9]
  442. + ((sp_uint64)a[ 6]) * b[ 8]
  443. + ((sp_uint64)a[ 7]) * b[ 7]
  444. + ((sp_uint64)a[ 8]) * b[ 6]
  445. + ((sp_uint64)a[ 9]) * b[ 5]
  446. + ((sp_uint64)a[10]) * b[ 4]
  447. + ((sp_uint64)a[11]) * b[ 3];
  448. r[13] = t1 & 0x1fffffff; t0 += t1 >> 29;
  449. t1 = ((sp_uint64)a[ 4]) * b[11]
  450. + ((sp_uint64)a[ 5]) * b[10]
  451. + ((sp_uint64)a[ 6]) * b[ 9]
  452. + ((sp_uint64)a[ 7]) * b[ 8]
  453. + ((sp_uint64)a[ 8]) * b[ 7]
  454. + ((sp_uint64)a[ 9]) * b[ 6]
  455. + ((sp_uint64)a[10]) * b[ 5]
  456. + ((sp_uint64)a[11]) * b[ 4];
  457. r[14] = t0 & 0x1fffffff; t1 += t0 >> 29;
  458. t0 = ((sp_uint64)a[ 5]) * b[11]
  459. + ((sp_uint64)a[ 6]) * b[10]
  460. + ((sp_uint64)a[ 7]) * b[ 9]
  461. + ((sp_uint64)a[ 8]) * b[ 8]
  462. + ((sp_uint64)a[ 9]) * b[ 7]
  463. + ((sp_uint64)a[10]) * b[ 6]
  464. + ((sp_uint64)a[11]) * b[ 5];
  465. r[15] = t1 & 0x1fffffff; t0 += t1 >> 29;
  466. t1 = ((sp_uint64)a[ 6]) * b[11]
  467. + ((sp_uint64)a[ 7]) * b[10]
  468. + ((sp_uint64)a[ 8]) * b[ 9]
  469. + ((sp_uint64)a[ 9]) * b[ 8]
  470. + ((sp_uint64)a[10]) * b[ 7]
  471. + ((sp_uint64)a[11]) * b[ 6];
  472. r[16] = t0 & 0x1fffffff; t1 += t0 >> 29;
  473. t0 = ((sp_uint64)a[ 7]) * b[11]
  474. + ((sp_uint64)a[ 8]) * b[10]
  475. + ((sp_uint64)a[ 9]) * b[ 9]
  476. + ((sp_uint64)a[10]) * b[ 8]
  477. + ((sp_uint64)a[11]) * b[ 7];
  478. r[17] = t1 & 0x1fffffff; t0 += t1 >> 29;
  479. t1 = ((sp_uint64)a[ 8]) * b[11]
  480. + ((sp_uint64)a[ 9]) * b[10]
  481. + ((sp_uint64)a[10]) * b[ 9]
  482. + ((sp_uint64)a[11]) * b[ 8];
  483. r[18] = t0 & 0x1fffffff; t1 += t0 >> 29;
  484. t0 = ((sp_uint64)a[ 9]) * b[11]
  485. + ((sp_uint64)a[10]) * b[10]
  486. + ((sp_uint64)a[11]) * b[ 9];
  487. r[19] = t1 & 0x1fffffff; t0 += t1 >> 29;
  488. t1 = ((sp_uint64)a[10]) * b[11]
  489. + ((sp_uint64)a[11]) * b[10];
  490. r[20] = t0 & 0x1fffffff; t1 += t0 >> 29;
  491. t0 = ((sp_uint64)a[11]) * b[11];
  492. r[21] = t1 & 0x1fffffff; t0 += t1 >> 29;
  493. r[22] = t0 & 0x1fffffff;
  494. r[23] = (sp_digit)(t0 >> 29);
  495. XMEMCPY(r, t, sizeof(t));
  496. }
  497. /* Add b to a into r. (r = a + b)
  498. *
  499. * r A single precision integer.
  500. * a A single precision integer.
  501. * b A single precision integer.
  502. */
  503. SP_NOINLINE static int sp_2048_add_12(sp_digit* r, const sp_digit* a,
  504. const sp_digit* b)
  505. {
  506. r[ 0] = a[ 0] + b[ 0];
  507. r[ 1] = a[ 1] + b[ 1];
  508. r[ 2] = a[ 2] + b[ 2];
  509. r[ 3] = a[ 3] + b[ 3];
  510. r[ 4] = a[ 4] + b[ 4];
  511. r[ 5] = a[ 5] + b[ 5];
  512. r[ 6] = a[ 6] + b[ 6];
  513. r[ 7] = a[ 7] + b[ 7];
  514. r[ 8] = a[ 8] + b[ 8];
  515. r[ 9] = a[ 9] + b[ 9];
  516. r[10] = a[10] + b[10];
  517. r[11] = a[11] + b[11];
  518. return 0;
  519. }
  520. /* Sub b from a into r. (r = a - b)
  521. *
  522. * r A single precision integer.
  523. * a A single precision integer.
  524. * b A single precision integer.
  525. */
  526. SP_NOINLINE static int sp_2048_sub_24(sp_digit* r, const sp_digit* a,
  527. const sp_digit* b)
  528. {
  529. int i;
  530. for (i = 0; i < 24; i += 8) {
  531. r[i + 0] = a[i + 0] - b[i + 0];
  532. r[i + 1] = a[i + 1] - b[i + 1];
  533. r[i + 2] = a[i + 2] - b[i + 2];
  534. r[i + 3] = a[i + 3] - b[i + 3];
  535. r[i + 4] = a[i + 4] - b[i + 4];
  536. r[i + 5] = a[i + 5] - b[i + 5];
  537. r[i + 6] = a[i + 6] - b[i + 6];
  538. r[i + 7] = a[i + 7] - b[i + 7];
  539. }
  540. return 0;
  541. }
  542. /* Add b to a into r. (r = a + b)
  543. *
  544. * r A single precision integer.
  545. * a A single precision integer.
  546. * b A single precision integer.
  547. */
  548. SP_NOINLINE static int sp_2048_add_24(sp_digit* r, const sp_digit* a,
  549. const sp_digit* b)
  550. {
  551. int i;
  552. for (i = 0; i < 24; i += 8) {
  553. r[i + 0] = a[i + 0] + b[i + 0];
  554. r[i + 1] = a[i + 1] + b[i + 1];
  555. r[i + 2] = a[i + 2] + b[i + 2];
  556. r[i + 3] = a[i + 3] + b[i + 3];
  557. r[i + 4] = a[i + 4] + b[i + 4];
  558. r[i + 5] = a[i + 5] + b[i + 5];
  559. r[i + 6] = a[i + 6] + b[i + 6];
  560. r[i + 7] = a[i + 7] + b[i + 7];
  561. }
  562. return 0;
  563. }
  564. /* Normalize the values in each word to 29 bits.
  565. *
  566. * a Array of sp_digit to normalize.
  567. */
  568. static void sp_2048_norm_12(sp_digit* a)
  569. {
  570. #ifdef WOLFSSL_SP_SMALL
  571. int i;
  572. for (i = 0; i < 11; i++) {
  573. a[i+1] += a[i] >> 29;
  574. a[i] &= 0x1fffffff;
  575. }
  576. #else
  577. a[1] += a[0] >> 29; a[0] &= 0x1fffffff;
  578. a[2] += a[1] >> 29; a[1] &= 0x1fffffff;
  579. a[3] += a[2] >> 29; a[2] &= 0x1fffffff;
  580. a[4] += a[3] >> 29; a[3] &= 0x1fffffff;
  581. a[5] += a[4] >> 29; a[4] &= 0x1fffffff;
  582. a[6] += a[5] >> 29; a[5] &= 0x1fffffff;
  583. a[7] += a[6] >> 29; a[6] &= 0x1fffffff;
  584. a[8] += a[7] >> 29; a[7] &= 0x1fffffff;
  585. a[9] += a[8] >> 29; a[8] &= 0x1fffffff;
  586. a[10] += a[9] >> 29; a[9] &= 0x1fffffff;
  587. a[11] += a[10] >> 29; a[10] &= 0x1fffffff;
  588. #endif /* WOLFSSL_SP_SMALL */
  589. }
  590. /* Normalize the values in each word to 29 bits.
  591. *
  592. * a Array of sp_digit to normalize.
  593. */
  594. static void sp_2048_norm_24(sp_digit* a)
  595. {
  596. #ifdef WOLFSSL_SP_SMALL
  597. int i;
  598. for (i = 0; i < 23; i++) {
  599. a[i+1] += a[i] >> 29;
  600. a[i] &= 0x1fffffff;
  601. }
  602. #else
  603. int i;
  604. for (i = 0; i < 16; i += 8) {
  605. a[i+1] += a[i+0] >> 29; a[i+0] &= 0x1fffffff;
  606. a[i+2] += a[i+1] >> 29; a[i+1] &= 0x1fffffff;
  607. a[i+3] += a[i+2] >> 29; a[i+2] &= 0x1fffffff;
  608. a[i+4] += a[i+3] >> 29; a[i+3] &= 0x1fffffff;
  609. a[i+5] += a[i+4] >> 29; a[i+4] &= 0x1fffffff;
  610. a[i+6] += a[i+5] >> 29; a[i+5] &= 0x1fffffff;
  611. a[i+7] += a[i+6] >> 29; a[i+6] &= 0x1fffffff;
  612. a[i+8] += a[i+7] >> 29; a[i+7] &= 0x1fffffff;
  613. }
  614. a[17] += a[16] >> 29; a[16] &= 0x1fffffff;
  615. a[18] += a[17] >> 29; a[17] &= 0x1fffffff;
  616. a[19] += a[18] >> 29; a[18] &= 0x1fffffff;
  617. a[20] += a[19] >> 29; a[19] &= 0x1fffffff;
  618. a[21] += a[20] >> 29; a[20] &= 0x1fffffff;
  619. a[22] += a[21] >> 29; a[21] &= 0x1fffffff;
  620. a[23] += a[22] >> 29; a[22] &= 0x1fffffff;
  621. #endif /* WOLFSSL_SP_SMALL */
  622. }
  623. /* Multiply a and b into r. (r = a * b)
  624. *
  625. * r A single precision integer.
  626. * a A single precision integer.
  627. * b A single precision integer.
  628. */
  629. SP_NOINLINE static void sp_2048_mul_36(sp_digit* r, const sp_digit* a,
  630. const sp_digit* b)
  631. {
  632. sp_digit p0[24];
  633. sp_digit p1[24];
  634. sp_digit p2[24];
  635. sp_digit p3[24];
  636. sp_digit p4[24];
  637. sp_digit p5[24];
  638. sp_digit t0[24];
  639. sp_digit t1[24];
  640. sp_digit t2[24];
  641. sp_digit a0[12];
  642. sp_digit a1[12];
  643. sp_digit a2[12];
  644. sp_digit b0[12];
  645. sp_digit b1[12];
  646. sp_digit b2[12];
  647. (void)sp_2048_add_12(a0, a, &a[12]);
  648. sp_2048_norm_12(a0);
  649. (void)sp_2048_add_12(b0, b, &b[12]);
  650. sp_2048_norm_12(b0);
  651. (void)sp_2048_add_12(a1, &a[12], &a[24]);
  652. sp_2048_norm_12(a1);
  653. (void)sp_2048_add_12(b1, &b[12], &b[24]);
  654. sp_2048_norm_12(b1);
  655. (void)sp_2048_add_12(a2, a0, &a[24]);
  656. sp_2048_norm_12(a1);
  657. (void)sp_2048_add_12(b2, b0, &b[24]);
  658. sp_2048_norm_12(b2);
  659. sp_2048_mul_12(p0, a, b);
  660. sp_2048_mul_12(p2, &a[12], &b[12]);
  661. sp_2048_mul_12(p4, &a[24], &b[24]);
  662. sp_2048_mul_12(p1, a0, b0);
  663. sp_2048_mul_12(p3, a1, b1);
  664. sp_2048_mul_12(p5, a2, b2);
  665. XMEMSET(r, 0, sizeof(*r)*2U*36U);
  666. (void)sp_2048_sub_24(t0, p3, p2);
  667. (void)sp_2048_sub_24(t1, p1, p2);
  668. (void)sp_2048_sub_24(t2, p5, t0);
  669. (void)sp_2048_sub_24(t2, t2, t1);
  670. sp_2048_norm_24(t2);
  671. (void)sp_2048_sub_24(t0, t0, p4);
  672. sp_2048_norm_24(t0);
  673. (void)sp_2048_sub_24(t1, t1, p0);
  674. sp_2048_norm_24(t1);
  675. (void)sp_2048_add_24(r, r, p0);
  676. (void)sp_2048_add_24(&r[12], &r[12], t1);
  677. (void)sp_2048_add_24(&r[24], &r[24], t2);
  678. (void)sp_2048_add_24(&r[36], &r[36], t0);
  679. (void)sp_2048_add_24(&r[48], &r[48], p4);
  680. sp_2048_norm_72(r);
  681. }
  682. /* Add b to a into r. (r = a + b)
  683. *
  684. * r A single precision integer.
  685. * a A single precision integer.
  686. * b A single precision integer.
  687. */
  688. SP_NOINLINE static int sp_2048_add_36(sp_digit* r, const sp_digit* a,
  689. const sp_digit* b)
  690. {
  691. int i;
  692. for (i = 0; i < 32; i += 8) {
  693. r[i + 0] = a[i + 0] + b[i + 0];
  694. r[i + 1] = a[i + 1] + b[i + 1];
  695. r[i + 2] = a[i + 2] + b[i + 2];
  696. r[i + 3] = a[i + 3] + b[i + 3];
  697. r[i + 4] = a[i + 4] + b[i + 4];
  698. r[i + 5] = a[i + 5] + b[i + 5];
  699. r[i + 6] = a[i + 6] + b[i + 6];
  700. r[i + 7] = a[i + 7] + b[i + 7];
  701. }
  702. r[32] = a[32] + b[32];
  703. r[33] = a[33] + b[33];
  704. r[34] = a[34] + b[34];
  705. r[35] = a[35] + b[35];
  706. return 0;
  707. }
  708. /* Add b to a into r. (r = a + b)
  709. *
  710. * r A single precision integer.
  711. * a A single precision integer.
  712. * b A single precision integer.
  713. */
  714. SP_NOINLINE static int sp_2048_add_72(sp_digit* r, const sp_digit* a,
  715. const sp_digit* b)
  716. {
  717. int i;
  718. for (i = 0; i < 72; i += 8) {
  719. r[i + 0] = a[i + 0] + b[i + 0];
  720. r[i + 1] = a[i + 1] + b[i + 1];
  721. r[i + 2] = a[i + 2] + b[i + 2];
  722. r[i + 3] = a[i + 3] + b[i + 3];
  723. r[i + 4] = a[i + 4] + b[i + 4];
  724. r[i + 5] = a[i + 5] + b[i + 5];
  725. r[i + 6] = a[i + 6] + b[i + 6];
  726. r[i + 7] = a[i + 7] + b[i + 7];
  727. }
  728. return 0;
  729. }
  730. /* Sub b from a into r. (r = a - b)
  731. *
  732. * r A single precision integer.
  733. * a A single precision integer.
  734. * b A single precision integer.
  735. */
  736. SP_NOINLINE static int sp_2048_sub_72(sp_digit* r, const sp_digit* a,
  737. const sp_digit* b)
  738. {
  739. int i;
  740. for (i = 0; i < 72; i += 8) {
  741. r[i + 0] = a[i + 0] - b[i + 0];
  742. r[i + 1] = a[i + 1] - b[i + 1];
  743. r[i + 2] = a[i + 2] - b[i + 2];
  744. r[i + 3] = a[i + 3] - b[i + 3];
  745. r[i + 4] = a[i + 4] - b[i + 4];
  746. r[i + 5] = a[i + 5] - b[i + 5];
  747. r[i + 6] = a[i + 6] - b[i + 6];
  748. r[i + 7] = a[i + 7] - b[i + 7];
  749. }
  750. return 0;
  751. }
  752. /* Normalize the values in each word to 29 bits.
  753. *
  754. * a Array of sp_digit to normalize.
  755. */
  756. static void sp_2048_norm_144(sp_digit* a)
  757. {
  758. #ifdef WOLFSSL_SP_SMALL
  759. int i;
  760. for (i = 0; i < 143; i++) {
  761. a[i+1] += a[i] >> 29;
  762. a[i] &= 0x1fffffff;
  763. }
  764. #else
  765. int i;
  766. for (i = 0; i < 136; i += 8) {
  767. a[i+1] += a[i+0] >> 29; a[i+0] &= 0x1fffffff;
  768. a[i+2] += a[i+1] >> 29; a[i+1] &= 0x1fffffff;
  769. a[i+3] += a[i+2] >> 29; a[i+2] &= 0x1fffffff;
  770. a[i+4] += a[i+3] >> 29; a[i+3] &= 0x1fffffff;
  771. a[i+5] += a[i+4] >> 29; a[i+4] &= 0x1fffffff;
  772. a[i+6] += a[i+5] >> 29; a[i+5] &= 0x1fffffff;
  773. a[i+7] += a[i+6] >> 29; a[i+6] &= 0x1fffffff;
  774. a[i+8] += a[i+7] >> 29; a[i+7] &= 0x1fffffff;
  775. }
  776. a[137] += a[136] >> 29; a[136] &= 0x1fffffff;
  777. a[138] += a[137] >> 29; a[137] &= 0x1fffffff;
  778. a[139] += a[138] >> 29; a[138] &= 0x1fffffff;
  779. a[140] += a[139] >> 29; a[139] &= 0x1fffffff;
  780. a[141] += a[140] >> 29; a[140] &= 0x1fffffff;
  781. a[142] += a[141] >> 29; a[141] &= 0x1fffffff;
  782. a[143] += a[142] >> 29; a[142] &= 0x1fffffff;
  783. #endif /* WOLFSSL_SP_SMALL */
  784. }
  785. /* Multiply a and b into r. (r = a * b)
  786. *
  787. * r A single precision integer.
  788. * a A single precision integer.
  789. * b A single precision integer.
  790. */
  791. SP_NOINLINE static void sp_2048_mul_72(sp_digit* r, const sp_digit* a,
  792. const sp_digit* b)
  793. {
  794. sp_digit* z0 = r;
  795. sp_digit z1[72];
  796. sp_digit* a1 = z1;
  797. sp_digit b1[36];
  798. sp_digit* z2 = r + 72;
  799. (void)sp_2048_add_36(a1, a, &a[36]);
  800. sp_2048_norm_36(a1);
  801. (void)sp_2048_add_36(b1, b, &b[36]);
  802. sp_2048_norm_36(b1);
  803. sp_2048_mul_36(z2, &a[36], &b[36]);
  804. sp_2048_mul_36(z0, a, b);
  805. sp_2048_mul_36(z1, a1, b1);
  806. (void)sp_2048_sub_72(z1, z1, z2);
  807. (void)sp_2048_sub_72(z1, z1, z0);
  808. (void)sp_2048_add_72(r + 36, r + 36, z1);
  809. sp_2048_norm_144(r);
  810. }
  811. /* Square a and put result in r. (r = a * a)
  812. *
  813. * r A single precision integer.
  814. * a A single precision integer.
  815. */
  816. SP_NOINLINE static void sp_2048_sqr_12(sp_digit* r, const sp_digit* a)
  817. {
  818. sp_uint64 t0;
  819. sp_uint64 t1;
  820. sp_digit t[12];
  821. t0 = ((sp_uint64)a[ 0]) * a[ 0];
  822. t1 = (((sp_uint64)a[ 0]) * a[ 1]) * 2;
  823. t[ 0] = t0 & 0x1fffffff; t1 += t0 >> 29;
  824. t0 = (((sp_uint64)a[ 0]) * a[ 2]) * 2
  825. + ((sp_uint64)a[ 1]) * a[ 1];
  826. t[ 1] = t1 & 0x1fffffff; t0 += t1 >> 29;
  827. t1 = (((sp_uint64)a[ 0]) * a[ 3]
  828. + ((sp_uint64)a[ 1]) * a[ 2]) * 2;
  829. t[ 2] = t0 & 0x1fffffff; t1 += t0 >> 29;
  830. t0 = (((sp_uint64)a[ 0]) * a[ 4]
  831. + ((sp_uint64)a[ 1]) * a[ 3]) * 2
  832. + ((sp_uint64)a[ 2]) * a[ 2];
  833. t[ 3] = t1 & 0x1fffffff; t0 += t1 >> 29;
  834. t1 = (((sp_uint64)a[ 0]) * a[ 5]
  835. + ((sp_uint64)a[ 1]) * a[ 4]
  836. + ((sp_uint64)a[ 2]) * a[ 3]) * 2;
  837. t[ 4] = t0 & 0x1fffffff; t1 += t0 >> 29;
  838. t0 = (((sp_uint64)a[ 0]) * a[ 6]
  839. + ((sp_uint64)a[ 1]) * a[ 5]
  840. + ((sp_uint64)a[ 2]) * a[ 4]) * 2
  841. + ((sp_uint64)a[ 3]) * a[ 3];
  842. t[ 5] = t1 & 0x1fffffff; t0 += t1 >> 29;
  843. t1 = (((sp_uint64)a[ 0]) * a[ 7]
  844. + ((sp_uint64)a[ 1]) * a[ 6]
  845. + ((sp_uint64)a[ 2]) * a[ 5]
  846. + ((sp_uint64)a[ 3]) * a[ 4]) * 2;
  847. t[ 6] = t0 & 0x1fffffff; t1 += t0 >> 29;
  848. t0 = (((sp_uint64)a[ 0]) * a[ 8]
  849. + ((sp_uint64)a[ 1]) * a[ 7]
  850. + ((sp_uint64)a[ 2]) * a[ 6]
  851. + ((sp_uint64)a[ 3]) * a[ 5]) * 2
  852. + ((sp_uint64)a[ 4]) * a[ 4];
  853. t[ 7] = t1 & 0x1fffffff; t0 += t1 >> 29;
  854. t1 = (((sp_uint64)a[ 0]) * a[ 9]
  855. + ((sp_uint64)a[ 1]) * a[ 8]
  856. + ((sp_uint64)a[ 2]) * a[ 7]
  857. + ((sp_uint64)a[ 3]) * a[ 6]
  858. + ((sp_uint64)a[ 4]) * a[ 5]) * 2;
  859. t[ 8] = t0 & 0x1fffffff; t1 += t0 >> 29;
  860. t0 = (((sp_uint64)a[ 0]) * a[10]
  861. + ((sp_uint64)a[ 1]) * a[ 9]
  862. + ((sp_uint64)a[ 2]) * a[ 8]
  863. + ((sp_uint64)a[ 3]) * a[ 7]
  864. + ((sp_uint64)a[ 4]) * a[ 6]) * 2
  865. + ((sp_uint64)a[ 5]) * a[ 5];
  866. t[ 9] = t1 & 0x1fffffff; t0 += t1 >> 29;
  867. t1 = (((sp_uint64)a[ 0]) * a[11]
  868. + ((sp_uint64)a[ 1]) * a[10]
  869. + ((sp_uint64)a[ 2]) * a[ 9]
  870. + ((sp_uint64)a[ 3]) * a[ 8]
  871. + ((sp_uint64)a[ 4]) * a[ 7]
  872. + ((sp_uint64)a[ 5]) * a[ 6]) * 2;
  873. t[10] = t0 & 0x1fffffff; t1 += t0 >> 29;
  874. t0 = (((sp_uint64)a[ 1]) * a[11]
  875. + ((sp_uint64)a[ 2]) * a[10]
  876. + ((sp_uint64)a[ 3]) * a[ 9]
  877. + ((sp_uint64)a[ 4]) * a[ 8]
  878. + ((sp_uint64)a[ 5]) * a[ 7]) * 2
  879. + ((sp_uint64)a[ 6]) * a[ 6];
  880. t[11] = t1 & 0x1fffffff; t0 += t1 >> 29;
  881. t1 = (((sp_uint64)a[ 2]) * a[11]
  882. + ((sp_uint64)a[ 3]) * a[10]
  883. + ((sp_uint64)a[ 4]) * a[ 9]
  884. + ((sp_uint64)a[ 5]) * a[ 8]
  885. + ((sp_uint64)a[ 6]) * a[ 7]) * 2;
  886. r[12] = t0 & 0x1fffffff; t1 += t0 >> 29;
  887. t0 = (((sp_uint64)a[ 3]) * a[11]
  888. + ((sp_uint64)a[ 4]) * a[10]
  889. + ((sp_uint64)a[ 5]) * a[ 9]
  890. + ((sp_uint64)a[ 6]) * a[ 8]) * 2
  891. + ((sp_uint64)a[ 7]) * a[ 7];
  892. r[13] = t1 & 0x1fffffff; t0 += t1 >> 29;
  893. t1 = (((sp_uint64)a[ 4]) * a[11]
  894. + ((sp_uint64)a[ 5]) * a[10]
  895. + ((sp_uint64)a[ 6]) * a[ 9]
  896. + ((sp_uint64)a[ 7]) * a[ 8]) * 2;
  897. r[14] = t0 & 0x1fffffff; t1 += t0 >> 29;
  898. t0 = (((sp_uint64)a[ 5]) * a[11]
  899. + ((sp_uint64)a[ 6]) * a[10]
  900. + ((sp_uint64)a[ 7]) * a[ 9]) * 2
  901. + ((sp_uint64)a[ 8]) * a[ 8];
  902. r[15] = t1 & 0x1fffffff; t0 += t1 >> 29;
  903. t1 = (((sp_uint64)a[ 6]) * a[11]
  904. + ((sp_uint64)a[ 7]) * a[10]
  905. + ((sp_uint64)a[ 8]) * a[ 9]) * 2;
  906. r[16] = t0 & 0x1fffffff; t1 += t0 >> 29;
  907. t0 = (((sp_uint64)a[ 7]) * a[11]
  908. + ((sp_uint64)a[ 8]) * a[10]) * 2
  909. + ((sp_uint64)a[ 9]) * a[ 9];
  910. r[17] = t1 & 0x1fffffff; t0 += t1 >> 29;
  911. t1 = (((sp_uint64)a[ 8]) * a[11]
  912. + ((sp_uint64)a[ 9]) * a[10]) * 2;
  913. r[18] = t0 & 0x1fffffff; t1 += t0 >> 29;
  914. t0 = (((sp_uint64)a[ 9]) * a[11]) * 2
  915. + ((sp_uint64)a[10]) * a[10];
  916. r[19] = t1 & 0x1fffffff; t0 += t1 >> 29;
  917. t1 = (((sp_uint64)a[10]) * a[11]) * 2;
  918. r[20] = t0 & 0x1fffffff; t1 += t0 >> 29;
  919. t0 = ((sp_uint64)a[11]) * a[11];
  920. r[21] = t1 & 0x1fffffff; t0 += t1 >> 29;
  921. r[22] = t0 & 0x1fffffff;
  922. r[23] = (sp_digit)(t0 >> 29);
  923. XMEMCPY(r, t, sizeof(t));
  924. }
  925. /* Square a into r. (r = a * a)
  926. *
  927. * r A single precision integer.
  928. * a A single precision integer.
  929. */
  930. SP_NOINLINE static void sp_2048_sqr_36(sp_digit* r, const sp_digit* a)
  931. {
  932. sp_digit p0[24];
  933. sp_digit p1[24];
  934. sp_digit p2[24];
  935. sp_digit p3[24];
  936. sp_digit p4[24];
  937. sp_digit p5[24];
  938. sp_digit t0[24];
  939. sp_digit t1[24];
  940. sp_digit t2[24];
  941. sp_digit a0[12];
  942. sp_digit a1[12];
  943. sp_digit a2[12];
  944. (void)sp_2048_add_12(a0, a, &a[12]);
  945. sp_2048_norm_12(a0);
  946. (void)sp_2048_add_12(a1, &a[12], &a[24]);
  947. sp_2048_norm_12(a1);
  948. (void)sp_2048_add_12(a2, a0, &a[24]);
  949. sp_2048_norm_12(a2);
  950. sp_2048_sqr_12(p0, a);
  951. sp_2048_sqr_12(p2, &a[12]);
  952. sp_2048_sqr_12(p4, &a[24]);
  953. sp_2048_sqr_12(p1, a0);
  954. sp_2048_sqr_12(p3, a1);
  955. sp_2048_sqr_12(p5, a2);
  956. XMEMSET(r, 0, sizeof(*r)*2U*36U);
  957. (void)sp_2048_sub_24(t0, p3, p2);
  958. (void)sp_2048_sub_24(t1, p1, p2);
  959. (void)sp_2048_sub_24(t2, p5, t0);
  960. (void)sp_2048_sub_24(t2, t2, t1);
  961. sp_2048_norm_24(t2);
  962. (void)sp_2048_sub_24(t0, t0, p4);
  963. sp_2048_norm_24(t0);
  964. (void)sp_2048_sub_24(t1, t1, p0);
  965. sp_2048_norm_24(t1);
  966. (void)sp_2048_add_24(r, r, p0);
  967. (void)sp_2048_add_24(&r[12], &r[12], t1);
  968. (void)sp_2048_add_24(&r[24], &r[24], t2);
  969. (void)sp_2048_add_24(&r[36], &r[36], t0);
  970. (void)sp_2048_add_24(&r[48], &r[48], p4);
  971. sp_2048_norm_72(r);
  972. }
  973. /* Square a and put result in r. (r = a * a)
  974. *
  975. * r A single precision integer.
  976. * a A single precision integer.
  977. */
  978. SP_NOINLINE static void sp_2048_sqr_72(sp_digit* r, const sp_digit* a)
  979. {
  980. sp_digit* z0 = r;
  981. sp_digit z1[72];
  982. sp_digit* a1 = z1;
  983. sp_digit* z2 = r + 72;
  984. (void)sp_2048_add_36(a1, a, &a[36]);
  985. sp_2048_norm_36(a1);
  986. sp_2048_sqr_36(z2, &a[36]);
  987. sp_2048_sqr_36(z0, a);
  988. sp_2048_sqr_36(z1, a1);
  989. (void)sp_2048_sub_72(z1, z1, z2);
  990. (void)sp_2048_sub_72(z1, z1, z0);
  991. (void)sp_2048_add_72(r + 36, r + 36, z1);
  992. sp_2048_norm_144(r);
  993. }
  994. #endif /* !WOLFSSL_SP_SMALL */
  995. #ifdef WOLFSSL_SP_SMALL
  996. /* Add b to a into r. (r = a + b)
  997. *
  998. * r A single precision integer.
  999. * a A single precision integer.
  1000. * b A single precision integer.
  1001. */
  1002. SP_NOINLINE static int sp_2048_add_72(sp_digit* r, const sp_digit* a,
  1003. const sp_digit* b)
  1004. {
  1005. int i;
  1006. for (i = 0; i < 72; i++) {
  1007. r[i] = a[i] + b[i];
  1008. }
  1009. return 0;
  1010. }
  1011. #endif /* WOLFSSL_SP_SMALL */
  1012. #ifdef WOLFSSL_SP_SMALL
  1013. /* Sub b from a into r. (r = a - b)
  1014. *
  1015. * r A single precision integer.
  1016. * a A single precision integer.
  1017. * b A single precision integer.
  1018. */
  1019. SP_NOINLINE static int sp_2048_sub_72(sp_digit* r, const sp_digit* a,
  1020. const sp_digit* b)
  1021. {
  1022. int i;
  1023. for (i = 0; i < 72; i++) {
  1024. r[i] = a[i] - b[i];
  1025. }
  1026. return 0;
  1027. }
  1028. #endif /* WOLFSSL_SP_SMALL */
  1029. #ifdef WOLFSSL_SP_SMALL
  1030. /* Multiply a and b into r. (r = a * b)
  1031. *
  1032. * r A single precision integer.
  1033. * a A single precision integer.
  1034. * b A single precision integer.
  1035. */
  1036. SP_NOINLINE static void sp_2048_mul_72(sp_digit* r, const sp_digit* a,
  1037. const sp_digit* b)
  1038. {
  1039. int i;
  1040. int imax;
  1041. int k;
  1042. sp_uint64 c;
  1043. sp_uint64 lo;
  1044. c = ((sp_uint64)a[71]) * b[71];
  1045. r[143] = (sp_digit)(c >> 29);
  1046. c &= 0x1fffffff;
  1047. for (k = 141; k >= 0; k--) {
  1048. if (k >= 72) {
  1049. i = k - 71;
  1050. imax = 71;
  1051. }
  1052. else {
  1053. i = 0;
  1054. imax = k;
  1055. }
  1056. if (imax - i > 15) {
  1057. int imaxlo;
  1058. lo = 0;
  1059. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  1060. for (; i <= imax && i < imaxlo + 15; i++) {
  1061. lo += ((sp_uint64)a[i]) * b[k - i];
  1062. }
  1063. c += lo >> 29;
  1064. lo &= 0x1fffffff;
  1065. }
  1066. r[k + 2] += (sp_digit)(c >> 29);
  1067. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  1068. c = lo & 0x1fffffff;
  1069. }
  1070. else {
  1071. lo = 0;
  1072. for (; i <= imax; i++) {
  1073. lo += ((sp_uint64)a[i]) * b[k - i];
  1074. }
  1075. c += lo >> 29;
  1076. r[k + 2] += (sp_digit)(c >> 29);
  1077. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  1078. c = lo & 0x1fffffff;
  1079. }
  1080. }
  1081. r[0] = (sp_digit)c;
  1082. }
  1083. /* Square a and put result in r. (r = a * a)
  1084. *
  1085. * r A single precision integer.
  1086. * a A single precision integer.
  1087. */
  1088. SP_NOINLINE static void sp_2048_sqr_72(sp_digit* r, const sp_digit* a)
  1089. {
  1090. int i;
  1091. int imax;
  1092. int k;
  1093. sp_uint64 c;
  1094. sp_uint64 t;
  1095. c = ((sp_uint64)a[71]) * a[71];
  1096. r[143] = (sp_digit)(c >> 29);
  1097. c = (c & 0x1fffffff) << 29;
  1098. for (k = 141; k >= 0; k--) {
  1099. i = (k + 1) / 2;
  1100. if ((k & 1) == 0) {
  1101. c += ((sp_uint64)a[i]) * a[i];
  1102. i++;
  1103. }
  1104. if (k < 71) {
  1105. imax = k;
  1106. }
  1107. else {
  1108. imax = 71;
  1109. }
  1110. if (imax - i >= 14) {
  1111. int imaxlo;
  1112. sp_uint64 hi;
  1113. hi = c >> 29;
  1114. c &= 0x1fffffff;
  1115. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  1116. t = 0;
  1117. for (; i <= imax && i < imaxlo + 14; i++) {
  1118. t += ((sp_uint64)a[i]) * a[k - i];
  1119. }
  1120. c += t * 2;
  1121. hi += c >> 29;
  1122. c &= 0x1fffffff;
  1123. }
  1124. r[k + 2] += (sp_digit)(hi >> 29);
  1125. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  1126. c <<= 29;
  1127. }
  1128. else
  1129. {
  1130. t = 0;
  1131. for (; i <= imax; i++) {
  1132. t += ((sp_uint64)a[i]) * a[k - i];
  1133. }
  1134. c += t * 2;
  1135. r[k + 2] += (sp_digit) (c >> 58);
  1136. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  1137. c = (c & 0x1fffffff) << 29;
  1138. }
  1139. }
  1140. r[0] = (sp_digit)(c >> 29);
  1141. }
  1142. #endif /* WOLFSSL_SP_SMALL */
  1143. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  1144. #ifdef WOLFSSL_SP_SMALL
  1145. /* Add b to a into r. (r = a + b)
  1146. *
  1147. * r A single precision integer.
  1148. * a A single precision integer.
  1149. * b A single precision integer.
  1150. */
  1151. SP_NOINLINE static int sp_2048_add_36(sp_digit* r, const sp_digit* a,
  1152. const sp_digit* b)
  1153. {
  1154. int i;
  1155. for (i = 0; i < 36; i++) {
  1156. r[i] = a[i] + b[i];
  1157. }
  1158. return 0;
  1159. }
  1160. #endif /* WOLFSSL_SP_SMALL */
  1161. #ifdef WOLFSSL_SP_SMALL
  1162. /* Sub b from a into r. (r = a - b)
  1163. *
  1164. * r A single precision integer.
  1165. * a A single precision integer.
  1166. * b A single precision integer.
  1167. */
  1168. SP_NOINLINE static int sp_2048_sub_36(sp_digit* r, const sp_digit* a,
  1169. const sp_digit* b)
  1170. {
  1171. int i;
  1172. for (i = 0; i < 36; i++) {
  1173. r[i] = a[i] - b[i];
  1174. }
  1175. return 0;
  1176. }
  1177. #else
  1178. /* Sub b from a into r. (r = a - b)
  1179. *
  1180. * r A single precision integer.
  1181. * a A single precision integer.
  1182. * b A single precision integer.
  1183. */
  1184. SP_NOINLINE static int sp_2048_sub_36(sp_digit* r, const sp_digit* a,
  1185. const sp_digit* b)
  1186. {
  1187. int i;
  1188. for (i = 0; i < 32; i += 8) {
  1189. r[i + 0] = a[i + 0] - b[i + 0];
  1190. r[i + 1] = a[i + 1] - b[i + 1];
  1191. r[i + 2] = a[i + 2] - b[i + 2];
  1192. r[i + 3] = a[i + 3] - b[i + 3];
  1193. r[i + 4] = a[i + 4] - b[i + 4];
  1194. r[i + 5] = a[i + 5] - b[i + 5];
  1195. r[i + 6] = a[i + 6] - b[i + 6];
  1196. r[i + 7] = a[i + 7] - b[i + 7];
  1197. }
  1198. r[32] = a[32] - b[32];
  1199. r[33] = a[33] - b[33];
  1200. r[34] = a[34] - b[34];
  1201. r[35] = a[35] - b[35];
  1202. return 0;
  1203. }
  1204. #endif /* WOLFSSL_SP_SMALL */
  1205. #ifdef WOLFSSL_SP_SMALL
  1206. /* Multiply a and b into r. (r = a * b)
  1207. *
  1208. * r A single precision integer.
  1209. * a A single precision integer.
  1210. * b A single precision integer.
  1211. */
  1212. SP_NOINLINE static void sp_2048_mul_36(sp_digit* r, const sp_digit* a,
  1213. const sp_digit* b)
  1214. {
  1215. int i;
  1216. int imax;
  1217. int k;
  1218. sp_uint64 c;
  1219. sp_uint64 lo;
  1220. c = ((sp_uint64)a[35]) * b[35];
  1221. r[71] = (sp_digit)(c >> 29);
  1222. c &= 0x1fffffff;
  1223. for (k = 69; k >= 0; k--) {
  1224. if (k >= 36) {
  1225. i = k - 35;
  1226. imax = 35;
  1227. }
  1228. else {
  1229. i = 0;
  1230. imax = k;
  1231. }
  1232. if (imax - i > 15) {
  1233. int imaxlo;
  1234. lo = 0;
  1235. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  1236. for (; i <= imax && i < imaxlo + 15; i++) {
  1237. lo += ((sp_uint64)a[i]) * b[k - i];
  1238. }
  1239. c += lo >> 29;
  1240. lo &= 0x1fffffff;
  1241. }
  1242. r[k + 2] += (sp_digit)(c >> 29);
  1243. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  1244. c = lo & 0x1fffffff;
  1245. }
  1246. else {
  1247. lo = 0;
  1248. for (; i <= imax; i++) {
  1249. lo += ((sp_uint64)a[i]) * b[k - i];
  1250. }
  1251. c += lo >> 29;
  1252. r[k + 2] += (sp_digit)(c >> 29);
  1253. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  1254. c = lo & 0x1fffffff;
  1255. }
  1256. }
  1257. r[0] = (sp_digit)c;
  1258. }
  1259. /* Square a and put result in r. (r = a * a)
  1260. *
  1261. * r A single precision integer.
  1262. * a A single precision integer.
  1263. */
  1264. SP_NOINLINE static void sp_2048_sqr_36(sp_digit* r, const sp_digit* a)
  1265. {
  1266. int i;
  1267. int imax;
  1268. int k;
  1269. sp_uint64 c;
  1270. sp_uint64 t;
  1271. c = ((sp_uint64)a[35]) * a[35];
  1272. r[71] = (sp_digit)(c >> 29);
  1273. c = (c & 0x1fffffff) << 29;
  1274. for (k = 69; k >= 0; k--) {
  1275. i = (k + 1) / 2;
  1276. if ((k & 1) == 0) {
  1277. c += ((sp_uint64)a[i]) * a[i];
  1278. i++;
  1279. }
  1280. if (k < 35) {
  1281. imax = k;
  1282. }
  1283. else {
  1284. imax = 35;
  1285. }
  1286. if (imax - i >= 14) {
  1287. int imaxlo;
  1288. sp_uint64 hi;
  1289. hi = c >> 29;
  1290. c &= 0x1fffffff;
  1291. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  1292. t = 0;
  1293. for (; i <= imax && i < imaxlo + 14; i++) {
  1294. t += ((sp_uint64)a[i]) * a[k - i];
  1295. }
  1296. c += t * 2;
  1297. hi += c >> 29;
  1298. c &= 0x1fffffff;
  1299. }
  1300. r[k + 2] += (sp_digit)(hi >> 29);
  1301. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  1302. c <<= 29;
  1303. }
  1304. else
  1305. {
  1306. t = 0;
  1307. for (; i <= imax; i++) {
  1308. t += ((sp_uint64)a[i]) * a[k - i];
  1309. }
  1310. c += t * 2;
  1311. r[k + 2] += (sp_digit) (c >> 58);
  1312. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  1313. c = (c & 0x1fffffff) << 29;
  1314. }
  1315. }
  1316. r[0] = (sp_digit)(c >> 29);
  1317. }
  1318. #endif /* WOLFSSL_SP_SMALL */
  1319. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) | WOLFSSL_HAVE_SP_DH */
  1320. /* Calculate the bottom digit of -1/a mod 2^n.
  1321. *
  1322. * a A single precision number.
  1323. * rho Bottom word of inverse.
  1324. */
  1325. static void sp_2048_mont_setup(const sp_digit* a, sp_digit* rho)
  1326. {
  1327. sp_digit x;
  1328. sp_digit b;
  1329. b = a[0];
  1330. x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
  1331. x *= 2 - b * x; /* here x*a==1 mod 2**8 */
  1332. x *= 2 - b * x; /* here x*a==1 mod 2**16 */
  1333. x *= 2 - b * x; /* here x*a==1 mod 2**32 */
  1334. x &= 0x1fffffff;
  1335. /* rho = -1/m mod b */
  1336. *rho = ((sp_digit)1 << 29) - x;
  1337. }
  1338. /* Multiply a by scalar b into r. (r = a * b)
  1339. *
  1340. * r A single precision integer.
  1341. * a A single precision integer.
  1342. * b A scalar.
  1343. */
  1344. SP_NOINLINE static void sp_2048_mul_d_72(sp_digit* r, const sp_digit* a,
  1345. sp_digit b)
  1346. {
  1347. #ifdef WOLFSSL_SP_SMALL
  1348. sp_int64 tb = b;
  1349. sp_int64 t = 0;
  1350. int i;
  1351. for (i = 0; i < 72; i++) {
  1352. t += tb * a[i];
  1353. r[i] = (sp_digit)(t & 0x1fffffff);
  1354. t >>= 29;
  1355. }
  1356. r[72] = (sp_digit)t;
  1357. #else
  1358. sp_int64 tb = b;
  1359. sp_int64 t = 0;
  1360. sp_digit t2;
  1361. sp_int64 p[4];
  1362. int i;
  1363. for (i = 0; i < 72; i += 4) {
  1364. p[0] = tb * a[i + 0];
  1365. p[1] = tb * a[i + 1];
  1366. p[2] = tb * a[i + 2];
  1367. p[3] = tb * a[i + 3];
  1368. t += p[0];
  1369. t2 = (sp_digit)(t & 0x1fffffff);
  1370. t >>= 29;
  1371. r[i + 0] = (sp_digit)t2;
  1372. t += p[1];
  1373. t2 = (sp_digit)(t & 0x1fffffff);
  1374. t >>= 29;
  1375. r[i + 1] = (sp_digit)t2;
  1376. t += p[2];
  1377. t2 = (sp_digit)(t & 0x1fffffff);
  1378. t >>= 29;
  1379. r[i + 2] = (sp_digit)t2;
  1380. t += p[3];
  1381. t2 = (sp_digit)(t & 0x1fffffff);
  1382. t >>= 29;
  1383. r[i + 3] = (sp_digit)t2;
  1384. }
  1385. r[72] = (sp_digit)(t & 0x1fffffff);
  1386. #endif /* WOLFSSL_SP_SMALL */
  1387. }
  1388. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  1389. /* r = 2^n mod m where n is the number of bits to reduce by.
  1390. * Given m must be 2048 bits, just need to subtract.
  1391. *
  1392. * r A single precision number.
  1393. * m A single precision number.
  1394. */
  1395. static void sp_2048_mont_norm_36(sp_digit* r, const sp_digit* m)
  1396. {
  1397. /* Set r = 2^n - 1. */
  1398. #ifdef WOLFSSL_SP_SMALL
  1399. int i;
  1400. for (i=0; i<35; i++) {
  1401. r[i] = 0x1fffffff;
  1402. }
  1403. #else
  1404. int i;
  1405. for (i = 0; i < 32; i += 8) {
  1406. r[i + 0] = 0x1fffffff;
  1407. r[i + 1] = 0x1fffffff;
  1408. r[i + 2] = 0x1fffffff;
  1409. r[i + 3] = 0x1fffffff;
  1410. r[i + 4] = 0x1fffffff;
  1411. r[i + 5] = 0x1fffffff;
  1412. r[i + 6] = 0x1fffffff;
  1413. r[i + 7] = 0x1fffffff;
  1414. }
  1415. r[32] = 0x1fffffff;
  1416. r[33] = 0x1fffffff;
  1417. r[34] = 0x1fffffff;
  1418. #endif /* WOLFSSL_SP_SMALL */
  1419. r[35] = 0x1ffL;
  1420. /* r = (2^n - 1) mod n */
  1421. (void)sp_2048_sub_36(r, r, m);
  1422. /* Add one so r = 2^n mod m */
  1423. r[0] += 1;
  1424. }
  1425. /* Compare a with b in constant time.
  1426. *
  1427. * a A single precision integer.
  1428. * b A single precision integer.
  1429. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  1430. * respectively.
  1431. */
  1432. static sp_digit sp_2048_cmp_36(const sp_digit* a, const sp_digit* b)
  1433. {
  1434. sp_digit r = 0;
  1435. #ifdef WOLFSSL_SP_SMALL
  1436. int i;
  1437. for (i=35; i>=0; i--) {
  1438. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  1439. }
  1440. #else
  1441. int i;
  1442. r |= (a[35] - b[35]) & (0 - (sp_digit)1);
  1443. r |= (a[34] - b[34]) & ~(((sp_digit)0 - r) >> 28);
  1444. r |= (a[33] - b[33]) & ~(((sp_digit)0 - r) >> 28);
  1445. r |= (a[32] - b[32]) & ~(((sp_digit)0 - r) >> 28);
  1446. for (i = 24; i >= 0; i -= 8) {
  1447. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 28);
  1448. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 28);
  1449. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 28);
  1450. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 28);
  1451. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 28);
  1452. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 28);
  1453. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 28);
  1454. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 28);
  1455. }
  1456. #endif /* WOLFSSL_SP_SMALL */
  1457. return r;
  1458. }
  1459. /* Conditionally subtract b from a using the mask m.
  1460. * m is -1 to subtract and 0 when not.
  1461. *
  1462. * r A single precision number representing condition subtract result.
  1463. * a A single precision number to subtract from.
  1464. * b A single precision number to subtract.
  1465. * m Mask value to apply.
  1466. */
  1467. static void sp_2048_cond_sub_36(sp_digit* r, const sp_digit* a,
  1468. const sp_digit* b, const sp_digit m)
  1469. {
  1470. #ifdef WOLFSSL_SP_SMALL
  1471. int i;
  1472. for (i = 0; i < 36; i++) {
  1473. r[i] = a[i] - (b[i] & m);
  1474. }
  1475. #else
  1476. int i;
  1477. for (i = 0; i < 32; i += 8) {
  1478. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  1479. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  1480. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  1481. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  1482. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  1483. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  1484. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  1485. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  1486. }
  1487. r[32] = a[32] - (b[32] & m);
  1488. r[33] = a[33] - (b[33] & m);
  1489. r[34] = a[34] - (b[34] & m);
  1490. r[35] = a[35] - (b[35] & m);
  1491. #endif /* WOLFSSL_SP_SMALL */
  1492. }
  1493. /* Mul a by scalar b and add into r. (r += a * b)
  1494. *
  1495. * r A single precision integer.
  1496. * a A single precision integer.
  1497. * b A scalar.
  1498. */
  1499. SP_NOINLINE static void sp_2048_mul_add_36(sp_digit* r, const sp_digit* a,
  1500. const sp_digit b)
  1501. {
  1502. #ifndef WOLFSSL_SP_LARGE_CODE
  1503. sp_int64 tb = b;
  1504. sp_int64 t = 0;
  1505. int i;
  1506. for (i = 0; i < 36; i++) {
  1507. t += r[i];
  1508. t += tb * a[i];
  1509. r[i] = ((sp_digit)t) & 0x1fffffff;
  1510. t >>= 29;
  1511. }
  1512. r[36] += (sp_digit)t;
  1513. #else
  1514. #ifdef WOLFSSL_SP_SMALL
  1515. sp_int64 tb = b;
  1516. sp_int64 t[4];
  1517. int i;
  1518. t[0] = 0;
  1519. for (i = 0; i < 32; i += 4) {
  1520. t[0] += (tb * a[i+0]) + r[i+0];
  1521. t[1] = (tb * a[i+1]) + r[i+1];
  1522. t[2] = (tb * a[i+2]) + r[i+2];
  1523. t[3] = (tb * a[i+3]) + r[i+3];
  1524. r[i+0] = t[0] & 0x1fffffff;
  1525. t[1] += t[0] >> 29;
  1526. r[i+1] = t[1] & 0x1fffffff;
  1527. t[2] += t[1] >> 29;
  1528. r[i+2] = t[2] & 0x1fffffff;
  1529. t[3] += t[2] >> 29;
  1530. r[i+3] = t[3] & 0x1fffffff;
  1531. t[0] = t[3] >> 29;
  1532. }
  1533. t[0] += (tb * a[32]) + r[32];
  1534. t[1] = (tb * a[33]) + r[33];
  1535. t[2] = (tb * a[34]) + r[34];
  1536. t[3] = (tb * a[35]) + r[35];
  1537. r[32] = t[0] & 0x1fffffff;
  1538. t[1] += t[0] >> 29;
  1539. r[33] = t[1] & 0x1fffffff;
  1540. t[2] += t[1] >> 29;
  1541. r[34] = t[2] & 0x1fffffff;
  1542. t[3] += t[2] >> 29;
  1543. r[35] = t[3] & 0x1fffffff;
  1544. r[36] += (sp_digit)(t[3] >> 29);
  1545. #else
  1546. sp_int64 tb = b;
  1547. sp_int64 t[8];
  1548. int i;
  1549. t[0] = 0;
  1550. for (i = 0; i < 32; i += 8) {
  1551. t[0] += (tb * a[i+0]) + r[i+0];
  1552. t[1] = (tb * a[i+1]) + r[i+1];
  1553. t[2] = (tb * a[i+2]) + r[i+2];
  1554. t[3] = (tb * a[i+3]) + r[i+3];
  1555. t[4] = (tb * a[i+4]) + r[i+4];
  1556. t[5] = (tb * a[i+5]) + r[i+5];
  1557. t[6] = (tb * a[i+6]) + r[i+6];
  1558. t[7] = (tb * a[i+7]) + r[i+7];
  1559. r[i+0] = t[0] & 0x1fffffff;
  1560. t[1] += t[0] >> 29;
  1561. r[i+1] = t[1] & 0x1fffffff;
  1562. t[2] += t[1] >> 29;
  1563. r[i+2] = t[2] & 0x1fffffff;
  1564. t[3] += t[2] >> 29;
  1565. r[i+3] = t[3] & 0x1fffffff;
  1566. t[4] += t[3] >> 29;
  1567. r[i+4] = t[4] & 0x1fffffff;
  1568. t[5] += t[4] >> 29;
  1569. r[i+5] = t[5] & 0x1fffffff;
  1570. t[6] += t[5] >> 29;
  1571. r[i+6] = t[6] & 0x1fffffff;
  1572. t[7] += t[6] >> 29;
  1573. r[i+7] = t[7] & 0x1fffffff;
  1574. t[0] = t[7] >> 29;
  1575. }
  1576. t[0] += (tb * a[32]) + r[32];
  1577. t[1] = (tb * a[33]) + r[33];
  1578. t[2] = (tb * a[34]) + r[34];
  1579. t[3] = (tb * a[35]) + r[35];
  1580. r[32] = t[0] & 0x1fffffff;
  1581. t[1] += t[0] >> 29;
  1582. r[33] = t[1] & 0x1fffffff;
  1583. t[2] += t[1] >> 29;
  1584. r[34] = t[2] & 0x1fffffff;
  1585. t[3] += t[2] >> 29;
  1586. r[35] = t[3] & 0x1fffffff;
  1587. r[36] += (sp_digit)(t[3] >> 29);
  1588. #endif /* WOLFSSL_SP_SMALL */
  1589. #endif /* !WOLFSSL_SP_LARGE_CODE */
  1590. }
  1591. /* Shift the result in the high 1024 bits down to the bottom.
  1592. *
  1593. * r A single precision number.
  1594. * a A single precision number.
  1595. */
  1596. static void sp_2048_mont_shift_36(sp_digit* r, const sp_digit* a)
  1597. {
  1598. #ifdef WOLFSSL_SP_SMALL
  1599. int i;
  1600. sp_int64 n = a[35] >> 9;
  1601. n += ((sp_int64)a[36]) << 20;
  1602. for (i = 0; i < 35; i++) {
  1603. r[i] = n & 0x1fffffff;
  1604. n >>= 29;
  1605. n += ((sp_int64)a[37 + i]) << 20;
  1606. }
  1607. r[35] = (sp_digit)n;
  1608. #else
  1609. int i;
  1610. sp_int64 n = a[35] >> 9;
  1611. n += ((sp_int64)a[36]) << 20;
  1612. for (i = 0; i < 32; i += 8) {
  1613. r[i + 0] = n & 0x1fffffff;
  1614. n >>= 29; n += ((sp_int64)a[i + 37]) << 20;
  1615. r[i + 1] = n & 0x1fffffff;
  1616. n >>= 29; n += ((sp_int64)a[i + 38]) << 20;
  1617. r[i + 2] = n & 0x1fffffff;
  1618. n >>= 29; n += ((sp_int64)a[i + 39]) << 20;
  1619. r[i + 3] = n & 0x1fffffff;
  1620. n >>= 29; n += ((sp_int64)a[i + 40]) << 20;
  1621. r[i + 4] = n & 0x1fffffff;
  1622. n >>= 29; n += ((sp_int64)a[i + 41]) << 20;
  1623. r[i + 5] = n & 0x1fffffff;
  1624. n >>= 29; n += ((sp_int64)a[i + 42]) << 20;
  1625. r[i + 6] = n & 0x1fffffff;
  1626. n >>= 29; n += ((sp_int64)a[i + 43]) << 20;
  1627. r[i + 7] = n & 0x1fffffff;
  1628. n >>= 29; n += ((sp_int64)a[i + 44]) << 20;
  1629. }
  1630. r[32] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[69]) << 20;
  1631. r[33] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[70]) << 20;
  1632. r[34] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[71]) << 20;
  1633. r[35] = (sp_digit)n;
  1634. #endif /* WOLFSSL_SP_SMALL */
  1635. XMEMSET(&r[36], 0, sizeof(*r) * 36U);
  1636. }
  1637. /* Reduce the number back to 2048 bits using Montgomery reduction.
  1638. *
  1639. * a A single precision number to reduce in place.
  1640. * m The single precision number representing the modulus.
  1641. * mp The digit representing the negative inverse of m mod 2^n.
  1642. */
  1643. static void sp_2048_mont_reduce_36(sp_digit* a, const sp_digit* m, sp_digit mp)
  1644. {
  1645. int i;
  1646. sp_digit mu;
  1647. sp_digit over;
  1648. sp_2048_norm_36(a + 36);
  1649. for (i=0; i<35; i++) {
  1650. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  1651. sp_2048_mul_add_36(a+i, m, mu);
  1652. a[i+1] += a[i] >> 29;
  1653. }
  1654. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1ffL;
  1655. sp_2048_mul_add_36(a+i, m, mu);
  1656. a[i+1] += a[i] >> 29;
  1657. a[i] &= 0x1fffffff;
  1658. sp_2048_mont_shift_36(a, a);
  1659. over = a[35] - m[35];
  1660. sp_2048_cond_sub_36(a, a, m, ~((over - 1) >> 31));
  1661. sp_2048_norm_36(a);
  1662. }
  1663. /* Multiply two Montgomery form numbers mod the modulus (prime).
  1664. * (r = a * b mod m)
  1665. *
  1666. * r Result of multiplication.
  1667. * a First number to multiply in Montgomery form.
  1668. * b Second number to multiply in Montgomery form.
  1669. * m Modulus (prime).
  1670. * mp Montgomery multiplier.
  1671. */
  1672. SP_NOINLINE static void sp_2048_mont_mul_36(sp_digit* r, const sp_digit* a,
  1673. const sp_digit* b, const sp_digit* m, sp_digit mp)
  1674. {
  1675. sp_2048_mul_36(r, a, b);
  1676. sp_2048_mont_reduce_36(r, m, mp);
  1677. }
  1678. /* Square the Montgomery form number. (r = a * a mod m)
  1679. *
  1680. * r Result of squaring.
  1681. * a Number to square in Montgomery form.
  1682. * m Modulus (prime).
  1683. * mp Montgomery multiplier.
  1684. */
  1685. SP_NOINLINE static void sp_2048_mont_sqr_36(sp_digit* r, const sp_digit* a,
  1686. const sp_digit* m, sp_digit mp)
  1687. {
  1688. sp_2048_sqr_36(r, a);
  1689. sp_2048_mont_reduce_36(r, m, mp);
  1690. }
  1691. /* Multiply a by scalar b into r. (r = a * b)
  1692. *
  1693. * r A single precision integer.
  1694. * a A single precision integer.
  1695. * b A scalar.
  1696. */
  1697. SP_NOINLINE static void sp_2048_mul_d_36(sp_digit* r, const sp_digit* a,
  1698. sp_digit b)
  1699. {
  1700. #ifdef WOLFSSL_SP_SMALL
  1701. sp_int64 tb = b;
  1702. sp_int64 t = 0;
  1703. int i;
  1704. for (i = 0; i < 36; i++) {
  1705. t += tb * a[i];
  1706. r[i] = (sp_digit)(t & 0x1fffffff);
  1707. t >>= 29;
  1708. }
  1709. r[36] = (sp_digit)t;
  1710. #else
  1711. sp_int64 tb = b;
  1712. sp_int64 t = 0;
  1713. sp_digit t2;
  1714. sp_int64 p[4];
  1715. int i;
  1716. for (i = 0; i < 36; i += 4) {
  1717. p[0] = tb * a[i + 0];
  1718. p[1] = tb * a[i + 1];
  1719. p[2] = tb * a[i + 2];
  1720. p[3] = tb * a[i + 3];
  1721. t += p[0];
  1722. t2 = (sp_digit)(t & 0x1fffffff);
  1723. t >>= 29;
  1724. r[i + 0] = (sp_digit)t2;
  1725. t += p[1];
  1726. t2 = (sp_digit)(t & 0x1fffffff);
  1727. t >>= 29;
  1728. r[i + 1] = (sp_digit)t2;
  1729. t += p[2];
  1730. t2 = (sp_digit)(t & 0x1fffffff);
  1731. t >>= 29;
  1732. r[i + 2] = (sp_digit)t2;
  1733. t += p[3];
  1734. t2 = (sp_digit)(t & 0x1fffffff);
  1735. t >>= 29;
  1736. r[i + 3] = (sp_digit)t2;
  1737. }
  1738. r[36] = (sp_digit)(t & 0x1fffffff);
  1739. #endif /* WOLFSSL_SP_SMALL */
  1740. }
  1741. #ifdef WOLFSSL_SP_SMALL
  1742. /* Conditionally add a and b using the mask m.
  1743. * m is -1 to add and 0 when not.
  1744. *
  1745. * r A single precision number representing conditional add result.
  1746. * a A single precision number to add with.
  1747. * b A single precision number to add.
  1748. * m Mask value to apply.
  1749. */
  1750. static void sp_2048_cond_add_36(sp_digit* r, const sp_digit* a,
  1751. const sp_digit* b, const sp_digit m)
  1752. {
  1753. int i;
  1754. for (i = 0; i < 36; i++) {
  1755. r[i] = a[i] + (b[i] & m);
  1756. }
  1757. }
  1758. #endif /* WOLFSSL_SP_SMALL */
  1759. #ifndef WOLFSSL_SP_SMALL
  1760. /* Conditionally add a and b using the mask m.
  1761. * m is -1 to add and 0 when not.
  1762. *
  1763. * r A single precision number representing conditional add result.
  1764. * a A single precision number to add with.
  1765. * b A single precision number to add.
  1766. * m Mask value to apply.
  1767. */
  1768. static void sp_2048_cond_add_36(sp_digit* r, const sp_digit* a,
  1769. const sp_digit* b, const sp_digit m)
  1770. {
  1771. int i;
  1772. for (i = 0; i < 32; i += 8) {
  1773. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  1774. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  1775. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  1776. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  1777. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  1778. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  1779. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  1780. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  1781. }
  1782. r[32] = a[32] + (b[32] & m);
  1783. r[33] = a[33] + (b[33] & m);
  1784. r[34] = a[34] + (b[34] & m);
  1785. r[35] = a[35] + (b[35] & m);
  1786. }
  1787. #endif /* !WOLFSSL_SP_SMALL */
  1788. SP_NOINLINE static void sp_2048_rshift_36(sp_digit* r, const sp_digit* a,
  1789. byte n)
  1790. {
  1791. int i;
  1792. #ifdef WOLFSSL_SP_SMALL
  1793. for (i=0; i<35; i++) {
  1794. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  1795. }
  1796. #else
  1797. for (i=0; i<32; i += 8) {
  1798. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (29 - n)) & 0x1fffffff);
  1799. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (29 - n)) & 0x1fffffff);
  1800. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (29 - n)) & 0x1fffffff);
  1801. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (29 - n)) & 0x1fffffff);
  1802. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (29 - n)) & 0x1fffffff);
  1803. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (29 - n)) & 0x1fffffff);
  1804. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (29 - n)) & 0x1fffffff);
  1805. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (29 - n)) & 0x1fffffff);
  1806. }
  1807. r[32] = (a[32] >> n) | ((a[33] << (29 - n)) & 0x1fffffff);
  1808. r[33] = (a[33] >> n) | ((a[34] << (29 - n)) & 0x1fffffff);
  1809. r[34] = (a[34] >> n) | ((a[35] << (29 - n)) & 0x1fffffff);
  1810. #endif /* WOLFSSL_SP_SMALL */
  1811. r[35] = a[35] >> n;
  1812. }
  1813. static WC_INLINE sp_digit sp_2048_div_word_36(sp_digit d1, sp_digit d0,
  1814. sp_digit div)
  1815. {
  1816. #ifdef SP_USE_DIVTI3
  1817. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  1818. return d / div;
  1819. #elif defined(__x86_64__) || defined(__i386__)
  1820. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  1821. sp_uint32 lo = (sp_uint32)d;
  1822. sp_digit hi = (sp_digit)(d >> 32);
  1823. __asm__ __volatile__ (
  1824. "idiv %2"
  1825. : "+a" (lo)
  1826. : "d" (hi), "r" (div)
  1827. : "cc"
  1828. );
  1829. return (sp_digit)lo;
  1830. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  1831. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  1832. sp_digit dv = (div >> 1) + 1;
  1833. sp_digit t1 = (sp_digit)(d >> 29);
  1834. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  1835. sp_digit t2;
  1836. sp_digit sign;
  1837. sp_digit r;
  1838. int i;
  1839. sp_int64 m;
  1840. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  1841. t1 -= dv & (0 - r);
  1842. for (i = 27; i >= 1; i--) {
  1843. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  1844. t0 <<= 1;
  1845. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  1846. r += r + t2;
  1847. t1 -= dv & (0 - t2);
  1848. t1 += t2;
  1849. }
  1850. r += r + 1;
  1851. m = d - ((sp_int64)r * div);
  1852. r += (sp_digit)(m >> 29);
  1853. m = d - ((sp_int64)r * div);
  1854. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  1855. m = d - ((sp_int64)r * div);
  1856. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  1857. m *= sign;
  1858. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  1859. r += sign * t2;
  1860. m = d - ((sp_int64)r * div);
  1861. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  1862. m *= sign;
  1863. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  1864. r += sign * t2;
  1865. return r;
  1866. #else
  1867. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  1868. sp_digit r = 0;
  1869. sp_digit t;
  1870. sp_digit dv = (div >> 14) + 1;
  1871. t = (sp_digit)(d >> 28);
  1872. t = (t / dv) << 14;
  1873. r += t;
  1874. d -= (sp_int64)t * div;
  1875. t = (sp_digit)(d >> 13);
  1876. t = t / (dv << 1);
  1877. r += t;
  1878. d -= (sp_int64)t * div;
  1879. t = (sp_digit)d;
  1880. t = t / div;
  1881. r += t;
  1882. d -= (sp_int64)t * div;
  1883. return r;
  1884. #endif
  1885. }
  1886. static WC_INLINE sp_digit sp_2048_word_div_word_36(sp_digit d, sp_digit div)
  1887. {
  1888. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  1889. defined(SP_DIV_WORD_USE_DIV)
  1890. return d / div;
  1891. #else
  1892. return (sp_digit)((sp_uint32)(div - d) >> 31);
  1893. #endif
  1894. }
  1895. /* Divide d in a and put remainder into r (m*d + r = a)
  1896. * m is not calculated as it is not needed at this time.
  1897. *
  1898. * Full implementation.
  1899. *
  1900. * a Number to be divided.
  1901. * d Number to divide with.
  1902. * m Multiplier result.
  1903. * r Remainder from the division.
  1904. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  1905. */
  1906. static int sp_2048_div_36(const sp_digit* a, const sp_digit* d,
  1907. const sp_digit* m, sp_digit* r)
  1908. {
  1909. int i;
  1910. #ifndef WOLFSSL_SP_DIV_32
  1911. #endif
  1912. sp_digit dv;
  1913. sp_digit r1;
  1914. #ifdef WOLFSSL_SP_SMALL_STACK
  1915. sp_digit* t1 = NULL;
  1916. #else
  1917. sp_digit t1[4 * 36 + 3];
  1918. #endif
  1919. sp_digit* t2 = NULL;
  1920. sp_digit* sd = NULL;
  1921. int err = MP_OKAY;
  1922. (void)m;
  1923. #ifdef WOLFSSL_SP_SMALL_STACK
  1924. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 36 + 3), NULL,
  1925. DYNAMIC_TYPE_TMP_BUFFER);
  1926. if (t1 == NULL)
  1927. err = MEMORY_E;
  1928. #endif
  1929. (void)m;
  1930. if (err == MP_OKAY) {
  1931. t2 = t1 + 72 + 1;
  1932. sd = t2 + 36 + 1;
  1933. sp_2048_mul_d_36(sd, d, (sp_digit)1 << 20);
  1934. sp_2048_mul_d_72(t1, a, (sp_digit)1 << 20);
  1935. dv = sd[35];
  1936. t1[36 + 36] += t1[36 + 36 - 1] >> 29;
  1937. t1[36 + 36 - 1] &= 0x1fffffff;
  1938. for (i=36; i>=0; i--) {
  1939. r1 = sp_2048_div_word_36(t1[36 + i], t1[36 + i - 1], dv);
  1940. sp_2048_mul_d_36(t2, sd, r1);
  1941. (void)sp_2048_sub_36(&t1[i], &t1[i], t2);
  1942. sp_2048_norm_36(&t1[i]);
  1943. t1[36 + i] -= t2[36];
  1944. t1[36 + i] += t1[36 + i - 1] >> 29;
  1945. t1[36 + i - 1] &= 0x1fffffff;
  1946. r1 = sp_2048_div_word_36(-t1[36 + i], -t1[36 + i - 1], dv);
  1947. r1 -= t1[36 + i];
  1948. sp_2048_mul_d_36(t2, sd, r1);
  1949. (void)sp_2048_add_36(&t1[i], &t1[i], t2);
  1950. t1[36 + i] += t1[36 + i - 1] >> 29;
  1951. t1[36 + i - 1] &= 0x1fffffff;
  1952. }
  1953. t1[36 - 1] += t1[36 - 2] >> 29;
  1954. t1[36 - 2] &= 0x1fffffff;
  1955. r1 = sp_2048_word_div_word_36(t1[36 - 1], dv);
  1956. sp_2048_mul_d_36(t2, sd, r1);
  1957. sp_2048_sub_36(t1, t1, t2);
  1958. XMEMCPY(r, t1, sizeof(*r) * 72U);
  1959. for (i=0; i<35; i++) {
  1960. r[i+1] += r[i] >> 29;
  1961. r[i] &= 0x1fffffff;
  1962. }
  1963. sp_2048_cond_add_36(r, r, sd, r[35] >> 31);
  1964. sp_2048_norm_36(r);
  1965. sp_2048_rshift_36(r, r, 20);
  1966. }
  1967. #ifdef WOLFSSL_SP_SMALL_STACK
  1968. if (t1 != NULL)
  1969. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  1970. #endif
  1971. return err;
  1972. }
  1973. /* Reduce a modulo m into r. (r = a mod m)
  1974. *
  1975. * r A single precision number that is the reduced result.
  1976. * a A single precision number that is to be reduced.
  1977. * m A single precision number that is the modulus to reduce with.
  1978. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  1979. */
  1980. static int sp_2048_mod_36(sp_digit* r, const sp_digit* a, const sp_digit* m)
  1981. {
  1982. return sp_2048_div_36(a, m, NULL, r);
  1983. }
  1984. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  1985. *
  1986. * r A single precision number that is the result of the operation.
  1987. * a A single precision number being exponentiated.
  1988. * e A single precision number that is the exponent.
  1989. * bits The number of bits in the exponent.
  1990. * m A single precision number that is the modulus.
  1991. * returns 0 on success.
  1992. * returns MEMORY_E on dynamic memory allocation failure.
  1993. * returns MP_VAL when base is even or exponent is 0.
  1994. */
  1995. static int sp_2048_mod_exp_36(sp_digit* r, const sp_digit* a, const sp_digit* e,
  1996. int bits, const sp_digit* m, int reduceA)
  1997. {
  1998. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  1999. #ifdef WOLFSSL_SP_SMALL_STACK
  2000. sp_digit* td = NULL;
  2001. #else
  2002. sp_digit td[3 * 72];
  2003. #endif
  2004. sp_digit* t[3] = {0, 0, 0};
  2005. sp_digit* norm = NULL;
  2006. sp_digit mp = 1;
  2007. sp_digit n;
  2008. int i;
  2009. int c;
  2010. byte y;
  2011. int err = MP_OKAY;
  2012. if (bits == 0) {
  2013. err = MP_VAL;
  2014. }
  2015. #ifdef WOLFSSL_SP_SMALL_STACK
  2016. if (err == MP_OKAY) {
  2017. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 36 * 2, NULL,
  2018. DYNAMIC_TYPE_TMP_BUFFER);
  2019. if (td == NULL)
  2020. err = MEMORY_E;
  2021. }
  2022. #endif
  2023. if (err == MP_OKAY) {
  2024. norm = td;
  2025. for (i=0; i<3; i++) {
  2026. t[i] = td + (i * 36 * 2);
  2027. XMEMSET(t[i], 0, sizeof(sp_digit) * 36U * 2U);
  2028. }
  2029. sp_2048_mont_setup(m, &mp);
  2030. sp_2048_mont_norm_36(norm, m);
  2031. if (reduceA != 0) {
  2032. err = sp_2048_mod_36(t[1], a, m);
  2033. }
  2034. else {
  2035. XMEMCPY(t[1], a, sizeof(sp_digit) * 36U);
  2036. }
  2037. }
  2038. if (err == MP_OKAY) {
  2039. sp_2048_mul_36(t[1], t[1], norm);
  2040. err = sp_2048_mod_36(t[1], t[1], m);
  2041. }
  2042. if (err == MP_OKAY) {
  2043. i = bits / 29;
  2044. c = bits % 29;
  2045. n = e[i--] << (29 - c);
  2046. for (; ; c--) {
  2047. if (c == 0) {
  2048. if (i == -1) {
  2049. break;
  2050. }
  2051. n = e[i--];
  2052. c = 29;
  2053. }
  2054. y = (int)((n >> 28) & 1);
  2055. n <<= 1;
  2056. sp_2048_mont_mul_36(t[y^1], t[0], t[1], m, mp);
  2057. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  2058. ((size_t)t[1] & addr_mask[y])),
  2059. sizeof(*t[2]) * 36 * 2);
  2060. sp_2048_mont_sqr_36(t[2], t[2], m, mp);
  2061. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  2062. ((size_t)t[1] & addr_mask[y])), t[2],
  2063. sizeof(*t[2]) * 36 * 2);
  2064. }
  2065. sp_2048_mont_reduce_36(t[0], m, mp);
  2066. n = sp_2048_cmp_36(t[0], m);
  2067. sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 31));
  2068. XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
  2069. }
  2070. #ifdef WOLFSSL_SP_SMALL_STACK
  2071. if (td != NULL)
  2072. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  2073. #endif
  2074. return err;
  2075. #elif !defined(WC_NO_CACHE_RESISTANT)
  2076. #ifdef WOLFSSL_SP_SMALL_STACK
  2077. sp_digit* td = NULL;
  2078. #else
  2079. sp_digit td[3 * 72];
  2080. #endif
  2081. sp_digit* t[3] = {0, 0, 0};
  2082. sp_digit* norm = NULL;
  2083. sp_digit mp = 1;
  2084. sp_digit n;
  2085. int i;
  2086. int c;
  2087. byte y;
  2088. int err = MP_OKAY;
  2089. if (bits == 0) {
  2090. err = MP_VAL;
  2091. }
  2092. #ifdef WOLFSSL_SP_SMALL_STACK
  2093. if (err == MP_OKAY) {
  2094. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 36 * 2, NULL,
  2095. DYNAMIC_TYPE_TMP_BUFFER);
  2096. if (td == NULL)
  2097. err = MEMORY_E;
  2098. }
  2099. #endif
  2100. if (err == MP_OKAY) {
  2101. norm = td;
  2102. for (i=0; i<3; i++) {
  2103. t[i] = td + (i * 36 * 2);
  2104. }
  2105. sp_2048_mont_setup(m, &mp);
  2106. sp_2048_mont_norm_36(norm, m);
  2107. if (reduceA != 0) {
  2108. err = sp_2048_mod_36(t[1], a, m);
  2109. if (err == MP_OKAY) {
  2110. sp_2048_mul_36(t[1], t[1], norm);
  2111. err = sp_2048_mod_36(t[1], t[1], m);
  2112. }
  2113. }
  2114. else {
  2115. sp_2048_mul_36(t[1], a, norm);
  2116. err = sp_2048_mod_36(t[1], t[1], m);
  2117. }
  2118. }
  2119. if (err == MP_OKAY) {
  2120. i = bits / 29;
  2121. c = bits % 29;
  2122. n = e[i--] << (29 - c);
  2123. for (; ; c--) {
  2124. if (c == 0) {
  2125. if (i == -1) {
  2126. break;
  2127. }
  2128. n = e[i--];
  2129. c = 29;
  2130. }
  2131. y = (int)((n >> 28) & 1);
  2132. n <<= 1;
  2133. sp_2048_mont_mul_36(t[y^1], t[0], t[1], m, mp);
  2134. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  2135. ((size_t)t[1] & addr_mask[y])),
  2136. sizeof(*t[2]) * 36 * 2);
  2137. sp_2048_mont_sqr_36(t[2], t[2], m, mp);
  2138. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  2139. ((size_t)t[1] & addr_mask[y])), t[2],
  2140. sizeof(*t[2]) * 36 * 2);
  2141. }
  2142. sp_2048_mont_reduce_36(t[0], m, mp);
  2143. n = sp_2048_cmp_36(t[0], m);
  2144. sp_2048_cond_sub_36(t[0], t[0], m, ~(n >> 31));
  2145. XMEMCPY(r, t[0], sizeof(*r) * 36 * 2);
  2146. }
  2147. #ifdef WOLFSSL_SP_SMALL_STACK
  2148. if (td != NULL)
  2149. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  2150. #endif
  2151. return err;
  2152. #else
  2153. #ifdef WOLFSSL_SP_SMALL_STACK
  2154. sp_digit* td = NULL;
  2155. #else
  2156. sp_digit td[(32 * 72) + 72];
  2157. #endif
  2158. sp_digit* t[32];
  2159. sp_digit* rt = NULL;
  2160. sp_digit* norm = NULL;
  2161. sp_digit mp = 1;
  2162. sp_digit n;
  2163. int i;
  2164. int c;
  2165. byte y;
  2166. int err = MP_OKAY;
  2167. if (bits == 0) {
  2168. err = MP_VAL;
  2169. }
  2170. #ifdef WOLFSSL_SP_SMALL_STACK
  2171. if (err == MP_OKAY) {
  2172. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((32 * 72) + 72), NULL,
  2173. DYNAMIC_TYPE_TMP_BUFFER);
  2174. if (td == NULL)
  2175. err = MEMORY_E;
  2176. }
  2177. #endif
  2178. if (err == MP_OKAY) {
  2179. norm = td;
  2180. for (i=0; i<32; i++)
  2181. t[i] = td + i * 72;
  2182. rt = td + 2304;
  2183. sp_2048_mont_setup(m, &mp);
  2184. sp_2048_mont_norm_36(norm, m);
  2185. if (reduceA != 0) {
  2186. err = sp_2048_mod_36(t[1], a, m);
  2187. if (err == MP_OKAY) {
  2188. sp_2048_mul_36(t[1], t[1], norm);
  2189. err = sp_2048_mod_36(t[1], t[1], m);
  2190. }
  2191. }
  2192. else {
  2193. sp_2048_mul_36(t[1], a, norm);
  2194. err = sp_2048_mod_36(t[1], t[1], m);
  2195. }
  2196. }
  2197. if (err == MP_OKAY) {
  2198. sp_2048_mont_sqr_36(t[ 2], t[ 1], m, mp);
  2199. sp_2048_mont_mul_36(t[ 3], t[ 2], t[ 1], m, mp);
  2200. sp_2048_mont_sqr_36(t[ 4], t[ 2], m, mp);
  2201. sp_2048_mont_mul_36(t[ 5], t[ 3], t[ 2], m, mp);
  2202. sp_2048_mont_sqr_36(t[ 6], t[ 3], m, mp);
  2203. sp_2048_mont_mul_36(t[ 7], t[ 4], t[ 3], m, mp);
  2204. sp_2048_mont_sqr_36(t[ 8], t[ 4], m, mp);
  2205. sp_2048_mont_mul_36(t[ 9], t[ 5], t[ 4], m, mp);
  2206. sp_2048_mont_sqr_36(t[10], t[ 5], m, mp);
  2207. sp_2048_mont_mul_36(t[11], t[ 6], t[ 5], m, mp);
  2208. sp_2048_mont_sqr_36(t[12], t[ 6], m, mp);
  2209. sp_2048_mont_mul_36(t[13], t[ 7], t[ 6], m, mp);
  2210. sp_2048_mont_sqr_36(t[14], t[ 7], m, mp);
  2211. sp_2048_mont_mul_36(t[15], t[ 8], t[ 7], m, mp);
  2212. sp_2048_mont_sqr_36(t[16], t[ 8], m, mp);
  2213. sp_2048_mont_mul_36(t[17], t[ 9], t[ 8], m, mp);
  2214. sp_2048_mont_sqr_36(t[18], t[ 9], m, mp);
  2215. sp_2048_mont_mul_36(t[19], t[10], t[ 9], m, mp);
  2216. sp_2048_mont_sqr_36(t[20], t[10], m, mp);
  2217. sp_2048_mont_mul_36(t[21], t[11], t[10], m, mp);
  2218. sp_2048_mont_sqr_36(t[22], t[11], m, mp);
  2219. sp_2048_mont_mul_36(t[23], t[12], t[11], m, mp);
  2220. sp_2048_mont_sqr_36(t[24], t[12], m, mp);
  2221. sp_2048_mont_mul_36(t[25], t[13], t[12], m, mp);
  2222. sp_2048_mont_sqr_36(t[26], t[13], m, mp);
  2223. sp_2048_mont_mul_36(t[27], t[14], t[13], m, mp);
  2224. sp_2048_mont_sqr_36(t[28], t[14], m, mp);
  2225. sp_2048_mont_mul_36(t[29], t[15], t[14], m, mp);
  2226. sp_2048_mont_sqr_36(t[30], t[15], m, mp);
  2227. sp_2048_mont_mul_36(t[31], t[16], t[15], m, mp);
  2228. bits = ((bits + 4) / 5) * 5;
  2229. i = ((bits + 28) / 29) - 1;
  2230. c = bits % 29;
  2231. if (c == 0) {
  2232. c = 29;
  2233. }
  2234. if (i < 36) {
  2235. n = e[i--] << (32 - c);
  2236. }
  2237. else {
  2238. n = 0;
  2239. i--;
  2240. }
  2241. if (c < 5) {
  2242. n |= e[i--] << (3 - c);
  2243. c += 29;
  2244. }
  2245. y = (int)((n >> 27) & 0x1f);
  2246. n <<= 5;
  2247. c -= 5;
  2248. XMEMCPY(rt, t[y], sizeof(sp_digit) * 72);
  2249. while ((i >= 0) || (c >= 5)) {
  2250. if (c >= 5) {
  2251. y = (byte)((n >> 27) & 0x1f);
  2252. n <<= 5;
  2253. c -= 5;
  2254. }
  2255. else if (c == 0) {
  2256. n = e[i--] << 3;
  2257. y = (byte)((n >> 27) & 0x1f);
  2258. n <<= 5;
  2259. c = 24;
  2260. }
  2261. else {
  2262. y = (byte)((n >> 27) & 0x1f);
  2263. n = e[i--] << 3;
  2264. c = 5 - c;
  2265. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  2266. n <<= c;
  2267. c = 29 - c;
  2268. }
  2269. sp_2048_mont_sqr_36(rt, rt, m, mp);
  2270. sp_2048_mont_sqr_36(rt, rt, m, mp);
  2271. sp_2048_mont_sqr_36(rt, rt, m, mp);
  2272. sp_2048_mont_sqr_36(rt, rt, m, mp);
  2273. sp_2048_mont_sqr_36(rt, rt, m, mp);
  2274. sp_2048_mont_mul_36(rt, rt, t[y], m, mp);
  2275. }
  2276. sp_2048_mont_reduce_36(rt, m, mp);
  2277. n = sp_2048_cmp_36(rt, m);
  2278. sp_2048_cond_sub_36(rt, rt, m, ~(n >> 31));
  2279. XMEMCPY(r, rt, sizeof(sp_digit) * 72);
  2280. }
  2281. #ifdef WOLFSSL_SP_SMALL_STACK
  2282. if (td != NULL)
  2283. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  2284. #endif
  2285. return err;
  2286. #endif
  2287. }
  2288. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) | WOLFSSL_HAVE_SP_DH */
  2289. /* r = 2^n mod m where n is the number of bits to reduce by.
  2290. * Given m must be 2048 bits, just need to subtract.
  2291. *
  2292. * r A single precision number.
  2293. * m A single precision number.
  2294. */
  2295. static void sp_2048_mont_norm_72(sp_digit* r, const sp_digit* m)
  2296. {
  2297. /* Set r = 2^n - 1. */
  2298. #ifdef WOLFSSL_SP_SMALL
  2299. int i;
  2300. for (i=0; i<70; i++) {
  2301. r[i] = 0x1fffffff;
  2302. }
  2303. #else
  2304. int i;
  2305. for (i = 0; i < 64; i += 8) {
  2306. r[i + 0] = 0x1fffffff;
  2307. r[i + 1] = 0x1fffffff;
  2308. r[i + 2] = 0x1fffffff;
  2309. r[i + 3] = 0x1fffffff;
  2310. r[i + 4] = 0x1fffffff;
  2311. r[i + 5] = 0x1fffffff;
  2312. r[i + 6] = 0x1fffffff;
  2313. r[i + 7] = 0x1fffffff;
  2314. }
  2315. r[64] = 0x1fffffff;
  2316. r[65] = 0x1fffffff;
  2317. r[66] = 0x1fffffff;
  2318. r[67] = 0x1fffffff;
  2319. r[68] = 0x1fffffff;
  2320. r[69] = 0x1fffffff;
  2321. #endif /* WOLFSSL_SP_SMALL */
  2322. r[70] = 0x3ffffL;
  2323. r[71] = 0;
  2324. /* r = (2^n - 1) mod n */
  2325. (void)sp_2048_sub_72(r, r, m);
  2326. /* Add one so r = 2^n mod m */
  2327. r[0] += 1;
  2328. }
  2329. /* Compare a with b in constant time.
  2330. *
  2331. * a A single precision integer.
  2332. * b A single precision integer.
  2333. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  2334. * respectively.
  2335. */
  2336. static sp_digit sp_2048_cmp_72(const sp_digit* a, const sp_digit* b)
  2337. {
  2338. sp_digit r = 0;
  2339. #ifdef WOLFSSL_SP_SMALL
  2340. int i;
  2341. for (i=71; i>=0; i--) {
  2342. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  2343. }
  2344. #else
  2345. int i;
  2346. for (i = 64; i >= 0; i -= 8) {
  2347. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 28);
  2348. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 28);
  2349. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 28);
  2350. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 28);
  2351. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 28);
  2352. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 28);
  2353. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 28);
  2354. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 28);
  2355. }
  2356. #endif /* WOLFSSL_SP_SMALL */
  2357. return r;
  2358. }
  2359. /* Conditionally subtract b from a using the mask m.
  2360. * m is -1 to subtract and 0 when not.
  2361. *
  2362. * r A single precision number representing condition subtract result.
  2363. * a A single precision number to subtract from.
  2364. * b A single precision number to subtract.
  2365. * m Mask value to apply.
  2366. */
  2367. static void sp_2048_cond_sub_72(sp_digit* r, const sp_digit* a,
  2368. const sp_digit* b, const sp_digit m)
  2369. {
  2370. #ifdef WOLFSSL_SP_SMALL
  2371. int i;
  2372. for (i = 0; i < 72; i++) {
  2373. r[i] = a[i] - (b[i] & m);
  2374. }
  2375. #else
  2376. int i;
  2377. for (i = 0; i < 72; i += 8) {
  2378. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  2379. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  2380. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  2381. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  2382. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  2383. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  2384. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  2385. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  2386. }
  2387. #endif /* WOLFSSL_SP_SMALL */
  2388. }
  2389. /* Mul a by scalar b and add into r. (r += a * b)
  2390. *
  2391. * r A single precision integer.
  2392. * a A single precision integer.
  2393. * b A scalar.
  2394. */
  2395. SP_NOINLINE static void sp_2048_mul_add_72(sp_digit* r, const sp_digit* a,
  2396. const sp_digit b)
  2397. {
  2398. #ifndef WOLFSSL_SP_LARGE_CODE
  2399. sp_int64 tb = b;
  2400. sp_int64 t = 0;
  2401. int i;
  2402. for (i = 0; i < 72; i++) {
  2403. t += r[i];
  2404. t += tb * a[i];
  2405. r[i] = ((sp_digit)t) & 0x1fffffff;
  2406. t >>= 29;
  2407. }
  2408. r[72] += (sp_digit)t;
  2409. #else
  2410. #ifdef WOLFSSL_SP_SMALL
  2411. sp_int64 tb = b;
  2412. sp_int64 t[4];
  2413. int i;
  2414. t[0] = 0;
  2415. for (i = 0; i < 68; i += 4) {
  2416. t[0] += (tb * a[i+0]) + r[i+0];
  2417. t[1] = (tb * a[i+1]) + r[i+1];
  2418. t[2] = (tb * a[i+2]) + r[i+2];
  2419. t[3] = (tb * a[i+3]) + r[i+3];
  2420. r[i+0] = t[0] & 0x1fffffff;
  2421. t[1] += t[0] >> 29;
  2422. r[i+1] = t[1] & 0x1fffffff;
  2423. t[2] += t[1] >> 29;
  2424. r[i+2] = t[2] & 0x1fffffff;
  2425. t[3] += t[2] >> 29;
  2426. r[i+3] = t[3] & 0x1fffffff;
  2427. t[0] = t[3] >> 29;
  2428. }
  2429. t[0] += (tb * a[68]) + r[68];
  2430. t[1] = (tb * a[69]) + r[69];
  2431. t[2] = (tb * a[70]) + r[70];
  2432. t[3] = (tb * a[71]) + r[71];
  2433. r[68] = t[0] & 0x1fffffff;
  2434. t[1] += t[0] >> 29;
  2435. r[69] = t[1] & 0x1fffffff;
  2436. t[2] += t[1] >> 29;
  2437. r[70] = t[2] & 0x1fffffff;
  2438. t[3] += t[2] >> 29;
  2439. r[71] = t[3] & 0x1fffffff;
  2440. r[72] += (sp_digit)(t[3] >> 29);
  2441. #else
  2442. sp_int64 tb = b;
  2443. sp_int64 t[8];
  2444. int i;
  2445. t[0] = 0;
  2446. for (i = 0; i < 64; i += 8) {
  2447. t[0] += (tb * a[i+0]) + r[i+0];
  2448. t[1] = (tb * a[i+1]) + r[i+1];
  2449. t[2] = (tb * a[i+2]) + r[i+2];
  2450. t[3] = (tb * a[i+3]) + r[i+3];
  2451. t[4] = (tb * a[i+4]) + r[i+4];
  2452. t[5] = (tb * a[i+5]) + r[i+5];
  2453. t[6] = (tb * a[i+6]) + r[i+6];
  2454. t[7] = (tb * a[i+7]) + r[i+7];
  2455. r[i+0] = t[0] & 0x1fffffff;
  2456. t[1] += t[0] >> 29;
  2457. r[i+1] = t[1] & 0x1fffffff;
  2458. t[2] += t[1] >> 29;
  2459. r[i+2] = t[2] & 0x1fffffff;
  2460. t[3] += t[2] >> 29;
  2461. r[i+3] = t[3] & 0x1fffffff;
  2462. t[4] += t[3] >> 29;
  2463. r[i+4] = t[4] & 0x1fffffff;
  2464. t[5] += t[4] >> 29;
  2465. r[i+5] = t[5] & 0x1fffffff;
  2466. t[6] += t[5] >> 29;
  2467. r[i+6] = t[6] & 0x1fffffff;
  2468. t[7] += t[6] >> 29;
  2469. r[i+7] = t[7] & 0x1fffffff;
  2470. t[0] = t[7] >> 29;
  2471. }
  2472. t[0] += (tb * a[64]) + r[64];
  2473. t[1] = (tb * a[65]) + r[65];
  2474. t[2] = (tb * a[66]) + r[66];
  2475. t[3] = (tb * a[67]) + r[67];
  2476. t[4] = (tb * a[68]) + r[68];
  2477. t[5] = (tb * a[69]) + r[69];
  2478. t[6] = (tb * a[70]) + r[70];
  2479. t[7] = (tb * a[71]) + r[71];
  2480. r[64] = t[0] & 0x1fffffff;
  2481. t[1] += t[0] >> 29;
  2482. r[65] = t[1] & 0x1fffffff;
  2483. t[2] += t[1] >> 29;
  2484. r[66] = t[2] & 0x1fffffff;
  2485. t[3] += t[2] >> 29;
  2486. r[67] = t[3] & 0x1fffffff;
  2487. t[4] += t[3] >> 29;
  2488. r[68] = t[4] & 0x1fffffff;
  2489. t[5] += t[4] >> 29;
  2490. r[69] = t[5] & 0x1fffffff;
  2491. t[6] += t[5] >> 29;
  2492. r[70] = t[6] & 0x1fffffff;
  2493. t[7] += t[6] >> 29;
  2494. r[71] = t[7] & 0x1fffffff;
  2495. r[72] += (sp_digit)(t[7] >> 29);
  2496. #endif /* WOLFSSL_SP_SMALL */
  2497. #endif /* !WOLFSSL_SP_LARGE_CODE */
  2498. }
  2499. /* Shift the result in the high 2048 bits down to the bottom.
  2500. *
  2501. * r A single precision number.
  2502. * a A single precision number.
  2503. */
  2504. static void sp_2048_mont_shift_72(sp_digit* r, const sp_digit* a)
  2505. {
  2506. #ifdef WOLFSSL_SP_SMALL
  2507. int i;
  2508. sp_int64 n = a[70] >> 18;
  2509. n += ((sp_int64)a[71]) << 11;
  2510. for (i = 0; i < 70; i++) {
  2511. r[i] = n & 0x1fffffff;
  2512. n >>= 29;
  2513. n += ((sp_int64)a[72 + i]) << 11;
  2514. }
  2515. r[70] = (sp_digit)n;
  2516. #else
  2517. int i;
  2518. sp_int64 n = a[70] >> 18;
  2519. n += ((sp_int64)a[71]) << 11;
  2520. for (i = 0; i < 64; i += 8) {
  2521. r[i + 0] = n & 0x1fffffff;
  2522. n >>= 29; n += ((sp_int64)a[i + 72]) << 11;
  2523. r[i + 1] = n & 0x1fffffff;
  2524. n >>= 29; n += ((sp_int64)a[i + 73]) << 11;
  2525. r[i + 2] = n & 0x1fffffff;
  2526. n >>= 29; n += ((sp_int64)a[i + 74]) << 11;
  2527. r[i + 3] = n & 0x1fffffff;
  2528. n >>= 29; n += ((sp_int64)a[i + 75]) << 11;
  2529. r[i + 4] = n & 0x1fffffff;
  2530. n >>= 29; n += ((sp_int64)a[i + 76]) << 11;
  2531. r[i + 5] = n & 0x1fffffff;
  2532. n >>= 29; n += ((sp_int64)a[i + 77]) << 11;
  2533. r[i + 6] = n & 0x1fffffff;
  2534. n >>= 29; n += ((sp_int64)a[i + 78]) << 11;
  2535. r[i + 7] = n & 0x1fffffff;
  2536. n >>= 29; n += ((sp_int64)a[i + 79]) << 11;
  2537. }
  2538. r[64] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[136]) << 11;
  2539. r[65] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[137]) << 11;
  2540. r[66] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[138]) << 11;
  2541. r[67] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[139]) << 11;
  2542. r[68] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[140]) << 11;
  2543. r[69] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[141]) << 11;
  2544. r[70] = (sp_digit)n;
  2545. #endif /* WOLFSSL_SP_SMALL */
  2546. XMEMSET(&r[71], 0, sizeof(*r) * 71U);
  2547. }
  2548. /* Reduce the number back to 2048 bits using Montgomery reduction.
  2549. *
  2550. * a A single precision number to reduce in place.
  2551. * m The single precision number representing the modulus.
  2552. * mp The digit representing the negative inverse of m mod 2^n.
  2553. */
  2554. static void sp_2048_mont_reduce_72(sp_digit* a, const sp_digit* m, sp_digit mp)
  2555. {
  2556. int i;
  2557. sp_digit mu;
  2558. sp_digit over;
  2559. sp_2048_norm_72(a + 71);
  2560. #ifdef WOLFSSL_SP_DH
  2561. if (mp != 1) {
  2562. for (i=0; i<70; i++) {
  2563. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  2564. sp_2048_mul_add_72(a+i, m, mu);
  2565. a[i+1] += a[i] >> 29;
  2566. }
  2567. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffL;
  2568. sp_2048_mul_add_72(a+i, m, mu);
  2569. a[i+1] += a[i] >> 29;
  2570. a[i] &= 0x1fffffff;
  2571. }
  2572. else {
  2573. for (i=0; i<70; i++) {
  2574. mu = a[i] & 0x1fffffff;
  2575. sp_2048_mul_add_72(a+i, m, mu);
  2576. a[i+1] += a[i] >> 29;
  2577. }
  2578. mu = a[i] & 0x3ffffL;
  2579. sp_2048_mul_add_72(a+i, m, mu);
  2580. a[i+1] += a[i] >> 29;
  2581. a[i] &= 0x1fffffff;
  2582. }
  2583. #else
  2584. for (i=0; i<70; i++) {
  2585. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  2586. sp_2048_mul_add_72(a+i, m, mu);
  2587. a[i+1] += a[i] >> 29;
  2588. }
  2589. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffL;
  2590. sp_2048_mul_add_72(a+i, m, mu);
  2591. a[i+1] += a[i] >> 29;
  2592. a[i] &= 0x1fffffff;
  2593. #endif
  2594. sp_2048_mont_shift_72(a, a);
  2595. over = a[70] - m[70];
  2596. sp_2048_cond_sub_72(a, a, m, ~((over - 1) >> 31));
  2597. sp_2048_norm_72(a);
  2598. }
  2599. /* Multiply two Montgomery form numbers mod the modulus (prime).
  2600. * (r = a * b mod m)
  2601. *
  2602. * r Result of multiplication.
  2603. * a First number to multiply in Montgomery form.
  2604. * b Second number to multiply in Montgomery form.
  2605. * m Modulus (prime).
  2606. * mp Montgomery multiplier.
  2607. */
  2608. SP_NOINLINE static void sp_2048_mont_mul_72(sp_digit* r, const sp_digit* a,
  2609. const sp_digit* b, const sp_digit* m, sp_digit mp)
  2610. {
  2611. sp_2048_mul_72(r, a, b);
  2612. sp_2048_mont_reduce_72(r, m, mp);
  2613. }
  2614. /* Square the Montgomery form number. (r = a * a mod m)
  2615. *
  2616. * r Result of squaring.
  2617. * a Number to square in Montgomery form.
  2618. * m Modulus (prime).
  2619. * mp Montgomery multiplier.
  2620. */
  2621. SP_NOINLINE static void sp_2048_mont_sqr_72(sp_digit* r, const sp_digit* a,
  2622. const sp_digit* m, sp_digit mp)
  2623. {
  2624. sp_2048_sqr_72(r, a);
  2625. sp_2048_mont_reduce_72(r, m, mp);
  2626. }
  2627. /* Normalize the values in each word to 29 bits.
  2628. *
  2629. * a Array of sp_digit to normalize.
  2630. */
  2631. static void sp_2048_norm_71(sp_digit* a)
  2632. {
  2633. #ifdef WOLFSSL_SP_SMALL
  2634. int i;
  2635. for (i = 0; i < 70; i++) {
  2636. a[i+1] += a[i] >> 29;
  2637. a[i] &= 0x1fffffff;
  2638. }
  2639. #else
  2640. int i;
  2641. for (i = 0; i < 64; i += 8) {
  2642. a[i+1] += a[i+0] >> 29; a[i+0] &= 0x1fffffff;
  2643. a[i+2] += a[i+1] >> 29; a[i+1] &= 0x1fffffff;
  2644. a[i+3] += a[i+2] >> 29; a[i+2] &= 0x1fffffff;
  2645. a[i+4] += a[i+3] >> 29; a[i+3] &= 0x1fffffff;
  2646. a[i+5] += a[i+4] >> 29; a[i+4] &= 0x1fffffff;
  2647. a[i+6] += a[i+5] >> 29; a[i+5] &= 0x1fffffff;
  2648. a[i+7] += a[i+6] >> 29; a[i+6] &= 0x1fffffff;
  2649. a[i+8] += a[i+7] >> 29; a[i+7] &= 0x1fffffff;
  2650. }
  2651. a[65] += a[64] >> 29; a[64] &= 0x1fffffff;
  2652. a[66] += a[65] >> 29; a[65] &= 0x1fffffff;
  2653. a[67] += a[66] >> 29; a[66] &= 0x1fffffff;
  2654. a[68] += a[67] >> 29; a[67] &= 0x1fffffff;
  2655. a[69] += a[68] >> 29; a[68] &= 0x1fffffff;
  2656. a[70] += a[69] >> 29; a[69] &= 0x1fffffff;
  2657. #endif /* WOLFSSL_SP_SMALL */
  2658. }
  2659. /* Multiply a by scalar b into r. (r = a * b)
  2660. *
  2661. * r A single precision integer.
  2662. * a A single precision integer.
  2663. * b A scalar.
  2664. */
  2665. SP_NOINLINE static void sp_2048_mul_d_144(sp_digit* r, const sp_digit* a,
  2666. sp_digit b)
  2667. {
  2668. #ifdef WOLFSSL_SP_SMALL
  2669. sp_int64 tb = b;
  2670. sp_int64 t = 0;
  2671. int i;
  2672. for (i = 0; i < 144; i++) {
  2673. t += tb * a[i];
  2674. r[i] = (sp_digit)(t & 0x1fffffff);
  2675. t >>= 29;
  2676. }
  2677. r[144] = (sp_digit)t;
  2678. #else
  2679. sp_int64 tb = b;
  2680. sp_int64 t = 0;
  2681. sp_digit t2;
  2682. sp_int64 p[4];
  2683. int i;
  2684. for (i = 0; i < 144; i += 4) {
  2685. p[0] = tb * a[i + 0];
  2686. p[1] = tb * a[i + 1];
  2687. p[2] = tb * a[i + 2];
  2688. p[3] = tb * a[i + 3];
  2689. t += p[0];
  2690. t2 = (sp_digit)(t & 0x1fffffff);
  2691. t >>= 29;
  2692. r[i + 0] = (sp_digit)t2;
  2693. t += p[1];
  2694. t2 = (sp_digit)(t & 0x1fffffff);
  2695. t >>= 29;
  2696. r[i + 1] = (sp_digit)t2;
  2697. t += p[2];
  2698. t2 = (sp_digit)(t & 0x1fffffff);
  2699. t >>= 29;
  2700. r[i + 2] = (sp_digit)t2;
  2701. t += p[3];
  2702. t2 = (sp_digit)(t & 0x1fffffff);
  2703. t >>= 29;
  2704. r[i + 3] = (sp_digit)t2;
  2705. }
  2706. r[144] = (sp_digit)(t & 0x1fffffff);
  2707. #endif /* WOLFSSL_SP_SMALL */
  2708. }
  2709. #ifdef WOLFSSL_SP_SMALL
  2710. /* Conditionally add a and b using the mask m.
  2711. * m is -1 to add and 0 when not.
  2712. *
  2713. * r A single precision number representing conditional add result.
  2714. * a A single precision number to add with.
  2715. * b A single precision number to add.
  2716. * m Mask value to apply.
  2717. */
  2718. static void sp_2048_cond_add_72(sp_digit* r, const sp_digit* a,
  2719. const sp_digit* b, const sp_digit m)
  2720. {
  2721. int i;
  2722. for (i = 0; i < 72; i++) {
  2723. r[i] = a[i] + (b[i] & m);
  2724. }
  2725. }
  2726. #endif /* WOLFSSL_SP_SMALL */
  2727. #ifndef WOLFSSL_SP_SMALL
  2728. /* Conditionally add a and b using the mask m.
  2729. * m is -1 to add and 0 when not.
  2730. *
  2731. * r A single precision number representing conditional add result.
  2732. * a A single precision number to add with.
  2733. * b A single precision number to add.
  2734. * m Mask value to apply.
  2735. */
  2736. static void sp_2048_cond_add_72(sp_digit* r, const sp_digit* a,
  2737. const sp_digit* b, const sp_digit m)
  2738. {
  2739. int i;
  2740. for (i = 0; i < 72; i += 8) {
  2741. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  2742. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  2743. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  2744. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  2745. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  2746. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  2747. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  2748. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  2749. }
  2750. }
  2751. #endif /* !WOLFSSL_SP_SMALL */
  2752. SP_NOINLINE static void sp_2048_rshift_72(sp_digit* r, const sp_digit* a,
  2753. byte n)
  2754. {
  2755. int i;
  2756. #ifdef WOLFSSL_SP_SMALL
  2757. for (i=0; i<71; i++) {
  2758. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  2759. }
  2760. #else
  2761. for (i=0; i<64; i += 8) {
  2762. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (29 - n)) & 0x1fffffff);
  2763. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (29 - n)) & 0x1fffffff);
  2764. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (29 - n)) & 0x1fffffff);
  2765. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (29 - n)) & 0x1fffffff);
  2766. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (29 - n)) & 0x1fffffff);
  2767. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (29 - n)) & 0x1fffffff);
  2768. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (29 - n)) & 0x1fffffff);
  2769. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (29 - n)) & 0x1fffffff);
  2770. }
  2771. r[64] = (a[64] >> n) | ((a[65] << (29 - n)) & 0x1fffffff);
  2772. r[65] = (a[65] >> n) | ((a[66] << (29 - n)) & 0x1fffffff);
  2773. r[66] = (a[66] >> n) | ((a[67] << (29 - n)) & 0x1fffffff);
  2774. r[67] = (a[67] >> n) | ((a[68] << (29 - n)) & 0x1fffffff);
  2775. r[68] = (a[68] >> n) | ((a[69] << (29 - n)) & 0x1fffffff);
  2776. r[69] = (a[69] >> n) | ((a[70] << (29 - n)) & 0x1fffffff);
  2777. r[70] = (a[70] >> n) | ((a[71] << (29 - n)) & 0x1fffffff);
  2778. #endif /* WOLFSSL_SP_SMALL */
  2779. r[71] = a[71] >> n;
  2780. }
  2781. static WC_INLINE sp_digit sp_2048_div_word_72(sp_digit d1, sp_digit d0,
  2782. sp_digit div)
  2783. {
  2784. #ifdef SP_USE_DIVTI3
  2785. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  2786. return d / div;
  2787. #elif defined(__x86_64__) || defined(__i386__)
  2788. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  2789. sp_uint32 lo = (sp_uint32)d;
  2790. sp_digit hi = (sp_digit)(d >> 32);
  2791. __asm__ __volatile__ (
  2792. "idiv %2"
  2793. : "+a" (lo)
  2794. : "d" (hi), "r" (div)
  2795. : "cc"
  2796. );
  2797. return (sp_digit)lo;
  2798. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  2799. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  2800. sp_digit dv = (div >> 1) + 1;
  2801. sp_digit t1 = (sp_digit)(d >> 29);
  2802. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  2803. sp_digit t2;
  2804. sp_digit sign;
  2805. sp_digit r;
  2806. int i;
  2807. sp_int64 m;
  2808. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  2809. t1 -= dv & (0 - r);
  2810. for (i = 27; i >= 1; i--) {
  2811. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  2812. t0 <<= 1;
  2813. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  2814. r += r + t2;
  2815. t1 -= dv & (0 - t2);
  2816. t1 += t2;
  2817. }
  2818. r += r + 1;
  2819. m = d - ((sp_int64)r * div);
  2820. r += (sp_digit)(m >> 29);
  2821. m = d - ((sp_int64)r * div);
  2822. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  2823. m = d - ((sp_int64)r * div);
  2824. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  2825. m *= sign;
  2826. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  2827. r += sign * t2;
  2828. m = d - ((sp_int64)r * div);
  2829. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  2830. m *= sign;
  2831. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  2832. r += sign * t2;
  2833. return r;
  2834. #else
  2835. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  2836. sp_digit r = 0;
  2837. sp_digit t;
  2838. sp_digit dv = (div >> 14) + 1;
  2839. t = (sp_digit)(d >> 28);
  2840. t = (t / dv) << 14;
  2841. r += t;
  2842. d -= (sp_int64)t * div;
  2843. t = (sp_digit)(d >> 13);
  2844. t = t / (dv << 1);
  2845. r += t;
  2846. d -= (sp_int64)t * div;
  2847. t = (sp_digit)d;
  2848. t = t / div;
  2849. r += t;
  2850. d -= (sp_int64)t * div;
  2851. return r;
  2852. #endif
  2853. }
  2854. static WC_INLINE sp_digit sp_2048_word_div_word_72(sp_digit d, sp_digit div)
  2855. {
  2856. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  2857. defined(SP_DIV_WORD_USE_DIV)
  2858. return d / div;
  2859. #else
  2860. return (sp_digit)((sp_uint32)(div - d) >> 31);
  2861. #endif
  2862. }
  2863. /* Divide d in a and put remainder into r (m*d + r = a)
  2864. * m is not calculated as it is not needed at this time.
  2865. *
  2866. * Full implementation.
  2867. *
  2868. * a Number to be divided.
  2869. * d Number to divide with.
  2870. * m Multiplier result.
  2871. * r Remainder from the division.
  2872. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  2873. */
  2874. static int sp_2048_div_72(const sp_digit* a, const sp_digit* d,
  2875. const sp_digit* m, sp_digit* r)
  2876. {
  2877. int i;
  2878. #ifndef WOLFSSL_SP_DIV_32
  2879. #endif
  2880. sp_digit dv;
  2881. sp_digit r1;
  2882. #ifdef WOLFSSL_SP_SMALL_STACK
  2883. sp_digit* t1 = NULL;
  2884. #else
  2885. sp_digit t1[4 * 72 + 3];
  2886. #endif
  2887. sp_digit* t2 = NULL;
  2888. sp_digit* sd = NULL;
  2889. int err = MP_OKAY;
  2890. (void)m;
  2891. #ifdef WOLFSSL_SP_SMALL_STACK
  2892. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 72 + 3), NULL,
  2893. DYNAMIC_TYPE_TMP_BUFFER);
  2894. if (t1 == NULL)
  2895. err = MEMORY_E;
  2896. #endif
  2897. (void)m;
  2898. if (err == MP_OKAY) {
  2899. t2 = t1 + 144 + 1;
  2900. sd = t2 + 72 + 1;
  2901. sp_2048_mul_d_72(sd, d, (sp_digit)1 << 11);
  2902. sp_2048_mul_d_144(t1, a, (sp_digit)1 << 11);
  2903. dv = sd[70];
  2904. t1[71 + 71] += t1[71 + 71 - 1] >> 29;
  2905. t1[71 + 71 - 1] &= 0x1fffffff;
  2906. for (i=71; i>=0; i--) {
  2907. r1 = sp_2048_div_word_72(t1[71 + i], t1[71 + i - 1], dv);
  2908. sp_2048_mul_d_72(t2, sd, r1);
  2909. (void)sp_2048_sub_72(&t1[i], &t1[i], t2);
  2910. sp_2048_norm_71(&t1[i]);
  2911. t1[71 + i] += t1[71 + i - 1] >> 29;
  2912. t1[71 + i - 1] &= 0x1fffffff;
  2913. r1 = sp_2048_div_word_72(-t1[71 + i], -t1[71 + i - 1], dv);
  2914. r1 -= t1[71 + i];
  2915. sp_2048_mul_d_72(t2, sd, r1);
  2916. (void)sp_2048_add_72(&t1[i], &t1[i], t2);
  2917. t1[71 + i] += t1[71 + i - 1] >> 29;
  2918. t1[71 + i - 1] &= 0x1fffffff;
  2919. }
  2920. t1[71 - 1] += t1[71 - 2] >> 29;
  2921. t1[71 - 2] &= 0x1fffffff;
  2922. r1 = sp_2048_word_div_word_72(t1[71 - 1], dv);
  2923. sp_2048_mul_d_72(t2, sd, r1);
  2924. sp_2048_sub_72(t1, t1, t2);
  2925. XMEMCPY(r, t1, sizeof(*r) * 144U);
  2926. for (i=0; i<70; i++) {
  2927. r[i+1] += r[i] >> 29;
  2928. r[i] &= 0x1fffffff;
  2929. }
  2930. sp_2048_cond_add_72(r, r, sd, r[70] >> 31);
  2931. sp_2048_norm_71(r);
  2932. sp_2048_rshift_72(r, r, 11);
  2933. r[71] = 0;
  2934. }
  2935. #ifdef WOLFSSL_SP_SMALL_STACK
  2936. if (t1 != NULL)
  2937. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  2938. #endif
  2939. return err;
  2940. }
  2941. /* Reduce a modulo m into r. (r = a mod m)
  2942. *
  2943. * r A single precision number that is the reduced result.
  2944. * a A single precision number that is to be reduced.
  2945. * m A single precision number that is the modulus to reduce with.
  2946. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  2947. */
  2948. static int sp_2048_mod_72(sp_digit* r, const sp_digit* a, const sp_digit* m)
  2949. {
  2950. return sp_2048_div_72(a, m, NULL, r);
  2951. }
  2952. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  2953. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
  2954. defined(WOLFSSL_HAVE_SP_DH)
  2955. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  2956. *
  2957. * r A single precision number that is the result of the operation.
  2958. * a A single precision number being exponentiated.
  2959. * e A single precision number that is the exponent.
  2960. * bits The number of bits in the exponent.
  2961. * m A single precision number that is the modulus.
  2962. * returns 0 on success.
  2963. * returns MEMORY_E on dynamic memory allocation failure.
  2964. * returns MP_VAL when base is even or exponent is 0.
  2965. */
  2966. static int sp_2048_mod_exp_72(sp_digit* r, const sp_digit* a, const sp_digit* e,
  2967. int bits, const sp_digit* m, int reduceA)
  2968. {
  2969. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  2970. #ifdef WOLFSSL_SP_SMALL_STACK
  2971. sp_digit* td = NULL;
  2972. #else
  2973. sp_digit td[3 * 144];
  2974. #endif
  2975. sp_digit* t[3] = {0, 0, 0};
  2976. sp_digit* norm = NULL;
  2977. sp_digit mp = 1;
  2978. sp_digit n;
  2979. int i;
  2980. int c;
  2981. byte y;
  2982. int err = MP_OKAY;
  2983. if (bits == 0) {
  2984. err = MP_VAL;
  2985. }
  2986. #ifdef WOLFSSL_SP_SMALL_STACK
  2987. if (err == MP_OKAY) {
  2988. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 72 * 2, NULL,
  2989. DYNAMIC_TYPE_TMP_BUFFER);
  2990. if (td == NULL)
  2991. err = MEMORY_E;
  2992. }
  2993. #endif
  2994. if (err == MP_OKAY) {
  2995. norm = td;
  2996. for (i=0; i<3; i++) {
  2997. t[i] = td + (i * 72 * 2);
  2998. XMEMSET(t[i], 0, sizeof(sp_digit) * 72U * 2U);
  2999. }
  3000. sp_2048_mont_setup(m, &mp);
  3001. sp_2048_mont_norm_72(norm, m);
  3002. if (reduceA != 0) {
  3003. err = sp_2048_mod_72(t[1], a, m);
  3004. }
  3005. else {
  3006. XMEMCPY(t[1], a, sizeof(sp_digit) * 72U);
  3007. }
  3008. }
  3009. if (err == MP_OKAY) {
  3010. sp_2048_mul_72(t[1], t[1], norm);
  3011. err = sp_2048_mod_72(t[1], t[1], m);
  3012. }
  3013. if (err == MP_OKAY) {
  3014. i = bits / 29;
  3015. c = bits % 29;
  3016. n = e[i--] << (29 - c);
  3017. for (; ; c--) {
  3018. if (c == 0) {
  3019. if (i == -1) {
  3020. break;
  3021. }
  3022. n = e[i--];
  3023. c = 29;
  3024. }
  3025. y = (int)((n >> 28) & 1);
  3026. n <<= 1;
  3027. sp_2048_mont_mul_72(t[y^1], t[0], t[1], m, mp);
  3028. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  3029. ((size_t)t[1] & addr_mask[y])),
  3030. sizeof(*t[2]) * 72 * 2);
  3031. sp_2048_mont_sqr_72(t[2], t[2], m, mp);
  3032. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  3033. ((size_t)t[1] & addr_mask[y])), t[2],
  3034. sizeof(*t[2]) * 72 * 2);
  3035. }
  3036. sp_2048_mont_reduce_72(t[0], m, mp);
  3037. n = sp_2048_cmp_72(t[0], m);
  3038. sp_2048_cond_sub_72(t[0], t[0], m, ~(n >> 31));
  3039. XMEMCPY(r, t[0], sizeof(*r) * 72 * 2);
  3040. }
  3041. #ifdef WOLFSSL_SP_SMALL_STACK
  3042. if (td != NULL)
  3043. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  3044. #endif
  3045. return err;
  3046. #elif !defined(WC_NO_CACHE_RESISTANT)
  3047. #ifdef WOLFSSL_SP_SMALL_STACK
  3048. sp_digit* td = NULL;
  3049. #else
  3050. sp_digit td[3 * 144];
  3051. #endif
  3052. sp_digit* t[3] = {0, 0, 0};
  3053. sp_digit* norm = NULL;
  3054. sp_digit mp = 1;
  3055. sp_digit n;
  3056. int i;
  3057. int c;
  3058. byte y;
  3059. int err = MP_OKAY;
  3060. if (bits == 0) {
  3061. err = MP_VAL;
  3062. }
  3063. #ifdef WOLFSSL_SP_SMALL_STACK
  3064. if (err == MP_OKAY) {
  3065. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 72 * 2, NULL,
  3066. DYNAMIC_TYPE_TMP_BUFFER);
  3067. if (td == NULL)
  3068. err = MEMORY_E;
  3069. }
  3070. #endif
  3071. if (err == MP_OKAY) {
  3072. norm = td;
  3073. for (i=0; i<3; i++) {
  3074. t[i] = td + (i * 72 * 2);
  3075. }
  3076. sp_2048_mont_setup(m, &mp);
  3077. sp_2048_mont_norm_72(norm, m);
  3078. if (reduceA != 0) {
  3079. err = sp_2048_mod_72(t[1], a, m);
  3080. if (err == MP_OKAY) {
  3081. sp_2048_mul_72(t[1], t[1], norm);
  3082. err = sp_2048_mod_72(t[1], t[1], m);
  3083. }
  3084. }
  3085. else {
  3086. sp_2048_mul_72(t[1], a, norm);
  3087. err = sp_2048_mod_72(t[1], t[1], m);
  3088. }
  3089. }
  3090. if (err == MP_OKAY) {
  3091. i = bits / 29;
  3092. c = bits % 29;
  3093. n = e[i--] << (29 - c);
  3094. for (; ; c--) {
  3095. if (c == 0) {
  3096. if (i == -1) {
  3097. break;
  3098. }
  3099. n = e[i--];
  3100. c = 29;
  3101. }
  3102. y = (int)((n >> 28) & 1);
  3103. n <<= 1;
  3104. sp_2048_mont_mul_72(t[y^1], t[0], t[1], m, mp);
  3105. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  3106. ((size_t)t[1] & addr_mask[y])),
  3107. sizeof(*t[2]) * 72 * 2);
  3108. sp_2048_mont_sqr_72(t[2], t[2], m, mp);
  3109. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  3110. ((size_t)t[1] & addr_mask[y])), t[2],
  3111. sizeof(*t[2]) * 72 * 2);
  3112. }
  3113. sp_2048_mont_reduce_72(t[0], m, mp);
  3114. n = sp_2048_cmp_72(t[0], m);
  3115. sp_2048_cond_sub_72(t[0], t[0], m, ~(n >> 31));
  3116. XMEMCPY(r, t[0], sizeof(*r) * 72 * 2);
  3117. }
  3118. #ifdef WOLFSSL_SP_SMALL_STACK
  3119. if (td != NULL)
  3120. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  3121. #endif
  3122. return err;
  3123. #else
  3124. #ifdef WOLFSSL_SP_SMALL_STACK
  3125. sp_digit* td = NULL;
  3126. #else
  3127. sp_digit td[(16 * 144) + 144];
  3128. #endif
  3129. sp_digit* t[16];
  3130. sp_digit* rt = NULL;
  3131. sp_digit* norm = NULL;
  3132. sp_digit mp = 1;
  3133. sp_digit n;
  3134. int i;
  3135. int c;
  3136. byte y;
  3137. int err = MP_OKAY;
  3138. if (bits == 0) {
  3139. err = MP_VAL;
  3140. }
  3141. #ifdef WOLFSSL_SP_SMALL_STACK
  3142. if (err == MP_OKAY) {
  3143. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((16 * 144) + 144), NULL,
  3144. DYNAMIC_TYPE_TMP_BUFFER);
  3145. if (td == NULL)
  3146. err = MEMORY_E;
  3147. }
  3148. #endif
  3149. if (err == MP_OKAY) {
  3150. norm = td;
  3151. for (i=0; i<16; i++)
  3152. t[i] = td + i * 144;
  3153. rt = td + 2304;
  3154. sp_2048_mont_setup(m, &mp);
  3155. sp_2048_mont_norm_72(norm, m);
  3156. if (reduceA != 0) {
  3157. err = sp_2048_mod_72(t[1], a, m);
  3158. if (err == MP_OKAY) {
  3159. sp_2048_mul_72(t[1], t[1], norm);
  3160. err = sp_2048_mod_72(t[1], t[1], m);
  3161. }
  3162. }
  3163. else {
  3164. sp_2048_mul_72(t[1], a, norm);
  3165. err = sp_2048_mod_72(t[1], t[1], m);
  3166. }
  3167. }
  3168. if (err == MP_OKAY) {
  3169. sp_2048_mont_sqr_72(t[ 2], t[ 1], m, mp);
  3170. sp_2048_mont_mul_72(t[ 3], t[ 2], t[ 1], m, mp);
  3171. sp_2048_mont_sqr_72(t[ 4], t[ 2], m, mp);
  3172. sp_2048_mont_mul_72(t[ 5], t[ 3], t[ 2], m, mp);
  3173. sp_2048_mont_sqr_72(t[ 6], t[ 3], m, mp);
  3174. sp_2048_mont_mul_72(t[ 7], t[ 4], t[ 3], m, mp);
  3175. sp_2048_mont_sqr_72(t[ 8], t[ 4], m, mp);
  3176. sp_2048_mont_mul_72(t[ 9], t[ 5], t[ 4], m, mp);
  3177. sp_2048_mont_sqr_72(t[10], t[ 5], m, mp);
  3178. sp_2048_mont_mul_72(t[11], t[ 6], t[ 5], m, mp);
  3179. sp_2048_mont_sqr_72(t[12], t[ 6], m, mp);
  3180. sp_2048_mont_mul_72(t[13], t[ 7], t[ 6], m, mp);
  3181. sp_2048_mont_sqr_72(t[14], t[ 7], m, mp);
  3182. sp_2048_mont_mul_72(t[15], t[ 8], t[ 7], m, mp);
  3183. bits = ((bits + 3) / 4) * 4;
  3184. i = ((bits + 28) / 29) - 1;
  3185. c = bits % 29;
  3186. if (c == 0) {
  3187. c = 29;
  3188. }
  3189. if (i < 72) {
  3190. n = e[i--] << (32 - c);
  3191. }
  3192. else {
  3193. n = 0;
  3194. i--;
  3195. }
  3196. if (c < 4) {
  3197. n |= e[i--] << (3 - c);
  3198. c += 29;
  3199. }
  3200. y = (int)((n >> 28) & 0xf);
  3201. n <<= 4;
  3202. c -= 4;
  3203. XMEMCPY(rt, t[y], sizeof(sp_digit) * 144);
  3204. while ((i >= 0) || (c >= 4)) {
  3205. if (c >= 4) {
  3206. y = (byte)((n >> 28) & 0xf);
  3207. n <<= 4;
  3208. c -= 4;
  3209. }
  3210. else if (c == 0) {
  3211. n = e[i--] << 3;
  3212. y = (byte)((n >> 28) & 0xf);
  3213. n <<= 4;
  3214. c = 25;
  3215. }
  3216. else {
  3217. y = (byte)((n >> 28) & 0xf);
  3218. n = e[i--] << 3;
  3219. c = 4 - c;
  3220. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  3221. n <<= c;
  3222. c = 29 - c;
  3223. }
  3224. sp_2048_mont_sqr_72(rt, rt, m, mp);
  3225. sp_2048_mont_sqr_72(rt, rt, m, mp);
  3226. sp_2048_mont_sqr_72(rt, rt, m, mp);
  3227. sp_2048_mont_sqr_72(rt, rt, m, mp);
  3228. sp_2048_mont_mul_72(rt, rt, t[y], m, mp);
  3229. }
  3230. sp_2048_mont_reduce_72(rt, m, mp);
  3231. n = sp_2048_cmp_72(rt, m);
  3232. sp_2048_cond_sub_72(rt, rt, m, ~(n >> 31));
  3233. XMEMCPY(r, rt, sizeof(sp_digit) * 144);
  3234. }
  3235. #ifdef WOLFSSL_SP_SMALL_STACK
  3236. if (td != NULL)
  3237. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  3238. #endif
  3239. return err;
  3240. #endif
  3241. }
  3242. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) || */
  3243. /* WOLFSSL_HAVE_SP_DH */
  3244. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  3245. #ifdef WOLFSSL_HAVE_SP_RSA
  3246. /* RSA public key operation.
  3247. *
  3248. * in Array of bytes representing the number to exponentiate, base.
  3249. * inLen Number of bytes in base.
  3250. * em Public exponent.
  3251. * mm Modulus.
  3252. * out Buffer to hold big-endian bytes of exponentiation result.
  3253. * Must be at least 256 bytes long.
  3254. * outLen Number of bytes in result.
  3255. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  3256. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  3257. */
  3258. int sp_RsaPublic_2048(const byte* in, word32 inLen, const mp_int* em,
  3259. const mp_int* mm, byte* out, word32* outLen)
  3260. {
  3261. #ifdef WOLFSSL_SP_SMALL
  3262. #ifdef WOLFSSL_SP_SMALL_STACK
  3263. sp_digit* a = NULL;
  3264. #else
  3265. sp_digit a[72 * 5];
  3266. #endif
  3267. sp_digit* m = NULL;
  3268. sp_digit* r = NULL;
  3269. sp_digit* norm = NULL;
  3270. sp_uint64 e[1] = {0};
  3271. sp_digit mp = 0;
  3272. int i;
  3273. int err = MP_OKAY;
  3274. if (*outLen < 256U) {
  3275. err = MP_TO_E;
  3276. }
  3277. if (err == MP_OKAY) {
  3278. if (mp_count_bits(em) > 64) {
  3279. err = MP_READ_E;
  3280. }
  3281. else if (inLen > 256U) {
  3282. err = MP_READ_E;
  3283. }
  3284. else if (mp_count_bits(mm) != 2048) {
  3285. err = MP_READ_E;
  3286. }
  3287. else if (mp_iseven(mm)) {
  3288. err = MP_VAL;
  3289. }
  3290. }
  3291. #ifdef WOLFSSL_SP_SMALL_STACK
  3292. if (err == MP_OKAY) {
  3293. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 5, NULL,
  3294. DYNAMIC_TYPE_RSA);
  3295. if (a == NULL)
  3296. err = MEMORY_E;
  3297. }
  3298. #endif
  3299. if (err == MP_OKAY) {
  3300. r = a + 72 * 2;
  3301. m = r + 72 * 2;
  3302. norm = r;
  3303. sp_2048_from_bin(a, 72, in, inLen);
  3304. #if DIGIT_BIT >= 64
  3305. e[0] = (sp_uint64)em->dp[0];
  3306. #else
  3307. e[0] = (sp_uint64)em->dp[0];
  3308. if (em->used > 1) {
  3309. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  3310. }
  3311. #endif
  3312. if (e[0] == 0) {
  3313. err = MP_EXPTMOD_E;
  3314. }
  3315. }
  3316. if (err == MP_OKAY) {
  3317. sp_2048_from_mp(m, 72, mm);
  3318. sp_2048_mont_setup(m, &mp);
  3319. sp_2048_mont_norm_72(norm, m);
  3320. }
  3321. if (err == MP_OKAY) {
  3322. sp_2048_mul_72(a, a, norm);
  3323. err = sp_2048_mod_72(a, a, m);
  3324. }
  3325. if (err == MP_OKAY) {
  3326. for (i=63; i>=0; i--) {
  3327. if ((e[0] >> i) != 0) {
  3328. break;
  3329. }
  3330. }
  3331. XMEMCPY(r, a, sizeof(sp_digit) * 72 * 2);
  3332. for (i--; i>=0; i--) {
  3333. sp_2048_mont_sqr_72(r, r, m, mp);
  3334. if (((e[0] >> i) & 1) == 1) {
  3335. sp_2048_mont_mul_72(r, r, a, m, mp);
  3336. }
  3337. }
  3338. sp_2048_mont_reduce_72(r, m, mp);
  3339. mp = sp_2048_cmp_72(r, m);
  3340. sp_2048_cond_sub_72(r, r, m, ~(mp >> 31));
  3341. sp_2048_to_bin_72(r, out);
  3342. *outLen = 256;
  3343. }
  3344. #ifdef WOLFSSL_SP_SMALL_STACK
  3345. if (a != NULL)
  3346. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  3347. #endif
  3348. return err;
  3349. #else
  3350. #ifdef WOLFSSL_SP_SMALL_STACK
  3351. sp_digit* d = NULL;
  3352. #else
  3353. sp_digit d[72 * 5];
  3354. #endif
  3355. sp_digit* a = NULL;
  3356. sp_digit* m = NULL;
  3357. sp_digit* r = NULL;
  3358. sp_uint64 e[1] = {0};
  3359. int err = MP_OKAY;
  3360. if (*outLen < 256U) {
  3361. err = MP_TO_E;
  3362. }
  3363. if (err == MP_OKAY) {
  3364. if (mp_count_bits(em) > 64) {
  3365. err = MP_READ_E;
  3366. }
  3367. else if (inLen > 256U) {
  3368. err = MP_READ_E;
  3369. }
  3370. else if (mp_count_bits(mm) != 2048) {
  3371. err = MP_READ_E;
  3372. }
  3373. else if (mp_iseven(mm)) {
  3374. err = MP_VAL;
  3375. }
  3376. }
  3377. #ifdef WOLFSSL_SP_SMALL_STACK
  3378. if (err == MP_OKAY) {
  3379. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 5, NULL,
  3380. DYNAMIC_TYPE_RSA);
  3381. if (d == NULL)
  3382. err = MEMORY_E;
  3383. }
  3384. #endif
  3385. if (err == MP_OKAY) {
  3386. a = d;
  3387. r = a + 72 * 2;
  3388. m = r + 72 * 2;
  3389. sp_2048_from_bin(a, 72, in, inLen);
  3390. #if DIGIT_BIT >= 64
  3391. e[0] = (sp_uint64)em->dp[0];
  3392. #else
  3393. e[0] = (sp_uint64)em->dp[0];
  3394. if (em->used > 1) {
  3395. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  3396. }
  3397. #endif
  3398. if (e[0] == 0) {
  3399. err = MP_EXPTMOD_E;
  3400. }
  3401. }
  3402. if (err == MP_OKAY) {
  3403. sp_2048_from_mp(m, 72, mm);
  3404. if (e[0] == 0x3) {
  3405. sp_2048_sqr_72(r, a);
  3406. err = sp_2048_mod_72(r, r, m);
  3407. if (err == MP_OKAY) {
  3408. sp_2048_mul_72(r, a, r);
  3409. err = sp_2048_mod_72(r, r, m);
  3410. }
  3411. }
  3412. else {
  3413. sp_digit* norm = r;
  3414. int i;
  3415. sp_digit mp;
  3416. sp_2048_mont_setup(m, &mp);
  3417. sp_2048_mont_norm_72(norm, m);
  3418. sp_2048_mul_72(a, a, norm);
  3419. err = sp_2048_mod_72(a, a, m);
  3420. if (err == MP_OKAY) {
  3421. for (i=63; i>=0; i--) {
  3422. if ((e[0] >> i) != 0) {
  3423. break;
  3424. }
  3425. }
  3426. XMEMCPY(r, a, sizeof(sp_digit) * 144U);
  3427. for (i--; i>=0; i--) {
  3428. sp_2048_mont_sqr_72(r, r, m, mp);
  3429. if (((e[0] >> i) & 1) == 1) {
  3430. sp_2048_mont_mul_72(r, r, a, m, mp);
  3431. }
  3432. }
  3433. sp_2048_mont_reduce_72(r, m, mp);
  3434. mp = sp_2048_cmp_72(r, m);
  3435. sp_2048_cond_sub_72(r, r, m, ~(mp >> 31));
  3436. }
  3437. }
  3438. }
  3439. if (err == MP_OKAY) {
  3440. sp_2048_to_bin_72(r, out);
  3441. *outLen = 256;
  3442. }
  3443. #ifdef WOLFSSL_SP_SMALL_STACK
  3444. if (d != NULL)
  3445. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  3446. #endif
  3447. return err;
  3448. #endif /* WOLFSSL_SP_SMALL */
  3449. }
  3450. #ifndef WOLFSSL_RSA_PUBLIC_ONLY
  3451. #if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
  3452. #endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
  3453. /* RSA private key operation.
  3454. *
  3455. * in Array of bytes representing the number to exponentiate, base.
  3456. * inLen Number of bytes in base.
  3457. * dm Private exponent.
  3458. * pm First prime.
  3459. * qm Second prime.
  3460. * dpm First prime's CRT exponent.
  3461. * dqm Second prime's CRT exponent.
  3462. * qim Inverse of second prime mod p.
  3463. * mm Modulus.
  3464. * out Buffer to hold big-endian bytes of exponentiation result.
  3465. * Must be at least 256 bytes long.
  3466. * outLen Number of bytes in result.
  3467. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  3468. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  3469. */
  3470. int sp_RsaPrivate_2048(const byte* in, word32 inLen, const mp_int* dm,
  3471. const mp_int* pm, const mp_int* qm, const mp_int* dpm, const mp_int* dqm,
  3472. const mp_int* qim, const mp_int* mm, byte* out, word32* outLen)
  3473. {
  3474. #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
  3475. #if defined(WOLFSSL_SP_SMALL)
  3476. #ifdef WOLFSSL_SP_SMALL_STACK
  3477. sp_digit* d = NULL;
  3478. #else
  3479. sp_digit d[72 * 4];
  3480. #endif
  3481. sp_digit* a = NULL;
  3482. sp_digit* m = NULL;
  3483. sp_digit* r = NULL;
  3484. int err = MP_OKAY;
  3485. (void)pm;
  3486. (void)qm;
  3487. (void)dpm;
  3488. (void)dqm;
  3489. (void)qim;
  3490. if (*outLen < 256U) {
  3491. err = MP_TO_E;
  3492. }
  3493. if (err == MP_OKAY) {
  3494. if (mp_count_bits(dm) > 2048) {
  3495. err = MP_READ_E;
  3496. }
  3497. else if (inLen > 256) {
  3498. err = MP_READ_E;
  3499. }
  3500. else if (mp_count_bits(mm) != 2048) {
  3501. err = MP_READ_E;
  3502. }
  3503. else if (mp_iseven(mm)) {
  3504. err = MP_VAL;
  3505. }
  3506. }
  3507. #ifdef WOLFSSL_SP_SMALL_STACK
  3508. if (err == MP_OKAY) {
  3509. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 4, NULL,
  3510. DYNAMIC_TYPE_RSA);
  3511. if (d == NULL)
  3512. err = MEMORY_E;
  3513. }
  3514. #endif
  3515. if (err == MP_OKAY) {
  3516. a = d + 72;
  3517. m = a + 144;
  3518. r = a;
  3519. sp_2048_from_bin(a, 72, in, inLen);
  3520. sp_2048_from_mp(d, 72, dm);
  3521. sp_2048_from_mp(m, 72, mm);
  3522. err = sp_2048_mod_exp_72(r, a, d, 2048, m, 0);
  3523. }
  3524. if (err == MP_OKAY) {
  3525. sp_2048_to_bin_72(r, out);
  3526. *outLen = 256;
  3527. }
  3528. #ifdef WOLFSSL_SP_SMALL_STACK
  3529. if (d != NULL)
  3530. #endif
  3531. {
  3532. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  3533. if (a != NULL)
  3534. ForceZero(a, sizeof(sp_digit) * 72);
  3535. #ifdef WOLFSSL_SP_SMALL_STACK
  3536. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  3537. #endif
  3538. }
  3539. return err;
  3540. #else
  3541. #ifdef WOLFSSL_SP_SMALL_STACK
  3542. sp_digit* d = NULL;
  3543. #else
  3544. sp_digit d[72 * 4];
  3545. #endif
  3546. sp_digit* a = NULL;
  3547. sp_digit* m = NULL;
  3548. sp_digit* r = NULL;
  3549. int err = MP_OKAY;
  3550. (void)pm;
  3551. (void)qm;
  3552. (void)dpm;
  3553. (void)dqm;
  3554. (void)qim;
  3555. if (*outLen < 256U) {
  3556. err = MP_TO_E;
  3557. }
  3558. if (err == MP_OKAY) {
  3559. if (mp_count_bits(dm) > 2048) {
  3560. err = MP_READ_E;
  3561. }
  3562. else if (inLen > 256U) {
  3563. err = MP_READ_E;
  3564. }
  3565. else if (mp_count_bits(mm) != 2048) {
  3566. err = MP_READ_E;
  3567. }
  3568. else if (mp_iseven(mm)) {
  3569. err = MP_VAL;
  3570. }
  3571. }
  3572. #ifdef WOLFSSL_SP_SMALL_STACK
  3573. if (err == MP_OKAY) {
  3574. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 4, NULL,
  3575. DYNAMIC_TYPE_RSA);
  3576. if (d == NULL)
  3577. err = MEMORY_E;
  3578. }
  3579. #endif
  3580. if (err == MP_OKAY) {
  3581. a = d + 72;
  3582. m = a + 144;
  3583. r = a;
  3584. sp_2048_from_bin(a, 72, in, inLen);
  3585. sp_2048_from_mp(d, 72, dm);
  3586. sp_2048_from_mp(m, 72, mm);
  3587. err = sp_2048_mod_exp_72(r, a, d, 2048, m, 0);
  3588. }
  3589. if (err == MP_OKAY) {
  3590. sp_2048_to_bin_72(r, out);
  3591. *outLen = 256;
  3592. }
  3593. #ifdef WOLFSSL_SP_SMALL_STACK
  3594. if (d != NULL)
  3595. #endif
  3596. {
  3597. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  3598. if (a != NULL)
  3599. ForceZero(a, sizeof(sp_digit) * 72);
  3600. #ifdef WOLFSSL_SP_SMALL_STACK
  3601. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  3602. #endif
  3603. }
  3604. return err;
  3605. #endif /* WOLFSSL_SP_SMALL */
  3606. #else
  3607. #if defined(WOLFSSL_SP_SMALL)
  3608. #ifdef WOLFSSL_SP_SMALL_STACK
  3609. sp_digit* a = NULL;
  3610. #else
  3611. sp_digit a[36 * 8];
  3612. #endif
  3613. sp_digit* p = NULL;
  3614. sp_digit* dp = NULL;
  3615. sp_digit* dq = NULL;
  3616. sp_digit* qi = NULL;
  3617. sp_digit* tmpa = NULL;
  3618. sp_digit* tmpb = NULL;
  3619. sp_digit* r = NULL;
  3620. int err = MP_OKAY;
  3621. (void)dm;
  3622. (void)mm;
  3623. if (*outLen < 256U) {
  3624. err = MP_TO_E;
  3625. }
  3626. if (err == MP_OKAY) {
  3627. if (inLen > 256) {
  3628. err = MP_READ_E;
  3629. }
  3630. else if (mp_count_bits(mm) != 2048) {
  3631. err = MP_READ_E;
  3632. }
  3633. else if (mp_iseven(mm)) {
  3634. err = MP_VAL;
  3635. }
  3636. else if (mp_iseven(pm)) {
  3637. err = MP_VAL;
  3638. }
  3639. else if (mp_iseven(qm)) {
  3640. err = MP_VAL;
  3641. }
  3642. }
  3643. #ifdef WOLFSSL_SP_SMALL_STACK
  3644. if (err == MP_OKAY) {
  3645. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 36 * 8, NULL,
  3646. DYNAMIC_TYPE_RSA);
  3647. if (a == NULL)
  3648. err = MEMORY_E;
  3649. }
  3650. #endif
  3651. if (err == MP_OKAY) {
  3652. p = a + 72;
  3653. qi = dq = dp = p + 36;
  3654. tmpa = qi + 36;
  3655. tmpb = tmpa + 72;
  3656. r = a;
  3657. sp_2048_from_bin(a, 72, in, inLen);
  3658. sp_2048_from_mp(p, 36, pm);
  3659. sp_2048_from_mp(dp, 36, dpm);
  3660. err = sp_2048_mod_exp_36(tmpa, a, dp, 1024, p, 1);
  3661. }
  3662. if (err == MP_OKAY) {
  3663. sp_2048_from_mp(p, 36, qm);
  3664. sp_2048_from_mp(dq, 36, dqm);
  3665. err = sp_2048_mod_exp_36(tmpb, a, dq, 1024, p, 1);
  3666. }
  3667. if (err == MP_OKAY) {
  3668. sp_2048_from_mp(p, 36, pm);
  3669. (void)sp_2048_sub_36(tmpa, tmpa, tmpb);
  3670. sp_2048_norm_36(tmpa);
  3671. sp_2048_cond_add_36(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[35] >> 31));
  3672. sp_2048_cond_add_36(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[35] >> 31));
  3673. sp_2048_norm_36(tmpa);
  3674. sp_2048_from_mp(qi, 36, qim);
  3675. sp_2048_mul_36(tmpa, tmpa, qi);
  3676. err = sp_2048_mod_36(tmpa, tmpa, p);
  3677. }
  3678. if (err == MP_OKAY) {
  3679. sp_2048_from_mp(p, 36, qm);
  3680. sp_2048_mul_36(tmpa, p, tmpa);
  3681. (void)sp_2048_add_72(r, tmpb, tmpa);
  3682. sp_2048_norm_72(r);
  3683. sp_2048_to_bin_72(r, out);
  3684. *outLen = 256;
  3685. }
  3686. #ifdef WOLFSSL_SP_SMALL_STACK
  3687. if (a != NULL)
  3688. #endif
  3689. {
  3690. ForceZero(a, sizeof(sp_digit) * 36 * 8);
  3691. #ifdef WOLFSSL_SP_SMALL_STACK
  3692. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  3693. #endif
  3694. }
  3695. return err;
  3696. #else
  3697. #ifdef WOLFSSL_SP_SMALL_STACK
  3698. sp_digit* a = NULL;
  3699. #else
  3700. sp_digit a[36 * 13];
  3701. #endif
  3702. sp_digit* p = NULL;
  3703. sp_digit* q = NULL;
  3704. sp_digit* dp = NULL;
  3705. sp_digit* dq = NULL;
  3706. sp_digit* qi = NULL;
  3707. sp_digit* tmpa = NULL;
  3708. sp_digit* tmpb = NULL;
  3709. sp_digit* r = NULL;
  3710. int err = MP_OKAY;
  3711. (void)dm;
  3712. (void)mm;
  3713. if (*outLen < 256U) {
  3714. err = MP_TO_E;
  3715. }
  3716. if (err == MP_OKAY) {
  3717. if (inLen > 256U) {
  3718. err = MP_READ_E;
  3719. }
  3720. else if (mp_count_bits(mm) != 2048) {
  3721. err = MP_READ_E;
  3722. }
  3723. else if (mp_iseven(mm)) {
  3724. err = MP_VAL;
  3725. }
  3726. else if (mp_iseven(pm)) {
  3727. err = MP_VAL;
  3728. }
  3729. else if (mp_iseven(qm)) {
  3730. err = MP_VAL;
  3731. }
  3732. }
  3733. #ifdef WOLFSSL_SP_SMALL_STACK
  3734. if (err == MP_OKAY) {
  3735. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 36 * 13, NULL,
  3736. DYNAMIC_TYPE_RSA);
  3737. if (a == NULL)
  3738. err = MEMORY_E;
  3739. }
  3740. #endif
  3741. if (err == MP_OKAY) {
  3742. p = a + 72 * 2;
  3743. q = p + 36;
  3744. dp = q + 36;
  3745. dq = dp + 36;
  3746. qi = dq + 36;
  3747. tmpa = qi + 36;
  3748. tmpb = tmpa + 72;
  3749. r = a;
  3750. sp_2048_from_bin(a, 72, in, inLen);
  3751. sp_2048_from_mp(p, 36, pm);
  3752. sp_2048_from_mp(q, 36, qm);
  3753. sp_2048_from_mp(dp, 36, dpm);
  3754. sp_2048_from_mp(dq, 36, dqm);
  3755. sp_2048_from_mp(qi, 36, qim);
  3756. err = sp_2048_mod_exp_36(tmpa, a, dp, 1024, p, 1);
  3757. }
  3758. if (err == MP_OKAY) {
  3759. err = sp_2048_mod_exp_36(tmpb, a, dq, 1024, q, 1);
  3760. }
  3761. if (err == MP_OKAY) {
  3762. (void)sp_2048_sub_36(tmpa, tmpa, tmpb);
  3763. sp_2048_norm_36(tmpa);
  3764. sp_2048_cond_add_36(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[35] >> 31));
  3765. sp_2048_cond_add_36(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[35] >> 31));
  3766. sp_2048_norm_36(tmpa);
  3767. sp_2048_mul_36(tmpa, tmpa, qi);
  3768. err = sp_2048_mod_36(tmpa, tmpa, p);
  3769. }
  3770. if (err == MP_OKAY) {
  3771. sp_2048_mul_36(tmpa, tmpa, q);
  3772. (void)sp_2048_add_72(r, tmpb, tmpa);
  3773. sp_2048_norm_72(r);
  3774. sp_2048_to_bin_72(r, out);
  3775. *outLen = 256;
  3776. }
  3777. #ifdef WOLFSSL_SP_SMALL_STACK
  3778. if (a != NULL)
  3779. #endif
  3780. {
  3781. ForceZero(a, sizeof(sp_digit) * 36 * 13);
  3782. #ifdef WOLFSSL_SP_SMALL_STACK
  3783. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  3784. #endif
  3785. }
  3786. return err;
  3787. #endif /* WOLFSSL_SP_SMALL */
  3788. #endif /* SP_RSA_PRIVATE_EXP_D || RSA_LOW_MEM */
  3789. }
  3790. #endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
  3791. #endif /* WOLFSSL_HAVE_SP_RSA */
  3792. #if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
  3793. !defined(WOLFSSL_RSA_PUBLIC_ONLY))
  3794. /* Convert an array of sp_digit to an mp_int.
  3795. *
  3796. * a A single precision integer.
  3797. * r A multi-precision integer.
  3798. */
  3799. static int sp_2048_to_mp(const sp_digit* a, mp_int* r)
  3800. {
  3801. int err;
  3802. err = mp_grow(r, (2048 + DIGIT_BIT - 1) / DIGIT_BIT);
  3803. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  3804. #if DIGIT_BIT == 29
  3805. XMEMCPY(r->dp, a, sizeof(sp_digit) * 71);
  3806. r->used = 71;
  3807. mp_clamp(r);
  3808. #elif DIGIT_BIT < 29
  3809. int i;
  3810. int j = 0;
  3811. int s = 0;
  3812. r->dp[0] = 0;
  3813. for (i = 0; i < 71; i++) {
  3814. r->dp[j] |= (mp_digit)(a[i] << s);
  3815. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  3816. s = DIGIT_BIT - s;
  3817. r->dp[++j] = (mp_digit)(a[i] >> s);
  3818. while (s + DIGIT_BIT <= 29) {
  3819. s += DIGIT_BIT;
  3820. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  3821. if (s == SP_WORD_SIZE) {
  3822. r->dp[j] = 0;
  3823. }
  3824. else {
  3825. r->dp[j] = (mp_digit)(a[i] >> s);
  3826. }
  3827. }
  3828. s = 29 - s;
  3829. }
  3830. r->used = (2048 + DIGIT_BIT - 1) / DIGIT_BIT;
  3831. mp_clamp(r);
  3832. #else
  3833. int i;
  3834. int j = 0;
  3835. int s = 0;
  3836. r->dp[0] = 0;
  3837. for (i = 0; i < 71; i++) {
  3838. r->dp[j] |= ((mp_digit)a[i]) << s;
  3839. if (s + 29 >= DIGIT_BIT) {
  3840. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  3841. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  3842. #endif
  3843. s = DIGIT_BIT - s;
  3844. r->dp[++j] = a[i] >> s;
  3845. s = 29 - s;
  3846. }
  3847. else {
  3848. s += 29;
  3849. }
  3850. }
  3851. r->used = (2048 + DIGIT_BIT - 1) / DIGIT_BIT;
  3852. mp_clamp(r);
  3853. #endif
  3854. }
  3855. return err;
  3856. }
  3857. /* Perform the modular exponentiation for Diffie-Hellman.
  3858. *
  3859. * base Base. MP integer.
  3860. * exp Exponent. MP integer.
  3861. * mod Modulus. MP integer.
  3862. * res Result. MP integer.
  3863. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  3864. * and MEMORY_E if memory allocation fails.
  3865. */
  3866. int sp_ModExp_2048(const mp_int* base, const mp_int* exp, const mp_int* mod,
  3867. mp_int* res)
  3868. {
  3869. #ifdef WOLFSSL_SP_SMALL
  3870. int err = MP_OKAY;
  3871. #ifdef WOLFSSL_SP_SMALL_STACK
  3872. sp_digit* b = NULL;
  3873. #else
  3874. sp_digit b[72 * 4];
  3875. #endif
  3876. sp_digit* e = NULL;
  3877. sp_digit* m = NULL;
  3878. sp_digit* r = NULL;
  3879. int expBits = mp_count_bits(exp);
  3880. if (mp_count_bits(base) > 2048) {
  3881. err = MP_READ_E;
  3882. }
  3883. else if (expBits > 2048) {
  3884. err = MP_READ_E;
  3885. }
  3886. else if (mp_count_bits(mod) != 2048) {
  3887. err = MP_READ_E;
  3888. }
  3889. else if (mp_iseven(mod)) {
  3890. err = MP_VAL;
  3891. }
  3892. #ifdef WOLFSSL_SP_SMALL_STACK
  3893. if (err == MP_OKAY) {
  3894. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 4, NULL,
  3895. DYNAMIC_TYPE_DH);
  3896. if (b == NULL)
  3897. err = MEMORY_E;
  3898. }
  3899. #endif
  3900. if (err == MP_OKAY) {
  3901. e = b + 72 * 2;
  3902. m = e + 72;
  3903. r = b;
  3904. sp_2048_from_mp(b, 72, base);
  3905. sp_2048_from_mp(e, 72, exp);
  3906. sp_2048_from_mp(m, 72, mod);
  3907. err = sp_2048_mod_exp_72(r, b, e, mp_count_bits(exp), m, 0);
  3908. }
  3909. if (err == MP_OKAY) {
  3910. err = sp_2048_to_mp(r, res);
  3911. }
  3912. #ifdef WOLFSSL_SP_SMALL_STACK
  3913. if (b != NULL)
  3914. #endif
  3915. {
  3916. /* only "e" is sensitive and needs zeroized */
  3917. if (e != NULL)
  3918. ForceZero(e, sizeof(sp_digit) * 72U);
  3919. #ifdef WOLFSSL_SP_SMALL_STACK
  3920. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  3921. #endif
  3922. }
  3923. return err;
  3924. #else
  3925. #ifdef WOLFSSL_SP_SMALL_STACK
  3926. sp_digit* b = NULL;
  3927. #else
  3928. sp_digit b[72 * 4];
  3929. #endif
  3930. sp_digit* e = NULL;
  3931. sp_digit* m = NULL;
  3932. sp_digit* r = NULL;
  3933. int err = MP_OKAY;
  3934. int expBits = mp_count_bits(exp);
  3935. if (mp_count_bits(base) > 2048) {
  3936. err = MP_READ_E;
  3937. }
  3938. else if (expBits > 2048) {
  3939. err = MP_READ_E;
  3940. }
  3941. else if (mp_count_bits(mod) != 2048) {
  3942. err = MP_READ_E;
  3943. }
  3944. else if (mp_iseven(mod)) {
  3945. err = MP_VAL;
  3946. }
  3947. #ifdef WOLFSSL_SP_SMALL_STACK
  3948. if (err == MP_OKAY) {
  3949. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 4, NULL, DYNAMIC_TYPE_DH);
  3950. if (b == NULL)
  3951. err = MEMORY_E;
  3952. }
  3953. #endif
  3954. if (err == MP_OKAY) {
  3955. e = b + 72 * 2;
  3956. m = e + 72;
  3957. r = b;
  3958. sp_2048_from_mp(b, 72, base);
  3959. sp_2048_from_mp(e, 72, exp);
  3960. sp_2048_from_mp(m, 72, mod);
  3961. err = sp_2048_mod_exp_72(r, b, e, expBits, m, 0);
  3962. }
  3963. if (err == MP_OKAY) {
  3964. err = sp_2048_to_mp(r, res);
  3965. }
  3966. #ifdef WOLFSSL_SP_SMALL_STACK
  3967. if (b != NULL)
  3968. #endif
  3969. {
  3970. /* only "e" is sensitive and needs zeroized */
  3971. if (e != NULL)
  3972. ForceZero(e, sizeof(sp_digit) * 72U);
  3973. #ifdef WOLFSSL_SP_SMALL_STACK
  3974. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  3975. #endif
  3976. }
  3977. return err;
  3978. #endif
  3979. }
  3980. #ifdef WOLFSSL_HAVE_SP_DH
  3981. #ifdef HAVE_FFDHE_2048
  3982. SP_NOINLINE static void sp_2048_lshift_72(sp_digit* r, const sp_digit* a,
  3983. byte n)
  3984. {
  3985. #ifdef WOLFSSL_SP_SMALL
  3986. int i;
  3987. r[72] = a[71] >> (29 - n);
  3988. for (i=71; i>0; i--) {
  3989. r[i] = ((a[i] << n) | (a[i-1] >> (29 - n))) & 0x1fffffff;
  3990. }
  3991. #else
  3992. sp_int_digit s;
  3993. sp_int_digit t;
  3994. s = (sp_int_digit)a[71];
  3995. r[72] = s >> (29U - n);
  3996. s = (sp_int_digit)(a[71]); t = (sp_int_digit)(a[70]);
  3997. r[71] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  3998. s = (sp_int_digit)(a[70]); t = (sp_int_digit)(a[69]);
  3999. r[70] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4000. s = (sp_int_digit)(a[69]); t = (sp_int_digit)(a[68]);
  4001. r[69] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4002. s = (sp_int_digit)(a[68]); t = (sp_int_digit)(a[67]);
  4003. r[68] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4004. s = (sp_int_digit)(a[67]); t = (sp_int_digit)(a[66]);
  4005. r[67] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4006. s = (sp_int_digit)(a[66]); t = (sp_int_digit)(a[65]);
  4007. r[66] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4008. s = (sp_int_digit)(a[65]); t = (sp_int_digit)(a[64]);
  4009. r[65] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4010. s = (sp_int_digit)(a[64]); t = (sp_int_digit)(a[63]);
  4011. r[64] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4012. s = (sp_int_digit)(a[63]); t = (sp_int_digit)(a[62]);
  4013. r[63] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4014. s = (sp_int_digit)(a[62]); t = (sp_int_digit)(a[61]);
  4015. r[62] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4016. s = (sp_int_digit)(a[61]); t = (sp_int_digit)(a[60]);
  4017. r[61] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4018. s = (sp_int_digit)(a[60]); t = (sp_int_digit)(a[59]);
  4019. r[60] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4020. s = (sp_int_digit)(a[59]); t = (sp_int_digit)(a[58]);
  4021. r[59] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4022. s = (sp_int_digit)(a[58]); t = (sp_int_digit)(a[57]);
  4023. r[58] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4024. s = (sp_int_digit)(a[57]); t = (sp_int_digit)(a[56]);
  4025. r[57] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4026. s = (sp_int_digit)(a[56]); t = (sp_int_digit)(a[55]);
  4027. r[56] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4028. s = (sp_int_digit)(a[55]); t = (sp_int_digit)(a[54]);
  4029. r[55] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4030. s = (sp_int_digit)(a[54]); t = (sp_int_digit)(a[53]);
  4031. r[54] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4032. s = (sp_int_digit)(a[53]); t = (sp_int_digit)(a[52]);
  4033. r[53] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4034. s = (sp_int_digit)(a[52]); t = (sp_int_digit)(a[51]);
  4035. r[52] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4036. s = (sp_int_digit)(a[51]); t = (sp_int_digit)(a[50]);
  4037. r[51] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4038. s = (sp_int_digit)(a[50]); t = (sp_int_digit)(a[49]);
  4039. r[50] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4040. s = (sp_int_digit)(a[49]); t = (sp_int_digit)(a[48]);
  4041. r[49] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4042. s = (sp_int_digit)(a[48]); t = (sp_int_digit)(a[47]);
  4043. r[48] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4044. s = (sp_int_digit)(a[47]); t = (sp_int_digit)(a[46]);
  4045. r[47] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4046. s = (sp_int_digit)(a[46]); t = (sp_int_digit)(a[45]);
  4047. r[46] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4048. s = (sp_int_digit)(a[45]); t = (sp_int_digit)(a[44]);
  4049. r[45] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4050. s = (sp_int_digit)(a[44]); t = (sp_int_digit)(a[43]);
  4051. r[44] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4052. s = (sp_int_digit)(a[43]); t = (sp_int_digit)(a[42]);
  4053. r[43] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4054. s = (sp_int_digit)(a[42]); t = (sp_int_digit)(a[41]);
  4055. r[42] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4056. s = (sp_int_digit)(a[41]); t = (sp_int_digit)(a[40]);
  4057. r[41] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4058. s = (sp_int_digit)(a[40]); t = (sp_int_digit)(a[39]);
  4059. r[40] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4060. s = (sp_int_digit)(a[39]); t = (sp_int_digit)(a[38]);
  4061. r[39] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4062. s = (sp_int_digit)(a[38]); t = (sp_int_digit)(a[37]);
  4063. r[38] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4064. s = (sp_int_digit)(a[37]); t = (sp_int_digit)(a[36]);
  4065. r[37] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4066. s = (sp_int_digit)(a[36]); t = (sp_int_digit)(a[35]);
  4067. r[36] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4068. s = (sp_int_digit)(a[35]); t = (sp_int_digit)(a[34]);
  4069. r[35] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4070. s = (sp_int_digit)(a[34]); t = (sp_int_digit)(a[33]);
  4071. r[34] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4072. s = (sp_int_digit)(a[33]); t = (sp_int_digit)(a[32]);
  4073. r[33] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4074. s = (sp_int_digit)(a[32]); t = (sp_int_digit)(a[31]);
  4075. r[32] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4076. s = (sp_int_digit)(a[31]); t = (sp_int_digit)(a[30]);
  4077. r[31] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4078. s = (sp_int_digit)(a[30]); t = (sp_int_digit)(a[29]);
  4079. r[30] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4080. s = (sp_int_digit)(a[29]); t = (sp_int_digit)(a[28]);
  4081. r[29] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4082. s = (sp_int_digit)(a[28]); t = (sp_int_digit)(a[27]);
  4083. r[28] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4084. s = (sp_int_digit)(a[27]); t = (sp_int_digit)(a[26]);
  4085. r[27] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4086. s = (sp_int_digit)(a[26]); t = (sp_int_digit)(a[25]);
  4087. r[26] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4088. s = (sp_int_digit)(a[25]); t = (sp_int_digit)(a[24]);
  4089. r[25] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4090. s = (sp_int_digit)(a[24]); t = (sp_int_digit)(a[23]);
  4091. r[24] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4092. s = (sp_int_digit)(a[23]); t = (sp_int_digit)(a[22]);
  4093. r[23] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4094. s = (sp_int_digit)(a[22]); t = (sp_int_digit)(a[21]);
  4095. r[22] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4096. s = (sp_int_digit)(a[21]); t = (sp_int_digit)(a[20]);
  4097. r[21] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4098. s = (sp_int_digit)(a[20]); t = (sp_int_digit)(a[19]);
  4099. r[20] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4100. s = (sp_int_digit)(a[19]); t = (sp_int_digit)(a[18]);
  4101. r[19] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4102. s = (sp_int_digit)(a[18]); t = (sp_int_digit)(a[17]);
  4103. r[18] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4104. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  4105. r[17] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4106. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  4107. r[16] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4108. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  4109. r[15] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4110. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  4111. r[14] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4112. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  4113. r[13] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4114. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  4115. r[12] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4116. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  4117. r[11] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4118. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  4119. r[10] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4120. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  4121. r[9] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4122. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  4123. r[8] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4124. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  4125. r[7] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4126. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  4127. r[6] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4128. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  4129. r[5] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4130. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  4131. r[4] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4132. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  4133. r[3] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4134. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  4135. r[2] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4136. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  4137. r[1] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  4138. #endif /* WOLFSSL_SP_SMALL */
  4139. r[0] = (a[0] << n) & 0x1fffffff;
  4140. }
  4141. /* Modular exponentiate 2 to the e mod m. (r = 2^e mod m)
  4142. *
  4143. * r A single precision number that is the result of the operation.
  4144. * e A single precision number that is the exponent.
  4145. * bits The number of bits in the exponent.
  4146. * m A single precision number that is the modulus.
  4147. * returns 0 on success.
  4148. * returns MEMORY_E on dynamic memory allocation failure.
  4149. * returns MP_VAL when base is even.
  4150. */
  4151. static int sp_2048_mod_exp_2_72(sp_digit* r, const sp_digit* e, int bits, const sp_digit* m)
  4152. {
  4153. #ifdef WOLFSSL_SP_SMALL_STACK
  4154. sp_digit* td = NULL;
  4155. #else
  4156. sp_digit td[217];
  4157. #endif
  4158. sp_digit* norm = NULL;
  4159. sp_digit* tmp = NULL;
  4160. sp_digit mp = 1;
  4161. sp_digit n;
  4162. sp_digit o;
  4163. int i;
  4164. int c;
  4165. byte y;
  4166. int err = MP_OKAY;
  4167. if (bits == 0) {
  4168. err = MP_VAL;
  4169. }
  4170. #ifdef WOLFSSL_SP_SMALL_STACK
  4171. if (err == MP_OKAY) {
  4172. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 217, NULL,
  4173. DYNAMIC_TYPE_TMP_BUFFER);
  4174. if (td == NULL)
  4175. err = MEMORY_E;
  4176. }
  4177. #endif
  4178. if (err == MP_OKAY) {
  4179. norm = td;
  4180. tmp = td + 144;
  4181. XMEMSET(td, 0, sizeof(sp_digit) * 217);
  4182. sp_2048_mont_setup(m, &mp);
  4183. sp_2048_mont_norm_72(norm, m);
  4184. bits = ((bits + 3) / 4) * 4;
  4185. i = ((bits + 28) / 29) - 1;
  4186. c = bits % 29;
  4187. if (c == 0) {
  4188. c = 29;
  4189. }
  4190. if (i < 72) {
  4191. n = e[i--] << (32 - c);
  4192. }
  4193. else {
  4194. n = 0;
  4195. i--;
  4196. }
  4197. if (c < 4) {
  4198. n |= e[i--] << (3 - c);
  4199. c += 29;
  4200. }
  4201. y = (int)((n >> 28) & 0xf);
  4202. n <<= 4;
  4203. c -= 4;
  4204. sp_2048_lshift_72(r, norm, (byte)y);
  4205. while ((i >= 0) || (c >= 4)) {
  4206. if (c >= 4) {
  4207. y = (byte)((n >> 28) & 0xf);
  4208. n <<= 4;
  4209. c -= 4;
  4210. }
  4211. else if (c == 0) {
  4212. n = e[i--] << 3;
  4213. y = (byte)((n >> 28) & 0xf);
  4214. n <<= 4;
  4215. c = 25;
  4216. }
  4217. else {
  4218. y = (byte)((n >> 28) & 0xf);
  4219. n = e[i--] << 3;
  4220. c = 4 - c;
  4221. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  4222. n <<= c;
  4223. c = 29 - c;
  4224. }
  4225. sp_2048_mont_sqr_72(r, r, m, mp);
  4226. sp_2048_mont_sqr_72(r, r, m, mp);
  4227. sp_2048_mont_sqr_72(r, r, m, mp);
  4228. sp_2048_mont_sqr_72(r, r, m, mp);
  4229. sp_2048_lshift_72(r, r, (byte)y);
  4230. sp_2048_mul_d_72(tmp, norm, (r[71] << 11) + (r[70] >> 18));
  4231. r[71] = 0;
  4232. r[70] &= 0x3ffffL;
  4233. (void)sp_2048_add_72(r, r, tmp);
  4234. sp_2048_norm_72(r);
  4235. o = sp_2048_cmp_72(r, m);
  4236. sp_2048_cond_sub_72(r, r, m, ~(o >> 31));
  4237. }
  4238. sp_2048_mont_reduce_72(r, m, mp);
  4239. n = sp_2048_cmp_72(r, m);
  4240. sp_2048_cond_sub_72(r, r, m, ~(n >> 31));
  4241. }
  4242. #ifdef WOLFSSL_SP_SMALL_STACK
  4243. if (td != NULL)
  4244. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  4245. #endif
  4246. return err;
  4247. }
  4248. #endif /* HAVE_FFDHE_2048 */
  4249. /* Perform the modular exponentiation for Diffie-Hellman.
  4250. *
  4251. * base Base.
  4252. * exp Array of bytes that is the exponent.
  4253. * expLen Length of data, in bytes, in exponent.
  4254. * mod Modulus.
  4255. * out Buffer to hold big-endian bytes of exponentiation result.
  4256. * Must be at least 256 bytes long.
  4257. * outLen Length, in bytes, of exponentiation result.
  4258. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  4259. * and MEMORY_E if memory allocation fails.
  4260. */
  4261. int sp_DhExp_2048(const mp_int* base, const byte* exp, word32 expLen,
  4262. const mp_int* mod, byte* out, word32* outLen)
  4263. {
  4264. #ifdef WOLFSSL_SP_SMALL_STACK
  4265. sp_digit* b = NULL;
  4266. #else
  4267. sp_digit b[72 * 4];
  4268. #endif
  4269. sp_digit* e = NULL;
  4270. sp_digit* m = NULL;
  4271. sp_digit* r = NULL;
  4272. word32 i;
  4273. int err = MP_OKAY;
  4274. if (mp_count_bits(base) > 2048) {
  4275. err = MP_READ_E;
  4276. }
  4277. else if (expLen > 256U) {
  4278. err = MP_READ_E;
  4279. }
  4280. else if (mp_count_bits(mod) != 2048) {
  4281. err = MP_READ_E;
  4282. }
  4283. else if (mp_iseven(mod)) {
  4284. err = MP_VAL;
  4285. }
  4286. #ifdef WOLFSSL_SP_SMALL_STACK
  4287. if (err == MP_OKAY) {
  4288. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 72 * 4, NULL,
  4289. DYNAMIC_TYPE_DH);
  4290. if (b == NULL)
  4291. err = MEMORY_E;
  4292. }
  4293. #endif
  4294. if (err == MP_OKAY) {
  4295. e = b + 72 * 2;
  4296. m = e + 72;
  4297. r = b;
  4298. sp_2048_from_mp(b, 72, base);
  4299. sp_2048_from_bin(e, 72, exp, expLen);
  4300. sp_2048_from_mp(m, 72, mod);
  4301. #ifdef HAVE_FFDHE_2048
  4302. if (base->used == 1 && base->dp[0] == 2U &&
  4303. (m[70] >> 2) == 0xffffL) {
  4304. err = sp_2048_mod_exp_2_72(r, e, expLen * 8U, m);
  4305. }
  4306. else {
  4307. #endif
  4308. err = sp_2048_mod_exp_72(r, b, e, expLen * 8U, m, 0);
  4309. #ifdef HAVE_FFDHE_2048
  4310. }
  4311. #endif
  4312. }
  4313. if (err == MP_OKAY) {
  4314. sp_2048_to_bin_72(r, out);
  4315. *outLen = 256;
  4316. for (i=0; i<256U && out[i] == 0U; i++) {
  4317. /* Search for first non-zero. */
  4318. }
  4319. *outLen -= i;
  4320. XMEMMOVE(out, out + i, *outLen);
  4321. }
  4322. #ifdef WOLFSSL_SP_SMALL_STACK
  4323. if (b != NULL)
  4324. #endif
  4325. {
  4326. /* only "e" is sensitive and needs zeroized */
  4327. if (e != NULL)
  4328. ForceZero(e, sizeof(sp_digit) * 72U);
  4329. #ifdef WOLFSSL_SP_SMALL_STACK
  4330. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  4331. #endif
  4332. }
  4333. return err;
  4334. }
  4335. #endif /* WOLFSSL_HAVE_SP_DH */
  4336. /* Perform the modular exponentiation for Diffie-Hellman.
  4337. *
  4338. * base Base. MP integer.
  4339. * exp Exponent. MP integer.
  4340. * mod Modulus. MP integer.
  4341. * res Result. MP integer.
  4342. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  4343. * and MEMORY_E if memory allocation fails.
  4344. */
  4345. int sp_ModExp_1024(const mp_int* base, const mp_int* exp, const mp_int* mod,
  4346. mp_int* res)
  4347. {
  4348. #ifdef WOLFSSL_SP_SMALL
  4349. int err = MP_OKAY;
  4350. #ifdef WOLFSSL_SP_SMALL_STACK
  4351. sp_digit* b = NULL;
  4352. #else
  4353. sp_digit b[36 * 4];
  4354. #endif
  4355. sp_digit* e = NULL;
  4356. sp_digit* m = NULL;
  4357. sp_digit* r = NULL;
  4358. int expBits = mp_count_bits(exp);
  4359. if (mp_count_bits(base) > 1024) {
  4360. err = MP_READ_E;
  4361. }
  4362. else if (expBits > 1024) {
  4363. err = MP_READ_E;
  4364. }
  4365. else if (mp_count_bits(mod) != 1024) {
  4366. err = MP_READ_E;
  4367. }
  4368. else if (mp_iseven(mod)) {
  4369. err = MP_VAL;
  4370. }
  4371. #ifdef WOLFSSL_SP_SMALL_STACK
  4372. if (err == MP_OKAY) {
  4373. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 36 * 4, NULL,
  4374. DYNAMIC_TYPE_DH);
  4375. if (b == NULL)
  4376. err = MEMORY_E;
  4377. }
  4378. #endif
  4379. if (err == MP_OKAY) {
  4380. e = b + 36 * 2;
  4381. m = e + 36;
  4382. r = b;
  4383. sp_2048_from_mp(b, 36, base);
  4384. sp_2048_from_mp(e, 36, exp);
  4385. sp_2048_from_mp(m, 36, mod);
  4386. err = sp_2048_mod_exp_36(r, b, e, mp_count_bits(exp), m, 0);
  4387. }
  4388. if (err == MP_OKAY) {
  4389. XMEMSET(r + 36, 0, sizeof(*r) * 36U);
  4390. err = sp_2048_to_mp(r, res);
  4391. }
  4392. #ifdef WOLFSSL_SP_SMALL_STACK
  4393. if (b != NULL)
  4394. #endif
  4395. {
  4396. /* only "e" is sensitive and needs zeroized */
  4397. if (e != NULL)
  4398. ForceZero(e, sizeof(sp_digit) * 72U);
  4399. #ifdef WOLFSSL_SP_SMALL_STACK
  4400. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  4401. #endif
  4402. }
  4403. return err;
  4404. #else
  4405. #ifdef WOLFSSL_SP_SMALL_STACK
  4406. sp_digit* b = NULL;
  4407. #else
  4408. sp_digit b[36 * 4];
  4409. #endif
  4410. sp_digit* e = NULL;
  4411. sp_digit* m = NULL;
  4412. sp_digit* r = NULL;
  4413. int err = MP_OKAY;
  4414. int expBits = mp_count_bits(exp);
  4415. if (mp_count_bits(base) > 1024) {
  4416. err = MP_READ_E;
  4417. }
  4418. else if (expBits > 1024) {
  4419. err = MP_READ_E;
  4420. }
  4421. else if (mp_count_bits(mod) != 1024) {
  4422. err = MP_READ_E;
  4423. }
  4424. else if (mp_iseven(mod)) {
  4425. err = MP_VAL;
  4426. }
  4427. #ifdef WOLFSSL_SP_SMALL_STACK
  4428. if (err == MP_OKAY) {
  4429. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 36 * 4, NULL, DYNAMIC_TYPE_DH);
  4430. if (b == NULL)
  4431. err = MEMORY_E;
  4432. }
  4433. #endif
  4434. if (err == MP_OKAY) {
  4435. e = b + 36 * 2;
  4436. m = e + 36;
  4437. r = b;
  4438. sp_2048_from_mp(b, 36, base);
  4439. sp_2048_from_mp(e, 36, exp);
  4440. sp_2048_from_mp(m, 36, mod);
  4441. err = sp_2048_mod_exp_36(r, b, e, expBits, m, 0);
  4442. }
  4443. if (err == MP_OKAY) {
  4444. XMEMSET(r + 36, 0, sizeof(*r) * 36U);
  4445. err = sp_2048_to_mp(r, res);
  4446. }
  4447. #ifdef WOLFSSL_SP_SMALL_STACK
  4448. if (b != NULL)
  4449. #endif
  4450. {
  4451. /* only "e" is sensitive and needs zeroized */
  4452. if (e != NULL)
  4453. ForceZero(e, sizeof(sp_digit) * 72U);
  4454. #ifdef WOLFSSL_SP_SMALL_STACK
  4455. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  4456. #endif
  4457. }
  4458. return err;
  4459. #endif
  4460. }
  4461. #endif /* WOLFSSL_HAVE_SP_DH | (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) */
  4462. #endif /* !WOLFSSL_SP_NO_2048 */
  4463. #ifndef WOLFSSL_SP_NO_3072
  4464. #ifdef WOLFSSL_SP_SMALL
  4465. /* Read big endian unsigned byte array into r.
  4466. *
  4467. * r A single precision integer.
  4468. * size Maximum number of bytes to convert
  4469. * a Byte array.
  4470. * n Number of bytes in array to read.
  4471. */
  4472. static void sp_3072_from_bin(sp_digit* r, int size, const byte* a, int n)
  4473. {
  4474. int i;
  4475. int j = 0;
  4476. word32 s = 0;
  4477. r[0] = 0;
  4478. for (i = n-1; i >= 0; i--) {
  4479. r[j] |= (((sp_digit)a[i]) << s);
  4480. if (s >= 21U) {
  4481. r[j] &= 0x1fffffff;
  4482. s = 29U - s;
  4483. if (j + 1 >= size) {
  4484. break;
  4485. }
  4486. r[++j] = (sp_digit)a[i] >> s;
  4487. s = 8U - s;
  4488. }
  4489. else {
  4490. s += 8U;
  4491. }
  4492. }
  4493. for (j++; j < size; j++) {
  4494. r[j] = 0;
  4495. }
  4496. }
  4497. /* Convert an mp_int to an array of sp_digit.
  4498. *
  4499. * r A single precision integer.
  4500. * size Maximum number of bytes to convert
  4501. * a A multi-precision integer.
  4502. */
  4503. static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
  4504. {
  4505. #if DIGIT_BIT == 29
  4506. int i;
  4507. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  4508. int o = 0;
  4509. for (i = 0; i < size; i++) {
  4510. sp_digit mask = (sp_digit)0 - (j >> 28);
  4511. r[i] = a->dp[o] & mask;
  4512. j++;
  4513. o += (int)(j >> 28);
  4514. }
  4515. #elif DIGIT_BIT > 29
  4516. unsigned int i;
  4517. int j = 0;
  4518. word32 s = 0;
  4519. r[0] = 0;
  4520. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  4521. r[j] |= ((sp_digit)a->dp[i] << s);
  4522. r[j] &= 0x1fffffff;
  4523. s = 29U - s;
  4524. if (j + 1 >= size) {
  4525. break;
  4526. }
  4527. /* lint allow cast of mismatch word32 and mp_digit */
  4528. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  4529. while ((s + 29U) <= (word32)DIGIT_BIT) {
  4530. s += 29U;
  4531. r[j] &= 0x1fffffff;
  4532. if (j + 1 >= size) {
  4533. break;
  4534. }
  4535. if (s < (word32)DIGIT_BIT) {
  4536. /* lint allow cast of mismatch word32 and mp_digit */
  4537. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  4538. }
  4539. else {
  4540. r[++j] = (sp_digit)0;
  4541. }
  4542. }
  4543. s = (word32)DIGIT_BIT - s;
  4544. }
  4545. for (j++; j < size; j++) {
  4546. r[j] = 0;
  4547. }
  4548. #else
  4549. unsigned int i;
  4550. int j = 0;
  4551. int s = 0;
  4552. r[0] = 0;
  4553. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  4554. r[j] |= ((sp_digit)a->dp[i]) << s;
  4555. if (s + DIGIT_BIT >= 29) {
  4556. r[j] &= 0x1fffffff;
  4557. if (j + 1 >= size) {
  4558. break;
  4559. }
  4560. s = 29 - s;
  4561. if (s == DIGIT_BIT) {
  4562. r[++j] = 0;
  4563. s = 0;
  4564. }
  4565. else {
  4566. r[++j] = a->dp[i] >> s;
  4567. s = DIGIT_BIT - s;
  4568. }
  4569. }
  4570. else {
  4571. s += DIGIT_BIT;
  4572. }
  4573. }
  4574. for (j++; j < size; j++) {
  4575. r[j] = 0;
  4576. }
  4577. #endif
  4578. }
  4579. /* Write r as big endian to byte array.
  4580. * Fixed length number of bytes written: 384
  4581. *
  4582. * r A single precision integer.
  4583. * a Byte array.
  4584. */
  4585. static void sp_3072_to_bin_106(sp_digit* r, byte* a)
  4586. {
  4587. int i;
  4588. int j;
  4589. int s = 0;
  4590. int b;
  4591. for (i=0; i<105; i++) {
  4592. r[i+1] += r[i] >> 29;
  4593. r[i] &= 0x1fffffff;
  4594. }
  4595. j = 3079 / 8 - 1;
  4596. a[j] = 0;
  4597. for (i=0; i<106 && j>=0; i++) {
  4598. b = 0;
  4599. /* lint allow cast of mismatch sp_digit and int */
  4600. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  4601. b += 8 - s;
  4602. if (j < 0) {
  4603. break;
  4604. }
  4605. while (b < 29) {
  4606. a[j--] = (byte)(r[i] >> b);
  4607. b += 8;
  4608. if (j < 0) {
  4609. break;
  4610. }
  4611. }
  4612. s = 8 - (b - 29);
  4613. if (j >= 0) {
  4614. a[j] = 0;
  4615. }
  4616. if (s != 0) {
  4617. j++;
  4618. }
  4619. }
  4620. }
  4621. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  4622. /* Normalize the values in each word to 29 bits.
  4623. *
  4624. * a Array of sp_digit to normalize.
  4625. */
  4626. static void sp_3072_norm_53(sp_digit* a)
  4627. {
  4628. int i;
  4629. for (i = 0; i < 52; i++) {
  4630. a[i+1] += a[i] >> 29;
  4631. a[i] &= 0x1fffffff;
  4632. }
  4633. }
  4634. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  4635. /* Normalize the values in each word to 29 bits.
  4636. *
  4637. * a Array of sp_digit to normalize.
  4638. */
  4639. static void sp_3072_norm_106(sp_digit* a)
  4640. {
  4641. int i;
  4642. for (i = 0; i < 105; i++) {
  4643. a[i+1] += a[i] >> 29;
  4644. a[i] &= 0x1fffffff;
  4645. }
  4646. }
  4647. /* Multiply a and b into r. (r = a * b)
  4648. *
  4649. * r A single precision integer.
  4650. * a A single precision integer.
  4651. * b A single precision integer.
  4652. */
  4653. SP_NOINLINE static void sp_3072_mul_106(sp_digit* r, const sp_digit* a,
  4654. const sp_digit* b)
  4655. {
  4656. int i;
  4657. int imax;
  4658. int k;
  4659. sp_uint64 c;
  4660. sp_uint64 lo;
  4661. c = ((sp_uint64)a[105]) * b[105];
  4662. r[211] = (sp_digit)(c >> 29);
  4663. c &= 0x1fffffff;
  4664. for (k = 209; k >= 0; k--) {
  4665. if (k >= 106) {
  4666. i = k - 105;
  4667. imax = 105;
  4668. }
  4669. else {
  4670. i = 0;
  4671. imax = k;
  4672. }
  4673. if (imax - i > 15) {
  4674. int imaxlo;
  4675. lo = 0;
  4676. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  4677. for (; i <= imax && i < imaxlo + 15; i++) {
  4678. lo += ((sp_uint64)a[i]) * b[k - i];
  4679. }
  4680. c += lo >> 29;
  4681. lo &= 0x1fffffff;
  4682. }
  4683. r[k + 2] += (sp_digit)(c >> 29);
  4684. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  4685. c = lo & 0x1fffffff;
  4686. }
  4687. else {
  4688. lo = 0;
  4689. for (; i <= imax; i++) {
  4690. lo += ((sp_uint64)a[i]) * b[k - i];
  4691. }
  4692. c += lo >> 29;
  4693. r[k + 2] += (sp_digit)(c >> 29);
  4694. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  4695. c = lo & 0x1fffffff;
  4696. }
  4697. }
  4698. r[0] = (sp_digit)c;
  4699. }
  4700. /* Square a and put result in r. (r = a * a)
  4701. *
  4702. * r A single precision integer.
  4703. * a A single precision integer.
  4704. */
  4705. SP_NOINLINE static void sp_3072_sqr_106(sp_digit* r, const sp_digit* a)
  4706. {
  4707. int i;
  4708. int imax;
  4709. int k;
  4710. sp_uint64 c;
  4711. sp_uint64 t;
  4712. c = ((sp_uint64)a[105]) * a[105];
  4713. r[211] = (sp_digit)(c >> 29);
  4714. c = (c & 0x1fffffff) << 29;
  4715. for (k = 209; k >= 0; k--) {
  4716. i = (k + 1) / 2;
  4717. if ((k & 1) == 0) {
  4718. c += ((sp_uint64)a[i]) * a[i];
  4719. i++;
  4720. }
  4721. if (k < 105) {
  4722. imax = k;
  4723. }
  4724. else {
  4725. imax = 105;
  4726. }
  4727. if (imax - i >= 14) {
  4728. int imaxlo;
  4729. sp_uint64 hi;
  4730. hi = c >> 29;
  4731. c &= 0x1fffffff;
  4732. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  4733. t = 0;
  4734. for (; i <= imax && i < imaxlo + 14; i++) {
  4735. t += ((sp_uint64)a[i]) * a[k - i];
  4736. }
  4737. c += t * 2;
  4738. hi += c >> 29;
  4739. c &= 0x1fffffff;
  4740. }
  4741. r[k + 2] += (sp_digit)(hi >> 29);
  4742. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  4743. c <<= 29;
  4744. }
  4745. else
  4746. {
  4747. t = 0;
  4748. for (; i <= imax; i++) {
  4749. t += ((sp_uint64)a[i]) * a[k - i];
  4750. }
  4751. c += t * 2;
  4752. r[k + 2] += (sp_digit) (c >> 58);
  4753. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  4754. c = (c & 0x1fffffff) << 29;
  4755. }
  4756. }
  4757. r[0] = (sp_digit)(c >> 29);
  4758. }
  4759. /* Calculate the bottom digit of -1/a mod 2^n.
  4760. *
  4761. * a A single precision number.
  4762. * rho Bottom word of inverse.
  4763. */
  4764. static void sp_3072_mont_setup(const sp_digit* a, sp_digit* rho)
  4765. {
  4766. sp_digit x;
  4767. sp_digit b;
  4768. b = a[0];
  4769. x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
  4770. x *= 2 - b * x; /* here x*a==1 mod 2**8 */
  4771. x *= 2 - b * x; /* here x*a==1 mod 2**16 */
  4772. x *= 2 - b * x; /* here x*a==1 mod 2**32 */
  4773. x &= 0x1fffffff;
  4774. /* rho = -1/m mod b */
  4775. *rho = ((sp_digit)1 << 29) - x;
  4776. }
  4777. /* Multiply a by scalar b into r. (r = a * b)
  4778. *
  4779. * r A single precision integer.
  4780. * a A single precision integer.
  4781. * b A scalar.
  4782. */
  4783. SP_NOINLINE static void sp_3072_mul_d_106(sp_digit* r, const sp_digit* a,
  4784. sp_digit b)
  4785. {
  4786. sp_int64 tb = b;
  4787. sp_int64 t = 0;
  4788. int i;
  4789. for (i = 0; i < 106; i++) {
  4790. t += tb * a[i];
  4791. r[i] = (sp_digit)(t & 0x1fffffff);
  4792. t >>= 29;
  4793. }
  4794. r[106] = (sp_digit)t;
  4795. }
  4796. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  4797. /* Sub b from a into r. (r = a - b)
  4798. *
  4799. * r A single precision integer.
  4800. * a A single precision integer.
  4801. * b A single precision integer.
  4802. */
  4803. SP_NOINLINE static int sp_3072_sub_53(sp_digit* r, const sp_digit* a,
  4804. const sp_digit* b)
  4805. {
  4806. int i;
  4807. for (i = 0; i < 53; i++) {
  4808. r[i] = a[i] - b[i];
  4809. }
  4810. return 0;
  4811. }
  4812. /* r = 2^n mod m where n is the number of bits to reduce by.
  4813. * Given m must be 3072 bits, just need to subtract.
  4814. *
  4815. * r A single precision number.
  4816. * m A single precision number.
  4817. */
  4818. static void sp_3072_mont_norm_53(sp_digit* r, const sp_digit* m)
  4819. {
  4820. /* Set r = 2^n - 1. */
  4821. int i;
  4822. for (i=0; i<52; i++) {
  4823. r[i] = 0x1fffffff;
  4824. }
  4825. r[52] = 0xfffffffL;
  4826. /* r = (2^n - 1) mod n */
  4827. (void)sp_3072_sub_53(r, r, m);
  4828. /* Add one so r = 2^n mod m */
  4829. r[0] += 1;
  4830. }
  4831. /* Compare a with b in constant time.
  4832. *
  4833. * a A single precision integer.
  4834. * b A single precision integer.
  4835. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  4836. * respectively.
  4837. */
  4838. static sp_digit sp_3072_cmp_53(const sp_digit* a, const sp_digit* b)
  4839. {
  4840. sp_digit r = 0;
  4841. int i;
  4842. for (i=52; i>=0; i--) {
  4843. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  4844. }
  4845. return r;
  4846. }
  4847. /* Conditionally subtract b from a using the mask m.
  4848. * m is -1 to subtract and 0 when not.
  4849. *
  4850. * r A single precision number representing condition subtract result.
  4851. * a A single precision number to subtract from.
  4852. * b A single precision number to subtract.
  4853. * m Mask value to apply.
  4854. */
  4855. static void sp_3072_cond_sub_53(sp_digit* r, const sp_digit* a,
  4856. const sp_digit* b, const sp_digit m)
  4857. {
  4858. int i;
  4859. for (i = 0; i < 53; i++) {
  4860. r[i] = a[i] - (b[i] & m);
  4861. }
  4862. }
  4863. /* Mul a by scalar b and add into r. (r += a * b)
  4864. *
  4865. * r A single precision integer.
  4866. * a A single precision integer.
  4867. * b A scalar.
  4868. */
  4869. SP_NOINLINE static void sp_3072_mul_add_53(sp_digit* r, const sp_digit* a,
  4870. const sp_digit b)
  4871. {
  4872. #ifndef WOLFSSL_SP_LARGE_CODE
  4873. sp_int64 tb = b;
  4874. sp_int64 t = 0;
  4875. int i;
  4876. for (i = 0; i < 53; i++) {
  4877. t += r[i];
  4878. t += tb * a[i];
  4879. r[i] = ((sp_digit)t) & 0x1fffffff;
  4880. t >>= 29;
  4881. }
  4882. r[53] += (sp_digit)t;
  4883. #else
  4884. sp_int64 tb = b;
  4885. sp_int64 t[4];
  4886. int i;
  4887. t[0] = 0;
  4888. for (i = 0; i < 52; i += 4) {
  4889. t[0] += (tb * a[i+0]) + r[i+0];
  4890. t[1] = (tb * a[i+1]) + r[i+1];
  4891. t[2] = (tb * a[i+2]) + r[i+2];
  4892. t[3] = (tb * a[i+3]) + r[i+3];
  4893. r[i+0] = t[0] & 0x1fffffff;
  4894. t[1] += t[0] >> 29;
  4895. r[i+1] = t[1] & 0x1fffffff;
  4896. t[2] += t[1] >> 29;
  4897. r[i+2] = t[2] & 0x1fffffff;
  4898. t[3] += t[2] >> 29;
  4899. r[i+3] = t[3] & 0x1fffffff;
  4900. t[0] = t[3] >> 29;
  4901. }
  4902. t[0] += (tb * a[52]) + r[52];
  4903. r[52] = t[0] & 0x1fffffff;
  4904. r[53] += (sp_digit)(t[0] >> 29);
  4905. #endif /* !WOLFSSL_SP_LARGE_CODE */
  4906. }
  4907. /* Shift the result in the high 1536 bits down to the bottom.
  4908. *
  4909. * r A single precision number.
  4910. * a A single precision number.
  4911. */
  4912. static void sp_3072_mont_shift_53(sp_digit* r, const sp_digit* a)
  4913. {
  4914. int i;
  4915. sp_int64 n = a[52] >> 28;
  4916. n += ((sp_int64)a[53]) << 1;
  4917. for (i = 0; i < 52; i++) {
  4918. r[i] = n & 0x1fffffff;
  4919. n >>= 29;
  4920. n += ((sp_int64)a[54 + i]) << 1;
  4921. }
  4922. r[52] = (sp_digit)n;
  4923. XMEMSET(&r[53], 0, sizeof(*r) * 53U);
  4924. }
  4925. /* Reduce the number back to 3072 bits using Montgomery reduction.
  4926. *
  4927. * a A single precision number to reduce in place.
  4928. * m The single precision number representing the modulus.
  4929. * mp The digit representing the negative inverse of m mod 2^n.
  4930. */
  4931. static void sp_3072_mont_reduce_53(sp_digit* a, const sp_digit* m, sp_digit mp)
  4932. {
  4933. int i;
  4934. sp_digit mu;
  4935. sp_digit over;
  4936. sp_3072_norm_53(a + 53);
  4937. for (i=0; i<52; i++) {
  4938. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  4939. sp_3072_mul_add_53(a+i, m, mu);
  4940. a[i+1] += a[i] >> 29;
  4941. }
  4942. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffffL;
  4943. sp_3072_mul_add_53(a+i, m, mu);
  4944. a[i+1] += a[i] >> 29;
  4945. a[i] &= 0x1fffffff;
  4946. sp_3072_mont_shift_53(a, a);
  4947. over = a[52] - m[52];
  4948. sp_3072_cond_sub_53(a, a, m, ~((over - 1) >> 31));
  4949. sp_3072_norm_53(a);
  4950. }
  4951. /* Multiply a and b into r. (r = a * b)
  4952. *
  4953. * r A single precision integer.
  4954. * a A single precision integer.
  4955. * b A single precision integer.
  4956. */
  4957. SP_NOINLINE static void sp_3072_mul_53(sp_digit* r, const sp_digit* a,
  4958. const sp_digit* b)
  4959. {
  4960. int i;
  4961. int imax;
  4962. int k;
  4963. sp_uint64 c;
  4964. sp_uint64 lo;
  4965. c = ((sp_uint64)a[52]) * b[52];
  4966. r[105] = (sp_digit)(c >> 29);
  4967. c &= 0x1fffffff;
  4968. for (k = 103; k >= 0; k--) {
  4969. if (k >= 53) {
  4970. i = k - 52;
  4971. imax = 52;
  4972. }
  4973. else {
  4974. i = 0;
  4975. imax = k;
  4976. }
  4977. if (imax - i > 15) {
  4978. int imaxlo;
  4979. lo = 0;
  4980. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  4981. for (; i <= imax && i < imaxlo + 15; i++) {
  4982. lo += ((sp_uint64)a[i]) * b[k - i];
  4983. }
  4984. c += lo >> 29;
  4985. lo &= 0x1fffffff;
  4986. }
  4987. r[k + 2] += (sp_digit)(c >> 29);
  4988. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  4989. c = lo & 0x1fffffff;
  4990. }
  4991. else {
  4992. lo = 0;
  4993. for (; i <= imax; i++) {
  4994. lo += ((sp_uint64)a[i]) * b[k - i];
  4995. }
  4996. c += lo >> 29;
  4997. r[k + 2] += (sp_digit)(c >> 29);
  4998. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  4999. c = lo & 0x1fffffff;
  5000. }
  5001. }
  5002. r[0] = (sp_digit)c;
  5003. }
  5004. /* Multiply two Montgomery form numbers mod the modulus (prime).
  5005. * (r = a * b mod m)
  5006. *
  5007. * r Result of multiplication.
  5008. * a First number to multiply in Montgomery form.
  5009. * b Second number to multiply in Montgomery form.
  5010. * m Modulus (prime).
  5011. * mp Montgomery multiplier.
  5012. */
  5013. SP_NOINLINE static void sp_3072_mont_mul_53(sp_digit* r, const sp_digit* a,
  5014. const sp_digit* b, const sp_digit* m, sp_digit mp)
  5015. {
  5016. sp_3072_mul_53(r, a, b);
  5017. sp_3072_mont_reduce_53(r, m, mp);
  5018. }
  5019. /* Square a and put result in r. (r = a * a)
  5020. *
  5021. * r A single precision integer.
  5022. * a A single precision integer.
  5023. */
  5024. SP_NOINLINE static void sp_3072_sqr_53(sp_digit* r, const sp_digit* a)
  5025. {
  5026. int i;
  5027. int imax;
  5028. int k;
  5029. sp_uint64 c;
  5030. sp_uint64 t;
  5031. c = ((sp_uint64)a[52]) * a[52];
  5032. r[105] = (sp_digit)(c >> 29);
  5033. c = (c & 0x1fffffff) << 29;
  5034. for (k = 103; k >= 0; k--) {
  5035. i = (k + 1) / 2;
  5036. if ((k & 1) == 0) {
  5037. c += ((sp_uint64)a[i]) * a[i];
  5038. i++;
  5039. }
  5040. if (k < 52) {
  5041. imax = k;
  5042. }
  5043. else {
  5044. imax = 52;
  5045. }
  5046. if (imax - i >= 14) {
  5047. int imaxlo;
  5048. sp_uint64 hi;
  5049. hi = c >> 29;
  5050. c &= 0x1fffffff;
  5051. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  5052. t = 0;
  5053. for (; i <= imax && i < imaxlo + 14; i++) {
  5054. t += ((sp_uint64)a[i]) * a[k - i];
  5055. }
  5056. c += t * 2;
  5057. hi += c >> 29;
  5058. c &= 0x1fffffff;
  5059. }
  5060. r[k + 2] += (sp_digit)(hi >> 29);
  5061. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  5062. c <<= 29;
  5063. }
  5064. else
  5065. {
  5066. t = 0;
  5067. for (; i <= imax; i++) {
  5068. t += ((sp_uint64)a[i]) * a[k - i];
  5069. }
  5070. c += t * 2;
  5071. r[k + 2] += (sp_digit) (c >> 58);
  5072. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  5073. c = (c & 0x1fffffff) << 29;
  5074. }
  5075. }
  5076. r[0] = (sp_digit)(c >> 29);
  5077. }
  5078. /* Square the Montgomery form number. (r = a * a mod m)
  5079. *
  5080. * r Result of squaring.
  5081. * a Number to square in Montgomery form.
  5082. * m Modulus (prime).
  5083. * mp Montgomery multiplier.
  5084. */
  5085. SP_NOINLINE static void sp_3072_mont_sqr_53(sp_digit* r, const sp_digit* a,
  5086. const sp_digit* m, sp_digit mp)
  5087. {
  5088. sp_3072_sqr_53(r, a);
  5089. sp_3072_mont_reduce_53(r, m, mp);
  5090. }
  5091. /* Multiply a by scalar b into r. (r = a * b)
  5092. *
  5093. * r A single precision integer.
  5094. * a A single precision integer.
  5095. * b A scalar.
  5096. */
  5097. SP_NOINLINE static void sp_3072_mul_d_53(sp_digit* r, const sp_digit* a,
  5098. sp_digit b)
  5099. {
  5100. sp_int64 tb = b;
  5101. sp_int64 t = 0;
  5102. int i;
  5103. for (i = 0; i < 53; i++) {
  5104. t += tb * a[i];
  5105. r[i] = (sp_digit)(t & 0x1fffffff);
  5106. t >>= 29;
  5107. }
  5108. r[53] = (sp_digit)t;
  5109. }
  5110. #ifdef WOLFSSL_SP_SMALL
  5111. /* Conditionally add a and b using the mask m.
  5112. * m is -1 to add and 0 when not.
  5113. *
  5114. * r A single precision number representing conditional add result.
  5115. * a A single precision number to add with.
  5116. * b A single precision number to add.
  5117. * m Mask value to apply.
  5118. */
  5119. static void sp_3072_cond_add_53(sp_digit* r, const sp_digit* a,
  5120. const sp_digit* b, const sp_digit m)
  5121. {
  5122. int i;
  5123. for (i = 0; i < 53; i++) {
  5124. r[i] = a[i] + (b[i] & m);
  5125. }
  5126. }
  5127. #endif /* WOLFSSL_SP_SMALL */
  5128. /* Add b to a into r. (r = a + b)
  5129. *
  5130. * r A single precision integer.
  5131. * a A single precision integer.
  5132. * b A single precision integer.
  5133. */
  5134. SP_NOINLINE static int sp_3072_add_53(sp_digit* r, const sp_digit* a,
  5135. const sp_digit* b)
  5136. {
  5137. int i;
  5138. for (i = 0; i < 53; i++) {
  5139. r[i] = a[i] + b[i];
  5140. }
  5141. return 0;
  5142. }
  5143. SP_NOINLINE static void sp_3072_rshift_53(sp_digit* r, const sp_digit* a,
  5144. byte n)
  5145. {
  5146. int i;
  5147. for (i=0; i<52; i++) {
  5148. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  5149. }
  5150. r[52] = a[52] >> n;
  5151. }
  5152. static WC_INLINE sp_digit sp_3072_div_word_53(sp_digit d1, sp_digit d0,
  5153. sp_digit div)
  5154. {
  5155. #ifdef SP_USE_DIVTI3
  5156. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5157. return d / div;
  5158. #elif defined(__x86_64__) || defined(__i386__)
  5159. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5160. sp_uint32 lo = (sp_uint32)d;
  5161. sp_digit hi = (sp_digit)(d >> 32);
  5162. __asm__ __volatile__ (
  5163. "idiv %2"
  5164. : "+a" (lo)
  5165. : "d" (hi), "r" (div)
  5166. : "cc"
  5167. );
  5168. return (sp_digit)lo;
  5169. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  5170. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5171. sp_digit dv = (div >> 1) + 1;
  5172. sp_digit t1 = (sp_digit)(d >> 29);
  5173. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  5174. sp_digit t2;
  5175. sp_digit sign;
  5176. sp_digit r;
  5177. int i;
  5178. sp_int64 m;
  5179. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  5180. t1 -= dv & (0 - r);
  5181. for (i = 27; i >= 1; i--) {
  5182. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  5183. t0 <<= 1;
  5184. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  5185. r += r + t2;
  5186. t1 -= dv & (0 - t2);
  5187. t1 += t2;
  5188. }
  5189. r += r + 1;
  5190. m = d - ((sp_int64)r * div);
  5191. r += (sp_digit)(m >> 29);
  5192. m = d - ((sp_int64)r * div);
  5193. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  5194. m = d - ((sp_int64)r * div);
  5195. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  5196. m *= sign;
  5197. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  5198. r += sign * t2;
  5199. m = d - ((sp_int64)r * div);
  5200. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  5201. m *= sign;
  5202. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  5203. r += sign * t2;
  5204. return r;
  5205. #else
  5206. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5207. sp_digit r = 0;
  5208. sp_digit t;
  5209. sp_digit dv = (div >> 14) + 1;
  5210. t = (sp_digit)(d >> 28);
  5211. t = (t / dv) << 14;
  5212. r += t;
  5213. d -= (sp_int64)t * div;
  5214. t = (sp_digit)(d >> 13);
  5215. t = t / (dv << 1);
  5216. r += t;
  5217. d -= (sp_int64)t * div;
  5218. t = (sp_digit)d;
  5219. t = t / div;
  5220. r += t;
  5221. d -= (sp_int64)t * div;
  5222. return r;
  5223. #endif
  5224. }
  5225. static WC_INLINE sp_digit sp_3072_word_div_word_53(sp_digit d, sp_digit div)
  5226. {
  5227. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  5228. defined(SP_DIV_WORD_USE_DIV)
  5229. return d / div;
  5230. #else
  5231. return (sp_digit)((sp_uint32)(div - d) >> 31);
  5232. #endif
  5233. }
  5234. /* Divide d in a and put remainder into r (m*d + r = a)
  5235. * m is not calculated as it is not needed at this time.
  5236. *
  5237. * Full implementation.
  5238. *
  5239. * a Number to be divided.
  5240. * d Number to divide with.
  5241. * m Multiplier result.
  5242. * r Remainder from the division.
  5243. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  5244. */
  5245. static int sp_3072_div_53(const sp_digit* a, const sp_digit* d,
  5246. const sp_digit* m, sp_digit* r)
  5247. {
  5248. int i;
  5249. #ifndef WOLFSSL_SP_DIV_32
  5250. #endif
  5251. sp_digit dv;
  5252. sp_digit r1;
  5253. #ifdef WOLFSSL_SP_SMALL_STACK
  5254. sp_digit* t1 = NULL;
  5255. #else
  5256. sp_digit t1[4 * 53 + 3];
  5257. #endif
  5258. sp_digit* t2 = NULL;
  5259. sp_digit* sd = NULL;
  5260. int err = MP_OKAY;
  5261. (void)m;
  5262. #ifdef WOLFSSL_SP_SMALL_STACK
  5263. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 53 + 3), NULL,
  5264. DYNAMIC_TYPE_TMP_BUFFER);
  5265. if (t1 == NULL)
  5266. err = MEMORY_E;
  5267. #endif
  5268. (void)m;
  5269. if (err == MP_OKAY) {
  5270. t2 = t1 + 106 + 1;
  5271. sd = t2 + 53 + 1;
  5272. sp_3072_mul_d_53(sd, d, (sp_digit)1 << 1);
  5273. sp_3072_mul_d_106(t1, a, (sp_digit)1 << 1);
  5274. dv = sd[52];
  5275. t1[53 + 53] += t1[53 + 53 - 1] >> 29;
  5276. t1[53 + 53 - 1] &= 0x1fffffff;
  5277. for (i=53; i>=0; i--) {
  5278. r1 = sp_3072_div_word_53(t1[53 + i], t1[53 + i - 1], dv);
  5279. sp_3072_mul_d_53(t2, sd, r1);
  5280. (void)sp_3072_sub_53(&t1[i], &t1[i], t2);
  5281. sp_3072_norm_53(&t1[i]);
  5282. t1[53 + i] -= t2[53];
  5283. t1[53 + i] += t1[53 + i - 1] >> 29;
  5284. t1[53 + i - 1] &= 0x1fffffff;
  5285. r1 = sp_3072_div_word_53(-t1[53 + i], -t1[53 + i - 1], dv);
  5286. r1 -= t1[53 + i];
  5287. sp_3072_mul_d_53(t2, sd, r1);
  5288. (void)sp_3072_add_53(&t1[i], &t1[i], t2);
  5289. t1[53 + i] += t1[53 + i - 1] >> 29;
  5290. t1[53 + i - 1] &= 0x1fffffff;
  5291. }
  5292. t1[53 - 1] += t1[53 - 2] >> 29;
  5293. t1[53 - 2] &= 0x1fffffff;
  5294. r1 = sp_3072_word_div_word_53(t1[53 - 1], dv);
  5295. sp_3072_mul_d_53(t2, sd, r1);
  5296. sp_3072_sub_53(t1, t1, t2);
  5297. XMEMCPY(r, t1, sizeof(*r) * 106U);
  5298. for (i=0; i<52; i++) {
  5299. r[i+1] += r[i] >> 29;
  5300. r[i] &= 0x1fffffff;
  5301. }
  5302. sp_3072_cond_add_53(r, r, sd, r[52] >> 31);
  5303. sp_3072_norm_53(r);
  5304. sp_3072_rshift_53(r, r, 1);
  5305. }
  5306. #ifdef WOLFSSL_SP_SMALL_STACK
  5307. if (t1 != NULL)
  5308. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  5309. #endif
  5310. return err;
  5311. }
  5312. /* Reduce a modulo m into r. (r = a mod m)
  5313. *
  5314. * r A single precision number that is the reduced result.
  5315. * a A single precision number that is to be reduced.
  5316. * m A single precision number that is the modulus to reduce with.
  5317. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  5318. */
  5319. static int sp_3072_mod_53(sp_digit* r, const sp_digit* a, const sp_digit* m)
  5320. {
  5321. return sp_3072_div_53(a, m, NULL, r);
  5322. }
  5323. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  5324. *
  5325. * r A single precision number that is the result of the operation.
  5326. * a A single precision number being exponentiated.
  5327. * e A single precision number that is the exponent.
  5328. * bits The number of bits in the exponent.
  5329. * m A single precision number that is the modulus.
  5330. * returns 0 on success.
  5331. * returns MEMORY_E on dynamic memory allocation failure.
  5332. * returns MP_VAL when base is even or exponent is 0.
  5333. */
  5334. static int sp_3072_mod_exp_53(sp_digit* r, const sp_digit* a, const sp_digit* e,
  5335. int bits, const sp_digit* m, int reduceA)
  5336. {
  5337. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  5338. #ifdef WOLFSSL_SP_SMALL_STACK
  5339. sp_digit* td = NULL;
  5340. #else
  5341. sp_digit td[3 * 106];
  5342. #endif
  5343. sp_digit* t[3] = {0, 0, 0};
  5344. sp_digit* norm = NULL;
  5345. sp_digit mp = 1;
  5346. sp_digit n;
  5347. int i;
  5348. int c;
  5349. byte y;
  5350. int err = MP_OKAY;
  5351. if (bits == 0) {
  5352. err = MP_VAL;
  5353. }
  5354. #ifdef WOLFSSL_SP_SMALL_STACK
  5355. if (err == MP_OKAY) {
  5356. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 53 * 2, NULL,
  5357. DYNAMIC_TYPE_TMP_BUFFER);
  5358. if (td == NULL)
  5359. err = MEMORY_E;
  5360. }
  5361. #endif
  5362. if (err == MP_OKAY) {
  5363. norm = td;
  5364. for (i=0; i<3; i++) {
  5365. t[i] = td + (i * 53 * 2);
  5366. XMEMSET(t[i], 0, sizeof(sp_digit) * 53U * 2U);
  5367. }
  5368. sp_3072_mont_setup(m, &mp);
  5369. sp_3072_mont_norm_53(norm, m);
  5370. if (reduceA != 0) {
  5371. err = sp_3072_mod_53(t[1], a, m);
  5372. }
  5373. else {
  5374. XMEMCPY(t[1], a, sizeof(sp_digit) * 53U);
  5375. }
  5376. }
  5377. if (err == MP_OKAY) {
  5378. sp_3072_mul_53(t[1], t[1], norm);
  5379. err = sp_3072_mod_53(t[1], t[1], m);
  5380. }
  5381. if (err == MP_OKAY) {
  5382. i = bits / 29;
  5383. c = bits % 29;
  5384. n = e[i--] << (29 - c);
  5385. for (; ; c--) {
  5386. if (c == 0) {
  5387. if (i == -1) {
  5388. break;
  5389. }
  5390. n = e[i--];
  5391. c = 29;
  5392. }
  5393. y = (int)((n >> 28) & 1);
  5394. n <<= 1;
  5395. sp_3072_mont_mul_53(t[y^1], t[0], t[1], m, mp);
  5396. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  5397. ((size_t)t[1] & addr_mask[y])),
  5398. sizeof(*t[2]) * 53 * 2);
  5399. sp_3072_mont_sqr_53(t[2], t[2], m, mp);
  5400. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  5401. ((size_t)t[1] & addr_mask[y])), t[2],
  5402. sizeof(*t[2]) * 53 * 2);
  5403. }
  5404. sp_3072_mont_reduce_53(t[0], m, mp);
  5405. n = sp_3072_cmp_53(t[0], m);
  5406. sp_3072_cond_sub_53(t[0], t[0], m, ~(n >> 31));
  5407. XMEMCPY(r, t[0], sizeof(*r) * 53 * 2);
  5408. }
  5409. #ifdef WOLFSSL_SP_SMALL_STACK
  5410. if (td != NULL)
  5411. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  5412. #endif
  5413. return err;
  5414. #elif !defined(WC_NO_CACHE_RESISTANT)
  5415. #ifdef WOLFSSL_SP_SMALL_STACK
  5416. sp_digit* td = NULL;
  5417. #else
  5418. sp_digit td[3 * 106];
  5419. #endif
  5420. sp_digit* t[3] = {0, 0, 0};
  5421. sp_digit* norm = NULL;
  5422. sp_digit mp = 1;
  5423. sp_digit n;
  5424. int i;
  5425. int c;
  5426. byte y;
  5427. int err = MP_OKAY;
  5428. if (bits == 0) {
  5429. err = MP_VAL;
  5430. }
  5431. #ifdef WOLFSSL_SP_SMALL_STACK
  5432. if (err == MP_OKAY) {
  5433. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 53 * 2, NULL,
  5434. DYNAMIC_TYPE_TMP_BUFFER);
  5435. if (td == NULL)
  5436. err = MEMORY_E;
  5437. }
  5438. #endif
  5439. if (err == MP_OKAY) {
  5440. norm = td;
  5441. for (i=0; i<3; i++) {
  5442. t[i] = td + (i * 53 * 2);
  5443. }
  5444. sp_3072_mont_setup(m, &mp);
  5445. sp_3072_mont_norm_53(norm, m);
  5446. if (reduceA != 0) {
  5447. err = sp_3072_mod_53(t[1], a, m);
  5448. if (err == MP_OKAY) {
  5449. sp_3072_mul_53(t[1], t[1], norm);
  5450. err = sp_3072_mod_53(t[1], t[1], m);
  5451. }
  5452. }
  5453. else {
  5454. sp_3072_mul_53(t[1], a, norm);
  5455. err = sp_3072_mod_53(t[1], t[1], m);
  5456. }
  5457. }
  5458. if (err == MP_OKAY) {
  5459. i = bits / 29;
  5460. c = bits % 29;
  5461. n = e[i--] << (29 - c);
  5462. for (; ; c--) {
  5463. if (c == 0) {
  5464. if (i == -1) {
  5465. break;
  5466. }
  5467. n = e[i--];
  5468. c = 29;
  5469. }
  5470. y = (int)((n >> 28) & 1);
  5471. n <<= 1;
  5472. sp_3072_mont_mul_53(t[y^1], t[0], t[1], m, mp);
  5473. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  5474. ((size_t)t[1] & addr_mask[y])),
  5475. sizeof(*t[2]) * 53 * 2);
  5476. sp_3072_mont_sqr_53(t[2], t[2], m, mp);
  5477. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  5478. ((size_t)t[1] & addr_mask[y])), t[2],
  5479. sizeof(*t[2]) * 53 * 2);
  5480. }
  5481. sp_3072_mont_reduce_53(t[0], m, mp);
  5482. n = sp_3072_cmp_53(t[0], m);
  5483. sp_3072_cond_sub_53(t[0], t[0], m, ~(n >> 31));
  5484. XMEMCPY(r, t[0], sizeof(*r) * 53 * 2);
  5485. }
  5486. #ifdef WOLFSSL_SP_SMALL_STACK
  5487. if (td != NULL)
  5488. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  5489. #endif
  5490. return err;
  5491. #else
  5492. #ifdef WOLFSSL_SP_SMALL_STACK
  5493. sp_digit* td = NULL;
  5494. #else
  5495. sp_digit td[(32 * 106) + 106];
  5496. #endif
  5497. sp_digit* t[32];
  5498. sp_digit* rt = NULL;
  5499. sp_digit* norm = NULL;
  5500. sp_digit mp = 1;
  5501. sp_digit n;
  5502. int i;
  5503. int c;
  5504. byte y;
  5505. int err = MP_OKAY;
  5506. if (bits == 0) {
  5507. err = MP_VAL;
  5508. }
  5509. #ifdef WOLFSSL_SP_SMALL_STACK
  5510. if (err == MP_OKAY) {
  5511. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((32 * 106) + 106), NULL,
  5512. DYNAMIC_TYPE_TMP_BUFFER);
  5513. if (td == NULL)
  5514. err = MEMORY_E;
  5515. }
  5516. #endif
  5517. if (err == MP_OKAY) {
  5518. norm = td;
  5519. for (i=0; i<32; i++)
  5520. t[i] = td + i * 106;
  5521. rt = td + 3392;
  5522. sp_3072_mont_setup(m, &mp);
  5523. sp_3072_mont_norm_53(norm, m);
  5524. if (reduceA != 0) {
  5525. err = sp_3072_mod_53(t[1], a, m);
  5526. if (err == MP_OKAY) {
  5527. sp_3072_mul_53(t[1], t[1], norm);
  5528. err = sp_3072_mod_53(t[1], t[1], m);
  5529. }
  5530. }
  5531. else {
  5532. sp_3072_mul_53(t[1], a, norm);
  5533. err = sp_3072_mod_53(t[1], t[1], m);
  5534. }
  5535. }
  5536. if (err == MP_OKAY) {
  5537. sp_3072_mont_sqr_53(t[ 2], t[ 1], m, mp);
  5538. sp_3072_mont_mul_53(t[ 3], t[ 2], t[ 1], m, mp);
  5539. sp_3072_mont_sqr_53(t[ 4], t[ 2], m, mp);
  5540. sp_3072_mont_mul_53(t[ 5], t[ 3], t[ 2], m, mp);
  5541. sp_3072_mont_sqr_53(t[ 6], t[ 3], m, mp);
  5542. sp_3072_mont_mul_53(t[ 7], t[ 4], t[ 3], m, mp);
  5543. sp_3072_mont_sqr_53(t[ 8], t[ 4], m, mp);
  5544. sp_3072_mont_mul_53(t[ 9], t[ 5], t[ 4], m, mp);
  5545. sp_3072_mont_sqr_53(t[10], t[ 5], m, mp);
  5546. sp_3072_mont_mul_53(t[11], t[ 6], t[ 5], m, mp);
  5547. sp_3072_mont_sqr_53(t[12], t[ 6], m, mp);
  5548. sp_3072_mont_mul_53(t[13], t[ 7], t[ 6], m, mp);
  5549. sp_3072_mont_sqr_53(t[14], t[ 7], m, mp);
  5550. sp_3072_mont_mul_53(t[15], t[ 8], t[ 7], m, mp);
  5551. sp_3072_mont_sqr_53(t[16], t[ 8], m, mp);
  5552. sp_3072_mont_mul_53(t[17], t[ 9], t[ 8], m, mp);
  5553. sp_3072_mont_sqr_53(t[18], t[ 9], m, mp);
  5554. sp_3072_mont_mul_53(t[19], t[10], t[ 9], m, mp);
  5555. sp_3072_mont_sqr_53(t[20], t[10], m, mp);
  5556. sp_3072_mont_mul_53(t[21], t[11], t[10], m, mp);
  5557. sp_3072_mont_sqr_53(t[22], t[11], m, mp);
  5558. sp_3072_mont_mul_53(t[23], t[12], t[11], m, mp);
  5559. sp_3072_mont_sqr_53(t[24], t[12], m, mp);
  5560. sp_3072_mont_mul_53(t[25], t[13], t[12], m, mp);
  5561. sp_3072_mont_sqr_53(t[26], t[13], m, mp);
  5562. sp_3072_mont_mul_53(t[27], t[14], t[13], m, mp);
  5563. sp_3072_mont_sqr_53(t[28], t[14], m, mp);
  5564. sp_3072_mont_mul_53(t[29], t[15], t[14], m, mp);
  5565. sp_3072_mont_sqr_53(t[30], t[15], m, mp);
  5566. sp_3072_mont_mul_53(t[31], t[16], t[15], m, mp);
  5567. bits = ((bits + 4) / 5) * 5;
  5568. i = ((bits + 28) / 29) - 1;
  5569. c = bits % 29;
  5570. if (c == 0) {
  5571. c = 29;
  5572. }
  5573. if (i < 53) {
  5574. n = e[i--] << (32 - c);
  5575. }
  5576. else {
  5577. n = 0;
  5578. i--;
  5579. }
  5580. if (c < 5) {
  5581. n |= e[i--] << (3 - c);
  5582. c += 29;
  5583. }
  5584. y = (int)((n >> 27) & 0x1f);
  5585. n <<= 5;
  5586. c -= 5;
  5587. XMEMCPY(rt, t[y], sizeof(sp_digit) * 106);
  5588. while ((i >= 0) || (c >= 5)) {
  5589. if (c >= 5) {
  5590. y = (byte)((n >> 27) & 0x1f);
  5591. n <<= 5;
  5592. c -= 5;
  5593. }
  5594. else if (c == 0) {
  5595. n = e[i--] << 3;
  5596. y = (byte)((n >> 27) & 0x1f);
  5597. n <<= 5;
  5598. c = 24;
  5599. }
  5600. else {
  5601. y = (byte)((n >> 27) & 0x1f);
  5602. n = e[i--] << 3;
  5603. c = 5 - c;
  5604. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  5605. n <<= c;
  5606. c = 29 - c;
  5607. }
  5608. sp_3072_mont_sqr_53(rt, rt, m, mp);
  5609. sp_3072_mont_sqr_53(rt, rt, m, mp);
  5610. sp_3072_mont_sqr_53(rt, rt, m, mp);
  5611. sp_3072_mont_sqr_53(rt, rt, m, mp);
  5612. sp_3072_mont_sqr_53(rt, rt, m, mp);
  5613. sp_3072_mont_mul_53(rt, rt, t[y], m, mp);
  5614. }
  5615. sp_3072_mont_reduce_53(rt, m, mp);
  5616. n = sp_3072_cmp_53(rt, m);
  5617. sp_3072_cond_sub_53(rt, rt, m, ~(n >> 31));
  5618. XMEMCPY(r, rt, sizeof(sp_digit) * 106);
  5619. }
  5620. #ifdef WOLFSSL_SP_SMALL_STACK
  5621. if (td != NULL)
  5622. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  5623. #endif
  5624. return err;
  5625. #endif
  5626. }
  5627. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) | WOLFSSL_HAVE_SP_DH */
  5628. /* Sub b from a into r. (r = a - b)
  5629. *
  5630. * r A single precision integer.
  5631. * a A single precision integer.
  5632. * b A single precision integer.
  5633. */
  5634. SP_NOINLINE static int sp_3072_sub_106(sp_digit* r, const sp_digit* a,
  5635. const sp_digit* b)
  5636. {
  5637. int i;
  5638. for (i = 0; i < 106; i++) {
  5639. r[i] = a[i] - b[i];
  5640. }
  5641. return 0;
  5642. }
  5643. /* r = 2^n mod m where n is the number of bits to reduce by.
  5644. * Given m must be 3072 bits, just need to subtract.
  5645. *
  5646. * r A single precision number.
  5647. * m A single precision number.
  5648. */
  5649. static void sp_3072_mont_norm_106(sp_digit* r, const sp_digit* m)
  5650. {
  5651. /* Set r = 2^n - 1. */
  5652. int i;
  5653. for (i=0; i<105; i++) {
  5654. r[i] = 0x1fffffff;
  5655. }
  5656. r[105] = 0x7ffffffL;
  5657. /* r = (2^n - 1) mod n */
  5658. (void)sp_3072_sub_106(r, r, m);
  5659. /* Add one so r = 2^n mod m */
  5660. r[0] += 1;
  5661. }
  5662. /* Compare a with b in constant time.
  5663. *
  5664. * a A single precision integer.
  5665. * b A single precision integer.
  5666. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  5667. * respectively.
  5668. */
  5669. static sp_digit sp_3072_cmp_106(const sp_digit* a, const sp_digit* b)
  5670. {
  5671. sp_digit r = 0;
  5672. int i;
  5673. for (i=105; i>=0; i--) {
  5674. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  5675. }
  5676. return r;
  5677. }
  5678. /* Conditionally subtract b from a using the mask m.
  5679. * m is -1 to subtract and 0 when not.
  5680. *
  5681. * r A single precision number representing condition subtract result.
  5682. * a A single precision number to subtract from.
  5683. * b A single precision number to subtract.
  5684. * m Mask value to apply.
  5685. */
  5686. static void sp_3072_cond_sub_106(sp_digit* r, const sp_digit* a,
  5687. const sp_digit* b, const sp_digit m)
  5688. {
  5689. int i;
  5690. for (i = 0; i < 106; i++) {
  5691. r[i] = a[i] - (b[i] & m);
  5692. }
  5693. }
  5694. /* Mul a by scalar b and add into r. (r += a * b)
  5695. *
  5696. * r A single precision integer.
  5697. * a A single precision integer.
  5698. * b A scalar.
  5699. */
  5700. SP_NOINLINE static void sp_3072_mul_add_106(sp_digit* r, const sp_digit* a,
  5701. const sp_digit b)
  5702. {
  5703. #ifndef WOLFSSL_SP_LARGE_CODE
  5704. sp_int64 tb = b;
  5705. sp_int64 t = 0;
  5706. int i;
  5707. for (i = 0; i < 106; i++) {
  5708. t += r[i];
  5709. t += tb * a[i];
  5710. r[i] = ((sp_digit)t) & 0x1fffffff;
  5711. t >>= 29;
  5712. }
  5713. r[106] += (sp_digit)t;
  5714. #else
  5715. sp_int64 tb = b;
  5716. sp_int64 t[4];
  5717. int i;
  5718. t[0] = 0;
  5719. for (i = 0; i < 104; i += 4) {
  5720. t[0] += (tb * a[i+0]) + r[i+0];
  5721. t[1] = (tb * a[i+1]) + r[i+1];
  5722. t[2] = (tb * a[i+2]) + r[i+2];
  5723. t[3] = (tb * a[i+3]) + r[i+3];
  5724. r[i+0] = t[0] & 0x1fffffff;
  5725. t[1] += t[0] >> 29;
  5726. r[i+1] = t[1] & 0x1fffffff;
  5727. t[2] += t[1] >> 29;
  5728. r[i+2] = t[2] & 0x1fffffff;
  5729. t[3] += t[2] >> 29;
  5730. r[i+3] = t[3] & 0x1fffffff;
  5731. t[0] = t[3] >> 29;
  5732. }
  5733. t[0] += (tb * a[104]) + r[104];
  5734. t[1] = (tb * a[105]) + r[105];
  5735. r[104] = t[0] & 0x1fffffff;
  5736. t[1] += t[0] >> 29;
  5737. r[105] = t[1] & 0x1fffffff;
  5738. r[106] += (sp_digit)(t[1] >> 29);
  5739. #endif /* !WOLFSSL_SP_LARGE_CODE */
  5740. }
  5741. /* Shift the result in the high 3072 bits down to the bottom.
  5742. *
  5743. * r A single precision number.
  5744. * a A single precision number.
  5745. */
  5746. static void sp_3072_mont_shift_106(sp_digit* r, const sp_digit* a)
  5747. {
  5748. int i;
  5749. sp_int64 n = a[105] >> 27;
  5750. n += ((sp_int64)a[106]) << 2;
  5751. for (i = 0; i < 105; i++) {
  5752. r[i] = n & 0x1fffffff;
  5753. n >>= 29;
  5754. n += ((sp_int64)a[107 + i]) << 2;
  5755. }
  5756. r[105] = (sp_digit)n;
  5757. XMEMSET(&r[106], 0, sizeof(*r) * 106U);
  5758. }
  5759. /* Reduce the number back to 3072 bits using Montgomery reduction.
  5760. *
  5761. * a A single precision number to reduce in place.
  5762. * m The single precision number representing the modulus.
  5763. * mp The digit representing the negative inverse of m mod 2^n.
  5764. */
  5765. static void sp_3072_mont_reduce_106(sp_digit* a, const sp_digit* m, sp_digit mp)
  5766. {
  5767. int i;
  5768. sp_digit mu;
  5769. sp_digit over;
  5770. sp_3072_norm_106(a + 106);
  5771. #ifdef WOLFSSL_SP_DH
  5772. if (mp != 1) {
  5773. for (i=0; i<105; i++) {
  5774. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  5775. sp_3072_mul_add_106(a+i, m, mu);
  5776. a[i+1] += a[i] >> 29;
  5777. }
  5778. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x7ffffffL;
  5779. sp_3072_mul_add_106(a+i, m, mu);
  5780. a[i+1] += a[i] >> 29;
  5781. a[i] &= 0x1fffffff;
  5782. }
  5783. else {
  5784. for (i=0; i<105; i++) {
  5785. mu = a[i] & 0x1fffffff;
  5786. sp_3072_mul_add_106(a+i, m, mu);
  5787. a[i+1] += a[i] >> 29;
  5788. }
  5789. mu = a[i] & 0x7ffffffL;
  5790. sp_3072_mul_add_106(a+i, m, mu);
  5791. a[i+1] += a[i] >> 29;
  5792. a[i] &= 0x1fffffff;
  5793. }
  5794. #else
  5795. for (i=0; i<105; i++) {
  5796. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  5797. sp_3072_mul_add_106(a+i, m, mu);
  5798. a[i+1] += a[i] >> 29;
  5799. }
  5800. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x7ffffffL;
  5801. sp_3072_mul_add_106(a+i, m, mu);
  5802. a[i+1] += a[i] >> 29;
  5803. a[i] &= 0x1fffffff;
  5804. #endif
  5805. sp_3072_mont_shift_106(a, a);
  5806. over = a[105] - m[105];
  5807. sp_3072_cond_sub_106(a, a, m, ~((over - 1) >> 31));
  5808. sp_3072_norm_106(a);
  5809. }
  5810. /* Multiply two Montgomery form numbers mod the modulus (prime).
  5811. * (r = a * b mod m)
  5812. *
  5813. * r Result of multiplication.
  5814. * a First number to multiply in Montgomery form.
  5815. * b Second number to multiply in Montgomery form.
  5816. * m Modulus (prime).
  5817. * mp Montgomery multiplier.
  5818. */
  5819. SP_NOINLINE static void sp_3072_mont_mul_106(sp_digit* r, const sp_digit* a,
  5820. const sp_digit* b, const sp_digit* m, sp_digit mp)
  5821. {
  5822. sp_3072_mul_106(r, a, b);
  5823. sp_3072_mont_reduce_106(r, m, mp);
  5824. }
  5825. /* Square the Montgomery form number. (r = a * a mod m)
  5826. *
  5827. * r Result of squaring.
  5828. * a Number to square in Montgomery form.
  5829. * m Modulus (prime).
  5830. * mp Montgomery multiplier.
  5831. */
  5832. SP_NOINLINE static void sp_3072_mont_sqr_106(sp_digit* r, const sp_digit* a,
  5833. const sp_digit* m, sp_digit mp)
  5834. {
  5835. sp_3072_sqr_106(r, a);
  5836. sp_3072_mont_reduce_106(r, m, mp);
  5837. }
  5838. /* Multiply a by scalar b into r. (r = a * b)
  5839. *
  5840. * r A single precision integer.
  5841. * a A single precision integer.
  5842. * b A scalar.
  5843. */
  5844. SP_NOINLINE static void sp_3072_mul_d_212(sp_digit* r, const sp_digit* a,
  5845. sp_digit b)
  5846. {
  5847. sp_int64 tb = b;
  5848. sp_int64 t = 0;
  5849. int i;
  5850. for (i = 0; i < 212; i++) {
  5851. t += tb * a[i];
  5852. r[i] = (sp_digit)(t & 0x1fffffff);
  5853. t >>= 29;
  5854. }
  5855. r[212] = (sp_digit)t;
  5856. }
  5857. #ifdef WOLFSSL_SP_SMALL
  5858. /* Conditionally add a and b using the mask m.
  5859. * m is -1 to add and 0 when not.
  5860. *
  5861. * r A single precision number representing conditional add result.
  5862. * a A single precision number to add with.
  5863. * b A single precision number to add.
  5864. * m Mask value to apply.
  5865. */
  5866. static void sp_3072_cond_add_106(sp_digit* r, const sp_digit* a,
  5867. const sp_digit* b, const sp_digit m)
  5868. {
  5869. int i;
  5870. for (i = 0; i < 106; i++) {
  5871. r[i] = a[i] + (b[i] & m);
  5872. }
  5873. }
  5874. #endif /* WOLFSSL_SP_SMALL */
  5875. /* Add b to a into r. (r = a + b)
  5876. *
  5877. * r A single precision integer.
  5878. * a A single precision integer.
  5879. * b A single precision integer.
  5880. */
  5881. SP_NOINLINE static int sp_3072_add_106(sp_digit* r, const sp_digit* a,
  5882. const sp_digit* b)
  5883. {
  5884. int i;
  5885. for (i = 0; i < 106; i++) {
  5886. r[i] = a[i] + b[i];
  5887. }
  5888. return 0;
  5889. }
  5890. SP_NOINLINE static void sp_3072_rshift_106(sp_digit* r, const sp_digit* a,
  5891. byte n)
  5892. {
  5893. int i;
  5894. for (i=0; i<105; i++) {
  5895. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  5896. }
  5897. r[105] = a[105] >> n;
  5898. }
  5899. static WC_INLINE sp_digit sp_3072_div_word_106(sp_digit d1, sp_digit d0,
  5900. sp_digit div)
  5901. {
  5902. #ifdef SP_USE_DIVTI3
  5903. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5904. return d / div;
  5905. #elif defined(__x86_64__) || defined(__i386__)
  5906. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5907. sp_uint32 lo = (sp_uint32)d;
  5908. sp_digit hi = (sp_digit)(d >> 32);
  5909. __asm__ __volatile__ (
  5910. "idiv %2"
  5911. : "+a" (lo)
  5912. : "d" (hi), "r" (div)
  5913. : "cc"
  5914. );
  5915. return (sp_digit)lo;
  5916. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  5917. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5918. sp_digit dv = (div >> 1) + 1;
  5919. sp_digit t1 = (sp_digit)(d >> 29);
  5920. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  5921. sp_digit t2;
  5922. sp_digit sign;
  5923. sp_digit r;
  5924. int i;
  5925. sp_int64 m;
  5926. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  5927. t1 -= dv & (0 - r);
  5928. for (i = 27; i >= 1; i--) {
  5929. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  5930. t0 <<= 1;
  5931. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  5932. r += r + t2;
  5933. t1 -= dv & (0 - t2);
  5934. t1 += t2;
  5935. }
  5936. r += r + 1;
  5937. m = d - ((sp_int64)r * div);
  5938. r += (sp_digit)(m >> 29);
  5939. m = d - ((sp_int64)r * div);
  5940. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  5941. m = d - ((sp_int64)r * div);
  5942. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  5943. m *= sign;
  5944. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  5945. r += sign * t2;
  5946. m = d - ((sp_int64)r * div);
  5947. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  5948. m *= sign;
  5949. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  5950. r += sign * t2;
  5951. return r;
  5952. #else
  5953. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  5954. sp_digit r = 0;
  5955. sp_digit t;
  5956. sp_digit dv = (div >> 14) + 1;
  5957. t = (sp_digit)(d >> 28);
  5958. t = (t / dv) << 14;
  5959. r += t;
  5960. d -= (sp_int64)t * div;
  5961. t = (sp_digit)(d >> 13);
  5962. t = t / (dv << 1);
  5963. r += t;
  5964. d -= (sp_int64)t * div;
  5965. t = (sp_digit)d;
  5966. t = t / div;
  5967. r += t;
  5968. d -= (sp_int64)t * div;
  5969. return r;
  5970. #endif
  5971. }
  5972. static WC_INLINE sp_digit sp_3072_word_div_word_106(sp_digit d, sp_digit div)
  5973. {
  5974. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  5975. defined(SP_DIV_WORD_USE_DIV)
  5976. return d / div;
  5977. #else
  5978. return (sp_digit)((sp_uint32)(div - d) >> 31);
  5979. #endif
  5980. }
  5981. /* Divide d in a and put remainder into r (m*d + r = a)
  5982. * m is not calculated as it is not needed at this time.
  5983. *
  5984. * Full implementation.
  5985. *
  5986. * a Number to be divided.
  5987. * d Number to divide with.
  5988. * m Multiplier result.
  5989. * r Remainder from the division.
  5990. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  5991. */
  5992. static int sp_3072_div_106(const sp_digit* a, const sp_digit* d,
  5993. const sp_digit* m, sp_digit* r)
  5994. {
  5995. int i;
  5996. #ifndef WOLFSSL_SP_DIV_32
  5997. #endif
  5998. sp_digit dv;
  5999. sp_digit r1;
  6000. #ifdef WOLFSSL_SP_SMALL_STACK
  6001. sp_digit* t1 = NULL;
  6002. #else
  6003. sp_digit t1[4 * 106 + 3];
  6004. #endif
  6005. sp_digit* t2 = NULL;
  6006. sp_digit* sd = NULL;
  6007. int err = MP_OKAY;
  6008. (void)m;
  6009. #ifdef WOLFSSL_SP_SMALL_STACK
  6010. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 106 + 3), NULL,
  6011. DYNAMIC_TYPE_TMP_BUFFER);
  6012. if (t1 == NULL)
  6013. err = MEMORY_E;
  6014. #endif
  6015. (void)m;
  6016. if (err == MP_OKAY) {
  6017. t2 = t1 + 212 + 1;
  6018. sd = t2 + 106 + 1;
  6019. sp_3072_mul_d_106(sd, d, (sp_digit)1 << 2);
  6020. sp_3072_mul_d_212(t1, a, (sp_digit)1 << 2);
  6021. dv = sd[105];
  6022. t1[106 + 106] += t1[106 + 106 - 1] >> 29;
  6023. t1[106 + 106 - 1] &= 0x1fffffff;
  6024. for (i=106; i>=0; i--) {
  6025. r1 = sp_3072_div_word_106(t1[106 + i], t1[106 + i - 1], dv);
  6026. sp_3072_mul_d_106(t2, sd, r1);
  6027. (void)sp_3072_sub_106(&t1[i], &t1[i], t2);
  6028. sp_3072_norm_106(&t1[i]);
  6029. t1[106 + i] -= t2[106];
  6030. t1[106 + i] += t1[106 + i - 1] >> 29;
  6031. t1[106 + i - 1] &= 0x1fffffff;
  6032. r1 = sp_3072_div_word_106(-t1[106 + i], -t1[106 + i - 1], dv);
  6033. r1 -= t1[106 + i];
  6034. sp_3072_mul_d_106(t2, sd, r1);
  6035. (void)sp_3072_add_106(&t1[i], &t1[i], t2);
  6036. t1[106 + i] += t1[106 + i - 1] >> 29;
  6037. t1[106 + i - 1] &= 0x1fffffff;
  6038. }
  6039. t1[106 - 1] += t1[106 - 2] >> 29;
  6040. t1[106 - 2] &= 0x1fffffff;
  6041. r1 = sp_3072_word_div_word_106(t1[106 - 1], dv);
  6042. sp_3072_mul_d_106(t2, sd, r1);
  6043. sp_3072_sub_106(t1, t1, t2);
  6044. XMEMCPY(r, t1, sizeof(*r) * 212U);
  6045. for (i=0; i<105; i++) {
  6046. r[i+1] += r[i] >> 29;
  6047. r[i] &= 0x1fffffff;
  6048. }
  6049. sp_3072_cond_add_106(r, r, sd, r[105] >> 31);
  6050. sp_3072_norm_106(r);
  6051. sp_3072_rshift_106(r, r, 2);
  6052. }
  6053. #ifdef WOLFSSL_SP_SMALL_STACK
  6054. if (t1 != NULL)
  6055. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  6056. #endif
  6057. return err;
  6058. }
  6059. /* Reduce a modulo m into r. (r = a mod m)
  6060. *
  6061. * r A single precision number that is the reduced result.
  6062. * a A single precision number that is to be reduced.
  6063. * m A single precision number that is the modulus to reduce with.
  6064. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  6065. */
  6066. static int sp_3072_mod_106(sp_digit* r, const sp_digit* a, const sp_digit* m)
  6067. {
  6068. return sp_3072_div_106(a, m, NULL, r);
  6069. }
  6070. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  6071. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  6072. *
  6073. * r A single precision number that is the result of the operation.
  6074. * a A single precision number being exponentiated.
  6075. * e A single precision number that is the exponent.
  6076. * bits The number of bits in the exponent.
  6077. * m A single precision number that is the modulus.
  6078. * returns 0 on success.
  6079. * returns MEMORY_E on dynamic memory allocation failure.
  6080. * returns MP_VAL when base is even or exponent is 0.
  6081. */
  6082. static int sp_3072_mod_exp_106(sp_digit* r, const sp_digit* a, const sp_digit* e,
  6083. int bits, const sp_digit* m, int reduceA)
  6084. {
  6085. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  6086. #ifdef WOLFSSL_SP_SMALL_STACK
  6087. sp_digit* td = NULL;
  6088. #else
  6089. sp_digit td[3 * 212];
  6090. #endif
  6091. sp_digit* t[3] = {0, 0, 0};
  6092. sp_digit* norm = NULL;
  6093. sp_digit mp = 1;
  6094. sp_digit n;
  6095. int i;
  6096. int c;
  6097. byte y;
  6098. int err = MP_OKAY;
  6099. if (bits == 0) {
  6100. err = MP_VAL;
  6101. }
  6102. #ifdef WOLFSSL_SP_SMALL_STACK
  6103. if (err == MP_OKAY) {
  6104. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 106 * 2, NULL,
  6105. DYNAMIC_TYPE_TMP_BUFFER);
  6106. if (td == NULL)
  6107. err = MEMORY_E;
  6108. }
  6109. #endif
  6110. if (err == MP_OKAY) {
  6111. norm = td;
  6112. for (i=0; i<3; i++) {
  6113. t[i] = td + (i * 106 * 2);
  6114. XMEMSET(t[i], 0, sizeof(sp_digit) * 106U * 2U);
  6115. }
  6116. sp_3072_mont_setup(m, &mp);
  6117. sp_3072_mont_norm_106(norm, m);
  6118. if (reduceA != 0) {
  6119. err = sp_3072_mod_106(t[1], a, m);
  6120. }
  6121. else {
  6122. XMEMCPY(t[1], a, sizeof(sp_digit) * 106U);
  6123. }
  6124. }
  6125. if (err == MP_OKAY) {
  6126. sp_3072_mul_106(t[1], t[1], norm);
  6127. err = sp_3072_mod_106(t[1], t[1], m);
  6128. }
  6129. if (err == MP_OKAY) {
  6130. i = bits / 29;
  6131. c = bits % 29;
  6132. n = e[i--] << (29 - c);
  6133. for (; ; c--) {
  6134. if (c == 0) {
  6135. if (i == -1) {
  6136. break;
  6137. }
  6138. n = e[i--];
  6139. c = 29;
  6140. }
  6141. y = (int)((n >> 28) & 1);
  6142. n <<= 1;
  6143. sp_3072_mont_mul_106(t[y^1], t[0], t[1], m, mp);
  6144. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  6145. ((size_t)t[1] & addr_mask[y])),
  6146. sizeof(*t[2]) * 106 * 2);
  6147. sp_3072_mont_sqr_106(t[2], t[2], m, mp);
  6148. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  6149. ((size_t)t[1] & addr_mask[y])), t[2],
  6150. sizeof(*t[2]) * 106 * 2);
  6151. }
  6152. sp_3072_mont_reduce_106(t[0], m, mp);
  6153. n = sp_3072_cmp_106(t[0], m);
  6154. sp_3072_cond_sub_106(t[0], t[0], m, ~(n >> 31));
  6155. XMEMCPY(r, t[0], sizeof(*r) * 106 * 2);
  6156. }
  6157. #ifdef WOLFSSL_SP_SMALL_STACK
  6158. if (td != NULL)
  6159. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  6160. #endif
  6161. return err;
  6162. #elif !defined(WC_NO_CACHE_RESISTANT)
  6163. #ifdef WOLFSSL_SP_SMALL_STACK
  6164. sp_digit* td = NULL;
  6165. #else
  6166. sp_digit td[3 * 212];
  6167. #endif
  6168. sp_digit* t[3] = {0, 0, 0};
  6169. sp_digit* norm = NULL;
  6170. sp_digit mp = 1;
  6171. sp_digit n;
  6172. int i;
  6173. int c;
  6174. byte y;
  6175. int err = MP_OKAY;
  6176. if (bits == 0) {
  6177. err = MP_VAL;
  6178. }
  6179. #ifdef WOLFSSL_SP_SMALL_STACK
  6180. if (err == MP_OKAY) {
  6181. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 106 * 2, NULL,
  6182. DYNAMIC_TYPE_TMP_BUFFER);
  6183. if (td == NULL)
  6184. err = MEMORY_E;
  6185. }
  6186. #endif
  6187. if (err == MP_OKAY) {
  6188. norm = td;
  6189. for (i=0; i<3; i++) {
  6190. t[i] = td + (i * 106 * 2);
  6191. }
  6192. sp_3072_mont_setup(m, &mp);
  6193. sp_3072_mont_norm_106(norm, m);
  6194. if (reduceA != 0) {
  6195. err = sp_3072_mod_106(t[1], a, m);
  6196. if (err == MP_OKAY) {
  6197. sp_3072_mul_106(t[1], t[1], norm);
  6198. err = sp_3072_mod_106(t[1], t[1], m);
  6199. }
  6200. }
  6201. else {
  6202. sp_3072_mul_106(t[1], a, norm);
  6203. err = sp_3072_mod_106(t[1], t[1], m);
  6204. }
  6205. }
  6206. if (err == MP_OKAY) {
  6207. i = bits / 29;
  6208. c = bits % 29;
  6209. n = e[i--] << (29 - c);
  6210. for (; ; c--) {
  6211. if (c == 0) {
  6212. if (i == -1) {
  6213. break;
  6214. }
  6215. n = e[i--];
  6216. c = 29;
  6217. }
  6218. y = (int)((n >> 28) & 1);
  6219. n <<= 1;
  6220. sp_3072_mont_mul_106(t[y^1], t[0], t[1], m, mp);
  6221. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  6222. ((size_t)t[1] & addr_mask[y])),
  6223. sizeof(*t[2]) * 106 * 2);
  6224. sp_3072_mont_sqr_106(t[2], t[2], m, mp);
  6225. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  6226. ((size_t)t[1] & addr_mask[y])), t[2],
  6227. sizeof(*t[2]) * 106 * 2);
  6228. }
  6229. sp_3072_mont_reduce_106(t[0], m, mp);
  6230. n = sp_3072_cmp_106(t[0], m);
  6231. sp_3072_cond_sub_106(t[0], t[0], m, ~(n >> 31));
  6232. XMEMCPY(r, t[0], sizeof(*r) * 106 * 2);
  6233. }
  6234. #ifdef WOLFSSL_SP_SMALL_STACK
  6235. if (td != NULL)
  6236. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  6237. #endif
  6238. return err;
  6239. #else
  6240. #ifdef WOLFSSL_SP_SMALL_STACK
  6241. sp_digit* td = NULL;
  6242. #else
  6243. sp_digit td[(16 * 212) + 212];
  6244. #endif
  6245. sp_digit* t[16];
  6246. sp_digit* rt = NULL;
  6247. sp_digit* norm = NULL;
  6248. sp_digit mp = 1;
  6249. sp_digit n;
  6250. int i;
  6251. int c;
  6252. byte y;
  6253. int err = MP_OKAY;
  6254. if (bits == 0) {
  6255. err = MP_VAL;
  6256. }
  6257. #ifdef WOLFSSL_SP_SMALL_STACK
  6258. if (err == MP_OKAY) {
  6259. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((16 * 212) + 212), NULL,
  6260. DYNAMIC_TYPE_TMP_BUFFER);
  6261. if (td == NULL)
  6262. err = MEMORY_E;
  6263. }
  6264. #endif
  6265. if (err == MP_OKAY) {
  6266. norm = td;
  6267. for (i=0; i<16; i++)
  6268. t[i] = td + i * 212;
  6269. rt = td + 3392;
  6270. sp_3072_mont_setup(m, &mp);
  6271. sp_3072_mont_norm_106(norm, m);
  6272. if (reduceA != 0) {
  6273. err = sp_3072_mod_106(t[1], a, m);
  6274. if (err == MP_OKAY) {
  6275. sp_3072_mul_106(t[1], t[1], norm);
  6276. err = sp_3072_mod_106(t[1], t[1], m);
  6277. }
  6278. }
  6279. else {
  6280. sp_3072_mul_106(t[1], a, norm);
  6281. err = sp_3072_mod_106(t[1], t[1], m);
  6282. }
  6283. }
  6284. if (err == MP_OKAY) {
  6285. sp_3072_mont_sqr_106(t[ 2], t[ 1], m, mp);
  6286. sp_3072_mont_mul_106(t[ 3], t[ 2], t[ 1], m, mp);
  6287. sp_3072_mont_sqr_106(t[ 4], t[ 2], m, mp);
  6288. sp_3072_mont_mul_106(t[ 5], t[ 3], t[ 2], m, mp);
  6289. sp_3072_mont_sqr_106(t[ 6], t[ 3], m, mp);
  6290. sp_3072_mont_mul_106(t[ 7], t[ 4], t[ 3], m, mp);
  6291. sp_3072_mont_sqr_106(t[ 8], t[ 4], m, mp);
  6292. sp_3072_mont_mul_106(t[ 9], t[ 5], t[ 4], m, mp);
  6293. sp_3072_mont_sqr_106(t[10], t[ 5], m, mp);
  6294. sp_3072_mont_mul_106(t[11], t[ 6], t[ 5], m, mp);
  6295. sp_3072_mont_sqr_106(t[12], t[ 6], m, mp);
  6296. sp_3072_mont_mul_106(t[13], t[ 7], t[ 6], m, mp);
  6297. sp_3072_mont_sqr_106(t[14], t[ 7], m, mp);
  6298. sp_3072_mont_mul_106(t[15], t[ 8], t[ 7], m, mp);
  6299. bits = ((bits + 3) / 4) * 4;
  6300. i = ((bits + 28) / 29) - 1;
  6301. c = bits % 29;
  6302. if (c == 0) {
  6303. c = 29;
  6304. }
  6305. if (i < 106) {
  6306. n = e[i--] << (32 - c);
  6307. }
  6308. else {
  6309. n = 0;
  6310. i--;
  6311. }
  6312. if (c < 4) {
  6313. n |= e[i--] << (3 - c);
  6314. c += 29;
  6315. }
  6316. y = (int)((n >> 28) & 0xf);
  6317. n <<= 4;
  6318. c -= 4;
  6319. XMEMCPY(rt, t[y], sizeof(sp_digit) * 212);
  6320. while ((i >= 0) || (c >= 4)) {
  6321. if (c >= 4) {
  6322. y = (byte)((n >> 28) & 0xf);
  6323. n <<= 4;
  6324. c -= 4;
  6325. }
  6326. else if (c == 0) {
  6327. n = e[i--] << 3;
  6328. y = (byte)((n >> 28) & 0xf);
  6329. n <<= 4;
  6330. c = 25;
  6331. }
  6332. else {
  6333. y = (byte)((n >> 28) & 0xf);
  6334. n = e[i--] << 3;
  6335. c = 4 - c;
  6336. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  6337. n <<= c;
  6338. c = 29 - c;
  6339. }
  6340. sp_3072_mont_sqr_106(rt, rt, m, mp);
  6341. sp_3072_mont_sqr_106(rt, rt, m, mp);
  6342. sp_3072_mont_sqr_106(rt, rt, m, mp);
  6343. sp_3072_mont_sqr_106(rt, rt, m, mp);
  6344. sp_3072_mont_mul_106(rt, rt, t[y], m, mp);
  6345. }
  6346. sp_3072_mont_reduce_106(rt, m, mp);
  6347. n = sp_3072_cmp_106(rt, m);
  6348. sp_3072_cond_sub_106(rt, rt, m, ~(n >> 31));
  6349. XMEMCPY(r, rt, sizeof(sp_digit) * 212);
  6350. }
  6351. #ifdef WOLFSSL_SP_SMALL_STACK
  6352. if (td != NULL)
  6353. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  6354. #endif
  6355. return err;
  6356. #endif
  6357. }
  6358. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  6359. #ifdef WOLFSSL_HAVE_SP_RSA
  6360. /* RSA public key operation.
  6361. *
  6362. * in Array of bytes representing the number to exponentiate, base.
  6363. * inLen Number of bytes in base.
  6364. * em Public exponent.
  6365. * mm Modulus.
  6366. * out Buffer to hold big-endian bytes of exponentiation result.
  6367. * Must be at least 384 bytes long.
  6368. * outLen Number of bytes in result.
  6369. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  6370. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  6371. */
  6372. int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
  6373. const mp_int* mm, byte* out, word32* outLen)
  6374. {
  6375. #ifdef WOLFSSL_SP_SMALL
  6376. #ifdef WOLFSSL_SP_SMALL_STACK
  6377. sp_digit* a = NULL;
  6378. #else
  6379. sp_digit a[106 * 5];
  6380. #endif
  6381. sp_digit* m = NULL;
  6382. sp_digit* r = NULL;
  6383. sp_digit* norm = NULL;
  6384. sp_uint64 e[1] = {0};
  6385. sp_digit mp = 0;
  6386. int i;
  6387. int err = MP_OKAY;
  6388. if (*outLen < 384U) {
  6389. err = MP_TO_E;
  6390. }
  6391. if (err == MP_OKAY) {
  6392. if (mp_count_bits(em) > 64) {
  6393. err = MP_READ_E;
  6394. }
  6395. else if (inLen > 384U) {
  6396. err = MP_READ_E;
  6397. }
  6398. else if (mp_count_bits(mm) != 3072) {
  6399. err = MP_READ_E;
  6400. }
  6401. else if (mp_iseven(mm)) {
  6402. err = MP_VAL;
  6403. }
  6404. }
  6405. #ifdef WOLFSSL_SP_SMALL_STACK
  6406. if (err == MP_OKAY) {
  6407. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 5, NULL,
  6408. DYNAMIC_TYPE_RSA);
  6409. if (a == NULL)
  6410. err = MEMORY_E;
  6411. }
  6412. #endif
  6413. if (err == MP_OKAY) {
  6414. r = a + 106 * 2;
  6415. m = r + 106 * 2;
  6416. norm = r;
  6417. sp_3072_from_bin(a, 106, in, inLen);
  6418. #if DIGIT_BIT >= 64
  6419. e[0] = (sp_uint64)em->dp[0];
  6420. #else
  6421. e[0] = (sp_uint64)em->dp[0];
  6422. if (em->used > 1) {
  6423. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  6424. }
  6425. #endif
  6426. if (e[0] == 0) {
  6427. err = MP_EXPTMOD_E;
  6428. }
  6429. }
  6430. if (err == MP_OKAY) {
  6431. sp_3072_from_mp(m, 106, mm);
  6432. sp_3072_mont_setup(m, &mp);
  6433. sp_3072_mont_norm_106(norm, m);
  6434. }
  6435. if (err == MP_OKAY) {
  6436. sp_3072_mul_106(a, a, norm);
  6437. err = sp_3072_mod_106(a, a, m);
  6438. }
  6439. if (err == MP_OKAY) {
  6440. for (i=63; i>=0; i--) {
  6441. if ((e[0] >> i) != 0) {
  6442. break;
  6443. }
  6444. }
  6445. XMEMCPY(r, a, sizeof(sp_digit) * 106 * 2);
  6446. for (i--; i>=0; i--) {
  6447. sp_3072_mont_sqr_106(r, r, m, mp);
  6448. if (((e[0] >> i) & 1) == 1) {
  6449. sp_3072_mont_mul_106(r, r, a, m, mp);
  6450. }
  6451. }
  6452. sp_3072_mont_reduce_106(r, m, mp);
  6453. mp = sp_3072_cmp_106(r, m);
  6454. sp_3072_cond_sub_106(r, r, m, ~(mp >> 31));
  6455. sp_3072_to_bin_106(r, out);
  6456. *outLen = 384;
  6457. }
  6458. #ifdef WOLFSSL_SP_SMALL_STACK
  6459. if (a != NULL)
  6460. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  6461. #endif
  6462. return err;
  6463. #else
  6464. #ifdef WOLFSSL_SP_SMALL_STACK
  6465. sp_digit* d = NULL;
  6466. #else
  6467. sp_digit d[106 * 5];
  6468. #endif
  6469. sp_digit* a = NULL;
  6470. sp_digit* m = NULL;
  6471. sp_digit* r = NULL;
  6472. sp_uint64 e[1] = {0};
  6473. int err = MP_OKAY;
  6474. if (*outLen < 384U) {
  6475. err = MP_TO_E;
  6476. }
  6477. if (err == MP_OKAY) {
  6478. if (mp_count_bits(em) > 64) {
  6479. err = MP_READ_E;
  6480. }
  6481. else if (inLen > 384U) {
  6482. err = MP_READ_E;
  6483. }
  6484. else if (mp_count_bits(mm) != 3072) {
  6485. err = MP_READ_E;
  6486. }
  6487. else if (mp_iseven(mm)) {
  6488. err = MP_VAL;
  6489. }
  6490. }
  6491. #ifdef WOLFSSL_SP_SMALL_STACK
  6492. if (err == MP_OKAY) {
  6493. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 5, NULL,
  6494. DYNAMIC_TYPE_RSA);
  6495. if (d == NULL)
  6496. err = MEMORY_E;
  6497. }
  6498. #endif
  6499. if (err == MP_OKAY) {
  6500. a = d;
  6501. r = a + 106 * 2;
  6502. m = r + 106 * 2;
  6503. sp_3072_from_bin(a, 106, in, inLen);
  6504. #if DIGIT_BIT >= 64
  6505. e[0] = (sp_uint64)em->dp[0];
  6506. #else
  6507. e[0] = (sp_uint64)em->dp[0];
  6508. if (em->used > 1) {
  6509. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  6510. }
  6511. #endif
  6512. if (e[0] == 0) {
  6513. err = MP_EXPTMOD_E;
  6514. }
  6515. }
  6516. if (err == MP_OKAY) {
  6517. sp_3072_from_mp(m, 106, mm);
  6518. if (e[0] == 0x3) {
  6519. sp_3072_sqr_106(r, a);
  6520. err = sp_3072_mod_106(r, r, m);
  6521. if (err == MP_OKAY) {
  6522. sp_3072_mul_106(r, a, r);
  6523. err = sp_3072_mod_106(r, r, m);
  6524. }
  6525. }
  6526. else {
  6527. sp_digit* norm = r;
  6528. int i;
  6529. sp_digit mp;
  6530. sp_3072_mont_setup(m, &mp);
  6531. sp_3072_mont_norm_106(norm, m);
  6532. sp_3072_mul_106(a, a, norm);
  6533. err = sp_3072_mod_106(a, a, m);
  6534. if (err == MP_OKAY) {
  6535. for (i=63; i>=0; i--) {
  6536. if ((e[0] >> i) != 0) {
  6537. break;
  6538. }
  6539. }
  6540. XMEMCPY(r, a, sizeof(sp_digit) * 212U);
  6541. for (i--; i>=0; i--) {
  6542. sp_3072_mont_sqr_106(r, r, m, mp);
  6543. if (((e[0] >> i) & 1) == 1) {
  6544. sp_3072_mont_mul_106(r, r, a, m, mp);
  6545. }
  6546. }
  6547. sp_3072_mont_reduce_106(r, m, mp);
  6548. mp = sp_3072_cmp_106(r, m);
  6549. sp_3072_cond_sub_106(r, r, m, ~(mp >> 31));
  6550. }
  6551. }
  6552. }
  6553. if (err == MP_OKAY) {
  6554. sp_3072_to_bin_106(r, out);
  6555. *outLen = 384;
  6556. }
  6557. #ifdef WOLFSSL_SP_SMALL_STACK
  6558. if (d != NULL)
  6559. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  6560. #endif
  6561. return err;
  6562. #endif /* WOLFSSL_SP_SMALL */
  6563. }
  6564. #ifndef WOLFSSL_RSA_PUBLIC_ONLY
  6565. #if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
  6566. #endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
  6567. /* RSA private key operation.
  6568. *
  6569. * in Array of bytes representing the number to exponentiate, base.
  6570. * inLen Number of bytes in base.
  6571. * dm Private exponent.
  6572. * pm First prime.
  6573. * qm Second prime.
  6574. * dpm First prime's CRT exponent.
  6575. * dqm Second prime's CRT exponent.
  6576. * qim Inverse of second prime mod p.
  6577. * mm Modulus.
  6578. * out Buffer to hold big-endian bytes of exponentiation result.
  6579. * Must be at least 384 bytes long.
  6580. * outLen Number of bytes in result.
  6581. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  6582. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  6583. */
  6584. int sp_RsaPrivate_3072(const byte* in, word32 inLen, const mp_int* dm,
  6585. const mp_int* pm, const mp_int* qm, const mp_int* dpm, const mp_int* dqm,
  6586. const mp_int* qim, const mp_int* mm, byte* out, word32* outLen)
  6587. {
  6588. #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
  6589. #if defined(WOLFSSL_SP_SMALL)
  6590. #ifdef WOLFSSL_SP_SMALL_STACK
  6591. sp_digit* d = NULL;
  6592. #else
  6593. sp_digit d[106 * 4];
  6594. #endif
  6595. sp_digit* a = NULL;
  6596. sp_digit* m = NULL;
  6597. sp_digit* r = NULL;
  6598. int err = MP_OKAY;
  6599. (void)pm;
  6600. (void)qm;
  6601. (void)dpm;
  6602. (void)dqm;
  6603. (void)qim;
  6604. if (*outLen < 384U) {
  6605. err = MP_TO_E;
  6606. }
  6607. if (err == MP_OKAY) {
  6608. if (mp_count_bits(dm) > 3072) {
  6609. err = MP_READ_E;
  6610. }
  6611. else if (inLen > 384) {
  6612. err = MP_READ_E;
  6613. }
  6614. else if (mp_count_bits(mm) != 3072) {
  6615. err = MP_READ_E;
  6616. }
  6617. else if (mp_iseven(mm)) {
  6618. err = MP_VAL;
  6619. }
  6620. }
  6621. #ifdef WOLFSSL_SP_SMALL_STACK
  6622. if (err == MP_OKAY) {
  6623. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 4, NULL,
  6624. DYNAMIC_TYPE_RSA);
  6625. if (d == NULL)
  6626. err = MEMORY_E;
  6627. }
  6628. #endif
  6629. if (err == MP_OKAY) {
  6630. a = d + 106;
  6631. m = a + 212;
  6632. r = a;
  6633. sp_3072_from_bin(a, 106, in, inLen);
  6634. sp_3072_from_mp(d, 106, dm);
  6635. sp_3072_from_mp(m, 106, mm);
  6636. err = sp_3072_mod_exp_106(r, a, d, 3072, m, 0);
  6637. }
  6638. if (err == MP_OKAY) {
  6639. sp_3072_to_bin_106(r, out);
  6640. *outLen = 384;
  6641. }
  6642. #ifdef WOLFSSL_SP_SMALL_STACK
  6643. if (d != NULL)
  6644. #endif
  6645. {
  6646. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  6647. if (a != NULL)
  6648. ForceZero(a, sizeof(sp_digit) * 106);
  6649. #ifdef WOLFSSL_SP_SMALL_STACK
  6650. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  6651. #endif
  6652. }
  6653. return err;
  6654. #else
  6655. #ifdef WOLFSSL_SP_SMALL_STACK
  6656. sp_digit* d = NULL;
  6657. #else
  6658. sp_digit d[106 * 4];
  6659. #endif
  6660. sp_digit* a = NULL;
  6661. sp_digit* m = NULL;
  6662. sp_digit* r = NULL;
  6663. int err = MP_OKAY;
  6664. (void)pm;
  6665. (void)qm;
  6666. (void)dpm;
  6667. (void)dqm;
  6668. (void)qim;
  6669. if (*outLen < 384U) {
  6670. err = MP_TO_E;
  6671. }
  6672. if (err == MP_OKAY) {
  6673. if (mp_count_bits(dm) > 3072) {
  6674. err = MP_READ_E;
  6675. }
  6676. else if (inLen > 384U) {
  6677. err = MP_READ_E;
  6678. }
  6679. else if (mp_count_bits(mm) != 3072) {
  6680. err = MP_READ_E;
  6681. }
  6682. else if (mp_iseven(mm)) {
  6683. err = MP_VAL;
  6684. }
  6685. }
  6686. #ifdef WOLFSSL_SP_SMALL_STACK
  6687. if (err == MP_OKAY) {
  6688. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 4, NULL,
  6689. DYNAMIC_TYPE_RSA);
  6690. if (d == NULL)
  6691. err = MEMORY_E;
  6692. }
  6693. #endif
  6694. if (err == MP_OKAY) {
  6695. a = d + 106;
  6696. m = a + 212;
  6697. r = a;
  6698. sp_3072_from_bin(a, 106, in, inLen);
  6699. sp_3072_from_mp(d, 106, dm);
  6700. sp_3072_from_mp(m, 106, mm);
  6701. err = sp_3072_mod_exp_106(r, a, d, 3072, m, 0);
  6702. }
  6703. if (err == MP_OKAY) {
  6704. sp_3072_to_bin_106(r, out);
  6705. *outLen = 384;
  6706. }
  6707. #ifdef WOLFSSL_SP_SMALL_STACK
  6708. if (d != NULL)
  6709. #endif
  6710. {
  6711. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  6712. if (a != NULL)
  6713. ForceZero(a, sizeof(sp_digit) * 106);
  6714. #ifdef WOLFSSL_SP_SMALL_STACK
  6715. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  6716. #endif
  6717. }
  6718. return err;
  6719. #endif /* WOLFSSL_SP_SMALL */
  6720. #else
  6721. #if defined(WOLFSSL_SP_SMALL)
  6722. #ifdef WOLFSSL_SP_SMALL_STACK
  6723. sp_digit* a = NULL;
  6724. #else
  6725. sp_digit a[53 * 8];
  6726. #endif
  6727. sp_digit* p = NULL;
  6728. sp_digit* dp = NULL;
  6729. sp_digit* dq = NULL;
  6730. sp_digit* qi = NULL;
  6731. sp_digit* tmpa = NULL;
  6732. sp_digit* tmpb = NULL;
  6733. sp_digit* r = NULL;
  6734. int err = MP_OKAY;
  6735. (void)dm;
  6736. (void)mm;
  6737. if (*outLen < 384U) {
  6738. err = MP_TO_E;
  6739. }
  6740. if (err == MP_OKAY) {
  6741. if (inLen > 384) {
  6742. err = MP_READ_E;
  6743. }
  6744. else if (mp_count_bits(mm) != 3072) {
  6745. err = MP_READ_E;
  6746. }
  6747. else if (mp_iseven(mm)) {
  6748. err = MP_VAL;
  6749. }
  6750. else if (mp_iseven(pm)) {
  6751. err = MP_VAL;
  6752. }
  6753. else if (mp_iseven(qm)) {
  6754. err = MP_VAL;
  6755. }
  6756. }
  6757. #ifdef WOLFSSL_SP_SMALL_STACK
  6758. if (err == MP_OKAY) {
  6759. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 53 * 8, NULL,
  6760. DYNAMIC_TYPE_RSA);
  6761. if (a == NULL)
  6762. err = MEMORY_E;
  6763. }
  6764. #endif
  6765. if (err == MP_OKAY) {
  6766. p = a + 106;
  6767. qi = dq = dp = p + 53;
  6768. tmpa = qi + 53;
  6769. tmpb = tmpa + 106;
  6770. r = a;
  6771. sp_3072_from_bin(a, 106, in, inLen);
  6772. sp_3072_from_mp(p, 53, pm);
  6773. sp_3072_from_mp(dp, 53, dpm);
  6774. err = sp_3072_mod_exp_53(tmpa, a, dp, 1536, p, 1);
  6775. }
  6776. if (err == MP_OKAY) {
  6777. sp_3072_from_mp(p, 53, qm);
  6778. sp_3072_from_mp(dq, 53, dqm);
  6779. err = sp_3072_mod_exp_53(tmpb, a, dq, 1536, p, 1);
  6780. }
  6781. if (err == MP_OKAY) {
  6782. sp_3072_from_mp(p, 53, pm);
  6783. (void)sp_3072_sub_53(tmpa, tmpa, tmpb);
  6784. sp_3072_norm_53(tmpa);
  6785. sp_3072_cond_add_53(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[52] >> 31));
  6786. sp_3072_cond_add_53(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[52] >> 31));
  6787. sp_3072_norm_53(tmpa);
  6788. sp_3072_from_mp(qi, 53, qim);
  6789. sp_3072_mul_53(tmpa, tmpa, qi);
  6790. err = sp_3072_mod_53(tmpa, tmpa, p);
  6791. }
  6792. if (err == MP_OKAY) {
  6793. sp_3072_from_mp(p, 53, qm);
  6794. sp_3072_mul_53(tmpa, p, tmpa);
  6795. (void)sp_3072_add_106(r, tmpb, tmpa);
  6796. sp_3072_norm_106(r);
  6797. sp_3072_to_bin_106(r, out);
  6798. *outLen = 384;
  6799. }
  6800. #ifdef WOLFSSL_SP_SMALL_STACK
  6801. if (a != NULL)
  6802. #endif
  6803. {
  6804. ForceZero(a, sizeof(sp_digit) * 53 * 8);
  6805. #ifdef WOLFSSL_SP_SMALL_STACK
  6806. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  6807. #endif
  6808. }
  6809. return err;
  6810. #else
  6811. #ifdef WOLFSSL_SP_SMALL_STACK
  6812. sp_digit* a = NULL;
  6813. #else
  6814. sp_digit a[53 * 13];
  6815. #endif
  6816. sp_digit* p = NULL;
  6817. sp_digit* q = NULL;
  6818. sp_digit* dp = NULL;
  6819. sp_digit* dq = NULL;
  6820. sp_digit* qi = NULL;
  6821. sp_digit* tmpa = NULL;
  6822. sp_digit* tmpb = NULL;
  6823. sp_digit* r = NULL;
  6824. int err = MP_OKAY;
  6825. (void)dm;
  6826. (void)mm;
  6827. if (*outLen < 384U) {
  6828. err = MP_TO_E;
  6829. }
  6830. if (err == MP_OKAY) {
  6831. if (inLen > 384U) {
  6832. err = MP_READ_E;
  6833. }
  6834. else if (mp_count_bits(mm) != 3072) {
  6835. err = MP_READ_E;
  6836. }
  6837. else if (mp_iseven(mm)) {
  6838. err = MP_VAL;
  6839. }
  6840. else if (mp_iseven(pm)) {
  6841. err = MP_VAL;
  6842. }
  6843. else if (mp_iseven(qm)) {
  6844. err = MP_VAL;
  6845. }
  6846. }
  6847. #ifdef WOLFSSL_SP_SMALL_STACK
  6848. if (err == MP_OKAY) {
  6849. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 53 * 13, NULL,
  6850. DYNAMIC_TYPE_RSA);
  6851. if (a == NULL)
  6852. err = MEMORY_E;
  6853. }
  6854. #endif
  6855. if (err == MP_OKAY) {
  6856. p = a + 106 * 2;
  6857. q = p + 53;
  6858. dp = q + 53;
  6859. dq = dp + 53;
  6860. qi = dq + 53;
  6861. tmpa = qi + 53;
  6862. tmpb = tmpa + 106;
  6863. r = a;
  6864. sp_3072_from_bin(a, 106, in, inLen);
  6865. sp_3072_from_mp(p, 53, pm);
  6866. sp_3072_from_mp(q, 53, qm);
  6867. sp_3072_from_mp(dp, 53, dpm);
  6868. sp_3072_from_mp(dq, 53, dqm);
  6869. sp_3072_from_mp(qi, 53, qim);
  6870. err = sp_3072_mod_exp_53(tmpa, a, dp, 1536, p, 1);
  6871. }
  6872. if (err == MP_OKAY) {
  6873. err = sp_3072_mod_exp_53(tmpb, a, dq, 1536, q, 1);
  6874. }
  6875. if (err == MP_OKAY) {
  6876. (void)sp_3072_sub_53(tmpa, tmpa, tmpb);
  6877. sp_3072_norm_53(tmpa);
  6878. sp_3072_cond_add_53(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[52] >> 31));
  6879. sp_3072_cond_add_53(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[52] >> 31));
  6880. sp_3072_norm_53(tmpa);
  6881. sp_3072_mul_53(tmpa, tmpa, qi);
  6882. err = sp_3072_mod_53(tmpa, tmpa, p);
  6883. }
  6884. if (err == MP_OKAY) {
  6885. sp_3072_mul_53(tmpa, tmpa, q);
  6886. (void)sp_3072_add_106(r, tmpb, tmpa);
  6887. sp_3072_norm_106(r);
  6888. sp_3072_to_bin_106(r, out);
  6889. *outLen = 384;
  6890. }
  6891. #ifdef WOLFSSL_SP_SMALL_STACK
  6892. if (a != NULL)
  6893. #endif
  6894. {
  6895. ForceZero(a, sizeof(sp_digit) * 53 * 13);
  6896. #ifdef WOLFSSL_SP_SMALL_STACK
  6897. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  6898. #endif
  6899. }
  6900. return err;
  6901. #endif /* WOLFSSL_SP_SMALL */
  6902. #endif /* SP_RSA_PRIVATE_EXP_D || RSA_LOW_MEM */
  6903. }
  6904. #endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
  6905. #endif /* WOLFSSL_HAVE_SP_RSA */
  6906. #if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
  6907. !defined(WOLFSSL_RSA_PUBLIC_ONLY))
  6908. /* Convert an array of sp_digit to an mp_int.
  6909. *
  6910. * a A single precision integer.
  6911. * r A multi-precision integer.
  6912. */
  6913. static int sp_3072_to_mp(const sp_digit* a, mp_int* r)
  6914. {
  6915. int err;
  6916. err = mp_grow(r, (3072 + DIGIT_BIT - 1) / DIGIT_BIT);
  6917. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  6918. #if DIGIT_BIT == 29
  6919. XMEMCPY(r->dp, a, sizeof(sp_digit) * 106);
  6920. r->used = 106;
  6921. mp_clamp(r);
  6922. #elif DIGIT_BIT < 29
  6923. int i;
  6924. int j = 0;
  6925. int s = 0;
  6926. r->dp[0] = 0;
  6927. for (i = 0; i < 106; i++) {
  6928. r->dp[j] |= (mp_digit)(a[i] << s);
  6929. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  6930. s = DIGIT_BIT - s;
  6931. r->dp[++j] = (mp_digit)(a[i] >> s);
  6932. while (s + DIGIT_BIT <= 29) {
  6933. s += DIGIT_BIT;
  6934. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  6935. if (s == SP_WORD_SIZE) {
  6936. r->dp[j] = 0;
  6937. }
  6938. else {
  6939. r->dp[j] = (mp_digit)(a[i] >> s);
  6940. }
  6941. }
  6942. s = 29 - s;
  6943. }
  6944. r->used = (3072 + DIGIT_BIT - 1) / DIGIT_BIT;
  6945. mp_clamp(r);
  6946. #else
  6947. int i;
  6948. int j = 0;
  6949. int s = 0;
  6950. r->dp[0] = 0;
  6951. for (i = 0; i < 106; i++) {
  6952. r->dp[j] |= ((mp_digit)a[i]) << s;
  6953. if (s + 29 >= DIGIT_BIT) {
  6954. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  6955. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  6956. #endif
  6957. s = DIGIT_BIT - s;
  6958. r->dp[++j] = a[i] >> s;
  6959. s = 29 - s;
  6960. }
  6961. else {
  6962. s += 29;
  6963. }
  6964. }
  6965. r->used = (3072 + DIGIT_BIT - 1) / DIGIT_BIT;
  6966. mp_clamp(r);
  6967. #endif
  6968. }
  6969. return err;
  6970. }
  6971. /* Perform the modular exponentiation for Diffie-Hellman.
  6972. *
  6973. * base Base. MP integer.
  6974. * exp Exponent. MP integer.
  6975. * mod Modulus. MP integer.
  6976. * res Result. MP integer.
  6977. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  6978. * and MEMORY_E if memory allocation fails.
  6979. */
  6980. int sp_ModExp_3072(const mp_int* base, const mp_int* exp, const mp_int* mod,
  6981. mp_int* res)
  6982. {
  6983. #ifdef WOLFSSL_SP_SMALL
  6984. int err = MP_OKAY;
  6985. #ifdef WOLFSSL_SP_SMALL_STACK
  6986. sp_digit* b = NULL;
  6987. #else
  6988. sp_digit b[106 * 4];
  6989. #endif
  6990. sp_digit* e = NULL;
  6991. sp_digit* m = NULL;
  6992. sp_digit* r = NULL;
  6993. int expBits = mp_count_bits(exp);
  6994. if (mp_count_bits(base) > 3072) {
  6995. err = MP_READ_E;
  6996. }
  6997. else if (expBits > 3072) {
  6998. err = MP_READ_E;
  6999. }
  7000. else if (mp_count_bits(mod) != 3072) {
  7001. err = MP_READ_E;
  7002. }
  7003. else if (mp_iseven(mod)) {
  7004. err = MP_VAL;
  7005. }
  7006. #ifdef WOLFSSL_SP_SMALL_STACK
  7007. if (err == MP_OKAY) {
  7008. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 4, NULL,
  7009. DYNAMIC_TYPE_DH);
  7010. if (b == NULL)
  7011. err = MEMORY_E;
  7012. }
  7013. #endif
  7014. if (err == MP_OKAY) {
  7015. e = b + 106 * 2;
  7016. m = e + 106;
  7017. r = b;
  7018. sp_3072_from_mp(b, 106, base);
  7019. sp_3072_from_mp(e, 106, exp);
  7020. sp_3072_from_mp(m, 106, mod);
  7021. err = sp_3072_mod_exp_106(r, b, e, mp_count_bits(exp), m, 0);
  7022. }
  7023. if (err == MP_OKAY) {
  7024. err = sp_3072_to_mp(r, res);
  7025. }
  7026. #ifdef WOLFSSL_SP_SMALL_STACK
  7027. if (b != NULL)
  7028. #endif
  7029. {
  7030. /* only "e" is sensitive and needs zeroized */
  7031. if (e != NULL)
  7032. ForceZero(e, sizeof(sp_digit) * 106U);
  7033. #ifdef WOLFSSL_SP_SMALL_STACK
  7034. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  7035. #endif
  7036. }
  7037. return err;
  7038. #else
  7039. #ifdef WOLFSSL_SP_SMALL_STACK
  7040. sp_digit* b = NULL;
  7041. #else
  7042. sp_digit b[106 * 4];
  7043. #endif
  7044. sp_digit* e = NULL;
  7045. sp_digit* m = NULL;
  7046. sp_digit* r = NULL;
  7047. int err = MP_OKAY;
  7048. int expBits = mp_count_bits(exp);
  7049. if (mp_count_bits(base) > 3072) {
  7050. err = MP_READ_E;
  7051. }
  7052. else if (expBits > 3072) {
  7053. err = MP_READ_E;
  7054. }
  7055. else if (mp_count_bits(mod) != 3072) {
  7056. err = MP_READ_E;
  7057. }
  7058. else if (mp_iseven(mod)) {
  7059. err = MP_VAL;
  7060. }
  7061. #ifdef WOLFSSL_SP_SMALL_STACK
  7062. if (err == MP_OKAY) {
  7063. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 4, NULL, DYNAMIC_TYPE_DH);
  7064. if (b == NULL)
  7065. err = MEMORY_E;
  7066. }
  7067. #endif
  7068. if (err == MP_OKAY) {
  7069. e = b + 106 * 2;
  7070. m = e + 106;
  7071. r = b;
  7072. sp_3072_from_mp(b, 106, base);
  7073. sp_3072_from_mp(e, 106, exp);
  7074. sp_3072_from_mp(m, 106, mod);
  7075. err = sp_3072_mod_exp_106(r, b, e, expBits, m, 0);
  7076. }
  7077. if (err == MP_OKAY) {
  7078. err = sp_3072_to_mp(r, res);
  7079. }
  7080. #ifdef WOLFSSL_SP_SMALL_STACK
  7081. if (b != NULL)
  7082. #endif
  7083. {
  7084. /* only "e" is sensitive and needs zeroized */
  7085. if (e != NULL)
  7086. ForceZero(e, sizeof(sp_digit) * 106U);
  7087. #ifdef WOLFSSL_SP_SMALL_STACK
  7088. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  7089. #endif
  7090. }
  7091. return err;
  7092. #endif
  7093. }
  7094. #ifdef WOLFSSL_HAVE_SP_DH
  7095. #ifdef HAVE_FFDHE_3072
  7096. SP_NOINLINE static void sp_3072_lshift_106(sp_digit* r, const sp_digit* a,
  7097. byte n)
  7098. {
  7099. int i;
  7100. r[106] = a[105] >> (29 - n);
  7101. for (i=105; i>0; i--) {
  7102. r[i] = ((a[i] << n) | (a[i-1] >> (29 - n))) & 0x1fffffff;
  7103. }
  7104. r[0] = (a[0] << n) & 0x1fffffff;
  7105. }
  7106. /* Modular exponentiate 2 to the e mod m. (r = 2^e mod m)
  7107. *
  7108. * r A single precision number that is the result of the operation.
  7109. * e A single precision number that is the exponent.
  7110. * bits The number of bits in the exponent.
  7111. * m A single precision number that is the modulus.
  7112. * returns 0 on success.
  7113. * returns MEMORY_E on dynamic memory allocation failure.
  7114. * returns MP_VAL when base is even.
  7115. */
  7116. static int sp_3072_mod_exp_2_106(sp_digit* r, const sp_digit* e, int bits, const sp_digit* m)
  7117. {
  7118. #ifdef WOLFSSL_SP_SMALL_STACK
  7119. sp_digit* td = NULL;
  7120. #else
  7121. sp_digit td[319];
  7122. #endif
  7123. sp_digit* norm = NULL;
  7124. sp_digit* tmp = NULL;
  7125. sp_digit mp = 1;
  7126. sp_digit n;
  7127. sp_digit o;
  7128. int i;
  7129. int c;
  7130. byte y;
  7131. int err = MP_OKAY;
  7132. if (bits == 0) {
  7133. err = MP_VAL;
  7134. }
  7135. #ifdef WOLFSSL_SP_SMALL_STACK
  7136. if (err == MP_OKAY) {
  7137. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 319, NULL,
  7138. DYNAMIC_TYPE_TMP_BUFFER);
  7139. if (td == NULL)
  7140. err = MEMORY_E;
  7141. }
  7142. #endif
  7143. if (err == MP_OKAY) {
  7144. norm = td;
  7145. tmp = td + 212;
  7146. XMEMSET(td, 0, sizeof(sp_digit) * 319);
  7147. sp_3072_mont_setup(m, &mp);
  7148. sp_3072_mont_norm_106(norm, m);
  7149. bits = ((bits + 3) / 4) * 4;
  7150. i = ((bits + 28) / 29) - 1;
  7151. c = bits % 29;
  7152. if (c == 0) {
  7153. c = 29;
  7154. }
  7155. if (i < 106) {
  7156. n = e[i--] << (32 - c);
  7157. }
  7158. else {
  7159. n = 0;
  7160. i--;
  7161. }
  7162. if (c < 4) {
  7163. n |= e[i--] << (3 - c);
  7164. c += 29;
  7165. }
  7166. y = (int)((n >> 28) & 0xf);
  7167. n <<= 4;
  7168. c -= 4;
  7169. sp_3072_lshift_106(r, norm, (byte)y);
  7170. while ((i >= 0) || (c >= 4)) {
  7171. if (c >= 4) {
  7172. y = (byte)((n >> 28) & 0xf);
  7173. n <<= 4;
  7174. c -= 4;
  7175. }
  7176. else if (c == 0) {
  7177. n = e[i--] << 3;
  7178. y = (byte)((n >> 28) & 0xf);
  7179. n <<= 4;
  7180. c = 25;
  7181. }
  7182. else {
  7183. y = (byte)((n >> 28) & 0xf);
  7184. n = e[i--] << 3;
  7185. c = 4 - c;
  7186. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  7187. n <<= c;
  7188. c = 29 - c;
  7189. }
  7190. sp_3072_mont_sqr_106(r, r, m, mp);
  7191. sp_3072_mont_sqr_106(r, r, m, mp);
  7192. sp_3072_mont_sqr_106(r, r, m, mp);
  7193. sp_3072_mont_sqr_106(r, r, m, mp);
  7194. sp_3072_lshift_106(r, r, (byte)y);
  7195. sp_3072_mul_d_106(tmp, norm, (r[106] << 2) + (r[105] >> 27));
  7196. r[106] = 0;
  7197. r[105] &= 0x7ffffffL;
  7198. (void)sp_3072_add_106(r, r, tmp);
  7199. sp_3072_norm_106(r);
  7200. o = sp_3072_cmp_106(r, m);
  7201. sp_3072_cond_sub_106(r, r, m, ~(o >> 31));
  7202. }
  7203. sp_3072_mont_reduce_106(r, m, mp);
  7204. n = sp_3072_cmp_106(r, m);
  7205. sp_3072_cond_sub_106(r, r, m, ~(n >> 31));
  7206. }
  7207. #ifdef WOLFSSL_SP_SMALL_STACK
  7208. if (td != NULL)
  7209. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  7210. #endif
  7211. return err;
  7212. }
  7213. #endif /* HAVE_FFDHE_3072 */
  7214. /* Perform the modular exponentiation for Diffie-Hellman.
  7215. *
  7216. * base Base.
  7217. * exp Array of bytes that is the exponent.
  7218. * expLen Length of data, in bytes, in exponent.
  7219. * mod Modulus.
  7220. * out Buffer to hold big-endian bytes of exponentiation result.
  7221. * Must be at least 384 bytes long.
  7222. * outLen Length, in bytes, of exponentiation result.
  7223. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  7224. * and MEMORY_E if memory allocation fails.
  7225. */
  7226. int sp_DhExp_3072(const mp_int* base, const byte* exp, word32 expLen,
  7227. const mp_int* mod, byte* out, word32* outLen)
  7228. {
  7229. #ifdef WOLFSSL_SP_SMALL_STACK
  7230. sp_digit* b = NULL;
  7231. #else
  7232. sp_digit b[106 * 4];
  7233. #endif
  7234. sp_digit* e = NULL;
  7235. sp_digit* m = NULL;
  7236. sp_digit* r = NULL;
  7237. word32 i;
  7238. int err = MP_OKAY;
  7239. if (mp_count_bits(base) > 3072) {
  7240. err = MP_READ_E;
  7241. }
  7242. else if (expLen > 384U) {
  7243. err = MP_READ_E;
  7244. }
  7245. else if (mp_count_bits(mod) != 3072) {
  7246. err = MP_READ_E;
  7247. }
  7248. else if (mp_iseven(mod)) {
  7249. err = MP_VAL;
  7250. }
  7251. #ifdef WOLFSSL_SP_SMALL_STACK
  7252. if (err == MP_OKAY) {
  7253. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 106 * 4, NULL,
  7254. DYNAMIC_TYPE_DH);
  7255. if (b == NULL)
  7256. err = MEMORY_E;
  7257. }
  7258. #endif
  7259. if (err == MP_OKAY) {
  7260. e = b + 106 * 2;
  7261. m = e + 106;
  7262. r = b;
  7263. sp_3072_from_mp(b, 106, base);
  7264. sp_3072_from_bin(e, 106, exp, expLen);
  7265. sp_3072_from_mp(m, 106, mod);
  7266. #ifdef HAVE_FFDHE_3072
  7267. if (base->used == 1 && base->dp[0] == 2U &&
  7268. (m[105] >> 11) == 0xffffL) {
  7269. err = sp_3072_mod_exp_2_106(r, e, expLen * 8U, m);
  7270. }
  7271. else {
  7272. #endif
  7273. err = sp_3072_mod_exp_106(r, b, e, expLen * 8U, m, 0);
  7274. #ifdef HAVE_FFDHE_3072
  7275. }
  7276. #endif
  7277. }
  7278. if (err == MP_OKAY) {
  7279. sp_3072_to_bin_106(r, out);
  7280. *outLen = 384;
  7281. for (i=0; i<384U && out[i] == 0U; i++) {
  7282. /* Search for first non-zero. */
  7283. }
  7284. *outLen -= i;
  7285. XMEMMOVE(out, out + i, *outLen);
  7286. }
  7287. #ifdef WOLFSSL_SP_SMALL_STACK
  7288. if (b != NULL)
  7289. #endif
  7290. {
  7291. /* only "e" is sensitive and needs zeroized */
  7292. if (e != NULL)
  7293. ForceZero(e, sizeof(sp_digit) * 106U);
  7294. #ifdef WOLFSSL_SP_SMALL_STACK
  7295. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  7296. #endif
  7297. }
  7298. return err;
  7299. }
  7300. #endif /* WOLFSSL_HAVE_SP_DH */
  7301. /* Perform the modular exponentiation for Diffie-Hellman.
  7302. *
  7303. * base Base. MP integer.
  7304. * exp Exponent. MP integer.
  7305. * mod Modulus. MP integer.
  7306. * res Result. MP integer.
  7307. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  7308. * and MEMORY_E if memory allocation fails.
  7309. */
  7310. int sp_ModExp_1536(const mp_int* base, const mp_int* exp, const mp_int* mod,
  7311. mp_int* res)
  7312. {
  7313. #ifdef WOLFSSL_SP_SMALL
  7314. int err = MP_OKAY;
  7315. #ifdef WOLFSSL_SP_SMALL_STACK
  7316. sp_digit* b = NULL;
  7317. #else
  7318. sp_digit b[53 * 4];
  7319. #endif
  7320. sp_digit* e = NULL;
  7321. sp_digit* m = NULL;
  7322. sp_digit* r = NULL;
  7323. int expBits = mp_count_bits(exp);
  7324. if (mp_count_bits(base) > 1536) {
  7325. err = MP_READ_E;
  7326. }
  7327. else if (expBits > 1536) {
  7328. err = MP_READ_E;
  7329. }
  7330. else if (mp_count_bits(mod) != 1536) {
  7331. err = MP_READ_E;
  7332. }
  7333. else if (mp_iseven(mod)) {
  7334. err = MP_VAL;
  7335. }
  7336. #ifdef WOLFSSL_SP_SMALL_STACK
  7337. if (err == MP_OKAY) {
  7338. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 53 * 4, NULL,
  7339. DYNAMIC_TYPE_DH);
  7340. if (b == NULL)
  7341. err = MEMORY_E;
  7342. }
  7343. #endif
  7344. if (err == MP_OKAY) {
  7345. e = b + 53 * 2;
  7346. m = e + 53;
  7347. r = b;
  7348. sp_3072_from_mp(b, 53, base);
  7349. sp_3072_from_mp(e, 53, exp);
  7350. sp_3072_from_mp(m, 53, mod);
  7351. err = sp_3072_mod_exp_53(r, b, e, mp_count_bits(exp), m, 0);
  7352. }
  7353. if (err == MP_OKAY) {
  7354. XMEMSET(r + 53, 0, sizeof(*r) * 53U);
  7355. err = sp_3072_to_mp(r, res);
  7356. }
  7357. #ifdef WOLFSSL_SP_SMALL_STACK
  7358. if (b != NULL)
  7359. #endif
  7360. {
  7361. /* only "e" is sensitive and needs zeroized */
  7362. if (e != NULL)
  7363. ForceZero(e, sizeof(sp_digit) * 106U);
  7364. #ifdef WOLFSSL_SP_SMALL_STACK
  7365. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  7366. #endif
  7367. }
  7368. return err;
  7369. #else
  7370. #ifdef WOLFSSL_SP_SMALL_STACK
  7371. sp_digit* b = NULL;
  7372. #else
  7373. sp_digit b[53 * 4];
  7374. #endif
  7375. sp_digit* e = NULL;
  7376. sp_digit* m = NULL;
  7377. sp_digit* r = NULL;
  7378. int err = MP_OKAY;
  7379. int expBits = mp_count_bits(exp);
  7380. if (mp_count_bits(base) > 1536) {
  7381. err = MP_READ_E;
  7382. }
  7383. else if (expBits > 1536) {
  7384. err = MP_READ_E;
  7385. }
  7386. else if (mp_count_bits(mod) != 1536) {
  7387. err = MP_READ_E;
  7388. }
  7389. else if (mp_iseven(mod)) {
  7390. err = MP_VAL;
  7391. }
  7392. #ifdef WOLFSSL_SP_SMALL_STACK
  7393. if (err == MP_OKAY) {
  7394. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 53 * 4, NULL, DYNAMIC_TYPE_DH);
  7395. if (b == NULL)
  7396. err = MEMORY_E;
  7397. }
  7398. #endif
  7399. if (err == MP_OKAY) {
  7400. e = b + 53 * 2;
  7401. m = e + 53;
  7402. r = b;
  7403. sp_3072_from_mp(b, 53, base);
  7404. sp_3072_from_mp(e, 53, exp);
  7405. sp_3072_from_mp(m, 53, mod);
  7406. err = sp_3072_mod_exp_53(r, b, e, expBits, m, 0);
  7407. }
  7408. if (err == MP_OKAY) {
  7409. XMEMSET(r + 53, 0, sizeof(*r) * 53U);
  7410. err = sp_3072_to_mp(r, res);
  7411. }
  7412. #ifdef WOLFSSL_SP_SMALL_STACK
  7413. if (b != NULL)
  7414. #endif
  7415. {
  7416. /* only "e" is sensitive and needs zeroized */
  7417. if (e != NULL)
  7418. ForceZero(e, sizeof(sp_digit) * 106U);
  7419. #ifdef WOLFSSL_SP_SMALL_STACK
  7420. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  7421. #endif
  7422. }
  7423. return err;
  7424. #endif
  7425. }
  7426. #endif /* WOLFSSL_HAVE_SP_DH | (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) */
  7427. #else
  7428. /* Read big endian unsigned byte array into r.
  7429. *
  7430. * r A single precision integer.
  7431. * size Maximum number of bytes to convert
  7432. * a Byte array.
  7433. * n Number of bytes in array to read.
  7434. */
  7435. static void sp_3072_from_bin(sp_digit* r, int size, const byte* a, int n)
  7436. {
  7437. int i;
  7438. int j = 0;
  7439. word32 s = 0;
  7440. r[0] = 0;
  7441. for (i = n-1; i >= 0; i--) {
  7442. r[j] |= (((sp_digit)a[i]) << s);
  7443. if (s >= 20U) {
  7444. r[j] &= 0xfffffff;
  7445. s = 28U - s;
  7446. if (j + 1 >= size) {
  7447. break;
  7448. }
  7449. r[++j] = (sp_digit)a[i] >> s;
  7450. s = 8U - s;
  7451. }
  7452. else {
  7453. s += 8U;
  7454. }
  7455. }
  7456. for (j++; j < size; j++) {
  7457. r[j] = 0;
  7458. }
  7459. }
  7460. /* Convert an mp_int to an array of sp_digit.
  7461. *
  7462. * r A single precision integer.
  7463. * size Maximum number of bytes to convert
  7464. * a A multi-precision integer.
  7465. */
  7466. static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
  7467. {
  7468. #if DIGIT_BIT == 28
  7469. int i;
  7470. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  7471. int o = 0;
  7472. for (i = 0; i < size; i++) {
  7473. sp_digit mask = (sp_digit)0 - (j >> 27);
  7474. r[i] = a->dp[o] & mask;
  7475. j++;
  7476. o += (int)(j >> 27);
  7477. }
  7478. #elif DIGIT_BIT > 28
  7479. unsigned int i;
  7480. int j = 0;
  7481. word32 s = 0;
  7482. r[0] = 0;
  7483. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  7484. r[j] |= ((sp_digit)a->dp[i] << s);
  7485. r[j] &= 0xfffffff;
  7486. s = 28U - s;
  7487. if (j + 1 >= size) {
  7488. break;
  7489. }
  7490. /* lint allow cast of mismatch word32 and mp_digit */
  7491. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  7492. while ((s + 28U) <= (word32)DIGIT_BIT) {
  7493. s += 28U;
  7494. r[j] &= 0xfffffff;
  7495. if (j + 1 >= size) {
  7496. break;
  7497. }
  7498. if (s < (word32)DIGIT_BIT) {
  7499. /* lint allow cast of mismatch word32 and mp_digit */
  7500. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  7501. }
  7502. else {
  7503. r[++j] = (sp_digit)0;
  7504. }
  7505. }
  7506. s = (word32)DIGIT_BIT - s;
  7507. }
  7508. for (j++; j < size; j++) {
  7509. r[j] = 0;
  7510. }
  7511. #else
  7512. unsigned int i;
  7513. int j = 0;
  7514. int s = 0;
  7515. r[0] = 0;
  7516. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  7517. r[j] |= ((sp_digit)a->dp[i]) << s;
  7518. if (s + DIGIT_BIT >= 28) {
  7519. r[j] &= 0xfffffff;
  7520. if (j + 1 >= size) {
  7521. break;
  7522. }
  7523. s = 28 - s;
  7524. if (s == DIGIT_BIT) {
  7525. r[++j] = 0;
  7526. s = 0;
  7527. }
  7528. else {
  7529. r[++j] = a->dp[i] >> s;
  7530. s = DIGIT_BIT - s;
  7531. }
  7532. }
  7533. else {
  7534. s += DIGIT_BIT;
  7535. }
  7536. }
  7537. for (j++; j < size; j++) {
  7538. r[j] = 0;
  7539. }
  7540. #endif
  7541. }
  7542. /* Write r as big endian to byte array.
  7543. * Fixed length number of bytes written: 384
  7544. *
  7545. * r A single precision integer.
  7546. * a Byte array.
  7547. */
  7548. static void sp_3072_to_bin_112(sp_digit* r, byte* a)
  7549. {
  7550. int i;
  7551. int j;
  7552. int s = 0;
  7553. int b;
  7554. for (i=0; i<111; i++) {
  7555. r[i+1] += r[i] >> 28;
  7556. r[i] &= 0xfffffff;
  7557. }
  7558. j = 3079 / 8 - 1;
  7559. a[j] = 0;
  7560. for (i=0; i<110 && j>=0; i++) {
  7561. b = 0;
  7562. /* lint allow cast of mismatch sp_digit and int */
  7563. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  7564. b += 8 - s;
  7565. if (j < 0) {
  7566. break;
  7567. }
  7568. while (b < 28) {
  7569. a[j--] = (byte)(r[i] >> b);
  7570. b += 8;
  7571. if (j < 0) {
  7572. break;
  7573. }
  7574. }
  7575. s = 8 - (b - 28);
  7576. if (j >= 0) {
  7577. a[j] = 0;
  7578. }
  7579. if (s != 0) {
  7580. j++;
  7581. }
  7582. }
  7583. }
  7584. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  7585. /* Normalize the values in each word to 28 bits.
  7586. *
  7587. * a Array of sp_digit to normalize.
  7588. */
  7589. static void sp_3072_norm_56(sp_digit* a)
  7590. {
  7591. int i;
  7592. for (i = 0; i < 48; i += 8) {
  7593. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  7594. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  7595. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  7596. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  7597. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  7598. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  7599. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  7600. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  7601. }
  7602. a[49] += a[48] >> 28; a[48] &= 0xfffffff;
  7603. a[50] += a[49] >> 28; a[49] &= 0xfffffff;
  7604. a[51] += a[50] >> 28; a[50] &= 0xfffffff;
  7605. a[52] += a[51] >> 28; a[51] &= 0xfffffff;
  7606. a[53] += a[52] >> 28; a[52] &= 0xfffffff;
  7607. a[54] += a[53] >> 28; a[53] &= 0xfffffff;
  7608. a[55] += a[54] >> 28; a[54] &= 0xfffffff;
  7609. }
  7610. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  7611. /* Normalize the values in each word to 28 bits.
  7612. *
  7613. * a Array of sp_digit to normalize.
  7614. */
  7615. static void sp_3072_norm_55(sp_digit* a)
  7616. {
  7617. int i;
  7618. for (i = 0; i < 48; i += 8) {
  7619. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  7620. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  7621. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  7622. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  7623. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  7624. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  7625. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  7626. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  7627. }
  7628. a[49] += a[48] >> 28; a[48] &= 0xfffffff;
  7629. a[50] += a[49] >> 28; a[49] &= 0xfffffff;
  7630. a[51] += a[50] >> 28; a[50] &= 0xfffffff;
  7631. a[52] += a[51] >> 28; a[51] &= 0xfffffff;
  7632. a[53] += a[52] >> 28; a[52] &= 0xfffffff;
  7633. a[54] += a[53] >> 28; a[53] &= 0xfffffff;
  7634. }
  7635. /* Normalize the values in each word to 28 bits.
  7636. *
  7637. * a Array of sp_digit to normalize.
  7638. */
  7639. static void sp_3072_norm_112(sp_digit* a)
  7640. {
  7641. int i;
  7642. for (i = 0; i < 104; i += 8) {
  7643. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  7644. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  7645. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  7646. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  7647. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  7648. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  7649. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  7650. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  7651. }
  7652. a[105] += a[104] >> 28; a[104] &= 0xfffffff;
  7653. a[106] += a[105] >> 28; a[105] &= 0xfffffff;
  7654. a[107] += a[106] >> 28; a[106] &= 0xfffffff;
  7655. a[108] += a[107] >> 28; a[107] &= 0xfffffff;
  7656. a[109] += a[108] >> 28; a[108] &= 0xfffffff;
  7657. a[110] += a[109] >> 28; a[109] &= 0xfffffff;
  7658. a[111] += a[110] >> 28; a[110] &= 0xfffffff;
  7659. }
  7660. /* Normalize the values in each word to 28 bits.
  7661. *
  7662. * a Array of sp_digit to normalize.
  7663. */
  7664. static void sp_3072_norm_110(sp_digit* a)
  7665. {
  7666. int i;
  7667. for (i = 0; i < 104; i += 8) {
  7668. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  7669. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  7670. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  7671. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  7672. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  7673. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  7674. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  7675. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  7676. }
  7677. a[105] += a[104] >> 28; a[104] &= 0xfffffff;
  7678. a[106] += a[105] >> 28; a[105] &= 0xfffffff;
  7679. a[107] += a[106] >> 28; a[106] &= 0xfffffff;
  7680. a[108] += a[107] >> 28; a[107] &= 0xfffffff;
  7681. a[109] += a[108] >> 28; a[108] &= 0xfffffff;
  7682. }
  7683. #ifndef WOLFSSL_SP_SMALL
  7684. /* Multiply a and b into r. (r = a * b)
  7685. *
  7686. * r A single precision integer.
  7687. * a A single precision integer.
  7688. * b A single precision integer.
  7689. */
  7690. SP_NOINLINE static void sp_3072_mul_14(sp_digit* r, const sp_digit* a,
  7691. const sp_digit* b)
  7692. {
  7693. sp_uint64 t0;
  7694. sp_uint64 t1;
  7695. sp_digit t[14];
  7696. t0 = ((sp_uint64)a[ 0]) * b[ 0];
  7697. t1 = ((sp_uint64)a[ 0]) * b[ 1]
  7698. + ((sp_uint64)a[ 1]) * b[ 0];
  7699. t[ 0] = t0 & 0xfffffff; t1 += t0 >> 28;
  7700. t0 = ((sp_uint64)a[ 0]) * b[ 2]
  7701. + ((sp_uint64)a[ 1]) * b[ 1]
  7702. + ((sp_uint64)a[ 2]) * b[ 0];
  7703. t[ 1] = t1 & 0xfffffff; t0 += t1 >> 28;
  7704. t1 = ((sp_uint64)a[ 0]) * b[ 3]
  7705. + ((sp_uint64)a[ 1]) * b[ 2]
  7706. + ((sp_uint64)a[ 2]) * b[ 1]
  7707. + ((sp_uint64)a[ 3]) * b[ 0];
  7708. t[ 2] = t0 & 0xfffffff; t1 += t0 >> 28;
  7709. t0 = ((sp_uint64)a[ 0]) * b[ 4]
  7710. + ((sp_uint64)a[ 1]) * b[ 3]
  7711. + ((sp_uint64)a[ 2]) * b[ 2]
  7712. + ((sp_uint64)a[ 3]) * b[ 1]
  7713. + ((sp_uint64)a[ 4]) * b[ 0];
  7714. t[ 3] = t1 & 0xfffffff; t0 += t1 >> 28;
  7715. t1 = ((sp_uint64)a[ 0]) * b[ 5]
  7716. + ((sp_uint64)a[ 1]) * b[ 4]
  7717. + ((sp_uint64)a[ 2]) * b[ 3]
  7718. + ((sp_uint64)a[ 3]) * b[ 2]
  7719. + ((sp_uint64)a[ 4]) * b[ 1]
  7720. + ((sp_uint64)a[ 5]) * b[ 0];
  7721. t[ 4] = t0 & 0xfffffff; t1 += t0 >> 28;
  7722. t0 = ((sp_uint64)a[ 0]) * b[ 6]
  7723. + ((sp_uint64)a[ 1]) * b[ 5]
  7724. + ((sp_uint64)a[ 2]) * b[ 4]
  7725. + ((sp_uint64)a[ 3]) * b[ 3]
  7726. + ((sp_uint64)a[ 4]) * b[ 2]
  7727. + ((sp_uint64)a[ 5]) * b[ 1]
  7728. + ((sp_uint64)a[ 6]) * b[ 0];
  7729. t[ 5] = t1 & 0xfffffff; t0 += t1 >> 28;
  7730. t1 = ((sp_uint64)a[ 0]) * b[ 7]
  7731. + ((sp_uint64)a[ 1]) * b[ 6]
  7732. + ((sp_uint64)a[ 2]) * b[ 5]
  7733. + ((sp_uint64)a[ 3]) * b[ 4]
  7734. + ((sp_uint64)a[ 4]) * b[ 3]
  7735. + ((sp_uint64)a[ 5]) * b[ 2]
  7736. + ((sp_uint64)a[ 6]) * b[ 1]
  7737. + ((sp_uint64)a[ 7]) * b[ 0];
  7738. t[ 6] = t0 & 0xfffffff; t1 += t0 >> 28;
  7739. t0 = ((sp_uint64)a[ 0]) * b[ 8]
  7740. + ((sp_uint64)a[ 1]) * b[ 7]
  7741. + ((sp_uint64)a[ 2]) * b[ 6]
  7742. + ((sp_uint64)a[ 3]) * b[ 5]
  7743. + ((sp_uint64)a[ 4]) * b[ 4]
  7744. + ((sp_uint64)a[ 5]) * b[ 3]
  7745. + ((sp_uint64)a[ 6]) * b[ 2]
  7746. + ((sp_uint64)a[ 7]) * b[ 1]
  7747. + ((sp_uint64)a[ 8]) * b[ 0];
  7748. t[ 7] = t1 & 0xfffffff; t0 += t1 >> 28;
  7749. t1 = ((sp_uint64)a[ 0]) * b[ 9]
  7750. + ((sp_uint64)a[ 1]) * b[ 8]
  7751. + ((sp_uint64)a[ 2]) * b[ 7]
  7752. + ((sp_uint64)a[ 3]) * b[ 6]
  7753. + ((sp_uint64)a[ 4]) * b[ 5]
  7754. + ((sp_uint64)a[ 5]) * b[ 4]
  7755. + ((sp_uint64)a[ 6]) * b[ 3]
  7756. + ((sp_uint64)a[ 7]) * b[ 2]
  7757. + ((sp_uint64)a[ 8]) * b[ 1]
  7758. + ((sp_uint64)a[ 9]) * b[ 0];
  7759. t[ 8] = t0 & 0xfffffff; t1 += t0 >> 28;
  7760. t0 = ((sp_uint64)a[ 0]) * b[10]
  7761. + ((sp_uint64)a[ 1]) * b[ 9]
  7762. + ((sp_uint64)a[ 2]) * b[ 8]
  7763. + ((sp_uint64)a[ 3]) * b[ 7]
  7764. + ((sp_uint64)a[ 4]) * b[ 6]
  7765. + ((sp_uint64)a[ 5]) * b[ 5]
  7766. + ((sp_uint64)a[ 6]) * b[ 4]
  7767. + ((sp_uint64)a[ 7]) * b[ 3]
  7768. + ((sp_uint64)a[ 8]) * b[ 2]
  7769. + ((sp_uint64)a[ 9]) * b[ 1]
  7770. + ((sp_uint64)a[10]) * b[ 0];
  7771. t[ 9] = t1 & 0xfffffff; t0 += t1 >> 28;
  7772. t1 = ((sp_uint64)a[ 0]) * b[11]
  7773. + ((sp_uint64)a[ 1]) * b[10]
  7774. + ((sp_uint64)a[ 2]) * b[ 9]
  7775. + ((sp_uint64)a[ 3]) * b[ 8]
  7776. + ((sp_uint64)a[ 4]) * b[ 7]
  7777. + ((sp_uint64)a[ 5]) * b[ 6]
  7778. + ((sp_uint64)a[ 6]) * b[ 5]
  7779. + ((sp_uint64)a[ 7]) * b[ 4]
  7780. + ((sp_uint64)a[ 8]) * b[ 3]
  7781. + ((sp_uint64)a[ 9]) * b[ 2]
  7782. + ((sp_uint64)a[10]) * b[ 1]
  7783. + ((sp_uint64)a[11]) * b[ 0];
  7784. t[10] = t0 & 0xfffffff; t1 += t0 >> 28;
  7785. t0 = ((sp_uint64)a[ 0]) * b[12]
  7786. + ((sp_uint64)a[ 1]) * b[11]
  7787. + ((sp_uint64)a[ 2]) * b[10]
  7788. + ((sp_uint64)a[ 3]) * b[ 9]
  7789. + ((sp_uint64)a[ 4]) * b[ 8]
  7790. + ((sp_uint64)a[ 5]) * b[ 7]
  7791. + ((sp_uint64)a[ 6]) * b[ 6]
  7792. + ((sp_uint64)a[ 7]) * b[ 5]
  7793. + ((sp_uint64)a[ 8]) * b[ 4]
  7794. + ((sp_uint64)a[ 9]) * b[ 3]
  7795. + ((sp_uint64)a[10]) * b[ 2]
  7796. + ((sp_uint64)a[11]) * b[ 1]
  7797. + ((sp_uint64)a[12]) * b[ 0];
  7798. t[11] = t1 & 0xfffffff; t0 += t1 >> 28;
  7799. t1 = ((sp_uint64)a[ 0]) * b[13]
  7800. + ((sp_uint64)a[ 1]) * b[12]
  7801. + ((sp_uint64)a[ 2]) * b[11]
  7802. + ((sp_uint64)a[ 3]) * b[10]
  7803. + ((sp_uint64)a[ 4]) * b[ 9]
  7804. + ((sp_uint64)a[ 5]) * b[ 8]
  7805. + ((sp_uint64)a[ 6]) * b[ 7]
  7806. + ((sp_uint64)a[ 7]) * b[ 6]
  7807. + ((sp_uint64)a[ 8]) * b[ 5]
  7808. + ((sp_uint64)a[ 9]) * b[ 4]
  7809. + ((sp_uint64)a[10]) * b[ 3]
  7810. + ((sp_uint64)a[11]) * b[ 2]
  7811. + ((sp_uint64)a[12]) * b[ 1]
  7812. + ((sp_uint64)a[13]) * b[ 0];
  7813. t[12] = t0 & 0xfffffff; t1 += t0 >> 28;
  7814. t0 = ((sp_uint64)a[ 1]) * b[13]
  7815. + ((sp_uint64)a[ 2]) * b[12]
  7816. + ((sp_uint64)a[ 3]) * b[11]
  7817. + ((sp_uint64)a[ 4]) * b[10]
  7818. + ((sp_uint64)a[ 5]) * b[ 9]
  7819. + ((sp_uint64)a[ 6]) * b[ 8]
  7820. + ((sp_uint64)a[ 7]) * b[ 7]
  7821. + ((sp_uint64)a[ 8]) * b[ 6]
  7822. + ((sp_uint64)a[ 9]) * b[ 5]
  7823. + ((sp_uint64)a[10]) * b[ 4]
  7824. + ((sp_uint64)a[11]) * b[ 3]
  7825. + ((sp_uint64)a[12]) * b[ 2]
  7826. + ((sp_uint64)a[13]) * b[ 1];
  7827. t[13] = t1 & 0xfffffff; t0 += t1 >> 28;
  7828. t1 = ((sp_uint64)a[ 2]) * b[13]
  7829. + ((sp_uint64)a[ 3]) * b[12]
  7830. + ((sp_uint64)a[ 4]) * b[11]
  7831. + ((sp_uint64)a[ 5]) * b[10]
  7832. + ((sp_uint64)a[ 6]) * b[ 9]
  7833. + ((sp_uint64)a[ 7]) * b[ 8]
  7834. + ((sp_uint64)a[ 8]) * b[ 7]
  7835. + ((sp_uint64)a[ 9]) * b[ 6]
  7836. + ((sp_uint64)a[10]) * b[ 5]
  7837. + ((sp_uint64)a[11]) * b[ 4]
  7838. + ((sp_uint64)a[12]) * b[ 3]
  7839. + ((sp_uint64)a[13]) * b[ 2];
  7840. r[14] = t0 & 0xfffffff; t1 += t0 >> 28;
  7841. t0 = ((sp_uint64)a[ 3]) * b[13]
  7842. + ((sp_uint64)a[ 4]) * b[12]
  7843. + ((sp_uint64)a[ 5]) * b[11]
  7844. + ((sp_uint64)a[ 6]) * b[10]
  7845. + ((sp_uint64)a[ 7]) * b[ 9]
  7846. + ((sp_uint64)a[ 8]) * b[ 8]
  7847. + ((sp_uint64)a[ 9]) * b[ 7]
  7848. + ((sp_uint64)a[10]) * b[ 6]
  7849. + ((sp_uint64)a[11]) * b[ 5]
  7850. + ((sp_uint64)a[12]) * b[ 4]
  7851. + ((sp_uint64)a[13]) * b[ 3];
  7852. r[15] = t1 & 0xfffffff; t0 += t1 >> 28;
  7853. t1 = ((sp_uint64)a[ 4]) * b[13]
  7854. + ((sp_uint64)a[ 5]) * b[12]
  7855. + ((sp_uint64)a[ 6]) * b[11]
  7856. + ((sp_uint64)a[ 7]) * b[10]
  7857. + ((sp_uint64)a[ 8]) * b[ 9]
  7858. + ((sp_uint64)a[ 9]) * b[ 8]
  7859. + ((sp_uint64)a[10]) * b[ 7]
  7860. + ((sp_uint64)a[11]) * b[ 6]
  7861. + ((sp_uint64)a[12]) * b[ 5]
  7862. + ((sp_uint64)a[13]) * b[ 4];
  7863. r[16] = t0 & 0xfffffff; t1 += t0 >> 28;
  7864. t0 = ((sp_uint64)a[ 5]) * b[13]
  7865. + ((sp_uint64)a[ 6]) * b[12]
  7866. + ((sp_uint64)a[ 7]) * b[11]
  7867. + ((sp_uint64)a[ 8]) * b[10]
  7868. + ((sp_uint64)a[ 9]) * b[ 9]
  7869. + ((sp_uint64)a[10]) * b[ 8]
  7870. + ((sp_uint64)a[11]) * b[ 7]
  7871. + ((sp_uint64)a[12]) * b[ 6]
  7872. + ((sp_uint64)a[13]) * b[ 5];
  7873. r[17] = t1 & 0xfffffff; t0 += t1 >> 28;
  7874. t1 = ((sp_uint64)a[ 6]) * b[13]
  7875. + ((sp_uint64)a[ 7]) * b[12]
  7876. + ((sp_uint64)a[ 8]) * b[11]
  7877. + ((sp_uint64)a[ 9]) * b[10]
  7878. + ((sp_uint64)a[10]) * b[ 9]
  7879. + ((sp_uint64)a[11]) * b[ 8]
  7880. + ((sp_uint64)a[12]) * b[ 7]
  7881. + ((sp_uint64)a[13]) * b[ 6];
  7882. r[18] = t0 & 0xfffffff; t1 += t0 >> 28;
  7883. t0 = ((sp_uint64)a[ 7]) * b[13]
  7884. + ((sp_uint64)a[ 8]) * b[12]
  7885. + ((sp_uint64)a[ 9]) * b[11]
  7886. + ((sp_uint64)a[10]) * b[10]
  7887. + ((sp_uint64)a[11]) * b[ 9]
  7888. + ((sp_uint64)a[12]) * b[ 8]
  7889. + ((sp_uint64)a[13]) * b[ 7];
  7890. r[19] = t1 & 0xfffffff; t0 += t1 >> 28;
  7891. t1 = ((sp_uint64)a[ 8]) * b[13]
  7892. + ((sp_uint64)a[ 9]) * b[12]
  7893. + ((sp_uint64)a[10]) * b[11]
  7894. + ((sp_uint64)a[11]) * b[10]
  7895. + ((sp_uint64)a[12]) * b[ 9]
  7896. + ((sp_uint64)a[13]) * b[ 8];
  7897. r[20] = t0 & 0xfffffff; t1 += t0 >> 28;
  7898. t0 = ((sp_uint64)a[ 9]) * b[13]
  7899. + ((sp_uint64)a[10]) * b[12]
  7900. + ((sp_uint64)a[11]) * b[11]
  7901. + ((sp_uint64)a[12]) * b[10]
  7902. + ((sp_uint64)a[13]) * b[ 9];
  7903. r[21] = t1 & 0xfffffff; t0 += t1 >> 28;
  7904. t1 = ((sp_uint64)a[10]) * b[13]
  7905. + ((sp_uint64)a[11]) * b[12]
  7906. + ((sp_uint64)a[12]) * b[11]
  7907. + ((sp_uint64)a[13]) * b[10];
  7908. r[22] = t0 & 0xfffffff; t1 += t0 >> 28;
  7909. t0 = ((sp_uint64)a[11]) * b[13]
  7910. + ((sp_uint64)a[12]) * b[12]
  7911. + ((sp_uint64)a[13]) * b[11];
  7912. r[23] = t1 & 0xfffffff; t0 += t1 >> 28;
  7913. t1 = ((sp_uint64)a[12]) * b[13]
  7914. + ((sp_uint64)a[13]) * b[12];
  7915. r[24] = t0 & 0xfffffff; t1 += t0 >> 28;
  7916. t0 = ((sp_uint64)a[13]) * b[13];
  7917. r[25] = t1 & 0xfffffff; t0 += t1 >> 28;
  7918. r[26] = t0 & 0xfffffff;
  7919. r[27] = (sp_digit)(t0 >> 28);
  7920. XMEMCPY(r, t, sizeof(t));
  7921. }
  7922. /* Add b to a into r. (r = a + b)
  7923. *
  7924. * r A single precision integer.
  7925. * a A single precision integer.
  7926. * b A single precision integer.
  7927. */
  7928. SP_NOINLINE static int sp_3072_add_14(sp_digit* r, const sp_digit* a,
  7929. const sp_digit* b)
  7930. {
  7931. r[ 0] = a[ 0] + b[ 0];
  7932. r[ 1] = a[ 1] + b[ 1];
  7933. r[ 2] = a[ 2] + b[ 2];
  7934. r[ 3] = a[ 3] + b[ 3];
  7935. r[ 4] = a[ 4] + b[ 4];
  7936. r[ 5] = a[ 5] + b[ 5];
  7937. r[ 6] = a[ 6] + b[ 6];
  7938. r[ 7] = a[ 7] + b[ 7];
  7939. r[ 8] = a[ 8] + b[ 8];
  7940. r[ 9] = a[ 9] + b[ 9];
  7941. r[10] = a[10] + b[10];
  7942. r[11] = a[11] + b[11];
  7943. r[12] = a[12] + b[12];
  7944. r[13] = a[13] + b[13];
  7945. return 0;
  7946. }
  7947. /* Add b to a into r. (r = a + b)
  7948. *
  7949. * r A single precision integer.
  7950. * a A single precision integer.
  7951. * b A single precision integer.
  7952. */
  7953. SP_NOINLINE static int sp_3072_add_28(sp_digit* r, const sp_digit* a,
  7954. const sp_digit* b)
  7955. {
  7956. int i;
  7957. for (i = 0; i < 24; i += 8) {
  7958. r[i + 0] = a[i + 0] + b[i + 0];
  7959. r[i + 1] = a[i + 1] + b[i + 1];
  7960. r[i + 2] = a[i + 2] + b[i + 2];
  7961. r[i + 3] = a[i + 3] + b[i + 3];
  7962. r[i + 4] = a[i + 4] + b[i + 4];
  7963. r[i + 5] = a[i + 5] + b[i + 5];
  7964. r[i + 6] = a[i + 6] + b[i + 6];
  7965. r[i + 7] = a[i + 7] + b[i + 7];
  7966. }
  7967. r[24] = a[24] + b[24];
  7968. r[25] = a[25] + b[25];
  7969. r[26] = a[26] + b[26];
  7970. r[27] = a[27] + b[27];
  7971. return 0;
  7972. }
  7973. /* Sub b from a into r. (r = a - b)
  7974. *
  7975. * r A single precision integer.
  7976. * a A single precision integer.
  7977. * b A single precision integer.
  7978. */
  7979. SP_NOINLINE static int sp_3072_sub_28(sp_digit* r, const sp_digit* a,
  7980. const sp_digit* b)
  7981. {
  7982. int i;
  7983. for (i = 0; i < 24; i += 8) {
  7984. r[i + 0] = a[i + 0] - b[i + 0];
  7985. r[i + 1] = a[i + 1] - b[i + 1];
  7986. r[i + 2] = a[i + 2] - b[i + 2];
  7987. r[i + 3] = a[i + 3] - b[i + 3];
  7988. r[i + 4] = a[i + 4] - b[i + 4];
  7989. r[i + 5] = a[i + 5] - b[i + 5];
  7990. r[i + 6] = a[i + 6] - b[i + 6];
  7991. r[i + 7] = a[i + 7] - b[i + 7];
  7992. }
  7993. r[24] = a[24] - b[24];
  7994. r[25] = a[25] - b[25];
  7995. r[26] = a[26] - b[26];
  7996. r[27] = a[27] - b[27];
  7997. return 0;
  7998. }
  7999. /* Normalize the values in each word to 28 bits.
  8000. *
  8001. * a Array of sp_digit to normalize.
  8002. */
  8003. static void sp_3072_norm_14(sp_digit* a)
  8004. {
  8005. a[1] += a[0] >> 28; a[0] &= 0xfffffff;
  8006. a[2] += a[1] >> 28; a[1] &= 0xfffffff;
  8007. a[3] += a[2] >> 28; a[2] &= 0xfffffff;
  8008. a[4] += a[3] >> 28; a[3] &= 0xfffffff;
  8009. a[5] += a[4] >> 28; a[4] &= 0xfffffff;
  8010. a[6] += a[5] >> 28; a[5] &= 0xfffffff;
  8011. a[7] += a[6] >> 28; a[6] &= 0xfffffff;
  8012. a[8] += a[7] >> 28; a[7] &= 0xfffffff;
  8013. a[9] += a[8] >> 28; a[8] &= 0xfffffff;
  8014. a[10] += a[9] >> 28; a[9] &= 0xfffffff;
  8015. a[11] += a[10] >> 28; a[10] &= 0xfffffff;
  8016. a[12] += a[11] >> 28; a[11] &= 0xfffffff;
  8017. a[13] += a[12] >> 28; a[12] &= 0xfffffff;
  8018. }
  8019. /* Multiply a and b into r. (r = a * b)
  8020. *
  8021. * r A single precision integer.
  8022. * a A single precision integer.
  8023. * b A single precision integer.
  8024. */
  8025. SP_NOINLINE static void sp_3072_mul_28(sp_digit* r, const sp_digit* a,
  8026. const sp_digit* b)
  8027. {
  8028. sp_digit* z0 = r;
  8029. sp_digit z1[28];
  8030. sp_digit* a1 = z1;
  8031. sp_digit b1[14];
  8032. sp_digit* z2 = r + 28;
  8033. (void)sp_3072_add_14(a1, a, &a[14]);
  8034. sp_3072_norm_14(a1);
  8035. (void)sp_3072_add_14(b1, b, &b[14]);
  8036. sp_3072_norm_14(b1);
  8037. sp_3072_mul_14(z2, &a[14], &b[14]);
  8038. sp_3072_mul_14(z0, a, b);
  8039. sp_3072_mul_14(z1, a1, b1);
  8040. (void)sp_3072_sub_28(z1, z1, z2);
  8041. (void)sp_3072_sub_28(z1, z1, z0);
  8042. (void)sp_3072_add_28(r + 14, r + 14, z1);
  8043. sp_3072_norm_56(r);
  8044. }
  8045. /* Add b to a into r. (r = a + b)
  8046. *
  8047. * r A single precision integer.
  8048. * a A single precision integer.
  8049. * b A single precision integer.
  8050. */
  8051. SP_NOINLINE static int sp_3072_add_56(sp_digit* r, const sp_digit* a,
  8052. const sp_digit* b)
  8053. {
  8054. int i;
  8055. for (i = 0; i < 56; i += 8) {
  8056. r[i + 0] = a[i + 0] + b[i + 0];
  8057. r[i + 1] = a[i + 1] + b[i + 1];
  8058. r[i + 2] = a[i + 2] + b[i + 2];
  8059. r[i + 3] = a[i + 3] + b[i + 3];
  8060. r[i + 4] = a[i + 4] + b[i + 4];
  8061. r[i + 5] = a[i + 5] + b[i + 5];
  8062. r[i + 6] = a[i + 6] + b[i + 6];
  8063. r[i + 7] = a[i + 7] + b[i + 7];
  8064. }
  8065. return 0;
  8066. }
  8067. /* Sub b from a into r. (r = a - b)
  8068. *
  8069. * r A single precision integer.
  8070. * a A single precision integer.
  8071. * b A single precision integer.
  8072. */
  8073. SP_NOINLINE static int sp_3072_sub_56(sp_digit* r, const sp_digit* a,
  8074. const sp_digit* b)
  8075. {
  8076. int i;
  8077. for (i = 0; i < 56; i += 8) {
  8078. r[i + 0] = a[i + 0] - b[i + 0];
  8079. r[i + 1] = a[i + 1] - b[i + 1];
  8080. r[i + 2] = a[i + 2] - b[i + 2];
  8081. r[i + 3] = a[i + 3] - b[i + 3];
  8082. r[i + 4] = a[i + 4] - b[i + 4];
  8083. r[i + 5] = a[i + 5] - b[i + 5];
  8084. r[i + 6] = a[i + 6] - b[i + 6];
  8085. r[i + 7] = a[i + 7] - b[i + 7];
  8086. }
  8087. return 0;
  8088. }
  8089. /* Normalize the values in each word to 28 bits.
  8090. *
  8091. * a Array of sp_digit to normalize.
  8092. */
  8093. static void sp_3072_norm_28(sp_digit* a)
  8094. {
  8095. int i;
  8096. for (i = 0; i < 24; i += 8) {
  8097. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  8098. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  8099. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  8100. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  8101. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  8102. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  8103. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  8104. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  8105. }
  8106. a[25] += a[24] >> 28; a[24] &= 0xfffffff;
  8107. a[26] += a[25] >> 28; a[25] &= 0xfffffff;
  8108. a[27] += a[26] >> 28; a[26] &= 0xfffffff;
  8109. }
  8110. /* Multiply a and b into r. (r = a * b)
  8111. *
  8112. * r A single precision integer.
  8113. * a A single precision integer.
  8114. * b A single precision integer.
  8115. */
  8116. SP_NOINLINE static void sp_3072_mul_56(sp_digit* r, const sp_digit* a,
  8117. const sp_digit* b)
  8118. {
  8119. sp_digit* z0 = r;
  8120. sp_digit z1[56];
  8121. sp_digit* a1 = z1;
  8122. sp_digit b1[28];
  8123. sp_digit* z2 = r + 56;
  8124. (void)sp_3072_add_28(a1, a, &a[28]);
  8125. sp_3072_norm_28(a1);
  8126. (void)sp_3072_add_28(b1, b, &b[28]);
  8127. sp_3072_norm_28(b1);
  8128. sp_3072_mul_28(z2, &a[28], &b[28]);
  8129. sp_3072_mul_28(z0, a, b);
  8130. sp_3072_mul_28(z1, a1, b1);
  8131. (void)sp_3072_sub_56(z1, z1, z2);
  8132. (void)sp_3072_sub_56(z1, z1, z0);
  8133. (void)sp_3072_add_56(r + 28, r + 28, z1);
  8134. sp_3072_norm_112(r);
  8135. }
  8136. /* Add b to a into r. (r = a + b)
  8137. *
  8138. * r A single precision integer.
  8139. * a A single precision integer.
  8140. * b A single precision integer.
  8141. */
  8142. SP_NOINLINE static int sp_3072_add_112(sp_digit* r, const sp_digit* a,
  8143. const sp_digit* b)
  8144. {
  8145. int i;
  8146. for (i = 0; i < 112; i += 8) {
  8147. r[i + 0] = a[i + 0] + b[i + 0];
  8148. r[i + 1] = a[i + 1] + b[i + 1];
  8149. r[i + 2] = a[i + 2] + b[i + 2];
  8150. r[i + 3] = a[i + 3] + b[i + 3];
  8151. r[i + 4] = a[i + 4] + b[i + 4];
  8152. r[i + 5] = a[i + 5] + b[i + 5];
  8153. r[i + 6] = a[i + 6] + b[i + 6];
  8154. r[i + 7] = a[i + 7] + b[i + 7];
  8155. }
  8156. return 0;
  8157. }
  8158. /* Sub b from a into r. (r = a - b)
  8159. *
  8160. * r A single precision integer.
  8161. * a A single precision integer.
  8162. * b A single precision integer.
  8163. */
  8164. SP_NOINLINE static int sp_3072_sub_112(sp_digit* r, const sp_digit* a,
  8165. const sp_digit* b)
  8166. {
  8167. int i;
  8168. for (i = 0; i < 112; i += 8) {
  8169. r[i + 0] = a[i + 0] - b[i + 0];
  8170. r[i + 1] = a[i + 1] - b[i + 1];
  8171. r[i + 2] = a[i + 2] - b[i + 2];
  8172. r[i + 3] = a[i + 3] - b[i + 3];
  8173. r[i + 4] = a[i + 4] - b[i + 4];
  8174. r[i + 5] = a[i + 5] - b[i + 5];
  8175. r[i + 6] = a[i + 6] - b[i + 6];
  8176. r[i + 7] = a[i + 7] - b[i + 7];
  8177. }
  8178. return 0;
  8179. }
  8180. /* Normalize the values in each word to 28 bits.
  8181. *
  8182. * a Array of sp_digit to normalize.
  8183. */
  8184. static void sp_3072_norm_224(sp_digit* a)
  8185. {
  8186. int i;
  8187. for (i = 0; i < 216; i += 8) {
  8188. a[i+1] += a[i+0] >> 28; a[i+0] &= 0xfffffff;
  8189. a[i+2] += a[i+1] >> 28; a[i+1] &= 0xfffffff;
  8190. a[i+3] += a[i+2] >> 28; a[i+2] &= 0xfffffff;
  8191. a[i+4] += a[i+3] >> 28; a[i+3] &= 0xfffffff;
  8192. a[i+5] += a[i+4] >> 28; a[i+4] &= 0xfffffff;
  8193. a[i+6] += a[i+5] >> 28; a[i+5] &= 0xfffffff;
  8194. a[i+7] += a[i+6] >> 28; a[i+6] &= 0xfffffff;
  8195. a[i+8] += a[i+7] >> 28; a[i+7] &= 0xfffffff;
  8196. }
  8197. a[217] += a[216] >> 28; a[216] &= 0xfffffff;
  8198. a[218] += a[217] >> 28; a[217] &= 0xfffffff;
  8199. a[219] += a[218] >> 28; a[218] &= 0xfffffff;
  8200. a[220] += a[219] >> 28; a[219] &= 0xfffffff;
  8201. a[221] += a[220] >> 28; a[220] &= 0xfffffff;
  8202. a[222] += a[221] >> 28; a[221] &= 0xfffffff;
  8203. a[223] += a[222] >> 28; a[222] &= 0xfffffff;
  8204. }
  8205. /* Multiply a and b into r. (r = a * b)
  8206. *
  8207. * r A single precision integer.
  8208. * a A single precision integer.
  8209. * b A single precision integer.
  8210. */
  8211. SP_NOINLINE static void sp_3072_mul_112(sp_digit* r, const sp_digit* a,
  8212. const sp_digit* b)
  8213. {
  8214. sp_digit* z0 = r;
  8215. sp_digit z1[112];
  8216. sp_digit* a1 = z1;
  8217. sp_digit b1[56];
  8218. sp_digit* z2 = r + 112;
  8219. (void)sp_3072_add_56(a1, a, &a[56]);
  8220. sp_3072_norm_56(a1);
  8221. (void)sp_3072_add_56(b1, b, &b[56]);
  8222. sp_3072_norm_56(b1);
  8223. sp_3072_mul_56(z2, &a[56], &b[56]);
  8224. sp_3072_mul_56(z0, a, b);
  8225. sp_3072_mul_56(z1, a1, b1);
  8226. (void)sp_3072_sub_112(z1, z1, z2);
  8227. (void)sp_3072_sub_112(z1, z1, z0);
  8228. (void)sp_3072_add_112(r + 56, r + 56, z1);
  8229. sp_3072_norm_224(r);
  8230. }
  8231. /* Square a and put result in r. (r = a * a)
  8232. *
  8233. * r A single precision integer.
  8234. * a A single precision integer.
  8235. */
  8236. SP_NOINLINE static void sp_3072_sqr_14(sp_digit* r, const sp_digit* a)
  8237. {
  8238. sp_uint64 t0;
  8239. sp_uint64 t1;
  8240. sp_digit t[14];
  8241. t0 = ((sp_uint64)a[ 0]) * a[ 0];
  8242. t1 = (((sp_uint64)a[ 0]) * a[ 1]) * 2;
  8243. t[ 0] = t0 & 0xfffffff; t1 += t0 >> 28;
  8244. t0 = (((sp_uint64)a[ 0]) * a[ 2]) * 2
  8245. + ((sp_uint64)a[ 1]) * a[ 1];
  8246. t[ 1] = t1 & 0xfffffff; t0 += t1 >> 28;
  8247. t1 = (((sp_uint64)a[ 0]) * a[ 3]
  8248. + ((sp_uint64)a[ 1]) * a[ 2]) * 2;
  8249. t[ 2] = t0 & 0xfffffff; t1 += t0 >> 28;
  8250. t0 = (((sp_uint64)a[ 0]) * a[ 4]
  8251. + ((sp_uint64)a[ 1]) * a[ 3]) * 2
  8252. + ((sp_uint64)a[ 2]) * a[ 2];
  8253. t[ 3] = t1 & 0xfffffff; t0 += t1 >> 28;
  8254. t1 = (((sp_uint64)a[ 0]) * a[ 5]
  8255. + ((sp_uint64)a[ 1]) * a[ 4]
  8256. + ((sp_uint64)a[ 2]) * a[ 3]) * 2;
  8257. t[ 4] = t0 & 0xfffffff; t1 += t0 >> 28;
  8258. t0 = (((sp_uint64)a[ 0]) * a[ 6]
  8259. + ((sp_uint64)a[ 1]) * a[ 5]
  8260. + ((sp_uint64)a[ 2]) * a[ 4]) * 2
  8261. + ((sp_uint64)a[ 3]) * a[ 3];
  8262. t[ 5] = t1 & 0xfffffff; t0 += t1 >> 28;
  8263. t1 = (((sp_uint64)a[ 0]) * a[ 7]
  8264. + ((sp_uint64)a[ 1]) * a[ 6]
  8265. + ((sp_uint64)a[ 2]) * a[ 5]
  8266. + ((sp_uint64)a[ 3]) * a[ 4]) * 2;
  8267. t[ 6] = t0 & 0xfffffff; t1 += t0 >> 28;
  8268. t0 = (((sp_uint64)a[ 0]) * a[ 8]
  8269. + ((sp_uint64)a[ 1]) * a[ 7]
  8270. + ((sp_uint64)a[ 2]) * a[ 6]
  8271. + ((sp_uint64)a[ 3]) * a[ 5]) * 2
  8272. + ((sp_uint64)a[ 4]) * a[ 4];
  8273. t[ 7] = t1 & 0xfffffff; t0 += t1 >> 28;
  8274. t1 = (((sp_uint64)a[ 0]) * a[ 9]
  8275. + ((sp_uint64)a[ 1]) * a[ 8]
  8276. + ((sp_uint64)a[ 2]) * a[ 7]
  8277. + ((sp_uint64)a[ 3]) * a[ 6]
  8278. + ((sp_uint64)a[ 4]) * a[ 5]) * 2;
  8279. t[ 8] = t0 & 0xfffffff; t1 += t0 >> 28;
  8280. t0 = (((sp_uint64)a[ 0]) * a[10]
  8281. + ((sp_uint64)a[ 1]) * a[ 9]
  8282. + ((sp_uint64)a[ 2]) * a[ 8]
  8283. + ((sp_uint64)a[ 3]) * a[ 7]
  8284. + ((sp_uint64)a[ 4]) * a[ 6]) * 2
  8285. + ((sp_uint64)a[ 5]) * a[ 5];
  8286. t[ 9] = t1 & 0xfffffff; t0 += t1 >> 28;
  8287. t1 = (((sp_uint64)a[ 0]) * a[11]
  8288. + ((sp_uint64)a[ 1]) * a[10]
  8289. + ((sp_uint64)a[ 2]) * a[ 9]
  8290. + ((sp_uint64)a[ 3]) * a[ 8]
  8291. + ((sp_uint64)a[ 4]) * a[ 7]
  8292. + ((sp_uint64)a[ 5]) * a[ 6]) * 2;
  8293. t[10] = t0 & 0xfffffff; t1 += t0 >> 28;
  8294. t0 = (((sp_uint64)a[ 0]) * a[12]
  8295. + ((sp_uint64)a[ 1]) * a[11]
  8296. + ((sp_uint64)a[ 2]) * a[10]
  8297. + ((sp_uint64)a[ 3]) * a[ 9]
  8298. + ((sp_uint64)a[ 4]) * a[ 8]
  8299. + ((sp_uint64)a[ 5]) * a[ 7]) * 2
  8300. + ((sp_uint64)a[ 6]) * a[ 6];
  8301. t[11] = t1 & 0xfffffff; t0 += t1 >> 28;
  8302. t1 = (((sp_uint64)a[ 0]) * a[13]
  8303. + ((sp_uint64)a[ 1]) * a[12]
  8304. + ((sp_uint64)a[ 2]) * a[11]
  8305. + ((sp_uint64)a[ 3]) * a[10]
  8306. + ((sp_uint64)a[ 4]) * a[ 9]
  8307. + ((sp_uint64)a[ 5]) * a[ 8]
  8308. + ((sp_uint64)a[ 6]) * a[ 7]) * 2;
  8309. t[12] = t0 & 0xfffffff; t1 += t0 >> 28;
  8310. t0 = (((sp_uint64)a[ 1]) * a[13]
  8311. + ((sp_uint64)a[ 2]) * a[12]
  8312. + ((sp_uint64)a[ 3]) * a[11]
  8313. + ((sp_uint64)a[ 4]) * a[10]
  8314. + ((sp_uint64)a[ 5]) * a[ 9]
  8315. + ((sp_uint64)a[ 6]) * a[ 8]) * 2
  8316. + ((sp_uint64)a[ 7]) * a[ 7];
  8317. t[13] = t1 & 0xfffffff; t0 += t1 >> 28;
  8318. t1 = (((sp_uint64)a[ 2]) * a[13]
  8319. + ((sp_uint64)a[ 3]) * a[12]
  8320. + ((sp_uint64)a[ 4]) * a[11]
  8321. + ((sp_uint64)a[ 5]) * a[10]
  8322. + ((sp_uint64)a[ 6]) * a[ 9]
  8323. + ((sp_uint64)a[ 7]) * a[ 8]) * 2;
  8324. r[14] = t0 & 0xfffffff; t1 += t0 >> 28;
  8325. t0 = (((sp_uint64)a[ 3]) * a[13]
  8326. + ((sp_uint64)a[ 4]) * a[12]
  8327. + ((sp_uint64)a[ 5]) * a[11]
  8328. + ((sp_uint64)a[ 6]) * a[10]
  8329. + ((sp_uint64)a[ 7]) * a[ 9]) * 2
  8330. + ((sp_uint64)a[ 8]) * a[ 8];
  8331. r[15] = t1 & 0xfffffff; t0 += t1 >> 28;
  8332. t1 = (((sp_uint64)a[ 4]) * a[13]
  8333. + ((sp_uint64)a[ 5]) * a[12]
  8334. + ((sp_uint64)a[ 6]) * a[11]
  8335. + ((sp_uint64)a[ 7]) * a[10]
  8336. + ((sp_uint64)a[ 8]) * a[ 9]) * 2;
  8337. r[16] = t0 & 0xfffffff; t1 += t0 >> 28;
  8338. t0 = (((sp_uint64)a[ 5]) * a[13]
  8339. + ((sp_uint64)a[ 6]) * a[12]
  8340. + ((sp_uint64)a[ 7]) * a[11]
  8341. + ((sp_uint64)a[ 8]) * a[10]) * 2
  8342. + ((sp_uint64)a[ 9]) * a[ 9];
  8343. r[17] = t1 & 0xfffffff; t0 += t1 >> 28;
  8344. t1 = (((sp_uint64)a[ 6]) * a[13]
  8345. + ((sp_uint64)a[ 7]) * a[12]
  8346. + ((sp_uint64)a[ 8]) * a[11]
  8347. + ((sp_uint64)a[ 9]) * a[10]) * 2;
  8348. r[18] = t0 & 0xfffffff; t1 += t0 >> 28;
  8349. t0 = (((sp_uint64)a[ 7]) * a[13]
  8350. + ((sp_uint64)a[ 8]) * a[12]
  8351. + ((sp_uint64)a[ 9]) * a[11]) * 2
  8352. + ((sp_uint64)a[10]) * a[10];
  8353. r[19] = t1 & 0xfffffff; t0 += t1 >> 28;
  8354. t1 = (((sp_uint64)a[ 8]) * a[13]
  8355. + ((sp_uint64)a[ 9]) * a[12]
  8356. + ((sp_uint64)a[10]) * a[11]) * 2;
  8357. r[20] = t0 & 0xfffffff; t1 += t0 >> 28;
  8358. t0 = (((sp_uint64)a[ 9]) * a[13]
  8359. + ((sp_uint64)a[10]) * a[12]) * 2
  8360. + ((sp_uint64)a[11]) * a[11];
  8361. r[21] = t1 & 0xfffffff; t0 += t1 >> 28;
  8362. t1 = (((sp_uint64)a[10]) * a[13]
  8363. + ((sp_uint64)a[11]) * a[12]) * 2;
  8364. r[22] = t0 & 0xfffffff; t1 += t0 >> 28;
  8365. t0 = (((sp_uint64)a[11]) * a[13]) * 2
  8366. + ((sp_uint64)a[12]) * a[12];
  8367. r[23] = t1 & 0xfffffff; t0 += t1 >> 28;
  8368. t1 = (((sp_uint64)a[12]) * a[13]) * 2;
  8369. r[24] = t0 & 0xfffffff; t1 += t0 >> 28;
  8370. t0 = ((sp_uint64)a[13]) * a[13];
  8371. r[25] = t1 & 0xfffffff; t0 += t1 >> 28;
  8372. r[26] = t0 & 0xfffffff;
  8373. r[27] = (sp_digit)(t0 >> 28);
  8374. XMEMCPY(r, t, sizeof(t));
  8375. }
  8376. /* Square a and put result in r. (r = a * a)
  8377. *
  8378. * r A single precision integer.
  8379. * a A single precision integer.
  8380. */
  8381. SP_NOINLINE static void sp_3072_sqr_28(sp_digit* r, const sp_digit* a)
  8382. {
  8383. sp_digit* z0 = r;
  8384. sp_digit z1[28];
  8385. sp_digit* a1 = z1;
  8386. sp_digit* z2 = r + 28;
  8387. (void)sp_3072_add_14(a1, a, &a[14]);
  8388. sp_3072_norm_14(a1);
  8389. sp_3072_sqr_14(z2, &a[14]);
  8390. sp_3072_sqr_14(z0, a);
  8391. sp_3072_sqr_14(z1, a1);
  8392. (void)sp_3072_sub_28(z1, z1, z2);
  8393. (void)sp_3072_sub_28(z1, z1, z0);
  8394. (void)sp_3072_add_28(r + 14, r + 14, z1);
  8395. sp_3072_norm_56(r);
  8396. }
  8397. /* Square a and put result in r. (r = a * a)
  8398. *
  8399. * r A single precision integer.
  8400. * a A single precision integer.
  8401. */
  8402. SP_NOINLINE static void sp_3072_sqr_56(sp_digit* r, const sp_digit* a)
  8403. {
  8404. sp_digit* z0 = r;
  8405. sp_digit z1[56];
  8406. sp_digit* a1 = z1;
  8407. sp_digit* z2 = r + 56;
  8408. (void)sp_3072_add_28(a1, a, &a[28]);
  8409. sp_3072_norm_28(a1);
  8410. sp_3072_sqr_28(z2, &a[28]);
  8411. sp_3072_sqr_28(z0, a);
  8412. sp_3072_sqr_28(z1, a1);
  8413. (void)sp_3072_sub_56(z1, z1, z2);
  8414. (void)sp_3072_sub_56(z1, z1, z0);
  8415. (void)sp_3072_add_56(r + 28, r + 28, z1);
  8416. sp_3072_norm_112(r);
  8417. }
  8418. /* Square a and put result in r. (r = a * a)
  8419. *
  8420. * r A single precision integer.
  8421. * a A single precision integer.
  8422. */
  8423. SP_NOINLINE static void sp_3072_sqr_112(sp_digit* r, const sp_digit* a)
  8424. {
  8425. sp_digit* z0 = r;
  8426. sp_digit z1[112];
  8427. sp_digit* a1 = z1;
  8428. sp_digit* z2 = r + 112;
  8429. (void)sp_3072_add_56(a1, a, &a[56]);
  8430. sp_3072_norm_56(a1);
  8431. sp_3072_sqr_56(z2, &a[56]);
  8432. sp_3072_sqr_56(z0, a);
  8433. sp_3072_sqr_56(z1, a1);
  8434. (void)sp_3072_sub_112(z1, z1, z2);
  8435. (void)sp_3072_sub_112(z1, z1, z0);
  8436. (void)sp_3072_add_112(r + 56, r + 56, z1);
  8437. sp_3072_norm_224(r);
  8438. }
  8439. #endif /* !WOLFSSL_SP_SMALL */
  8440. /* Calculate the bottom digit of -1/a mod 2^n.
  8441. *
  8442. * a A single precision number.
  8443. * rho Bottom word of inverse.
  8444. */
  8445. static void sp_3072_mont_setup(const sp_digit* a, sp_digit* rho)
  8446. {
  8447. sp_digit x;
  8448. sp_digit b;
  8449. b = a[0];
  8450. x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
  8451. x *= 2 - b * x; /* here x*a==1 mod 2**8 */
  8452. x *= 2 - b * x; /* here x*a==1 mod 2**16 */
  8453. x *= 2 - b * x; /* here x*a==1 mod 2**32 */
  8454. x &= 0xfffffff;
  8455. /* rho = -1/m mod b */
  8456. *rho = ((sp_digit)1 << 28) - x;
  8457. }
  8458. /* Multiply a by scalar b into r. (r = a * b)
  8459. *
  8460. * r A single precision integer.
  8461. * a A single precision integer.
  8462. * b A scalar.
  8463. */
  8464. SP_NOINLINE static void sp_3072_mul_d_112(sp_digit* r, const sp_digit* a,
  8465. sp_digit b)
  8466. {
  8467. sp_int64 tb = b;
  8468. sp_int64 t = 0;
  8469. sp_digit t2;
  8470. sp_int64 p[4];
  8471. int i;
  8472. for (i = 0; i < 112; i += 4) {
  8473. p[0] = tb * a[i + 0];
  8474. p[1] = tb * a[i + 1];
  8475. p[2] = tb * a[i + 2];
  8476. p[3] = tb * a[i + 3];
  8477. t += p[0];
  8478. t2 = (sp_digit)(t & 0xfffffff);
  8479. t >>= 28;
  8480. r[i + 0] = (sp_digit)t2;
  8481. t += p[1];
  8482. t2 = (sp_digit)(t & 0xfffffff);
  8483. t >>= 28;
  8484. r[i + 1] = (sp_digit)t2;
  8485. t += p[2];
  8486. t2 = (sp_digit)(t & 0xfffffff);
  8487. t >>= 28;
  8488. r[i + 2] = (sp_digit)t2;
  8489. t += p[3];
  8490. t2 = (sp_digit)(t & 0xfffffff);
  8491. t >>= 28;
  8492. r[i + 3] = (sp_digit)t2;
  8493. }
  8494. r[112] = (sp_digit)(t & 0xfffffff);
  8495. }
  8496. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  8497. /* r = 2^n mod m where n is the number of bits to reduce by.
  8498. * Given m must be 3072 bits, just need to subtract.
  8499. *
  8500. * r A single precision number.
  8501. * m A single precision number.
  8502. */
  8503. static void sp_3072_mont_norm_56(sp_digit* r, const sp_digit* m)
  8504. {
  8505. /* Set r = 2^n - 1. */
  8506. int i;
  8507. for (i = 0; i < 48; i += 8) {
  8508. r[i + 0] = 0xfffffff;
  8509. r[i + 1] = 0xfffffff;
  8510. r[i + 2] = 0xfffffff;
  8511. r[i + 3] = 0xfffffff;
  8512. r[i + 4] = 0xfffffff;
  8513. r[i + 5] = 0xfffffff;
  8514. r[i + 6] = 0xfffffff;
  8515. r[i + 7] = 0xfffffff;
  8516. }
  8517. r[48] = 0xfffffff;
  8518. r[49] = 0xfffffff;
  8519. r[50] = 0xfffffff;
  8520. r[51] = 0xfffffff;
  8521. r[52] = 0xfffffff;
  8522. r[53] = 0xfffffff;
  8523. r[54] = 0xffffffL;
  8524. r[55] = 0;
  8525. /* r = (2^n - 1) mod n */
  8526. (void)sp_3072_sub_56(r, r, m);
  8527. /* Add one so r = 2^n mod m */
  8528. r[0] += 1;
  8529. }
  8530. /* Compare a with b in constant time.
  8531. *
  8532. * a A single precision integer.
  8533. * b A single precision integer.
  8534. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  8535. * respectively.
  8536. */
  8537. static sp_digit sp_3072_cmp_56(const sp_digit* a, const sp_digit* b)
  8538. {
  8539. sp_digit r = 0;
  8540. int i;
  8541. for (i = 48; i >= 0; i -= 8) {
  8542. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 27);
  8543. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 27);
  8544. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 27);
  8545. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 27);
  8546. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 27);
  8547. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 27);
  8548. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 27);
  8549. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 27);
  8550. }
  8551. return r;
  8552. }
  8553. /* Conditionally subtract b from a using the mask m.
  8554. * m is -1 to subtract and 0 when not.
  8555. *
  8556. * r A single precision number representing condition subtract result.
  8557. * a A single precision number to subtract from.
  8558. * b A single precision number to subtract.
  8559. * m Mask value to apply.
  8560. */
  8561. static void sp_3072_cond_sub_56(sp_digit* r, const sp_digit* a,
  8562. const sp_digit* b, const sp_digit m)
  8563. {
  8564. int i;
  8565. for (i = 0; i < 56; i += 8) {
  8566. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  8567. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  8568. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  8569. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  8570. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  8571. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  8572. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  8573. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  8574. }
  8575. }
  8576. /* Mul a by scalar b and add into r. (r += a * b)
  8577. *
  8578. * r A single precision integer.
  8579. * a A single precision integer.
  8580. * b A scalar.
  8581. */
  8582. SP_NOINLINE static void sp_3072_mul_add_56(sp_digit* r, const sp_digit* a,
  8583. const sp_digit b)
  8584. {
  8585. #ifndef WOLFSSL_SP_LARGE_CODE
  8586. sp_int64 tb = b;
  8587. sp_int64 t = 0;
  8588. int i;
  8589. for (i = 0; i < 56; i++) {
  8590. t += r[i];
  8591. t += tb * a[i];
  8592. r[i] = ((sp_digit)t) & 0xfffffff;
  8593. t >>= 28;
  8594. }
  8595. r[56] += (sp_digit)t;
  8596. #else
  8597. sp_int64 tb = b;
  8598. sp_int64 t[8];
  8599. int i;
  8600. t[0] = 0;
  8601. for (i = 0; i < 48; i += 8) {
  8602. t[0] += (tb * a[i+0]) + r[i+0];
  8603. t[1] = (tb * a[i+1]) + r[i+1];
  8604. t[2] = (tb * a[i+2]) + r[i+2];
  8605. t[3] = (tb * a[i+3]) + r[i+3];
  8606. t[4] = (tb * a[i+4]) + r[i+4];
  8607. t[5] = (tb * a[i+5]) + r[i+5];
  8608. t[6] = (tb * a[i+6]) + r[i+6];
  8609. t[7] = (tb * a[i+7]) + r[i+7];
  8610. r[i+0] = t[0] & 0xfffffff;
  8611. t[1] += t[0] >> 28;
  8612. r[i+1] = t[1] & 0xfffffff;
  8613. t[2] += t[1] >> 28;
  8614. r[i+2] = t[2] & 0xfffffff;
  8615. t[3] += t[2] >> 28;
  8616. r[i+3] = t[3] & 0xfffffff;
  8617. t[4] += t[3] >> 28;
  8618. r[i+4] = t[4] & 0xfffffff;
  8619. t[5] += t[4] >> 28;
  8620. r[i+5] = t[5] & 0xfffffff;
  8621. t[6] += t[5] >> 28;
  8622. r[i+6] = t[6] & 0xfffffff;
  8623. t[7] += t[6] >> 28;
  8624. r[i+7] = t[7] & 0xfffffff;
  8625. t[0] = t[7] >> 28;
  8626. }
  8627. t[0] += (tb * a[48]) + r[48];
  8628. t[1] = (tb * a[49]) + r[49];
  8629. t[2] = (tb * a[50]) + r[50];
  8630. t[3] = (tb * a[51]) + r[51];
  8631. t[4] = (tb * a[52]) + r[52];
  8632. t[5] = (tb * a[53]) + r[53];
  8633. t[6] = (tb * a[54]) + r[54];
  8634. t[7] = (tb * a[55]) + r[55];
  8635. r[48] = t[0] & 0xfffffff;
  8636. t[1] += t[0] >> 28;
  8637. r[49] = t[1] & 0xfffffff;
  8638. t[2] += t[1] >> 28;
  8639. r[50] = t[2] & 0xfffffff;
  8640. t[3] += t[2] >> 28;
  8641. r[51] = t[3] & 0xfffffff;
  8642. t[4] += t[3] >> 28;
  8643. r[52] = t[4] & 0xfffffff;
  8644. t[5] += t[4] >> 28;
  8645. r[53] = t[5] & 0xfffffff;
  8646. t[6] += t[5] >> 28;
  8647. r[54] = t[6] & 0xfffffff;
  8648. t[7] += t[6] >> 28;
  8649. r[55] = t[7] & 0xfffffff;
  8650. r[56] += (sp_digit)(t[7] >> 28);
  8651. #endif /* !WOLFSSL_SP_LARGE_CODE */
  8652. }
  8653. /* Shift the result in the high 1536 bits down to the bottom.
  8654. *
  8655. * r A single precision number.
  8656. * a A single precision number.
  8657. */
  8658. static void sp_3072_mont_shift_56(sp_digit* r, const sp_digit* a)
  8659. {
  8660. int i;
  8661. sp_int64 n = a[54] >> 24;
  8662. n += ((sp_int64)a[55]) << 4;
  8663. for (i = 0; i < 48; i += 8) {
  8664. r[i + 0] = n & 0xfffffff;
  8665. n >>= 28; n += ((sp_int64)a[i + 56]) << 4;
  8666. r[i + 1] = n & 0xfffffff;
  8667. n >>= 28; n += ((sp_int64)a[i + 57]) << 4;
  8668. r[i + 2] = n & 0xfffffff;
  8669. n >>= 28; n += ((sp_int64)a[i + 58]) << 4;
  8670. r[i + 3] = n & 0xfffffff;
  8671. n >>= 28; n += ((sp_int64)a[i + 59]) << 4;
  8672. r[i + 4] = n & 0xfffffff;
  8673. n >>= 28; n += ((sp_int64)a[i + 60]) << 4;
  8674. r[i + 5] = n & 0xfffffff;
  8675. n >>= 28; n += ((sp_int64)a[i + 61]) << 4;
  8676. r[i + 6] = n & 0xfffffff;
  8677. n >>= 28; n += ((sp_int64)a[i + 62]) << 4;
  8678. r[i + 7] = n & 0xfffffff;
  8679. n >>= 28; n += ((sp_int64)a[i + 63]) << 4;
  8680. }
  8681. r[48] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[104]) << 4;
  8682. r[49] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[105]) << 4;
  8683. r[50] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[106]) << 4;
  8684. r[51] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[107]) << 4;
  8685. r[52] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[108]) << 4;
  8686. r[53] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[109]) << 4;
  8687. r[54] = (sp_digit)n;
  8688. XMEMSET(&r[55], 0, sizeof(*r) * 55U);
  8689. }
  8690. /* Reduce the number back to 3072 bits using Montgomery reduction.
  8691. *
  8692. * a A single precision number to reduce in place.
  8693. * m The single precision number representing the modulus.
  8694. * mp The digit representing the negative inverse of m mod 2^n.
  8695. */
  8696. static void sp_3072_mont_reduce_56(sp_digit* a, const sp_digit* m, sp_digit mp)
  8697. {
  8698. int i;
  8699. sp_digit mu;
  8700. sp_digit over;
  8701. sp_3072_norm_56(a + 55);
  8702. for (i=0; i<54; i++) {
  8703. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffff;
  8704. sp_3072_mul_add_56(a+i, m, mu);
  8705. a[i+1] += a[i] >> 28;
  8706. }
  8707. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xffffffL;
  8708. sp_3072_mul_add_56(a+i, m, mu);
  8709. a[i+1] += a[i] >> 28;
  8710. a[i] &= 0xfffffff;
  8711. sp_3072_mont_shift_56(a, a);
  8712. over = a[54] - m[54];
  8713. sp_3072_cond_sub_56(a, a, m, ~((over - 1) >> 31));
  8714. sp_3072_norm_56(a);
  8715. }
  8716. /* Multiply two Montgomery form numbers mod the modulus (prime).
  8717. * (r = a * b mod m)
  8718. *
  8719. * r Result of multiplication.
  8720. * a First number to multiply in Montgomery form.
  8721. * b Second number to multiply in Montgomery form.
  8722. * m Modulus (prime).
  8723. * mp Montgomery multiplier.
  8724. */
  8725. SP_NOINLINE static void sp_3072_mont_mul_56(sp_digit* r, const sp_digit* a,
  8726. const sp_digit* b, const sp_digit* m, sp_digit mp)
  8727. {
  8728. sp_3072_mul_56(r, a, b);
  8729. sp_3072_mont_reduce_56(r, m, mp);
  8730. }
  8731. /* Square the Montgomery form number. (r = a * a mod m)
  8732. *
  8733. * r Result of squaring.
  8734. * a Number to square in Montgomery form.
  8735. * m Modulus (prime).
  8736. * mp Montgomery multiplier.
  8737. */
  8738. SP_NOINLINE static void sp_3072_mont_sqr_56(sp_digit* r, const sp_digit* a,
  8739. const sp_digit* m, sp_digit mp)
  8740. {
  8741. sp_3072_sqr_56(r, a);
  8742. sp_3072_mont_reduce_56(r, m, mp);
  8743. }
  8744. /* Multiply a by scalar b into r. (r = a * b)
  8745. *
  8746. * r A single precision integer.
  8747. * a A single precision integer.
  8748. * b A scalar.
  8749. */
  8750. SP_NOINLINE static void sp_3072_mul_d_56(sp_digit* r, const sp_digit* a,
  8751. sp_digit b)
  8752. {
  8753. sp_int64 tb = b;
  8754. sp_int64 t = 0;
  8755. sp_digit t2;
  8756. sp_int64 p[4];
  8757. int i;
  8758. for (i = 0; i < 56; i += 4) {
  8759. p[0] = tb * a[i + 0];
  8760. p[1] = tb * a[i + 1];
  8761. p[2] = tb * a[i + 2];
  8762. p[3] = tb * a[i + 3];
  8763. t += p[0];
  8764. t2 = (sp_digit)(t & 0xfffffff);
  8765. t >>= 28;
  8766. r[i + 0] = (sp_digit)t2;
  8767. t += p[1];
  8768. t2 = (sp_digit)(t & 0xfffffff);
  8769. t >>= 28;
  8770. r[i + 1] = (sp_digit)t2;
  8771. t += p[2];
  8772. t2 = (sp_digit)(t & 0xfffffff);
  8773. t >>= 28;
  8774. r[i + 2] = (sp_digit)t2;
  8775. t += p[3];
  8776. t2 = (sp_digit)(t & 0xfffffff);
  8777. t >>= 28;
  8778. r[i + 3] = (sp_digit)t2;
  8779. }
  8780. r[56] = (sp_digit)(t & 0xfffffff);
  8781. }
  8782. #ifndef WOLFSSL_SP_SMALL
  8783. /* Conditionally add a and b using the mask m.
  8784. * m is -1 to add and 0 when not.
  8785. *
  8786. * r A single precision number representing conditional add result.
  8787. * a A single precision number to add with.
  8788. * b A single precision number to add.
  8789. * m Mask value to apply.
  8790. */
  8791. static void sp_3072_cond_add_56(sp_digit* r, const sp_digit* a,
  8792. const sp_digit* b, const sp_digit m)
  8793. {
  8794. int i;
  8795. for (i = 0; i < 56; i += 8) {
  8796. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  8797. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  8798. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  8799. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  8800. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  8801. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  8802. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  8803. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  8804. }
  8805. }
  8806. #endif /* !WOLFSSL_SP_SMALL */
  8807. SP_NOINLINE static void sp_3072_rshift_56(sp_digit* r, const sp_digit* a,
  8808. byte n)
  8809. {
  8810. int i;
  8811. for (i=0; i<48; i += 8) {
  8812. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (28 - n)) & 0xfffffff);
  8813. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (28 - n)) & 0xfffffff);
  8814. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (28 - n)) & 0xfffffff);
  8815. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (28 - n)) & 0xfffffff);
  8816. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (28 - n)) & 0xfffffff);
  8817. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (28 - n)) & 0xfffffff);
  8818. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (28 - n)) & 0xfffffff);
  8819. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (28 - n)) & 0xfffffff);
  8820. }
  8821. r[48] = (a[48] >> n) | ((a[49] << (28 - n)) & 0xfffffff);
  8822. r[49] = (a[49] >> n) | ((a[50] << (28 - n)) & 0xfffffff);
  8823. r[50] = (a[50] >> n) | ((a[51] << (28 - n)) & 0xfffffff);
  8824. r[51] = (a[51] >> n) | ((a[52] << (28 - n)) & 0xfffffff);
  8825. r[52] = (a[52] >> n) | ((a[53] << (28 - n)) & 0xfffffff);
  8826. r[53] = (a[53] >> n) | ((a[54] << (28 - n)) & 0xfffffff);
  8827. r[54] = (a[54] >> n) | ((a[55] << (28 - n)) & 0xfffffff);
  8828. r[55] = a[55] >> n;
  8829. }
  8830. static WC_INLINE sp_digit sp_3072_div_word_56(sp_digit d1, sp_digit d0,
  8831. sp_digit div)
  8832. {
  8833. #ifdef SP_USE_DIVTI3
  8834. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  8835. return d / div;
  8836. #elif defined(__x86_64__) || defined(__i386__)
  8837. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  8838. sp_uint32 lo = (sp_uint32)d;
  8839. sp_digit hi = (sp_digit)(d >> 32);
  8840. __asm__ __volatile__ (
  8841. "idiv %2"
  8842. : "+a" (lo)
  8843. : "d" (hi), "r" (div)
  8844. : "cc"
  8845. );
  8846. return (sp_digit)lo;
  8847. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  8848. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  8849. sp_digit dv = (div >> 1) + 1;
  8850. sp_digit t1 = (sp_digit)(d >> 28);
  8851. sp_digit t0 = (sp_digit)(d & 0xfffffff);
  8852. sp_digit t2;
  8853. sp_digit sign;
  8854. sp_digit r;
  8855. int i;
  8856. sp_int64 m;
  8857. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  8858. t1 -= dv & (0 - r);
  8859. for (i = 26; i >= 1; i--) {
  8860. t1 += t1 + (((sp_uint32)t0 >> 27) & 1);
  8861. t0 <<= 1;
  8862. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  8863. r += r + t2;
  8864. t1 -= dv & (0 - t2);
  8865. t1 += t2;
  8866. }
  8867. r += r + 1;
  8868. m = d - ((sp_int64)r * div);
  8869. r += (sp_digit)(m >> 28);
  8870. m = d - ((sp_int64)r * div);
  8871. r += (sp_digit)(m >> 56) - (sp_digit)(d >> 56);
  8872. m = d - ((sp_int64)r * div);
  8873. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  8874. m *= sign;
  8875. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  8876. r += sign * t2;
  8877. m = d - ((sp_int64)r * div);
  8878. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  8879. m *= sign;
  8880. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  8881. r += sign * t2;
  8882. return r;
  8883. #else
  8884. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  8885. sp_digit r = 0;
  8886. sp_digit t;
  8887. sp_digit dv = (div >> 13) + 1;
  8888. t = (sp_digit)(d >> 26);
  8889. t = (t / dv) << 13;
  8890. r += t;
  8891. d -= (sp_int64)t * div;
  8892. t = (sp_digit)(d >> 11);
  8893. t = t / (dv << 2);
  8894. r += t;
  8895. d -= (sp_int64)t * div;
  8896. t = (sp_digit)d;
  8897. t = t / div;
  8898. r += t;
  8899. d -= (sp_int64)t * div;
  8900. return r;
  8901. #endif
  8902. }
  8903. static WC_INLINE sp_digit sp_3072_word_div_word_56(sp_digit d, sp_digit div)
  8904. {
  8905. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  8906. defined(SP_DIV_WORD_USE_DIV)
  8907. return d / div;
  8908. #else
  8909. return (sp_digit)((sp_uint32)(div - d) >> 31);
  8910. #endif
  8911. }
  8912. /* Divide d in a and put remainder into r (m*d + r = a)
  8913. * m is not calculated as it is not needed at this time.
  8914. *
  8915. * Full implementation.
  8916. *
  8917. * a Number to be divided.
  8918. * d Number to divide with.
  8919. * m Multiplier result.
  8920. * r Remainder from the division.
  8921. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  8922. */
  8923. static int sp_3072_div_56(const sp_digit* a, const sp_digit* d,
  8924. const sp_digit* m, sp_digit* r)
  8925. {
  8926. int i;
  8927. #ifndef WOLFSSL_SP_DIV_32
  8928. #endif
  8929. sp_digit dv;
  8930. sp_digit r1;
  8931. #ifdef WOLFSSL_SP_SMALL_STACK
  8932. sp_digit* t1 = NULL;
  8933. #else
  8934. sp_digit t1[4 * 56 + 3];
  8935. #endif
  8936. sp_digit* t2 = NULL;
  8937. sp_digit* sd = NULL;
  8938. int err = MP_OKAY;
  8939. (void)m;
  8940. #ifdef WOLFSSL_SP_SMALL_STACK
  8941. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 56 + 3), NULL,
  8942. DYNAMIC_TYPE_TMP_BUFFER);
  8943. if (t1 == NULL)
  8944. err = MEMORY_E;
  8945. #endif
  8946. (void)m;
  8947. if (err == MP_OKAY) {
  8948. t2 = t1 + 112 + 1;
  8949. sd = t2 + 56 + 1;
  8950. sp_3072_mul_d_56(sd, d, (sp_digit)1 << 4);
  8951. sp_3072_mul_d_112(t1, a, (sp_digit)1 << 4);
  8952. dv = sd[54];
  8953. t1[55 + 55] += t1[55 + 55 - 1] >> 28;
  8954. t1[55 + 55 - 1] &= 0xfffffff;
  8955. for (i=55; i>=0; i--) {
  8956. r1 = sp_3072_div_word_56(t1[55 + i], t1[55 + i - 1], dv);
  8957. sp_3072_mul_d_56(t2, sd, r1);
  8958. (void)sp_3072_sub_56(&t1[i], &t1[i], t2);
  8959. sp_3072_norm_55(&t1[i]);
  8960. t1[55 + i] += t1[55 + i - 1] >> 28;
  8961. t1[55 + i - 1] &= 0xfffffff;
  8962. r1 = sp_3072_div_word_56(-t1[55 + i], -t1[55 + i - 1], dv);
  8963. r1 -= t1[55 + i];
  8964. sp_3072_mul_d_56(t2, sd, r1);
  8965. (void)sp_3072_add_56(&t1[i], &t1[i], t2);
  8966. t1[55 + i] += t1[55 + i - 1] >> 28;
  8967. t1[55 + i - 1] &= 0xfffffff;
  8968. }
  8969. t1[55 - 1] += t1[55 - 2] >> 28;
  8970. t1[55 - 2] &= 0xfffffff;
  8971. r1 = sp_3072_word_div_word_56(t1[55 - 1], dv);
  8972. sp_3072_mul_d_56(t2, sd, r1);
  8973. sp_3072_sub_56(t1, t1, t2);
  8974. XMEMCPY(r, t1, sizeof(*r) * 112U);
  8975. for (i=0; i<54; i++) {
  8976. r[i+1] += r[i] >> 28;
  8977. r[i] &= 0xfffffff;
  8978. }
  8979. sp_3072_cond_add_56(r, r, sd, r[54] >> 31);
  8980. sp_3072_norm_55(r);
  8981. sp_3072_rshift_56(r, r, 4);
  8982. r[55] = 0;
  8983. }
  8984. #ifdef WOLFSSL_SP_SMALL_STACK
  8985. if (t1 != NULL)
  8986. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  8987. #endif
  8988. return err;
  8989. }
  8990. /* Reduce a modulo m into r. (r = a mod m)
  8991. *
  8992. * r A single precision number that is the reduced result.
  8993. * a A single precision number that is to be reduced.
  8994. * m A single precision number that is the modulus to reduce with.
  8995. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  8996. */
  8997. static int sp_3072_mod_56(sp_digit* r, const sp_digit* a, const sp_digit* m)
  8998. {
  8999. return sp_3072_div_56(a, m, NULL, r);
  9000. }
  9001. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  9002. *
  9003. * r A single precision number that is the result of the operation.
  9004. * a A single precision number being exponentiated.
  9005. * e A single precision number that is the exponent.
  9006. * bits The number of bits in the exponent.
  9007. * m A single precision number that is the modulus.
  9008. * returns 0 on success.
  9009. * returns MEMORY_E on dynamic memory allocation failure.
  9010. * returns MP_VAL when base is even or exponent is 0.
  9011. */
  9012. static int sp_3072_mod_exp_56(sp_digit* r, const sp_digit* a, const sp_digit* e,
  9013. int bits, const sp_digit* m, int reduceA)
  9014. {
  9015. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  9016. #ifdef WOLFSSL_SP_SMALL_STACK
  9017. sp_digit* td = NULL;
  9018. #else
  9019. sp_digit td[3 * 112];
  9020. #endif
  9021. sp_digit* t[3] = {0, 0, 0};
  9022. sp_digit* norm = NULL;
  9023. sp_digit mp = 1;
  9024. sp_digit n;
  9025. int i;
  9026. int c;
  9027. byte y;
  9028. int err = MP_OKAY;
  9029. if (bits == 0) {
  9030. err = MP_VAL;
  9031. }
  9032. #ifdef WOLFSSL_SP_SMALL_STACK
  9033. if (err == MP_OKAY) {
  9034. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 56 * 2, NULL,
  9035. DYNAMIC_TYPE_TMP_BUFFER);
  9036. if (td == NULL)
  9037. err = MEMORY_E;
  9038. }
  9039. #endif
  9040. if (err == MP_OKAY) {
  9041. norm = td;
  9042. for (i=0; i<3; i++) {
  9043. t[i] = td + (i * 56 * 2);
  9044. XMEMSET(t[i], 0, sizeof(sp_digit) * 56U * 2U);
  9045. }
  9046. sp_3072_mont_setup(m, &mp);
  9047. sp_3072_mont_norm_56(norm, m);
  9048. if (reduceA != 0) {
  9049. err = sp_3072_mod_56(t[1], a, m);
  9050. }
  9051. else {
  9052. XMEMCPY(t[1], a, sizeof(sp_digit) * 56U);
  9053. }
  9054. }
  9055. if (err == MP_OKAY) {
  9056. sp_3072_mul_56(t[1], t[1], norm);
  9057. err = sp_3072_mod_56(t[1], t[1], m);
  9058. }
  9059. if (err == MP_OKAY) {
  9060. i = bits / 28;
  9061. c = bits % 28;
  9062. n = e[i--] << (28 - c);
  9063. for (; ; c--) {
  9064. if (c == 0) {
  9065. if (i == -1) {
  9066. break;
  9067. }
  9068. n = e[i--];
  9069. c = 28;
  9070. }
  9071. y = (int)((n >> 27) & 1);
  9072. n <<= 1;
  9073. sp_3072_mont_mul_56(t[y^1], t[0], t[1], m, mp);
  9074. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  9075. ((size_t)t[1] & addr_mask[y])),
  9076. sizeof(*t[2]) * 56 * 2);
  9077. sp_3072_mont_sqr_56(t[2], t[2], m, mp);
  9078. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  9079. ((size_t)t[1] & addr_mask[y])), t[2],
  9080. sizeof(*t[2]) * 56 * 2);
  9081. }
  9082. sp_3072_mont_reduce_56(t[0], m, mp);
  9083. n = sp_3072_cmp_56(t[0], m);
  9084. sp_3072_cond_sub_56(t[0], t[0], m, ~(n >> 31));
  9085. XMEMCPY(r, t[0], sizeof(*r) * 56 * 2);
  9086. }
  9087. #ifdef WOLFSSL_SP_SMALL_STACK
  9088. if (td != NULL)
  9089. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  9090. #endif
  9091. return err;
  9092. #elif !defined(WC_NO_CACHE_RESISTANT)
  9093. #ifdef WOLFSSL_SP_SMALL_STACK
  9094. sp_digit* td = NULL;
  9095. #else
  9096. sp_digit td[3 * 112];
  9097. #endif
  9098. sp_digit* t[3] = {0, 0, 0};
  9099. sp_digit* norm = NULL;
  9100. sp_digit mp = 1;
  9101. sp_digit n;
  9102. int i;
  9103. int c;
  9104. byte y;
  9105. int err = MP_OKAY;
  9106. if (bits == 0) {
  9107. err = MP_VAL;
  9108. }
  9109. #ifdef WOLFSSL_SP_SMALL_STACK
  9110. if (err == MP_OKAY) {
  9111. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 56 * 2, NULL,
  9112. DYNAMIC_TYPE_TMP_BUFFER);
  9113. if (td == NULL)
  9114. err = MEMORY_E;
  9115. }
  9116. #endif
  9117. if (err == MP_OKAY) {
  9118. norm = td;
  9119. for (i=0; i<3; i++) {
  9120. t[i] = td + (i * 56 * 2);
  9121. }
  9122. sp_3072_mont_setup(m, &mp);
  9123. sp_3072_mont_norm_56(norm, m);
  9124. if (reduceA != 0) {
  9125. err = sp_3072_mod_56(t[1], a, m);
  9126. if (err == MP_OKAY) {
  9127. sp_3072_mul_56(t[1], t[1], norm);
  9128. err = sp_3072_mod_56(t[1], t[1], m);
  9129. }
  9130. }
  9131. else {
  9132. sp_3072_mul_56(t[1], a, norm);
  9133. err = sp_3072_mod_56(t[1], t[1], m);
  9134. }
  9135. }
  9136. if (err == MP_OKAY) {
  9137. i = bits / 28;
  9138. c = bits % 28;
  9139. n = e[i--] << (28 - c);
  9140. for (; ; c--) {
  9141. if (c == 0) {
  9142. if (i == -1) {
  9143. break;
  9144. }
  9145. n = e[i--];
  9146. c = 28;
  9147. }
  9148. y = (int)((n >> 27) & 1);
  9149. n <<= 1;
  9150. sp_3072_mont_mul_56(t[y^1], t[0], t[1], m, mp);
  9151. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  9152. ((size_t)t[1] & addr_mask[y])),
  9153. sizeof(*t[2]) * 56 * 2);
  9154. sp_3072_mont_sqr_56(t[2], t[2], m, mp);
  9155. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  9156. ((size_t)t[1] & addr_mask[y])), t[2],
  9157. sizeof(*t[2]) * 56 * 2);
  9158. }
  9159. sp_3072_mont_reduce_56(t[0], m, mp);
  9160. n = sp_3072_cmp_56(t[0], m);
  9161. sp_3072_cond_sub_56(t[0], t[0], m, ~(n >> 31));
  9162. XMEMCPY(r, t[0], sizeof(*r) * 56 * 2);
  9163. }
  9164. #ifdef WOLFSSL_SP_SMALL_STACK
  9165. if (td != NULL)
  9166. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  9167. #endif
  9168. return err;
  9169. #else
  9170. #ifdef WOLFSSL_SP_SMALL_STACK
  9171. sp_digit* td = NULL;
  9172. #else
  9173. sp_digit td[(32 * 112) + 112];
  9174. #endif
  9175. sp_digit* t[32];
  9176. sp_digit* rt = NULL;
  9177. sp_digit* norm = NULL;
  9178. sp_digit mp = 1;
  9179. sp_digit n;
  9180. int i;
  9181. int c;
  9182. byte y;
  9183. int err = MP_OKAY;
  9184. if (bits == 0) {
  9185. err = MP_VAL;
  9186. }
  9187. #ifdef WOLFSSL_SP_SMALL_STACK
  9188. if (err == MP_OKAY) {
  9189. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((32 * 112) + 112), NULL,
  9190. DYNAMIC_TYPE_TMP_BUFFER);
  9191. if (td == NULL)
  9192. err = MEMORY_E;
  9193. }
  9194. #endif
  9195. if (err == MP_OKAY) {
  9196. norm = td;
  9197. for (i=0; i<32; i++)
  9198. t[i] = td + i * 112;
  9199. rt = td + 3584;
  9200. sp_3072_mont_setup(m, &mp);
  9201. sp_3072_mont_norm_56(norm, m);
  9202. if (reduceA != 0) {
  9203. err = sp_3072_mod_56(t[1], a, m);
  9204. if (err == MP_OKAY) {
  9205. sp_3072_mul_56(t[1], t[1], norm);
  9206. err = sp_3072_mod_56(t[1], t[1], m);
  9207. }
  9208. }
  9209. else {
  9210. sp_3072_mul_56(t[1], a, norm);
  9211. err = sp_3072_mod_56(t[1], t[1], m);
  9212. }
  9213. }
  9214. if (err == MP_OKAY) {
  9215. sp_3072_mont_sqr_56(t[ 2], t[ 1], m, mp);
  9216. sp_3072_mont_mul_56(t[ 3], t[ 2], t[ 1], m, mp);
  9217. sp_3072_mont_sqr_56(t[ 4], t[ 2], m, mp);
  9218. sp_3072_mont_mul_56(t[ 5], t[ 3], t[ 2], m, mp);
  9219. sp_3072_mont_sqr_56(t[ 6], t[ 3], m, mp);
  9220. sp_3072_mont_mul_56(t[ 7], t[ 4], t[ 3], m, mp);
  9221. sp_3072_mont_sqr_56(t[ 8], t[ 4], m, mp);
  9222. sp_3072_mont_mul_56(t[ 9], t[ 5], t[ 4], m, mp);
  9223. sp_3072_mont_sqr_56(t[10], t[ 5], m, mp);
  9224. sp_3072_mont_mul_56(t[11], t[ 6], t[ 5], m, mp);
  9225. sp_3072_mont_sqr_56(t[12], t[ 6], m, mp);
  9226. sp_3072_mont_mul_56(t[13], t[ 7], t[ 6], m, mp);
  9227. sp_3072_mont_sqr_56(t[14], t[ 7], m, mp);
  9228. sp_3072_mont_mul_56(t[15], t[ 8], t[ 7], m, mp);
  9229. sp_3072_mont_sqr_56(t[16], t[ 8], m, mp);
  9230. sp_3072_mont_mul_56(t[17], t[ 9], t[ 8], m, mp);
  9231. sp_3072_mont_sqr_56(t[18], t[ 9], m, mp);
  9232. sp_3072_mont_mul_56(t[19], t[10], t[ 9], m, mp);
  9233. sp_3072_mont_sqr_56(t[20], t[10], m, mp);
  9234. sp_3072_mont_mul_56(t[21], t[11], t[10], m, mp);
  9235. sp_3072_mont_sqr_56(t[22], t[11], m, mp);
  9236. sp_3072_mont_mul_56(t[23], t[12], t[11], m, mp);
  9237. sp_3072_mont_sqr_56(t[24], t[12], m, mp);
  9238. sp_3072_mont_mul_56(t[25], t[13], t[12], m, mp);
  9239. sp_3072_mont_sqr_56(t[26], t[13], m, mp);
  9240. sp_3072_mont_mul_56(t[27], t[14], t[13], m, mp);
  9241. sp_3072_mont_sqr_56(t[28], t[14], m, mp);
  9242. sp_3072_mont_mul_56(t[29], t[15], t[14], m, mp);
  9243. sp_3072_mont_sqr_56(t[30], t[15], m, mp);
  9244. sp_3072_mont_mul_56(t[31], t[16], t[15], m, mp);
  9245. bits = ((bits + 4) / 5) * 5;
  9246. i = ((bits + 27) / 28) - 1;
  9247. c = bits % 28;
  9248. if (c == 0) {
  9249. c = 28;
  9250. }
  9251. if (i < 56) {
  9252. n = e[i--] << (32 - c);
  9253. }
  9254. else {
  9255. n = 0;
  9256. i--;
  9257. }
  9258. if (c < 5) {
  9259. n |= e[i--] << (4 - c);
  9260. c += 28;
  9261. }
  9262. y = (int)((n >> 27) & 0x1f);
  9263. n <<= 5;
  9264. c -= 5;
  9265. XMEMCPY(rt, t[y], sizeof(sp_digit) * 112);
  9266. while ((i >= 0) || (c >= 5)) {
  9267. if (c >= 5) {
  9268. y = (byte)((n >> 27) & 0x1f);
  9269. n <<= 5;
  9270. c -= 5;
  9271. }
  9272. else if (c == 0) {
  9273. n = e[i--] << 4;
  9274. y = (byte)((n >> 27) & 0x1f);
  9275. n <<= 5;
  9276. c = 23;
  9277. }
  9278. else {
  9279. y = (byte)((n >> 27) & 0x1f);
  9280. n = e[i--] << 4;
  9281. c = 5 - c;
  9282. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  9283. n <<= c;
  9284. c = 28 - c;
  9285. }
  9286. sp_3072_mont_sqr_56(rt, rt, m, mp);
  9287. sp_3072_mont_sqr_56(rt, rt, m, mp);
  9288. sp_3072_mont_sqr_56(rt, rt, m, mp);
  9289. sp_3072_mont_sqr_56(rt, rt, m, mp);
  9290. sp_3072_mont_sqr_56(rt, rt, m, mp);
  9291. sp_3072_mont_mul_56(rt, rt, t[y], m, mp);
  9292. }
  9293. sp_3072_mont_reduce_56(rt, m, mp);
  9294. n = sp_3072_cmp_56(rt, m);
  9295. sp_3072_cond_sub_56(rt, rt, m, ~(n >> 31));
  9296. XMEMCPY(r, rt, sizeof(sp_digit) * 112);
  9297. }
  9298. #ifdef WOLFSSL_SP_SMALL_STACK
  9299. if (td != NULL)
  9300. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  9301. #endif
  9302. return err;
  9303. #endif
  9304. }
  9305. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) | WOLFSSL_HAVE_SP_DH */
  9306. /* r = 2^n mod m where n is the number of bits to reduce by.
  9307. * Given m must be 3072 bits, just need to subtract.
  9308. *
  9309. * r A single precision number.
  9310. * m A single precision number.
  9311. */
  9312. static void sp_3072_mont_norm_112(sp_digit* r, const sp_digit* m)
  9313. {
  9314. /* Set r = 2^n - 1. */
  9315. int i;
  9316. for (i = 0; i < 104; i += 8) {
  9317. r[i + 0] = 0xfffffff;
  9318. r[i + 1] = 0xfffffff;
  9319. r[i + 2] = 0xfffffff;
  9320. r[i + 3] = 0xfffffff;
  9321. r[i + 4] = 0xfffffff;
  9322. r[i + 5] = 0xfffffff;
  9323. r[i + 6] = 0xfffffff;
  9324. r[i + 7] = 0xfffffff;
  9325. }
  9326. r[104] = 0xfffffff;
  9327. r[105] = 0xfffffff;
  9328. r[106] = 0xfffffff;
  9329. r[107] = 0xfffffff;
  9330. r[108] = 0xfffffff;
  9331. r[109] = 0xfffffL;
  9332. r[110] = 0;
  9333. r[111] = 0;
  9334. /* r = (2^n - 1) mod n */
  9335. (void)sp_3072_sub_112(r, r, m);
  9336. /* Add one so r = 2^n mod m */
  9337. r[0] += 1;
  9338. }
  9339. /* Compare a with b in constant time.
  9340. *
  9341. * a A single precision integer.
  9342. * b A single precision integer.
  9343. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  9344. * respectively.
  9345. */
  9346. static sp_digit sp_3072_cmp_112(const sp_digit* a, const sp_digit* b)
  9347. {
  9348. sp_digit r = 0;
  9349. int i;
  9350. for (i = 104; i >= 0; i -= 8) {
  9351. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 27);
  9352. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 27);
  9353. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 27);
  9354. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 27);
  9355. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 27);
  9356. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 27);
  9357. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 27);
  9358. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 27);
  9359. }
  9360. return r;
  9361. }
  9362. /* Conditionally subtract b from a using the mask m.
  9363. * m is -1 to subtract and 0 when not.
  9364. *
  9365. * r A single precision number representing condition subtract result.
  9366. * a A single precision number to subtract from.
  9367. * b A single precision number to subtract.
  9368. * m Mask value to apply.
  9369. */
  9370. static void sp_3072_cond_sub_112(sp_digit* r, const sp_digit* a,
  9371. const sp_digit* b, const sp_digit m)
  9372. {
  9373. int i;
  9374. for (i = 0; i < 112; i += 8) {
  9375. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  9376. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  9377. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  9378. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  9379. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  9380. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  9381. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  9382. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  9383. }
  9384. }
  9385. /* Mul a by scalar b and add into r. (r += a * b)
  9386. *
  9387. * r A single precision integer.
  9388. * a A single precision integer.
  9389. * b A scalar.
  9390. */
  9391. SP_NOINLINE static void sp_3072_mul_add_112(sp_digit* r, const sp_digit* a,
  9392. const sp_digit b)
  9393. {
  9394. #ifndef WOLFSSL_SP_LARGE_CODE
  9395. sp_int64 tb = b;
  9396. sp_int64 t = 0;
  9397. int i;
  9398. for (i = 0; i < 112; i++) {
  9399. t += r[i];
  9400. t += tb * a[i];
  9401. r[i] = ((sp_digit)t) & 0xfffffff;
  9402. t >>= 28;
  9403. }
  9404. r[112] += (sp_digit)t;
  9405. #else
  9406. sp_int64 tb = b;
  9407. sp_int64 t[8];
  9408. int i;
  9409. t[0] = 0;
  9410. for (i = 0; i < 104; i += 8) {
  9411. t[0] += (tb * a[i+0]) + r[i+0];
  9412. t[1] = (tb * a[i+1]) + r[i+1];
  9413. t[2] = (tb * a[i+2]) + r[i+2];
  9414. t[3] = (tb * a[i+3]) + r[i+3];
  9415. t[4] = (tb * a[i+4]) + r[i+4];
  9416. t[5] = (tb * a[i+5]) + r[i+5];
  9417. t[6] = (tb * a[i+6]) + r[i+6];
  9418. t[7] = (tb * a[i+7]) + r[i+7];
  9419. r[i+0] = t[0] & 0xfffffff;
  9420. t[1] += t[0] >> 28;
  9421. r[i+1] = t[1] & 0xfffffff;
  9422. t[2] += t[1] >> 28;
  9423. r[i+2] = t[2] & 0xfffffff;
  9424. t[3] += t[2] >> 28;
  9425. r[i+3] = t[3] & 0xfffffff;
  9426. t[4] += t[3] >> 28;
  9427. r[i+4] = t[4] & 0xfffffff;
  9428. t[5] += t[4] >> 28;
  9429. r[i+5] = t[5] & 0xfffffff;
  9430. t[6] += t[5] >> 28;
  9431. r[i+6] = t[6] & 0xfffffff;
  9432. t[7] += t[6] >> 28;
  9433. r[i+7] = t[7] & 0xfffffff;
  9434. t[0] = t[7] >> 28;
  9435. }
  9436. t[0] += (tb * a[104]) + r[104];
  9437. t[1] = (tb * a[105]) + r[105];
  9438. t[2] = (tb * a[106]) + r[106];
  9439. t[3] = (tb * a[107]) + r[107];
  9440. t[4] = (tb * a[108]) + r[108];
  9441. t[5] = (tb * a[109]) + r[109];
  9442. t[6] = (tb * a[110]) + r[110];
  9443. t[7] = (tb * a[111]) + r[111];
  9444. r[104] = t[0] & 0xfffffff;
  9445. t[1] += t[0] >> 28;
  9446. r[105] = t[1] & 0xfffffff;
  9447. t[2] += t[1] >> 28;
  9448. r[106] = t[2] & 0xfffffff;
  9449. t[3] += t[2] >> 28;
  9450. r[107] = t[3] & 0xfffffff;
  9451. t[4] += t[3] >> 28;
  9452. r[108] = t[4] & 0xfffffff;
  9453. t[5] += t[4] >> 28;
  9454. r[109] = t[5] & 0xfffffff;
  9455. t[6] += t[5] >> 28;
  9456. r[110] = t[6] & 0xfffffff;
  9457. t[7] += t[6] >> 28;
  9458. r[111] = t[7] & 0xfffffff;
  9459. r[112] += (sp_digit)(t[7] >> 28);
  9460. #endif /* !WOLFSSL_SP_LARGE_CODE */
  9461. }
  9462. /* Shift the result in the high 3072 bits down to the bottom.
  9463. *
  9464. * r A single precision number.
  9465. * a A single precision number.
  9466. */
  9467. static void sp_3072_mont_shift_112(sp_digit* r, const sp_digit* a)
  9468. {
  9469. int i;
  9470. sp_int64 n = a[109] >> 20;
  9471. n += ((sp_int64)a[110]) << 8;
  9472. for (i = 0; i < 104; i += 8) {
  9473. r[i + 0] = n & 0xfffffff;
  9474. n >>= 28; n += ((sp_int64)a[i + 111]) << 8;
  9475. r[i + 1] = n & 0xfffffff;
  9476. n >>= 28; n += ((sp_int64)a[i + 112]) << 8;
  9477. r[i + 2] = n & 0xfffffff;
  9478. n >>= 28; n += ((sp_int64)a[i + 113]) << 8;
  9479. r[i + 3] = n & 0xfffffff;
  9480. n >>= 28; n += ((sp_int64)a[i + 114]) << 8;
  9481. r[i + 4] = n & 0xfffffff;
  9482. n >>= 28; n += ((sp_int64)a[i + 115]) << 8;
  9483. r[i + 5] = n & 0xfffffff;
  9484. n >>= 28; n += ((sp_int64)a[i + 116]) << 8;
  9485. r[i + 6] = n & 0xfffffff;
  9486. n >>= 28; n += ((sp_int64)a[i + 117]) << 8;
  9487. r[i + 7] = n & 0xfffffff;
  9488. n >>= 28; n += ((sp_int64)a[i + 118]) << 8;
  9489. }
  9490. r[104] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[215]) << 8;
  9491. r[105] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[216]) << 8;
  9492. r[106] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[217]) << 8;
  9493. r[107] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[218]) << 8;
  9494. r[108] = n & 0xfffffff; n >>= 28; n += ((sp_int64)a[219]) << 8;
  9495. r[109] = (sp_digit)n;
  9496. XMEMSET(&r[110], 0, sizeof(*r) * 110U);
  9497. }
  9498. /* Reduce the number back to 3072 bits using Montgomery reduction.
  9499. *
  9500. * a A single precision number to reduce in place.
  9501. * m The single precision number representing the modulus.
  9502. * mp The digit representing the negative inverse of m mod 2^n.
  9503. */
  9504. static void sp_3072_mont_reduce_112(sp_digit* a, const sp_digit* m, sp_digit mp)
  9505. {
  9506. int i;
  9507. sp_digit mu;
  9508. sp_digit over;
  9509. sp_3072_norm_112(a + 110);
  9510. #ifdef WOLFSSL_SP_DH
  9511. if (mp != 1) {
  9512. for (i=0; i<109; i++) {
  9513. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffff;
  9514. sp_3072_mul_add_112(a+i, m, mu);
  9515. a[i+1] += a[i] >> 28;
  9516. }
  9517. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffL;
  9518. sp_3072_mul_add_112(a+i, m, mu);
  9519. a[i+1] += a[i] >> 28;
  9520. a[i] &= 0xfffffff;
  9521. }
  9522. else {
  9523. for (i=0; i<109; i++) {
  9524. mu = a[i] & 0xfffffff;
  9525. sp_3072_mul_add_112(a+i, m, mu);
  9526. a[i+1] += a[i] >> 28;
  9527. }
  9528. mu = a[i] & 0xfffffL;
  9529. sp_3072_mul_add_112(a+i, m, mu);
  9530. a[i+1] += a[i] >> 28;
  9531. a[i] &= 0xfffffff;
  9532. }
  9533. #else
  9534. for (i=0; i<109; i++) {
  9535. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffff;
  9536. sp_3072_mul_add_112(a+i, m, mu);
  9537. a[i+1] += a[i] >> 28;
  9538. }
  9539. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffL;
  9540. sp_3072_mul_add_112(a+i, m, mu);
  9541. a[i+1] += a[i] >> 28;
  9542. a[i] &= 0xfffffff;
  9543. #endif
  9544. sp_3072_mont_shift_112(a, a);
  9545. over = a[109] - m[109];
  9546. sp_3072_cond_sub_112(a, a, m, ~((over - 1) >> 31));
  9547. sp_3072_norm_112(a);
  9548. }
  9549. /* Multiply two Montgomery form numbers mod the modulus (prime).
  9550. * (r = a * b mod m)
  9551. *
  9552. * r Result of multiplication.
  9553. * a First number to multiply in Montgomery form.
  9554. * b Second number to multiply in Montgomery form.
  9555. * m Modulus (prime).
  9556. * mp Montgomery multiplier.
  9557. */
  9558. SP_NOINLINE static void sp_3072_mont_mul_112(sp_digit* r, const sp_digit* a,
  9559. const sp_digit* b, const sp_digit* m, sp_digit mp)
  9560. {
  9561. sp_3072_mul_112(r, a, b);
  9562. sp_3072_mont_reduce_112(r, m, mp);
  9563. }
  9564. /* Square the Montgomery form number. (r = a * a mod m)
  9565. *
  9566. * r Result of squaring.
  9567. * a Number to square in Montgomery form.
  9568. * m Modulus (prime).
  9569. * mp Montgomery multiplier.
  9570. */
  9571. SP_NOINLINE static void sp_3072_mont_sqr_112(sp_digit* r, const sp_digit* a,
  9572. const sp_digit* m, sp_digit mp)
  9573. {
  9574. sp_3072_sqr_112(r, a);
  9575. sp_3072_mont_reduce_112(r, m, mp);
  9576. }
  9577. /* Multiply a by scalar b into r. (r = a * b)
  9578. *
  9579. * r A single precision integer.
  9580. * a A single precision integer.
  9581. * b A scalar.
  9582. */
  9583. SP_NOINLINE static void sp_3072_mul_d_224(sp_digit* r, const sp_digit* a,
  9584. sp_digit b)
  9585. {
  9586. sp_int64 tb = b;
  9587. sp_int64 t = 0;
  9588. sp_digit t2;
  9589. sp_int64 p[4];
  9590. int i;
  9591. for (i = 0; i < 224; i += 4) {
  9592. p[0] = tb * a[i + 0];
  9593. p[1] = tb * a[i + 1];
  9594. p[2] = tb * a[i + 2];
  9595. p[3] = tb * a[i + 3];
  9596. t += p[0];
  9597. t2 = (sp_digit)(t & 0xfffffff);
  9598. t >>= 28;
  9599. r[i + 0] = (sp_digit)t2;
  9600. t += p[1];
  9601. t2 = (sp_digit)(t & 0xfffffff);
  9602. t >>= 28;
  9603. r[i + 1] = (sp_digit)t2;
  9604. t += p[2];
  9605. t2 = (sp_digit)(t & 0xfffffff);
  9606. t >>= 28;
  9607. r[i + 2] = (sp_digit)t2;
  9608. t += p[3];
  9609. t2 = (sp_digit)(t & 0xfffffff);
  9610. t >>= 28;
  9611. r[i + 3] = (sp_digit)t2;
  9612. }
  9613. r[224] = (sp_digit)(t & 0xfffffff);
  9614. }
  9615. #ifndef WOLFSSL_SP_SMALL
  9616. /* Conditionally add a and b using the mask m.
  9617. * m is -1 to add and 0 when not.
  9618. *
  9619. * r A single precision number representing conditional add result.
  9620. * a A single precision number to add with.
  9621. * b A single precision number to add.
  9622. * m Mask value to apply.
  9623. */
  9624. static void sp_3072_cond_add_112(sp_digit* r, const sp_digit* a,
  9625. const sp_digit* b, const sp_digit m)
  9626. {
  9627. int i;
  9628. for (i = 0; i < 112; i += 8) {
  9629. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  9630. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  9631. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  9632. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  9633. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  9634. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  9635. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  9636. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  9637. }
  9638. }
  9639. #endif /* !WOLFSSL_SP_SMALL */
  9640. SP_NOINLINE static void sp_3072_rshift_112(sp_digit* r, const sp_digit* a,
  9641. byte n)
  9642. {
  9643. int i;
  9644. for (i=0; i<104; i += 8) {
  9645. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (28 - n)) & 0xfffffff);
  9646. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (28 - n)) & 0xfffffff);
  9647. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (28 - n)) & 0xfffffff);
  9648. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (28 - n)) & 0xfffffff);
  9649. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (28 - n)) & 0xfffffff);
  9650. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (28 - n)) & 0xfffffff);
  9651. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (28 - n)) & 0xfffffff);
  9652. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (28 - n)) & 0xfffffff);
  9653. }
  9654. r[104] = (a[104] >> n) | ((a[105] << (28 - n)) & 0xfffffff);
  9655. r[105] = (a[105] >> n) | ((a[106] << (28 - n)) & 0xfffffff);
  9656. r[106] = (a[106] >> n) | ((a[107] << (28 - n)) & 0xfffffff);
  9657. r[107] = (a[107] >> n) | ((a[108] << (28 - n)) & 0xfffffff);
  9658. r[108] = (a[108] >> n) | ((a[109] << (28 - n)) & 0xfffffff);
  9659. r[109] = (a[109] >> n) | ((a[110] << (28 - n)) & 0xfffffff);
  9660. r[110] = (a[110] >> n) | ((a[111] << (28 - n)) & 0xfffffff);
  9661. r[111] = a[111] >> n;
  9662. }
  9663. static WC_INLINE sp_digit sp_3072_div_word_112(sp_digit d1, sp_digit d0,
  9664. sp_digit div)
  9665. {
  9666. #ifdef SP_USE_DIVTI3
  9667. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  9668. return d / div;
  9669. #elif defined(__x86_64__) || defined(__i386__)
  9670. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  9671. sp_uint32 lo = (sp_uint32)d;
  9672. sp_digit hi = (sp_digit)(d >> 32);
  9673. __asm__ __volatile__ (
  9674. "idiv %2"
  9675. : "+a" (lo)
  9676. : "d" (hi), "r" (div)
  9677. : "cc"
  9678. );
  9679. return (sp_digit)lo;
  9680. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  9681. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  9682. sp_digit dv = (div >> 1) + 1;
  9683. sp_digit t1 = (sp_digit)(d >> 28);
  9684. sp_digit t0 = (sp_digit)(d & 0xfffffff);
  9685. sp_digit t2;
  9686. sp_digit sign;
  9687. sp_digit r;
  9688. int i;
  9689. sp_int64 m;
  9690. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  9691. t1 -= dv & (0 - r);
  9692. for (i = 26; i >= 1; i--) {
  9693. t1 += t1 + (((sp_uint32)t0 >> 27) & 1);
  9694. t0 <<= 1;
  9695. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  9696. r += r + t2;
  9697. t1 -= dv & (0 - t2);
  9698. t1 += t2;
  9699. }
  9700. r += r + 1;
  9701. m = d - ((sp_int64)r * div);
  9702. r += (sp_digit)(m >> 28);
  9703. m = d - ((sp_int64)r * div);
  9704. r += (sp_digit)(m >> 56) - (sp_digit)(d >> 56);
  9705. m = d - ((sp_int64)r * div);
  9706. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  9707. m *= sign;
  9708. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  9709. r += sign * t2;
  9710. m = d - ((sp_int64)r * div);
  9711. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  9712. m *= sign;
  9713. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  9714. r += sign * t2;
  9715. return r;
  9716. #else
  9717. sp_int64 d = ((sp_int64)d1 << 28) + d0;
  9718. sp_digit r = 0;
  9719. sp_digit t;
  9720. sp_digit dv = (div >> 13) + 1;
  9721. t = (sp_digit)(d >> 26);
  9722. t = (t / dv) << 13;
  9723. r += t;
  9724. d -= (sp_int64)t * div;
  9725. t = (sp_digit)(d >> 11);
  9726. t = t / (dv << 2);
  9727. r += t;
  9728. d -= (sp_int64)t * div;
  9729. t = (sp_digit)d;
  9730. t = t / div;
  9731. r += t;
  9732. d -= (sp_int64)t * div;
  9733. return r;
  9734. #endif
  9735. }
  9736. static WC_INLINE sp_digit sp_3072_word_div_word_112(sp_digit d, sp_digit div)
  9737. {
  9738. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  9739. defined(SP_DIV_WORD_USE_DIV)
  9740. return d / div;
  9741. #else
  9742. return (sp_digit)((sp_uint32)(div - d) >> 31);
  9743. #endif
  9744. }
  9745. /* Divide d in a and put remainder into r (m*d + r = a)
  9746. * m is not calculated as it is not needed at this time.
  9747. *
  9748. * Full implementation.
  9749. *
  9750. * a Number to be divided.
  9751. * d Number to divide with.
  9752. * m Multiplier result.
  9753. * r Remainder from the division.
  9754. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  9755. */
  9756. static int sp_3072_div_112(const sp_digit* a, const sp_digit* d,
  9757. const sp_digit* m, sp_digit* r)
  9758. {
  9759. int i;
  9760. #ifndef WOLFSSL_SP_DIV_32
  9761. #endif
  9762. sp_digit dv;
  9763. sp_digit r1;
  9764. #ifdef WOLFSSL_SP_SMALL_STACK
  9765. sp_digit* t1 = NULL;
  9766. #else
  9767. sp_digit t1[4 * 112 + 3];
  9768. #endif
  9769. sp_digit* t2 = NULL;
  9770. sp_digit* sd = NULL;
  9771. int err = MP_OKAY;
  9772. (void)m;
  9773. #ifdef WOLFSSL_SP_SMALL_STACK
  9774. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 112 + 3), NULL,
  9775. DYNAMIC_TYPE_TMP_BUFFER);
  9776. if (t1 == NULL)
  9777. err = MEMORY_E;
  9778. #endif
  9779. (void)m;
  9780. if (err == MP_OKAY) {
  9781. t2 = t1 + 224 + 1;
  9782. sd = t2 + 112 + 1;
  9783. sp_3072_mul_d_112(sd, d, (sp_digit)1 << 8);
  9784. sp_3072_mul_d_224(t1, a, (sp_digit)1 << 8);
  9785. dv = sd[109];
  9786. t1[110 + 110] += t1[110 + 110 - 1] >> 28;
  9787. t1[110 + 110 - 1] &= 0xfffffff;
  9788. for (i=110; i>=0; i--) {
  9789. r1 = sp_3072_div_word_112(t1[110 + i], t1[110 + i - 1], dv);
  9790. sp_3072_mul_d_112(t2, sd, r1);
  9791. (void)sp_3072_sub_112(&t1[i], &t1[i], t2);
  9792. sp_3072_norm_110(&t1[i]);
  9793. t1[110 + i] += t1[110 + i - 1] >> 28;
  9794. t1[110 + i - 1] &= 0xfffffff;
  9795. r1 = sp_3072_div_word_112(-t1[110 + i], -t1[110 + i - 1], dv);
  9796. r1 -= t1[110 + i];
  9797. sp_3072_mul_d_112(t2, sd, r1);
  9798. (void)sp_3072_add_112(&t1[i], &t1[i], t2);
  9799. t1[110 + i] += t1[110 + i - 1] >> 28;
  9800. t1[110 + i - 1] &= 0xfffffff;
  9801. }
  9802. t1[110 - 1] += t1[110 - 2] >> 28;
  9803. t1[110 - 2] &= 0xfffffff;
  9804. r1 = sp_3072_word_div_word_112(t1[110 - 1], dv);
  9805. sp_3072_mul_d_112(t2, sd, r1);
  9806. sp_3072_sub_112(t1, t1, t2);
  9807. XMEMCPY(r, t1, sizeof(*r) * 224U);
  9808. for (i=0; i<109; i++) {
  9809. r[i+1] += r[i] >> 28;
  9810. r[i] &= 0xfffffff;
  9811. }
  9812. sp_3072_cond_add_112(r, r, sd, r[109] >> 31);
  9813. sp_3072_norm_110(r);
  9814. sp_3072_rshift_112(r, r, 8);
  9815. r[110] = 0;
  9816. r[111] = 0;
  9817. }
  9818. #ifdef WOLFSSL_SP_SMALL_STACK
  9819. if (t1 != NULL)
  9820. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  9821. #endif
  9822. return err;
  9823. }
  9824. /* Reduce a modulo m into r. (r = a mod m)
  9825. *
  9826. * r A single precision number that is the reduced result.
  9827. * a A single precision number that is to be reduced.
  9828. * m A single precision number that is the modulus to reduce with.
  9829. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  9830. */
  9831. static int sp_3072_mod_112(sp_digit* r, const sp_digit* a, const sp_digit* m)
  9832. {
  9833. return sp_3072_div_112(a, m, NULL, r);
  9834. }
  9835. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  9836. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
  9837. defined(WOLFSSL_HAVE_SP_DH)
  9838. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  9839. *
  9840. * r A single precision number that is the result of the operation.
  9841. * a A single precision number being exponentiated.
  9842. * e A single precision number that is the exponent.
  9843. * bits The number of bits in the exponent.
  9844. * m A single precision number that is the modulus.
  9845. * returns 0 on success.
  9846. * returns MEMORY_E on dynamic memory allocation failure.
  9847. * returns MP_VAL when base is even or exponent is 0.
  9848. */
  9849. static int sp_3072_mod_exp_112(sp_digit* r, const sp_digit* a, const sp_digit* e,
  9850. int bits, const sp_digit* m, int reduceA)
  9851. {
  9852. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  9853. #ifdef WOLFSSL_SP_SMALL_STACK
  9854. sp_digit* td = NULL;
  9855. #else
  9856. sp_digit td[3 * 224];
  9857. #endif
  9858. sp_digit* t[3] = {0, 0, 0};
  9859. sp_digit* norm = NULL;
  9860. sp_digit mp = 1;
  9861. sp_digit n;
  9862. int i;
  9863. int c;
  9864. byte y;
  9865. int err = MP_OKAY;
  9866. if (bits == 0) {
  9867. err = MP_VAL;
  9868. }
  9869. #ifdef WOLFSSL_SP_SMALL_STACK
  9870. if (err == MP_OKAY) {
  9871. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 112 * 2, NULL,
  9872. DYNAMIC_TYPE_TMP_BUFFER);
  9873. if (td == NULL)
  9874. err = MEMORY_E;
  9875. }
  9876. #endif
  9877. if (err == MP_OKAY) {
  9878. norm = td;
  9879. for (i=0; i<3; i++) {
  9880. t[i] = td + (i * 112 * 2);
  9881. XMEMSET(t[i], 0, sizeof(sp_digit) * 112U * 2U);
  9882. }
  9883. sp_3072_mont_setup(m, &mp);
  9884. sp_3072_mont_norm_112(norm, m);
  9885. if (reduceA != 0) {
  9886. err = sp_3072_mod_112(t[1], a, m);
  9887. }
  9888. else {
  9889. XMEMCPY(t[1], a, sizeof(sp_digit) * 112U);
  9890. }
  9891. }
  9892. if (err == MP_OKAY) {
  9893. sp_3072_mul_112(t[1], t[1], norm);
  9894. err = sp_3072_mod_112(t[1], t[1], m);
  9895. }
  9896. if (err == MP_OKAY) {
  9897. i = bits / 28;
  9898. c = bits % 28;
  9899. n = e[i--] << (28 - c);
  9900. for (; ; c--) {
  9901. if (c == 0) {
  9902. if (i == -1) {
  9903. break;
  9904. }
  9905. n = e[i--];
  9906. c = 28;
  9907. }
  9908. y = (int)((n >> 27) & 1);
  9909. n <<= 1;
  9910. sp_3072_mont_mul_112(t[y^1], t[0], t[1], m, mp);
  9911. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  9912. ((size_t)t[1] & addr_mask[y])),
  9913. sizeof(*t[2]) * 112 * 2);
  9914. sp_3072_mont_sqr_112(t[2], t[2], m, mp);
  9915. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  9916. ((size_t)t[1] & addr_mask[y])), t[2],
  9917. sizeof(*t[2]) * 112 * 2);
  9918. }
  9919. sp_3072_mont_reduce_112(t[0], m, mp);
  9920. n = sp_3072_cmp_112(t[0], m);
  9921. sp_3072_cond_sub_112(t[0], t[0], m, ~(n >> 31));
  9922. XMEMCPY(r, t[0], sizeof(*r) * 112 * 2);
  9923. }
  9924. #ifdef WOLFSSL_SP_SMALL_STACK
  9925. if (td != NULL)
  9926. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  9927. #endif
  9928. return err;
  9929. #elif !defined(WC_NO_CACHE_RESISTANT)
  9930. #ifdef WOLFSSL_SP_SMALL_STACK
  9931. sp_digit* td = NULL;
  9932. #else
  9933. sp_digit td[3 * 224];
  9934. #endif
  9935. sp_digit* t[3] = {0, 0, 0};
  9936. sp_digit* norm = NULL;
  9937. sp_digit mp = 1;
  9938. sp_digit n;
  9939. int i;
  9940. int c;
  9941. byte y;
  9942. int err = MP_OKAY;
  9943. if (bits == 0) {
  9944. err = MP_VAL;
  9945. }
  9946. #ifdef WOLFSSL_SP_SMALL_STACK
  9947. if (err == MP_OKAY) {
  9948. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 112 * 2, NULL,
  9949. DYNAMIC_TYPE_TMP_BUFFER);
  9950. if (td == NULL)
  9951. err = MEMORY_E;
  9952. }
  9953. #endif
  9954. if (err == MP_OKAY) {
  9955. norm = td;
  9956. for (i=0; i<3; i++) {
  9957. t[i] = td + (i * 112 * 2);
  9958. }
  9959. sp_3072_mont_setup(m, &mp);
  9960. sp_3072_mont_norm_112(norm, m);
  9961. if (reduceA != 0) {
  9962. err = sp_3072_mod_112(t[1], a, m);
  9963. if (err == MP_OKAY) {
  9964. sp_3072_mul_112(t[1], t[1], norm);
  9965. err = sp_3072_mod_112(t[1], t[1], m);
  9966. }
  9967. }
  9968. else {
  9969. sp_3072_mul_112(t[1], a, norm);
  9970. err = sp_3072_mod_112(t[1], t[1], m);
  9971. }
  9972. }
  9973. if (err == MP_OKAY) {
  9974. i = bits / 28;
  9975. c = bits % 28;
  9976. n = e[i--] << (28 - c);
  9977. for (; ; c--) {
  9978. if (c == 0) {
  9979. if (i == -1) {
  9980. break;
  9981. }
  9982. n = e[i--];
  9983. c = 28;
  9984. }
  9985. y = (int)((n >> 27) & 1);
  9986. n <<= 1;
  9987. sp_3072_mont_mul_112(t[y^1], t[0], t[1], m, mp);
  9988. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  9989. ((size_t)t[1] & addr_mask[y])),
  9990. sizeof(*t[2]) * 112 * 2);
  9991. sp_3072_mont_sqr_112(t[2], t[2], m, mp);
  9992. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  9993. ((size_t)t[1] & addr_mask[y])), t[2],
  9994. sizeof(*t[2]) * 112 * 2);
  9995. }
  9996. sp_3072_mont_reduce_112(t[0], m, mp);
  9997. n = sp_3072_cmp_112(t[0], m);
  9998. sp_3072_cond_sub_112(t[0], t[0], m, ~(n >> 31));
  9999. XMEMCPY(r, t[0], sizeof(*r) * 112 * 2);
  10000. }
  10001. #ifdef WOLFSSL_SP_SMALL_STACK
  10002. if (td != NULL)
  10003. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  10004. #endif
  10005. return err;
  10006. #else
  10007. #ifdef WOLFSSL_SP_SMALL_STACK
  10008. sp_digit* td = NULL;
  10009. #else
  10010. sp_digit td[(16 * 224) + 224];
  10011. #endif
  10012. sp_digit* t[16];
  10013. sp_digit* rt = NULL;
  10014. sp_digit* norm = NULL;
  10015. sp_digit mp = 1;
  10016. sp_digit n;
  10017. int i;
  10018. int c;
  10019. byte y;
  10020. int err = MP_OKAY;
  10021. if (bits == 0) {
  10022. err = MP_VAL;
  10023. }
  10024. #ifdef WOLFSSL_SP_SMALL_STACK
  10025. if (err == MP_OKAY) {
  10026. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((16 * 224) + 224), NULL,
  10027. DYNAMIC_TYPE_TMP_BUFFER);
  10028. if (td == NULL)
  10029. err = MEMORY_E;
  10030. }
  10031. #endif
  10032. if (err == MP_OKAY) {
  10033. norm = td;
  10034. for (i=0; i<16; i++)
  10035. t[i] = td + i * 224;
  10036. rt = td + 3584;
  10037. sp_3072_mont_setup(m, &mp);
  10038. sp_3072_mont_norm_112(norm, m);
  10039. if (reduceA != 0) {
  10040. err = sp_3072_mod_112(t[1], a, m);
  10041. if (err == MP_OKAY) {
  10042. sp_3072_mul_112(t[1], t[1], norm);
  10043. err = sp_3072_mod_112(t[1], t[1], m);
  10044. }
  10045. }
  10046. else {
  10047. sp_3072_mul_112(t[1], a, norm);
  10048. err = sp_3072_mod_112(t[1], t[1], m);
  10049. }
  10050. }
  10051. if (err == MP_OKAY) {
  10052. sp_3072_mont_sqr_112(t[ 2], t[ 1], m, mp);
  10053. sp_3072_mont_mul_112(t[ 3], t[ 2], t[ 1], m, mp);
  10054. sp_3072_mont_sqr_112(t[ 4], t[ 2], m, mp);
  10055. sp_3072_mont_mul_112(t[ 5], t[ 3], t[ 2], m, mp);
  10056. sp_3072_mont_sqr_112(t[ 6], t[ 3], m, mp);
  10057. sp_3072_mont_mul_112(t[ 7], t[ 4], t[ 3], m, mp);
  10058. sp_3072_mont_sqr_112(t[ 8], t[ 4], m, mp);
  10059. sp_3072_mont_mul_112(t[ 9], t[ 5], t[ 4], m, mp);
  10060. sp_3072_mont_sqr_112(t[10], t[ 5], m, mp);
  10061. sp_3072_mont_mul_112(t[11], t[ 6], t[ 5], m, mp);
  10062. sp_3072_mont_sqr_112(t[12], t[ 6], m, mp);
  10063. sp_3072_mont_mul_112(t[13], t[ 7], t[ 6], m, mp);
  10064. sp_3072_mont_sqr_112(t[14], t[ 7], m, mp);
  10065. sp_3072_mont_mul_112(t[15], t[ 8], t[ 7], m, mp);
  10066. bits = ((bits + 3) / 4) * 4;
  10067. i = ((bits + 27) / 28) - 1;
  10068. c = bits % 28;
  10069. if (c == 0) {
  10070. c = 28;
  10071. }
  10072. if (i < 112) {
  10073. n = e[i--] << (32 - c);
  10074. }
  10075. else {
  10076. n = 0;
  10077. i--;
  10078. }
  10079. if (c < 4) {
  10080. n |= e[i--] << (4 - c);
  10081. c += 28;
  10082. }
  10083. y = (int)((n >> 28) & 0xf);
  10084. n <<= 4;
  10085. c -= 4;
  10086. XMEMCPY(rt, t[y], sizeof(sp_digit) * 224);
  10087. while ((i >= 0) || (c >= 4)) {
  10088. if (c >= 4) {
  10089. y = (byte)((n >> 28) & 0xf);
  10090. n <<= 4;
  10091. c -= 4;
  10092. }
  10093. else if (c == 0) {
  10094. n = e[i--] << 4;
  10095. y = (byte)((n >> 28) & 0xf);
  10096. n <<= 4;
  10097. c = 24;
  10098. }
  10099. else {
  10100. y = (byte)((n >> 28) & 0xf);
  10101. n = e[i--] << 4;
  10102. c = 4 - c;
  10103. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  10104. n <<= c;
  10105. c = 28 - c;
  10106. }
  10107. sp_3072_mont_sqr_112(rt, rt, m, mp);
  10108. sp_3072_mont_sqr_112(rt, rt, m, mp);
  10109. sp_3072_mont_sqr_112(rt, rt, m, mp);
  10110. sp_3072_mont_sqr_112(rt, rt, m, mp);
  10111. sp_3072_mont_mul_112(rt, rt, t[y], m, mp);
  10112. }
  10113. sp_3072_mont_reduce_112(rt, m, mp);
  10114. n = sp_3072_cmp_112(rt, m);
  10115. sp_3072_cond_sub_112(rt, rt, m, ~(n >> 31));
  10116. XMEMCPY(r, rt, sizeof(sp_digit) * 224);
  10117. }
  10118. #ifdef WOLFSSL_SP_SMALL_STACK
  10119. if (td != NULL)
  10120. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  10121. #endif
  10122. return err;
  10123. #endif
  10124. }
  10125. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) || */
  10126. /* WOLFSSL_HAVE_SP_DH */
  10127. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  10128. #ifdef WOLFSSL_HAVE_SP_RSA
  10129. /* RSA public key operation.
  10130. *
  10131. * in Array of bytes representing the number to exponentiate, base.
  10132. * inLen Number of bytes in base.
  10133. * em Public exponent.
  10134. * mm Modulus.
  10135. * out Buffer to hold big-endian bytes of exponentiation result.
  10136. * Must be at least 384 bytes long.
  10137. * outLen Number of bytes in result.
  10138. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  10139. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  10140. */
  10141. int sp_RsaPublic_3072(const byte* in, word32 inLen, const mp_int* em,
  10142. const mp_int* mm, byte* out, word32* outLen)
  10143. {
  10144. #ifdef WOLFSSL_SP_SMALL
  10145. #ifdef WOLFSSL_SP_SMALL_STACK
  10146. sp_digit* a = NULL;
  10147. #else
  10148. sp_digit a[112 * 5];
  10149. #endif
  10150. sp_digit* m = NULL;
  10151. sp_digit* r = NULL;
  10152. sp_digit* norm = NULL;
  10153. sp_uint64 e[1] = {0};
  10154. sp_digit mp = 0;
  10155. int i;
  10156. int err = MP_OKAY;
  10157. if (*outLen < 384U) {
  10158. err = MP_TO_E;
  10159. }
  10160. if (err == MP_OKAY) {
  10161. if (mp_count_bits(em) > 64) {
  10162. err = MP_READ_E;
  10163. }
  10164. else if (inLen > 384U) {
  10165. err = MP_READ_E;
  10166. }
  10167. else if (mp_count_bits(mm) != 3072) {
  10168. err = MP_READ_E;
  10169. }
  10170. else if (mp_iseven(mm)) {
  10171. err = MP_VAL;
  10172. }
  10173. }
  10174. #ifdef WOLFSSL_SP_SMALL_STACK
  10175. if (err == MP_OKAY) {
  10176. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 5, NULL,
  10177. DYNAMIC_TYPE_RSA);
  10178. if (a == NULL)
  10179. err = MEMORY_E;
  10180. }
  10181. #endif
  10182. if (err == MP_OKAY) {
  10183. r = a + 112 * 2;
  10184. m = r + 112 * 2;
  10185. norm = r;
  10186. sp_3072_from_bin(a, 112, in, inLen);
  10187. #if DIGIT_BIT >= 64
  10188. e[0] = (sp_uint64)em->dp[0];
  10189. #else
  10190. e[0] = (sp_uint64)em->dp[0];
  10191. if (em->used > 1) {
  10192. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  10193. }
  10194. #endif
  10195. if (e[0] == 0) {
  10196. err = MP_EXPTMOD_E;
  10197. }
  10198. }
  10199. if (err == MP_OKAY) {
  10200. sp_3072_from_mp(m, 112, mm);
  10201. sp_3072_mont_setup(m, &mp);
  10202. sp_3072_mont_norm_112(norm, m);
  10203. }
  10204. if (err == MP_OKAY) {
  10205. sp_3072_mul_112(a, a, norm);
  10206. err = sp_3072_mod_112(a, a, m);
  10207. }
  10208. if (err == MP_OKAY) {
  10209. for (i=63; i>=0; i--) {
  10210. if ((e[0] >> i) != 0) {
  10211. break;
  10212. }
  10213. }
  10214. XMEMCPY(r, a, sizeof(sp_digit) * 112 * 2);
  10215. for (i--; i>=0; i--) {
  10216. sp_3072_mont_sqr_112(r, r, m, mp);
  10217. if (((e[0] >> i) & 1) == 1) {
  10218. sp_3072_mont_mul_112(r, r, a, m, mp);
  10219. }
  10220. }
  10221. sp_3072_mont_reduce_112(r, m, mp);
  10222. mp = sp_3072_cmp_112(r, m);
  10223. sp_3072_cond_sub_112(r, r, m, ~(mp >> 31));
  10224. sp_3072_to_bin_112(r, out);
  10225. *outLen = 384;
  10226. }
  10227. #ifdef WOLFSSL_SP_SMALL_STACK
  10228. if (a != NULL)
  10229. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  10230. #endif
  10231. return err;
  10232. #else
  10233. #ifdef WOLFSSL_SP_SMALL_STACK
  10234. sp_digit* d = NULL;
  10235. #else
  10236. sp_digit d[112 * 5];
  10237. #endif
  10238. sp_digit* a = NULL;
  10239. sp_digit* m = NULL;
  10240. sp_digit* r = NULL;
  10241. sp_uint64 e[1] = {0};
  10242. int err = MP_OKAY;
  10243. if (*outLen < 384U) {
  10244. err = MP_TO_E;
  10245. }
  10246. if (err == MP_OKAY) {
  10247. if (mp_count_bits(em) > 64) {
  10248. err = MP_READ_E;
  10249. }
  10250. else if (inLen > 384U) {
  10251. err = MP_READ_E;
  10252. }
  10253. else if (mp_count_bits(mm) != 3072) {
  10254. err = MP_READ_E;
  10255. }
  10256. else if (mp_iseven(mm)) {
  10257. err = MP_VAL;
  10258. }
  10259. }
  10260. #ifdef WOLFSSL_SP_SMALL_STACK
  10261. if (err == MP_OKAY) {
  10262. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 5, NULL,
  10263. DYNAMIC_TYPE_RSA);
  10264. if (d == NULL)
  10265. err = MEMORY_E;
  10266. }
  10267. #endif
  10268. if (err == MP_OKAY) {
  10269. a = d;
  10270. r = a + 112 * 2;
  10271. m = r + 112 * 2;
  10272. sp_3072_from_bin(a, 112, in, inLen);
  10273. #if DIGIT_BIT >= 64
  10274. e[0] = (sp_uint64)em->dp[0];
  10275. #else
  10276. e[0] = (sp_uint64)em->dp[0];
  10277. if (em->used > 1) {
  10278. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  10279. }
  10280. #endif
  10281. if (e[0] == 0) {
  10282. err = MP_EXPTMOD_E;
  10283. }
  10284. }
  10285. if (err == MP_OKAY) {
  10286. sp_3072_from_mp(m, 112, mm);
  10287. if (e[0] == 0x3) {
  10288. sp_3072_sqr_112(r, a);
  10289. err = sp_3072_mod_112(r, r, m);
  10290. if (err == MP_OKAY) {
  10291. sp_3072_mul_112(r, a, r);
  10292. err = sp_3072_mod_112(r, r, m);
  10293. }
  10294. }
  10295. else {
  10296. sp_digit* norm = r;
  10297. int i;
  10298. sp_digit mp;
  10299. sp_3072_mont_setup(m, &mp);
  10300. sp_3072_mont_norm_112(norm, m);
  10301. sp_3072_mul_112(a, a, norm);
  10302. err = sp_3072_mod_112(a, a, m);
  10303. if (err == MP_OKAY) {
  10304. for (i=63; i>=0; i--) {
  10305. if ((e[0] >> i) != 0) {
  10306. break;
  10307. }
  10308. }
  10309. XMEMCPY(r, a, sizeof(sp_digit) * 224U);
  10310. for (i--; i>=0; i--) {
  10311. sp_3072_mont_sqr_112(r, r, m, mp);
  10312. if (((e[0] >> i) & 1) == 1) {
  10313. sp_3072_mont_mul_112(r, r, a, m, mp);
  10314. }
  10315. }
  10316. sp_3072_mont_reduce_112(r, m, mp);
  10317. mp = sp_3072_cmp_112(r, m);
  10318. sp_3072_cond_sub_112(r, r, m, ~(mp >> 31));
  10319. }
  10320. }
  10321. }
  10322. if (err == MP_OKAY) {
  10323. sp_3072_to_bin_112(r, out);
  10324. *outLen = 384;
  10325. }
  10326. #ifdef WOLFSSL_SP_SMALL_STACK
  10327. if (d != NULL)
  10328. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  10329. #endif
  10330. return err;
  10331. #endif /* WOLFSSL_SP_SMALL */
  10332. }
  10333. #ifndef WOLFSSL_RSA_PUBLIC_ONLY
  10334. #if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
  10335. #endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
  10336. /* RSA private key operation.
  10337. *
  10338. * in Array of bytes representing the number to exponentiate, base.
  10339. * inLen Number of bytes in base.
  10340. * dm Private exponent.
  10341. * pm First prime.
  10342. * qm Second prime.
  10343. * dpm First prime's CRT exponent.
  10344. * dqm Second prime's CRT exponent.
  10345. * qim Inverse of second prime mod p.
  10346. * mm Modulus.
  10347. * out Buffer to hold big-endian bytes of exponentiation result.
  10348. * Must be at least 384 bytes long.
  10349. * outLen Number of bytes in result.
  10350. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  10351. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  10352. */
  10353. int sp_RsaPrivate_3072(const byte* in, word32 inLen, const mp_int* dm,
  10354. const mp_int* pm, const mp_int* qm, const mp_int* dpm, const mp_int* dqm,
  10355. const mp_int* qim, const mp_int* mm, byte* out, word32* outLen)
  10356. {
  10357. #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
  10358. #if defined(WOLFSSL_SP_SMALL)
  10359. #ifdef WOLFSSL_SP_SMALL_STACK
  10360. sp_digit* d = NULL;
  10361. #else
  10362. sp_digit d[112 * 4];
  10363. #endif
  10364. sp_digit* a = NULL;
  10365. sp_digit* m = NULL;
  10366. sp_digit* r = NULL;
  10367. int err = MP_OKAY;
  10368. (void)pm;
  10369. (void)qm;
  10370. (void)dpm;
  10371. (void)dqm;
  10372. (void)qim;
  10373. if (*outLen < 384U) {
  10374. err = MP_TO_E;
  10375. }
  10376. if (err == MP_OKAY) {
  10377. if (mp_count_bits(dm) > 3072) {
  10378. err = MP_READ_E;
  10379. }
  10380. else if (inLen > 384) {
  10381. err = MP_READ_E;
  10382. }
  10383. else if (mp_count_bits(mm) != 3072) {
  10384. err = MP_READ_E;
  10385. }
  10386. else if (mp_iseven(mm)) {
  10387. err = MP_VAL;
  10388. }
  10389. }
  10390. #ifdef WOLFSSL_SP_SMALL_STACK
  10391. if (err == MP_OKAY) {
  10392. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 4, NULL,
  10393. DYNAMIC_TYPE_RSA);
  10394. if (d == NULL)
  10395. err = MEMORY_E;
  10396. }
  10397. #endif
  10398. if (err == MP_OKAY) {
  10399. a = d + 112;
  10400. m = a + 224;
  10401. r = a;
  10402. sp_3072_from_bin(a, 112, in, inLen);
  10403. sp_3072_from_mp(d, 112, dm);
  10404. sp_3072_from_mp(m, 112, mm);
  10405. err = sp_3072_mod_exp_112(r, a, d, 3072, m, 0);
  10406. }
  10407. if (err == MP_OKAY) {
  10408. sp_3072_to_bin_112(r, out);
  10409. *outLen = 384;
  10410. }
  10411. #ifdef WOLFSSL_SP_SMALL_STACK
  10412. if (d != NULL)
  10413. #endif
  10414. {
  10415. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  10416. if (a != NULL)
  10417. ForceZero(a, sizeof(sp_digit) * 112);
  10418. #ifdef WOLFSSL_SP_SMALL_STACK
  10419. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  10420. #endif
  10421. }
  10422. return err;
  10423. #else
  10424. #ifdef WOLFSSL_SP_SMALL_STACK
  10425. sp_digit* d = NULL;
  10426. #else
  10427. sp_digit d[112 * 4];
  10428. #endif
  10429. sp_digit* a = NULL;
  10430. sp_digit* m = NULL;
  10431. sp_digit* r = NULL;
  10432. int err = MP_OKAY;
  10433. (void)pm;
  10434. (void)qm;
  10435. (void)dpm;
  10436. (void)dqm;
  10437. (void)qim;
  10438. if (*outLen < 384U) {
  10439. err = MP_TO_E;
  10440. }
  10441. if (err == MP_OKAY) {
  10442. if (mp_count_bits(dm) > 3072) {
  10443. err = MP_READ_E;
  10444. }
  10445. else if (inLen > 384U) {
  10446. err = MP_READ_E;
  10447. }
  10448. else if (mp_count_bits(mm) != 3072) {
  10449. err = MP_READ_E;
  10450. }
  10451. else if (mp_iseven(mm)) {
  10452. err = MP_VAL;
  10453. }
  10454. }
  10455. #ifdef WOLFSSL_SP_SMALL_STACK
  10456. if (err == MP_OKAY) {
  10457. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 4, NULL,
  10458. DYNAMIC_TYPE_RSA);
  10459. if (d == NULL)
  10460. err = MEMORY_E;
  10461. }
  10462. #endif
  10463. if (err == MP_OKAY) {
  10464. a = d + 112;
  10465. m = a + 224;
  10466. r = a;
  10467. sp_3072_from_bin(a, 112, in, inLen);
  10468. sp_3072_from_mp(d, 112, dm);
  10469. sp_3072_from_mp(m, 112, mm);
  10470. err = sp_3072_mod_exp_112(r, a, d, 3072, m, 0);
  10471. }
  10472. if (err == MP_OKAY) {
  10473. sp_3072_to_bin_112(r, out);
  10474. *outLen = 384;
  10475. }
  10476. #ifdef WOLFSSL_SP_SMALL_STACK
  10477. if (d != NULL)
  10478. #endif
  10479. {
  10480. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  10481. if (a != NULL)
  10482. ForceZero(a, sizeof(sp_digit) * 112);
  10483. #ifdef WOLFSSL_SP_SMALL_STACK
  10484. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  10485. #endif
  10486. }
  10487. return err;
  10488. #endif /* WOLFSSL_SP_SMALL */
  10489. #else
  10490. #if defined(WOLFSSL_SP_SMALL)
  10491. #ifdef WOLFSSL_SP_SMALL_STACK
  10492. sp_digit* a = NULL;
  10493. #else
  10494. sp_digit a[56 * 8];
  10495. #endif
  10496. sp_digit* p = NULL;
  10497. sp_digit* dp = NULL;
  10498. sp_digit* dq = NULL;
  10499. sp_digit* qi = NULL;
  10500. sp_digit* tmpa = NULL;
  10501. sp_digit* tmpb = NULL;
  10502. sp_digit* r = NULL;
  10503. int err = MP_OKAY;
  10504. (void)dm;
  10505. (void)mm;
  10506. if (*outLen < 384U) {
  10507. err = MP_TO_E;
  10508. }
  10509. if (err == MP_OKAY) {
  10510. if (inLen > 384) {
  10511. err = MP_READ_E;
  10512. }
  10513. else if (mp_count_bits(mm) != 3072) {
  10514. err = MP_READ_E;
  10515. }
  10516. else if (mp_iseven(mm)) {
  10517. err = MP_VAL;
  10518. }
  10519. else if (mp_iseven(pm)) {
  10520. err = MP_VAL;
  10521. }
  10522. else if (mp_iseven(qm)) {
  10523. err = MP_VAL;
  10524. }
  10525. }
  10526. #ifdef WOLFSSL_SP_SMALL_STACK
  10527. if (err == MP_OKAY) {
  10528. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 8, NULL,
  10529. DYNAMIC_TYPE_RSA);
  10530. if (a == NULL)
  10531. err = MEMORY_E;
  10532. }
  10533. #endif
  10534. if (err == MP_OKAY) {
  10535. p = a + 112;
  10536. qi = dq = dp = p + 56;
  10537. tmpa = qi + 56;
  10538. tmpb = tmpa + 112;
  10539. r = a;
  10540. sp_3072_from_bin(a, 112, in, inLen);
  10541. sp_3072_from_mp(p, 56, pm);
  10542. sp_3072_from_mp(dp, 56, dpm);
  10543. err = sp_3072_mod_exp_56(tmpa, a, dp, 1536, p, 1);
  10544. }
  10545. if (err == MP_OKAY) {
  10546. sp_3072_from_mp(p, 56, qm);
  10547. sp_3072_from_mp(dq, 56, dqm);
  10548. err = sp_3072_mod_exp_56(tmpb, a, dq, 1536, p, 1);
  10549. }
  10550. if (err == MP_OKAY) {
  10551. sp_3072_from_mp(p, 56, pm);
  10552. (void)sp_3072_sub_56(tmpa, tmpa, tmpb);
  10553. sp_3072_norm_55(tmpa);
  10554. sp_3072_cond_add_56(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[54] >> 31));
  10555. sp_3072_cond_add_56(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[54] >> 31));
  10556. sp_3072_norm_56(tmpa);
  10557. sp_3072_from_mp(qi, 56, qim);
  10558. sp_3072_mul_56(tmpa, tmpa, qi);
  10559. err = sp_3072_mod_56(tmpa, tmpa, p);
  10560. }
  10561. if (err == MP_OKAY) {
  10562. sp_3072_from_mp(p, 56, qm);
  10563. sp_3072_mul_56(tmpa, p, tmpa);
  10564. (void)sp_3072_add_112(r, tmpb, tmpa);
  10565. sp_3072_norm_112(r);
  10566. sp_3072_to_bin_112(r, out);
  10567. *outLen = 384;
  10568. }
  10569. #ifdef WOLFSSL_SP_SMALL_STACK
  10570. if (a != NULL)
  10571. #endif
  10572. {
  10573. ForceZero(a, sizeof(sp_digit) * 56 * 8);
  10574. #ifdef WOLFSSL_SP_SMALL_STACK
  10575. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  10576. #endif
  10577. }
  10578. return err;
  10579. #else
  10580. #ifdef WOLFSSL_SP_SMALL_STACK
  10581. sp_digit* a = NULL;
  10582. #else
  10583. sp_digit a[56 * 13];
  10584. #endif
  10585. sp_digit* p = NULL;
  10586. sp_digit* q = NULL;
  10587. sp_digit* dp = NULL;
  10588. sp_digit* dq = NULL;
  10589. sp_digit* qi = NULL;
  10590. sp_digit* tmpa = NULL;
  10591. sp_digit* tmpb = NULL;
  10592. sp_digit* r = NULL;
  10593. int err = MP_OKAY;
  10594. (void)dm;
  10595. (void)mm;
  10596. if (*outLen < 384U) {
  10597. err = MP_TO_E;
  10598. }
  10599. if (err == MP_OKAY) {
  10600. if (inLen > 384U) {
  10601. err = MP_READ_E;
  10602. }
  10603. else if (mp_count_bits(mm) != 3072) {
  10604. err = MP_READ_E;
  10605. }
  10606. else if (mp_iseven(mm)) {
  10607. err = MP_VAL;
  10608. }
  10609. else if (mp_iseven(pm)) {
  10610. err = MP_VAL;
  10611. }
  10612. else if (mp_iseven(qm)) {
  10613. err = MP_VAL;
  10614. }
  10615. }
  10616. #ifdef WOLFSSL_SP_SMALL_STACK
  10617. if (err == MP_OKAY) {
  10618. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 13, NULL,
  10619. DYNAMIC_TYPE_RSA);
  10620. if (a == NULL)
  10621. err = MEMORY_E;
  10622. }
  10623. #endif
  10624. if (err == MP_OKAY) {
  10625. p = a + 112 * 2;
  10626. q = p + 56;
  10627. dp = q + 56;
  10628. dq = dp + 56;
  10629. qi = dq + 56;
  10630. tmpa = qi + 56;
  10631. tmpb = tmpa + 112;
  10632. r = a;
  10633. sp_3072_from_bin(a, 112, in, inLen);
  10634. sp_3072_from_mp(p, 56, pm);
  10635. sp_3072_from_mp(q, 56, qm);
  10636. sp_3072_from_mp(dp, 56, dpm);
  10637. sp_3072_from_mp(dq, 56, dqm);
  10638. sp_3072_from_mp(qi, 56, qim);
  10639. err = sp_3072_mod_exp_56(tmpa, a, dp, 1536, p, 1);
  10640. }
  10641. if (err == MP_OKAY) {
  10642. err = sp_3072_mod_exp_56(tmpb, a, dq, 1536, q, 1);
  10643. }
  10644. if (err == MP_OKAY) {
  10645. (void)sp_3072_sub_56(tmpa, tmpa, tmpb);
  10646. sp_3072_norm_55(tmpa);
  10647. sp_3072_cond_add_56(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[54] >> 31));
  10648. sp_3072_cond_add_56(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[54] >> 31));
  10649. sp_3072_norm_56(tmpa);
  10650. sp_3072_mul_56(tmpa, tmpa, qi);
  10651. err = sp_3072_mod_56(tmpa, tmpa, p);
  10652. }
  10653. if (err == MP_OKAY) {
  10654. sp_3072_mul_56(tmpa, tmpa, q);
  10655. (void)sp_3072_add_112(r, tmpb, tmpa);
  10656. sp_3072_norm_112(r);
  10657. sp_3072_to_bin_112(r, out);
  10658. *outLen = 384;
  10659. }
  10660. #ifdef WOLFSSL_SP_SMALL_STACK
  10661. if (a != NULL)
  10662. #endif
  10663. {
  10664. ForceZero(a, sizeof(sp_digit) * 56 * 13);
  10665. #ifdef WOLFSSL_SP_SMALL_STACK
  10666. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  10667. #endif
  10668. }
  10669. return err;
  10670. #endif /* WOLFSSL_SP_SMALL */
  10671. #endif /* SP_RSA_PRIVATE_EXP_D || RSA_LOW_MEM */
  10672. }
  10673. #endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
  10674. #endif /* WOLFSSL_HAVE_SP_RSA */
  10675. #if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
  10676. !defined(WOLFSSL_RSA_PUBLIC_ONLY))
  10677. /* Convert an array of sp_digit to an mp_int.
  10678. *
  10679. * a A single precision integer.
  10680. * r A multi-precision integer.
  10681. */
  10682. static int sp_3072_to_mp(const sp_digit* a, mp_int* r)
  10683. {
  10684. int err;
  10685. err = mp_grow(r, (3072 + DIGIT_BIT - 1) / DIGIT_BIT);
  10686. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  10687. #if DIGIT_BIT == 28
  10688. XMEMCPY(r->dp, a, sizeof(sp_digit) * 110);
  10689. r->used = 110;
  10690. mp_clamp(r);
  10691. #elif DIGIT_BIT < 28
  10692. int i;
  10693. int j = 0;
  10694. int s = 0;
  10695. r->dp[0] = 0;
  10696. for (i = 0; i < 110; i++) {
  10697. r->dp[j] |= (mp_digit)(a[i] << s);
  10698. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  10699. s = DIGIT_BIT - s;
  10700. r->dp[++j] = (mp_digit)(a[i] >> s);
  10701. while (s + DIGIT_BIT <= 28) {
  10702. s += DIGIT_BIT;
  10703. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  10704. if (s == SP_WORD_SIZE) {
  10705. r->dp[j] = 0;
  10706. }
  10707. else {
  10708. r->dp[j] = (mp_digit)(a[i] >> s);
  10709. }
  10710. }
  10711. s = 28 - s;
  10712. }
  10713. r->used = (3072 + DIGIT_BIT - 1) / DIGIT_BIT;
  10714. mp_clamp(r);
  10715. #else
  10716. int i;
  10717. int j = 0;
  10718. int s = 0;
  10719. r->dp[0] = 0;
  10720. for (i = 0; i < 110; i++) {
  10721. r->dp[j] |= ((mp_digit)a[i]) << s;
  10722. if (s + 28 >= DIGIT_BIT) {
  10723. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  10724. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  10725. #endif
  10726. s = DIGIT_BIT - s;
  10727. r->dp[++j] = a[i] >> s;
  10728. s = 28 - s;
  10729. }
  10730. else {
  10731. s += 28;
  10732. }
  10733. }
  10734. r->used = (3072 + DIGIT_BIT - 1) / DIGIT_BIT;
  10735. mp_clamp(r);
  10736. #endif
  10737. }
  10738. return err;
  10739. }
  10740. /* Perform the modular exponentiation for Diffie-Hellman.
  10741. *
  10742. * base Base. MP integer.
  10743. * exp Exponent. MP integer.
  10744. * mod Modulus. MP integer.
  10745. * res Result. MP integer.
  10746. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  10747. * and MEMORY_E if memory allocation fails.
  10748. */
  10749. int sp_ModExp_3072(const mp_int* base, const mp_int* exp, const mp_int* mod,
  10750. mp_int* res)
  10751. {
  10752. #ifdef WOLFSSL_SP_SMALL
  10753. int err = MP_OKAY;
  10754. #ifdef WOLFSSL_SP_SMALL_STACK
  10755. sp_digit* b = NULL;
  10756. #else
  10757. sp_digit b[112 * 4];
  10758. #endif
  10759. sp_digit* e = NULL;
  10760. sp_digit* m = NULL;
  10761. sp_digit* r = NULL;
  10762. int expBits = mp_count_bits(exp);
  10763. if (mp_count_bits(base) > 3072) {
  10764. err = MP_READ_E;
  10765. }
  10766. else if (expBits > 3072) {
  10767. err = MP_READ_E;
  10768. }
  10769. else if (mp_count_bits(mod) != 3072) {
  10770. err = MP_READ_E;
  10771. }
  10772. else if (mp_iseven(mod)) {
  10773. err = MP_VAL;
  10774. }
  10775. #ifdef WOLFSSL_SP_SMALL_STACK
  10776. if (err == MP_OKAY) {
  10777. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 4, NULL,
  10778. DYNAMIC_TYPE_DH);
  10779. if (b == NULL)
  10780. err = MEMORY_E;
  10781. }
  10782. #endif
  10783. if (err == MP_OKAY) {
  10784. e = b + 112 * 2;
  10785. m = e + 112;
  10786. r = b;
  10787. sp_3072_from_mp(b, 112, base);
  10788. sp_3072_from_mp(e, 112, exp);
  10789. sp_3072_from_mp(m, 112, mod);
  10790. err = sp_3072_mod_exp_112(r, b, e, mp_count_bits(exp), m, 0);
  10791. }
  10792. if (err == MP_OKAY) {
  10793. err = sp_3072_to_mp(r, res);
  10794. }
  10795. #ifdef WOLFSSL_SP_SMALL_STACK
  10796. if (b != NULL)
  10797. #endif
  10798. {
  10799. /* only "e" is sensitive and needs zeroized */
  10800. if (e != NULL)
  10801. ForceZero(e, sizeof(sp_digit) * 112U);
  10802. #ifdef WOLFSSL_SP_SMALL_STACK
  10803. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  10804. #endif
  10805. }
  10806. return err;
  10807. #else
  10808. #ifdef WOLFSSL_SP_SMALL_STACK
  10809. sp_digit* b = NULL;
  10810. #else
  10811. sp_digit b[112 * 4];
  10812. #endif
  10813. sp_digit* e = NULL;
  10814. sp_digit* m = NULL;
  10815. sp_digit* r = NULL;
  10816. int err = MP_OKAY;
  10817. int expBits = mp_count_bits(exp);
  10818. if (mp_count_bits(base) > 3072) {
  10819. err = MP_READ_E;
  10820. }
  10821. else if (expBits > 3072) {
  10822. err = MP_READ_E;
  10823. }
  10824. else if (mp_count_bits(mod) != 3072) {
  10825. err = MP_READ_E;
  10826. }
  10827. else if (mp_iseven(mod)) {
  10828. err = MP_VAL;
  10829. }
  10830. #ifdef WOLFSSL_SP_SMALL_STACK
  10831. if (err == MP_OKAY) {
  10832. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 4, NULL, DYNAMIC_TYPE_DH);
  10833. if (b == NULL)
  10834. err = MEMORY_E;
  10835. }
  10836. #endif
  10837. if (err == MP_OKAY) {
  10838. e = b + 112 * 2;
  10839. m = e + 112;
  10840. r = b;
  10841. sp_3072_from_mp(b, 112, base);
  10842. sp_3072_from_mp(e, 112, exp);
  10843. sp_3072_from_mp(m, 112, mod);
  10844. err = sp_3072_mod_exp_112(r, b, e, expBits, m, 0);
  10845. }
  10846. if (err == MP_OKAY) {
  10847. err = sp_3072_to_mp(r, res);
  10848. }
  10849. #ifdef WOLFSSL_SP_SMALL_STACK
  10850. if (b != NULL)
  10851. #endif
  10852. {
  10853. /* only "e" is sensitive and needs zeroized */
  10854. if (e != NULL)
  10855. ForceZero(e, sizeof(sp_digit) * 112U);
  10856. #ifdef WOLFSSL_SP_SMALL_STACK
  10857. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  10858. #endif
  10859. }
  10860. return err;
  10861. #endif
  10862. }
  10863. #ifdef WOLFSSL_HAVE_SP_DH
  10864. #ifdef HAVE_FFDHE_3072
  10865. SP_NOINLINE static void sp_3072_lshift_112(sp_digit* r, const sp_digit* a,
  10866. byte n)
  10867. {
  10868. sp_int_digit s;
  10869. sp_int_digit t;
  10870. s = (sp_int_digit)a[111];
  10871. r[112] = s >> (28U - n);
  10872. s = (sp_int_digit)(a[111]); t = (sp_int_digit)(a[110]);
  10873. r[111] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10874. s = (sp_int_digit)(a[110]); t = (sp_int_digit)(a[109]);
  10875. r[110] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10876. s = (sp_int_digit)(a[109]); t = (sp_int_digit)(a[108]);
  10877. r[109] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10878. s = (sp_int_digit)(a[108]); t = (sp_int_digit)(a[107]);
  10879. r[108] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10880. s = (sp_int_digit)(a[107]); t = (sp_int_digit)(a[106]);
  10881. r[107] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10882. s = (sp_int_digit)(a[106]); t = (sp_int_digit)(a[105]);
  10883. r[106] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10884. s = (sp_int_digit)(a[105]); t = (sp_int_digit)(a[104]);
  10885. r[105] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10886. s = (sp_int_digit)(a[104]); t = (sp_int_digit)(a[103]);
  10887. r[104] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10888. s = (sp_int_digit)(a[103]); t = (sp_int_digit)(a[102]);
  10889. r[103] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10890. s = (sp_int_digit)(a[102]); t = (sp_int_digit)(a[101]);
  10891. r[102] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10892. s = (sp_int_digit)(a[101]); t = (sp_int_digit)(a[100]);
  10893. r[101] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10894. s = (sp_int_digit)(a[100]); t = (sp_int_digit)(a[99]);
  10895. r[100] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10896. s = (sp_int_digit)(a[99]); t = (sp_int_digit)(a[98]);
  10897. r[99] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10898. s = (sp_int_digit)(a[98]); t = (sp_int_digit)(a[97]);
  10899. r[98] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10900. s = (sp_int_digit)(a[97]); t = (sp_int_digit)(a[96]);
  10901. r[97] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10902. s = (sp_int_digit)(a[96]); t = (sp_int_digit)(a[95]);
  10903. r[96] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10904. s = (sp_int_digit)(a[95]); t = (sp_int_digit)(a[94]);
  10905. r[95] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10906. s = (sp_int_digit)(a[94]); t = (sp_int_digit)(a[93]);
  10907. r[94] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10908. s = (sp_int_digit)(a[93]); t = (sp_int_digit)(a[92]);
  10909. r[93] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10910. s = (sp_int_digit)(a[92]); t = (sp_int_digit)(a[91]);
  10911. r[92] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10912. s = (sp_int_digit)(a[91]); t = (sp_int_digit)(a[90]);
  10913. r[91] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10914. s = (sp_int_digit)(a[90]); t = (sp_int_digit)(a[89]);
  10915. r[90] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10916. s = (sp_int_digit)(a[89]); t = (sp_int_digit)(a[88]);
  10917. r[89] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10918. s = (sp_int_digit)(a[88]); t = (sp_int_digit)(a[87]);
  10919. r[88] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10920. s = (sp_int_digit)(a[87]); t = (sp_int_digit)(a[86]);
  10921. r[87] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10922. s = (sp_int_digit)(a[86]); t = (sp_int_digit)(a[85]);
  10923. r[86] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10924. s = (sp_int_digit)(a[85]); t = (sp_int_digit)(a[84]);
  10925. r[85] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10926. s = (sp_int_digit)(a[84]); t = (sp_int_digit)(a[83]);
  10927. r[84] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10928. s = (sp_int_digit)(a[83]); t = (sp_int_digit)(a[82]);
  10929. r[83] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10930. s = (sp_int_digit)(a[82]); t = (sp_int_digit)(a[81]);
  10931. r[82] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10932. s = (sp_int_digit)(a[81]); t = (sp_int_digit)(a[80]);
  10933. r[81] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10934. s = (sp_int_digit)(a[80]); t = (sp_int_digit)(a[79]);
  10935. r[80] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10936. s = (sp_int_digit)(a[79]); t = (sp_int_digit)(a[78]);
  10937. r[79] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10938. s = (sp_int_digit)(a[78]); t = (sp_int_digit)(a[77]);
  10939. r[78] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10940. s = (sp_int_digit)(a[77]); t = (sp_int_digit)(a[76]);
  10941. r[77] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10942. s = (sp_int_digit)(a[76]); t = (sp_int_digit)(a[75]);
  10943. r[76] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10944. s = (sp_int_digit)(a[75]); t = (sp_int_digit)(a[74]);
  10945. r[75] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10946. s = (sp_int_digit)(a[74]); t = (sp_int_digit)(a[73]);
  10947. r[74] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10948. s = (sp_int_digit)(a[73]); t = (sp_int_digit)(a[72]);
  10949. r[73] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10950. s = (sp_int_digit)(a[72]); t = (sp_int_digit)(a[71]);
  10951. r[72] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10952. s = (sp_int_digit)(a[71]); t = (sp_int_digit)(a[70]);
  10953. r[71] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10954. s = (sp_int_digit)(a[70]); t = (sp_int_digit)(a[69]);
  10955. r[70] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10956. s = (sp_int_digit)(a[69]); t = (sp_int_digit)(a[68]);
  10957. r[69] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10958. s = (sp_int_digit)(a[68]); t = (sp_int_digit)(a[67]);
  10959. r[68] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10960. s = (sp_int_digit)(a[67]); t = (sp_int_digit)(a[66]);
  10961. r[67] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10962. s = (sp_int_digit)(a[66]); t = (sp_int_digit)(a[65]);
  10963. r[66] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10964. s = (sp_int_digit)(a[65]); t = (sp_int_digit)(a[64]);
  10965. r[65] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10966. s = (sp_int_digit)(a[64]); t = (sp_int_digit)(a[63]);
  10967. r[64] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10968. s = (sp_int_digit)(a[63]); t = (sp_int_digit)(a[62]);
  10969. r[63] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10970. s = (sp_int_digit)(a[62]); t = (sp_int_digit)(a[61]);
  10971. r[62] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10972. s = (sp_int_digit)(a[61]); t = (sp_int_digit)(a[60]);
  10973. r[61] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10974. s = (sp_int_digit)(a[60]); t = (sp_int_digit)(a[59]);
  10975. r[60] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10976. s = (sp_int_digit)(a[59]); t = (sp_int_digit)(a[58]);
  10977. r[59] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10978. s = (sp_int_digit)(a[58]); t = (sp_int_digit)(a[57]);
  10979. r[58] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10980. s = (sp_int_digit)(a[57]); t = (sp_int_digit)(a[56]);
  10981. r[57] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10982. s = (sp_int_digit)(a[56]); t = (sp_int_digit)(a[55]);
  10983. r[56] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10984. s = (sp_int_digit)(a[55]); t = (sp_int_digit)(a[54]);
  10985. r[55] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10986. s = (sp_int_digit)(a[54]); t = (sp_int_digit)(a[53]);
  10987. r[54] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10988. s = (sp_int_digit)(a[53]); t = (sp_int_digit)(a[52]);
  10989. r[53] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10990. s = (sp_int_digit)(a[52]); t = (sp_int_digit)(a[51]);
  10991. r[52] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10992. s = (sp_int_digit)(a[51]); t = (sp_int_digit)(a[50]);
  10993. r[51] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10994. s = (sp_int_digit)(a[50]); t = (sp_int_digit)(a[49]);
  10995. r[50] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10996. s = (sp_int_digit)(a[49]); t = (sp_int_digit)(a[48]);
  10997. r[49] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  10998. s = (sp_int_digit)(a[48]); t = (sp_int_digit)(a[47]);
  10999. r[48] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11000. s = (sp_int_digit)(a[47]); t = (sp_int_digit)(a[46]);
  11001. r[47] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11002. s = (sp_int_digit)(a[46]); t = (sp_int_digit)(a[45]);
  11003. r[46] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11004. s = (sp_int_digit)(a[45]); t = (sp_int_digit)(a[44]);
  11005. r[45] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11006. s = (sp_int_digit)(a[44]); t = (sp_int_digit)(a[43]);
  11007. r[44] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11008. s = (sp_int_digit)(a[43]); t = (sp_int_digit)(a[42]);
  11009. r[43] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11010. s = (sp_int_digit)(a[42]); t = (sp_int_digit)(a[41]);
  11011. r[42] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11012. s = (sp_int_digit)(a[41]); t = (sp_int_digit)(a[40]);
  11013. r[41] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11014. s = (sp_int_digit)(a[40]); t = (sp_int_digit)(a[39]);
  11015. r[40] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11016. s = (sp_int_digit)(a[39]); t = (sp_int_digit)(a[38]);
  11017. r[39] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11018. s = (sp_int_digit)(a[38]); t = (sp_int_digit)(a[37]);
  11019. r[38] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11020. s = (sp_int_digit)(a[37]); t = (sp_int_digit)(a[36]);
  11021. r[37] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11022. s = (sp_int_digit)(a[36]); t = (sp_int_digit)(a[35]);
  11023. r[36] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11024. s = (sp_int_digit)(a[35]); t = (sp_int_digit)(a[34]);
  11025. r[35] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11026. s = (sp_int_digit)(a[34]); t = (sp_int_digit)(a[33]);
  11027. r[34] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11028. s = (sp_int_digit)(a[33]); t = (sp_int_digit)(a[32]);
  11029. r[33] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11030. s = (sp_int_digit)(a[32]); t = (sp_int_digit)(a[31]);
  11031. r[32] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11032. s = (sp_int_digit)(a[31]); t = (sp_int_digit)(a[30]);
  11033. r[31] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11034. s = (sp_int_digit)(a[30]); t = (sp_int_digit)(a[29]);
  11035. r[30] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11036. s = (sp_int_digit)(a[29]); t = (sp_int_digit)(a[28]);
  11037. r[29] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11038. s = (sp_int_digit)(a[28]); t = (sp_int_digit)(a[27]);
  11039. r[28] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11040. s = (sp_int_digit)(a[27]); t = (sp_int_digit)(a[26]);
  11041. r[27] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11042. s = (sp_int_digit)(a[26]); t = (sp_int_digit)(a[25]);
  11043. r[26] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11044. s = (sp_int_digit)(a[25]); t = (sp_int_digit)(a[24]);
  11045. r[25] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11046. s = (sp_int_digit)(a[24]); t = (sp_int_digit)(a[23]);
  11047. r[24] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11048. s = (sp_int_digit)(a[23]); t = (sp_int_digit)(a[22]);
  11049. r[23] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11050. s = (sp_int_digit)(a[22]); t = (sp_int_digit)(a[21]);
  11051. r[22] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11052. s = (sp_int_digit)(a[21]); t = (sp_int_digit)(a[20]);
  11053. r[21] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11054. s = (sp_int_digit)(a[20]); t = (sp_int_digit)(a[19]);
  11055. r[20] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11056. s = (sp_int_digit)(a[19]); t = (sp_int_digit)(a[18]);
  11057. r[19] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11058. s = (sp_int_digit)(a[18]); t = (sp_int_digit)(a[17]);
  11059. r[18] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11060. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  11061. r[17] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11062. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  11063. r[16] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11064. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  11065. r[15] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11066. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  11067. r[14] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11068. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  11069. r[13] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11070. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  11071. r[12] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11072. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  11073. r[11] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11074. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  11075. r[10] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11076. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  11077. r[9] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11078. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  11079. r[8] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11080. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  11081. r[7] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11082. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  11083. r[6] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11084. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  11085. r[5] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11086. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  11087. r[4] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11088. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  11089. r[3] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11090. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  11091. r[2] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11092. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  11093. r[1] = ((s << n) | (t >> (28U - n))) & 0xfffffff;
  11094. r[0] = (a[0] << n) & 0xfffffff;
  11095. }
  11096. /* Modular exponentiate 2 to the e mod m. (r = 2^e mod m)
  11097. *
  11098. * r A single precision number that is the result of the operation.
  11099. * e A single precision number that is the exponent.
  11100. * bits The number of bits in the exponent.
  11101. * m A single precision number that is the modulus.
  11102. * returns 0 on success.
  11103. * returns MEMORY_E on dynamic memory allocation failure.
  11104. * returns MP_VAL when base is even.
  11105. */
  11106. static int sp_3072_mod_exp_2_112(sp_digit* r, const sp_digit* e, int bits, const sp_digit* m)
  11107. {
  11108. #ifdef WOLFSSL_SP_SMALL_STACK
  11109. sp_digit* td = NULL;
  11110. #else
  11111. sp_digit td[337];
  11112. #endif
  11113. sp_digit* norm = NULL;
  11114. sp_digit* tmp = NULL;
  11115. sp_digit mp = 1;
  11116. sp_digit n;
  11117. sp_digit o;
  11118. int i;
  11119. int c;
  11120. byte y;
  11121. int err = MP_OKAY;
  11122. if (bits == 0) {
  11123. err = MP_VAL;
  11124. }
  11125. #ifdef WOLFSSL_SP_SMALL_STACK
  11126. if (err == MP_OKAY) {
  11127. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 337, NULL,
  11128. DYNAMIC_TYPE_TMP_BUFFER);
  11129. if (td == NULL)
  11130. err = MEMORY_E;
  11131. }
  11132. #endif
  11133. if (err == MP_OKAY) {
  11134. norm = td;
  11135. tmp = td + 224;
  11136. XMEMSET(td, 0, sizeof(sp_digit) * 337);
  11137. sp_3072_mont_setup(m, &mp);
  11138. sp_3072_mont_norm_112(norm, m);
  11139. bits = ((bits + 3) / 4) * 4;
  11140. i = ((bits + 27) / 28) - 1;
  11141. c = bits % 28;
  11142. if (c == 0) {
  11143. c = 28;
  11144. }
  11145. if (i < 112) {
  11146. n = e[i--] << (32 - c);
  11147. }
  11148. else {
  11149. n = 0;
  11150. i--;
  11151. }
  11152. if (c < 4) {
  11153. n |= e[i--] << (4 - c);
  11154. c += 28;
  11155. }
  11156. y = (int)((n >> 28) & 0xf);
  11157. n <<= 4;
  11158. c -= 4;
  11159. sp_3072_lshift_112(r, norm, (byte)y);
  11160. while ((i >= 0) || (c >= 4)) {
  11161. if (c >= 4) {
  11162. y = (byte)((n >> 28) & 0xf);
  11163. n <<= 4;
  11164. c -= 4;
  11165. }
  11166. else if (c == 0) {
  11167. n = e[i--] << 4;
  11168. y = (byte)((n >> 28) & 0xf);
  11169. n <<= 4;
  11170. c = 24;
  11171. }
  11172. else {
  11173. y = (byte)((n >> 28) & 0xf);
  11174. n = e[i--] << 4;
  11175. c = 4 - c;
  11176. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  11177. n <<= c;
  11178. c = 28 - c;
  11179. }
  11180. sp_3072_mont_sqr_112(r, r, m, mp);
  11181. sp_3072_mont_sqr_112(r, r, m, mp);
  11182. sp_3072_mont_sqr_112(r, r, m, mp);
  11183. sp_3072_mont_sqr_112(r, r, m, mp);
  11184. sp_3072_lshift_112(r, r, (byte)y);
  11185. sp_3072_mul_d_112(tmp, norm, (r[110] << 8) + (r[109] >> 20));
  11186. r[110] = 0;
  11187. r[109] &= 0xfffffL;
  11188. (void)sp_3072_add_112(r, r, tmp);
  11189. sp_3072_norm_112(r);
  11190. o = sp_3072_cmp_112(r, m);
  11191. sp_3072_cond_sub_112(r, r, m, ~(o >> 31));
  11192. }
  11193. sp_3072_mont_reduce_112(r, m, mp);
  11194. n = sp_3072_cmp_112(r, m);
  11195. sp_3072_cond_sub_112(r, r, m, ~(n >> 31));
  11196. }
  11197. #ifdef WOLFSSL_SP_SMALL_STACK
  11198. if (td != NULL)
  11199. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  11200. #endif
  11201. return err;
  11202. }
  11203. #endif /* HAVE_FFDHE_3072 */
  11204. /* Perform the modular exponentiation for Diffie-Hellman.
  11205. *
  11206. * base Base.
  11207. * exp Array of bytes that is the exponent.
  11208. * expLen Length of data, in bytes, in exponent.
  11209. * mod Modulus.
  11210. * out Buffer to hold big-endian bytes of exponentiation result.
  11211. * Must be at least 384 bytes long.
  11212. * outLen Length, in bytes, of exponentiation result.
  11213. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  11214. * and MEMORY_E if memory allocation fails.
  11215. */
  11216. int sp_DhExp_3072(const mp_int* base, const byte* exp, word32 expLen,
  11217. const mp_int* mod, byte* out, word32* outLen)
  11218. {
  11219. #ifdef WOLFSSL_SP_SMALL_STACK
  11220. sp_digit* b = NULL;
  11221. #else
  11222. sp_digit b[112 * 4];
  11223. #endif
  11224. sp_digit* e = NULL;
  11225. sp_digit* m = NULL;
  11226. sp_digit* r = NULL;
  11227. word32 i;
  11228. int err = MP_OKAY;
  11229. if (mp_count_bits(base) > 3072) {
  11230. err = MP_READ_E;
  11231. }
  11232. else if (expLen > 384U) {
  11233. err = MP_READ_E;
  11234. }
  11235. else if (mp_count_bits(mod) != 3072) {
  11236. err = MP_READ_E;
  11237. }
  11238. else if (mp_iseven(mod)) {
  11239. err = MP_VAL;
  11240. }
  11241. #ifdef WOLFSSL_SP_SMALL_STACK
  11242. if (err == MP_OKAY) {
  11243. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 112 * 4, NULL,
  11244. DYNAMIC_TYPE_DH);
  11245. if (b == NULL)
  11246. err = MEMORY_E;
  11247. }
  11248. #endif
  11249. if (err == MP_OKAY) {
  11250. e = b + 112 * 2;
  11251. m = e + 112;
  11252. r = b;
  11253. sp_3072_from_mp(b, 112, base);
  11254. sp_3072_from_bin(e, 112, exp, expLen);
  11255. sp_3072_from_mp(m, 112, mod);
  11256. #ifdef HAVE_FFDHE_3072
  11257. if (base->used == 1 && base->dp[0] == 2U &&
  11258. (m[109] >> 4) == 0xffffL) {
  11259. err = sp_3072_mod_exp_2_112(r, e, expLen * 8U, m);
  11260. }
  11261. else {
  11262. #endif
  11263. err = sp_3072_mod_exp_112(r, b, e, expLen * 8U, m, 0);
  11264. #ifdef HAVE_FFDHE_3072
  11265. }
  11266. #endif
  11267. }
  11268. if (err == MP_OKAY) {
  11269. sp_3072_to_bin_112(r, out);
  11270. *outLen = 384;
  11271. for (i=0; i<384U && out[i] == 0U; i++) {
  11272. /* Search for first non-zero. */
  11273. }
  11274. *outLen -= i;
  11275. XMEMMOVE(out, out + i, *outLen);
  11276. }
  11277. #ifdef WOLFSSL_SP_SMALL_STACK
  11278. if (b != NULL)
  11279. #endif
  11280. {
  11281. /* only "e" is sensitive and needs zeroized */
  11282. if (e != NULL)
  11283. ForceZero(e, sizeof(sp_digit) * 112U);
  11284. #ifdef WOLFSSL_SP_SMALL_STACK
  11285. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  11286. #endif
  11287. }
  11288. return err;
  11289. }
  11290. #endif /* WOLFSSL_HAVE_SP_DH */
  11291. /* Perform the modular exponentiation for Diffie-Hellman.
  11292. *
  11293. * base Base. MP integer.
  11294. * exp Exponent. MP integer.
  11295. * mod Modulus. MP integer.
  11296. * res Result. MP integer.
  11297. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  11298. * and MEMORY_E if memory allocation fails.
  11299. */
  11300. int sp_ModExp_1536(const mp_int* base, const mp_int* exp, const mp_int* mod,
  11301. mp_int* res)
  11302. {
  11303. #ifdef WOLFSSL_SP_SMALL
  11304. int err = MP_OKAY;
  11305. #ifdef WOLFSSL_SP_SMALL_STACK
  11306. sp_digit* b = NULL;
  11307. #else
  11308. sp_digit b[56 * 4];
  11309. #endif
  11310. sp_digit* e = NULL;
  11311. sp_digit* m = NULL;
  11312. sp_digit* r = NULL;
  11313. int expBits = mp_count_bits(exp);
  11314. if (mp_count_bits(base) > 1536) {
  11315. err = MP_READ_E;
  11316. }
  11317. else if (expBits > 1536) {
  11318. err = MP_READ_E;
  11319. }
  11320. else if (mp_count_bits(mod) != 1536) {
  11321. err = MP_READ_E;
  11322. }
  11323. else if (mp_iseven(mod)) {
  11324. err = MP_VAL;
  11325. }
  11326. #ifdef WOLFSSL_SP_SMALL_STACK
  11327. if (err == MP_OKAY) {
  11328. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 4, NULL,
  11329. DYNAMIC_TYPE_DH);
  11330. if (b == NULL)
  11331. err = MEMORY_E;
  11332. }
  11333. #endif
  11334. if (err == MP_OKAY) {
  11335. e = b + 56 * 2;
  11336. m = e + 56;
  11337. r = b;
  11338. sp_3072_from_mp(b, 56, base);
  11339. sp_3072_from_mp(e, 56, exp);
  11340. sp_3072_from_mp(m, 56, mod);
  11341. err = sp_3072_mod_exp_56(r, b, e, mp_count_bits(exp), m, 0);
  11342. }
  11343. if (err == MP_OKAY) {
  11344. XMEMSET(r + 56, 0, sizeof(*r) * 56U);
  11345. err = sp_3072_to_mp(r, res);
  11346. }
  11347. #ifdef WOLFSSL_SP_SMALL_STACK
  11348. if (b != NULL)
  11349. #endif
  11350. {
  11351. /* only "e" is sensitive and needs zeroized */
  11352. if (e != NULL)
  11353. ForceZero(e, sizeof(sp_digit) * 112U);
  11354. #ifdef WOLFSSL_SP_SMALL_STACK
  11355. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  11356. #endif
  11357. }
  11358. return err;
  11359. #else
  11360. #ifdef WOLFSSL_SP_SMALL_STACK
  11361. sp_digit* b = NULL;
  11362. #else
  11363. sp_digit b[56 * 4];
  11364. #endif
  11365. sp_digit* e = NULL;
  11366. sp_digit* m = NULL;
  11367. sp_digit* r = NULL;
  11368. int err = MP_OKAY;
  11369. int expBits = mp_count_bits(exp);
  11370. if (mp_count_bits(base) > 1536) {
  11371. err = MP_READ_E;
  11372. }
  11373. else if (expBits > 1536) {
  11374. err = MP_READ_E;
  11375. }
  11376. else if (mp_count_bits(mod) != 1536) {
  11377. err = MP_READ_E;
  11378. }
  11379. else if (mp_iseven(mod)) {
  11380. err = MP_VAL;
  11381. }
  11382. #ifdef WOLFSSL_SP_SMALL_STACK
  11383. if (err == MP_OKAY) {
  11384. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 4, NULL, DYNAMIC_TYPE_DH);
  11385. if (b == NULL)
  11386. err = MEMORY_E;
  11387. }
  11388. #endif
  11389. if (err == MP_OKAY) {
  11390. e = b + 56 * 2;
  11391. m = e + 56;
  11392. r = b;
  11393. sp_3072_from_mp(b, 56, base);
  11394. sp_3072_from_mp(e, 56, exp);
  11395. sp_3072_from_mp(m, 56, mod);
  11396. err = sp_3072_mod_exp_56(r, b, e, expBits, m, 0);
  11397. }
  11398. if (err == MP_OKAY) {
  11399. XMEMSET(r + 56, 0, sizeof(*r) * 56U);
  11400. err = sp_3072_to_mp(r, res);
  11401. }
  11402. #ifdef WOLFSSL_SP_SMALL_STACK
  11403. if (b != NULL)
  11404. #endif
  11405. {
  11406. /* only "e" is sensitive and needs zeroized */
  11407. if (e != NULL)
  11408. ForceZero(e, sizeof(sp_digit) * 112U);
  11409. #ifdef WOLFSSL_SP_SMALL_STACK
  11410. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  11411. #endif
  11412. }
  11413. return err;
  11414. #endif
  11415. }
  11416. #endif /* WOLFSSL_HAVE_SP_DH | (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) */
  11417. #endif /* WOLFSSL_SP_SMALL */
  11418. #endif /* !WOLFSSL_SP_NO_3072 */
  11419. #ifdef WOLFSSL_SP_4096
  11420. #ifdef WOLFSSL_SP_SMALL
  11421. /* Read big endian unsigned byte array into r.
  11422. *
  11423. * r A single precision integer.
  11424. * size Maximum number of bytes to convert
  11425. * a Byte array.
  11426. * n Number of bytes in array to read.
  11427. */
  11428. static void sp_4096_from_bin(sp_digit* r, int size, const byte* a, int n)
  11429. {
  11430. int i;
  11431. int j = 0;
  11432. word32 s = 0;
  11433. r[0] = 0;
  11434. for (i = n-1; i >= 0; i--) {
  11435. r[j] |= (((sp_digit)a[i]) << s);
  11436. if (s >= 21U) {
  11437. r[j] &= 0x1fffffff;
  11438. s = 29U - s;
  11439. if (j + 1 >= size) {
  11440. break;
  11441. }
  11442. r[++j] = (sp_digit)a[i] >> s;
  11443. s = 8U - s;
  11444. }
  11445. else {
  11446. s += 8U;
  11447. }
  11448. }
  11449. for (j++; j < size; j++) {
  11450. r[j] = 0;
  11451. }
  11452. }
  11453. /* Convert an mp_int to an array of sp_digit.
  11454. *
  11455. * r A single precision integer.
  11456. * size Maximum number of bytes to convert
  11457. * a A multi-precision integer.
  11458. */
  11459. static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
  11460. {
  11461. #if DIGIT_BIT == 29
  11462. int i;
  11463. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  11464. int o = 0;
  11465. for (i = 0; i < size; i++) {
  11466. sp_digit mask = (sp_digit)0 - (j >> 28);
  11467. r[i] = a->dp[o] & mask;
  11468. j++;
  11469. o += (int)(j >> 28);
  11470. }
  11471. #elif DIGIT_BIT > 29
  11472. unsigned int i;
  11473. int j = 0;
  11474. word32 s = 0;
  11475. r[0] = 0;
  11476. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  11477. r[j] |= ((sp_digit)a->dp[i] << s);
  11478. r[j] &= 0x1fffffff;
  11479. s = 29U - s;
  11480. if (j + 1 >= size) {
  11481. break;
  11482. }
  11483. /* lint allow cast of mismatch word32 and mp_digit */
  11484. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  11485. while ((s + 29U) <= (word32)DIGIT_BIT) {
  11486. s += 29U;
  11487. r[j] &= 0x1fffffff;
  11488. if (j + 1 >= size) {
  11489. break;
  11490. }
  11491. if (s < (word32)DIGIT_BIT) {
  11492. /* lint allow cast of mismatch word32 and mp_digit */
  11493. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  11494. }
  11495. else {
  11496. r[++j] = (sp_digit)0;
  11497. }
  11498. }
  11499. s = (word32)DIGIT_BIT - s;
  11500. }
  11501. for (j++; j < size; j++) {
  11502. r[j] = 0;
  11503. }
  11504. #else
  11505. unsigned int i;
  11506. int j = 0;
  11507. int s = 0;
  11508. r[0] = 0;
  11509. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  11510. r[j] |= ((sp_digit)a->dp[i]) << s;
  11511. if (s + DIGIT_BIT >= 29) {
  11512. r[j] &= 0x1fffffff;
  11513. if (j + 1 >= size) {
  11514. break;
  11515. }
  11516. s = 29 - s;
  11517. if (s == DIGIT_BIT) {
  11518. r[++j] = 0;
  11519. s = 0;
  11520. }
  11521. else {
  11522. r[++j] = a->dp[i] >> s;
  11523. s = DIGIT_BIT - s;
  11524. }
  11525. }
  11526. else {
  11527. s += DIGIT_BIT;
  11528. }
  11529. }
  11530. for (j++; j < size; j++) {
  11531. r[j] = 0;
  11532. }
  11533. #endif
  11534. }
  11535. /* Write r as big endian to byte array.
  11536. * Fixed length number of bytes written: 512
  11537. *
  11538. * r A single precision integer.
  11539. * a Byte array.
  11540. */
  11541. static void sp_4096_to_bin_142(sp_digit* r, byte* a)
  11542. {
  11543. int i;
  11544. int j;
  11545. int s = 0;
  11546. int b;
  11547. for (i=0; i<141; i++) {
  11548. r[i+1] += r[i] >> 29;
  11549. r[i] &= 0x1fffffff;
  11550. }
  11551. j = 4103 / 8 - 1;
  11552. a[j] = 0;
  11553. for (i=0; i<142 && j>=0; i++) {
  11554. b = 0;
  11555. /* lint allow cast of mismatch sp_digit and int */
  11556. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  11557. b += 8 - s;
  11558. if (j < 0) {
  11559. break;
  11560. }
  11561. while (b < 29) {
  11562. a[j--] = (byte)(r[i] >> b);
  11563. b += 8;
  11564. if (j < 0) {
  11565. break;
  11566. }
  11567. }
  11568. s = 8 - (b - 29);
  11569. if (j >= 0) {
  11570. a[j] = 0;
  11571. }
  11572. if (s != 0) {
  11573. j++;
  11574. }
  11575. }
  11576. }
  11577. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  11578. #if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D)
  11579. /* Normalize the values in each word to 29 bits.
  11580. *
  11581. * a Array of sp_digit to normalize.
  11582. */
  11583. static void sp_4096_norm_71(sp_digit* a)
  11584. {
  11585. int i;
  11586. for (i = 0; i < 70; i++) {
  11587. a[i+1] += a[i] >> 29;
  11588. a[i] &= 0x1fffffff;
  11589. }
  11590. }
  11591. #endif /* WOLFSSL_HAVE_SP_RSA & !SP_RSA_PRIVATE_EXP_D */
  11592. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  11593. /* Normalize the values in each word to 29 bits.
  11594. *
  11595. * a Array of sp_digit to normalize.
  11596. */
  11597. static void sp_4096_norm_142(sp_digit* a)
  11598. {
  11599. int i;
  11600. for (i = 0; i < 141; i++) {
  11601. a[i+1] += a[i] >> 29;
  11602. a[i] &= 0x1fffffff;
  11603. }
  11604. }
  11605. /* Multiply a and b into r. (r = a * b)
  11606. *
  11607. * r A single precision integer.
  11608. * a A single precision integer.
  11609. * b A single precision integer.
  11610. */
  11611. SP_NOINLINE static void sp_4096_mul_142(sp_digit* r, const sp_digit* a,
  11612. const sp_digit* b)
  11613. {
  11614. int i;
  11615. int imax;
  11616. int k;
  11617. sp_uint64 c;
  11618. sp_uint64 lo;
  11619. c = ((sp_uint64)a[141]) * b[141];
  11620. r[283] = (sp_digit)(c >> 29);
  11621. c &= 0x1fffffff;
  11622. for (k = 281; k >= 0; k--) {
  11623. if (k >= 142) {
  11624. i = k - 141;
  11625. imax = 141;
  11626. }
  11627. else {
  11628. i = 0;
  11629. imax = k;
  11630. }
  11631. if (imax - i > 15) {
  11632. int imaxlo;
  11633. lo = 0;
  11634. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  11635. for (; i <= imax && i < imaxlo + 15; i++) {
  11636. lo += ((sp_uint64)a[i]) * b[k - i];
  11637. }
  11638. c += lo >> 29;
  11639. lo &= 0x1fffffff;
  11640. }
  11641. r[k + 2] += (sp_digit)(c >> 29);
  11642. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  11643. c = lo & 0x1fffffff;
  11644. }
  11645. else {
  11646. lo = 0;
  11647. for (; i <= imax; i++) {
  11648. lo += ((sp_uint64)a[i]) * b[k - i];
  11649. }
  11650. c += lo >> 29;
  11651. r[k + 2] += (sp_digit)(c >> 29);
  11652. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  11653. c = lo & 0x1fffffff;
  11654. }
  11655. }
  11656. r[0] = (sp_digit)c;
  11657. }
  11658. /* Square a and put result in r. (r = a * a)
  11659. *
  11660. * r A single precision integer.
  11661. * a A single precision integer.
  11662. */
  11663. SP_NOINLINE static void sp_4096_sqr_142(sp_digit* r, const sp_digit* a)
  11664. {
  11665. int i;
  11666. int imax;
  11667. int k;
  11668. sp_uint64 c;
  11669. sp_uint64 t;
  11670. c = ((sp_uint64)a[141]) * a[141];
  11671. r[283] = (sp_digit)(c >> 29);
  11672. c = (c & 0x1fffffff) << 29;
  11673. for (k = 281; k >= 0; k--) {
  11674. i = (k + 1) / 2;
  11675. if ((k & 1) == 0) {
  11676. c += ((sp_uint64)a[i]) * a[i];
  11677. i++;
  11678. }
  11679. if (k < 141) {
  11680. imax = k;
  11681. }
  11682. else {
  11683. imax = 141;
  11684. }
  11685. if (imax - i >= 14) {
  11686. int imaxlo;
  11687. sp_uint64 hi;
  11688. hi = c >> 29;
  11689. c &= 0x1fffffff;
  11690. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  11691. t = 0;
  11692. for (; i <= imax && i < imaxlo + 14; i++) {
  11693. t += ((sp_uint64)a[i]) * a[k - i];
  11694. }
  11695. c += t * 2;
  11696. hi += c >> 29;
  11697. c &= 0x1fffffff;
  11698. }
  11699. r[k + 2] += (sp_digit)(hi >> 29);
  11700. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  11701. c <<= 29;
  11702. }
  11703. else
  11704. {
  11705. t = 0;
  11706. for (; i <= imax; i++) {
  11707. t += ((sp_uint64)a[i]) * a[k - i];
  11708. }
  11709. c += t * 2;
  11710. r[k + 2] += (sp_digit) (c >> 58);
  11711. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  11712. c = (c & 0x1fffffff) << 29;
  11713. }
  11714. }
  11715. r[0] = (sp_digit)(c >> 29);
  11716. }
  11717. /* Calculate the bottom digit of -1/a mod 2^n.
  11718. *
  11719. * a A single precision number.
  11720. * rho Bottom word of inverse.
  11721. */
  11722. static void sp_4096_mont_setup(const sp_digit* a, sp_digit* rho)
  11723. {
  11724. sp_digit x;
  11725. sp_digit b;
  11726. b = a[0];
  11727. x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
  11728. x *= 2 - b * x; /* here x*a==1 mod 2**8 */
  11729. x *= 2 - b * x; /* here x*a==1 mod 2**16 */
  11730. x *= 2 - b * x; /* here x*a==1 mod 2**32 */
  11731. x &= 0x1fffffff;
  11732. /* rho = -1/m mod b */
  11733. *rho = ((sp_digit)1 << 29) - x;
  11734. }
  11735. /* Multiply a by scalar b into r. (r = a * b)
  11736. *
  11737. * r A single precision integer.
  11738. * a A single precision integer.
  11739. * b A scalar.
  11740. */
  11741. SP_NOINLINE static void sp_4096_mul_d_142(sp_digit* r, const sp_digit* a,
  11742. sp_digit b)
  11743. {
  11744. sp_int64 tb = b;
  11745. sp_int64 t = 0;
  11746. int i;
  11747. for (i = 0; i < 142; i++) {
  11748. t += tb * a[i];
  11749. r[i] = (sp_digit)(t & 0x1fffffff);
  11750. t >>= 29;
  11751. }
  11752. r[142] = (sp_digit)t;
  11753. }
  11754. #if (defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
  11755. #if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D)
  11756. /* Sub b from a into r. (r = a - b)
  11757. *
  11758. * r A single precision integer.
  11759. * a A single precision integer.
  11760. * b A single precision integer.
  11761. */
  11762. SP_NOINLINE static int sp_4096_sub_71(sp_digit* r, const sp_digit* a,
  11763. const sp_digit* b)
  11764. {
  11765. int i;
  11766. for (i = 0; i < 71; i++) {
  11767. r[i] = a[i] - b[i];
  11768. }
  11769. return 0;
  11770. }
  11771. /* r = 2^n mod m where n is the number of bits to reduce by.
  11772. * Given m must be 4096 bits, just need to subtract.
  11773. *
  11774. * r A single precision number.
  11775. * m A single precision number.
  11776. */
  11777. static void sp_4096_mont_norm_71(sp_digit* r, const sp_digit* m)
  11778. {
  11779. /* Set r = 2^n - 1. */
  11780. int i;
  11781. for (i=0; i<70; i++) {
  11782. r[i] = 0x1fffffff;
  11783. }
  11784. r[70] = 0x3ffffL;
  11785. /* r = (2^n - 1) mod n */
  11786. (void)sp_4096_sub_71(r, r, m);
  11787. /* Add one so r = 2^n mod m */
  11788. r[0] += 1;
  11789. }
  11790. /* Compare a with b in constant time.
  11791. *
  11792. * a A single precision integer.
  11793. * b A single precision integer.
  11794. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  11795. * respectively.
  11796. */
  11797. static sp_digit sp_4096_cmp_71(const sp_digit* a, const sp_digit* b)
  11798. {
  11799. sp_digit r = 0;
  11800. int i;
  11801. for (i=70; i>=0; i--) {
  11802. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  11803. }
  11804. return r;
  11805. }
  11806. /* Conditionally subtract b from a using the mask m.
  11807. * m is -1 to subtract and 0 when not.
  11808. *
  11809. * r A single precision number representing condition subtract result.
  11810. * a A single precision number to subtract from.
  11811. * b A single precision number to subtract.
  11812. * m Mask value to apply.
  11813. */
  11814. static void sp_4096_cond_sub_71(sp_digit* r, const sp_digit* a,
  11815. const sp_digit* b, const sp_digit m)
  11816. {
  11817. int i;
  11818. for (i = 0; i < 71; i++) {
  11819. r[i] = a[i] - (b[i] & m);
  11820. }
  11821. }
  11822. /* Mul a by scalar b and add into r. (r += a * b)
  11823. *
  11824. * r A single precision integer.
  11825. * a A single precision integer.
  11826. * b A scalar.
  11827. */
  11828. SP_NOINLINE static void sp_4096_mul_add_71(sp_digit* r, const sp_digit* a,
  11829. const sp_digit b)
  11830. {
  11831. #ifndef WOLFSSL_SP_LARGE_CODE
  11832. sp_int64 tb = b;
  11833. sp_int64 t = 0;
  11834. int i;
  11835. for (i = 0; i < 71; i++) {
  11836. t += r[i];
  11837. t += tb * a[i];
  11838. r[i] = ((sp_digit)t) & 0x1fffffff;
  11839. t >>= 29;
  11840. }
  11841. r[71] += (sp_digit)t;
  11842. #else
  11843. sp_int64 tb = b;
  11844. sp_int64 t[4];
  11845. int i;
  11846. t[0] = 0;
  11847. for (i = 0; i < 68; i += 4) {
  11848. t[0] += (tb * a[i+0]) + r[i+0];
  11849. t[1] = (tb * a[i+1]) + r[i+1];
  11850. t[2] = (tb * a[i+2]) + r[i+2];
  11851. t[3] = (tb * a[i+3]) + r[i+3];
  11852. r[i+0] = t[0] & 0x1fffffff;
  11853. t[1] += t[0] >> 29;
  11854. r[i+1] = t[1] & 0x1fffffff;
  11855. t[2] += t[1] >> 29;
  11856. r[i+2] = t[2] & 0x1fffffff;
  11857. t[3] += t[2] >> 29;
  11858. r[i+3] = t[3] & 0x1fffffff;
  11859. t[0] = t[3] >> 29;
  11860. }
  11861. t[0] += (tb * a[68]) + r[68];
  11862. t[1] = (tb * a[69]) + r[69];
  11863. t[2] = (tb * a[70]) + r[70];
  11864. r[68] = t[0] & 0x1fffffff;
  11865. t[1] += t[0] >> 29;
  11866. r[69] = t[1] & 0x1fffffff;
  11867. t[2] += t[1] >> 29;
  11868. r[70] = t[2] & 0x1fffffff;
  11869. r[71] += (sp_digit)(t[2] >> 29);
  11870. #endif /* !WOLFSSL_SP_LARGE_CODE */
  11871. }
  11872. /* Shift the result in the high 2048 bits down to the bottom.
  11873. *
  11874. * r A single precision number.
  11875. * a A single precision number.
  11876. */
  11877. static void sp_4096_mont_shift_71(sp_digit* r, const sp_digit* a)
  11878. {
  11879. int i;
  11880. sp_int64 n = a[70] >> 18;
  11881. n += ((sp_int64)a[71]) << 11;
  11882. for (i = 0; i < 70; i++) {
  11883. r[i] = n & 0x1fffffff;
  11884. n >>= 29;
  11885. n += ((sp_int64)a[72 + i]) << 11;
  11886. }
  11887. r[70] = (sp_digit)n;
  11888. XMEMSET(&r[71], 0, sizeof(*r) * 71U);
  11889. }
  11890. /* Reduce the number back to 4096 bits using Montgomery reduction.
  11891. *
  11892. * a A single precision number to reduce in place.
  11893. * m The single precision number representing the modulus.
  11894. * mp The digit representing the negative inverse of m mod 2^n.
  11895. */
  11896. static void sp_4096_mont_reduce_71(sp_digit* a, const sp_digit* m, sp_digit mp)
  11897. {
  11898. int i;
  11899. sp_digit mu;
  11900. sp_digit over;
  11901. sp_4096_norm_71(a + 71);
  11902. for (i=0; i<70; i++) {
  11903. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  11904. sp_4096_mul_add_71(a+i, m, mu);
  11905. a[i+1] += a[i] >> 29;
  11906. }
  11907. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffL;
  11908. sp_4096_mul_add_71(a+i, m, mu);
  11909. a[i+1] += a[i] >> 29;
  11910. a[i] &= 0x1fffffff;
  11911. sp_4096_mont_shift_71(a, a);
  11912. over = a[70] - m[70];
  11913. sp_4096_cond_sub_71(a, a, m, ~((over - 1) >> 31));
  11914. sp_4096_norm_71(a);
  11915. }
  11916. /* Multiply a and b into r. (r = a * b)
  11917. *
  11918. * r A single precision integer.
  11919. * a A single precision integer.
  11920. * b A single precision integer.
  11921. */
  11922. SP_NOINLINE static void sp_4096_mul_71(sp_digit* r, const sp_digit* a,
  11923. const sp_digit* b)
  11924. {
  11925. int i;
  11926. int imax;
  11927. int k;
  11928. sp_uint64 c;
  11929. sp_uint64 lo;
  11930. c = ((sp_uint64)a[70]) * b[70];
  11931. r[141] = (sp_digit)(c >> 29);
  11932. c &= 0x1fffffff;
  11933. for (k = 139; k >= 0; k--) {
  11934. if (k >= 71) {
  11935. i = k - 70;
  11936. imax = 70;
  11937. }
  11938. else {
  11939. i = 0;
  11940. imax = k;
  11941. }
  11942. if (imax - i > 15) {
  11943. int imaxlo;
  11944. lo = 0;
  11945. for (imaxlo = i; imaxlo <= imax; imaxlo += 15) {
  11946. for (; i <= imax && i < imaxlo + 15; i++) {
  11947. lo += ((sp_uint64)a[i]) * b[k - i];
  11948. }
  11949. c += lo >> 29;
  11950. lo &= 0x1fffffff;
  11951. }
  11952. r[k + 2] += (sp_digit)(c >> 29);
  11953. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  11954. c = lo & 0x1fffffff;
  11955. }
  11956. else {
  11957. lo = 0;
  11958. for (; i <= imax; i++) {
  11959. lo += ((sp_uint64)a[i]) * b[k - i];
  11960. }
  11961. c += lo >> 29;
  11962. r[k + 2] += (sp_digit)(c >> 29);
  11963. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  11964. c = lo & 0x1fffffff;
  11965. }
  11966. }
  11967. r[0] = (sp_digit)c;
  11968. }
  11969. /* Multiply two Montgomery form numbers mod the modulus (prime).
  11970. * (r = a * b mod m)
  11971. *
  11972. * r Result of multiplication.
  11973. * a First number to multiply in Montgomery form.
  11974. * b Second number to multiply in Montgomery form.
  11975. * m Modulus (prime).
  11976. * mp Montgomery multiplier.
  11977. */
  11978. SP_NOINLINE static void sp_4096_mont_mul_71(sp_digit* r, const sp_digit* a,
  11979. const sp_digit* b, const sp_digit* m, sp_digit mp)
  11980. {
  11981. sp_4096_mul_71(r, a, b);
  11982. sp_4096_mont_reduce_71(r, m, mp);
  11983. }
  11984. /* Square a and put result in r. (r = a * a)
  11985. *
  11986. * r A single precision integer.
  11987. * a A single precision integer.
  11988. */
  11989. SP_NOINLINE static void sp_4096_sqr_71(sp_digit* r, const sp_digit* a)
  11990. {
  11991. int i;
  11992. int imax;
  11993. int k;
  11994. sp_uint64 c;
  11995. sp_uint64 t;
  11996. c = ((sp_uint64)a[70]) * a[70];
  11997. r[141] = (sp_digit)(c >> 29);
  11998. c = (c & 0x1fffffff) << 29;
  11999. for (k = 139; k >= 0; k--) {
  12000. i = (k + 1) / 2;
  12001. if ((k & 1) == 0) {
  12002. c += ((sp_uint64)a[i]) * a[i];
  12003. i++;
  12004. }
  12005. if (k < 70) {
  12006. imax = k;
  12007. }
  12008. else {
  12009. imax = 70;
  12010. }
  12011. if (imax - i >= 14) {
  12012. int imaxlo;
  12013. sp_uint64 hi;
  12014. hi = c >> 29;
  12015. c &= 0x1fffffff;
  12016. for (imaxlo = i; imaxlo <= imax; imaxlo += 14) {
  12017. t = 0;
  12018. for (; i <= imax && i < imaxlo + 14; i++) {
  12019. t += ((sp_uint64)a[i]) * a[k - i];
  12020. }
  12021. c += t * 2;
  12022. hi += c >> 29;
  12023. c &= 0x1fffffff;
  12024. }
  12025. r[k + 2] += (sp_digit)(hi >> 29);
  12026. r[k + 1] = (sp_digit)(hi & 0x1fffffff);
  12027. c <<= 29;
  12028. }
  12029. else
  12030. {
  12031. t = 0;
  12032. for (; i <= imax; i++) {
  12033. t += ((sp_uint64)a[i]) * a[k - i];
  12034. }
  12035. c += t * 2;
  12036. r[k + 2] += (sp_digit) (c >> 58);
  12037. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  12038. c = (c & 0x1fffffff) << 29;
  12039. }
  12040. }
  12041. r[0] = (sp_digit)(c >> 29);
  12042. }
  12043. /* Square the Montgomery form number. (r = a * a mod m)
  12044. *
  12045. * r Result of squaring.
  12046. * a Number to square in Montgomery form.
  12047. * m Modulus (prime).
  12048. * mp Montgomery multiplier.
  12049. */
  12050. SP_NOINLINE static void sp_4096_mont_sqr_71(sp_digit* r, const sp_digit* a,
  12051. const sp_digit* m, sp_digit mp)
  12052. {
  12053. sp_4096_sqr_71(r, a);
  12054. sp_4096_mont_reduce_71(r, m, mp);
  12055. }
  12056. /* Multiply a by scalar b into r. (r = a * b)
  12057. *
  12058. * r A single precision integer.
  12059. * a A single precision integer.
  12060. * b A scalar.
  12061. */
  12062. SP_NOINLINE static void sp_4096_mul_d_71(sp_digit* r, const sp_digit* a,
  12063. sp_digit b)
  12064. {
  12065. sp_int64 tb = b;
  12066. sp_int64 t = 0;
  12067. int i;
  12068. for (i = 0; i < 71; i++) {
  12069. t += tb * a[i];
  12070. r[i] = (sp_digit)(t & 0x1fffffff);
  12071. t >>= 29;
  12072. }
  12073. r[71] = (sp_digit)t;
  12074. }
  12075. #ifdef WOLFSSL_SP_SMALL
  12076. /* Conditionally add a and b using the mask m.
  12077. * m is -1 to add and 0 when not.
  12078. *
  12079. * r A single precision number representing conditional add result.
  12080. * a A single precision number to add with.
  12081. * b A single precision number to add.
  12082. * m Mask value to apply.
  12083. */
  12084. static void sp_4096_cond_add_71(sp_digit* r, const sp_digit* a,
  12085. const sp_digit* b, const sp_digit m)
  12086. {
  12087. int i;
  12088. for (i = 0; i < 71; i++) {
  12089. r[i] = a[i] + (b[i] & m);
  12090. }
  12091. }
  12092. #endif /* WOLFSSL_SP_SMALL */
  12093. /* Add b to a into r. (r = a + b)
  12094. *
  12095. * r A single precision integer.
  12096. * a A single precision integer.
  12097. * b A single precision integer.
  12098. */
  12099. SP_NOINLINE static int sp_4096_add_71(sp_digit* r, const sp_digit* a,
  12100. const sp_digit* b)
  12101. {
  12102. int i;
  12103. for (i = 0; i < 71; i++) {
  12104. r[i] = a[i] + b[i];
  12105. }
  12106. return 0;
  12107. }
  12108. SP_NOINLINE static void sp_4096_rshift_71(sp_digit* r, const sp_digit* a,
  12109. byte n)
  12110. {
  12111. int i;
  12112. for (i=0; i<70; i++) {
  12113. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  12114. }
  12115. r[70] = a[70] >> n;
  12116. }
  12117. static WC_INLINE sp_digit sp_4096_div_word_71(sp_digit d1, sp_digit d0,
  12118. sp_digit div)
  12119. {
  12120. #ifdef SP_USE_DIVTI3
  12121. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12122. return d / div;
  12123. #elif defined(__x86_64__) || defined(__i386__)
  12124. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12125. sp_uint32 lo = (sp_uint32)d;
  12126. sp_digit hi = (sp_digit)(d >> 32);
  12127. __asm__ __volatile__ (
  12128. "idiv %2"
  12129. : "+a" (lo)
  12130. : "d" (hi), "r" (div)
  12131. : "cc"
  12132. );
  12133. return (sp_digit)lo;
  12134. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  12135. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12136. sp_digit dv = (div >> 1) + 1;
  12137. sp_digit t1 = (sp_digit)(d >> 29);
  12138. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  12139. sp_digit t2;
  12140. sp_digit sign;
  12141. sp_digit r;
  12142. int i;
  12143. sp_int64 m;
  12144. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  12145. t1 -= dv & (0 - r);
  12146. for (i = 27; i >= 1; i--) {
  12147. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  12148. t0 <<= 1;
  12149. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  12150. r += r + t2;
  12151. t1 -= dv & (0 - t2);
  12152. t1 += t2;
  12153. }
  12154. r += r + 1;
  12155. m = d - ((sp_int64)r * div);
  12156. r += (sp_digit)(m >> 29);
  12157. m = d - ((sp_int64)r * div);
  12158. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  12159. m = d - ((sp_int64)r * div);
  12160. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  12161. m *= sign;
  12162. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  12163. r += sign * t2;
  12164. m = d - ((sp_int64)r * div);
  12165. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  12166. m *= sign;
  12167. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  12168. r += sign * t2;
  12169. return r;
  12170. #else
  12171. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12172. sp_digit r = 0;
  12173. sp_digit t;
  12174. sp_digit dv = (div >> 14) + 1;
  12175. t = (sp_digit)(d >> 28);
  12176. t = (t / dv) << 14;
  12177. r += t;
  12178. d -= (sp_int64)t * div;
  12179. t = (sp_digit)(d >> 13);
  12180. t = t / (dv << 1);
  12181. r += t;
  12182. d -= (sp_int64)t * div;
  12183. t = (sp_digit)d;
  12184. t = t / div;
  12185. r += t;
  12186. d -= (sp_int64)t * div;
  12187. return r;
  12188. #endif
  12189. }
  12190. static WC_INLINE sp_digit sp_4096_word_div_word_71(sp_digit d, sp_digit div)
  12191. {
  12192. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  12193. defined(SP_DIV_WORD_USE_DIV)
  12194. return d / div;
  12195. #else
  12196. return (sp_digit)((sp_uint32)(div - d) >> 31);
  12197. #endif
  12198. }
  12199. /* Divide d in a and put remainder into r (m*d + r = a)
  12200. * m is not calculated as it is not needed at this time.
  12201. *
  12202. * Full implementation.
  12203. *
  12204. * a Number to be divided.
  12205. * d Number to divide with.
  12206. * m Multiplier result.
  12207. * r Remainder from the division.
  12208. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  12209. */
  12210. static int sp_4096_div_71(const sp_digit* a, const sp_digit* d,
  12211. const sp_digit* m, sp_digit* r)
  12212. {
  12213. int i;
  12214. #ifndef WOLFSSL_SP_DIV_32
  12215. #endif
  12216. sp_digit dv;
  12217. sp_digit r1;
  12218. #ifdef WOLFSSL_SP_SMALL_STACK
  12219. sp_digit* t1 = NULL;
  12220. #else
  12221. sp_digit t1[4 * 71 + 3];
  12222. #endif
  12223. sp_digit* t2 = NULL;
  12224. sp_digit* sd = NULL;
  12225. int err = MP_OKAY;
  12226. (void)m;
  12227. #ifdef WOLFSSL_SP_SMALL_STACK
  12228. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 71 + 3), NULL,
  12229. DYNAMIC_TYPE_TMP_BUFFER);
  12230. if (t1 == NULL)
  12231. err = MEMORY_E;
  12232. #endif
  12233. (void)m;
  12234. if (err == MP_OKAY) {
  12235. t2 = t1 + 142 + 1;
  12236. sd = t2 + 71 + 1;
  12237. sp_4096_mul_d_71(sd, d, (sp_digit)1 << 11);
  12238. sp_4096_mul_d_142(t1, a, (sp_digit)1 << 11);
  12239. dv = sd[70];
  12240. t1[71 + 71] += t1[71 + 71 - 1] >> 29;
  12241. t1[71 + 71 - 1] &= 0x1fffffff;
  12242. for (i=71; i>=0; i--) {
  12243. r1 = sp_4096_div_word_71(t1[71 + i], t1[71 + i - 1], dv);
  12244. sp_4096_mul_d_71(t2, sd, r1);
  12245. (void)sp_4096_sub_71(&t1[i], &t1[i], t2);
  12246. sp_4096_norm_71(&t1[i]);
  12247. t1[71 + i] -= t2[71];
  12248. t1[71 + i] += t1[71 + i - 1] >> 29;
  12249. t1[71 + i - 1] &= 0x1fffffff;
  12250. r1 = sp_4096_div_word_71(-t1[71 + i], -t1[71 + i - 1], dv);
  12251. r1 -= t1[71 + i];
  12252. sp_4096_mul_d_71(t2, sd, r1);
  12253. (void)sp_4096_add_71(&t1[i], &t1[i], t2);
  12254. t1[71 + i] += t1[71 + i - 1] >> 29;
  12255. t1[71 + i - 1] &= 0x1fffffff;
  12256. }
  12257. t1[71 - 1] += t1[71 - 2] >> 29;
  12258. t1[71 - 2] &= 0x1fffffff;
  12259. r1 = sp_4096_word_div_word_71(t1[71 - 1], dv);
  12260. sp_4096_mul_d_71(t2, sd, r1);
  12261. sp_4096_sub_71(t1, t1, t2);
  12262. XMEMCPY(r, t1, sizeof(*r) * 142U);
  12263. for (i=0; i<70; i++) {
  12264. r[i+1] += r[i] >> 29;
  12265. r[i] &= 0x1fffffff;
  12266. }
  12267. sp_4096_cond_add_71(r, r, sd, r[70] >> 31);
  12268. sp_4096_norm_71(r);
  12269. sp_4096_rshift_71(r, r, 11);
  12270. }
  12271. #ifdef WOLFSSL_SP_SMALL_STACK
  12272. if (t1 != NULL)
  12273. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  12274. #endif
  12275. return err;
  12276. }
  12277. /* Reduce a modulo m into r. (r = a mod m)
  12278. *
  12279. * r A single precision number that is the reduced result.
  12280. * a A single precision number that is to be reduced.
  12281. * m A single precision number that is the modulus to reduce with.
  12282. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  12283. */
  12284. static int sp_4096_mod_71(sp_digit* r, const sp_digit* a, const sp_digit* m)
  12285. {
  12286. return sp_4096_div_71(a, m, NULL, r);
  12287. }
  12288. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  12289. *
  12290. * r A single precision number that is the result of the operation.
  12291. * a A single precision number being exponentiated.
  12292. * e A single precision number that is the exponent.
  12293. * bits The number of bits in the exponent.
  12294. * m A single precision number that is the modulus.
  12295. * returns 0 on success.
  12296. * returns MEMORY_E on dynamic memory allocation failure.
  12297. * returns MP_VAL when base is even or exponent is 0.
  12298. */
  12299. static int sp_4096_mod_exp_71(sp_digit* r, const sp_digit* a, const sp_digit* e,
  12300. int bits, const sp_digit* m, int reduceA)
  12301. {
  12302. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  12303. #ifdef WOLFSSL_SP_SMALL_STACK
  12304. sp_digit* td = NULL;
  12305. #else
  12306. sp_digit td[3 * 142];
  12307. #endif
  12308. sp_digit* t[3] = {0, 0, 0};
  12309. sp_digit* norm = NULL;
  12310. sp_digit mp = 1;
  12311. sp_digit n;
  12312. int i;
  12313. int c;
  12314. byte y;
  12315. int err = MP_OKAY;
  12316. if (bits == 0) {
  12317. err = MP_VAL;
  12318. }
  12319. #ifdef WOLFSSL_SP_SMALL_STACK
  12320. if (err == MP_OKAY) {
  12321. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 71 * 2, NULL,
  12322. DYNAMIC_TYPE_TMP_BUFFER);
  12323. if (td == NULL)
  12324. err = MEMORY_E;
  12325. }
  12326. #endif
  12327. if (err == MP_OKAY) {
  12328. norm = td;
  12329. for (i=0; i<3; i++) {
  12330. t[i] = td + (i * 71 * 2);
  12331. XMEMSET(t[i], 0, sizeof(sp_digit) * 71U * 2U);
  12332. }
  12333. sp_4096_mont_setup(m, &mp);
  12334. sp_4096_mont_norm_71(norm, m);
  12335. if (reduceA != 0) {
  12336. err = sp_4096_mod_71(t[1], a, m);
  12337. }
  12338. else {
  12339. XMEMCPY(t[1], a, sizeof(sp_digit) * 71U);
  12340. }
  12341. }
  12342. if (err == MP_OKAY) {
  12343. sp_4096_mul_71(t[1], t[1], norm);
  12344. err = sp_4096_mod_71(t[1], t[1], m);
  12345. }
  12346. if (err == MP_OKAY) {
  12347. i = bits / 29;
  12348. c = bits % 29;
  12349. n = e[i--] << (29 - c);
  12350. for (; ; c--) {
  12351. if (c == 0) {
  12352. if (i == -1) {
  12353. break;
  12354. }
  12355. n = e[i--];
  12356. c = 29;
  12357. }
  12358. y = (int)((n >> 28) & 1);
  12359. n <<= 1;
  12360. sp_4096_mont_mul_71(t[y^1], t[0], t[1], m, mp);
  12361. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  12362. ((size_t)t[1] & addr_mask[y])),
  12363. sizeof(*t[2]) * 71 * 2);
  12364. sp_4096_mont_sqr_71(t[2], t[2], m, mp);
  12365. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  12366. ((size_t)t[1] & addr_mask[y])), t[2],
  12367. sizeof(*t[2]) * 71 * 2);
  12368. }
  12369. sp_4096_mont_reduce_71(t[0], m, mp);
  12370. n = sp_4096_cmp_71(t[0], m);
  12371. sp_4096_cond_sub_71(t[0], t[0], m, ~(n >> 31));
  12372. XMEMCPY(r, t[0], sizeof(*r) * 71 * 2);
  12373. }
  12374. #ifdef WOLFSSL_SP_SMALL_STACK
  12375. if (td != NULL)
  12376. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  12377. #endif
  12378. return err;
  12379. #elif !defined(WC_NO_CACHE_RESISTANT)
  12380. #ifdef WOLFSSL_SP_SMALL_STACK
  12381. sp_digit* td = NULL;
  12382. #else
  12383. sp_digit td[3 * 142];
  12384. #endif
  12385. sp_digit* t[3] = {0, 0, 0};
  12386. sp_digit* norm = NULL;
  12387. sp_digit mp = 1;
  12388. sp_digit n;
  12389. int i;
  12390. int c;
  12391. byte y;
  12392. int err = MP_OKAY;
  12393. if (bits == 0) {
  12394. err = MP_VAL;
  12395. }
  12396. #ifdef WOLFSSL_SP_SMALL_STACK
  12397. if (err == MP_OKAY) {
  12398. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 71 * 2, NULL,
  12399. DYNAMIC_TYPE_TMP_BUFFER);
  12400. if (td == NULL)
  12401. err = MEMORY_E;
  12402. }
  12403. #endif
  12404. if (err == MP_OKAY) {
  12405. norm = td;
  12406. for (i=0; i<3; i++) {
  12407. t[i] = td + (i * 71 * 2);
  12408. }
  12409. sp_4096_mont_setup(m, &mp);
  12410. sp_4096_mont_norm_71(norm, m);
  12411. if (reduceA != 0) {
  12412. err = sp_4096_mod_71(t[1], a, m);
  12413. if (err == MP_OKAY) {
  12414. sp_4096_mul_71(t[1], t[1], norm);
  12415. err = sp_4096_mod_71(t[1], t[1], m);
  12416. }
  12417. }
  12418. else {
  12419. sp_4096_mul_71(t[1], a, norm);
  12420. err = sp_4096_mod_71(t[1], t[1], m);
  12421. }
  12422. }
  12423. if (err == MP_OKAY) {
  12424. i = bits / 29;
  12425. c = bits % 29;
  12426. n = e[i--] << (29 - c);
  12427. for (; ; c--) {
  12428. if (c == 0) {
  12429. if (i == -1) {
  12430. break;
  12431. }
  12432. n = e[i--];
  12433. c = 29;
  12434. }
  12435. y = (int)((n >> 28) & 1);
  12436. n <<= 1;
  12437. sp_4096_mont_mul_71(t[y^1], t[0], t[1], m, mp);
  12438. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  12439. ((size_t)t[1] & addr_mask[y])),
  12440. sizeof(*t[2]) * 71 * 2);
  12441. sp_4096_mont_sqr_71(t[2], t[2], m, mp);
  12442. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  12443. ((size_t)t[1] & addr_mask[y])), t[2],
  12444. sizeof(*t[2]) * 71 * 2);
  12445. }
  12446. sp_4096_mont_reduce_71(t[0], m, mp);
  12447. n = sp_4096_cmp_71(t[0], m);
  12448. sp_4096_cond_sub_71(t[0], t[0], m, ~(n >> 31));
  12449. XMEMCPY(r, t[0], sizeof(*r) * 71 * 2);
  12450. }
  12451. #ifdef WOLFSSL_SP_SMALL_STACK
  12452. if (td != NULL)
  12453. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  12454. #endif
  12455. return err;
  12456. #else
  12457. #ifdef WOLFSSL_SP_SMALL_STACK
  12458. sp_digit* td = NULL;
  12459. #else
  12460. sp_digit td[(32 * 142) + 142];
  12461. #endif
  12462. sp_digit* t[32];
  12463. sp_digit* rt = NULL;
  12464. sp_digit* norm = NULL;
  12465. sp_digit mp = 1;
  12466. sp_digit n;
  12467. int i;
  12468. int c;
  12469. byte y;
  12470. int err = MP_OKAY;
  12471. if (bits == 0) {
  12472. err = MP_VAL;
  12473. }
  12474. #ifdef WOLFSSL_SP_SMALL_STACK
  12475. if (err == MP_OKAY) {
  12476. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((32 * 142) + 142), NULL,
  12477. DYNAMIC_TYPE_TMP_BUFFER);
  12478. if (td == NULL)
  12479. err = MEMORY_E;
  12480. }
  12481. #endif
  12482. if (err == MP_OKAY) {
  12483. norm = td;
  12484. for (i=0; i<32; i++)
  12485. t[i] = td + i * 142;
  12486. rt = td + 4544;
  12487. sp_4096_mont_setup(m, &mp);
  12488. sp_4096_mont_norm_71(norm, m);
  12489. if (reduceA != 0) {
  12490. err = sp_4096_mod_71(t[1], a, m);
  12491. if (err == MP_OKAY) {
  12492. sp_4096_mul_71(t[1], t[1], norm);
  12493. err = sp_4096_mod_71(t[1], t[1], m);
  12494. }
  12495. }
  12496. else {
  12497. sp_4096_mul_71(t[1], a, norm);
  12498. err = sp_4096_mod_71(t[1], t[1], m);
  12499. }
  12500. }
  12501. if (err == MP_OKAY) {
  12502. sp_4096_mont_sqr_71(t[ 2], t[ 1], m, mp);
  12503. sp_4096_mont_mul_71(t[ 3], t[ 2], t[ 1], m, mp);
  12504. sp_4096_mont_sqr_71(t[ 4], t[ 2], m, mp);
  12505. sp_4096_mont_mul_71(t[ 5], t[ 3], t[ 2], m, mp);
  12506. sp_4096_mont_sqr_71(t[ 6], t[ 3], m, mp);
  12507. sp_4096_mont_mul_71(t[ 7], t[ 4], t[ 3], m, mp);
  12508. sp_4096_mont_sqr_71(t[ 8], t[ 4], m, mp);
  12509. sp_4096_mont_mul_71(t[ 9], t[ 5], t[ 4], m, mp);
  12510. sp_4096_mont_sqr_71(t[10], t[ 5], m, mp);
  12511. sp_4096_mont_mul_71(t[11], t[ 6], t[ 5], m, mp);
  12512. sp_4096_mont_sqr_71(t[12], t[ 6], m, mp);
  12513. sp_4096_mont_mul_71(t[13], t[ 7], t[ 6], m, mp);
  12514. sp_4096_mont_sqr_71(t[14], t[ 7], m, mp);
  12515. sp_4096_mont_mul_71(t[15], t[ 8], t[ 7], m, mp);
  12516. sp_4096_mont_sqr_71(t[16], t[ 8], m, mp);
  12517. sp_4096_mont_mul_71(t[17], t[ 9], t[ 8], m, mp);
  12518. sp_4096_mont_sqr_71(t[18], t[ 9], m, mp);
  12519. sp_4096_mont_mul_71(t[19], t[10], t[ 9], m, mp);
  12520. sp_4096_mont_sqr_71(t[20], t[10], m, mp);
  12521. sp_4096_mont_mul_71(t[21], t[11], t[10], m, mp);
  12522. sp_4096_mont_sqr_71(t[22], t[11], m, mp);
  12523. sp_4096_mont_mul_71(t[23], t[12], t[11], m, mp);
  12524. sp_4096_mont_sqr_71(t[24], t[12], m, mp);
  12525. sp_4096_mont_mul_71(t[25], t[13], t[12], m, mp);
  12526. sp_4096_mont_sqr_71(t[26], t[13], m, mp);
  12527. sp_4096_mont_mul_71(t[27], t[14], t[13], m, mp);
  12528. sp_4096_mont_sqr_71(t[28], t[14], m, mp);
  12529. sp_4096_mont_mul_71(t[29], t[15], t[14], m, mp);
  12530. sp_4096_mont_sqr_71(t[30], t[15], m, mp);
  12531. sp_4096_mont_mul_71(t[31], t[16], t[15], m, mp);
  12532. bits = ((bits + 4) / 5) * 5;
  12533. i = ((bits + 28) / 29) - 1;
  12534. c = bits % 29;
  12535. if (c == 0) {
  12536. c = 29;
  12537. }
  12538. if (i < 71) {
  12539. n = e[i--] << (32 - c);
  12540. }
  12541. else {
  12542. n = 0;
  12543. i--;
  12544. }
  12545. if (c < 5) {
  12546. n |= e[i--] << (3 - c);
  12547. c += 29;
  12548. }
  12549. y = (int)((n >> 27) & 0x1f);
  12550. n <<= 5;
  12551. c -= 5;
  12552. XMEMCPY(rt, t[y], sizeof(sp_digit) * 142);
  12553. while ((i >= 0) || (c >= 5)) {
  12554. if (c >= 5) {
  12555. y = (byte)((n >> 27) & 0x1f);
  12556. n <<= 5;
  12557. c -= 5;
  12558. }
  12559. else if (c == 0) {
  12560. n = e[i--] << 3;
  12561. y = (byte)((n >> 27) & 0x1f);
  12562. n <<= 5;
  12563. c = 24;
  12564. }
  12565. else {
  12566. y = (byte)((n >> 27) & 0x1f);
  12567. n = e[i--] << 3;
  12568. c = 5 - c;
  12569. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  12570. n <<= c;
  12571. c = 29 - c;
  12572. }
  12573. sp_4096_mont_sqr_71(rt, rt, m, mp);
  12574. sp_4096_mont_sqr_71(rt, rt, m, mp);
  12575. sp_4096_mont_sqr_71(rt, rt, m, mp);
  12576. sp_4096_mont_sqr_71(rt, rt, m, mp);
  12577. sp_4096_mont_sqr_71(rt, rt, m, mp);
  12578. sp_4096_mont_mul_71(rt, rt, t[y], m, mp);
  12579. }
  12580. sp_4096_mont_reduce_71(rt, m, mp);
  12581. n = sp_4096_cmp_71(rt, m);
  12582. sp_4096_cond_sub_71(rt, rt, m, ~(n >> 31));
  12583. XMEMCPY(r, rt, sizeof(sp_digit) * 142);
  12584. }
  12585. #ifdef WOLFSSL_SP_SMALL_STACK
  12586. if (td != NULL)
  12587. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  12588. #endif
  12589. return err;
  12590. #endif
  12591. }
  12592. #endif /* WOLFSSL_HAVE_SP_RSA & !SP_RSA_PRIVATE_EXP_D */
  12593. #endif /* (WOLFSSL_HAVE_SP_RSA | WOLFSSL_HAVE_SP_DH) & !WOLFSSL_RSA_PUBLIC_ONLY */
  12594. /* Sub b from a into r. (r = a - b)
  12595. *
  12596. * r A single precision integer.
  12597. * a A single precision integer.
  12598. * b A single precision integer.
  12599. */
  12600. SP_NOINLINE static int sp_4096_sub_142(sp_digit* r, const sp_digit* a,
  12601. const sp_digit* b)
  12602. {
  12603. int i;
  12604. for (i = 0; i < 142; i++) {
  12605. r[i] = a[i] - b[i];
  12606. }
  12607. return 0;
  12608. }
  12609. /* r = 2^n mod m where n is the number of bits to reduce by.
  12610. * Given m must be 4096 bits, just need to subtract.
  12611. *
  12612. * r A single precision number.
  12613. * m A single precision number.
  12614. */
  12615. static void sp_4096_mont_norm_142(sp_digit* r, const sp_digit* m)
  12616. {
  12617. /* Set r = 2^n - 1. */
  12618. int i;
  12619. for (i=0; i<141; i++) {
  12620. r[i] = 0x1fffffff;
  12621. }
  12622. r[141] = 0x7fL;
  12623. /* r = (2^n - 1) mod n */
  12624. (void)sp_4096_sub_142(r, r, m);
  12625. /* Add one so r = 2^n mod m */
  12626. r[0] += 1;
  12627. }
  12628. /* Compare a with b in constant time.
  12629. *
  12630. * a A single precision integer.
  12631. * b A single precision integer.
  12632. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  12633. * respectively.
  12634. */
  12635. static sp_digit sp_4096_cmp_142(const sp_digit* a, const sp_digit* b)
  12636. {
  12637. sp_digit r = 0;
  12638. int i;
  12639. for (i=141; i>=0; i--) {
  12640. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  12641. }
  12642. return r;
  12643. }
  12644. /* Conditionally subtract b from a using the mask m.
  12645. * m is -1 to subtract and 0 when not.
  12646. *
  12647. * r A single precision number representing condition subtract result.
  12648. * a A single precision number to subtract from.
  12649. * b A single precision number to subtract.
  12650. * m Mask value to apply.
  12651. */
  12652. static void sp_4096_cond_sub_142(sp_digit* r, const sp_digit* a,
  12653. const sp_digit* b, const sp_digit m)
  12654. {
  12655. int i;
  12656. for (i = 0; i < 142; i++) {
  12657. r[i] = a[i] - (b[i] & m);
  12658. }
  12659. }
  12660. /* Mul a by scalar b and add into r. (r += a * b)
  12661. *
  12662. * r A single precision integer.
  12663. * a A single precision integer.
  12664. * b A scalar.
  12665. */
  12666. SP_NOINLINE static void sp_4096_mul_add_142(sp_digit* r, const sp_digit* a,
  12667. const sp_digit b)
  12668. {
  12669. #ifndef WOLFSSL_SP_LARGE_CODE
  12670. sp_int64 tb = b;
  12671. sp_int64 t = 0;
  12672. int i;
  12673. for (i = 0; i < 142; i++) {
  12674. t += r[i];
  12675. t += tb * a[i];
  12676. r[i] = ((sp_digit)t) & 0x1fffffff;
  12677. t >>= 29;
  12678. }
  12679. r[142] += (sp_digit)t;
  12680. #else
  12681. sp_int64 tb = b;
  12682. sp_int64 t[4];
  12683. int i;
  12684. t[0] = 0;
  12685. for (i = 0; i < 140; i += 4) {
  12686. t[0] += (tb * a[i+0]) + r[i+0];
  12687. t[1] = (tb * a[i+1]) + r[i+1];
  12688. t[2] = (tb * a[i+2]) + r[i+2];
  12689. t[3] = (tb * a[i+3]) + r[i+3];
  12690. r[i+0] = t[0] & 0x1fffffff;
  12691. t[1] += t[0] >> 29;
  12692. r[i+1] = t[1] & 0x1fffffff;
  12693. t[2] += t[1] >> 29;
  12694. r[i+2] = t[2] & 0x1fffffff;
  12695. t[3] += t[2] >> 29;
  12696. r[i+3] = t[3] & 0x1fffffff;
  12697. t[0] = t[3] >> 29;
  12698. }
  12699. t[0] += (tb * a[140]) + r[140];
  12700. t[1] = (tb * a[141]) + r[141];
  12701. r[140] = t[0] & 0x1fffffff;
  12702. t[1] += t[0] >> 29;
  12703. r[141] = t[1] & 0x1fffffff;
  12704. r[142] += (sp_digit)(t[1] >> 29);
  12705. #endif /* !WOLFSSL_SP_LARGE_CODE */
  12706. }
  12707. /* Shift the result in the high 4096 bits down to the bottom.
  12708. *
  12709. * r A single precision number.
  12710. * a A single precision number.
  12711. */
  12712. static void sp_4096_mont_shift_142(sp_digit* r, const sp_digit* a)
  12713. {
  12714. int i;
  12715. sp_int64 n = a[141] >> 7;
  12716. n += ((sp_int64)a[142]) << 22;
  12717. for (i = 0; i < 141; i++) {
  12718. r[i] = n & 0x1fffffff;
  12719. n >>= 29;
  12720. n += ((sp_int64)a[143 + i]) << 22;
  12721. }
  12722. r[141] = (sp_digit)n;
  12723. XMEMSET(&r[142], 0, sizeof(*r) * 142U);
  12724. }
  12725. /* Reduce the number back to 4096 bits using Montgomery reduction.
  12726. *
  12727. * a A single precision number to reduce in place.
  12728. * m The single precision number representing the modulus.
  12729. * mp The digit representing the negative inverse of m mod 2^n.
  12730. */
  12731. static void sp_4096_mont_reduce_142(sp_digit* a, const sp_digit* m, sp_digit mp)
  12732. {
  12733. int i;
  12734. sp_digit mu;
  12735. sp_digit over;
  12736. sp_4096_norm_142(a + 142);
  12737. #ifdef WOLFSSL_SP_DH
  12738. if (mp != 1) {
  12739. for (i=0; i<141; i++) {
  12740. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  12741. sp_4096_mul_add_142(a+i, m, mu);
  12742. a[i+1] += a[i] >> 29;
  12743. }
  12744. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x7fL;
  12745. sp_4096_mul_add_142(a+i, m, mu);
  12746. a[i+1] += a[i] >> 29;
  12747. a[i] &= 0x1fffffff;
  12748. }
  12749. else {
  12750. for (i=0; i<141; i++) {
  12751. mu = a[i] & 0x1fffffff;
  12752. sp_4096_mul_add_142(a+i, m, mu);
  12753. a[i+1] += a[i] >> 29;
  12754. }
  12755. mu = a[i] & 0x7fL;
  12756. sp_4096_mul_add_142(a+i, m, mu);
  12757. a[i+1] += a[i] >> 29;
  12758. a[i] &= 0x1fffffff;
  12759. }
  12760. #else
  12761. for (i=0; i<141; i++) {
  12762. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  12763. sp_4096_mul_add_142(a+i, m, mu);
  12764. a[i+1] += a[i] >> 29;
  12765. }
  12766. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x7fL;
  12767. sp_4096_mul_add_142(a+i, m, mu);
  12768. a[i+1] += a[i] >> 29;
  12769. a[i] &= 0x1fffffff;
  12770. #endif
  12771. sp_4096_mont_shift_142(a, a);
  12772. over = a[141] - m[141];
  12773. sp_4096_cond_sub_142(a, a, m, ~((over - 1) >> 31));
  12774. sp_4096_norm_142(a);
  12775. }
  12776. /* Multiply two Montgomery form numbers mod the modulus (prime).
  12777. * (r = a * b mod m)
  12778. *
  12779. * r Result of multiplication.
  12780. * a First number to multiply in Montgomery form.
  12781. * b Second number to multiply in Montgomery form.
  12782. * m Modulus (prime).
  12783. * mp Montgomery multiplier.
  12784. */
  12785. SP_NOINLINE static void sp_4096_mont_mul_142(sp_digit* r, const sp_digit* a,
  12786. const sp_digit* b, const sp_digit* m, sp_digit mp)
  12787. {
  12788. sp_4096_mul_142(r, a, b);
  12789. sp_4096_mont_reduce_142(r, m, mp);
  12790. }
  12791. /* Square the Montgomery form number. (r = a * a mod m)
  12792. *
  12793. * r Result of squaring.
  12794. * a Number to square in Montgomery form.
  12795. * m Modulus (prime).
  12796. * mp Montgomery multiplier.
  12797. */
  12798. SP_NOINLINE static void sp_4096_mont_sqr_142(sp_digit* r, const sp_digit* a,
  12799. const sp_digit* m, sp_digit mp)
  12800. {
  12801. sp_4096_sqr_142(r, a);
  12802. sp_4096_mont_reduce_142(r, m, mp);
  12803. }
  12804. /* Multiply a by scalar b into r. (r = a * b)
  12805. *
  12806. * r A single precision integer.
  12807. * a A single precision integer.
  12808. * b A scalar.
  12809. */
  12810. SP_NOINLINE static void sp_4096_mul_d_284(sp_digit* r, const sp_digit* a,
  12811. sp_digit b)
  12812. {
  12813. sp_int64 tb = b;
  12814. sp_int64 t = 0;
  12815. int i;
  12816. for (i = 0; i < 284; i++) {
  12817. t += tb * a[i];
  12818. r[i] = (sp_digit)(t & 0x1fffffff);
  12819. t >>= 29;
  12820. }
  12821. r[284] = (sp_digit)t;
  12822. }
  12823. #ifdef WOLFSSL_SP_SMALL
  12824. /* Conditionally add a and b using the mask m.
  12825. * m is -1 to add and 0 when not.
  12826. *
  12827. * r A single precision number representing conditional add result.
  12828. * a A single precision number to add with.
  12829. * b A single precision number to add.
  12830. * m Mask value to apply.
  12831. */
  12832. static void sp_4096_cond_add_142(sp_digit* r, const sp_digit* a,
  12833. const sp_digit* b, const sp_digit m)
  12834. {
  12835. int i;
  12836. for (i = 0; i < 142; i++) {
  12837. r[i] = a[i] + (b[i] & m);
  12838. }
  12839. }
  12840. #endif /* WOLFSSL_SP_SMALL */
  12841. /* Add b to a into r. (r = a + b)
  12842. *
  12843. * r A single precision integer.
  12844. * a A single precision integer.
  12845. * b A single precision integer.
  12846. */
  12847. SP_NOINLINE static int sp_4096_add_142(sp_digit* r, const sp_digit* a,
  12848. const sp_digit* b)
  12849. {
  12850. int i;
  12851. for (i = 0; i < 142; i++) {
  12852. r[i] = a[i] + b[i];
  12853. }
  12854. return 0;
  12855. }
  12856. SP_NOINLINE static void sp_4096_rshift_142(sp_digit* r, const sp_digit* a,
  12857. byte n)
  12858. {
  12859. int i;
  12860. for (i=0; i<141; i++) {
  12861. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  12862. }
  12863. r[141] = a[141] >> n;
  12864. }
  12865. static WC_INLINE sp_digit sp_4096_div_word_142(sp_digit d1, sp_digit d0,
  12866. sp_digit div)
  12867. {
  12868. #ifdef SP_USE_DIVTI3
  12869. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12870. return d / div;
  12871. #elif defined(__x86_64__) || defined(__i386__)
  12872. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12873. sp_uint32 lo = (sp_uint32)d;
  12874. sp_digit hi = (sp_digit)(d >> 32);
  12875. __asm__ __volatile__ (
  12876. "idiv %2"
  12877. : "+a" (lo)
  12878. : "d" (hi), "r" (div)
  12879. : "cc"
  12880. );
  12881. return (sp_digit)lo;
  12882. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  12883. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12884. sp_digit dv = (div >> 1) + 1;
  12885. sp_digit t1 = (sp_digit)(d >> 29);
  12886. sp_digit t0 = (sp_digit)(d & 0x1fffffff);
  12887. sp_digit t2;
  12888. sp_digit sign;
  12889. sp_digit r;
  12890. int i;
  12891. sp_int64 m;
  12892. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  12893. t1 -= dv & (0 - r);
  12894. for (i = 27; i >= 1; i--) {
  12895. t1 += t1 + (((sp_uint32)t0 >> 28) & 1);
  12896. t0 <<= 1;
  12897. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  12898. r += r + t2;
  12899. t1 -= dv & (0 - t2);
  12900. t1 += t2;
  12901. }
  12902. r += r + 1;
  12903. m = d - ((sp_int64)r * div);
  12904. r += (sp_digit)(m >> 29);
  12905. m = d - ((sp_int64)r * div);
  12906. r += (sp_digit)(m >> 58) - (sp_digit)(d >> 58);
  12907. m = d - ((sp_int64)r * div);
  12908. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  12909. m *= sign;
  12910. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  12911. r += sign * t2;
  12912. m = d - ((sp_int64)r * div);
  12913. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  12914. m *= sign;
  12915. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  12916. r += sign * t2;
  12917. return r;
  12918. #else
  12919. sp_int64 d = ((sp_int64)d1 << 29) + d0;
  12920. sp_digit r = 0;
  12921. sp_digit t;
  12922. sp_digit dv = (div >> 14) + 1;
  12923. t = (sp_digit)(d >> 28);
  12924. t = (t / dv) << 14;
  12925. r += t;
  12926. d -= (sp_int64)t * div;
  12927. t = (sp_digit)(d >> 13);
  12928. t = t / (dv << 1);
  12929. r += t;
  12930. d -= (sp_int64)t * div;
  12931. t = (sp_digit)d;
  12932. t = t / div;
  12933. r += t;
  12934. d -= (sp_int64)t * div;
  12935. return r;
  12936. #endif
  12937. }
  12938. static WC_INLINE sp_digit sp_4096_word_div_word_142(sp_digit d, sp_digit div)
  12939. {
  12940. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  12941. defined(SP_DIV_WORD_USE_DIV)
  12942. return d / div;
  12943. #else
  12944. return (sp_digit)((sp_uint32)(div - d) >> 31);
  12945. #endif
  12946. }
  12947. /* Divide d in a and put remainder into r (m*d + r = a)
  12948. * m is not calculated as it is not needed at this time.
  12949. *
  12950. * Full implementation.
  12951. *
  12952. * a Number to be divided.
  12953. * d Number to divide with.
  12954. * m Multiplier result.
  12955. * r Remainder from the division.
  12956. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  12957. */
  12958. static int sp_4096_div_142(const sp_digit* a, const sp_digit* d,
  12959. const sp_digit* m, sp_digit* r)
  12960. {
  12961. int i;
  12962. #ifndef WOLFSSL_SP_DIV_32
  12963. #endif
  12964. sp_digit dv;
  12965. sp_digit r1;
  12966. #ifdef WOLFSSL_SP_SMALL_STACK
  12967. sp_digit* t1 = NULL;
  12968. #else
  12969. sp_digit t1[4 * 142 + 3];
  12970. #endif
  12971. sp_digit* t2 = NULL;
  12972. sp_digit* sd = NULL;
  12973. int err = MP_OKAY;
  12974. (void)m;
  12975. #ifdef WOLFSSL_SP_SMALL_STACK
  12976. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 142 + 3), NULL,
  12977. DYNAMIC_TYPE_TMP_BUFFER);
  12978. if (t1 == NULL)
  12979. err = MEMORY_E;
  12980. #endif
  12981. (void)m;
  12982. if (err == MP_OKAY) {
  12983. t2 = t1 + 284 + 1;
  12984. sd = t2 + 142 + 1;
  12985. sp_4096_mul_d_142(sd, d, (sp_digit)1 << 22);
  12986. sp_4096_mul_d_284(t1, a, (sp_digit)1 << 22);
  12987. dv = sd[141];
  12988. t1[142 + 142] += t1[142 + 142 - 1] >> 29;
  12989. t1[142 + 142 - 1] &= 0x1fffffff;
  12990. for (i=142; i>=0; i--) {
  12991. r1 = sp_4096_div_word_142(t1[142 + i], t1[142 + i - 1], dv);
  12992. sp_4096_mul_d_142(t2, sd, r1);
  12993. (void)sp_4096_sub_142(&t1[i], &t1[i], t2);
  12994. sp_4096_norm_142(&t1[i]);
  12995. t1[142 + i] -= t2[142];
  12996. t1[142 + i] += t1[142 + i - 1] >> 29;
  12997. t1[142 + i - 1] &= 0x1fffffff;
  12998. r1 = sp_4096_div_word_142(-t1[142 + i], -t1[142 + i - 1], dv);
  12999. r1 -= t1[142 + i];
  13000. sp_4096_mul_d_142(t2, sd, r1);
  13001. (void)sp_4096_add_142(&t1[i], &t1[i], t2);
  13002. t1[142 + i] += t1[142 + i - 1] >> 29;
  13003. t1[142 + i - 1] &= 0x1fffffff;
  13004. }
  13005. t1[142 - 1] += t1[142 - 2] >> 29;
  13006. t1[142 - 2] &= 0x1fffffff;
  13007. r1 = sp_4096_word_div_word_142(t1[142 - 1], dv);
  13008. sp_4096_mul_d_142(t2, sd, r1);
  13009. sp_4096_sub_142(t1, t1, t2);
  13010. XMEMCPY(r, t1, sizeof(*r) * 284U);
  13011. for (i=0; i<141; i++) {
  13012. r[i+1] += r[i] >> 29;
  13013. r[i] &= 0x1fffffff;
  13014. }
  13015. sp_4096_cond_add_142(r, r, sd, r[141] >> 31);
  13016. sp_4096_norm_142(r);
  13017. sp_4096_rshift_142(r, r, 22);
  13018. }
  13019. #ifdef WOLFSSL_SP_SMALL_STACK
  13020. if (t1 != NULL)
  13021. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  13022. #endif
  13023. return err;
  13024. }
  13025. /* Reduce a modulo m into r. (r = a mod m)
  13026. *
  13027. * r A single precision number that is the reduced result.
  13028. * a A single precision number that is to be reduced.
  13029. * m A single precision number that is the modulus to reduce with.
  13030. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  13031. */
  13032. static int sp_4096_mod_142(sp_digit* r, const sp_digit* a, const sp_digit* m)
  13033. {
  13034. return sp_4096_div_142(a, m, NULL, r);
  13035. }
  13036. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  13037. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  13038. *
  13039. * r A single precision number that is the result of the operation.
  13040. * a A single precision number being exponentiated.
  13041. * e A single precision number that is the exponent.
  13042. * bits The number of bits in the exponent.
  13043. * m A single precision number that is the modulus.
  13044. * returns 0 on success.
  13045. * returns MEMORY_E on dynamic memory allocation failure.
  13046. * returns MP_VAL when base is even or exponent is 0.
  13047. */
  13048. static int sp_4096_mod_exp_142(sp_digit* r, const sp_digit* a, const sp_digit* e,
  13049. int bits, const sp_digit* m, int reduceA)
  13050. {
  13051. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  13052. #ifdef WOLFSSL_SP_SMALL_STACK
  13053. sp_digit* td = NULL;
  13054. #else
  13055. sp_digit td[3 * 284];
  13056. #endif
  13057. sp_digit* t[3] = {0, 0, 0};
  13058. sp_digit* norm = NULL;
  13059. sp_digit mp = 1;
  13060. sp_digit n;
  13061. int i;
  13062. int c;
  13063. byte y;
  13064. int err = MP_OKAY;
  13065. if (bits == 0) {
  13066. err = MP_VAL;
  13067. }
  13068. #ifdef WOLFSSL_SP_SMALL_STACK
  13069. if (err == MP_OKAY) {
  13070. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 142 * 2, NULL,
  13071. DYNAMIC_TYPE_TMP_BUFFER);
  13072. if (td == NULL)
  13073. err = MEMORY_E;
  13074. }
  13075. #endif
  13076. if (err == MP_OKAY) {
  13077. norm = td;
  13078. for (i=0; i<3; i++) {
  13079. t[i] = td + (i * 142 * 2);
  13080. XMEMSET(t[i], 0, sizeof(sp_digit) * 142U * 2U);
  13081. }
  13082. sp_4096_mont_setup(m, &mp);
  13083. sp_4096_mont_norm_142(norm, m);
  13084. if (reduceA != 0) {
  13085. err = sp_4096_mod_142(t[1], a, m);
  13086. }
  13087. else {
  13088. XMEMCPY(t[1], a, sizeof(sp_digit) * 142U);
  13089. }
  13090. }
  13091. if (err == MP_OKAY) {
  13092. sp_4096_mul_142(t[1], t[1], norm);
  13093. err = sp_4096_mod_142(t[1], t[1], m);
  13094. }
  13095. if (err == MP_OKAY) {
  13096. i = bits / 29;
  13097. c = bits % 29;
  13098. n = e[i--] << (29 - c);
  13099. for (; ; c--) {
  13100. if (c == 0) {
  13101. if (i == -1) {
  13102. break;
  13103. }
  13104. n = e[i--];
  13105. c = 29;
  13106. }
  13107. y = (int)((n >> 28) & 1);
  13108. n <<= 1;
  13109. sp_4096_mont_mul_142(t[y^1], t[0], t[1], m, mp);
  13110. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  13111. ((size_t)t[1] & addr_mask[y])),
  13112. sizeof(*t[2]) * 142 * 2);
  13113. sp_4096_mont_sqr_142(t[2], t[2], m, mp);
  13114. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  13115. ((size_t)t[1] & addr_mask[y])), t[2],
  13116. sizeof(*t[2]) * 142 * 2);
  13117. }
  13118. sp_4096_mont_reduce_142(t[0], m, mp);
  13119. n = sp_4096_cmp_142(t[0], m);
  13120. sp_4096_cond_sub_142(t[0], t[0], m, ~(n >> 31));
  13121. XMEMCPY(r, t[0], sizeof(*r) * 142 * 2);
  13122. }
  13123. #ifdef WOLFSSL_SP_SMALL_STACK
  13124. if (td != NULL)
  13125. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  13126. #endif
  13127. return err;
  13128. #elif !defined(WC_NO_CACHE_RESISTANT)
  13129. #ifdef WOLFSSL_SP_SMALL_STACK
  13130. sp_digit* td = NULL;
  13131. #else
  13132. sp_digit td[3 * 284];
  13133. #endif
  13134. sp_digit* t[3] = {0, 0, 0};
  13135. sp_digit* norm = NULL;
  13136. sp_digit mp = 1;
  13137. sp_digit n;
  13138. int i;
  13139. int c;
  13140. byte y;
  13141. int err = MP_OKAY;
  13142. if (bits == 0) {
  13143. err = MP_VAL;
  13144. }
  13145. #ifdef WOLFSSL_SP_SMALL_STACK
  13146. if (err == MP_OKAY) {
  13147. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 142 * 2, NULL,
  13148. DYNAMIC_TYPE_TMP_BUFFER);
  13149. if (td == NULL)
  13150. err = MEMORY_E;
  13151. }
  13152. #endif
  13153. if (err == MP_OKAY) {
  13154. norm = td;
  13155. for (i=0; i<3; i++) {
  13156. t[i] = td + (i * 142 * 2);
  13157. }
  13158. sp_4096_mont_setup(m, &mp);
  13159. sp_4096_mont_norm_142(norm, m);
  13160. if (reduceA != 0) {
  13161. err = sp_4096_mod_142(t[1], a, m);
  13162. if (err == MP_OKAY) {
  13163. sp_4096_mul_142(t[1], t[1], norm);
  13164. err = sp_4096_mod_142(t[1], t[1], m);
  13165. }
  13166. }
  13167. else {
  13168. sp_4096_mul_142(t[1], a, norm);
  13169. err = sp_4096_mod_142(t[1], t[1], m);
  13170. }
  13171. }
  13172. if (err == MP_OKAY) {
  13173. i = bits / 29;
  13174. c = bits % 29;
  13175. n = e[i--] << (29 - c);
  13176. for (; ; c--) {
  13177. if (c == 0) {
  13178. if (i == -1) {
  13179. break;
  13180. }
  13181. n = e[i--];
  13182. c = 29;
  13183. }
  13184. y = (int)((n >> 28) & 1);
  13185. n <<= 1;
  13186. sp_4096_mont_mul_142(t[y^1], t[0], t[1], m, mp);
  13187. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  13188. ((size_t)t[1] & addr_mask[y])),
  13189. sizeof(*t[2]) * 142 * 2);
  13190. sp_4096_mont_sqr_142(t[2], t[2], m, mp);
  13191. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  13192. ((size_t)t[1] & addr_mask[y])), t[2],
  13193. sizeof(*t[2]) * 142 * 2);
  13194. }
  13195. sp_4096_mont_reduce_142(t[0], m, mp);
  13196. n = sp_4096_cmp_142(t[0], m);
  13197. sp_4096_cond_sub_142(t[0], t[0], m, ~(n >> 31));
  13198. XMEMCPY(r, t[0], sizeof(*r) * 142 * 2);
  13199. }
  13200. #ifdef WOLFSSL_SP_SMALL_STACK
  13201. if (td != NULL)
  13202. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  13203. #endif
  13204. return err;
  13205. #else
  13206. #ifdef WOLFSSL_SP_SMALL_STACK
  13207. sp_digit* td = NULL;
  13208. #else
  13209. sp_digit td[(16 * 284) + 284];
  13210. #endif
  13211. sp_digit* t[16];
  13212. sp_digit* rt = NULL;
  13213. sp_digit* norm = NULL;
  13214. sp_digit mp = 1;
  13215. sp_digit n;
  13216. int i;
  13217. int c;
  13218. byte y;
  13219. int err = MP_OKAY;
  13220. if (bits == 0) {
  13221. err = MP_VAL;
  13222. }
  13223. #ifdef WOLFSSL_SP_SMALL_STACK
  13224. if (err == MP_OKAY) {
  13225. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((16 * 284) + 284), NULL,
  13226. DYNAMIC_TYPE_TMP_BUFFER);
  13227. if (td == NULL)
  13228. err = MEMORY_E;
  13229. }
  13230. #endif
  13231. if (err == MP_OKAY) {
  13232. norm = td;
  13233. for (i=0; i<16; i++)
  13234. t[i] = td + i * 284;
  13235. rt = td + 4544;
  13236. sp_4096_mont_setup(m, &mp);
  13237. sp_4096_mont_norm_142(norm, m);
  13238. if (reduceA != 0) {
  13239. err = sp_4096_mod_142(t[1], a, m);
  13240. if (err == MP_OKAY) {
  13241. sp_4096_mul_142(t[1], t[1], norm);
  13242. err = sp_4096_mod_142(t[1], t[1], m);
  13243. }
  13244. }
  13245. else {
  13246. sp_4096_mul_142(t[1], a, norm);
  13247. err = sp_4096_mod_142(t[1], t[1], m);
  13248. }
  13249. }
  13250. if (err == MP_OKAY) {
  13251. sp_4096_mont_sqr_142(t[ 2], t[ 1], m, mp);
  13252. sp_4096_mont_mul_142(t[ 3], t[ 2], t[ 1], m, mp);
  13253. sp_4096_mont_sqr_142(t[ 4], t[ 2], m, mp);
  13254. sp_4096_mont_mul_142(t[ 5], t[ 3], t[ 2], m, mp);
  13255. sp_4096_mont_sqr_142(t[ 6], t[ 3], m, mp);
  13256. sp_4096_mont_mul_142(t[ 7], t[ 4], t[ 3], m, mp);
  13257. sp_4096_mont_sqr_142(t[ 8], t[ 4], m, mp);
  13258. sp_4096_mont_mul_142(t[ 9], t[ 5], t[ 4], m, mp);
  13259. sp_4096_mont_sqr_142(t[10], t[ 5], m, mp);
  13260. sp_4096_mont_mul_142(t[11], t[ 6], t[ 5], m, mp);
  13261. sp_4096_mont_sqr_142(t[12], t[ 6], m, mp);
  13262. sp_4096_mont_mul_142(t[13], t[ 7], t[ 6], m, mp);
  13263. sp_4096_mont_sqr_142(t[14], t[ 7], m, mp);
  13264. sp_4096_mont_mul_142(t[15], t[ 8], t[ 7], m, mp);
  13265. bits = ((bits + 3) / 4) * 4;
  13266. i = ((bits + 28) / 29) - 1;
  13267. c = bits % 29;
  13268. if (c == 0) {
  13269. c = 29;
  13270. }
  13271. if (i < 142) {
  13272. n = e[i--] << (32 - c);
  13273. }
  13274. else {
  13275. n = 0;
  13276. i--;
  13277. }
  13278. if (c < 4) {
  13279. n |= e[i--] << (3 - c);
  13280. c += 29;
  13281. }
  13282. y = (int)((n >> 28) & 0xf);
  13283. n <<= 4;
  13284. c -= 4;
  13285. XMEMCPY(rt, t[y], sizeof(sp_digit) * 284);
  13286. while ((i >= 0) || (c >= 4)) {
  13287. if (c >= 4) {
  13288. y = (byte)((n >> 28) & 0xf);
  13289. n <<= 4;
  13290. c -= 4;
  13291. }
  13292. else if (c == 0) {
  13293. n = e[i--] << 3;
  13294. y = (byte)((n >> 28) & 0xf);
  13295. n <<= 4;
  13296. c = 25;
  13297. }
  13298. else {
  13299. y = (byte)((n >> 28) & 0xf);
  13300. n = e[i--] << 3;
  13301. c = 4 - c;
  13302. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  13303. n <<= c;
  13304. c = 29 - c;
  13305. }
  13306. sp_4096_mont_sqr_142(rt, rt, m, mp);
  13307. sp_4096_mont_sqr_142(rt, rt, m, mp);
  13308. sp_4096_mont_sqr_142(rt, rt, m, mp);
  13309. sp_4096_mont_sqr_142(rt, rt, m, mp);
  13310. sp_4096_mont_mul_142(rt, rt, t[y], m, mp);
  13311. }
  13312. sp_4096_mont_reduce_142(rt, m, mp);
  13313. n = sp_4096_cmp_142(rt, m);
  13314. sp_4096_cond_sub_142(rt, rt, m, ~(n >> 31));
  13315. XMEMCPY(r, rt, sizeof(sp_digit) * 284);
  13316. }
  13317. #ifdef WOLFSSL_SP_SMALL_STACK
  13318. if (td != NULL)
  13319. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  13320. #endif
  13321. return err;
  13322. #endif
  13323. }
  13324. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  13325. #ifdef WOLFSSL_HAVE_SP_RSA
  13326. /* RSA public key operation.
  13327. *
  13328. * in Array of bytes representing the number to exponentiate, base.
  13329. * inLen Number of bytes in base.
  13330. * em Public exponent.
  13331. * mm Modulus.
  13332. * out Buffer to hold big-endian bytes of exponentiation result.
  13333. * Must be at least 512 bytes long.
  13334. * outLen Number of bytes in result.
  13335. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  13336. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  13337. */
  13338. int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
  13339. const mp_int* mm, byte* out, word32* outLen)
  13340. {
  13341. #ifdef WOLFSSL_SP_SMALL
  13342. #ifdef WOLFSSL_SP_SMALL_STACK
  13343. sp_digit* a = NULL;
  13344. #else
  13345. sp_digit a[142 * 5];
  13346. #endif
  13347. sp_digit* m = NULL;
  13348. sp_digit* r = NULL;
  13349. sp_digit* norm = NULL;
  13350. sp_uint64 e[1] = {0};
  13351. sp_digit mp = 0;
  13352. int i;
  13353. int err = MP_OKAY;
  13354. if (*outLen < 512U) {
  13355. err = MP_TO_E;
  13356. }
  13357. if (err == MP_OKAY) {
  13358. if (mp_count_bits(em) > 64) {
  13359. err = MP_READ_E;
  13360. }
  13361. else if (inLen > 512U) {
  13362. err = MP_READ_E;
  13363. }
  13364. else if (mp_count_bits(mm) != 4096) {
  13365. err = MP_READ_E;
  13366. }
  13367. else if (mp_iseven(mm)) {
  13368. err = MP_VAL;
  13369. }
  13370. }
  13371. #ifdef WOLFSSL_SP_SMALL_STACK
  13372. if (err == MP_OKAY) {
  13373. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 5, NULL,
  13374. DYNAMIC_TYPE_RSA);
  13375. if (a == NULL)
  13376. err = MEMORY_E;
  13377. }
  13378. #endif
  13379. if (err == MP_OKAY) {
  13380. r = a + 142 * 2;
  13381. m = r + 142 * 2;
  13382. norm = r;
  13383. sp_4096_from_bin(a, 142, in, inLen);
  13384. #if DIGIT_BIT >= 64
  13385. e[0] = (sp_uint64)em->dp[0];
  13386. #else
  13387. e[0] = (sp_uint64)em->dp[0];
  13388. if (em->used > 1) {
  13389. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  13390. }
  13391. #endif
  13392. if (e[0] == 0) {
  13393. err = MP_EXPTMOD_E;
  13394. }
  13395. }
  13396. if (err == MP_OKAY) {
  13397. sp_4096_from_mp(m, 142, mm);
  13398. sp_4096_mont_setup(m, &mp);
  13399. sp_4096_mont_norm_142(norm, m);
  13400. }
  13401. if (err == MP_OKAY) {
  13402. sp_4096_mul_142(a, a, norm);
  13403. err = sp_4096_mod_142(a, a, m);
  13404. }
  13405. if (err == MP_OKAY) {
  13406. for (i=63; i>=0; i--) {
  13407. if ((e[0] >> i) != 0) {
  13408. break;
  13409. }
  13410. }
  13411. XMEMCPY(r, a, sizeof(sp_digit) * 142 * 2);
  13412. for (i--; i>=0; i--) {
  13413. sp_4096_mont_sqr_142(r, r, m, mp);
  13414. if (((e[0] >> i) & 1) == 1) {
  13415. sp_4096_mont_mul_142(r, r, a, m, mp);
  13416. }
  13417. }
  13418. sp_4096_mont_reduce_142(r, m, mp);
  13419. mp = sp_4096_cmp_142(r, m);
  13420. sp_4096_cond_sub_142(r, r, m, ~(mp >> 31));
  13421. sp_4096_to_bin_142(r, out);
  13422. *outLen = 512;
  13423. }
  13424. #ifdef WOLFSSL_SP_SMALL_STACK
  13425. if (a != NULL)
  13426. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  13427. #endif
  13428. return err;
  13429. #else
  13430. #ifdef WOLFSSL_SP_SMALL_STACK
  13431. sp_digit* d = NULL;
  13432. #else
  13433. sp_digit d[142 * 5];
  13434. #endif
  13435. sp_digit* a = NULL;
  13436. sp_digit* m = NULL;
  13437. sp_digit* r = NULL;
  13438. sp_uint64 e[1] = {0};
  13439. int err = MP_OKAY;
  13440. if (*outLen < 512U) {
  13441. err = MP_TO_E;
  13442. }
  13443. if (err == MP_OKAY) {
  13444. if (mp_count_bits(em) > 64) {
  13445. err = MP_READ_E;
  13446. }
  13447. else if (inLen > 512U) {
  13448. err = MP_READ_E;
  13449. }
  13450. else if (mp_count_bits(mm) != 4096) {
  13451. err = MP_READ_E;
  13452. }
  13453. else if (mp_iseven(mm)) {
  13454. err = MP_VAL;
  13455. }
  13456. }
  13457. #ifdef WOLFSSL_SP_SMALL_STACK
  13458. if (err == MP_OKAY) {
  13459. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 5, NULL,
  13460. DYNAMIC_TYPE_RSA);
  13461. if (d == NULL)
  13462. err = MEMORY_E;
  13463. }
  13464. #endif
  13465. if (err == MP_OKAY) {
  13466. a = d;
  13467. r = a + 142 * 2;
  13468. m = r + 142 * 2;
  13469. sp_4096_from_bin(a, 142, in, inLen);
  13470. #if DIGIT_BIT >= 64
  13471. e[0] = (sp_uint64)em->dp[0];
  13472. #else
  13473. e[0] = (sp_uint64)em->dp[0];
  13474. if (em->used > 1) {
  13475. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  13476. }
  13477. #endif
  13478. if (e[0] == 0) {
  13479. err = MP_EXPTMOD_E;
  13480. }
  13481. }
  13482. if (err == MP_OKAY) {
  13483. sp_4096_from_mp(m, 142, mm);
  13484. if (e[0] == 0x3) {
  13485. sp_4096_sqr_142(r, a);
  13486. err = sp_4096_mod_142(r, r, m);
  13487. if (err == MP_OKAY) {
  13488. sp_4096_mul_142(r, a, r);
  13489. err = sp_4096_mod_142(r, r, m);
  13490. }
  13491. }
  13492. else {
  13493. sp_digit* norm = r;
  13494. int i;
  13495. sp_digit mp;
  13496. sp_4096_mont_setup(m, &mp);
  13497. sp_4096_mont_norm_142(norm, m);
  13498. sp_4096_mul_142(a, a, norm);
  13499. err = sp_4096_mod_142(a, a, m);
  13500. if (err == MP_OKAY) {
  13501. for (i=63; i>=0; i--) {
  13502. if ((e[0] >> i) != 0) {
  13503. break;
  13504. }
  13505. }
  13506. XMEMCPY(r, a, sizeof(sp_digit) * 284U);
  13507. for (i--; i>=0; i--) {
  13508. sp_4096_mont_sqr_142(r, r, m, mp);
  13509. if (((e[0] >> i) & 1) == 1) {
  13510. sp_4096_mont_mul_142(r, r, a, m, mp);
  13511. }
  13512. }
  13513. sp_4096_mont_reduce_142(r, m, mp);
  13514. mp = sp_4096_cmp_142(r, m);
  13515. sp_4096_cond_sub_142(r, r, m, ~(mp >> 31));
  13516. }
  13517. }
  13518. }
  13519. if (err == MP_OKAY) {
  13520. sp_4096_to_bin_142(r, out);
  13521. *outLen = 512;
  13522. }
  13523. #ifdef WOLFSSL_SP_SMALL_STACK
  13524. if (d != NULL)
  13525. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  13526. #endif
  13527. return err;
  13528. #endif /* WOLFSSL_SP_SMALL */
  13529. }
  13530. #ifndef WOLFSSL_RSA_PUBLIC_ONLY
  13531. #if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
  13532. #endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
  13533. /* RSA private key operation.
  13534. *
  13535. * in Array of bytes representing the number to exponentiate, base.
  13536. * inLen Number of bytes in base.
  13537. * dm Private exponent.
  13538. * pm First prime.
  13539. * qm Second prime.
  13540. * dpm First prime's CRT exponent.
  13541. * dqm Second prime's CRT exponent.
  13542. * qim Inverse of second prime mod p.
  13543. * mm Modulus.
  13544. * out Buffer to hold big-endian bytes of exponentiation result.
  13545. * Must be at least 512 bytes long.
  13546. * outLen Number of bytes in result.
  13547. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  13548. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  13549. */
  13550. int sp_RsaPrivate_4096(const byte* in, word32 inLen, const mp_int* dm,
  13551. const mp_int* pm, const mp_int* qm, const mp_int* dpm, const mp_int* dqm,
  13552. const mp_int* qim, const mp_int* mm, byte* out, word32* outLen)
  13553. {
  13554. #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
  13555. #if defined(WOLFSSL_SP_SMALL)
  13556. #ifdef WOLFSSL_SP_SMALL_STACK
  13557. sp_digit* d = NULL;
  13558. #else
  13559. sp_digit d[142 * 4];
  13560. #endif
  13561. sp_digit* a = NULL;
  13562. sp_digit* m = NULL;
  13563. sp_digit* r = NULL;
  13564. int err = MP_OKAY;
  13565. (void)pm;
  13566. (void)qm;
  13567. (void)dpm;
  13568. (void)dqm;
  13569. (void)qim;
  13570. if (*outLen < 512U) {
  13571. err = MP_TO_E;
  13572. }
  13573. if (err == MP_OKAY) {
  13574. if (mp_count_bits(dm) > 4096) {
  13575. err = MP_READ_E;
  13576. }
  13577. else if (inLen > 512) {
  13578. err = MP_READ_E;
  13579. }
  13580. else if (mp_count_bits(mm) != 4096) {
  13581. err = MP_READ_E;
  13582. }
  13583. else if (mp_iseven(mm)) {
  13584. err = MP_VAL;
  13585. }
  13586. }
  13587. #ifdef WOLFSSL_SP_SMALL_STACK
  13588. if (err == MP_OKAY) {
  13589. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 4, NULL,
  13590. DYNAMIC_TYPE_RSA);
  13591. if (d == NULL)
  13592. err = MEMORY_E;
  13593. }
  13594. #endif
  13595. if (err == MP_OKAY) {
  13596. a = d + 142;
  13597. m = a + 284;
  13598. r = a;
  13599. sp_4096_from_bin(a, 142, in, inLen);
  13600. sp_4096_from_mp(d, 142, dm);
  13601. sp_4096_from_mp(m, 142, mm);
  13602. err = sp_4096_mod_exp_142(r, a, d, 4096, m, 0);
  13603. }
  13604. if (err == MP_OKAY) {
  13605. sp_4096_to_bin_142(r, out);
  13606. *outLen = 512;
  13607. }
  13608. #ifdef WOLFSSL_SP_SMALL_STACK
  13609. if (d != NULL)
  13610. #endif
  13611. {
  13612. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  13613. if (a != NULL)
  13614. ForceZero(a, sizeof(sp_digit) * 142);
  13615. #ifdef WOLFSSL_SP_SMALL_STACK
  13616. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  13617. #endif
  13618. }
  13619. return err;
  13620. #else
  13621. #ifdef WOLFSSL_SP_SMALL_STACK
  13622. sp_digit* d = NULL;
  13623. #else
  13624. sp_digit d[142 * 4];
  13625. #endif
  13626. sp_digit* a = NULL;
  13627. sp_digit* m = NULL;
  13628. sp_digit* r = NULL;
  13629. int err = MP_OKAY;
  13630. (void)pm;
  13631. (void)qm;
  13632. (void)dpm;
  13633. (void)dqm;
  13634. (void)qim;
  13635. if (*outLen < 512U) {
  13636. err = MP_TO_E;
  13637. }
  13638. if (err == MP_OKAY) {
  13639. if (mp_count_bits(dm) > 4096) {
  13640. err = MP_READ_E;
  13641. }
  13642. else if (inLen > 512U) {
  13643. err = MP_READ_E;
  13644. }
  13645. else if (mp_count_bits(mm) != 4096) {
  13646. err = MP_READ_E;
  13647. }
  13648. else if (mp_iseven(mm)) {
  13649. err = MP_VAL;
  13650. }
  13651. }
  13652. #ifdef WOLFSSL_SP_SMALL_STACK
  13653. if (err == MP_OKAY) {
  13654. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 4, NULL,
  13655. DYNAMIC_TYPE_RSA);
  13656. if (d == NULL)
  13657. err = MEMORY_E;
  13658. }
  13659. #endif
  13660. if (err == MP_OKAY) {
  13661. a = d + 142;
  13662. m = a + 284;
  13663. r = a;
  13664. sp_4096_from_bin(a, 142, in, inLen);
  13665. sp_4096_from_mp(d, 142, dm);
  13666. sp_4096_from_mp(m, 142, mm);
  13667. err = sp_4096_mod_exp_142(r, a, d, 4096, m, 0);
  13668. }
  13669. if (err == MP_OKAY) {
  13670. sp_4096_to_bin_142(r, out);
  13671. *outLen = 512;
  13672. }
  13673. #ifdef WOLFSSL_SP_SMALL_STACK
  13674. if (d != NULL)
  13675. #endif
  13676. {
  13677. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  13678. if (a != NULL)
  13679. ForceZero(a, sizeof(sp_digit) * 142);
  13680. #ifdef WOLFSSL_SP_SMALL_STACK
  13681. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  13682. #endif
  13683. }
  13684. return err;
  13685. #endif /* WOLFSSL_SP_SMALL */
  13686. #else
  13687. #if defined(WOLFSSL_SP_SMALL)
  13688. #ifdef WOLFSSL_SP_SMALL_STACK
  13689. sp_digit* a = NULL;
  13690. #else
  13691. sp_digit a[71 * 8];
  13692. #endif
  13693. sp_digit* p = NULL;
  13694. sp_digit* dp = NULL;
  13695. sp_digit* dq = NULL;
  13696. sp_digit* qi = NULL;
  13697. sp_digit* tmpa = NULL;
  13698. sp_digit* tmpb = NULL;
  13699. sp_digit* r = NULL;
  13700. int err = MP_OKAY;
  13701. (void)dm;
  13702. (void)mm;
  13703. if (*outLen < 512U) {
  13704. err = MP_TO_E;
  13705. }
  13706. if (err == MP_OKAY) {
  13707. if (inLen > 512) {
  13708. err = MP_READ_E;
  13709. }
  13710. else if (mp_count_bits(mm) != 4096) {
  13711. err = MP_READ_E;
  13712. }
  13713. else if (mp_iseven(mm)) {
  13714. err = MP_VAL;
  13715. }
  13716. else if (mp_iseven(pm)) {
  13717. err = MP_VAL;
  13718. }
  13719. else if (mp_iseven(qm)) {
  13720. err = MP_VAL;
  13721. }
  13722. }
  13723. #ifdef WOLFSSL_SP_SMALL_STACK
  13724. if (err == MP_OKAY) {
  13725. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 71 * 8, NULL,
  13726. DYNAMIC_TYPE_RSA);
  13727. if (a == NULL)
  13728. err = MEMORY_E;
  13729. }
  13730. #endif
  13731. if (err == MP_OKAY) {
  13732. p = a + 142;
  13733. qi = dq = dp = p + 71;
  13734. tmpa = qi + 71;
  13735. tmpb = tmpa + 142;
  13736. r = a;
  13737. sp_4096_from_bin(a, 142, in, inLen);
  13738. sp_4096_from_mp(p, 71, pm);
  13739. sp_4096_from_mp(dp, 71, dpm);
  13740. err = sp_4096_mod_exp_71(tmpa, a, dp, 2048, p, 1);
  13741. }
  13742. if (err == MP_OKAY) {
  13743. sp_4096_from_mp(p, 71, qm);
  13744. sp_4096_from_mp(dq, 71, dqm);
  13745. err = sp_4096_mod_exp_71(tmpb, a, dq, 2048, p, 1);
  13746. }
  13747. if (err == MP_OKAY) {
  13748. sp_4096_from_mp(p, 71, pm);
  13749. (void)sp_4096_sub_71(tmpa, tmpa, tmpb);
  13750. sp_4096_norm_71(tmpa);
  13751. sp_4096_cond_add_71(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[70] >> 31));
  13752. sp_4096_cond_add_71(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[70] >> 31));
  13753. sp_4096_norm_71(tmpa);
  13754. sp_4096_from_mp(qi, 71, qim);
  13755. sp_4096_mul_71(tmpa, tmpa, qi);
  13756. err = sp_4096_mod_71(tmpa, tmpa, p);
  13757. }
  13758. if (err == MP_OKAY) {
  13759. sp_4096_from_mp(p, 71, qm);
  13760. sp_4096_mul_71(tmpa, p, tmpa);
  13761. (void)sp_4096_add_142(r, tmpb, tmpa);
  13762. sp_4096_norm_142(r);
  13763. sp_4096_to_bin_142(r, out);
  13764. *outLen = 512;
  13765. }
  13766. #ifdef WOLFSSL_SP_SMALL_STACK
  13767. if (a != NULL)
  13768. #endif
  13769. {
  13770. ForceZero(a, sizeof(sp_digit) * 71 * 8);
  13771. #ifdef WOLFSSL_SP_SMALL_STACK
  13772. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  13773. #endif
  13774. }
  13775. return err;
  13776. #else
  13777. #ifdef WOLFSSL_SP_SMALL_STACK
  13778. sp_digit* a = NULL;
  13779. #else
  13780. sp_digit a[71 * 13];
  13781. #endif
  13782. sp_digit* p = NULL;
  13783. sp_digit* q = NULL;
  13784. sp_digit* dp = NULL;
  13785. sp_digit* dq = NULL;
  13786. sp_digit* qi = NULL;
  13787. sp_digit* tmpa = NULL;
  13788. sp_digit* tmpb = NULL;
  13789. sp_digit* r = NULL;
  13790. int err = MP_OKAY;
  13791. (void)dm;
  13792. (void)mm;
  13793. if (*outLen < 512U) {
  13794. err = MP_TO_E;
  13795. }
  13796. if (err == MP_OKAY) {
  13797. if (inLen > 512U) {
  13798. err = MP_READ_E;
  13799. }
  13800. else if (mp_count_bits(mm) != 4096) {
  13801. err = MP_READ_E;
  13802. }
  13803. else if (mp_iseven(mm)) {
  13804. err = MP_VAL;
  13805. }
  13806. else if (mp_iseven(pm)) {
  13807. err = MP_VAL;
  13808. }
  13809. else if (mp_iseven(qm)) {
  13810. err = MP_VAL;
  13811. }
  13812. }
  13813. #ifdef WOLFSSL_SP_SMALL_STACK
  13814. if (err == MP_OKAY) {
  13815. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 71 * 13, NULL,
  13816. DYNAMIC_TYPE_RSA);
  13817. if (a == NULL)
  13818. err = MEMORY_E;
  13819. }
  13820. #endif
  13821. if (err == MP_OKAY) {
  13822. p = a + 142 * 2;
  13823. q = p + 71;
  13824. dp = q + 71;
  13825. dq = dp + 71;
  13826. qi = dq + 71;
  13827. tmpa = qi + 71;
  13828. tmpb = tmpa + 142;
  13829. r = a;
  13830. sp_4096_from_bin(a, 142, in, inLen);
  13831. sp_4096_from_mp(p, 71, pm);
  13832. sp_4096_from_mp(q, 71, qm);
  13833. sp_4096_from_mp(dp, 71, dpm);
  13834. sp_4096_from_mp(dq, 71, dqm);
  13835. sp_4096_from_mp(qi, 71, qim);
  13836. err = sp_4096_mod_exp_71(tmpa, a, dp, 2048, p, 1);
  13837. }
  13838. if (err == MP_OKAY) {
  13839. err = sp_4096_mod_exp_71(tmpb, a, dq, 2048, q, 1);
  13840. }
  13841. if (err == MP_OKAY) {
  13842. (void)sp_4096_sub_71(tmpa, tmpa, tmpb);
  13843. sp_4096_norm_71(tmpa);
  13844. sp_4096_cond_add_71(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[70] >> 31));
  13845. sp_4096_cond_add_71(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[70] >> 31));
  13846. sp_4096_norm_71(tmpa);
  13847. sp_4096_mul_71(tmpa, tmpa, qi);
  13848. err = sp_4096_mod_71(tmpa, tmpa, p);
  13849. }
  13850. if (err == MP_OKAY) {
  13851. sp_4096_mul_71(tmpa, tmpa, q);
  13852. (void)sp_4096_add_142(r, tmpb, tmpa);
  13853. sp_4096_norm_142(r);
  13854. sp_4096_to_bin_142(r, out);
  13855. *outLen = 512;
  13856. }
  13857. #ifdef WOLFSSL_SP_SMALL_STACK
  13858. if (a != NULL)
  13859. #endif
  13860. {
  13861. ForceZero(a, sizeof(sp_digit) * 71 * 13);
  13862. #ifdef WOLFSSL_SP_SMALL_STACK
  13863. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  13864. #endif
  13865. }
  13866. return err;
  13867. #endif /* WOLFSSL_SP_SMALL */
  13868. #endif /* SP_RSA_PRIVATE_EXP_D || RSA_LOW_MEM */
  13869. }
  13870. #endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
  13871. #endif /* WOLFSSL_HAVE_SP_RSA */
  13872. #if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
  13873. !defined(WOLFSSL_RSA_PUBLIC_ONLY))
  13874. /* Convert an array of sp_digit to an mp_int.
  13875. *
  13876. * a A single precision integer.
  13877. * r A multi-precision integer.
  13878. */
  13879. static int sp_4096_to_mp(const sp_digit* a, mp_int* r)
  13880. {
  13881. int err;
  13882. err = mp_grow(r, (4096 + DIGIT_BIT - 1) / DIGIT_BIT);
  13883. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  13884. #if DIGIT_BIT == 29
  13885. XMEMCPY(r->dp, a, sizeof(sp_digit) * 142);
  13886. r->used = 142;
  13887. mp_clamp(r);
  13888. #elif DIGIT_BIT < 29
  13889. int i;
  13890. int j = 0;
  13891. int s = 0;
  13892. r->dp[0] = 0;
  13893. for (i = 0; i < 142; i++) {
  13894. r->dp[j] |= (mp_digit)(a[i] << s);
  13895. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  13896. s = DIGIT_BIT - s;
  13897. r->dp[++j] = (mp_digit)(a[i] >> s);
  13898. while (s + DIGIT_BIT <= 29) {
  13899. s += DIGIT_BIT;
  13900. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  13901. if (s == SP_WORD_SIZE) {
  13902. r->dp[j] = 0;
  13903. }
  13904. else {
  13905. r->dp[j] = (mp_digit)(a[i] >> s);
  13906. }
  13907. }
  13908. s = 29 - s;
  13909. }
  13910. r->used = (4096 + DIGIT_BIT - 1) / DIGIT_BIT;
  13911. mp_clamp(r);
  13912. #else
  13913. int i;
  13914. int j = 0;
  13915. int s = 0;
  13916. r->dp[0] = 0;
  13917. for (i = 0; i < 142; i++) {
  13918. r->dp[j] |= ((mp_digit)a[i]) << s;
  13919. if (s + 29 >= DIGIT_BIT) {
  13920. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  13921. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  13922. #endif
  13923. s = DIGIT_BIT - s;
  13924. r->dp[++j] = a[i] >> s;
  13925. s = 29 - s;
  13926. }
  13927. else {
  13928. s += 29;
  13929. }
  13930. }
  13931. r->used = (4096 + DIGIT_BIT - 1) / DIGIT_BIT;
  13932. mp_clamp(r);
  13933. #endif
  13934. }
  13935. return err;
  13936. }
  13937. /* Perform the modular exponentiation for Diffie-Hellman.
  13938. *
  13939. * base Base. MP integer.
  13940. * exp Exponent. MP integer.
  13941. * mod Modulus. MP integer.
  13942. * res Result. MP integer.
  13943. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  13944. * and MEMORY_E if memory allocation fails.
  13945. */
  13946. int sp_ModExp_4096(const mp_int* base, const mp_int* exp, const mp_int* mod,
  13947. mp_int* res)
  13948. {
  13949. #ifdef WOLFSSL_SP_SMALL
  13950. int err = MP_OKAY;
  13951. #ifdef WOLFSSL_SP_SMALL_STACK
  13952. sp_digit* b = NULL;
  13953. #else
  13954. sp_digit b[142 * 4];
  13955. #endif
  13956. sp_digit* e = NULL;
  13957. sp_digit* m = NULL;
  13958. sp_digit* r = NULL;
  13959. int expBits = mp_count_bits(exp);
  13960. if (mp_count_bits(base) > 4096) {
  13961. err = MP_READ_E;
  13962. }
  13963. else if (expBits > 4096) {
  13964. err = MP_READ_E;
  13965. }
  13966. else if (mp_count_bits(mod) != 4096) {
  13967. err = MP_READ_E;
  13968. }
  13969. else if (mp_iseven(mod)) {
  13970. err = MP_VAL;
  13971. }
  13972. #ifdef WOLFSSL_SP_SMALL_STACK
  13973. if (err == MP_OKAY) {
  13974. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 4, NULL,
  13975. DYNAMIC_TYPE_DH);
  13976. if (b == NULL)
  13977. err = MEMORY_E;
  13978. }
  13979. #endif
  13980. if (err == MP_OKAY) {
  13981. e = b + 142 * 2;
  13982. m = e + 142;
  13983. r = b;
  13984. sp_4096_from_mp(b, 142, base);
  13985. sp_4096_from_mp(e, 142, exp);
  13986. sp_4096_from_mp(m, 142, mod);
  13987. err = sp_4096_mod_exp_142(r, b, e, mp_count_bits(exp), m, 0);
  13988. }
  13989. if (err == MP_OKAY) {
  13990. err = sp_4096_to_mp(r, res);
  13991. }
  13992. #ifdef WOLFSSL_SP_SMALL_STACK
  13993. if (b != NULL)
  13994. #endif
  13995. {
  13996. /* only "e" is sensitive and needs zeroized */
  13997. if (e != NULL)
  13998. ForceZero(e, sizeof(sp_digit) * 142U);
  13999. #ifdef WOLFSSL_SP_SMALL_STACK
  14000. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  14001. #endif
  14002. }
  14003. return err;
  14004. #else
  14005. #ifdef WOLFSSL_SP_SMALL_STACK
  14006. sp_digit* b = NULL;
  14007. #else
  14008. sp_digit b[142 * 4];
  14009. #endif
  14010. sp_digit* e = NULL;
  14011. sp_digit* m = NULL;
  14012. sp_digit* r = NULL;
  14013. int err = MP_OKAY;
  14014. int expBits = mp_count_bits(exp);
  14015. if (mp_count_bits(base) > 4096) {
  14016. err = MP_READ_E;
  14017. }
  14018. else if (expBits > 4096) {
  14019. err = MP_READ_E;
  14020. }
  14021. else if (mp_count_bits(mod) != 4096) {
  14022. err = MP_READ_E;
  14023. }
  14024. else if (mp_iseven(mod)) {
  14025. err = MP_VAL;
  14026. }
  14027. #ifdef WOLFSSL_SP_SMALL_STACK
  14028. if (err == MP_OKAY) {
  14029. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 4, NULL, DYNAMIC_TYPE_DH);
  14030. if (b == NULL)
  14031. err = MEMORY_E;
  14032. }
  14033. #endif
  14034. if (err == MP_OKAY) {
  14035. e = b + 142 * 2;
  14036. m = e + 142;
  14037. r = b;
  14038. sp_4096_from_mp(b, 142, base);
  14039. sp_4096_from_mp(e, 142, exp);
  14040. sp_4096_from_mp(m, 142, mod);
  14041. err = sp_4096_mod_exp_142(r, b, e, expBits, m, 0);
  14042. }
  14043. if (err == MP_OKAY) {
  14044. err = sp_4096_to_mp(r, res);
  14045. }
  14046. #ifdef WOLFSSL_SP_SMALL_STACK
  14047. if (b != NULL)
  14048. #endif
  14049. {
  14050. /* only "e" is sensitive and needs zeroized */
  14051. if (e != NULL)
  14052. ForceZero(e, sizeof(sp_digit) * 142U);
  14053. #ifdef WOLFSSL_SP_SMALL_STACK
  14054. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  14055. #endif
  14056. }
  14057. return err;
  14058. #endif
  14059. }
  14060. #ifdef WOLFSSL_HAVE_SP_DH
  14061. #ifdef HAVE_FFDHE_4096
  14062. SP_NOINLINE static void sp_4096_lshift_142(sp_digit* r, const sp_digit* a,
  14063. byte n)
  14064. {
  14065. int i;
  14066. r[142] = a[141] >> (29 - n);
  14067. for (i=141; i>0; i--) {
  14068. r[i] = ((a[i] << n) | (a[i-1] >> (29 - n))) & 0x1fffffff;
  14069. }
  14070. r[0] = (a[0] << n) & 0x1fffffff;
  14071. }
  14072. /* Modular exponentiate 2 to the e mod m. (r = 2^e mod m)
  14073. *
  14074. * r A single precision number that is the result of the operation.
  14075. * e A single precision number that is the exponent.
  14076. * bits The number of bits in the exponent.
  14077. * m A single precision number that is the modulus.
  14078. * returns 0 on success.
  14079. * returns MEMORY_E on dynamic memory allocation failure.
  14080. * returns MP_VAL when base is even.
  14081. */
  14082. static int sp_4096_mod_exp_2_142(sp_digit* r, const sp_digit* e, int bits, const sp_digit* m)
  14083. {
  14084. #ifdef WOLFSSL_SP_SMALL_STACK
  14085. sp_digit* td = NULL;
  14086. #else
  14087. sp_digit td[427];
  14088. #endif
  14089. sp_digit* norm = NULL;
  14090. sp_digit* tmp = NULL;
  14091. sp_digit mp = 1;
  14092. sp_digit n;
  14093. sp_digit o;
  14094. int i;
  14095. int c;
  14096. byte y;
  14097. int err = MP_OKAY;
  14098. if (bits == 0) {
  14099. err = MP_VAL;
  14100. }
  14101. #ifdef WOLFSSL_SP_SMALL_STACK
  14102. if (err == MP_OKAY) {
  14103. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 427, NULL,
  14104. DYNAMIC_TYPE_TMP_BUFFER);
  14105. if (td == NULL)
  14106. err = MEMORY_E;
  14107. }
  14108. #endif
  14109. if (err == MP_OKAY) {
  14110. norm = td;
  14111. tmp = td + 284;
  14112. XMEMSET(td, 0, sizeof(sp_digit) * 427);
  14113. sp_4096_mont_setup(m, &mp);
  14114. sp_4096_mont_norm_142(norm, m);
  14115. bits = ((bits + 3) / 4) * 4;
  14116. i = ((bits + 28) / 29) - 1;
  14117. c = bits % 29;
  14118. if (c == 0) {
  14119. c = 29;
  14120. }
  14121. if (i < 142) {
  14122. n = e[i--] << (32 - c);
  14123. }
  14124. else {
  14125. n = 0;
  14126. i--;
  14127. }
  14128. if (c < 4) {
  14129. n |= e[i--] << (3 - c);
  14130. c += 29;
  14131. }
  14132. y = (int)((n >> 28) & 0xf);
  14133. n <<= 4;
  14134. c -= 4;
  14135. sp_4096_lshift_142(r, norm, (byte)y);
  14136. while ((i >= 0) || (c >= 4)) {
  14137. if (c >= 4) {
  14138. y = (byte)((n >> 28) & 0xf);
  14139. n <<= 4;
  14140. c -= 4;
  14141. }
  14142. else if (c == 0) {
  14143. n = e[i--] << 3;
  14144. y = (byte)((n >> 28) & 0xf);
  14145. n <<= 4;
  14146. c = 25;
  14147. }
  14148. else {
  14149. y = (byte)((n >> 28) & 0xf);
  14150. n = e[i--] << 3;
  14151. c = 4 - c;
  14152. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  14153. n <<= c;
  14154. c = 29 - c;
  14155. }
  14156. sp_4096_mont_sqr_142(r, r, m, mp);
  14157. sp_4096_mont_sqr_142(r, r, m, mp);
  14158. sp_4096_mont_sqr_142(r, r, m, mp);
  14159. sp_4096_mont_sqr_142(r, r, m, mp);
  14160. sp_4096_lshift_142(r, r, (byte)y);
  14161. sp_4096_mul_d_142(tmp, norm, (r[142] << 22) + (r[141] >> 7));
  14162. r[142] = 0;
  14163. r[141] &= 0x7fL;
  14164. (void)sp_4096_add_142(r, r, tmp);
  14165. sp_4096_norm_142(r);
  14166. o = sp_4096_cmp_142(r, m);
  14167. sp_4096_cond_sub_142(r, r, m, ~(o >> 31));
  14168. }
  14169. sp_4096_mont_reduce_142(r, m, mp);
  14170. n = sp_4096_cmp_142(r, m);
  14171. sp_4096_cond_sub_142(r, r, m, ~(n >> 31));
  14172. }
  14173. #ifdef WOLFSSL_SP_SMALL_STACK
  14174. if (td != NULL)
  14175. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  14176. #endif
  14177. return err;
  14178. }
  14179. #endif /* HAVE_FFDHE_4096 */
  14180. /* Perform the modular exponentiation for Diffie-Hellman.
  14181. *
  14182. * base Base.
  14183. * exp Array of bytes that is the exponent.
  14184. * expLen Length of data, in bytes, in exponent.
  14185. * mod Modulus.
  14186. * out Buffer to hold big-endian bytes of exponentiation result.
  14187. * Must be at least 512 bytes long.
  14188. * outLen Length, in bytes, of exponentiation result.
  14189. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  14190. * and MEMORY_E if memory allocation fails.
  14191. */
  14192. int sp_DhExp_4096(const mp_int* base, const byte* exp, word32 expLen,
  14193. const mp_int* mod, byte* out, word32* outLen)
  14194. {
  14195. #ifdef WOLFSSL_SP_SMALL_STACK
  14196. sp_digit* b = NULL;
  14197. #else
  14198. sp_digit b[142 * 4];
  14199. #endif
  14200. sp_digit* e = NULL;
  14201. sp_digit* m = NULL;
  14202. sp_digit* r = NULL;
  14203. word32 i;
  14204. int err = MP_OKAY;
  14205. if (mp_count_bits(base) > 4096) {
  14206. err = MP_READ_E;
  14207. }
  14208. else if (expLen > 512U) {
  14209. err = MP_READ_E;
  14210. }
  14211. else if (mp_count_bits(mod) != 4096) {
  14212. err = MP_READ_E;
  14213. }
  14214. else if (mp_iseven(mod)) {
  14215. err = MP_VAL;
  14216. }
  14217. #ifdef WOLFSSL_SP_SMALL_STACK
  14218. if (err == MP_OKAY) {
  14219. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 142 * 4, NULL,
  14220. DYNAMIC_TYPE_DH);
  14221. if (b == NULL)
  14222. err = MEMORY_E;
  14223. }
  14224. #endif
  14225. if (err == MP_OKAY) {
  14226. e = b + 142 * 2;
  14227. m = e + 142;
  14228. r = b;
  14229. sp_4096_from_mp(b, 142, base);
  14230. sp_4096_from_bin(e, 142, exp, expLen);
  14231. sp_4096_from_mp(m, 142, mod);
  14232. #ifdef HAVE_FFDHE_4096
  14233. if (base->used == 1 && base->dp[0] == 2U &&
  14234. ((m[141] << 9) | (m[140] >> 20)) == 0xffffL) {
  14235. err = sp_4096_mod_exp_2_142(r, e, expLen * 8U, m);
  14236. }
  14237. else {
  14238. #endif
  14239. err = sp_4096_mod_exp_142(r, b, e, expLen * 8U, m, 0);
  14240. #ifdef HAVE_FFDHE_4096
  14241. }
  14242. #endif
  14243. }
  14244. if (err == MP_OKAY) {
  14245. sp_4096_to_bin_142(r, out);
  14246. *outLen = 512;
  14247. for (i=0; i<512U && out[i] == 0U; i++) {
  14248. /* Search for first non-zero. */
  14249. }
  14250. *outLen -= i;
  14251. XMEMMOVE(out, out + i, *outLen);
  14252. }
  14253. #ifdef WOLFSSL_SP_SMALL_STACK
  14254. if (b != NULL)
  14255. #endif
  14256. {
  14257. /* only "e" is sensitive and needs zeroized */
  14258. if (e != NULL)
  14259. ForceZero(e, sizeof(sp_digit) * 142U);
  14260. #ifdef WOLFSSL_SP_SMALL_STACK
  14261. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  14262. #endif
  14263. }
  14264. return err;
  14265. }
  14266. #endif /* WOLFSSL_HAVE_SP_DH */
  14267. #endif /* WOLFSSL_HAVE_SP_DH | (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) */
  14268. #else
  14269. /* Read big endian unsigned byte array into r.
  14270. *
  14271. * r A single precision integer.
  14272. * size Maximum number of bytes to convert
  14273. * a Byte array.
  14274. * n Number of bytes in array to read.
  14275. */
  14276. static void sp_4096_from_bin(sp_digit* r, int size, const byte* a, int n)
  14277. {
  14278. int i;
  14279. int j = 0;
  14280. word32 s = 0;
  14281. r[0] = 0;
  14282. for (i = n-1; i >= 0; i--) {
  14283. r[j] |= (((sp_digit)a[i]) << s);
  14284. if (s >= 18U) {
  14285. r[j] &= 0x3ffffff;
  14286. s = 26U - s;
  14287. if (j + 1 >= size) {
  14288. break;
  14289. }
  14290. r[++j] = (sp_digit)a[i] >> s;
  14291. s = 8U - s;
  14292. }
  14293. else {
  14294. s += 8U;
  14295. }
  14296. }
  14297. for (j++; j < size; j++) {
  14298. r[j] = 0;
  14299. }
  14300. }
  14301. /* Convert an mp_int to an array of sp_digit.
  14302. *
  14303. * r A single precision integer.
  14304. * size Maximum number of bytes to convert
  14305. * a A multi-precision integer.
  14306. */
  14307. static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
  14308. {
  14309. #if DIGIT_BIT == 26
  14310. int i;
  14311. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  14312. int o = 0;
  14313. for (i = 0; i < size; i++) {
  14314. sp_digit mask = (sp_digit)0 - (j >> 25);
  14315. r[i] = a->dp[o] & mask;
  14316. j++;
  14317. o += (int)(j >> 25);
  14318. }
  14319. #elif DIGIT_BIT > 26
  14320. unsigned int i;
  14321. int j = 0;
  14322. word32 s = 0;
  14323. r[0] = 0;
  14324. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  14325. r[j] |= ((sp_digit)a->dp[i] << s);
  14326. r[j] &= 0x3ffffff;
  14327. s = 26U - s;
  14328. if (j + 1 >= size) {
  14329. break;
  14330. }
  14331. /* lint allow cast of mismatch word32 and mp_digit */
  14332. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  14333. while ((s + 26U) <= (word32)DIGIT_BIT) {
  14334. s += 26U;
  14335. r[j] &= 0x3ffffff;
  14336. if (j + 1 >= size) {
  14337. break;
  14338. }
  14339. if (s < (word32)DIGIT_BIT) {
  14340. /* lint allow cast of mismatch word32 and mp_digit */
  14341. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  14342. }
  14343. else {
  14344. r[++j] = (sp_digit)0;
  14345. }
  14346. }
  14347. s = (word32)DIGIT_BIT - s;
  14348. }
  14349. for (j++; j < size; j++) {
  14350. r[j] = 0;
  14351. }
  14352. #else
  14353. unsigned int i;
  14354. int j = 0;
  14355. int s = 0;
  14356. r[0] = 0;
  14357. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  14358. r[j] |= ((sp_digit)a->dp[i]) << s;
  14359. if (s + DIGIT_BIT >= 26) {
  14360. r[j] &= 0x3ffffff;
  14361. if (j + 1 >= size) {
  14362. break;
  14363. }
  14364. s = 26 - s;
  14365. if (s == DIGIT_BIT) {
  14366. r[++j] = 0;
  14367. s = 0;
  14368. }
  14369. else {
  14370. r[++j] = a->dp[i] >> s;
  14371. s = DIGIT_BIT - s;
  14372. }
  14373. }
  14374. else {
  14375. s += DIGIT_BIT;
  14376. }
  14377. }
  14378. for (j++; j < size; j++) {
  14379. r[j] = 0;
  14380. }
  14381. #endif
  14382. }
  14383. /* Write r as big endian to byte array.
  14384. * Fixed length number of bytes written: 512
  14385. *
  14386. * r A single precision integer.
  14387. * a Byte array.
  14388. */
  14389. static void sp_4096_to_bin_162(sp_digit* r, byte* a)
  14390. {
  14391. int i;
  14392. int j;
  14393. int s = 0;
  14394. int b;
  14395. for (i=0; i<161; i++) {
  14396. r[i+1] += r[i] >> 26;
  14397. r[i] &= 0x3ffffff;
  14398. }
  14399. j = 4103 / 8 - 1;
  14400. a[j] = 0;
  14401. for (i=0; i<158 && j>=0; i++) {
  14402. b = 0;
  14403. /* lint allow cast of mismatch sp_digit and int */
  14404. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  14405. b += 8 - s;
  14406. if (j < 0) {
  14407. break;
  14408. }
  14409. while (b < 26) {
  14410. a[j--] = (byte)(r[i] >> b);
  14411. b += 8;
  14412. if (j < 0) {
  14413. break;
  14414. }
  14415. }
  14416. s = 8 - (b - 26);
  14417. if (j >= 0) {
  14418. a[j] = 0;
  14419. }
  14420. if (s != 0) {
  14421. j++;
  14422. }
  14423. }
  14424. }
  14425. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  14426. #if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D)
  14427. /* Normalize the values in each word to 26 bits.
  14428. *
  14429. * a Array of sp_digit to normalize.
  14430. */
  14431. static void sp_4096_norm_81(sp_digit* a)
  14432. {
  14433. int i;
  14434. for (i = 0; i < 80; i += 8) {
  14435. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14436. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14437. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14438. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14439. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14440. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14441. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14442. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14443. }
  14444. }
  14445. #endif /* WOLFSSL_HAVE_SP_RSA & !SP_RSA_PRIVATE_EXP_D */
  14446. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  14447. /* Normalize the values in each word to 26 bits.
  14448. *
  14449. * a Array of sp_digit to normalize.
  14450. */
  14451. static void sp_4096_norm_79(sp_digit* a)
  14452. {
  14453. int i;
  14454. for (i = 0; i < 72; i += 8) {
  14455. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14456. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14457. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14458. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14459. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14460. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14461. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14462. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14463. }
  14464. a[73] += a[72] >> 26; a[72] &= 0x3ffffff;
  14465. a[74] += a[73] >> 26; a[73] &= 0x3ffffff;
  14466. a[75] += a[74] >> 26; a[74] &= 0x3ffffff;
  14467. a[76] += a[75] >> 26; a[75] &= 0x3ffffff;
  14468. a[77] += a[76] >> 26; a[76] &= 0x3ffffff;
  14469. a[78] += a[77] >> 26; a[77] &= 0x3ffffff;
  14470. }
  14471. /* Normalize the values in each word to 26 bits.
  14472. *
  14473. * a Array of sp_digit to normalize.
  14474. */
  14475. static void sp_4096_norm_162(sp_digit* a)
  14476. {
  14477. int i;
  14478. for (i = 0; i < 160; i += 8) {
  14479. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14480. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14481. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14482. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14483. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14484. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14485. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14486. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14487. }
  14488. a[161] += a[160] >> 26; a[160] &= 0x3ffffff;
  14489. }
  14490. /* Normalize the values in each word to 26 bits.
  14491. *
  14492. * a Array of sp_digit to normalize.
  14493. */
  14494. static void sp_4096_norm_158(sp_digit* a)
  14495. {
  14496. int i;
  14497. for (i = 0; i < 152; i += 8) {
  14498. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14499. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14500. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14501. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14502. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14503. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14504. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14505. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14506. }
  14507. a[153] += a[152] >> 26; a[152] &= 0x3ffffff;
  14508. a[154] += a[153] >> 26; a[153] &= 0x3ffffff;
  14509. a[155] += a[154] >> 26; a[154] &= 0x3ffffff;
  14510. a[156] += a[155] >> 26; a[155] &= 0x3ffffff;
  14511. a[157] += a[156] >> 26; a[156] &= 0x3ffffff;
  14512. }
  14513. #ifndef WOLFSSL_SP_SMALL
  14514. /* Multiply a and b into r. (r = a * b)
  14515. *
  14516. * r A single precision integer.
  14517. * a A single precision integer.
  14518. * b A single precision integer.
  14519. */
  14520. SP_NOINLINE static void sp_4096_mul_9(sp_digit* r, const sp_digit* a,
  14521. const sp_digit* b)
  14522. {
  14523. sp_uint64 t0;
  14524. sp_uint64 t1;
  14525. sp_digit t[9];
  14526. t0 = ((sp_uint64)a[ 0]) * b[ 0];
  14527. t1 = ((sp_uint64)a[ 0]) * b[ 1]
  14528. + ((sp_uint64)a[ 1]) * b[ 0];
  14529. t[ 0] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14530. t0 = ((sp_uint64)a[ 0]) * b[ 2]
  14531. + ((sp_uint64)a[ 1]) * b[ 1]
  14532. + ((sp_uint64)a[ 2]) * b[ 0];
  14533. t[ 1] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14534. t1 = ((sp_uint64)a[ 0]) * b[ 3]
  14535. + ((sp_uint64)a[ 1]) * b[ 2]
  14536. + ((sp_uint64)a[ 2]) * b[ 1]
  14537. + ((sp_uint64)a[ 3]) * b[ 0];
  14538. t[ 2] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14539. t0 = ((sp_uint64)a[ 0]) * b[ 4]
  14540. + ((sp_uint64)a[ 1]) * b[ 3]
  14541. + ((sp_uint64)a[ 2]) * b[ 2]
  14542. + ((sp_uint64)a[ 3]) * b[ 1]
  14543. + ((sp_uint64)a[ 4]) * b[ 0];
  14544. t[ 3] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14545. t1 = ((sp_uint64)a[ 0]) * b[ 5]
  14546. + ((sp_uint64)a[ 1]) * b[ 4]
  14547. + ((sp_uint64)a[ 2]) * b[ 3]
  14548. + ((sp_uint64)a[ 3]) * b[ 2]
  14549. + ((sp_uint64)a[ 4]) * b[ 1]
  14550. + ((sp_uint64)a[ 5]) * b[ 0];
  14551. t[ 4] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14552. t0 = ((sp_uint64)a[ 0]) * b[ 6]
  14553. + ((sp_uint64)a[ 1]) * b[ 5]
  14554. + ((sp_uint64)a[ 2]) * b[ 4]
  14555. + ((sp_uint64)a[ 3]) * b[ 3]
  14556. + ((sp_uint64)a[ 4]) * b[ 2]
  14557. + ((sp_uint64)a[ 5]) * b[ 1]
  14558. + ((sp_uint64)a[ 6]) * b[ 0];
  14559. t[ 5] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14560. t1 = ((sp_uint64)a[ 0]) * b[ 7]
  14561. + ((sp_uint64)a[ 1]) * b[ 6]
  14562. + ((sp_uint64)a[ 2]) * b[ 5]
  14563. + ((sp_uint64)a[ 3]) * b[ 4]
  14564. + ((sp_uint64)a[ 4]) * b[ 3]
  14565. + ((sp_uint64)a[ 5]) * b[ 2]
  14566. + ((sp_uint64)a[ 6]) * b[ 1]
  14567. + ((sp_uint64)a[ 7]) * b[ 0];
  14568. t[ 6] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14569. t0 = ((sp_uint64)a[ 0]) * b[ 8]
  14570. + ((sp_uint64)a[ 1]) * b[ 7]
  14571. + ((sp_uint64)a[ 2]) * b[ 6]
  14572. + ((sp_uint64)a[ 3]) * b[ 5]
  14573. + ((sp_uint64)a[ 4]) * b[ 4]
  14574. + ((sp_uint64)a[ 5]) * b[ 3]
  14575. + ((sp_uint64)a[ 6]) * b[ 2]
  14576. + ((sp_uint64)a[ 7]) * b[ 1]
  14577. + ((sp_uint64)a[ 8]) * b[ 0];
  14578. t[ 7] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14579. t1 = ((sp_uint64)a[ 1]) * b[ 8]
  14580. + ((sp_uint64)a[ 2]) * b[ 7]
  14581. + ((sp_uint64)a[ 3]) * b[ 6]
  14582. + ((sp_uint64)a[ 4]) * b[ 5]
  14583. + ((sp_uint64)a[ 5]) * b[ 4]
  14584. + ((sp_uint64)a[ 6]) * b[ 3]
  14585. + ((sp_uint64)a[ 7]) * b[ 2]
  14586. + ((sp_uint64)a[ 8]) * b[ 1];
  14587. t[ 8] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14588. t0 = ((sp_uint64)a[ 2]) * b[ 8]
  14589. + ((sp_uint64)a[ 3]) * b[ 7]
  14590. + ((sp_uint64)a[ 4]) * b[ 6]
  14591. + ((sp_uint64)a[ 5]) * b[ 5]
  14592. + ((sp_uint64)a[ 6]) * b[ 4]
  14593. + ((sp_uint64)a[ 7]) * b[ 3]
  14594. + ((sp_uint64)a[ 8]) * b[ 2];
  14595. r[ 9] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14596. t1 = ((sp_uint64)a[ 3]) * b[ 8]
  14597. + ((sp_uint64)a[ 4]) * b[ 7]
  14598. + ((sp_uint64)a[ 5]) * b[ 6]
  14599. + ((sp_uint64)a[ 6]) * b[ 5]
  14600. + ((sp_uint64)a[ 7]) * b[ 4]
  14601. + ((sp_uint64)a[ 8]) * b[ 3];
  14602. r[10] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14603. t0 = ((sp_uint64)a[ 4]) * b[ 8]
  14604. + ((sp_uint64)a[ 5]) * b[ 7]
  14605. + ((sp_uint64)a[ 6]) * b[ 6]
  14606. + ((sp_uint64)a[ 7]) * b[ 5]
  14607. + ((sp_uint64)a[ 8]) * b[ 4];
  14608. r[11] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14609. t1 = ((sp_uint64)a[ 5]) * b[ 8]
  14610. + ((sp_uint64)a[ 6]) * b[ 7]
  14611. + ((sp_uint64)a[ 7]) * b[ 6]
  14612. + ((sp_uint64)a[ 8]) * b[ 5];
  14613. r[12] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14614. t0 = ((sp_uint64)a[ 6]) * b[ 8]
  14615. + ((sp_uint64)a[ 7]) * b[ 7]
  14616. + ((sp_uint64)a[ 8]) * b[ 6];
  14617. r[13] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14618. t1 = ((sp_uint64)a[ 7]) * b[ 8]
  14619. + ((sp_uint64)a[ 8]) * b[ 7];
  14620. r[14] = t0 & 0x3ffffff; t1 += t0 >> 26;
  14621. t0 = ((sp_uint64)a[ 8]) * b[ 8];
  14622. r[15] = t1 & 0x3ffffff; t0 += t1 >> 26;
  14623. r[16] = t0 & 0x3ffffff;
  14624. r[17] = (sp_digit)(t0 >> 26);
  14625. XMEMCPY(r, t, sizeof(t));
  14626. }
  14627. /* Add b to a into r. (r = a + b)
  14628. *
  14629. * r A single precision integer.
  14630. * a A single precision integer.
  14631. * b A single precision integer.
  14632. */
  14633. SP_NOINLINE static int sp_4096_add_9(sp_digit* r, const sp_digit* a,
  14634. const sp_digit* b)
  14635. {
  14636. r[ 0] = a[ 0] + b[ 0];
  14637. r[ 1] = a[ 1] + b[ 1];
  14638. r[ 2] = a[ 2] + b[ 2];
  14639. r[ 3] = a[ 3] + b[ 3];
  14640. r[ 4] = a[ 4] + b[ 4];
  14641. r[ 5] = a[ 5] + b[ 5];
  14642. r[ 6] = a[ 6] + b[ 6];
  14643. r[ 7] = a[ 7] + b[ 7];
  14644. r[ 8] = a[ 8] + b[ 8];
  14645. return 0;
  14646. }
  14647. /* Sub b from a into r. (r = a - b)
  14648. *
  14649. * r A single precision integer.
  14650. * a A single precision integer.
  14651. * b A single precision integer.
  14652. */
  14653. SP_NOINLINE static int sp_4096_sub_18(sp_digit* r, const sp_digit* a,
  14654. const sp_digit* b)
  14655. {
  14656. int i;
  14657. for (i = 0; i < 16; i += 8) {
  14658. r[i + 0] = a[i + 0] - b[i + 0];
  14659. r[i + 1] = a[i + 1] - b[i + 1];
  14660. r[i + 2] = a[i + 2] - b[i + 2];
  14661. r[i + 3] = a[i + 3] - b[i + 3];
  14662. r[i + 4] = a[i + 4] - b[i + 4];
  14663. r[i + 5] = a[i + 5] - b[i + 5];
  14664. r[i + 6] = a[i + 6] - b[i + 6];
  14665. r[i + 7] = a[i + 7] - b[i + 7];
  14666. }
  14667. r[16] = a[16] - b[16];
  14668. r[17] = a[17] - b[17];
  14669. return 0;
  14670. }
  14671. /* Add b to a into r. (r = a + b)
  14672. *
  14673. * r A single precision integer.
  14674. * a A single precision integer.
  14675. * b A single precision integer.
  14676. */
  14677. SP_NOINLINE static int sp_4096_add_18(sp_digit* r, const sp_digit* a,
  14678. const sp_digit* b)
  14679. {
  14680. int i;
  14681. for (i = 0; i < 16; i += 8) {
  14682. r[i + 0] = a[i + 0] + b[i + 0];
  14683. r[i + 1] = a[i + 1] + b[i + 1];
  14684. r[i + 2] = a[i + 2] + b[i + 2];
  14685. r[i + 3] = a[i + 3] + b[i + 3];
  14686. r[i + 4] = a[i + 4] + b[i + 4];
  14687. r[i + 5] = a[i + 5] + b[i + 5];
  14688. r[i + 6] = a[i + 6] + b[i + 6];
  14689. r[i + 7] = a[i + 7] + b[i + 7];
  14690. }
  14691. r[16] = a[16] + b[16];
  14692. r[17] = a[17] + b[17];
  14693. return 0;
  14694. }
  14695. /* Normalize the values in each word to 26 bits.
  14696. *
  14697. * a Array of sp_digit to normalize.
  14698. */
  14699. static void sp_4096_norm_9(sp_digit* a)
  14700. {
  14701. a[1] += a[0] >> 26; a[0] &= 0x3ffffff;
  14702. a[2] += a[1] >> 26; a[1] &= 0x3ffffff;
  14703. a[3] += a[2] >> 26; a[2] &= 0x3ffffff;
  14704. a[4] += a[3] >> 26; a[3] &= 0x3ffffff;
  14705. a[5] += a[4] >> 26; a[4] &= 0x3ffffff;
  14706. a[6] += a[5] >> 26; a[5] &= 0x3ffffff;
  14707. a[7] += a[6] >> 26; a[6] &= 0x3ffffff;
  14708. a[8] += a[7] >> 26; a[7] &= 0x3ffffff;
  14709. }
  14710. /* Normalize the values in each word to 26 bits.
  14711. *
  14712. * a Array of sp_digit to normalize.
  14713. */
  14714. static void sp_4096_norm_18(sp_digit* a)
  14715. {
  14716. int i;
  14717. for (i = 0; i < 16; i += 8) {
  14718. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14719. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14720. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14721. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14722. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14723. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14724. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14725. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14726. }
  14727. a[17] += a[16] >> 26; a[16] &= 0x3ffffff;
  14728. }
  14729. /* Normalize the values in each word to 26 bits.
  14730. *
  14731. * a Array of sp_digit to normalize.
  14732. */
  14733. static void sp_4096_norm_54(sp_digit* a)
  14734. {
  14735. int i;
  14736. for (i = 0; i < 48; i += 8) {
  14737. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14738. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14739. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14740. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14741. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14742. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14743. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14744. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14745. }
  14746. a[49] += a[48] >> 26; a[48] &= 0x3ffffff;
  14747. a[50] += a[49] >> 26; a[49] &= 0x3ffffff;
  14748. a[51] += a[50] >> 26; a[50] &= 0x3ffffff;
  14749. a[52] += a[51] >> 26; a[51] &= 0x3ffffff;
  14750. a[53] += a[52] >> 26; a[52] &= 0x3ffffff;
  14751. }
  14752. /* Multiply a and b into r. (r = a * b)
  14753. *
  14754. * r A single precision integer.
  14755. * a A single precision integer.
  14756. * b A single precision integer.
  14757. */
  14758. SP_NOINLINE static void sp_4096_mul_27(sp_digit* r, const sp_digit* a,
  14759. const sp_digit* b)
  14760. {
  14761. sp_digit p0[18];
  14762. sp_digit p1[18];
  14763. sp_digit p2[18];
  14764. sp_digit p3[18];
  14765. sp_digit p4[18];
  14766. sp_digit p5[18];
  14767. sp_digit t0[18];
  14768. sp_digit t1[18];
  14769. sp_digit t2[18];
  14770. sp_digit a0[9];
  14771. sp_digit a1[9];
  14772. sp_digit a2[9];
  14773. sp_digit b0[9];
  14774. sp_digit b1[9];
  14775. sp_digit b2[9];
  14776. (void)sp_4096_add_9(a0, a, &a[9]);
  14777. sp_4096_norm_9(a0);
  14778. (void)sp_4096_add_9(b0, b, &b[9]);
  14779. sp_4096_norm_9(b0);
  14780. (void)sp_4096_add_9(a1, &a[9], &a[18]);
  14781. sp_4096_norm_9(a1);
  14782. (void)sp_4096_add_9(b1, &b[9], &b[18]);
  14783. sp_4096_norm_9(b1);
  14784. (void)sp_4096_add_9(a2, a0, &a[18]);
  14785. sp_4096_norm_9(a1);
  14786. (void)sp_4096_add_9(b2, b0, &b[18]);
  14787. sp_4096_norm_9(b2);
  14788. sp_4096_mul_9(p0, a, b);
  14789. sp_4096_mul_9(p2, &a[9], &b[9]);
  14790. sp_4096_mul_9(p4, &a[18], &b[18]);
  14791. sp_4096_mul_9(p1, a0, b0);
  14792. sp_4096_mul_9(p3, a1, b1);
  14793. sp_4096_mul_9(p5, a2, b2);
  14794. XMEMSET(r, 0, sizeof(*r)*2U*27U);
  14795. (void)sp_4096_sub_18(t0, p3, p2);
  14796. (void)sp_4096_sub_18(t1, p1, p2);
  14797. (void)sp_4096_sub_18(t2, p5, t0);
  14798. (void)sp_4096_sub_18(t2, t2, t1);
  14799. sp_4096_norm_18(t2);
  14800. (void)sp_4096_sub_18(t0, t0, p4);
  14801. sp_4096_norm_18(t0);
  14802. (void)sp_4096_sub_18(t1, t1, p0);
  14803. sp_4096_norm_18(t1);
  14804. (void)sp_4096_add_18(r, r, p0);
  14805. (void)sp_4096_add_18(&r[9], &r[9], t1);
  14806. (void)sp_4096_add_18(&r[18], &r[18], t2);
  14807. (void)sp_4096_add_18(&r[27], &r[27], t0);
  14808. (void)sp_4096_add_18(&r[36], &r[36], p4);
  14809. sp_4096_norm_54(r);
  14810. }
  14811. /* Add b to a into r. (r = a + b)
  14812. *
  14813. * r A single precision integer.
  14814. * a A single precision integer.
  14815. * b A single precision integer.
  14816. */
  14817. SP_NOINLINE static int sp_4096_add_27(sp_digit* r, const sp_digit* a,
  14818. const sp_digit* b)
  14819. {
  14820. int i;
  14821. for (i = 0; i < 24; i += 8) {
  14822. r[i + 0] = a[i + 0] + b[i + 0];
  14823. r[i + 1] = a[i + 1] + b[i + 1];
  14824. r[i + 2] = a[i + 2] + b[i + 2];
  14825. r[i + 3] = a[i + 3] + b[i + 3];
  14826. r[i + 4] = a[i + 4] + b[i + 4];
  14827. r[i + 5] = a[i + 5] + b[i + 5];
  14828. r[i + 6] = a[i + 6] + b[i + 6];
  14829. r[i + 7] = a[i + 7] + b[i + 7];
  14830. }
  14831. r[24] = a[24] + b[24];
  14832. r[25] = a[25] + b[25];
  14833. r[26] = a[26] + b[26];
  14834. return 0;
  14835. }
  14836. /* Sub b from a into r. (r = a - b)
  14837. *
  14838. * r A single precision integer.
  14839. * a A single precision integer.
  14840. * b A single precision integer.
  14841. */
  14842. SP_NOINLINE static int sp_4096_sub_54(sp_digit* r, const sp_digit* a,
  14843. const sp_digit* b)
  14844. {
  14845. int i;
  14846. for (i = 0; i < 48; i += 8) {
  14847. r[i + 0] = a[i + 0] - b[i + 0];
  14848. r[i + 1] = a[i + 1] - b[i + 1];
  14849. r[i + 2] = a[i + 2] - b[i + 2];
  14850. r[i + 3] = a[i + 3] - b[i + 3];
  14851. r[i + 4] = a[i + 4] - b[i + 4];
  14852. r[i + 5] = a[i + 5] - b[i + 5];
  14853. r[i + 6] = a[i + 6] - b[i + 6];
  14854. r[i + 7] = a[i + 7] - b[i + 7];
  14855. }
  14856. r[48] = a[48] - b[48];
  14857. r[49] = a[49] - b[49];
  14858. r[50] = a[50] - b[50];
  14859. r[51] = a[51] - b[51];
  14860. r[52] = a[52] - b[52];
  14861. r[53] = a[53] - b[53];
  14862. return 0;
  14863. }
  14864. /* Add b to a into r. (r = a + b)
  14865. *
  14866. * r A single precision integer.
  14867. * a A single precision integer.
  14868. * b A single precision integer.
  14869. */
  14870. SP_NOINLINE static int sp_4096_add_54(sp_digit* r, const sp_digit* a,
  14871. const sp_digit* b)
  14872. {
  14873. int i;
  14874. for (i = 0; i < 48; i += 8) {
  14875. r[i + 0] = a[i + 0] + b[i + 0];
  14876. r[i + 1] = a[i + 1] + b[i + 1];
  14877. r[i + 2] = a[i + 2] + b[i + 2];
  14878. r[i + 3] = a[i + 3] + b[i + 3];
  14879. r[i + 4] = a[i + 4] + b[i + 4];
  14880. r[i + 5] = a[i + 5] + b[i + 5];
  14881. r[i + 6] = a[i + 6] + b[i + 6];
  14882. r[i + 7] = a[i + 7] + b[i + 7];
  14883. }
  14884. r[48] = a[48] + b[48];
  14885. r[49] = a[49] + b[49];
  14886. r[50] = a[50] + b[50];
  14887. r[51] = a[51] + b[51];
  14888. r[52] = a[52] + b[52];
  14889. r[53] = a[53] + b[53];
  14890. return 0;
  14891. }
  14892. /* Normalize the values in each word to 26 bits.
  14893. *
  14894. * a Array of sp_digit to normalize.
  14895. */
  14896. static void sp_4096_norm_27(sp_digit* a)
  14897. {
  14898. int i;
  14899. for (i = 0; i < 24; i += 8) {
  14900. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  14901. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  14902. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  14903. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  14904. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  14905. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  14906. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  14907. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  14908. }
  14909. a[25] += a[24] >> 26; a[24] &= 0x3ffffff;
  14910. a[26] += a[25] >> 26; a[25] &= 0x3ffffff;
  14911. }
  14912. /* Multiply a and b into r. (r = a * b)
  14913. *
  14914. * r A single precision integer.
  14915. * a A single precision integer.
  14916. * b A single precision integer.
  14917. */
  14918. SP_NOINLINE static void sp_4096_mul_81(sp_digit* r, const sp_digit* a,
  14919. const sp_digit* b)
  14920. {
  14921. sp_digit p0[54];
  14922. sp_digit p1[54];
  14923. sp_digit p2[54];
  14924. sp_digit p3[54];
  14925. sp_digit p4[54];
  14926. sp_digit p5[54];
  14927. sp_digit t0[54];
  14928. sp_digit t1[54];
  14929. sp_digit t2[54];
  14930. sp_digit a0[27];
  14931. sp_digit a1[27];
  14932. sp_digit a2[27];
  14933. sp_digit b0[27];
  14934. sp_digit b1[27];
  14935. sp_digit b2[27];
  14936. (void)sp_4096_add_27(a0, a, &a[27]);
  14937. sp_4096_norm_27(a0);
  14938. (void)sp_4096_add_27(b0, b, &b[27]);
  14939. sp_4096_norm_27(b0);
  14940. (void)sp_4096_add_27(a1, &a[27], &a[54]);
  14941. sp_4096_norm_27(a1);
  14942. (void)sp_4096_add_27(b1, &b[27], &b[54]);
  14943. sp_4096_norm_27(b1);
  14944. (void)sp_4096_add_27(a2, a0, &a[54]);
  14945. sp_4096_norm_27(a1);
  14946. (void)sp_4096_add_27(b2, b0, &b[54]);
  14947. sp_4096_norm_27(b2);
  14948. sp_4096_mul_27(p0, a, b);
  14949. sp_4096_mul_27(p2, &a[27], &b[27]);
  14950. sp_4096_mul_27(p4, &a[54], &b[54]);
  14951. sp_4096_mul_27(p1, a0, b0);
  14952. sp_4096_mul_27(p3, a1, b1);
  14953. sp_4096_mul_27(p5, a2, b2);
  14954. XMEMSET(r, 0, sizeof(*r)*2U*81U);
  14955. (void)sp_4096_sub_54(t0, p3, p2);
  14956. (void)sp_4096_sub_54(t1, p1, p2);
  14957. (void)sp_4096_sub_54(t2, p5, t0);
  14958. (void)sp_4096_sub_54(t2, t2, t1);
  14959. sp_4096_norm_54(t2);
  14960. (void)sp_4096_sub_54(t0, t0, p4);
  14961. sp_4096_norm_54(t0);
  14962. (void)sp_4096_sub_54(t1, t1, p0);
  14963. sp_4096_norm_54(t1);
  14964. (void)sp_4096_add_54(r, r, p0);
  14965. (void)sp_4096_add_54(&r[27], &r[27], t1);
  14966. (void)sp_4096_add_54(&r[54], &r[54], t2);
  14967. (void)sp_4096_add_54(&r[81], &r[81], t0);
  14968. (void)sp_4096_add_54(&r[108], &r[108], p4);
  14969. sp_4096_norm_162(r);
  14970. }
  14971. /* Add b to a into r. (r = a + b)
  14972. *
  14973. * r A single precision integer.
  14974. * a A single precision integer.
  14975. * b A single precision integer.
  14976. */
  14977. SP_NOINLINE static int sp_4096_add_81(sp_digit* r, const sp_digit* a,
  14978. const sp_digit* b)
  14979. {
  14980. int i;
  14981. for (i = 0; i < 80; i += 8) {
  14982. r[i + 0] = a[i + 0] + b[i + 0];
  14983. r[i + 1] = a[i + 1] + b[i + 1];
  14984. r[i + 2] = a[i + 2] + b[i + 2];
  14985. r[i + 3] = a[i + 3] + b[i + 3];
  14986. r[i + 4] = a[i + 4] + b[i + 4];
  14987. r[i + 5] = a[i + 5] + b[i + 5];
  14988. r[i + 6] = a[i + 6] + b[i + 6];
  14989. r[i + 7] = a[i + 7] + b[i + 7];
  14990. }
  14991. r[80] = a[80] + b[80];
  14992. return 0;
  14993. }
  14994. /* Add b to a into r. (r = a + b)
  14995. *
  14996. * r A single precision integer.
  14997. * a A single precision integer.
  14998. * b A single precision integer.
  14999. */
  15000. SP_NOINLINE static int sp_4096_add_162(sp_digit* r, const sp_digit* a,
  15001. const sp_digit* b)
  15002. {
  15003. int i;
  15004. for (i = 0; i < 160; i += 8) {
  15005. r[i + 0] = a[i + 0] + b[i + 0];
  15006. r[i + 1] = a[i + 1] + b[i + 1];
  15007. r[i + 2] = a[i + 2] + b[i + 2];
  15008. r[i + 3] = a[i + 3] + b[i + 3];
  15009. r[i + 4] = a[i + 4] + b[i + 4];
  15010. r[i + 5] = a[i + 5] + b[i + 5];
  15011. r[i + 6] = a[i + 6] + b[i + 6];
  15012. r[i + 7] = a[i + 7] + b[i + 7];
  15013. }
  15014. r[160] = a[160] + b[160];
  15015. r[161] = a[161] + b[161];
  15016. return 0;
  15017. }
  15018. /* Sub b from a into r. (r = a - b)
  15019. *
  15020. * r A single precision integer.
  15021. * a A single precision integer.
  15022. * b A single precision integer.
  15023. */
  15024. SP_NOINLINE static int sp_4096_sub_162(sp_digit* r, const sp_digit* a,
  15025. const sp_digit* b)
  15026. {
  15027. int i;
  15028. for (i = 0; i < 160; i += 8) {
  15029. r[i + 0] = a[i + 0] - b[i + 0];
  15030. r[i + 1] = a[i + 1] - b[i + 1];
  15031. r[i + 2] = a[i + 2] - b[i + 2];
  15032. r[i + 3] = a[i + 3] - b[i + 3];
  15033. r[i + 4] = a[i + 4] - b[i + 4];
  15034. r[i + 5] = a[i + 5] - b[i + 5];
  15035. r[i + 6] = a[i + 6] - b[i + 6];
  15036. r[i + 7] = a[i + 7] - b[i + 7];
  15037. }
  15038. r[160] = a[160] - b[160];
  15039. r[161] = a[161] - b[161];
  15040. return 0;
  15041. }
  15042. /* Normalize the values in each word to 26 bits.
  15043. *
  15044. * a Array of sp_digit to normalize.
  15045. */
  15046. static void sp_4096_norm_324(sp_digit* a)
  15047. {
  15048. int i;
  15049. for (i = 0; i < 320; i += 8) {
  15050. a[i+1] += a[i+0] >> 26; a[i+0] &= 0x3ffffff;
  15051. a[i+2] += a[i+1] >> 26; a[i+1] &= 0x3ffffff;
  15052. a[i+3] += a[i+2] >> 26; a[i+2] &= 0x3ffffff;
  15053. a[i+4] += a[i+3] >> 26; a[i+3] &= 0x3ffffff;
  15054. a[i+5] += a[i+4] >> 26; a[i+4] &= 0x3ffffff;
  15055. a[i+6] += a[i+5] >> 26; a[i+5] &= 0x3ffffff;
  15056. a[i+7] += a[i+6] >> 26; a[i+6] &= 0x3ffffff;
  15057. a[i+8] += a[i+7] >> 26; a[i+7] &= 0x3ffffff;
  15058. }
  15059. a[321] += a[320] >> 26; a[320] &= 0x3ffffff;
  15060. a[322] += a[321] >> 26; a[321] &= 0x3ffffff;
  15061. a[323] += a[322] >> 26; a[322] &= 0x3ffffff;
  15062. }
  15063. /* Multiply a and b into r. (r = a * b)
  15064. *
  15065. * r A single precision integer.
  15066. * a A single precision integer.
  15067. * b A single precision integer.
  15068. */
  15069. SP_NOINLINE static void sp_4096_mul_162(sp_digit* r, const sp_digit* a,
  15070. const sp_digit* b)
  15071. {
  15072. sp_digit* z0 = r;
  15073. sp_digit z1[162];
  15074. sp_digit* a1 = z1;
  15075. sp_digit b1[81];
  15076. sp_digit* z2 = r + 162;
  15077. (void)sp_4096_add_81(a1, a, &a[81]);
  15078. sp_4096_norm_81(a1);
  15079. (void)sp_4096_add_81(b1, b, &b[81]);
  15080. sp_4096_norm_81(b1);
  15081. sp_4096_mul_81(z2, &a[81], &b[81]);
  15082. sp_4096_mul_81(z0, a, b);
  15083. sp_4096_mul_81(z1, a1, b1);
  15084. (void)sp_4096_sub_162(z1, z1, z2);
  15085. (void)sp_4096_sub_162(z1, z1, z0);
  15086. (void)sp_4096_add_162(r + 81, r + 81, z1);
  15087. sp_4096_norm_324(r);
  15088. }
  15089. /* Square a and put result in r. (r = a * a)
  15090. *
  15091. * r A single precision integer.
  15092. * a A single precision integer.
  15093. */
  15094. SP_NOINLINE static void sp_4096_sqr_9(sp_digit* r, const sp_digit* a)
  15095. {
  15096. sp_uint64 t0;
  15097. sp_uint64 t1;
  15098. sp_digit t[9];
  15099. t0 = ((sp_uint64)a[ 0]) * a[ 0];
  15100. t1 = (((sp_uint64)a[ 0]) * a[ 1]) * 2;
  15101. t[ 0] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15102. t0 = (((sp_uint64)a[ 0]) * a[ 2]) * 2
  15103. + ((sp_uint64)a[ 1]) * a[ 1];
  15104. t[ 1] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15105. t1 = (((sp_uint64)a[ 0]) * a[ 3]
  15106. + ((sp_uint64)a[ 1]) * a[ 2]) * 2;
  15107. t[ 2] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15108. t0 = (((sp_uint64)a[ 0]) * a[ 4]
  15109. + ((sp_uint64)a[ 1]) * a[ 3]) * 2
  15110. + ((sp_uint64)a[ 2]) * a[ 2];
  15111. t[ 3] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15112. t1 = (((sp_uint64)a[ 0]) * a[ 5]
  15113. + ((sp_uint64)a[ 1]) * a[ 4]
  15114. + ((sp_uint64)a[ 2]) * a[ 3]) * 2;
  15115. t[ 4] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15116. t0 = (((sp_uint64)a[ 0]) * a[ 6]
  15117. + ((sp_uint64)a[ 1]) * a[ 5]
  15118. + ((sp_uint64)a[ 2]) * a[ 4]) * 2
  15119. + ((sp_uint64)a[ 3]) * a[ 3];
  15120. t[ 5] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15121. t1 = (((sp_uint64)a[ 0]) * a[ 7]
  15122. + ((sp_uint64)a[ 1]) * a[ 6]
  15123. + ((sp_uint64)a[ 2]) * a[ 5]
  15124. + ((sp_uint64)a[ 3]) * a[ 4]) * 2;
  15125. t[ 6] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15126. t0 = (((sp_uint64)a[ 0]) * a[ 8]
  15127. + ((sp_uint64)a[ 1]) * a[ 7]
  15128. + ((sp_uint64)a[ 2]) * a[ 6]
  15129. + ((sp_uint64)a[ 3]) * a[ 5]) * 2
  15130. + ((sp_uint64)a[ 4]) * a[ 4];
  15131. t[ 7] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15132. t1 = (((sp_uint64)a[ 1]) * a[ 8]
  15133. + ((sp_uint64)a[ 2]) * a[ 7]
  15134. + ((sp_uint64)a[ 3]) * a[ 6]
  15135. + ((sp_uint64)a[ 4]) * a[ 5]) * 2;
  15136. t[ 8] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15137. t0 = (((sp_uint64)a[ 2]) * a[ 8]
  15138. + ((sp_uint64)a[ 3]) * a[ 7]
  15139. + ((sp_uint64)a[ 4]) * a[ 6]) * 2
  15140. + ((sp_uint64)a[ 5]) * a[ 5];
  15141. r[ 9] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15142. t1 = (((sp_uint64)a[ 3]) * a[ 8]
  15143. + ((sp_uint64)a[ 4]) * a[ 7]
  15144. + ((sp_uint64)a[ 5]) * a[ 6]) * 2;
  15145. r[10] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15146. t0 = (((sp_uint64)a[ 4]) * a[ 8]
  15147. + ((sp_uint64)a[ 5]) * a[ 7]) * 2
  15148. + ((sp_uint64)a[ 6]) * a[ 6];
  15149. r[11] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15150. t1 = (((sp_uint64)a[ 5]) * a[ 8]
  15151. + ((sp_uint64)a[ 6]) * a[ 7]) * 2;
  15152. r[12] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15153. t0 = (((sp_uint64)a[ 6]) * a[ 8]) * 2
  15154. + ((sp_uint64)a[ 7]) * a[ 7];
  15155. r[13] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15156. t1 = (((sp_uint64)a[ 7]) * a[ 8]) * 2;
  15157. r[14] = t0 & 0x3ffffff; t1 += t0 >> 26;
  15158. t0 = ((sp_uint64)a[ 8]) * a[ 8];
  15159. r[15] = t1 & 0x3ffffff; t0 += t1 >> 26;
  15160. r[16] = t0 & 0x3ffffff;
  15161. r[17] = (sp_digit)(t0 >> 26);
  15162. XMEMCPY(r, t, sizeof(t));
  15163. }
  15164. /* Square a into r. (r = a * a)
  15165. *
  15166. * r A single precision integer.
  15167. * a A single precision integer.
  15168. */
  15169. SP_NOINLINE static void sp_4096_sqr_27(sp_digit* r, const sp_digit* a)
  15170. {
  15171. sp_digit p0[18];
  15172. sp_digit p1[18];
  15173. sp_digit p2[18];
  15174. sp_digit p3[18];
  15175. sp_digit p4[18];
  15176. sp_digit p5[18];
  15177. sp_digit t0[18];
  15178. sp_digit t1[18];
  15179. sp_digit t2[18];
  15180. sp_digit a0[9];
  15181. sp_digit a1[9];
  15182. sp_digit a2[9];
  15183. (void)sp_4096_add_9(a0, a, &a[9]);
  15184. sp_4096_norm_9(a0);
  15185. (void)sp_4096_add_9(a1, &a[9], &a[18]);
  15186. sp_4096_norm_9(a1);
  15187. (void)sp_4096_add_9(a2, a0, &a[18]);
  15188. sp_4096_norm_9(a2);
  15189. sp_4096_sqr_9(p0, a);
  15190. sp_4096_sqr_9(p2, &a[9]);
  15191. sp_4096_sqr_9(p4, &a[18]);
  15192. sp_4096_sqr_9(p1, a0);
  15193. sp_4096_sqr_9(p3, a1);
  15194. sp_4096_sqr_9(p5, a2);
  15195. XMEMSET(r, 0, sizeof(*r)*2U*27U);
  15196. (void)sp_4096_sub_18(t0, p3, p2);
  15197. (void)sp_4096_sub_18(t1, p1, p2);
  15198. (void)sp_4096_sub_18(t2, p5, t0);
  15199. (void)sp_4096_sub_18(t2, t2, t1);
  15200. sp_4096_norm_18(t2);
  15201. (void)sp_4096_sub_18(t0, t0, p4);
  15202. sp_4096_norm_18(t0);
  15203. (void)sp_4096_sub_18(t1, t1, p0);
  15204. sp_4096_norm_18(t1);
  15205. (void)sp_4096_add_18(r, r, p0);
  15206. (void)sp_4096_add_18(&r[9], &r[9], t1);
  15207. (void)sp_4096_add_18(&r[18], &r[18], t2);
  15208. (void)sp_4096_add_18(&r[27], &r[27], t0);
  15209. (void)sp_4096_add_18(&r[36], &r[36], p4);
  15210. sp_4096_norm_54(r);
  15211. }
  15212. /* Square a into r. (r = a * a)
  15213. *
  15214. * r A single precision integer.
  15215. * a A single precision integer.
  15216. */
  15217. SP_NOINLINE static void sp_4096_sqr_81(sp_digit* r, const sp_digit* a)
  15218. {
  15219. sp_digit p0[54];
  15220. sp_digit p1[54];
  15221. sp_digit p2[54];
  15222. sp_digit p3[54];
  15223. sp_digit p4[54];
  15224. sp_digit p5[54];
  15225. sp_digit t0[54];
  15226. sp_digit t1[54];
  15227. sp_digit t2[54];
  15228. sp_digit a0[27];
  15229. sp_digit a1[27];
  15230. sp_digit a2[27];
  15231. (void)sp_4096_add_27(a0, a, &a[27]);
  15232. sp_4096_norm_27(a0);
  15233. (void)sp_4096_add_27(a1, &a[27], &a[54]);
  15234. sp_4096_norm_27(a1);
  15235. (void)sp_4096_add_27(a2, a0, &a[54]);
  15236. sp_4096_norm_27(a2);
  15237. sp_4096_sqr_27(p0, a);
  15238. sp_4096_sqr_27(p2, &a[27]);
  15239. sp_4096_sqr_27(p4, &a[54]);
  15240. sp_4096_sqr_27(p1, a0);
  15241. sp_4096_sqr_27(p3, a1);
  15242. sp_4096_sqr_27(p5, a2);
  15243. XMEMSET(r, 0, sizeof(*r)*2U*81U);
  15244. (void)sp_4096_sub_54(t0, p3, p2);
  15245. (void)sp_4096_sub_54(t1, p1, p2);
  15246. (void)sp_4096_sub_54(t2, p5, t0);
  15247. (void)sp_4096_sub_54(t2, t2, t1);
  15248. sp_4096_norm_54(t2);
  15249. (void)sp_4096_sub_54(t0, t0, p4);
  15250. sp_4096_norm_54(t0);
  15251. (void)sp_4096_sub_54(t1, t1, p0);
  15252. sp_4096_norm_54(t1);
  15253. (void)sp_4096_add_54(r, r, p0);
  15254. (void)sp_4096_add_54(&r[27], &r[27], t1);
  15255. (void)sp_4096_add_54(&r[54], &r[54], t2);
  15256. (void)sp_4096_add_54(&r[81], &r[81], t0);
  15257. (void)sp_4096_add_54(&r[108], &r[108], p4);
  15258. sp_4096_norm_162(r);
  15259. }
  15260. /* Square a and put result in r. (r = a * a)
  15261. *
  15262. * r A single precision integer.
  15263. * a A single precision integer.
  15264. */
  15265. SP_NOINLINE static void sp_4096_sqr_162(sp_digit* r, const sp_digit* a)
  15266. {
  15267. sp_digit* z0 = r;
  15268. sp_digit z1[162];
  15269. sp_digit* a1 = z1;
  15270. sp_digit* z2 = r + 162;
  15271. (void)sp_4096_add_81(a1, a, &a[81]);
  15272. sp_4096_norm_81(a1);
  15273. sp_4096_sqr_81(z2, &a[81]);
  15274. sp_4096_sqr_81(z0, a);
  15275. sp_4096_sqr_81(z1, a1);
  15276. (void)sp_4096_sub_162(z1, z1, z2);
  15277. (void)sp_4096_sub_162(z1, z1, z0);
  15278. (void)sp_4096_add_162(r + 81, r + 81, z1);
  15279. sp_4096_norm_324(r);
  15280. }
  15281. #endif /* !WOLFSSL_SP_SMALL */
  15282. /* Calculate the bottom digit of -1/a mod 2^n.
  15283. *
  15284. * a A single precision number.
  15285. * rho Bottom word of inverse.
  15286. */
  15287. static void sp_4096_mont_setup(const sp_digit* a, sp_digit* rho)
  15288. {
  15289. sp_digit x;
  15290. sp_digit b;
  15291. b = a[0];
  15292. x = (((b + 2) & 4) << 1) + b; /* here x*a==1 mod 2**4 */
  15293. x *= 2 - b * x; /* here x*a==1 mod 2**8 */
  15294. x *= 2 - b * x; /* here x*a==1 mod 2**16 */
  15295. x *= 2 - b * x; /* here x*a==1 mod 2**32 */
  15296. x &= 0x3ffffff;
  15297. /* rho = -1/m mod b */
  15298. *rho = ((sp_digit)1 << 26) - x;
  15299. }
  15300. /* Multiply a by scalar b into r. (r = a * b)
  15301. *
  15302. * r A single precision integer.
  15303. * a A single precision integer.
  15304. * b A scalar.
  15305. */
  15306. SP_NOINLINE static void sp_4096_mul_d_162(sp_digit* r, const sp_digit* a,
  15307. sp_digit b)
  15308. {
  15309. sp_int64 tb = b;
  15310. sp_int64 t = 0;
  15311. sp_digit t2;
  15312. sp_int64 p[4];
  15313. int i;
  15314. for (i = 0; i < 160; i += 4) {
  15315. p[0] = tb * a[i + 0];
  15316. p[1] = tb * a[i + 1];
  15317. p[2] = tb * a[i + 2];
  15318. p[3] = tb * a[i + 3];
  15319. t += p[0];
  15320. t2 = (sp_digit)(t & 0x3ffffff);
  15321. t >>= 26;
  15322. r[i + 0] = (sp_digit)t2;
  15323. t += p[1];
  15324. t2 = (sp_digit)(t & 0x3ffffff);
  15325. t >>= 26;
  15326. r[i + 1] = (sp_digit)t2;
  15327. t += p[2];
  15328. t2 = (sp_digit)(t & 0x3ffffff);
  15329. t >>= 26;
  15330. r[i + 2] = (sp_digit)t2;
  15331. t += p[3];
  15332. t2 = (sp_digit)(t & 0x3ffffff);
  15333. t >>= 26;
  15334. r[i + 3] = (sp_digit)t2;
  15335. }
  15336. t += tb * a[160];
  15337. r[160] = (sp_digit)(t & 0x3ffffff);
  15338. t >>= 26;
  15339. t += tb * a[161];
  15340. r[161] = (sp_digit)(t & 0x3ffffff);
  15341. t >>= 26;
  15342. r[162] = (sp_digit)(t & 0x3ffffff);
  15343. }
  15344. #if (defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
  15345. #if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D)
  15346. /* Sub b from a into r. (r = a - b)
  15347. *
  15348. * r A single precision integer.
  15349. * a A single precision integer.
  15350. * b A single precision integer.
  15351. */
  15352. SP_NOINLINE static int sp_4096_sub_81(sp_digit* r, const sp_digit* a,
  15353. const sp_digit* b)
  15354. {
  15355. int i;
  15356. for (i = 0; i < 80; i += 8) {
  15357. r[i + 0] = a[i + 0] - b[i + 0];
  15358. r[i + 1] = a[i + 1] - b[i + 1];
  15359. r[i + 2] = a[i + 2] - b[i + 2];
  15360. r[i + 3] = a[i + 3] - b[i + 3];
  15361. r[i + 4] = a[i + 4] - b[i + 4];
  15362. r[i + 5] = a[i + 5] - b[i + 5];
  15363. r[i + 6] = a[i + 6] - b[i + 6];
  15364. r[i + 7] = a[i + 7] - b[i + 7];
  15365. }
  15366. r[80] = a[80] - b[80];
  15367. return 0;
  15368. }
  15369. /* r = 2^n mod m where n is the number of bits to reduce by.
  15370. * Given m must be 4096 bits, just need to subtract.
  15371. *
  15372. * r A single precision number.
  15373. * m A single precision number.
  15374. */
  15375. static void sp_4096_mont_norm_81(sp_digit* r, const sp_digit* m)
  15376. {
  15377. /* Set r = 2^n - 1. */
  15378. int i;
  15379. for (i = 0; i < 72; i += 8) {
  15380. r[i + 0] = 0x3ffffff;
  15381. r[i + 1] = 0x3ffffff;
  15382. r[i + 2] = 0x3ffffff;
  15383. r[i + 3] = 0x3ffffff;
  15384. r[i + 4] = 0x3ffffff;
  15385. r[i + 5] = 0x3ffffff;
  15386. r[i + 6] = 0x3ffffff;
  15387. r[i + 7] = 0x3ffffff;
  15388. }
  15389. r[72] = 0x3ffffff;
  15390. r[73] = 0x3ffffff;
  15391. r[74] = 0x3ffffff;
  15392. r[75] = 0x3ffffff;
  15393. r[76] = 0x3ffffff;
  15394. r[77] = 0x3ffffff;
  15395. r[78] = 0xfffffL;
  15396. r[79] = 0;
  15397. r[80] = 0;
  15398. /* r = (2^n - 1) mod n */
  15399. (void)sp_4096_sub_81(r, r, m);
  15400. /* Add one so r = 2^n mod m */
  15401. r[0] += 1;
  15402. }
  15403. /* Compare a with b in constant time.
  15404. *
  15405. * a A single precision integer.
  15406. * b A single precision integer.
  15407. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  15408. * respectively.
  15409. */
  15410. static sp_digit sp_4096_cmp_81(const sp_digit* a, const sp_digit* b)
  15411. {
  15412. sp_digit r = 0;
  15413. int i;
  15414. r |= (a[80] - b[80]) & (0 - (sp_digit)1);
  15415. for (i = 72; i >= 0; i -= 8) {
  15416. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 25);
  15417. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 25);
  15418. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 25);
  15419. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 25);
  15420. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 25);
  15421. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 25);
  15422. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 25);
  15423. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 25);
  15424. }
  15425. return r;
  15426. }
  15427. /* Conditionally subtract b from a using the mask m.
  15428. * m is -1 to subtract and 0 when not.
  15429. *
  15430. * r A single precision number representing condition subtract result.
  15431. * a A single precision number to subtract from.
  15432. * b A single precision number to subtract.
  15433. * m Mask value to apply.
  15434. */
  15435. static void sp_4096_cond_sub_81(sp_digit* r, const sp_digit* a,
  15436. const sp_digit* b, const sp_digit m)
  15437. {
  15438. int i;
  15439. for (i = 0; i < 80; i += 8) {
  15440. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  15441. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  15442. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  15443. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  15444. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  15445. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  15446. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  15447. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  15448. }
  15449. r[80] = a[80] - (b[80] & m);
  15450. }
  15451. /* Mul a by scalar b and add into r. (r += a * b)
  15452. *
  15453. * r A single precision integer.
  15454. * a A single precision integer.
  15455. * b A scalar.
  15456. */
  15457. SP_NOINLINE static void sp_4096_mul_add_81(sp_digit* r, const sp_digit* a,
  15458. const sp_digit b)
  15459. {
  15460. #ifndef WOLFSSL_SP_LARGE_CODE
  15461. sp_int64 tb = b;
  15462. sp_int64 t = 0;
  15463. int i;
  15464. for (i = 0; i < 81; i++) {
  15465. t += r[i];
  15466. t += tb * a[i];
  15467. r[i] = ((sp_digit)t) & 0x3ffffff;
  15468. t >>= 26;
  15469. }
  15470. r[81] += (sp_digit)t;
  15471. #else
  15472. sp_int64 tb = b;
  15473. sp_int64 t[8];
  15474. int i;
  15475. t[0] = 0;
  15476. for (i = 0; i < 80; i += 8) {
  15477. t[0] += (tb * a[i+0]) + r[i+0];
  15478. t[1] = (tb * a[i+1]) + r[i+1];
  15479. t[2] = (tb * a[i+2]) + r[i+2];
  15480. t[3] = (tb * a[i+3]) + r[i+3];
  15481. t[4] = (tb * a[i+4]) + r[i+4];
  15482. t[5] = (tb * a[i+5]) + r[i+5];
  15483. t[6] = (tb * a[i+6]) + r[i+6];
  15484. t[7] = (tb * a[i+7]) + r[i+7];
  15485. r[i+0] = t[0] & 0x3ffffff;
  15486. t[1] += t[0] >> 26;
  15487. r[i+1] = t[1] & 0x3ffffff;
  15488. t[2] += t[1] >> 26;
  15489. r[i+2] = t[2] & 0x3ffffff;
  15490. t[3] += t[2] >> 26;
  15491. r[i+3] = t[3] & 0x3ffffff;
  15492. t[4] += t[3] >> 26;
  15493. r[i+4] = t[4] & 0x3ffffff;
  15494. t[5] += t[4] >> 26;
  15495. r[i+5] = t[5] & 0x3ffffff;
  15496. t[6] += t[5] >> 26;
  15497. r[i+6] = t[6] & 0x3ffffff;
  15498. t[7] += t[6] >> 26;
  15499. r[i+7] = t[7] & 0x3ffffff;
  15500. t[0] = t[7] >> 26;
  15501. }
  15502. t[0] += (tb * a[80]) + r[80];
  15503. r[80] = t[0] & 0x3ffffff;
  15504. r[81] += (sp_digit)(t[0] >> 26);
  15505. #endif /* !WOLFSSL_SP_LARGE_CODE */
  15506. }
  15507. /* Shift the result in the high 2048 bits down to the bottom.
  15508. *
  15509. * r A single precision number.
  15510. * a A single precision number.
  15511. */
  15512. static void sp_4096_mont_shift_81(sp_digit* r, const sp_digit* a)
  15513. {
  15514. int i;
  15515. sp_int64 n = a[78] >> 20;
  15516. n += ((sp_int64)a[79]) << 6;
  15517. for (i = 0; i < 72; i += 8) {
  15518. r[i + 0] = n & 0x3ffffff;
  15519. n >>= 26; n += ((sp_int64)a[i + 80]) << 6;
  15520. r[i + 1] = n & 0x3ffffff;
  15521. n >>= 26; n += ((sp_int64)a[i + 81]) << 6;
  15522. r[i + 2] = n & 0x3ffffff;
  15523. n >>= 26; n += ((sp_int64)a[i + 82]) << 6;
  15524. r[i + 3] = n & 0x3ffffff;
  15525. n >>= 26; n += ((sp_int64)a[i + 83]) << 6;
  15526. r[i + 4] = n & 0x3ffffff;
  15527. n >>= 26; n += ((sp_int64)a[i + 84]) << 6;
  15528. r[i + 5] = n & 0x3ffffff;
  15529. n >>= 26; n += ((sp_int64)a[i + 85]) << 6;
  15530. r[i + 6] = n & 0x3ffffff;
  15531. n >>= 26; n += ((sp_int64)a[i + 86]) << 6;
  15532. r[i + 7] = n & 0x3ffffff;
  15533. n >>= 26; n += ((sp_int64)a[i + 87]) << 6;
  15534. }
  15535. r[72] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[152]) << 6;
  15536. r[73] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[153]) << 6;
  15537. r[74] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[154]) << 6;
  15538. r[75] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[155]) << 6;
  15539. r[76] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[156]) << 6;
  15540. r[77] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[157]) << 6;
  15541. r[78] = (sp_digit)n;
  15542. XMEMSET(&r[79], 0, sizeof(*r) * 79U);
  15543. }
  15544. /* Reduce the number back to 4096 bits using Montgomery reduction.
  15545. *
  15546. * a A single precision number to reduce in place.
  15547. * m The single precision number representing the modulus.
  15548. * mp The digit representing the negative inverse of m mod 2^n.
  15549. */
  15550. static void sp_4096_mont_reduce_81(sp_digit* a, const sp_digit* m, sp_digit mp)
  15551. {
  15552. int i;
  15553. sp_digit mu;
  15554. sp_digit over;
  15555. sp_4096_norm_81(a + 79);
  15556. for (i=0; i<78; i++) {
  15557. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffff;
  15558. sp_4096_mul_add_81(a+i, m, mu);
  15559. a[i+1] += a[i] >> 26;
  15560. }
  15561. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffL;
  15562. sp_4096_mul_add_81(a+i, m, mu);
  15563. a[i+1] += a[i] >> 26;
  15564. a[i] &= 0x3ffffff;
  15565. sp_4096_mont_shift_81(a, a);
  15566. over = a[78] - m[78];
  15567. sp_4096_cond_sub_81(a, a, m, ~((over - 1) >> 31));
  15568. sp_4096_norm_81(a);
  15569. }
  15570. /* Multiply two Montgomery form numbers mod the modulus (prime).
  15571. * (r = a * b mod m)
  15572. *
  15573. * r Result of multiplication.
  15574. * a First number to multiply in Montgomery form.
  15575. * b Second number to multiply in Montgomery form.
  15576. * m Modulus (prime).
  15577. * mp Montgomery multiplier.
  15578. */
  15579. SP_NOINLINE static void sp_4096_mont_mul_81(sp_digit* r, const sp_digit* a,
  15580. const sp_digit* b, const sp_digit* m, sp_digit mp)
  15581. {
  15582. sp_4096_mul_81(r, a, b);
  15583. sp_4096_mont_reduce_81(r, m, mp);
  15584. }
  15585. /* Square the Montgomery form number. (r = a * a mod m)
  15586. *
  15587. * r Result of squaring.
  15588. * a Number to square in Montgomery form.
  15589. * m Modulus (prime).
  15590. * mp Montgomery multiplier.
  15591. */
  15592. SP_NOINLINE static void sp_4096_mont_sqr_81(sp_digit* r, const sp_digit* a,
  15593. const sp_digit* m, sp_digit mp)
  15594. {
  15595. sp_4096_sqr_81(r, a);
  15596. sp_4096_mont_reduce_81(r, m, mp);
  15597. }
  15598. /* Multiply a by scalar b into r. (r = a * b)
  15599. *
  15600. * r A single precision integer.
  15601. * a A single precision integer.
  15602. * b A scalar.
  15603. */
  15604. SP_NOINLINE static void sp_4096_mul_d_81(sp_digit* r, const sp_digit* a,
  15605. sp_digit b)
  15606. {
  15607. sp_int64 tb = b;
  15608. sp_int64 t = 0;
  15609. sp_digit t2;
  15610. sp_int64 p[4];
  15611. int i;
  15612. for (i = 0; i < 80; i += 4) {
  15613. p[0] = tb * a[i + 0];
  15614. p[1] = tb * a[i + 1];
  15615. p[2] = tb * a[i + 2];
  15616. p[3] = tb * a[i + 3];
  15617. t += p[0];
  15618. t2 = (sp_digit)(t & 0x3ffffff);
  15619. t >>= 26;
  15620. r[i + 0] = (sp_digit)t2;
  15621. t += p[1];
  15622. t2 = (sp_digit)(t & 0x3ffffff);
  15623. t >>= 26;
  15624. r[i + 1] = (sp_digit)t2;
  15625. t += p[2];
  15626. t2 = (sp_digit)(t & 0x3ffffff);
  15627. t >>= 26;
  15628. r[i + 2] = (sp_digit)t2;
  15629. t += p[3];
  15630. t2 = (sp_digit)(t & 0x3ffffff);
  15631. t >>= 26;
  15632. r[i + 3] = (sp_digit)t2;
  15633. }
  15634. t += tb * a[80];
  15635. r[80] = (sp_digit)(t & 0x3ffffff);
  15636. t >>= 26;
  15637. r[81] = (sp_digit)(t & 0x3ffffff);
  15638. }
  15639. #ifndef WOLFSSL_SP_SMALL
  15640. /* Conditionally add a and b using the mask m.
  15641. * m is -1 to add and 0 when not.
  15642. *
  15643. * r A single precision number representing conditional add result.
  15644. * a A single precision number to add with.
  15645. * b A single precision number to add.
  15646. * m Mask value to apply.
  15647. */
  15648. static void sp_4096_cond_add_81(sp_digit* r, const sp_digit* a,
  15649. const sp_digit* b, const sp_digit m)
  15650. {
  15651. int i;
  15652. for (i = 0; i < 80; i += 8) {
  15653. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  15654. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  15655. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  15656. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  15657. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  15658. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  15659. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  15660. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  15661. }
  15662. r[80] = a[80] + (b[80] & m);
  15663. }
  15664. #endif /* !WOLFSSL_SP_SMALL */
  15665. SP_NOINLINE static void sp_4096_rshift_81(sp_digit* r, const sp_digit* a,
  15666. byte n)
  15667. {
  15668. int i;
  15669. for (i=0; i<80; i += 8) {
  15670. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (26 - n)) & 0x3ffffff);
  15671. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (26 - n)) & 0x3ffffff);
  15672. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (26 - n)) & 0x3ffffff);
  15673. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (26 - n)) & 0x3ffffff);
  15674. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (26 - n)) & 0x3ffffff);
  15675. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (26 - n)) & 0x3ffffff);
  15676. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (26 - n)) & 0x3ffffff);
  15677. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (26 - n)) & 0x3ffffff);
  15678. }
  15679. r[80] = a[80] >> n;
  15680. }
  15681. static WC_INLINE sp_digit sp_4096_div_word_81(sp_digit d1, sp_digit d0,
  15682. sp_digit div)
  15683. {
  15684. #ifdef SP_USE_DIVTI3
  15685. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  15686. return d / div;
  15687. #elif defined(__x86_64__) || defined(__i386__)
  15688. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  15689. sp_uint32 lo = (sp_uint32)d;
  15690. sp_digit hi = (sp_digit)(d >> 32);
  15691. __asm__ __volatile__ (
  15692. "idiv %2"
  15693. : "+a" (lo)
  15694. : "d" (hi), "r" (div)
  15695. : "cc"
  15696. );
  15697. return (sp_digit)lo;
  15698. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  15699. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  15700. sp_digit dv = (div >> 1) + 1;
  15701. sp_digit t1 = (sp_digit)(d >> 26);
  15702. sp_digit t0 = (sp_digit)(d & 0x3ffffff);
  15703. sp_digit t2;
  15704. sp_digit sign;
  15705. sp_digit r;
  15706. int i;
  15707. sp_int64 m;
  15708. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  15709. t1 -= dv & (0 - r);
  15710. for (i = 24; i >= 1; i--) {
  15711. t1 += t1 + (((sp_uint32)t0 >> 25) & 1);
  15712. t0 <<= 1;
  15713. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  15714. r += r + t2;
  15715. t1 -= dv & (0 - t2);
  15716. t1 += t2;
  15717. }
  15718. r += r + 1;
  15719. m = d - ((sp_int64)r * div);
  15720. r += (sp_digit)(m >> 26);
  15721. m = d - ((sp_int64)r * div);
  15722. r += (sp_digit)(m >> 52) - (sp_digit)(d >> 52);
  15723. m = d - ((sp_int64)r * div);
  15724. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  15725. m *= sign;
  15726. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  15727. r += sign * t2;
  15728. m = d - ((sp_int64)r * div);
  15729. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  15730. m *= sign;
  15731. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  15732. r += sign * t2;
  15733. return r;
  15734. #else
  15735. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  15736. sp_digit r = 0;
  15737. sp_digit t;
  15738. sp_digit dv = (div >> 11) + 1;
  15739. t = (sp_digit)(d >> 22);
  15740. t = (t / dv) << 11;
  15741. r += t;
  15742. d -= (sp_int64)t * div;
  15743. t = (sp_digit)(d >> 7);
  15744. t = t / (dv << 4);
  15745. r += t;
  15746. d -= (sp_int64)t * div;
  15747. t = (sp_digit)d;
  15748. t = t / div;
  15749. r += t;
  15750. d -= (sp_int64)t * div;
  15751. return r;
  15752. #endif
  15753. }
  15754. static WC_INLINE sp_digit sp_4096_word_div_word_81(sp_digit d, sp_digit div)
  15755. {
  15756. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  15757. defined(SP_DIV_WORD_USE_DIV)
  15758. return d / div;
  15759. #else
  15760. return (sp_digit)((sp_uint32)(div - d) >> 31);
  15761. #endif
  15762. }
  15763. /* Divide d in a and put remainder into r (m*d + r = a)
  15764. * m is not calculated as it is not needed at this time.
  15765. *
  15766. * Full implementation.
  15767. *
  15768. * a Number to be divided.
  15769. * d Number to divide with.
  15770. * m Multiplier result.
  15771. * r Remainder from the division.
  15772. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  15773. */
  15774. static int sp_4096_div_81(const sp_digit* a, const sp_digit* d,
  15775. const sp_digit* m, sp_digit* r)
  15776. {
  15777. int i;
  15778. #ifndef WOLFSSL_SP_DIV_32
  15779. #endif
  15780. sp_digit dv;
  15781. sp_digit r1;
  15782. #ifdef WOLFSSL_SP_SMALL_STACK
  15783. sp_digit* t1 = NULL;
  15784. #else
  15785. sp_digit t1[4 * 81 + 3];
  15786. #endif
  15787. sp_digit* t2 = NULL;
  15788. sp_digit* sd = NULL;
  15789. int err = MP_OKAY;
  15790. (void)m;
  15791. #ifdef WOLFSSL_SP_SMALL_STACK
  15792. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 81 + 3), NULL,
  15793. DYNAMIC_TYPE_TMP_BUFFER);
  15794. if (t1 == NULL)
  15795. err = MEMORY_E;
  15796. #endif
  15797. (void)m;
  15798. if (err == MP_OKAY) {
  15799. t2 = t1 + 162 + 1;
  15800. sd = t2 + 81 + 1;
  15801. sp_4096_mul_d_81(sd, d, (sp_digit)1 << 6);
  15802. sp_4096_mul_d_162(t1, a, (sp_digit)1 << 6);
  15803. dv = sd[78];
  15804. t1[79 + 79] += t1[79 + 79 - 1] >> 26;
  15805. t1[79 + 79 - 1] &= 0x3ffffff;
  15806. for (i=79; i>=0; i--) {
  15807. r1 = sp_4096_div_word_81(t1[79 + i], t1[79 + i - 1], dv);
  15808. sp_4096_mul_d_81(t2, sd, r1);
  15809. (void)sp_4096_sub_81(&t1[i], &t1[i], t2);
  15810. sp_4096_norm_79(&t1[i]);
  15811. t1[79 + i] += t1[79 + i - 1] >> 26;
  15812. t1[79 + i - 1] &= 0x3ffffff;
  15813. r1 = sp_4096_div_word_81(-t1[79 + i], -t1[79 + i - 1], dv);
  15814. r1 -= t1[79 + i];
  15815. sp_4096_mul_d_81(t2, sd, r1);
  15816. (void)sp_4096_add_81(&t1[i], &t1[i], t2);
  15817. t1[79 + i] += t1[79 + i - 1] >> 26;
  15818. t1[79 + i - 1] &= 0x3ffffff;
  15819. }
  15820. t1[79 - 1] += t1[79 - 2] >> 26;
  15821. t1[79 - 2] &= 0x3ffffff;
  15822. r1 = sp_4096_word_div_word_81(t1[79 - 1], dv);
  15823. sp_4096_mul_d_81(t2, sd, r1);
  15824. sp_4096_sub_81(t1, t1, t2);
  15825. XMEMCPY(r, t1, sizeof(*r) * 162U);
  15826. for (i=0; i<78; i++) {
  15827. r[i+1] += r[i] >> 26;
  15828. r[i] &= 0x3ffffff;
  15829. }
  15830. sp_4096_cond_add_81(r, r, sd, r[78] >> 31);
  15831. sp_4096_norm_79(r);
  15832. sp_4096_rshift_81(r, r, 6);
  15833. r[79] = 0;
  15834. r[80] = 0;
  15835. }
  15836. #ifdef WOLFSSL_SP_SMALL_STACK
  15837. if (t1 != NULL)
  15838. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  15839. #endif
  15840. return err;
  15841. }
  15842. /* Reduce a modulo m into r. (r = a mod m)
  15843. *
  15844. * r A single precision number that is the reduced result.
  15845. * a A single precision number that is to be reduced.
  15846. * m A single precision number that is the modulus to reduce with.
  15847. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  15848. */
  15849. static int sp_4096_mod_81(sp_digit* r, const sp_digit* a, const sp_digit* m)
  15850. {
  15851. return sp_4096_div_81(a, m, NULL, r);
  15852. }
  15853. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  15854. *
  15855. * r A single precision number that is the result of the operation.
  15856. * a A single precision number being exponentiated.
  15857. * e A single precision number that is the exponent.
  15858. * bits The number of bits in the exponent.
  15859. * m A single precision number that is the modulus.
  15860. * returns 0 on success.
  15861. * returns MEMORY_E on dynamic memory allocation failure.
  15862. * returns MP_VAL when base is even or exponent is 0.
  15863. */
  15864. static int sp_4096_mod_exp_81(sp_digit* r, const sp_digit* a, const sp_digit* e,
  15865. int bits, const sp_digit* m, int reduceA)
  15866. {
  15867. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  15868. #ifdef WOLFSSL_SP_SMALL_STACK
  15869. sp_digit* td = NULL;
  15870. #else
  15871. sp_digit td[3 * 162];
  15872. #endif
  15873. sp_digit* t[3] = {0, 0, 0};
  15874. sp_digit* norm = NULL;
  15875. sp_digit mp = 1;
  15876. sp_digit n;
  15877. int i;
  15878. int c;
  15879. byte y;
  15880. int err = MP_OKAY;
  15881. if (bits == 0) {
  15882. err = MP_VAL;
  15883. }
  15884. #ifdef WOLFSSL_SP_SMALL_STACK
  15885. if (err == MP_OKAY) {
  15886. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 81 * 2, NULL,
  15887. DYNAMIC_TYPE_TMP_BUFFER);
  15888. if (td == NULL)
  15889. err = MEMORY_E;
  15890. }
  15891. #endif
  15892. if (err == MP_OKAY) {
  15893. norm = td;
  15894. for (i=0; i<3; i++) {
  15895. t[i] = td + (i * 81 * 2);
  15896. XMEMSET(t[i], 0, sizeof(sp_digit) * 81U * 2U);
  15897. }
  15898. sp_4096_mont_setup(m, &mp);
  15899. sp_4096_mont_norm_81(norm, m);
  15900. if (reduceA != 0) {
  15901. err = sp_4096_mod_81(t[1], a, m);
  15902. }
  15903. else {
  15904. XMEMCPY(t[1], a, sizeof(sp_digit) * 81U);
  15905. }
  15906. }
  15907. if (err == MP_OKAY) {
  15908. sp_4096_mul_81(t[1], t[1], norm);
  15909. err = sp_4096_mod_81(t[1], t[1], m);
  15910. }
  15911. if (err == MP_OKAY) {
  15912. i = bits / 26;
  15913. c = bits % 26;
  15914. n = e[i--] << (26 - c);
  15915. for (; ; c--) {
  15916. if (c == 0) {
  15917. if (i == -1) {
  15918. break;
  15919. }
  15920. n = e[i--];
  15921. c = 26;
  15922. }
  15923. y = (int)((n >> 25) & 1);
  15924. n <<= 1;
  15925. sp_4096_mont_mul_81(t[y^1], t[0], t[1], m, mp);
  15926. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  15927. ((size_t)t[1] & addr_mask[y])),
  15928. sizeof(*t[2]) * 81 * 2);
  15929. sp_4096_mont_sqr_81(t[2], t[2], m, mp);
  15930. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  15931. ((size_t)t[1] & addr_mask[y])), t[2],
  15932. sizeof(*t[2]) * 81 * 2);
  15933. }
  15934. sp_4096_mont_reduce_81(t[0], m, mp);
  15935. n = sp_4096_cmp_81(t[0], m);
  15936. sp_4096_cond_sub_81(t[0], t[0], m, ~(n >> 31));
  15937. XMEMCPY(r, t[0], sizeof(*r) * 81 * 2);
  15938. }
  15939. #ifdef WOLFSSL_SP_SMALL_STACK
  15940. if (td != NULL)
  15941. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  15942. #endif
  15943. return err;
  15944. #elif !defined(WC_NO_CACHE_RESISTANT)
  15945. #ifdef WOLFSSL_SP_SMALL_STACK
  15946. sp_digit* td = NULL;
  15947. #else
  15948. sp_digit td[3 * 162];
  15949. #endif
  15950. sp_digit* t[3] = {0, 0, 0};
  15951. sp_digit* norm = NULL;
  15952. sp_digit mp = 1;
  15953. sp_digit n;
  15954. int i;
  15955. int c;
  15956. byte y;
  15957. int err = MP_OKAY;
  15958. if (bits == 0) {
  15959. err = MP_VAL;
  15960. }
  15961. #ifdef WOLFSSL_SP_SMALL_STACK
  15962. if (err == MP_OKAY) {
  15963. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 81 * 2, NULL,
  15964. DYNAMIC_TYPE_TMP_BUFFER);
  15965. if (td == NULL)
  15966. err = MEMORY_E;
  15967. }
  15968. #endif
  15969. if (err == MP_OKAY) {
  15970. norm = td;
  15971. for (i=0; i<3; i++) {
  15972. t[i] = td + (i * 81 * 2);
  15973. }
  15974. sp_4096_mont_setup(m, &mp);
  15975. sp_4096_mont_norm_81(norm, m);
  15976. if (reduceA != 0) {
  15977. err = sp_4096_mod_81(t[1], a, m);
  15978. if (err == MP_OKAY) {
  15979. sp_4096_mul_81(t[1], t[1], norm);
  15980. err = sp_4096_mod_81(t[1], t[1], m);
  15981. }
  15982. }
  15983. else {
  15984. sp_4096_mul_81(t[1], a, norm);
  15985. err = sp_4096_mod_81(t[1], t[1], m);
  15986. }
  15987. }
  15988. if (err == MP_OKAY) {
  15989. i = bits / 26;
  15990. c = bits % 26;
  15991. n = e[i--] << (26 - c);
  15992. for (; ; c--) {
  15993. if (c == 0) {
  15994. if (i == -1) {
  15995. break;
  15996. }
  15997. n = e[i--];
  15998. c = 26;
  15999. }
  16000. y = (int)((n >> 25) & 1);
  16001. n <<= 1;
  16002. sp_4096_mont_mul_81(t[y^1], t[0], t[1], m, mp);
  16003. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  16004. ((size_t)t[1] & addr_mask[y])),
  16005. sizeof(*t[2]) * 81 * 2);
  16006. sp_4096_mont_sqr_81(t[2], t[2], m, mp);
  16007. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  16008. ((size_t)t[1] & addr_mask[y])), t[2],
  16009. sizeof(*t[2]) * 81 * 2);
  16010. }
  16011. sp_4096_mont_reduce_81(t[0], m, mp);
  16012. n = sp_4096_cmp_81(t[0], m);
  16013. sp_4096_cond_sub_81(t[0], t[0], m, ~(n >> 31));
  16014. XMEMCPY(r, t[0], sizeof(*r) * 81 * 2);
  16015. }
  16016. #ifdef WOLFSSL_SP_SMALL_STACK
  16017. if (td != NULL)
  16018. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16019. #endif
  16020. return err;
  16021. #else
  16022. #ifdef WOLFSSL_SP_SMALL_STACK
  16023. sp_digit* td = NULL;
  16024. #else
  16025. sp_digit td[(32 * 162) + 162];
  16026. #endif
  16027. sp_digit* t[32];
  16028. sp_digit* rt = NULL;
  16029. sp_digit* norm = NULL;
  16030. sp_digit mp = 1;
  16031. sp_digit n;
  16032. int i;
  16033. int c;
  16034. byte y;
  16035. int err = MP_OKAY;
  16036. if (bits == 0) {
  16037. err = MP_VAL;
  16038. }
  16039. #ifdef WOLFSSL_SP_SMALL_STACK
  16040. if (err == MP_OKAY) {
  16041. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((32 * 162) + 162), NULL,
  16042. DYNAMIC_TYPE_TMP_BUFFER);
  16043. if (td == NULL)
  16044. err = MEMORY_E;
  16045. }
  16046. #endif
  16047. if (err == MP_OKAY) {
  16048. norm = td;
  16049. for (i=0; i<32; i++)
  16050. t[i] = td + i * 162;
  16051. rt = td + 5184;
  16052. sp_4096_mont_setup(m, &mp);
  16053. sp_4096_mont_norm_81(norm, m);
  16054. if (reduceA != 0) {
  16055. err = sp_4096_mod_81(t[1], a, m);
  16056. if (err == MP_OKAY) {
  16057. sp_4096_mul_81(t[1], t[1], norm);
  16058. err = sp_4096_mod_81(t[1], t[1], m);
  16059. }
  16060. }
  16061. else {
  16062. sp_4096_mul_81(t[1], a, norm);
  16063. err = sp_4096_mod_81(t[1], t[1], m);
  16064. }
  16065. }
  16066. if (err == MP_OKAY) {
  16067. sp_4096_mont_sqr_81(t[ 2], t[ 1], m, mp);
  16068. sp_4096_mont_mul_81(t[ 3], t[ 2], t[ 1], m, mp);
  16069. sp_4096_mont_sqr_81(t[ 4], t[ 2], m, mp);
  16070. sp_4096_mont_mul_81(t[ 5], t[ 3], t[ 2], m, mp);
  16071. sp_4096_mont_sqr_81(t[ 6], t[ 3], m, mp);
  16072. sp_4096_mont_mul_81(t[ 7], t[ 4], t[ 3], m, mp);
  16073. sp_4096_mont_sqr_81(t[ 8], t[ 4], m, mp);
  16074. sp_4096_mont_mul_81(t[ 9], t[ 5], t[ 4], m, mp);
  16075. sp_4096_mont_sqr_81(t[10], t[ 5], m, mp);
  16076. sp_4096_mont_mul_81(t[11], t[ 6], t[ 5], m, mp);
  16077. sp_4096_mont_sqr_81(t[12], t[ 6], m, mp);
  16078. sp_4096_mont_mul_81(t[13], t[ 7], t[ 6], m, mp);
  16079. sp_4096_mont_sqr_81(t[14], t[ 7], m, mp);
  16080. sp_4096_mont_mul_81(t[15], t[ 8], t[ 7], m, mp);
  16081. sp_4096_mont_sqr_81(t[16], t[ 8], m, mp);
  16082. sp_4096_mont_mul_81(t[17], t[ 9], t[ 8], m, mp);
  16083. sp_4096_mont_sqr_81(t[18], t[ 9], m, mp);
  16084. sp_4096_mont_mul_81(t[19], t[10], t[ 9], m, mp);
  16085. sp_4096_mont_sqr_81(t[20], t[10], m, mp);
  16086. sp_4096_mont_mul_81(t[21], t[11], t[10], m, mp);
  16087. sp_4096_mont_sqr_81(t[22], t[11], m, mp);
  16088. sp_4096_mont_mul_81(t[23], t[12], t[11], m, mp);
  16089. sp_4096_mont_sqr_81(t[24], t[12], m, mp);
  16090. sp_4096_mont_mul_81(t[25], t[13], t[12], m, mp);
  16091. sp_4096_mont_sqr_81(t[26], t[13], m, mp);
  16092. sp_4096_mont_mul_81(t[27], t[14], t[13], m, mp);
  16093. sp_4096_mont_sqr_81(t[28], t[14], m, mp);
  16094. sp_4096_mont_mul_81(t[29], t[15], t[14], m, mp);
  16095. sp_4096_mont_sqr_81(t[30], t[15], m, mp);
  16096. sp_4096_mont_mul_81(t[31], t[16], t[15], m, mp);
  16097. bits = ((bits + 4) / 5) * 5;
  16098. i = ((bits + 25) / 26) - 1;
  16099. c = bits % 26;
  16100. if (c == 0) {
  16101. c = 26;
  16102. }
  16103. if (i < 81) {
  16104. n = e[i--] << (32 - c);
  16105. }
  16106. else {
  16107. n = 0;
  16108. i--;
  16109. }
  16110. if (c < 5) {
  16111. n |= e[i--] << (6 - c);
  16112. c += 26;
  16113. }
  16114. y = (int)((n >> 27) & 0x1f);
  16115. n <<= 5;
  16116. c -= 5;
  16117. XMEMCPY(rt, t[y], sizeof(sp_digit) * 162);
  16118. while ((i >= 0) || (c >= 5)) {
  16119. if (c >= 5) {
  16120. y = (byte)((n >> 27) & 0x1f);
  16121. n <<= 5;
  16122. c -= 5;
  16123. }
  16124. else if (c == 0) {
  16125. n = e[i--] << 6;
  16126. y = (byte)((n >> 27) & 0x1f);
  16127. n <<= 5;
  16128. c = 21;
  16129. }
  16130. else {
  16131. y = (byte)((n >> 27) & 0x1f);
  16132. n = e[i--] << 6;
  16133. c = 5 - c;
  16134. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  16135. n <<= c;
  16136. c = 26 - c;
  16137. }
  16138. sp_4096_mont_sqr_81(rt, rt, m, mp);
  16139. sp_4096_mont_sqr_81(rt, rt, m, mp);
  16140. sp_4096_mont_sqr_81(rt, rt, m, mp);
  16141. sp_4096_mont_sqr_81(rt, rt, m, mp);
  16142. sp_4096_mont_sqr_81(rt, rt, m, mp);
  16143. sp_4096_mont_mul_81(rt, rt, t[y], m, mp);
  16144. }
  16145. sp_4096_mont_reduce_81(rt, m, mp);
  16146. n = sp_4096_cmp_81(rt, m);
  16147. sp_4096_cond_sub_81(rt, rt, m, ~(n >> 31));
  16148. XMEMCPY(r, rt, sizeof(sp_digit) * 162);
  16149. }
  16150. #ifdef WOLFSSL_SP_SMALL_STACK
  16151. if (td != NULL)
  16152. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16153. #endif
  16154. return err;
  16155. #endif
  16156. }
  16157. #endif /* WOLFSSL_HAVE_SP_RSA & !SP_RSA_PRIVATE_EXP_D */
  16158. #endif /* (WOLFSSL_HAVE_SP_RSA | WOLFSSL_HAVE_SP_DH) & !WOLFSSL_RSA_PUBLIC_ONLY */
  16159. /* r = 2^n mod m where n is the number of bits to reduce by.
  16160. * Given m must be 4096 bits, just need to subtract.
  16161. *
  16162. * r A single precision number.
  16163. * m A single precision number.
  16164. */
  16165. static void sp_4096_mont_norm_162(sp_digit* r, const sp_digit* m)
  16166. {
  16167. /* Set r = 2^n - 1. */
  16168. int i;
  16169. for (i = 0; i < 152; i += 8) {
  16170. r[i + 0] = 0x3ffffff;
  16171. r[i + 1] = 0x3ffffff;
  16172. r[i + 2] = 0x3ffffff;
  16173. r[i + 3] = 0x3ffffff;
  16174. r[i + 4] = 0x3ffffff;
  16175. r[i + 5] = 0x3ffffff;
  16176. r[i + 6] = 0x3ffffff;
  16177. r[i + 7] = 0x3ffffff;
  16178. }
  16179. r[152] = 0x3ffffff;
  16180. r[153] = 0x3ffffff;
  16181. r[154] = 0x3ffffff;
  16182. r[155] = 0x3ffffff;
  16183. r[156] = 0x3ffffff;
  16184. r[157] = 0x3fffL;
  16185. r[158] = 0;
  16186. r[159] = 0;
  16187. r[160] = 0;
  16188. r[161] = 0;
  16189. /* r = (2^n - 1) mod n */
  16190. (void)sp_4096_sub_162(r, r, m);
  16191. /* Add one so r = 2^n mod m */
  16192. r[0] += 1;
  16193. }
  16194. /* Compare a with b in constant time.
  16195. *
  16196. * a A single precision integer.
  16197. * b A single precision integer.
  16198. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  16199. * respectively.
  16200. */
  16201. static sp_digit sp_4096_cmp_162(const sp_digit* a, const sp_digit* b)
  16202. {
  16203. sp_digit r = 0;
  16204. int i;
  16205. r |= (a[161] - b[161]) & (0 - (sp_digit)1);
  16206. r |= (a[160] - b[160]) & ~(((sp_digit)0 - r) >> 25);
  16207. for (i = 152; i >= 0; i -= 8) {
  16208. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 25);
  16209. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 25);
  16210. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 25);
  16211. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 25);
  16212. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 25);
  16213. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 25);
  16214. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 25);
  16215. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 25);
  16216. }
  16217. return r;
  16218. }
  16219. /* Conditionally subtract b from a using the mask m.
  16220. * m is -1 to subtract and 0 when not.
  16221. *
  16222. * r A single precision number representing condition subtract result.
  16223. * a A single precision number to subtract from.
  16224. * b A single precision number to subtract.
  16225. * m Mask value to apply.
  16226. */
  16227. static void sp_4096_cond_sub_162(sp_digit* r, const sp_digit* a,
  16228. const sp_digit* b, const sp_digit m)
  16229. {
  16230. int i;
  16231. for (i = 0; i < 160; i += 8) {
  16232. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  16233. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  16234. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  16235. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  16236. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  16237. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  16238. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  16239. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  16240. }
  16241. r[160] = a[160] - (b[160] & m);
  16242. r[161] = a[161] - (b[161] & m);
  16243. }
  16244. /* Mul a by scalar b and add into r. (r += a * b)
  16245. *
  16246. * r A single precision integer.
  16247. * a A single precision integer.
  16248. * b A scalar.
  16249. */
  16250. SP_NOINLINE static void sp_4096_mul_add_162(sp_digit* r, const sp_digit* a,
  16251. const sp_digit b)
  16252. {
  16253. #ifndef WOLFSSL_SP_LARGE_CODE
  16254. sp_int64 tb = b;
  16255. sp_int64 t = 0;
  16256. int i;
  16257. for (i = 0; i < 162; i++) {
  16258. t += r[i];
  16259. t += tb * a[i];
  16260. r[i] = ((sp_digit)t) & 0x3ffffff;
  16261. t >>= 26;
  16262. }
  16263. r[162] += (sp_digit)t;
  16264. #else
  16265. sp_int64 tb = b;
  16266. sp_int64 t[8];
  16267. int i;
  16268. t[0] = 0;
  16269. for (i = 0; i < 160; i += 8) {
  16270. t[0] += (tb * a[i+0]) + r[i+0];
  16271. t[1] = (tb * a[i+1]) + r[i+1];
  16272. t[2] = (tb * a[i+2]) + r[i+2];
  16273. t[3] = (tb * a[i+3]) + r[i+3];
  16274. t[4] = (tb * a[i+4]) + r[i+4];
  16275. t[5] = (tb * a[i+5]) + r[i+5];
  16276. t[6] = (tb * a[i+6]) + r[i+6];
  16277. t[7] = (tb * a[i+7]) + r[i+7];
  16278. r[i+0] = t[0] & 0x3ffffff;
  16279. t[1] += t[0] >> 26;
  16280. r[i+1] = t[1] & 0x3ffffff;
  16281. t[2] += t[1] >> 26;
  16282. r[i+2] = t[2] & 0x3ffffff;
  16283. t[3] += t[2] >> 26;
  16284. r[i+3] = t[3] & 0x3ffffff;
  16285. t[4] += t[3] >> 26;
  16286. r[i+4] = t[4] & 0x3ffffff;
  16287. t[5] += t[4] >> 26;
  16288. r[i+5] = t[5] & 0x3ffffff;
  16289. t[6] += t[5] >> 26;
  16290. r[i+6] = t[6] & 0x3ffffff;
  16291. t[7] += t[6] >> 26;
  16292. r[i+7] = t[7] & 0x3ffffff;
  16293. t[0] = t[7] >> 26;
  16294. }
  16295. t[0] += (tb * a[160]) + r[160];
  16296. t[1] = (tb * a[161]) + r[161];
  16297. r[160] = t[0] & 0x3ffffff;
  16298. t[1] += t[0] >> 26;
  16299. r[161] = t[1] & 0x3ffffff;
  16300. r[162] += (sp_digit)(t[1] >> 26);
  16301. #endif /* !WOLFSSL_SP_LARGE_CODE */
  16302. }
  16303. /* Shift the result in the high 4096 bits down to the bottom.
  16304. *
  16305. * r A single precision number.
  16306. * a A single precision number.
  16307. */
  16308. static void sp_4096_mont_shift_162(sp_digit* r, const sp_digit* a)
  16309. {
  16310. int i;
  16311. sp_int64 n = a[157] >> 14;
  16312. n += ((sp_int64)a[158]) << 12;
  16313. for (i = 0; i < 152; i += 8) {
  16314. r[i + 0] = n & 0x3ffffff;
  16315. n >>= 26; n += ((sp_int64)a[i + 159]) << 12;
  16316. r[i + 1] = n & 0x3ffffff;
  16317. n >>= 26; n += ((sp_int64)a[i + 160]) << 12;
  16318. r[i + 2] = n & 0x3ffffff;
  16319. n >>= 26; n += ((sp_int64)a[i + 161]) << 12;
  16320. r[i + 3] = n & 0x3ffffff;
  16321. n >>= 26; n += ((sp_int64)a[i + 162]) << 12;
  16322. r[i + 4] = n & 0x3ffffff;
  16323. n >>= 26; n += ((sp_int64)a[i + 163]) << 12;
  16324. r[i + 5] = n & 0x3ffffff;
  16325. n >>= 26; n += ((sp_int64)a[i + 164]) << 12;
  16326. r[i + 6] = n & 0x3ffffff;
  16327. n >>= 26; n += ((sp_int64)a[i + 165]) << 12;
  16328. r[i + 7] = n & 0x3ffffff;
  16329. n >>= 26; n += ((sp_int64)a[i + 166]) << 12;
  16330. }
  16331. r[152] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[311]) << 12;
  16332. r[153] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[312]) << 12;
  16333. r[154] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[313]) << 12;
  16334. r[155] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[314]) << 12;
  16335. r[156] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[315]) << 12;
  16336. r[157] = (sp_digit)n;
  16337. XMEMSET(&r[158], 0, sizeof(*r) * 158U);
  16338. }
  16339. /* Reduce the number back to 4096 bits using Montgomery reduction.
  16340. *
  16341. * a A single precision number to reduce in place.
  16342. * m The single precision number representing the modulus.
  16343. * mp The digit representing the negative inverse of m mod 2^n.
  16344. */
  16345. static void sp_4096_mont_reduce_162(sp_digit* a, const sp_digit* m, sp_digit mp)
  16346. {
  16347. int i;
  16348. sp_digit mu;
  16349. sp_digit over;
  16350. sp_4096_norm_162(a + 158);
  16351. #ifdef WOLFSSL_SP_DH
  16352. if (mp != 1) {
  16353. for (i=0; i<157; i++) {
  16354. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffff;
  16355. sp_4096_mul_add_162(a+i, m, mu);
  16356. a[i+1] += a[i] >> 26;
  16357. }
  16358. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3fffL;
  16359. sp_4096_mul_add_162(a+i, m, mu);
  16360. a[i+1] += a[i] >> 26;
  16361. a[i] &= 0x3ffffff;
  16362. }
  16363. else {
  16364. for (i=0; i<157; i++) {
  16365. mu = a[i] & 0x3ffffff;
  16366. sp_4096_mul_add_162(a+i, m, mu);
  16367. a[i+1] += a[i] >> 26;
  16368. }
  16369. mu = a[i] & 0x3fffL;
  16370. sp_4096_mul_add_162(a+i, m, mu);
  16371. a[i+1] += a[i] >> 26;
  16372. a[i] &= 0x3ffffff;
  16373. }
  16374. #else
  16375. for (i=0; i<157; i++) {
  16376. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffff;
  16377. sp_4096_mul_add_162(a+i, m, mu);
  16378. a[i+1] += a[i] >> 26;
  16379. }
  16380. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3fffL;
  16381. sp_4096_mul_add_162(a+i, m, mu);
  16382. a[i+1] += a[i] >> 26;
  16383. a[i] &= 0x3ffffff;
  16384. #endif
  16385. sp_4096_mont_shift_162(a, a);
  16386. over = a[157] - m[157];
  16387. sp_4096_cond_sub_162(a, a, m, ~((over - 1) >> 31));
  16388. sp_4096_norm_162(a);
  16389. }
  16390. /* Multiply two Montgomery form numbers mod the modulus (prime).
  16391. * (r = a * b mod m)
  16392. *
  16393. * r Result of multiplication.
  16394. * a First number to multiply in Montgomery form.
  16395. * b Second number to multiply in Montgomery form.
  16396. * m Modulus (prime).
  16397. * mp Montgomery multiplier.
  16398. */
  16399. SP_NOINLINE static void sp_4096_mont_mul_162(sp_digit* r, const sp_digit* a,
  16400. const sp_digit* b, const sp_digit* m, sp_digit mp)
  16401. {
  16402. sp_4096_mul_162(r, a, b);
  16403. sp_4096_mont_reduce_162(r, m, mp);
  16404. }
  16405. /* Square the Montgomery form number. (r = a * a mod m)
  16406. *
  16407. * r Result of squaring.
  16408. * a Number to square in Montgomery form.
  16409. * m Modulus (prime).
  16410. * mp Montgomery multiplier.
  16411. */
  16412. SP_NOINLINE static void sp_4096_mont_sqr_162(sp_digit* r, const sp_digit* a,
  16413. const sp_digit* m, sp_digit mp)
  16414. {
  16415. sp_4096_sqr_162(r, a);
  16416. sp_4096_mont_reduce_162(r, m, mp);
  16417. }
  16418. /* Multiply a by scalar b into r. (r = a * b)
  16419. *
  16420. * r A single precision integer.
  16421. * a A single precision integer.
  16422. * b A scalar.
  16423. */
  16424. SP_NOINLINE static void sp_4096_mul_d_324(sp_digit* r, const sp_digit* a,
  16425. sp_digit b)
  16426. {
  16427. sp_int64 tb = b;
  16428. sp_int64 t = 0;
  16429. sp_digit t2;
  16430. sp_int64 p[4];
  16431. int i;
  16432. for (i = 0; i < 324; i += 4) {
  16433. p[0] = tb * a[i + 0];
  16434. p[1] = tb * a[i + 1];
  16435. p[2] = tb * a[i + 2];
  16436. p[3] = tb * a[i + 3];
  16437. t += p[0];
  16438. t2 = (sp_digit)(t & 0x3ffffff);
  16439. t >>= 26;
  16440. r[i + 0] = (sp_digit)t2;
  16441. t += p[1];
  16442. t2 = (sp_digit)(t & 0x3ffffff);
  16443. t >>= 26;
  16444. r[i + 1] = (sp_digit)t2;
  16445. t += p[2];
  16446. t2 = (sp_digit)(t & 0x3ffffff);
  16447. t >>= 26;
  16448. r[i + 2] = (sp_digit)t2;
  16449. t += p[3];
  16450. t2 = (sp_digit)(t & 0x3ffffff);
  16451. t >>= 26;
  16452. r[i + 3] = (sp_digit)t2;
  16453. }
  16454. r[324] = (sp_digit)(t & 0x3ffffff);
  16455. }
  16456. #ifndef WOLFSSL_SP_SMALL
  16457. /* Conditionally add a and b using the mask m.
  16458. * m is -1 to add and 0 when not.
  16459. *
  16460. * r A single precision number representing conditional add result.
  16461. * a A single precision number to add with.
  16462. * b A single precision number to add.
  16463. * m Mask value to apply.
  16464. */
  16465. static void sp_4096_cond_add_162(sp_digit* r, const sp_digit* a,
  16466. const sp_digit* b, const sp_digit m)
  16467. {
  16468. int i;
  16469. for (i = 0; i < 160; i += 8) {
  16470. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  16471. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  16472. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  16473. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  16474. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  16475. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  16476. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  16477. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  16478. }
  16479. r[160] = a[160] + (b[160] & m);
  16480. r[161] = a[161] + (b[161] & m);
  16481. }
  16482. #endif /* !WOLFSSL_SP_SMALL */
  16483. SP_NOINLINE static void sp_4096_rshift_162(sp_digit* r, const sp_digit* a,
  16484. byte n)
  16485. {
  16486. int i;
  16487. for (i=0; i<160; i += 8) {
  16488. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (26 - n)) & 0x3ffffff);
  16489. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (26 - n)) & 0x3ffffff);
  16490. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (26 - n)) & 0x3ffffff);
  16491. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (26 - n)) & 0x3ffffff);
  16492. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (26 - n)) & 0x3ffffff);
  16493. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (26 - n)) & 0x3ffffff);
  16494. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (26 - n)) & 0x3ffffff);
  16495. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (26 - n)) & 0x3ffffff);
  16496. }
  16497. r[160] = (a[160] >> n) | ((a[161] << (26 - n)) & 0x3ffffff);
  16498. r[161] = a[161] >> n;
  16499. }
  16500. static WC_INLINE sp_digit sp_4096_div_word_162(sp_digit d1, sp_digit d0,
  16501. sp_digit div)
  16502. {
  16503. #ifdef SP_USE_DIVTI3
  16504. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  16505. return d / div;
  16506. #elif defined(__x86_64__) || defined(__i386__)
  16507. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  16508. sp_uint32 lo = (sp_uint32)d;
  16509. sp_digit hi = (sp_digit)(d >> 32);
  16510. __asm__ __volatile__ (
  16511. "idiv %2"
  16512. : "+a" (lo)
  16513. : "d" (hi), "r" (div)
  16514. : "cc"
  16515. );
  16516. return (sp_digit)lo;
  16517. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  16518. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  16519. sp_digit dv = (div >> 1) + 1;
  16520. sp_digit t1 = (sp_digit)(d >> 26);
  16521. sp_digit t0 = (sp_digit)(d & 0x3ffffff);
  16522. sp_digit t2;
  16523. sp_digit sign;
  16524. sp_digit r;
  16525. int i;
  16526. sp_int64 m;
  16527. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  16528. t1 -= dv & (0 - r);
  16529. for (i = 24; i >= 1; i--) {
  16530. t1 += t1 + (((sp_uint32)t0 >> 25) & 1);
  16531. t0 <<= 1;
  16532. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  16533. r += r + t2;
  16534. t1 -= dv & (0 - t2);
  16535. t1 += t2;
  16536. }
  16537. r += r + 1;
  16538. m = d - ((sp_int64)r * div);
  16539. r += (sp_digit)(m >> 26);
  16540. m = d - ((sp_int64)r * div);
  16541. r += (sp_digit)(m >> 52) - (sp_digit)(d >> 52);
  16542. m = d - ((sp_int64)r * div);
  16543. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  16544. m *= sign;
  16545. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  16546. r += sign * t2;
  16547. m = d - ((sp_int64)r * div);
  16548. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  16549. m *= sign;
  16550. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  16551. r += sign * t2;
  16552. return r;
  16553. #else
  16554. sp_int64 d = ((sp_int64)d1 << 26) + d0;
  16555. sp_digit r = 0;
  16556. sp_digit t;
  16557. sp_digit dv = (div >> 11) + 1;
  16558. t = (sp_digit)(d >> 22);
  16559. t = (t / dv) << 11;
  16560. r += t;
  16561. d -= (sp_int64)t * div;
  16562. t = (sp_digit)(d >> 7);
  16563. t = t / (dv << 4);
  16564. r += t;
  16565. d -= (sp_int64)t * div;
  16566. t = (sp_digit)d;
  16567. t = t / div;
  16568. r += t;
  16569. d -= (sp_int64)t * div;
  16570. return r;
  16571. #endif
  16572. }
  16573. static WC_INLINE sp_digit sp_4096_word_div_word_162(sp_digit d, sp_digit div)
  16574. {
  16575. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  16576. defined(SP_DIV_WORD_USE_DIV)
  16577. return d / div;
  16578. #else
  16579. return (sp_digit)((sp_uint32)(div - d) >> 31);
  16580. #endif
  16581. }
  16582. /* Divide d in a and put remainder into r (m*d + r = a)
  16583. * m is not calculated as it is not needed at this time.
  16584. *
  16585. * Full implementation.
  16586. *
  16587. * a Number to be divided.
  16588. * d Number to divide with.
  16589. * m Multiplier result.
  16590. * r Remainder from the division.
  16591. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  16592. */
  16593. static int sp_4096_div_162(const sp_digit* a, const sp_digit* d,
  16594. const sp_digit* m, sp_digit* r)
  16595. {
  16596. int i;
  16597. #ifndef WOLFSSL_SP_DIV_32
  16598. #endif
  16599. sp_digit dv;
  16600. sp_digit r1;
  16601. #ifdef WOLFSSL_SP_SMALL_STACK
  16602. sp_digit* t1 = NULL;
  16603. #else
  16604. sp_digit t1[4 * 162 + 3];
  16605. #endif
  16606. sp_digit* t2 = NULL;
  16607. sp_digit* sd = NULL;
  16608. int err = MP_OKAY;
  16609. (void)m;
  16610. #ifdef WOLFSSL_SP_SMALL_STACK
  16611. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 162 + 3), NULL,
  16612. DYNAMIC_TYPE_TMP_BUFFER);
  16613. if (t1 == NULL)
  16614. err = MEMORY_E;
  16615. #endif
  16616. (void)m;
  16617. if (err == MP_OKAY) {
  16618. t2 = t1 + 324 + 1;
  16619. sd = t2 + 162 + 1;
  16620. sp_4096_mul_d_162(sd, d, (sp_digit)1 << 12);
  16621. sp_4096_mul_d_324(t1, a, (sp_digit)1 << 12);
  16622. dv = sd[157];
  16623. t1[158 + 158] += t1[158 + 158 - 1] >> 26;
  16624. t1[158 + 158 - 1] &= 0x3ffffff;
  16625. for (i=158; i>=0; i--) {
  16626. r1 = sp_4096_div_word_162(t1[158 + i], t1[158 + i - 1], dv);
  16627. sp_4096_mul_d_162(t2, sd, r1);
  16628. (void)sp_4096_sub_162(&t1[i], &t1[i], t2);
  16629. sp_4096_norm_158(&t1[i]);
  16630. t1[158 + i] += t1[158 + i - 1] >> 26;
  16631. t1[158 + i - 1] &= 0x3ffffff;
  16632. r1 = sp_4096_div_word_162(-t1[158 + i], -t1[158 + i - 1], dv);
  16633. r1 -= t1[158 + i];
  16634. sp_4096_mul_d_162(t2, sd, r1);
  16635. (void)sp_4096_add_162(&t1[i], &t1[i], t2);
  16636. t1[158 + i] += t1[158 + i - 1] >> 26;
  16637. t1[158 + i - 1] &= 0x3ffffff;
  16638. }
  16639. t1[158 - 1] += t1[158 - 2] >> 26;
  16640. t1[158 - 2] &= 0x3ffffff;
  16641. r1 = sp_4096_word_div_word_162(t1[158 - 1], dv);
  16642. sp_4096_mul_d_162(t2, sd, r1);
  16643. sp_4096_sub_162(t1, t1, t2);
  16644. XMEMCPY(r, t1, sizeof(*r) * 324U);
  16645. for (i=0; i<157; i++) {
  16646. r[i+1] += r[i] >> 26;
  16647. r[i] &= 0x3ffffff;
  16648. }
  16649. sp_4096_cond_add_162(r, r, sd, r[157] >> 31);
  16650. sp_4096_norm_158(r);
  16651. sp_4096_rshift_162(r, r, 12);
  16652. r[158] = 0;
  16653. r[159] = 0;
  16654. r[160] = 0;
  16655. r[161] = 0;
  16656. }
  16657. #ifdef WOLFSSL_SP_SMALL_STACK
  16658. if (t1 != NULL)
  16659. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16660. #endif
  16661. return err;
  16662. }
  16663. /* Reduce a modulo m into r. (r = a mod m)
  16664. *
  16665. * r A single precision number that is the reduced result.
  16666. * a A single precision number that is to be reduced.
  16667. * m A single precision number that is the modulus to reduce with.
  16668. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  16669. */
  16670. static int sp_4096_mod_162(sp_digit* r, const sp_digit* a, const sp_digit* m)
  16671. {
  16672. return sp_4096_div_162(a, m, NULL, r);
  16673. }
  16674. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || defined(WOLFSSL_HAVE_SP_DH)
  16675. #if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
  16676. defined(WOLFSSL_HAVE_SP_DH)
  16677. /* Modular exponentiate a to the e mod m. (r = a^e mod m)
  16678. *
  16679. * r A single precision number that is the result of the operation.
  16680. * a A single precision number being exponentiated.
  16681. * e A single precision number that is the exponent.
  16682. * bits The number of bits in the exponent.
  16683. * m A single precision number that is the modulus.
  16684. * returns 0 on success.
  16685. * returns MEMORY_E on dynamic memory allocation failure.
  16686. * returns MP_VAL when base is even or exponent is 0.
  16687. */
  16688. static int sp_4096_mod_exp_162(sp_digit* r, const sp_digit* a, const sp_digit* e,
  16689. int bits, const sp_digit* m, int reduceA)
  16690. {
  16691. #if defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_FAST_MODEXP)
  16692. #ifdef WOLFSSL_SP_SMALL_STACK
  16693. sp_digit* td = NULL;
  16694. #else
  16695. sp_digit td[3 * 324];
  16696. #endif
  16697. sp_digit* t[3] = {0, 0, 0};
  16698. sp_digit* norm = NULL;
  16699. sp_digit mp = 1;
  16700. sp_digit n;
  16701. int i;
  16702. int c;
  16703. byte y;
  16704. int err = MP_OKAY;
  16705. if (bits == 0) {
  16706. err = MP_VAL;
  16707. }
  16708. #ifdef WOLFSSL_SP_SMALL_STACK
  16709. if (err == MP_OKAY) {
  16710. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 162 * 2, NULL,
  16711. DYNAMIC_TYPE_TMP_BUFFER);
  16712. if (td == NULL)
  16713. err = MEMORY_E;
  16714. }
  16715. #endif
  16716. if (err == MP_OKAY) {
  16717. norm = td;
  16718. for (i=0; i<3; i++) {
  16719. t[i] = td + (i * 162 * 2);
  16720. XMEMSET(t[i], 0, sizeof(sp_digit) * 162U * 2U);
  16721. }
  16722. sp_4096_mont_setup(m, &mp);
  16723. sp_4096_mont_norm_162(norm, m);
  16724. if (reduceA != 0) {
  16725. err = sp_4096_mod_162(t[1], a, m);
  16726. }
  16727. else {
  16728. XMEMCPY(t[1], a, sizeof(sp_digit) * 162U);
  16729. }
  16730. }
  16731. if (err == MP_OKAY) {
  16732. sp_4096_mul_162(t[1], t[1], norm);
  16733. err = sp_4096_mod_162(t[1], t[1], m);
  16734. }
  16735. if (err == MP_OKAY) {
  16736. i = bits / 26;
  16737. c = bits % 26;
  16738. n = e[i--] << (26 - c);
  16739. for (; ; c--) {
  16740. if (c == 0) {
  16741. if (i == -1) {
  16742. break;
  16743. }
  16744. n = e[i--];
  16745. c = 26;
  16746. }
  16747. y = (int)((n >> 25) & 1);
  16748. n <<= 1;
  16749. sp_4096_mont_mul_162(t[y^1], t[0], t[1], m, mp);
  16750. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  16751. ((size_t)t[1] & addr_mask[y])),
  16752. sizeof(*t[2]) * 162 * 2);
  16753. sp_4096_mont_sqr_162(t[2], t[2], m, mp);
  16754. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  16755. ((size_t)t[1] & addr_mask[y])), t[2],
  16756. sizeof(*t[2]) * 162 * 2);
  16757. }
  16758. sp_4096_mont_reduce_162(t[0], m, mp);
  16759. n = sp_4096_cmp_162(t[0], m);
  16760. sp_4096_cond_sub_162(t[0], t[0], m, ~(n >> 31));
  16761. XMEMCPY(r, t[0], sizeof(*r) * 162 * 2);
  16762. }
  16763. #ifdef WOLFSSL_SP_SMALL_STACK
  16764. if (td != NULL)
  16765. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16766. #endif
  16767. return err;
  16768. #elif !defined(WC_NO_CACHE_RESISTANT)
  16769. #ifdef WOLFSSL_SP_SMALL_STACK
  16770. sp_digit* td = NULL;
  16771. #else
  16772. sp_digit td[3 * 324];
  16773. #endif
  16774. sp_digit* t[3] = {0, 0, 0};
  16775. sp_digit* norm = NULL;
  16776. sp_digit mp = 1;
  16777. sp_digit n;
  16778. int i;
  16779. int c;
  16780. byte y;
  16781. int err = MP_OKAY;
  16782. if (bits == 0) {
  16783. err = MP_VAL;
  16784. }
  16785. #ifdef WOLFSSL_SP_SMALL_STACK
  16786. if (err == MP_OKAY) {
  16787. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 3 * 162 * 2, NULL,
  16788. DYNAMIC_TYPE_TMP_BUFFER);
  16789. if (td == NULL)
  16790. err = MEMORY_E;
  16791. }
  16792. #endif
  16793. if (err == MP_OKAY) {
  16794. norm = td;
  16795. for (i=0; i<3; i++) {
  16796. t[i] = td + (i * 162 * 2);
  16797. }
  16798. sp_4096_mont_setup(m, &mp);
  16799. sp_4096_mont_norm_162(norm, m);
  16800. if (reduceA != 0) {
  16801. err = sp_4096_mod_162(t[1], a, m);
  16802. if (err == MP_OKAY) {
  16803. sp_4096_mul_162(t[1], t[1], norm);
  16804. err = sp_4096_mod_162(t[1], t[1], m);
  16805. }
  16806. }
  16807. else {
  16808. sp_4096_mul_162(t[1], a, norm);
  16809. err = sp_4096_mod_162(t[1], t[1], m);
  16810. }
  16811. }
  16812. if (err == MP_OKAY) {
  16813. i = bits / 26;
  16814. c = bits % 26;
  16815. n = e[i--] << (26 - c);
  16816. for (; ; c--) {
  16817. if (c == 0) {
  16818. if (i == -1) {
  16819. break;
  16820. }
  16821. n = e[i--];
  16822. c = 26;
  16823. }
  16824. y = (int)((n >> 25) & 1);
  16825. n <<= 1;
  16826. sp_4096_mont_mul_162(t[y^1], t[0], t[1], m, mp);
  16827. XMEMCPY(t[2], (void*)(((size_t)t[0] & addr_mask[y^1]) +
  16828. ((size_t)t[1] & addr_mask[y])),
  16829. sizeof(*t[2]) * 162 * 2);
  16830. sp_4096_mont_sqr_162(t[2], t[2], m, mp);
  16831. XMEMCPY((void*)(((size_t)t[0] & addr_mask[y^1]) +
  16832. ((size_t)t[1] & addr_mask[y])), t[2],
  16833. sizeof(*t[2]) * 162 * 2);
  16834. }
  16835. sp_4096_mont_reduce_162(t[0], m, mp);
  16836. n = sp_4096_cmp_162(t[0], m);
  16837. sp_4096_cond_sub_162(t[0], t[0], m, ~(n >> 31));
  16838. XMEMCPY(r, t[0], sizeof(*r) * 162 * 2);
  16839. }
  16840. #ifdef WOLFSSL_SP_SMALL_STACK
  16841. if (td != NULL)
  16842. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16843. #endif
  16844. return err;
  16845. #else
  16846. #ifdef WOLFSSL_SP_SMALL_STACK
  16847. sp_digit* td = NULL;
  16848. #else
  16849. sp_digit td[(16 * 324) + 324];
  16850. #endif
  16851. sp_digit* t[16];
  16852. sp_digit* rt = NULL;
  16853. sp_digit* norm = NULL;
  16854. sp_digit mp = 1;
  16855. sp_digit n;
  16856. int i;
  16857. int c;
  16858. byte y;
  16859. int err = MP_OKAY;
  16860. if (bits == 0) {
  16861. err = MP_VAL;
  16862. }
  16863. #ifdef WOLFSSL_SP_SMALL_STACK
  16864. if (err == MP_OKAY) {
  16865. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * ((16 * 324) + 324), NULL,
  16866. DYNAMIC_TYPE_TMP_BUFFER);
  16867. if (td == NULL)
  16868. err = MEMORY_E;
  16869. }
  16870. #endif
  16871. if (err == MP_OKAY) {
  16872. norm = td;
  16873. for (i=0; i<16; i++)
  16874. t[i] = td + i * 324;
  16875. rt = td + 5184;
  16876. sp_4096_mont_setup(m, &mp);
  16877. sp_4096_mont_norm_162(norm, m);
  16878. if (reduceA != 0) {
  16879. err = sp_4096_mod_162(t[1], a, m);
  16880. if (err == MP_OKAY) {
  16881. sp_4096_mul_162(t[1], t[1], norm);
  16882. err = sp_4096_mod_162(t[1], t[1], m);
  16883. }
  16884. }
  16885. else {
  16886. sp_4096_mul_162(t[1], a, norm);
  16887. err = sp_4096_mod_162(t[1], t[1], m);
  16888. }
  16889. }
  16890. if (err == MP_OKAY) {
  16891. sp_4096_mont_sqr_162(t[ 2], t[ 1], m, mp);
  16892. sp_4096_mont_mul_162(t[ 3], t[ 2], t[ 1], m, mp);
  16893. sp_4096_mont_sqr_162(t[ 4], t[ 2], m, mp);
  16894. sp_4096_mont_mul_162(t[ 5], t[ 3], t[ 2], m, mp);
  16895. sp_4096_mont_sqr_162(t[ 6], t[ 3], m, mp);
  16896. sp_4096_mont_mul_162(t[ 7], t[ 4], t[ 3], m, mp);
  16897. sp_4096_mont_sqr_162(t[ 8], t[ 4], m, mp);
  16898. sp_4096_mont_mul_162(t[ 9], t[ 5], t[ 4], m, mp);
  16899. sp_4096_mont_sqr_162(t[10], t[ 5], m, mp);
  16900. sp_4096_mont_mul_162(t[11], t[ 6], t[ 5], m, mp);
  16901. sp_4096_mont_sqr_162(t[12], t[ 6], m, mp);
  16902. sp_4096_mont_mul_162(t[13], t[ 7], t[ 6], m, mp);
  16903. sp_4096_mont_sqr_162(t[14], t[ 7], m, mp);
  16904. sp_4096_mont_mul_162(t[15], t[ 8], t[ 7], m, mp);
  16905. bits = ((bits + 3) / 4) * 4;
  16906. i = ((bits + 25) / 26) - 1;
  16907. c = bits % 26;
  16908. if (c == 0) {
  16909. c = 26;
  16910. }
  16911. if (i < 162) {
  16912. n = e[i--] << (32 - c);
  16913. }
  16914. else {
  16915. n = 0;
  16916. i--;
  16917. }
  16918. if (c < 4) {
  16919. n |= e[i--] << (6 - c);
  16920. c += 26;
  16921. }
  16922. y = (int)((n >> 28) & 0xf);
  16923. n <<= 4;
  16924. c -= 4;
  16925. XMEMCPY(rt, t[y], sizeof(sp_digit) * 324);
  16926. while ((i >= 0) || (c >= 4)) {
  16927. if (c >= 4) {
  16928. y = (byte)((n >> 28) & 0xf);
  16929. n <<= 4;
  16930. c -= 4;
  16931. }
  16932. else if (c == 0) {
  16933. n = e[i--] << 6;
  16934. y = (byte)((n >> 28) & 0xf);
  16935. n <<= 4;
  16936. c = 22;
  16937. }
  16938. else {
  16939. y = (byte)((n >> 28) & 0xf);
  16940. n = e[i--] << 6;
  16941. c = 4 - c;
  16942. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  16943. n <<= c;
  16944. c = 26 - c;
  16945. }
  16946. sp_4096_mont_sqr_162(rt, rt, m, mp);
  16947. sp_4096_mont_sqr_162(rt, rt, m, mp);
  16948. sp_4096_mont_sqr_162(rt, rt, m, mp);
  16949. sp_4096_mont_sqr_162(rt, rt, m, mp);
  16950. sp_4096_mont_mul_162(rt, rt, t[y], m, mp);
  16951. }
  16952. sp_4096_mont_reduce_162(rt, m, mp);
  16953. n = sp_4096_cmp_162(rt, m);
  16954. sp_4096_cond_sub_162(rt, rt, m, ~(n >> 31));
  16955. XMEMCPY(r, rt, sizeof(sp_digit) * 324);
  16956. }
  16957. #ifdef WOLFSSL_SP_SMALL_STACK
  16958. if (td != NULL)
  16959. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  16960. #endif
  16961. return err;
  16962. #endif
  16963. }
  16964. #endif /* (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) || */
  16965. /* WOLFSSL_HAVE_SP_DH */
  16966. #endif /* (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
  16967. #ifdef WOLFSSL_HAVE_SP_RSA
  16968. /* RSA public key operation.
  16969. *
  16970. * in Array of bytes representing the number to exponentiate, base.
  16971. * inLen Number of bytes in base.
  16972. * em Public exponent.
  16973. * mm Modulus.
  16974. * out Buffer to hold big-endian bytes of exponentiation result.
  16975. * Must be at least 512 bytes long.
  16976. * outLen Number of bytes in result.
  16977. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  16978. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  16979. */
  16980. int sp_RsaPublic_4096(const byte* in, word32 inLen, const mp_int* em,
  16981. const mp_int* mm, byte* out, word32* outLen)
  16982. {
  16983. #ifdef WOLFSSL_SP_SMALL
  16984. #ifdef WOLFSSL_SP_SMALL_STACK
  16985. sp_digit* a = NULL;
  16986. #else
  16987. sp_digit a[162 * 5];
  16988. #endif
  16989. sp_digit* m = NULL;
  16990. sp_digit* r = NULL;
  16991. sp_digit* norm = NULL;
  16992. sp_uint64 e[1] = {0};
  16993. sp_digit mp = 0;
  16994. int i;
  16995. int err = MP_OKAY;
  16996. if (*outLen < 512U) {
  16997. err = MP_TO_E;
  16998. }
  16999. if (err == MP_OKAY) {
  17000. if (mp_count_bits(em) > 64) {
  17001. err = MP_READ_E;
  17002. }
  17003. else if (inLen > 512U) {
  17004. err = MP_READ_E;
  17005. }
  17006. else if (mp_count_bits(mm) != 4096) {
  17007. err = MP_READ_E;
  17008. }
  17009. else if (mp_iseven(mm)) {
  17010. err = MP_VAL;
  17011. }
  17012. }
  17013. #ifdef WOLFSSL_SP_SMALL_STACK
  17014. if (err == MP_OKAY) {
  17015. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 5, NULL,
  17016. DYNAMIC_TYPE_RSA);
  17017. if (a == NULL)
  17018. err = MEMORY_E;
  17019. }
  17020. #endif
  17021. if (err == MP_OKAY) {
  17022. r = a + 162 * 2;
  17023. m = r + 162 * 2;
  17024. norm = r;
  17025. sp_4096_from_bin(a, 162, in, inLen);
  17026. #if DIGIT_BIT >= 64
  17027. e[0] = (sp_uint64)em->dp[0];
  17028. #else
  17029. e[0] = (sp_uint64)em->dp[0];
  17030. if (em->used > 1) {
  17031. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  17032. }
  17033. #endif
  17034. if (e[0] == 0) {
  17035. err = MP_EXPTMOD_E;
  17036. }
  17037. }
  17038. if (err == MP_OKAY) {
  17039. sp_4096_from_mp(m, 162, mm);
  17040. sp_4096_mont_setup(m, &mp);
  17041. sp_4096_mont_norm_162(norm, m);
  17042. }
  17043. if (err == MP_OKAY) {
  17044. sp_4096_mul_162(a, a, norm);
  17045. err = sp_4096_mod_162(a, a, m);
  17046. }
  17047. if (err == MP_OKAY) {
  17048. for (i=63; i>=0; i--) {
  17049. if ((e[0] >> i) != 0) {
  17050. break;
  17051. }
  17052. }
  17053. XMEMCPY(r, a, sizeof(sp_digit) * 162 * 2);
  17054. for (i--; i>=0; i--) {
  17055. sp_4096_mont_sqr_162(r, r, m, mp);
  17056. if (((e[0] >> i) & 1) == 1) {
  17057. sp_4096_mont_mul_162(r, r, a, m, mp);
  17058. }
  17059. }
  17060. sp_4096_mont_reduce_162(r, m, mp);
  17061. mp = sp_4096_cmp_162(r, m);
  17062. sp_4096_cond_sub_162(r, r, m, ~(mp >> 31));
  17063. sp_4096_to_bin_162(r, out);
  17064. *outLen = 512;
  17065. }
  17066. #ifdef WOLFSSL_SP_SMALL_STACK
  17067. if (a != NULL)
  17068. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  17069. #endif
  17070. return err;
  17071. #else
  17072. #ifdef WOLFSSL_SP_SMALL_STACK
  17073. sp_digit* d = NULL;
  17074. #else
  17075. sp_digit d[162 * 5];
  17076. #endif
  17077. sp_digit* a = NULL;
  17078. sp_digit* m = NULL;
  17079. sp_digit* r = NULL;
  17080. sp_uint64 e[1] = {0};
  17081. int err = MP_OKAY;
  17082. if (*outLen < 512U) {
  17083. err = MP_TO_E;
  17084. }
  17085. if (err == MP_OKAY) {
  17086. if (mp_count_bits(em) > 64) {
  17087. err = MP_READ_E;
  17088. }
  17089. else if (inLen > 512U) {
  17090. err = MP_READ_E;
  17091. }
  17092. else if (mp_count_bits(mm) != 4096) {
  17093. err = MP_READ_E;
  17094. }
  17095. else if (mp_iseven(mm)) {
  17096. err = MP_VAL;
  17097. }
  17098. }
  17099. #ifdef WOLFSSL_SP_SMALL_STACK
  17100. if (err == MP_OKAY) {
  17101. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 5, NULL,
  17102. DYNAMIC_TYPE_RSA);
  17103. if (d == NULL)
  17104. err = MEMORY_E;
  17105. }
  17106. #endif
  17107. if (err == MP_OKAY) {
  17108. a = d;
  17109. r = a + 162 * 2;
  17110. m = r + 162 * 2;
  17111. sp_4096_from_bin(a, 162, in, inLen);
  17112. #if DIGIT_BIT >= 64
  17113. e[0] = (sp_uint64)em->dp[0];
  17114. #else
  17115. e[0] = (sp_uint64)em->dp[0];
  17116. if (em->used > 1) {
  17117. e[0] |= ((sp_uint64)em->dp[1]) << DIGIT_BIT;
  17118. }
  17119. #endif
  17120. if (e[0] == 0) {
  17121. err = MP_EXPTMOD_E;
  17122. }
  17123. }
  17124. if (err == MP_OKAY) {
  17125. sp_4096_from_mp(m, 162, mm);
  17126. if (e[0] == 0x3) {
  17127. sp_4096_sqr_162(r, a);
  17128. err = sp_4096_mod_162(r, r, m);
  17129. if (err == MP_OKAY) {
  17130. sp_4096_mul_162(r, a, r);
  17131. err = sp_4096_mod_162(r, r, m);
  17132. }
  17133. }
  17134. else {
  17135. sp_digit* norm = r;
  17136. int i;
  17137. sp_digit mp;
  17138. sp_4096_mont_setup(m, &mp);
  17139. sp_4096_mont_norm_162(norm, m);
  17140. sp_4096_mul_162(a, a, norm);
  17141. err = sp_4096_mod_162(a, a, m);
  17142. if (err == MP_OKAY) {
  17143. for (i=63; i>=0; i--) {
  17144. if ((e[0] >> i) != 0) {
  17145. break;
  17146. }
  17147. }
  17148. XMEMCPY(r, a, sizeof(sp_digit) * 324U);
  17149. for (i--; i>=0; i--) {
  17150. sp_4096_mont_sqr_162(r, r, m, mp);
  17151. if (((e[0] >> i) & 1) == 1) {
  17152. sp_4096_mont_mul_162(r, r, a, m, mp);
  17153. }
  17154. }
  17155. sp_4096_mont_reduce_162(r, m, mp);
  17156. mp = sp_4096_cmp_162(r, m);
  17157. sp_4096_cond_sub_162(r, r, m, ~(mp >> 31));
  17158. }
  17159. }
  17160. }
  17161. if (err == MP_OKAY) {
  17162. sp_4096_to_bin_162(r, out);
  17163. *outLen = 512;
  17164. }
  17165. #ifdef WOLFSSL_SP_SMALL_STACK
  17166. if (d != NULL)
  17167. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  17168. #endif
  17169. return err;
  17170. #endif /* WOLFSSL_SP_SMALL */
  17171. }
  17172. #ifndef WOLFSSL_RSA_PUBLIC_ONLY
  17173. #if !defined(SP_RSA_PRIVATE_EXP_D) && !defined(RSA_LOW_MEM)
  17174. #endif /* !SP_RSA_PRIVATE_EXP_D & !RSA_LOW_MEM */
  17175. /* RSA private key operation.
  17176. *
  17177. * in Array of bytes representing the number to exponentiate, base.
  17178. * inLen Number of bytes in base.
  17179. * dm Private exponent.
  17180. * pm First prime.
  17181. * qm Second prime.
  17182. * dpm First prime's CRT exponent.
  17183. * dqm Second prime's CRT exponent.
  17184. * qim Inverse of second prime mod p.
  17185. * mm Modulus.
  17186. * out Buffer to hold big-endian bytes of exponentiation result.
  17187. * Must be at least 512 bytes long.
  17188. * outLen Number of bytes in result.
  17189. * returns 0 on success, MP_TO_E when the outLen is too small, MP_READ_E when
  17190. * an array is too long and MEMORY_E when dynamic memory allocation fails.
  17191. */
  17192. int sp_RsaPrivate_4096(const byte* in, word32 inLen, const mp_int* dm,
  17193. const mp_int* pm, const mp_int* qm, const mp_int* dpm, const mp_int* dqm,
  17194. const mp_int* qim, const mp_int* mm, byte* out, word32* outLen)
  17195. {
  17196. #if defined(SP_RSA_PRIVATE_EXP_D) || defined(RSA_LOW_MEM)
  17197. #if defined(WOLFSSL_SP_SMALL)
  17198. #ifdef WOLFSSL_SP_SMALL_STACK
  17199. sp_digit* d = NULL;
  17200. #else
  17201. sp_digit d[162 * 4];
  17202. #endif
  17203. sp_digit* a = NULL;
  17204. sp_digit* m = NULL;
  17205. sp_digit* r = NULL;
  17206. int err = MP_OKAY;
  17207. (void)pm;
  17208. (void)qm;
  17209. (void)dpm;
  17210. (void)dqm;
  17211. (void)qim;
  17212. if (*outLen < 512U) {
  17213. err = MP_TO_E;
  17214. }
  17215. if (err == MP_OKAY) {
  17216. if (mp_count_bits(dm) > 4096) {
  17217. err = MP_READ_E;
  17218. }
  17219. else if (inLen > 512) {
  17220. err = MP_READ_E;
  17221. }
  17222. else if (mp_count_bits(mm) != 4096) {
  17223. err = MP_READ_E;
  17224. }
  17225. else if (mp_iseven(mm)) {
  17226. err = MP_VAL;
  17227. }
  17228. }
  17229. #ifdef WOLFSSL_SP_SMALL_STACK
  17230. if (err == MP_OKAY) {
  17231. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 4, NULL,
  17232. DYNAMIC_TYPE_RSA);
  17233. if (d == NULL)
  17234. err = MEMORY_E;
  17235. }
  17236. #endif
  17237. if (err == MP_OKAY) {
  17238. a = d + 162;
  17239. m = a + 324;
  17240. r = a;
  17241. sp_4096_from_bin(a, 162, in, inLen);
  17242. sp_4096_from_mp(d, 162, dm);
  17243. sp_4096_from_mp(m, 162, mm);
  17244. err = sp_4096_mod_exp_162(r, a, d, 4096, m, 0);
  17245. }
  17246. if (err == MP_OKAY) {
  17247. sp_4096_to_bin_162(r, out);
  17248. *outLen = 512;
  17249. }
  17250. #ifdef WOLFSSL_SP_SMALL_STACK
  17251. if (d != NULL)
  17252. #endif
  17253. {
  17254. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  17255. if (a != NULL)
  17256. ForceZero(a, sizeof(sp_digit) * 162);
  17257. #ifdef WOLFSSL_SP_SMALL_STACK
  17258. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  17259. #endif
  17260. }
  17261. return err;
  17262. #else
  17263. #ifdef WOLFSSL_SP_SMALL_STACK
  17264. sp_digit* d = NULL;
  17265. #else
  17266. sp_digit d[162 * 4];
  17267. #endif
  17268. sp_digit* a = NULL;
  17269. sp_digit* m = NULL;
  17270. sp_digit* r = NULL;
  17271. int err = MP_OKAY;
  17272. (void)pm;
  17273. (void)qm;
  17274. (void)dpm;
  17275. (void)dqm;
  17276. (void)qim;
  17277. if (*outLen < 512U) {
  17278. err = MP_TO_E;
  17279. }
  17280. if (err == MP_OKAY) {
  17281. if (mp_count_bits(dm) > 4096) {
  17282. err = MP_READ_E;
  17283. }
  17284. else if (inLen > 512U) {
  17285. err = MP_READ_E;
  17286. }
  17287. else if (mp_count_bits(mm) != 4096) {
  17288. err = MP_READ_E;
  17289. }
  17290. else if (mp_iseven(mm)) {
  17291. err = MP_VAL;
  17292. }
  17293. }
  17294. #ifdef WOLFSSL_SP_SMALL_STACK
  17295. if (err == MP_OKAY) {
  17296. d = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 4, NULL,
  17297. DYNAMIC_TYPE_RSA);
  17298. if (d == NULL)
  17299. err = MEMORY_E;
  17300. }
  17301. #endif
  17302. if (err == MP_OKAY) {
  17303. a = d + 162;
  17304. m = a + 324;
  17305. r = a;
  17306. sp_4096_from_bin(a, 162, in, inLen);
  17307. sp_4096_from_mp(d, 162, dm);
  17308. sp_4096_from_mp(m, 162, mm);
  17309. err = sp_4096_mod_exp_162(r, a, d, 4096, m, 0);
  17310. }
  17311. if (err == MP_OKAY) {
  17312. sp_4096_to_bin_162(r, out);
  17313. *outLen = 512;
  17314. }
  17315. #ifdef WOLFSSL_SP_SMALL_STACK
  17316. if (d != NULL)
  17317. #endif
  17318. {
  17319. /* only "a" and "r" are sensitive and need zeroized (same pointer) */
  17320. if (a != NULL)
  17321. ForceZero(a, sizeof(sp_digit) * 162);
  17322. #ifdef WOLFSSL_SP_SMALL_STACK
  17323. XFREE(d, NULL, DYNAMIC_TYPE_RSA);
  17324. #endif
  17325. }
  17326. return err;
  17327. #endif /* WOLFSSL_SP_SMALL */
  17328. #else
  17329. #if defined(WOLFSSL_SP_SMALL)
  17330. #ifdef WOLFSSL_SP_SMALL_STACK
  17331. sp_digit* a = NULL;
  17332. #else
  17333. sp_digit a[81 * 8];
  17334. #endif
  17335. sp_digit* p = NULL;
  17336. sp_digit* dp = NULL;
  17337. sp_digit* dq = NULL;
  17338. sp_digit* qi = NULL;
  17339. sp_digit* tmpa = NULL;
  17340. sp_digit* tmpb = NULL;
  17341. sp_digit* r = NULL;
  17342. int err = MP_OKAY;
  17343. (void)dm;
  17344. (void)mm;
  17345. if (*outLen < 512U) {
  17346. err = MP_TO_E;
  17347. }
  17348. if (err == MP_OKAY) {
  17349. if (inLen > 512) {
  17350. err = MP_READ_E;
  17351. }
  17352. else if (mp_count_bits(mm) != 4096) {
  17353. err = MP_READ_E;
  17354. }
  17355. else if (mp_iseven(mm)) {
  17356. err = MP_VAL;
  17357. }
  17358. else if (mp_iseven(pm)) {
  17359. err = MP_VAL;
  17360. }
  17361. else if (mp_iseven(qm)) {
  17362. err = MP_VAL;
  17363. }
  17364. }
  17365. #ifdef WOLFSSL_SP_SMALL_STACK
  17366. if (err == MP_OKAY) {
  17367. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 81 * 8, NULL,
  17368. DYNAMIC_TYPE_RSA);
  17369. if (a == NULL)
  17370. err = MEMORY_E;
  17371. }
  17372. #endif
  17373. if (err == MP_OKAY) {
  17374. p = a + 162;
  17375. qi = dq = dp = p + 81;
  17376. tmpa = qi + 81;
  17377. tmpb = tmpa + 162;
  17378. r = a;
  17379. sp_4096_from_bin(a, 162, in, inLen);
  17380. sp_4096_from_mp(p, 81, pm);
  17381. sp_4096_from_mp(dp, 81, dpm);
  17382. err = sp_4096_mod_exp_81(tmpa, a, dp, 2048, p, 1);
  17383. }
  17384. if (err == MP_OKAY) {
  17385. sp_4096_from_mp(p, 81, qm);
  17386. sp_4096_from_mp(dq, 81, dqm);
  17387. err = sp_4096_mod_exp_81(tmpb, a, dq, 2048, p, 1);
  17388. }
  17389. if (err == MP_OKAY) {
  17390. sp_4096_from_mp(p, 81, pm);
  17391. (void)sp_4096_sub_81(tmpa, tmpa, tmpb);
  17392. sp_4096_norm_79(tmpa);
  17393. sp_4096_cond_add_81(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[78] >> 31));
  17394. sp_4096_cond_add_81(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[78] >> 31));
  17395. sp_4096_norm_81(tmpa);
  17396. sp_4096_from_mp(qi, 81, qim);
  17397. sp_4096_mul_81(tmpa, tmpa, qi);
  17398. err = sp_4096_mod_81(tmpa, tmpa, p);
  17399. }
  17400. if (err == MP_OKAY) {
  17401. sp_4096_from_mp(p, 81, qm);
  17402. sp_4096_mul_81(tmpa, p, tmpa);
  17403. (void)sp_4096_add_162(r, tmpb, tmpa);
  17404. sp_4096_norm_162(r);
  17405. sp_4096_to_bin_162(r, out);
  17406. *outLen = 512;
  17407. }
  17408. #ifdef WOLFSSL_SP_SMALL_STACK
  17409. if (a != NULL)
  17410. #endif
  17411. {
  17412. ForceZero(a, sizeof(sp_digit) * 81 * 8);
  17413. #ifdef WOLFSSL_SP_SMALL_STACK
  17414. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  17415. #endif
  17416. }
  17417. return err;
  17418. #else
  17419. #ifdef WOLFSSL_SP_SMALL_STACK
  17420. sp_digit* a = NULL;
  17421. #else
  17422. sp_digit a[81 * 13];
  17423. #endif
  17424. sp_digit* p = NULL;
  17425. sp_digit* q = NULL;
  17426. sp_digit* dp = NULL;
  17427. sp_digit* dq = NULL;
  17428. sp_digit* qi = NULL;
  17429. sp_digit* tmpa = NULL;
  17430. sp_digit* tmpb = NULL;
  17431. sp_digit* r = NULL;
  17432. int err = MP_OKAY;
  17433. (void)dm;
  17434. (void)mm;
  17435. if (*outLen < 512U) {
  17436. err = MP_TO_E;
  17437. }
  17438. if (err == MP_OKAY) {
  17439. if (inLen > 512U) {
  17440. err = MP_READ_E;
  17441. }
  17442. else if (mp_count_bits(mm) != 4096) {
  17443. err = MP_READ_E;
  17444. }
  17445. else if (mp_iseven(mm)) {
  17446. err = MP_VAL;
  17447. }
  17448. else if (mp_iseven(pm)) {
  17449. err = MP_VAL;
  17450. }
  17451. else if (mp_iseven(qm)) {
  17452. err = MP_VAL;
  17453. }
  17454. }
  17455. #ifdef WOLFSSL_SP_SMALL_STACK
  17456. if (err == MP_OKAY) {
  17457. a = (sp_digit*)XMALLOC(sizeof(sp_digit) * 81 * 13, NULL,
  17458. DYNAMIC_TYPE_RSA);
  17459. if (a == NULL)
  17460. err = MEMORY_E;
  17461. }
  17462. #endif
  17463. if (err == MP_OKAY) {
  17464. p = a + 162 * 2;
  17465. q = p + 81;
  17466. dp = q + 81;
  17467. dq = dp + 81;
  17468. qi = dq + 81;
  17469. tmpa = qi + 81;
  17470. tmpb = tmpa + 162;
  17471. r = a;
  17472. sp_4096_from_bin(a, 162, in, inLen);
  17473. sp_4096_from_mp(p, 81, pm);
  17474. sp_4096_from_mp(q, 81, qm);
  17475. sp_4096_from_mp(dp, 81, dpm);
  17476. sp_4096_from_mp(dq, 81, dqm);
  17477. sp_4096_from_mp(qi, 81, qim);
  17478. err = sp_4096_mod_exp_81(tmpa, a, dp, 2048, p, 1);
  17479. }
  17480. if (err == MP_OKAY) {
  17481. err = sp_4096_mod_exp_81(tmpb, a, dq, 2048, q, 1);
  17482. }
  17483. if (err == MP_OKAY) {
  17484. (void)sp_4096_sub_81(tmpa, tmpa, tmpb);
  17485. sp_4096_norm_79(tmpa);
  17486. sp_4096_cond_add_81(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[78] >> 31));
  17487. sp_4096_cond_add_81(tmpa, tmpa, p, 0 - ((sp_int_digit)tmpa[78] >> 31));
  17488. sp_4096_norm_81(tmpa);
  17489. sp_4096_mul_81(tmpa, tmpa, qi);
  17490. err = sp_4096_mod_81(tmpa, tmpa, p);
  17491. }
  17492. if (err == MP_OKAY) {
  17493. sp_4096_mul_81(tmpa, tmpa, q);
  17494. (void)sp_4096_add_162(r, tmpb, tmpa);
  17495. sp_4096_norm_162(r);
  17496. sp_4096_to_bin_162(r, out);
  17497. *outLen = 512;
  17498. }
  17499. #ifdef WOLFSSL_SP_SMALL_STACK
  17500. if (a != NULL)
  17501. #endif
  17502. {
  17503. ForceZero(a, sizeof(sp_digit) * 81 * 13);
  17504. #ifdef WOLFSSL_SP_SMALL_STACK
  17505. XFREE(a, NULL, DYNAMIC_TYPE_RSA);
  17506. #endif
  17507. }
  17508. return err;
  17509. #endif /* WOLFSSL_SP_SMALL */
  17510. #endif /* SP_RSA_PRIVATE_EXP_D || RSA_LOW_MEM */
  17511. }
  17512. #endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
  17513. #endif /* WOLFSSL_HAVE_SP_RSA */
  17514. #if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
  17515. !defined(WOLFSSL_RSA_PUBLIC_ONLY))
  17516. /* Convert an array of sp_digit to an mp_int.
  17517. *
  17518. * a A single precision integer.
  17519. * r A multi-precision integer.
  17520. */
  17521. static int sp_4096_to_mp(const sp_digit* a, mp_int* r)
  17522. {
  17523. int err;
  17524. err = mp_grow(r, (4096 + DIGIT_BIT - 1) / DIGIT_BIT);
  17525. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  17526. #if DIGIT_BIT == 26
  17527. XMEMCPY(r->dp, a, sizeof(sp_digit) * 158);
  17528. r->used = 158;
  17529. mp_clamp(r);
  17530. #elif DIGIT_BIT < 26
  17531. int i;
  17532. int j = 0;
  17533. int s = 0;
  17534. r->dp[0] = 0;
  17535. for (i = 0; i < 158; i++) {
  17536. r->dp[j] |= (mp_digit)(a[i] << s);
  17537. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  17538. s = DIGIT_BIT - s;
  17539. r->dp[++j] = (mp_digit)(a[i] >> s);
  17540. while (s + DIGIT_BIT <= 26) {
  17541. s += DIGIT_BIT;
  17542. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  17543. if (s == SP_WORD_SIZE) {
  17544. r->dp[j] = 0;
  17545. }
  17546. else {
  17547. r->dp[j] = (mp_digit)(a[i] >> s);
  17548. }
  17549. }
  17550. s = 26 - s;
  17551. }
  17552. r->used = (4096 + DIGIT_BIT - 1) / DIGIT_BIT;
  17553. mp_clamp(r);
  17554. #else
  17555. int i;
  17556. int j = 0;
  17557. int s = 0;
  17558. r->dp[0] = 0;
  17559. for (i = 0; i < 158; i++) {
  17560. r->dp[j] |= ((mp_digit)a[i]) << s;
  17561. if (s + 26 >= DIGIT_BIT) {
  17562. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  17563. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  17564. #endif
  17565. s = DIGIT_BIT - s;
  17566. r->dp[++j] = a[i] >> s;
  17567. s = 26 - s;
  17568. }
  17569. else {
  17570. s += 26;
  17571. }
  17572. }
  17573. r->used = (4096 + DIGIT_BIT - 1) / DIGIT_BIT;
  17574. mp_clamp(r);
  17575. #endif
  17576. }
  17577. return err;
  17578. }
  17579. /* Perform the modular exponentiation for Diffie-Hellman.
  17580. *
  17581. * base Base. MP integer.
  17582. * exp Exponent. MP integer.
  17583. * mod Modulus. MP integer.
  17584. * res Result. MP integer.
  17585. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  17586. * and MEMORY_E if memory allocation fails.
  17587. */
  17588. int sp_ModExp_4096(const mp_int* base, const mp_int* exp, const mp_int* mod,
  17589. mp_int* res)
  17590. {
  17591. #ifdef WOLFSSL_SP_SMALL
  17592. int err = MP_OKAY;
  17593. #ifdef WOLFSSL_SP_SMALL_STACK
  17594. sp_digit* b = NULL;
  17595. #else
  17596. sp_digit b[162 * 4];
  17597. #endif
  17598. sp_digit* e = NULL;
  17599. sp_digit* m = NULL;
  17600. sp_digit* r = NULL;
  17601. int expBits = mp_count_bits(exp);
  17602. if (mp_count_bits(base) > 4096) {
  17603. err = MP_READ_E;
  17604. }
  17605. else if (expBits > 4096) {
  17606. err = MP_READ_E;
  17607. }
  17608. else if (mp_count_bits(mod) != 4096) {
  17609. err = MP_READ_E;
  17610. }
  17611. else if (mp_iseven(mod)) {
  17612. err = MP_VAL;
  17613. }
  17614. #ifdef WOLFSSL_SP_SMALL_STACK
  17615. if (err == MP_OKAY) {
  17616. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 4, NULL,
  17617. DYNAMIC_TYPE_DH);
  17618. if (b == NULL)
  17619. err = MEMORY_E;
  17620. }
  17621. #endif
  17622. if (err == MP_OKAY) {
  17623. e = b + 162 * 2;
  17624. m = e + 162;
  17625. r = b;
  17626. sp_4096_from_mp(b, 162, base);
  17627. sp_4096_from_mp(e, 162, exp);
  17628. sp_4096_from_mp(m, 162, mod);
  17629. err = sp_4096_mod_exp_162(r, b, e, mp_count_bits(exp), m, 0);
  17630. }
  17631. if (err == MP_OKAY) {
  17632. err = sp_4096_to_mp(r, res);
  17633. }
  17634. #ifdef WOLFSSL_SP_SMALL_STACK
  17635. if (b != NULL)
  17636. #endif
  17637. {
  17638. /* only "e" is sensitive and needs zeroized */
  17639. if (e != NULL)
  17640. ForceZero(e, sizeof(sp_digit) * 162U);
  17641. #ifdef WOLFSSL_SP_SMALL_STACK
  17642. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  17643. #endif
  17644. }
  17645. return err;
  17646. #else
  17647. #ifdef WOLFSSL_SP_SMALL_STACK
  17648. sp_digit* b = NULL;
  17649. #else
  17650. sp_digit b[162 * 4];
  17651. #endif
  17652. sp_digit* e = NULL;
  17653. sp_digit* m = NULL;
  17654. sp_digit* r = NULL;
  17655. int err = MP_OKAY;
  17656. int expBits = mp_count_bits(exp);
  17657. if (mp_count_bits(base) > 4096) {
  17658. err = MP_READ_E;
  17659. }
  17660. else if (expBits > 4096) {
  17661. err = MP_READ_E;
  17662. }
  17663. else if (mp_count_bits(mod) != 4096) {
  17664. err = MP_READ_E;
  17665. }
  17666. else if (mp_iseven(mod)) {
  17667. err = MP_VAL;
  17668. }
  17669. #ifdef WOLFSSL_SP_SMALL_STACK
  17670. if (err == MP_OKAY) {
  17671. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 4, NULL, DYNAMIC_TYPE_DH);
  17672. if (b == NULL)
  17673. err = MEMORY_E;
  17674. }
  17675. #endif
  17676. if (err == MP_OKAY) {
  17677. e = b + 162 * 2;
  17678. m = e + 162;
  17679. r = b;
  17680. sp_4096_from_mp(b, 162, base);
  17681. sp_4096_from_mp(e, 162, exp);
  17682. sp_4096_from_mp(m, 162, mod);
  17683. err = sp_4096_mod_exp_162(r, b, e, expBits, m, 0);
  17684. }
  17685. if (err == MP_OKAY) {
  17686. err = sp_4096_to_mp(r, res);
  17687. }
  17688. #ifdef WOLFSSL_SP_SMALL_STACK
  17689. if (b != NULL)
  17690. #endif
  17691. {
  17692. /* only "e" is sensitive and needs zeroized */
  17693. if (e != NULL)
  17694. ForceZero(e, sizeof(sp_digit) * 162U);
  17695. #ifdef WOLFSSL_SP_SMALL_STACK
  17696. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  17697. #endif
  17698. }
  17699. return err;
  17700. #endif
  17701. }
  17702. #ifdef WOLFSSL_HAVE_SP_DH
  17703. #ifdef HAVE_FFDHE_4096
  17704. SP_NOINLINE static void sp_4096_lshift_162(sp_digit* r, const sp_digit* a,
  17705. byte n)
  17706. {
  17707. sp_int_digit s;
  17708. sp_int_digit t;
  17709. s = (sp_int_digit)a[161];
  17710. r[162] = s >> (26U - n);
  17711. s = (sp_int_digit)(a[161]); t = (sp_int_digit)(a[160]);
  17712. r[161] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17713. s = (sp_int_digit)(a[160]); t = (sp_int_digit)(a[159]);
  17714. r[160] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17715. s = (sp_int_digit)(a[159]); t = (sp_int_digit)(a[158]);
  17716. r[159] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17717. s = (sp_int_digit)(a[158]); t = (sp_int_digit)(a[157]);
  17718. r[158] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17719. s = (sp_int_digit)(a[157]); t = (sp_int_digit)(a[156]);
  17720. r[157] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17721. s = (sp_int_digit)(a[156]); t = (sp_int_digit)(a[155]);
  17722. r[156] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17723. s = (sp_int_digit)(a[155]); t = (sp_int_digit)(a[154]);
  17724. r[155] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17725. s = (sp_int_digit)(a[154]); t = (sp_int_digit)(a[153]);
  17726. r[154] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17727. s = (sp_int_digit)(a[153]); t = (sp_int_digit)(a[152]);
  17728. r[153] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17729. s = (sp_int_digit)(a[152]); t = (sp_int_digit)(a[151]);
  17730. r[152] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17731. s = (sp_int_digit)(a[151]); t = (sp_int_digit)(a[150]);
  17732. r[151] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17733. s = (sp_int_digit)(a[150]); t = (sp_int_digit)(a[149]);
  17734. r[150] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17735. s = (sp_int_digit)(a[149]); t = (sp_int_digit)(a[148]);
  17736. r[149] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17737. s = (sp_int_digit)(a[148]); t = (sp_int_digit)(a[147]);
  17738. r[148] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17739. s = (sp_int_digit)(a[147]); t = (sp_int_digit)(a[146]);
  17740. r[147] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17741. s = (sp_int_digit)(a[146]); t = (sp_int_digit)(a[145]);
  17742. r[146] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17743. s = (sp_int_digit)(a[145]); t = (sp_int_digit)(a[144]);
  17744. r[145] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17745. s = (sp_int_digit)(a[144]); t = (sp_int_digit)(a[143]);
  17746. r[144] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17747. s = (sp_int_digit)(a[143]); t = (sp_int_digit)(a[142]);
  17748. r[143] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17749. s = (sp_int_digit)(a[142]); t = (sp_int_digit)(a[141]);
  17750. r[142] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17751. s = (sp_int_digit)(a[141]); t = (sp_int_digit)(a[140]);
  17752. r[141] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17753. s = (sp_int_digit)(a[140]); t = (sp_int_digit)(a[139]);
  17754. r[140] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17755. s = (sp_int_digit)(a[139]); t = (sp_int_digit)(a[138]);
  17756. r[139] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17757. s = (sp_int_digit)(a[138]); t = (sp_int_digit)(a[137]);
  17758. r[138] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17759. s = (sp_int_digit)(a[137]); t = (sp_int_digit)(a[136]);
  17760. r[137] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17761. s = (sp_int_digit)(a[136]); t = (sp_int_digit)(a[135]);
  17762. r[136] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17763. s = (sp_int_digit)(a[135]); t = (sp_int_digit)(a[134]);
  17764. r[135] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17765. s = (sp_int_digit)(a[134]); t = (sp_int_digit)(a[133]);
  17766. r[134] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17767. s = (sp_int_digit)(a[133]); t = (sp_int_digit)(a[132]);
  17768. r[133] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17769. s = (sp_int_digit)(a[132]); t = (sp_int_digit)(a[131]);
  17770. r[132] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17771. s = (sp_int_digit)(a[131]); t = (sp_int_digit)(a[130]);
  17772. r[131] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17773. s = (sp_int_digit)(a[130]); t = (sp_int_digit)(a[129]);
  17774. r[130] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17775. s = (sp_int_digit)(a[129]); t = (sp_int_digit)(a[128]);
  17776. r[129] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17777. s = (sp_int_digit)(a[128]); t = (sp_int_digit)(a[127]);
  17778. r[128] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17779. s = (sp_int_digit)(a[127]); t = (sp_int_digit)(a[126]);
  17780. r[127] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17781. s = (sp_int_digit)(a[126]); t = (sp_int_digit)(a[125]);
  17782. r[126] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17783. s = (sp_int_digit)(a[125]); t = (sp_int_digit)(a[124]);
  17784. r[125] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17785. s = (sp_int_digit)(a[124]); t = (sp_int_digit)(a[123]);
  17786. r[124] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17787. s = (sp_int_digit)(a[123]); t = (sp_int_digit)(a[122]);
  17788. r[123] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17789. s = (sp_int_digit)(a[122]); t = (sp_int_digit)(a[121]);
  17790. r[122] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17791. s = (sp_int_digit)(a[121]); t = (sp_int_digit)(a[120]);
  17792. r[121] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17793. s = (sp_int_digit)(a[120]); t = (sp_int_digit)(a[119]);
  17794. r[120] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17795. s = (sp_int_digit)(a[119]); t = (sp_int_digit)(a[118]);
  17796. r[119] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17797. s = (sp_int_digit)(a[118]); t = (sp_int_digit)(a[117]);
  17798. r[118] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17799. s = (sp_int_digit)(a[117]); t = (sp_int_digit)(a[116]);
  17800. r[117] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17801. s = (sp_int_digit)(a[116]); t = (sp_int_digit)(a[115]);
  17802. r[116] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17803. s = (sp_int_digit)(a[115]); t = (sp_int_digit)(a[114]);
  17804. r[115] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17805. s = (sp_int_digit)(a[114]); t = (sp_int_digit)(a[113]);
  17806. r[114] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17807. s = (sp_int_digit)(a[113]); t = (sp_int_digit)(a[112]);
  17808. r[113] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17809. s = (sp_int_digit)(a[112]); t = (sp_int_digit)(a[111]);
  17810. r[112] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17811. s = (sp_int_digit)(a[111]); t = (sp_int_digit)(a[110]);
  17812. r[111] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17813. s = (sp_int_digit)(a[110]); t = (sp_int_digit)(a[109]);
  17814. r[110] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17815. s = (sp_int_digit)(a[109]); t = (sp_int_digit)(a[108]);
  17816. r[109] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17817. s = (sp_int_digit)(a[108]); t = (sp_int_digit)(a[107]);
  17818. r[108] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17819. s = (sp_int_digit)(a[107]); t = (sp_int_digit)(a[106]);
  17820. r[107] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17821. s = (sp_int_digit)(a[106]); t = (sp_int_digit)(a[105]);
  17822. r[106] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17823. s = (sp_int_digit)(a[105]); t = (sp_int_digit)(a[104]);
  17824. r[105] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17825. s = (sp_int_digit)(a[104]); t = (sp_int_digit)(a[103]);
  17826. r[104] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17827. s = (sp_int_digit)(a[103]); t = (sp_int_digit)(a[102]);
  17828. r[103] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17829. s = (sp_int_digit)(a[102]); t = (sp_int_digit)(a[101]);
  17830. r[102] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17831. s = (sp_int_digit)(a[101]); t = (sp_int_digit)(a[100]);
  17832. r[101] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17833. s = (sp_int_digit)(a[100]); t = (sp_int_digit)(a[99]);
  17834. r[100] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17835. s = (sp_int_digit)(a[99]); t = (sp_int_digit)(a[98]);
  17836. r[99] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17837. s = (sp_int_digit)(a[98]); t = (sp_int_digit)(a[97]);
  17838. r[98] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17839. s = (sp_int_digit)(a[97]); t = (sp_int_digit)(a[96]);
  17840. r[97] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17841. s = (sp_int_digit)(a[96]); t = (sp_int_digit)(a[95]);
  17842. r[96] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17843. s = (sp_int_digit)(a[95]); t = (sp_int_digit)(a[94]);
  17844. r[95] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17845. s = (sp_int_digit)(a[94]); t = (sp_int_digit)(a[93]);
  17846. r[94] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17847. s = (sp_int_digit)(a[93]); t = (sp_int_digit)(a[92]);
  17848. r[93] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17849. s = (sp_int_digit)(a[92]); t = (sp_int_digit)(a[91]);
  17850. r[92] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17851. s = (sp_int_digit)(a[91]); t = (sp_int_digit)(a[90]);
  17852. r[91] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17853. s = (sp_int_digit)(a[90]); t = (sp_int_digit)(a[89]);
  17854. r[90] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17855. s = (sp_int_digit)(a[89]); t = (sp_int_digit)(a[88]);
  17856. r[89] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17857. s = (sp_int_digit)(a[88]); t = (sp_int_digit)(a[87]);
  17858. r[88] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17859. s = (sp_int_digit)(a[87]); t = (sp_int_digit)(a[86]);
  17860. r[87] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17861. s = (sp_int_digit)(a[86]); t = (sp_int_digit)(a[85]);
  17862. r[86] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17863. s = (sp_int_digit)(a[85]); t = (sp_int_digit)(a[84]);
  17864. r[85] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17865. s = (sp_int_digit)(a[84]); t = (sp_int_digit)(a[83]);
  17866. r[84] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17867. s = (sp_int_digit)(a[83]); t = (sp_int_digit)(a[82]);
  17868. r[83] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17869. s = (sp_int_digit)(a[82]); t = (sp_int_digit)(a[81]);
  17870. r[82] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17871. s = (sp_int_digit)(a[81]); t = (sp_int_digit)(a[80]);
  17872. r[81] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17873. s = (sp_int_digit)(a[80]); t = (sp_int_digit)(a[79]);
  17874. r[80] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17875. s = (sp_int_digit)(a[79]); t = (sp_int_digit)(a[78]);
  17876. r[79] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17877. s = (sp_int_digit)(a[78]); t = (sp_int_digit)(a[77]);
  17878. r[78] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17879. s = (sp_int_digit)(a[77]); t = (sp_int_digit)(a[76]);
  17880. r[77] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17881. s = (sp_int_digit)(a[76]); t = (sp_int_digit)(a[75]);
  17882. r[76] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17883. s = (sp_int_digit)(a[75]); t = (sp_int_digit)(a[74]);
  17884. r[75] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17885. s = (sp_int_digit)(a[74]); t = (sp_int_digit)(a[73]);
  17886. r[74] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17887. s = (sp_int_digit)(a[73]); t = (sp_int_digit)(a[72]);
  17888. r[73] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17889. s = (sp_int_digit)(a[72]); t = (sp_int_digit)(a[71]);
  17890. r[72] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17891. s = (sp_int_digit)(a[71]); t = (sp_int_digit)(a[70]);
  17892. r[71] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17893. s = (sp_int_digit)(a[70]); t = (sp_int_digit)(a[69]);
  17894. r[70] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17895. s = (sp_int_digit)(a[69]); t = (sp_int_digit)(a[68]);
  17896. r[69] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17897. s = (sp_int_digit)(a[68]); t = (sp_int_digit)(a[67]);
  17898. r[68] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17899. s = (sp_int_digit)(a[67]); t = (sp_int_digit)(a[66]);
  17900. r[67] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17901. s = (sp_int_digit)(a[66]); t = (sp_int_digit)(a[65]);
  17902. r[66] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17903. s = (sp_int_digit)(a[65]); t = (sp_int_digit)(a[64]);
  17904. r[65] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17905. s = (sp_int_digit)(a[64]); t = (sp_int_digit)(a[63]);
  17906. r[64] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17907. s = (sp_int_digit)(a[63]); t = (sp_int_digit)(a[62]);
  17908. r[63] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17909. s = (sp_int_digit)(a[62]); t = (sp_int_digit)(a[61]);
  17910. r[62] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17911. s = (sp_int_digit)(a[61]); t = (sp_int_digit)(a[60]);
  17912. r[61] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17913. s = (sp_int_digit)(a[60]); t = (sp_int_digit)(a[59]);
  17914. r[60] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17915. s = (sp_int_digit)(a[59]); t = (sp_int_digit)(a[58]);
  17916. r[59] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17917. s = (sp_int_digit)(a[58]); t = (sp_int_digit)(a[57]);
  17918. r[58] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17919. s = (sp_int_digit)(a[57]); t = (sp_int_digit)(a[56]);
  17920. r[57] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17921. s = (sp_int_digit)(a[56]); t = (sp_int_digit)(a[55]);
  17922. r[56] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17923. s = (sp_int_digit)(a[55]); t = (sp_int_digit)(a[54]);
  17924. r[55] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17925. s = (sp_int_digit)(a[54]); t = (sp_int_digit)(a[53]);
  17926. r[54] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17927. s = (sp_int_digit)(a[53]); t = (sp_int_digit)(a[52]);
  17928. r[53] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17929. s = (sp_int_digit)(a[52]); t = (sp_int_digit)(a[51]);
  17930. r[52] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17931. s = (sp_int_digit)(a[51]); t = (sp_int_digit)(a[50]);
  17932. r[51] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17933. s = (sp_int_digit)(a[50]); t = (sp_int_digit)(a[49]);
  17934. r[50] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17935. s = (sp_int_digit)(a[49]); t = (sp_int_digit)(a[48]);
  17936. r[49] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17937. s = (sp_int_digit)(a[48]); t = (sp_int_digit)(a[47]);
  17938. r[48] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17939. s = (sp_int_digit)(a[47]); t = (sp_int_digit)(a[46]);
  17940. r[47] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17941. s = (sp_int_digit)(a[46]); t = (sp_int_digit)(a[45]);
  17942. r[46] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17943. s = (sp_int_digit)(a[45]); t = (sp_int_digit)(a[44]);
  17944. r[45] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17945. s = (sp_int_digit)(a[44]); t = (sp_int_digit)(a[43]);
  17946. r[44] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17947. s = (sp_int_digit)(a[43]); t = (sp_int_digit)(a[42]);
  17948. r[43] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17949. s = (sp_int_digit)(a[42]); t = (sp_int_digit)(a[41]);
  17950. r[42] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17951. s = (sp_int_digit)(a[41]); t = (sp_int_digit)(a[40]);
  17952. r[41] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17953. s = (sp_int_digit)(a[40]); t = (sp_int_digit)(a[39]);
  17954. r[40] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17955. s = (sp_int_digit)(a[39]); t = (sp_int_digit)(a[38]);
  17956. r[39] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17957. s = (sp_int_digit)(a[38]); t = (sp_int_digit)(a[37]);
  17958. r[38] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17959. s = (sp_int_digit)(a[37]); t = (sp_int_digit)(a[36]);
  17960. r[37] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17961. s = (sp_int_digit)(a[36]); t = (sp_int_digit)(a[35]);
  17962. r[36] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17963. s = (sp_int_digit)(a[35]); t = (sp_int_digit)(a[34]);
  17964. r[35] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17965. s = (sp_int_digit)(a[34]); t = (sp_int_digit)(a[33]);
  17966. r[34] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17967. s = (sp_int_digit)(a[33]); t = (sp_int_digit)(a[32]);
  17968. r[33] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17969. s = (sp_int_digit)(a[32]); t = (sp_int_digit)(a[31]);
  17970. r[32] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17971. s = (sp_int_digit)(a[31]); t = (sp_int_digit)(a[30]);
  17972. r[31] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17973. s = (sp_int_digit)(a[30]); t = (sp_int_digit)(a[29]);
  17974. r[30] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17975. s = (sp_int_digit)(a[29]); t = (sp_int_digit)(a[28]);
  17976. r[29] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17977. s = (sp_int_digit)(a[28]); t = (sp_int_digit)(a[27]);
  17978. r[28] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17979. s = (sp_int_digit)(a[27]); t = (sp_int_digit)(a[26]);
  17980. r[27] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17981. s = (sp_int_digit)(a[26]); t = (sp_int_digit)(a[25]);
  17982. r[26] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17983. s = (sp_int_digit)(a[25]); t = (sp_int_digit)(a[24]);
  17984. r[25] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17985. s = (sp_int_digit)(a[24]); t = (sp_int_digit)(a[23]);
  17986. r[24] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17987. s = (sp_int_digit)(a[23]); t = (sp_int_digit)(a[22]);
  17988. r[23] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17989. s = (sp_int_digit)(a[22]); t = (sp_int_digit)(a[21]);
  17990. r[22] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17991. s = (sp_int_digit)(a[21]); t = (sp_int_digit)(a[20]);
  17992. r[21] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17993. s = (sp_int_digit)(a[20]); t = (sp_int_digit)(a[19]);
  17994. r[20] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17995. s = (sp_int_digit)(a[19]); t = (sp_int_digit)(a[18]);
  17996. r[19] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17997. s = (sp_int_digit)(a[18]); t = (sp_int_digit)(a[17]);
  17998. r[18] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  17999. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  18000. r[17] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18001. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  18002. r[16] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18003. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  18004. r[15] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18005. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  18006. r[14] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18007. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  18008. r[13] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18009. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  18010. r[12] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18011. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  18012. r[11] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18013. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  18014. r[10] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18015. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  18016. r[9] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18017. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  18018. r[8] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18019. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  18020. r[7] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18021. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  18022. r[6] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18023. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  18024. r[5] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18025. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  18026. r[4] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18027. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  18028. r[3] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18029. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  18030. r[2] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18031. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  18032. r[1] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  18033. r[0] = (a[0] << n) & 0x3ffffff;
  18034. }
  18035. /* Modular exponentiate 2 to the e mod m. (r = 2^e mod m)
  18036. *
  18037. * r A single precision number that is the result of the operation.
  18038. * e A single precision number that is the exponent.
  18039. * bits The number of bits in the exponent.
  18040. * m A single precision number that is the modulus.
  18041. * returns 0 on success.
  18042. * returns MEMORY_E on dynamic memory allocation failure.
  18043. * returns MP_VAL when base is even.
  18044. */
  18045. static int sp_4096_mod_exp_2_162(sp_digit* r, const sp_digit* e, int bits, const sp_digit* m)
  18046. {
  18047. #ifdef WOLFSSL_SP_SMALL_STACK
  18048. sp_digit* td = NULL;
  18049. #else
  18050. sp_digit td[487];
  18051. #endif
  18052. sp_digit* norm = NULL;
  18053. sp_digit* tmp = NULL;
  18054. sp_digit mp = 1;
  18055. sp_digit n;
  18056. sp_digit o;
  18057. int i;
  18058. int c;
  18059. byte y;
  18060. int err = MP_OKAY;
  18061. if (bits == 0) {
  18062. err = MP_VAL;
  18063. }
  18064. #ifdef WOLFSSL_SP_SMALL_STACK
  18065. if (err == MP_OKAY) {
  18066. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 487, NULL,
  18067. DYNAMIC_TYPE_TMP_BUFFER);
  18068. if (td == NULL)
  18069. err = MEMORY_E;
  18070. }
  18071. #endif
  18072. if (err == MP_OKAY) {
  18073. norm = td;
  18074. tmp = td + 324;
  18075. XMEMSET(td, 0, sizeof(sp_digit) * 487);
  18076. sp_4096_mont_setup(m, &mp);
  18077. sp_4096_mont_norm_162(norm, m);
  18078. bits = ((bits + 3) / 4) * 4;
  18079. i = ((bits + 25) / 26) - 1;
  18080. c = bits % 26;
  18081. if (c == 0) {
  18082. c = 26;
  18083. }
  18084. if (i < 162) {
  18085. n = e[i--] << (32 - c);
  18086. }
  18087. else {
  18088. n = 0;
  18089. i--;
  18090. }
  18091. if (c < 4) {
  18092. n |= e[i--] << (6 - c);
  18093. c += 26;
  18094. }
  18095. y = (int)((n >> 28) & 0xf);
  18096. n <<= 4;
  18097. c -= 4;
  18098. sp_4096_lshift_162(r, norm, (byte)y);
  18099. while ((i >= 0) || (c >= 4)) {
  18100. if (c >= 4) {
  18101. y = (byte)((n >> 28) & 0xf);
  18102. n <<= 4;
  18103. c -= 4;
  18104. }
  18105. else if (c == 0) {
  18106. n = e[i--] << 6;
  18107. y = (byte)((n >> 28) & 0xf);
  18108. n <<= 4;
  18109. c = 22;
  18110. }
  18111. else {
  18112. y = (byte)((n >> 28) & 0xf);
  18113. n = e[i--] << 6;
  18114. c = 4 - c;
  18115. y |= (byte)((n >> (32 - c)) & ((1 << c) - 1));
  18116. n <<= c;
  18117. c = 26 - c;
  18118. }
  18119. sp_4096_mont_sqr_162(r, r, m, mp);
  18120. sp_4096_mont_sqr_162(r, r, m, mp);
  18121. sp_4096_mont_sqr_162(r, r, m, mp);
  18122. sp_4096_mont_sqr_162(r, r, m, mp);
  18123. sp_4096_lshift_162(r, r, (byte)y);
  18124. sp_4096_mul_d_162(tmp, norm, (r[158] << 12) + (r[157] >> 14));
  18125. r[158] = 0;
  18126. r[157] &= 0x3fffL;
  18127. (void)sp_4096_add_162(r, r, tmp);
  18128. sp_4096_norm_162(r);
  18129. o = sp_4096_cmp_162(r, m);
  18130. sp_4096_cond_sub_162(r, r, m, ~(o >> 31));
  18131. }
  18132. sp_4096_mont_reduce_162(r, m, mp);
  18133. n = sp_4096_cmp_162(r, m);
  18134. sp_4096_cond_sub_162(r, r, m, ~(n >> 31));
  18135. }
  18136. #ifdef WOLFSSL_SP_SMALL_STACK
  18137. if (td != NULL)
  18138. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  18139. #endif
  18140. return err;
  18141. }
  18142. #endif /* HAVE_FFDHE_4096 */
  18143. /* Perform the modular exponentiation for Diffie-Hellman.
  18144. *
  18145. * base Base.
  18146. * exp Array of bytes that is the exponent.
  18147. * expLen Length of data, in bytes, in exponent.
  18148. * mod Modulus.
  18149. * out Buffer to hold big-endian bytes of exponentiation result.
  18150. * Must be at least 512 bytes long.
  18151. * outLen Length, in bytes, of exponentiation result.
  18152. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  18153. * and MEMORY_E if memory allocation fails.
  18154. */
  18155. int sp_DhExp_4096(const mp_int* base, const byte* exp, word32 expLen,
  18156. const mp_int* mod, byte* out, word32* outLen)
  18157. {
  18158. #ifdef WOLFSSL_SP_SMALL_STACK
  18159. sp_digit* b = NULL;
  18160. #else
  18161. sp_digit b[162 * 4];
  18162. #endif
  18163. sp_digit* e = NULL;
  18164. sp_digit* m = NULL;
  18165. sp_digit* r = NULL;
  18166. word32 i;
  18167. int err = MP_OKAY;
  18168. if (mp_count_bits(base) > 4096) {
  18169. err = MP_READ_E;
  18170. }
  18171. else if (expLen > 512U) {
  18172. err = MP_READ_E;
  18173. }
  18174. else if (mp_count_bits(mod) != 4096) {
  18175. err = MP_READ_E;
  18176. }
  18177. else if (mp_iseven(mod)) {
  18178. err = MP_VAL;
  18179. }
  18180. #ifdef WOLFSSL_SP_SMALL_STACK
  18181. if (err == MP_OKAY) {
  18182. b = (sp_digit*)XMALLOC(sizeof(sp_digit) * 162 * 4, NULL,
  18183. DYNAMIC_TYPE_DH);
  18184. if (b == NULL)
  18185. err = MEMORY_E;
  18186. }
  18187. #endif
  18188. if (err == MP_OKAY) {
  18189. e = b + 162 * 2;
  18190. m = e + 162;
  18191. r = b;
  18192. sp_4096_from_mp(b, 162, base);
  18193. sp_4096_from_bin(e, 162, exp, expLen);
  18194. sp_4096_from_mp(m, 162, mod);
  18195. #ifdef HAVE_FFDHE_4096
  18196. if (base->used == 1 && base->dp[0] == 2U &&
  18197. ((m[157] << 2) | (m[156] >> 24)) == 0xffffL) {
  18198. err = sp_4096_mod_exp_2_162(r, e, expLen * 8U, m);
  18199. }
  18200. else {
  18201. #endif
  18202. err = sp_4096_mod_exp_162(r, b, e, expLen * 8U, m, 0);
  18203. #ifdef HAVE_FFDHE_4096
  18204. }
  18205. #endif
  18206. }
  18207. if (err == MP_OKAY) {
  18208. sp_4096_to_bin_162(r, out);
  18209. *outLen = 512;
  18210. for (i=0; i<512U && out[i] == 0U; i++) {
  18211. /* Search for first non-zero. */
  18212. }
  18213. *outLen -= i;
  18214. XMEMMOVE(out, out + i, *outLen);
  18215. }
  18216. #ifdef WOLFSSL_SP_SMALL_STACK
  18217. if (b != NULL)
  18218. #endif
  18219. {
  18220. /* only "e" is sensitive and needs zeroized */
  18221. if (e != NULL)
  18222. ForceZero(e, sizeof(sp_digit) * 162U);
  18223. #ifdef WOLFSSL_SP_SMALL_STACK
  18224. XFREE(b, NULL, DYNAMIC_TYPE_DH);
  18225. #endif
  18226. }
  18227. return err;
  18228. }
  18229. #endif /* WOLFSSL_HAVE_SP_DH */
  18230. #endif /* WOLFSSL_HAVE_SP_DH | (WOLFSSL_HAVE_SP_RSA & !WOLFSSL_RSA_PUBLIC_ONLY) */
  18231. #endif /* WOLFSSL_SP_SMALL */
  18232. #endif /* WOLFSSL_SP_4096 */
  18233. #endif /* WOLFSSL_HAVE_SP_RSA | WOLFSSL_HAVE_SP_DH */
  18234. #ifdef WOLFSSL_HAVE_SP_ECC
  18235. #ifndef WOLFSSL_SP_NO_256
  18236. /* Point structure to use. */
  18237. typedef struct sp_point_256 {
  18238. /* X ordinate of point. */
  18239. sp_digit x[2 * 9];
  18240. /* Y ordinate of point. */
  18241. sp_digit y[2 * 9];
  18242. /* Z ordinate of point. */
  18243. sp_digit z[2 * 9];
  18244. /* Indicates point is at infinity. */
  18245. int infinity;
  18246. } sp_point_256;
  18247. /* The modulus (prime) of the curve P256. */
  18248. static const sp_digit p256_mod[9] = {
  18249. 0x1fffffff,0x1fffffff,0x1fffffff,0x000001ff,0x00000000,0x00000000,
  18250. 0x00040000,0x1fe00000,0x00ffffff
  18251. };
  18252. /* The Montgomery normalizer for modulus of the curve P256. */
  18253. static const sp_digit p256_norm_mod[9] = {
  18254. 0x00000001,0x00000000,0x00000000,0x1ffffe00,0x1fffffff,0x1fffffff,
  18255. 0x1ffbffff,0x001fffff,0x00000000
  18256. };
  18257. /* The Montgomery multiplier for modulus of the curve P256. */
  18258. static const sp_digit p256_mp_mod = 0x0000001;
  18259. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  18260. defined(HAVE_ECC_VERIFY)
  18261. /* The order of the curve P256. */
  18262. static const sp_digit p256_order[9] = {
  18263. 0x1c632551,0x1dce5617,0x05e7a13c,0x0df55b4e,0x1ffffbce,0x1fffffff,
  18264. 0x0003ffff,0x1fe00000,0x00ffffff
  18265. };
  18266. #endif
  18267. /* The order of the curve P256 minus 2. */
  18268. static const sp_digit p256_order2[9] = {
  18269. 0x1c63254f,0x1dce5617,0x05e7a13c,0x0df55b4e,0x1ffffbce,0x1fffffff,
  18270. 0x0003ffff,0x1fe00000,0x00ffffff
  18271. };
  18272. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  18273. /* The Montgomery normalizer for order of the curve P256. */
  18274. static const sp_digit p256_norm_order[9] = {
  18275. 0x039cdaaf,0x0231a9e8,0x1a185ec3,0x120aa4b1,0x00000431,0x00000000,
  18276. 0x1ffc0000,0x001fffff,0x00000000
  18277. };
  18278. #endif
  18279. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  18280. /* The Montgomery multiplier for order of the curve P256. */
  18281. static const sp_digit p256_mp_order = 0xe00bc4f;
  18282. #endif
  18283. /* The base point of curve P256. */
  18284. static const sp_point_256 p256_base = {
  18285. /* X ordinate */
  18286. {
  18287. 0x1898c296,0x0509ca2e,0x1acce83d,0x06fb025b,0x040f2770,0x1372b1d2,
  18288. 0x091fe2f3,0x1e5c2588,0x006b17d1,
  18289. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  18290. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  18291. },
  18292. /* Y ordinate */
  18293. {
  18294. 0x17bf51f5,0x1db20341,0x0c57b3b2,0x1c66aed6,0x19e162bc,0x15a53e07,
  18295. 0x1e6e3b9f,0x1c5fc34f,0x004fe342,
  18296. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  18297. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  18298. },
  18299. /* Z ordinate */
  18300. {
  18301. 0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  18302. 0x00000000,0x00000000,0x00000000,
  18303. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  18304. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  18305. },
  18306. /* infinity */
  18307. 0
  18308. };
  18309. #if defined(HAVE_ECC_CHECK_KEY) || defined(HAVE_COMP_KEY)
  18310. static const sp_digit p256_b[9] = {
  18311. 0x07d2604b,0x1e71e1f1,0x14ec3d8e,0x1a0d6198,0x086bc651,0x1eaabb4c,
  18312. 0x0f9ecfae,0x1b154752,0x005ac635
  18313. };
  18314. #endif
  18315. #ifdef WOLFSSL_SP_SMALL
  18316. /* Multiply a and b into r. (r = a * b)
  18317. *
  18318. * r A single precision integer.
  18319. * a A single precision integer.
  18320. * b A single precision integer.
  18321. */
  18322. SP_NOINLINE static void sp_256_mul_9(sp_digit* r, const sp_digit* a,
  18323. const sp_digit* b)
  18324. {
  18325. int i;
  18326. int imax;
  18327. int k;
  18328. sp_uint64 c;
  18329. sp_uint64 lo;
  18330. c = ((sp_uint64)a[8]) * b[8];
  18331. r[17] = (sp_digit)(c >> 29);
  18332. c &= 0x1fffffff;
  18333. for (k = 15; k >= 0; k--) {
  18334. if (k >= 9) {
  18335. i = k - 8;
  18336. imax = 8;
  18337. }
  18338. else {
  18339. i = 0;
  18340. imax = k;
  18341. }
  18342. lo = 0;
  18343. for (; i <= imax; i++) {
  18344. lo += ((sp_uint64)a[i]) * b[k - i];
  18345. }
  18346. c += lo >> 29;
  18347. r[k + 2] += (sp_digit)(c >> 29);
  18348. r[k + 1] = (sp_digit)(c & 0x1fffffff);
  18349. c = lo & 0x1fffffff;
  18350. }
  18351. r[0] = (sp_digit)c;
  18352. }
  18353. #else
  18354. /* Multiply a and b into r. (r = a * b)
  18355. *
  18356. * r A single precision integer.
  18357. * a A single precision integer.
  18358. * b A single precision integer.
  18359. */
  18360. SP_NOINLINE static void sp_256_mul_9(sp_digit* r, const sp_digit* a,
  18361. const sp_digit* b)
  18362. {
  18363. sp_int64 t0;
  18364. sp_int64 t1;
  18365. sp_digit t[9];
  18366. t0 = ((sp_int64)a[ 0]) * b[ 0];
  18367. t1 = ((sp_int64)a[ 0]) * b[ 1]
  18368. + ((sp_int64)a[ 1]) * b[ 0];
  18369. t[ 0] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18370. t0 = ((sp_int64)a[ 0]) * b[ 2]
  18371. + ((sp_int64)a[ 1]) * b[ 1]
  18372. + ((sp_int64)a[ 2]) * b[ 0];
  18373. t[ 1] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18374. t1 = ((sp_int64)a[ 0]) * b[ 3]
  18375. + ((sp_int64)a[ 1]) * b[ 2]
  18376. + ((sp_int64)a[ 2]) * b[ 1]
  18377. + ((sp_int64)a[ 3]) * b[ 0];
  18378. t[ 2] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18379. t0 = ((sp_int64)a[ 0]) * b[ 4]
  18380. + ((sp_int64)a[ 1]) * b[ 3]
  18381. + ((sp_int64)a[ 2]) * b[ 2]
  18382. + ((sp_int64)a[ 3]) * b[ 1]
  18383. + ((sp_int64)a[ 4]) * b[ 0];
  18384. t[ 3] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18385. t1 = ((sp_int64)a[ 0]) * b[ 5]
  18386. + ((sp_int64)a[ 1]) * b[ 4]
  18387. + ((sp_int64)a[ 2]) * b[ 3]
  18388. + ((sp_int64)a[ 3]) * b[ 2]
  18389. + ((sp_int64)a[ 4]) * b[ 1]
  18390. + ((sp_int64)a[ 5]) * b[ 0];
  18391. t[ 4] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18392. t0 = ((sp_int64)a[ 0]) * b[ 6]
  18393. + ((sp_int64)a[ 1]) * b[ 5]
  18394. + ((sp_int64)a[ 2]) * b[ 4]
  18395. + ((sp_int64)a[ 3]) * b[ 3]
  18396. + ((sp_int64)a[ 4]) * b[ 2]
  18397. + ((sp_int64)a[ 5]) * b[ 1]
  18398. + ((sp_int64)a[ 6]) * b[ 0];
  18399. t[ 5] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18400. t1 = ((sp_int64)a[ 0]) * b[ 7]
  18401. + ((sp_int64)a[ 1]) * b[ 6]
  18402. + ((sp_int64)a[ 2]) * b[ 5]
  18403. + ((sp_int64)a[ 3]) * b[ 4]
  18404. + ((sp_int64)a[ 4]) * b[ 3]
  18405. + ((sp_int64)a[ 5]) * b[ 2]
  18406. + ((sp_int64)a[ 6]) * b[ 1]
  18407. + ((sp_int64)a[ 7]) * b[ 0];
  18408. t[ 6] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18409. t0 = ((sp_int64)a[ 0]) * b[ 8]
  18410. + ((sp_int64)a[ 1]) * b[ 7]
  18411. + ((sp_int64)a[ 2]) * b[ 6]
  18412. + ((sp_int64)a[ 3]) * b[ 5]
  18413. + ((sp_int64)a[ 4]) * b[ 4]
  18414. + ((sp_int64)a[ 5]) * b[ 3]
  18415. + ((sp_int64)a[ 6]) * b[ 2]
  18416. + ((sp_int64)a[ 7]) * b[ 1]
  18417. + ((sp_int64)a[ 8]) * b[ 0];
  18418. t[ 7] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18419. t1 = ((sp_int64)a[ 1]) * b[ 8]
  18420. + ((sp_int64)a[ 2]) * b[ 7]
  18421. + ((sp_int64)a[ 3]) * b[ 6]
  18422. + ((sp_int64)a[ 4]) * b[ 5]
  18423. + ((sp_int64)a[ 5]) * b[ 4]
  18424. + ((sp_int64)a[ 6]) * b[ 3]
  18425. + ((sp_int64)a[ 7]) * b[ 2]
  18426. + ((sp_int64)a[ 8]) * b[ 1];
  18427. t[ 8] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18428. t0 = ((sp_int64)a[ 2]) * b[ 8]
  18429. + ((sp_int64)a[ 3]) * b[ 7]
  18430. + ((sp_int64)a[ 4]) * b[ 6]
  18431. + ((sp_int64)a[ 5]) * b[ 5]
  18432. + ((sp_int64)a[ 6]) * b[ 4]
  18433. + ((sp_int64)a[ 7]) * b[ 3]
  18434. + ((sp_int64)a[ 8]) * b[ 2];
  18435. r[ 9] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18436. t1 = ((sp_int64)a[ 3]) * b[ 8]
  18437. + ((sp_int64)a[ 4]) * b[ 7]
  18438. + ((sp_int64)a[ 5]) * b[ 6]
  18439. + ((sp_int64)a[ 6]) * b[ 5]
  18440. + ((sp_int64)a[ 7]) * b[ 4]
  18441. + ((sp_int64)a[ 8]) * b[ 3];
  18442. r[10] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18443. t0 = ((sp_int64)a[ 4]) * b[ 8]
  18444. + ((sp_int64)a[ 5]) * b[ 7]
  18445. + ((sp_int64)a[ 6]) * b[ 6]
  18446. + ((sp_int64)a[ 7]) * b[ 5]
  18447. + ((sp_int64)a[ 8]) * b[ 4];
  18448. r[11] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18449. t1 = ((sp_int64)a[ 5]) * b[ 8]
  18450. + ((sp_int64)a[ 6]) * b[ 7]
  18451. + ((sp_int64)a[ 7]) * b[ 6]
  18452. + ((sp_int64)a[ 8]) * b[ 5];
  18453. r[12] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18454. t0 = ((sp_int64)a[ 6]) * b[ 8]
  18455. + ((sp_int64)a[ 7]) * b[ 7]
  18456. + ((sp_int64)a[ 8]) * b[ 6];
  18457. r[13] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18458. t1 = ((sp_int64)a[ 7]) * b[ 8]
  18459. + ((sp_int64)a[ 8]) * b[ 7];
  18460. r[14] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18461. t0 = ((sp_int64)a[ 8]) * b[ 8];
  18462. r[15] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18463. r[16] = t0 & 0x1fffffff;
  18464. r[17] = (sp_digit)(t0 >> 29);
  18465. XMEMCPY(r, t, sizeof(t));
  18466. }
  18467. #endif /* WOLFSSL_SP_SMALL */
  18468. #ifdef WOLFSSL_SP_SMALL
  18469. /* Square a and put result in r. (r = a * a)
  18470. *
  18471. * r A single precision integer.
  18472. * a A single precision integer.
  18473. */
  18474. SP_NOINLINE static void sp_256_sqr_9(sp_digit* r, const sp_digit* a)
  18475. {
  18476. int i;
  18477. int imax;
  18478. int k;
  18479. sp_uint64 c;
  18480. sp_uint64 t;
  18481. c = ((sp_uint64)a[8]) * a[8];
  18482. r[17] = (sp_digit)(c >> 29);
  18483. c = (c & 0x1fffffff) << 29;
  18484. for (k = 15; k >= 0; k--) {
  18485. i = (k + 1) / 2;
  18486. if ((k & 1) == 0) {
  18487. c += ((sp_uint64)a[i]) * a[i];
  18488. i++;
  18489. }
  18490. if (k < 8) {
  18491. imax = k;
  18492. }
  18493. else {
  18494. imax = 8;
  18495. }
  18496. t = 0;
  18497. for (; i <= imax; i++) {
  18498. t += ((sp_uint64)a[i]) * a[k - i];
  18499. }
  18500. c += t * 2;
  18501. r[k + 2] += (sp_digit) (c >> 58);
  18502. r[k + 1] = (sp_digit)((c >> 29) & 0x1fffffff);
  18503. c = (c & 0x1fffffff) << 29;
  18504. }
  18505. r[0] = (sp_digit)(c >> 29);
  18506. }
  18507. #else
  18508. /* Square a and put result in r. (r = a * a)
  18509. *
  18510. * r A single precision integer.
  18511. * a A single precision integer.
  18512. */
  18513. SP_NOINLINE static void sp_256_sqr_9(sp_digit* r, const sp_digit* a)
  18514. {
  18515. sp_int64 t0;
  18516. sp_int64 t1;
  18517. sp_digit t[9];
  18518. t0 = ((sp_int64)a[ 0]) * a[ 0];
  18519. t1 = (((sp_int64)a[ 0]) * a[ 1]) * 2;
  18520. t[ 0] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18521. t0 = (((sp_int64)a[ 0]) * a[ 2]) * 2
  18522. + ((sp_int64)a[ 1]) * a[ 1];
  18523. t[ 1] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18524. t1 = (((sp_int64)a[ 0]) * a[ 3]
  18525. + ((sp_int64)a[ 1]) * a[ 2]) * 2;
  18526. t[ 2] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18527. t0 = (((sp_int64)a[ 0]) * a[ 4]
  18528. + ((sp_int64)a[ 1]) * a[ 3]) * 2
  18529. + ((sp_int64)a[ 2]) * a[ 2];
  18530. t[ 3] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18531. t1 = (((sp_int64)a[ 0]) * a[ 5]
  18532. + ((sp_int64)a[ 1]) * a[ 4]
  18533. + ((sp_int64)a[ 2]) * a[ 3]) * 2;
  18534. t[ 4] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18535. t0 = (((sp_int64)a[ 0]) * a[ 6]
  18536. + ((sp_int64)a[ 1]) * a[ 5]
  18537. + ((sp_int64)a[ 2]) * a[ 4]) * 2
  18538. + ((sp_int64)a[ 3]) * a[ 3];
  18539. t[ 5] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18540. t1 = (((sp_int64)a[ 0]) * a[ 7]
  18541. + ((sp_int64)a[ 1]) * a[ 6]
  18542. + ((sp_int64)a[ 2]) * a[ 5]
  18543. + ((sp_int64)a[ 3]) * a[ 4]) * 2;
  18544. t[ 6] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18545. t0 = (((sp_int64)a[ 0]) * a[ 8]
  18546. + ((sp_int64)a[ 1]) * a[ 7]
  18547. + ((sp_int64)a[ 2]) * a[ 6]
  18548. + ((sp_int64)a[ 3]) * a[ 5]) * 2
  18549. + ((sp_int64)a[ 4]) * a[ 4];
  18550. t[ 7] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18551. t1 = (((sp_int64)a[ 1]) * a[ 8]
  18552. + ((sp_int64)a[ 2]) * a[ 7]
  18553. + ((sp_int64)a[ 3]) * a[ 6]
  18554. + ((sp_int64)a[ 4]) * a[ 5]) * 2;
  18555. t[ 8] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18556. t0 = (((sp_int64)a[ 2]) * a[ 8]
  18557. + ((sp_int64)a[ 3]) * a[ 7]
  18558. + ((sp_int64)a[ 4]) * a[ 6]) * 2
  18559. + ((sp_int64)a[ 5]) * a[ 5];
  18560. r[ 9] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18561. t1 = (((sp_int64)a[ 3]) * a[ 8]
  18562. + ((sp_int64)a[ 4]) * a[ 7]
  18563. + ((sp_int64)a[ 5]) * a[ 6]) * 2;
  18564. r[10] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18565. t0 = (((sp_int64)a[ 4]) * a[ 8]
  18566. + ((sp_int64)a[ 5]) * a[ 7]) * 2
  18567. + ((sp_int64)a[ 6]) * a[ 6];
  18568. r[11] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18569. t1 = (((sp_int64)a[ 5]) * a[ 8]
  18570. + ((sp_int64)a[ 6]) * a[ 7]) * 2;
  18571. r[12] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18572. t0 = (((sp_int64)a[ 6]) * a[ 8]) * 2
  18573. + ((sp_int64)a[ 7]) * a[ 7];
  18574. r[13] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18575. t1 = (((sp_int64)a[ 7]) * a[ 8]) * 2;
  18576. r[14] = t0 & 0x1fffffff; t1 += t0 >> 29;
  18577. t0 = ((sp_int64)a[ 8]) * a[ 8];
  18578. r[15] = t1 & 0x1fffffff; t0 += t1 >> 29;
  18579. r[16] = t0 & 0x1fffffff;
  18580. r[17] = (sp_digit)(t0 >> 29);
  18581. XMEMCPY(r, t, sizeof(t));
  18582. }
  18583. #endif /* WOLFSSL_SP_SMALL */
  18584. #ifdef WOLFSSL_SP_SMALL
  18585. /* Add b to a into r. (r = a + b)
  18586. *
  18587. * r A single precision integer.
  18588. * a A single precision integer.
  18589. * b A single precision integer.
  18590. */
  18591. SP_NOINLINE static int sp_256_add_9(sp_digit* r, const sp_digit* a,
  18592. const sp_digit* b)
  18593. {
  18594. int i;
  18595. for (i = 0; i < 9; i++) {
  18596. r[i] = a[i] + b[i];
  18597. }
  18598. return 0;
  18599. }
  18600. #else
  18601. /* Add b to a into r. (r = a + b)
  18602. *
  18603. * r A single precision integer.
  18604. * a A single precision integer.
  18605. * b A single precision integer.
  18606. */
  18607. SP_NOINLINE static int sp_256_add_9(sp_digit* r, const sp_digit* a,
  18608. const sp_digit* b)
  18609. {
  18610. r[ 0] = a[ 0] + b[ 0];
  18611. r[ 1] = a[ 1] + b[ 1];
  18612. r[ 2] = a[ 2] + b[ 2];
  18613. r[ 3] = a[ 3] + b[ 3];
  18614. r[ 4] = a[ 4] + b[ 4];
  18615. r[ 5] = a[ 5] + b[ 5];
  18616. r[ 6] = a[ 6] + b[ 6];
  18617. r[ 7] = a[ 7] + b[ 7];
  18618. r[ 8] = a[ 8] + b[ 8];
  18619. return 0;
  18620. }
  18621. #endif /* WOLFSSL_SP_SMALL */
  18622. #ifdef WOLFSSL_SP_SMALL
  18623. /* Sub b from a into r. (r = a - b)
  18624. *
  18625. * r A single precision integer.
  18626. * a A single precision integer.
  18627. * b A single precision integer.
  18628. */
  18629. SP_NOINLINE static int sp_256_sub_9(sp_digit* r, const sp_digit* a,
  18630. const sp_digit* b)
  18631. {
  18632. int i;
  18633. for (i = 0; i < 9; i++) {
  18634. r[i] = a[i] - b[i];
  18635. }
  18636. return 0;
  18637. }
  18638. #else
  18639. /* Sub b from a into r. (r = a - b)
  18640. *
  18641. * r A single precision integer.
  18642. * a A single precision integer.
  18643. * b A single precision integer.
  18644. */
  18645. SP_NOINLINE static int sp_256_sub_9(sp_digit* r, const sp_digit* a,
  18646. const sp_digit* b)
  18647. {
  18648. r[ 0] = a[ 0] - b[ 0];
  18649. r[ 1] = a[ 1] - b[ 1];
  18650. r[ 2] = a[ 2] - b[ 2];
  18651. r[ 3] = a[ 3] - b[ 3];
  18652. r[ 4] = a[ 4] - b[ 4];
  18653. r[ 5] = a[ 5] - b[ 5];
  18654. r[ 6] = a[ 6] - b[ 6];
  18655. r[ 7] = a[ 7] - b[ 7];
  18656. r[ 8] = a[ 8] - b[ 8];
  18657. return 0;
  18658. }
  18659. #endif /* WOLFSSL_SP_SMALL */
  18660. /* Convert an mp_int to an array of sp_digit.
  18661. *
  18662. * r A single precision integer.
  18663. * size Maximum number of bytes to convert
  18664. * a A multi-precision integer.
  18665. */
  18666. static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
  18667. {
  18668. #if DIGIT_BIT == 29
  18669. int i;
  18670. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  18671. int o = 0;
  18672. for (i = 0; i < size; i++) {
  18673. sp_digit mask = (sp_digit)0 - (j >> 28);
  18674. r[i] = a->dp[o] & mask;
  18675. j++;
  18676. o += (int)(j >> 28);
  18677. }
  18678. #elif DIGIT_BIT > 29
  18679. unsigned int i;
  18680. int j = 0;
  18681. word32 s = 0;
  18682. r[0] = 0;
  18683. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  18684. r[j] |= ((sp_digit)a->dp[i] << s);
  18685. r[j] &= 0x1fffffff;
  18686. s = 29U - s;
  18687. if (j + 1 >= size) {
  18688. break;
  18689. }
  18690. /* lint allow cast of mismatch word32 and mp_digit */
  18691. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  18692. while ((s + 29U) <= (word32)DIGIT_BIT) {
  18693. s += 29U;
  18694. r[j] &= 0x1fffffff;
  18695. if (j + 1 >= size) {
  18696. break;
  18697. }
  18698. if (s < (word32)DIGIT_BIT) {
  18699. /* lint allow cast of mismatch word32 and mp_digit */
  18700. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  18701. }
  18702. else {
  18703. r[++j] = (sp_digit)0;
  18704. }
  18705. }
  18706. s = (word32)DIGIT_BIT - s;
  18707. }
  18708. for (j++; j < size; j++) {
  18709. r[j] = 0;
  18710. }
  18711. #else
  18712. unsigned int i;
  18713. int j = 0;
  18714. int s = 0;
  18715. r[0] = 0;
  18716. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  18717. r[j] |= ((sp_digit)a->dp[i]) << s;
  18718. if (s + DIGIT_BIT >= 29) {
  18719. r[j] &= 0x1fffffff;
  18720. if (j + 1 >= size) {
  18721. break;
  18722. }
  18723. s = 29 - s;
  18724. if (s == DIGIT_BIT) {
  18725. r[++j] = 0;
  18726. s = 0;
  18727. }
  18728. else {
  18729. r[++j] = a->dp[i] >> s;
  18730. s = DIGIT_BIT - s;
  18731. }
  18732. }
  18733. else {
  18734. s += DIGIT_BIT;
  18735. }
  18736. }
  18737. for (j++; j < size; j++) {
  18738. r[j] = 0;
  18739. }
  18740. #endif
  18741. }
  18742. /* Convert a point of type ecc_point to type sp_point_256.
  18743. *
  18744. * p Point of type sp_point_256 (result).
  18745. * pm Point of type ecc_point.
  18746. */
  18747. static void sp_256_point_from_ecc_point_9(sp_point_256* p,
  18748. const ecc_point* pm)
  18749. {
  18750. XMEMSET(p->x, 0, sizeof(p->x));
  18751. XMEMSET(p->y, 0, sizeof(p->y));
  18752. XMEMSET(p->z, 0, sizeof(p->z));
  18753. sp_256_from_mp(p->x, 9, pm->x);
  18754. sp_256_from_mp(p->y, 9, pm->y);
  18755. sp_256_from_mp(p->z, 9, pm->z);
  18756. p->infinity = 0;
  18757. }
  18758. /* Convert an array of sp_digit to an mp_int.
  18759. *
  18760. * a A single precision integer.
  18761. * r A multi-precision integer.
  18762. */
  18763. static int sp_256_to_mp(const sp_digit* a, mp_int* r)
  18764. {
  18765. int err;
  18766. err = mp_grow(r, (256 + DIGIT_BIT - 1) / DIGIT_BIT);
  18767. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  18768. #if DIGIT_BIT == 29
  18769. XMEMCPY(r->dp, a, sizeof(sp_digit) * 9);
  18770. r->used = 9;
  18771. mp_clamp(r);
  18772. #elif DIGIT_BIT < 29
  18773. int i;
  18774. int j = 0;
  18775. int s = 0;
  18776. r->dp[0] = 0;
  18777. for (i = 0; i < 9; i++) {
  18778. r->dp[j] |= (mp_digit)(a[i] << s);
  18779. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  18780. s = DIGIT_BIT - s;
  18781. r->dp[++j] = (mp_digit)(a[i] >> s);
  18782. while (s + DIGIT_BIT <= 29) {
  18783. s += DIGIT_BIT;
  18784. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  18785. if (s == SP_WORD_SIZE) {
  18786. r->dp[j] = 0;
  18787. }
  18788. else {
  18789. r->dp[j] = (mp_digit)(a[i] >> s);
  18790. }
  18791. }
  18792. s = 29 - s;
  18793. }
  18794. r->used = (256 + DIGIT_BIT - 1) / DIGIT_BIT;
  18795. mp_clamp(r);
  18796. #else
  18797. int i;
  18798. int j = 0;
  18799. int s = 0;
  18800. r->dp[0] = 0;
  18801. for (i = 0; i < 9; i++) {
  18802. r->dp[j] |= ((mp_digit)a[i]) << s;
  18803. if (s + 29 >= DIGIT_BIT) {
  18804. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  18805. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  18806. #endif
  18807. s = DIGIT_BIT - s;
  18808. r->dp[++j] = a[i] >> s;
  18809. s = 29 - s;
  18810. }
  18811. else {
  18812. s += 29;
  18813. }
  18814. }
  18815. r->used = (256 + DIGIT_BIT - 1) / DIGIT_BIT;
  18816. mp_clamp(r);
  18817. #endif
  18818. }
  18819. return err;
  18820. }
  18821. /* Convert a point of type sp_point_256 to type ecc_point.
  18822. *
  18823. * p Point of type sp_point_256.
  18824. * pm Point of type ecc_point (result).
  18825. * returns MEMORY_E when allocation of memory in ecc_point fails otherwise
  18826. * MP_OKAY.
  18827. */
  18828. static int sp_256_point_to_ecc_point_9(const sp_point_256* p, ecc_point* pm)
  18829. {
  18830. int err;
  18831. err = sp_256_to_mp(p->x, pm->x);
  18832. if (err == MP_OKAY) {
  18833. err = sp_256_to_mp(p->y, pm->y);
  18834. }
  18835. if (err == MP_OKAY) {
  18836. err = sp_256_to_mp(p->z, pm->z);
  18837. }
  18838. return err;
  18839. }
  18840. /* Compare a with b in constant time.
  18841. *
  18842. * a A single precision integer.
  18843. * b A single precision integer.
  18844. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  18845. * respectively.
  18846. */
  18847. static sp_digit sp_256_cmp_9(const sp_digit* a, const sp_digit* b)
  18848. {
  18849. sp_digit r = 0;
  18850. #ifdef WOLFSSL_SP_SMALL
  18851. int i;
  18852. for (i=8; i>=0; i--) {
  18853. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 28);
  18854. }
  18855. #else
  18856. r |= (a[ 8] - b[ 8]) & (0 - (sp_digit)1);
  18857. r |= (a[ 7] - b[ 7]) & ~(((sp_digit)0 - r) >> 28);
  18858. r |= (a[ 6] - b[ 6]) & ~(((sp_digit)0 - r) >> 28);
  18859. r |= (a[ 5] - b[ 5]) & ~(((sp_digit)0 - r) >> 28);
  18860. r |= (a[ 4] - b[ 4]) & ~(((sp_digit)0 - r) >> 28);
  18861. r |= (a[ 3] - b[ 3]) & ~(((sp_digit)0 - r) >> 28);
  18862. r |= (a[ 2] - b[ 2]) & ~(((sp_digit)0 - r) >> 28);
  18863. r |= (a[ 1] - b[ 1]) & ~(((sp_digit)0 - r) >> 28);
  18864. r |= (a[ 0] - b[ 0]) & ~(((sp_digit)0 - r) >> 28);
  18865. #endif /* WOLFSSL_SP_SMALL */
  18866. return r;
  18867. }
  18868. /* Conditionally subtract b from a using the mask m.
  18869. * m is -1 to subtract and 0 when not.
  18870. *
  18871. * r A single precision number representing condition subtract result.
  18872. * a A single precision number to subtract from.
  18873. * b A single precision number to subtract.
  18874. * m Mask value to apply.
  18875. */
  18876. static void sp_256_cond_sub_9(sp_digit* r, const sp_digit* a,
  18877. const sp_digit* b, const sp_digit m)
  18878. {
  18879. #ifdef WOLFSSL_SP_SMALL
  18880. int i;
  18881. for (i = 0; i < 9; i++) {
  18882. r[i] = a[i] - (b[i] & m);
  18883. }
  18884. #else
  18885. r[ 0] = a[ 0] - (b[ 0] & m);
  18886. r[ 1] = a[ 1] - (b[ 1] & m);
  18887. r[ 2] = a[ 2] - (b[ 2] & m);
  18888. r[ 3] = a[ 3] - (b[ 3] & m);
  18889. r[ 4] = a[ 4] - (b[ 4] & m);
  18890. r[ 5] = a[ 5] - (b[ 5] & m);
  18891. r[ 6] = a[ 6] - (b[ 6] & m);
  18892. r[ 7] = a[ 7] - (b[ 7] & m);
  18893. r[ 8] = a[ 8] - (b[ 8] & m);
  18894. #endif /* WOLFSSL_SP_SMALL */
  18895. }
  18896. /* Mul a by scalar b and add into r. (r += a * b)
  18897. *
  18898. * r A single precision integer.
  18899. * a A single precision integer.
  18900. * b A scalar.
  18901. */
  18902. SP_NOINLINE static void sp_256_mul_add_9(sp_digit* r, const sp_digit* a,
  18903. const sp_digit b)
  18904. {
  18905. #ifndef WOLFSSL_SP_LARGE_CODE
  18906. sp_int64 tb = b;
  18907. sp_int64 t = 0;
  18908. int i;
  18909. for (i = 0; i < 9; i++) {
  18910. t += r[i];
  18911. t += tb * a[i];
  18912. r[i] = ((sp_digit)t) & 0x1fffffff;
  18913. t >>= 29;
  18914. }
  18915. r[9] += (sp_digit)t;
  18916. #else
  18917. #ifdef WOLFSSL_SP_SMALL
  18918. sp_int64 tb = b;
  18919. sp_int64 t[4];
  18920. int i;
  18921. t[0] = 0;
  18922. for (i = 0; i < 8; i += 4) {
  18923. t[0] += (tb * a[i+0]) + r[i+0];
  18924. t[1] = (tb * a[i+1]) + r[i+1];
  18925. t[2] = (tb * a[i+2]) + r[i+2];
  18926. t[3] = (tb * a[i+3]) + r[i+3];
  18927. r[i+0] = t[0] & 0x1fffffff;
  18928. t[1] += t[0] >> 29;
  18929. r[i+1] = t[1] & 0x1fffffff;
  18930. t[2] += t[1] >> 29;
  18931. r[i+2] = t[2] & 0x1fffffff;
  18932. t[3] += t[2] >> 29;
  18933. r[i+3] = t[3] & 0x1fffffff;
  18934. t[0] = t[3] >> 29;
  18935. }
  18936. t[0] += (tb * a[8]) + r[8];
  18937. r[8] = t[0] & 0x1fffffff;
  18938. r[9] += (sp_digit)(t[0] >> 29);
  18939. #else
  18940. sp_int64 tb = b;
  18941. sp_int64 t[8];
  18942. int i;
  18943. t[0] = 0;
  18944. for (i = 0; i < 8; i += 8) {
  18945. t[0] += (tb * a[i+0]) + r[i+0];
  18946. t[1] = (tb * a[i+1]) + r[i+1];
  18947. t[2] = (tb * a[i+2]) + r[i+2];
  18948. t[3] = (tb * a[i+3]) + r[i+3];
  18949. t[4] = (tb * a[i+4]) + r[i+4];
  18950. t[5] = (tb * a[i+5]) + r[i+5];
  18951. t[6] = (tb * a[i+6]) + r[i+6];
  18952. t[7] = (tb * a[i+7]) + r[i+7];
  18953. r[i+0] = t[0] & 0x1fffffff;
  18954. t[1] += t[0] >> 29;
  18955. r[i+1] = t[1] & 0x1fffffff;
  18956. t[2] += t[1] >> 29;
  18957. r[i+2] = t[2] & 0x1fffffff;
  18958. t[3] += t[2] >> 29;
  18959. r[i+3] = t[3] & 0x1fffffff;
  18960. t[4] += t[3] >> 29;
  18961. r[i+4] = t[4] & 0x1fffffff;
  18962. t[5] += t[4] >> 29;
  18963. r[i+5] = t[5] & 0x1fffffff;
  18964. t[6] += t[5] >> 29;
  18965. r[i+6] = t[6] & 0x1fffffff;
  18966. t[7] += t[6] >> 29;
  18967. r[i+7] = t[7] & 0x1fffffff;
  18968. t[0] = t[7] >> 29;
  18969. }
  18970. t[0] += (tb * a[8]) + r[8];
  18971. r[8] = t[0] & 0x1fffffff;
  18972. r[9] += (sp_digit)(t[0] >> 29);
  18973. #endif /* WOLFSSL_SP_SMALL */
  18974. #endif /* !WOLFSSL_SP_LARGE_CODE */
  18975. }
  18976. /* Normalize the values in each word to 29 bits.
  18977. *
  18978. * a Array of sp_digit to normalize.
  18979. */
  18980. static void sp_256_norm_9(sp_digit* a)
  18981. {
  18982. #ifdef WOLFSSL_SP_SMALL
  18983. int i;
  18984. for (i = 0; i < 8; i++) {
  18985. a[i+1] += a[i] >> 29;
  18986. a[i] &= 0x1fffffff;
  18987. }
  18988. #else
  18989. a[1] += a[0] >> 29; a[0] &= 0x1fffffff;
  18990. a[2] += a[1] >> 29; a[1] &= 0x1fffffff;
  18991. a[3] += a[2] >> 29; a[2] &= 0x1fffffff;
  18992. a[4] += a[3] >> 29; a[3] &= 0x1fffffff;
  18993. a[5] += a[4] >> 29; a[4] &= 0x1fffffff;
  18994. a[6] += a[5] >> 29; a[5] &= 0x1fffffff;
  18995. a[7] += a[6] >> 29; a[6] &= 0x1fffffff;
  18996. a[8] += a[7] >> 29; a[7] &= 0x1fffffff;
  18997. #endif /* WOLFSSL_SP_SMALL */
  18998. }
  18999. /* Shift the result in the high 256 bits down to the bottom.
  19000. *
  19001. * r A single precision number.
  19002. * a A single precision number.
  19003. */
  19004. static void sp_256_mont_shift_9(sp_digit* r, const sp_digit* a)
  19005. {
  19006. #ifdef WOLFSSL_SP_SMALL
  19007. int i;
  19008. sp_int64 n = a[8] >> 24;
  19009. n += ((sp_int64)a[9]) << 5;
  19010. for (i = 0; i < 8; i++) {
  19011. r[i] = n & 0x1fffffff;
  19012. n >>= 29;
  19013. n += ((sp_int64)a[10 + i]) << 5;
  19014. }
  19015. r[8] = (sp_digit)n;
  19016. #else
  19017. sp_int64 n = a[8] >> 24;
  19018. n += ((sp_int64)a[9]) << 5;
  19019. r[ 0] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[10]) << 5;
  19020. r[ 1] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[11]) << 5;
  19021. r[ 2] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[12]) << 5;
  19022. r[ 3] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[13]) << 5;
  19023. r[ 4] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[14]) << 5;
  19024. r[ 5] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[15]) << 5;
  19025. r[ 6] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[16]) << 5;
  19026. r[ 7] = n & 0x1fffffff; n >>= 29; n += ((sp_int64)a[17]) << 5;
  19027. r[8] = (sp_digit)n;
  19028. #endif /* WOLFSSL_SP_SMALL */
  19029. XMEMSET(&r[9], 0, sizeof(*r) * 9U);
  19030. }
  19031. /* Reduce the number back to 256 bits using Montgomery reduction.
  19032. *
  19033. * a A single precision number to reduce in place.
  19034. * m The single precision number representing the modulus.
  19035. * mp The digit representing the negative inverse of m mod 2^n.
  19036. */
  19037. static void sp_256_mont_reduce_order_9(sp_digit* a, const sp_digit* m, sp_digit mp)
  19038. {
  19039. int i;
  19040. sp_digit mu;
  19041. sp_digit over;
  19042. sp_256_norm_9(a + 9);
  19043. for (i=0; i<8; i++) {
  19044. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffff;
  19045. sp_256_mul_add_9(a+i, m, mu);
  19046. a[i+1] += a[i] >> 29;
  19047. }
  19048. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xffffffL;
  19049. sp_256_mul_add_9(a+i, m, mu);
  19050. a[i+1] += a[i] >> 29;
  19051. a[i] &= 0x1fffffff;
  19052. sp_256_mont_shift_9(a, a);
  19053. over = a[8] >> 24;
  19054. sp_256_cond_sub_9(a, a, m, ~((over - 1) >> 31));
  19055. sp_256_norm_9(a);
  19056. }
  19057. /* Reduce the number back to 256 bits using Montgomery reduction.
  19058. *
  19059. * a A single precision number to reduce in place.
  19060. * m The single precision number representing the modulus.
  19061. * mp The digit representing the negative inverse of m mod 2^n.
  19062. */
  19063. static void sp_256_mont_reduce_9(sp_digit* a, const sp_digit* m, sp_digit mp)
  19064. {
  19065. int i;
  19066. sp_digit am;
  19067. (void)m;
  19068. (void)mp;
  19069. for (i = 0; i < 8; i++) {
  19070. am = a[i] & 0x1fffffff;
  19071. a[i + 3] += (am << 9) & 0x1fffffff;
  19072. a[i + 4] += am >> 20;
  19073. a[i + 6] += (am << 18) & 0x1fffffff;
  19074. a[i + 7] += (am >> 11) - ((am << 21) & 0x1fffffff);
  19075. a[i + 8] += -(am >> 8) + ((am << 24) & 0x1fffffff);
  19076. a[i + 9] += am >> 5;
  19077. a[i + 1] += a[i] >> 29;
  19078. }
  19079. am = a[8] & 0xffffff;
  19080. a[8 + 3] += (am << 9) & 0x1fffffff;
  19081. a[8 + 4] += am >> 20;
  19082. a[8 + 6] += (am << 18) & 0x1fffffff;
  19083. a[8 + 7] += (am >> 11) - ((am << 21) & 0x1fffffff);
  19084. a[8 + 8] += -(am >> 8) + ((am << 24) & 0x1fffffff);
  19085. a[8 + 9] += am >> 5;
  19086. a[0] = (a[ 8] >> 24) + ((a[ 9] << 5) & 0x1fffffff);
  19087. a[1] = (a[ 9] >> 24) + ((a[10] << 5) & 0x1fffffff);
  19088. a[2] = (a[10] >> 24) + ((a[11] << 5) & 0x1fffffff);
  19089. a[3] = (a[11] >> 24) + ((a[12] << 5) & 0x1fffffff);
  19090. a[4] = (a[12] >> 24) + ((a[13] << 5) & 0x1fffffff);
  19091. a[5] = (a[13] >> 24) + ((a[14] << 5) & 0x1fffffff);
  19092. a[6] = (a[14] >> 24) + ((a[15] << 5) & 0x1fffffff);
  19093. a[7] = (a[15] >> 24) + ((a[16] << 5) & 0x1fffffff);
  19094. a[8] = (a[16] >> 24) + (a[17] << 5);
  19095. a[1] += a[0] >> 29; a[0] &= 0x1fffffff;
  19096. a[2] += a[1] >> 29; a[1] &= 0x1fffffff;
  19097. a[3] += a[2] >> 29; a[2] &= 0x1fffffff;
  19098. a[4] += a[3] >> 29; a[3] &= 0x1fffffff;
  19099. a[5] += a[4] >> 29; a[4] &= 0x1fffffff;
  19100. a[6] += a[5] >> 29; a[5] &= 0x1fffffff;
  19101. a[7] += a[6] >> 29; a[6] &= 0x1fffffff;
  19102. a[8] += a[7] >> 29; a[7] &= 0x1fffffff;
  19103. /* Get the bit over, if any. */
  19104. am = a[8] >> 24;
  19105. /* Create mask. */
  19106. am = 0 - am;
  19107. a[0] -= 0x1fffffff & am;
  19108. a[1] -= 0x1fffffff & am;
  19109. a[2] -= 0x1fffffff & am;
  19110. a[3] -= 0x000001ff & am;
  19111. /* p256_mod[4] is zero */
  19112. /* p256_mod[5] is zero */
  19113. a[6] -= 0x00040000 & am;
  19114. a[7] -= 0x1fe00000 & am;
  19115. a[8] -= 0x00ffffff & am;
  19116. a[1] += a[0] >> 29; a[0] &= 0x1fffffff;
  19117. a[2] += a[1] >> 29; a[1] &= 0x1fffffff;
  19118. a[3] += a[2] >> 29; a[2] &= 0x1fffffff;
  19119. a[4] += a[3] >> 29; a[3] &= 0x1fffffff;
  19120. a[5] += a[4] >> 29; a[4] &= 0x1fffffff;
  19121. a[6] += a[5] >> 29; a[5] &= 0x1fffffff;
  19122. a[7] += a[6] >> 29; a[6] &= 0x1fffffff;
  19123. a[8] += a[7] >> 29; a[7] &= 0x1fffffff;
  19124. }
  19125. /* Multiply two Montgomery form numbers mod the modulus (prime).
  19126. * (r = a * b mod m)
  19127. *
  19128. * r Result of multiplication.
  19129. * a First number to multiply in Montgomery form.
  19130. * b Second number to multiply in Montgomery form.
  19131. * m Modulus (prime).
  19132. * mp Montgomery multiplier.
  19133. */
  19134. SP_NOINLINE static void sp_256_mont_mul_9(sp_digit* r, const sp_digit* a,
  19135. const sp_digit* b, const sp_digit* m, sp_digit mp)
  19136. {
  19137. sp_256_mul_9(r, a, b);
  19138. sp_256_mont_reduce_9(r, m, mp);
  19139. }
  19140. /* Square the Montgomery form number. (r = a * a mod m)
  19141. *
  19142. * r Result of squaring.
  19143. * a Number to square in Montgomery form.
  19144. * m Modulus (prime).
  19145. * mp Montgomery multiplier.
  19146. */
  19147. SP_NOINLINE static void sp_256_mont_sqr_9(sp_digit* r, const sp_digit* a,
  19148. const sp_digit* m, sp_digit mp)
  19149. {
  19150. sp_256_sqr_9(r, a);
  19151. sp_256_mont_reduce_9(r, m, mp);
  19152. }
  19153. #if !defined(WOLFSSL_SP_SMALL) || defined(HAVE_COMP_KEY)
  19154. /* Square the Montgomery form number a number of times. (r = a ^ n mod m)
  19155. *
  19156. * r Result of squaring.
  19157. * a Number to square in Montgomery form.
  19158. * n Number of times to square.
  19159. * m Modulus (prime).
  19160. * mp Montgomery multiplier.
  19161. */
  19162. SP_NOINLINE static void sp_256_mont_sqr_n_9(sp_digit* r,
  19163. const sp_digit* a, int n, const sp_digit* m, sp_digit mp)
  19164. {
  19165. sp_256_mont_sqr_9(r, a, m, mp);
  19166. for (; n > 1; n--) {
  19167. sp_256_mont_sqr_9(r, r, m, mp);
  19168. }
  19169. }
  19170. #endif /* !WOLFSSL_SP_SMALL || HAVE_COMP_KEY */
  19171. #ifdef WOLFSSL_SP_SMALL
  19172. /* Mod-2 for the P256 curve. */
  19173. static const uint32_t p256_mod_minus_2[8] = {
  19174. 0xfffffffdU,0xffffffffU,0xffffffffU,0x00000000U,0x00000000U,0x00000000U,
  19175. 0x00000001U,0xffffffffU
  19176. };
  19177. #endif /* !WOLFSSL_SP_SMALL */
  19178. /* Invert the number, in Montgomery form, modulo the modulus (prime) of the
  19179. * P256 curve. (r = 1 / a mod m)
  19180. *
  19181. * r Inverse result.
  19182. * a Number to invert.
  19183. * td Temporary data.
  19184. */
  19185. static void sp_256_mont_inv_9(sp_digit* r, const sp_digit* a, sp_digit* td)
  19186. {
  19187. #ifdef WOLFSSL_SP_SMALL
  19188. sp_digit* t = td;
  19189. int i;
  19190. XMEMCPY(t, a, sizeof(sp_digit) * 9);
  19191. for (i=254; i>=0; i--) {
  19192. sp_256_mont_sqr_9(t, t, p256_mod, p256_mp_mod);
  19193. if (p256_mod_minus_2[i / 32] & ((sp_digit)1 << (i % 32)))
  19194. sp_256_mont_mul_9(t, t, a, p256_mod, p256_mp_mod);
  19195. }
  19196. XMEMCPY(r, t, sizeof(sp_digit) * 9);
  19197. #else
  19198. sp_digit* t1 = td;
  19199. sp_digit* t2 = td + 2 * 9;
  19200. sp_digit* t3 = td + 4 * 9;
  19201. /* 0x2 */
  19202. sp_256_mont_sqr_9(t1, a, p256_mod, p256_mp_mod);
  19203. /* 0x3 */
  19204. sp_256_mont_mul_9(t2, t1, a, p256_mod, p256_mp_mod);
  19205. /* 0xc */
  19206. sp_256_mont_sqr_n_9(t1, t2, 2, p256_mod, p256_mp_mod);
  19207. /* 0xd */
  19208. sp_256_mont_mul_9(t3, t1, a, p256_mod, p256_mp_mod);
  19209. /* 0xf */
  19210. sp_256_mont_mul_9(t2, t2, t1, p256_mod, p256_mp_mod);
  19211. /* 0xf0 */
  19212. sp_256_mont_sqr_n_9(t1, t2, 4, p256_mod, p256_mp_mod);
  19213. /* 0xfd */
  19214. sp_256_mont_mul_9(t3, t3, t1, p256_mod, p256_mp_mod);
  19215. /* 0xff */
  19216. sp_256_mont_mul_9(t2, t2, t1, p256_mod, p256_mp_mod);
  19217. /* 0xff00 */
  19218. sp_256_mont_sqr_n_9(t1, t2, 8, p256_mod, p256_mp_mod);
  19219. /* 0xfffd */
  19220. sp_256_mont_mul_9(t3, t3, t1, p256_mod, p256_mp_mod);
  19221. /* 0xffff */
  19222. sp_256_mont_mul_9(t2, t2, t1, p256_mod, p256_mp_mod);
  19223. /* 0xffff0000 */
  19224. sp_256_mont_sqr_n_9(t1, t2, 16, p256_mod, p256_mp_mod);
  19225. /* 0xfffffffd */
  19226. sp_256_mont_mul_9(t3, t3, t1, p256_mod, p256_mp_mod);
  19227. /* 0xffffffff */
  19228. sp_256_mont_mul_9(t2, t2, t1, p256_mod, p256_mp_mod);
  19229. /* 0xffffffff00000000 */
  19230. sp_256_mont_sqr_n_9(t1, t2, 32, p256_mod, p256_mp_mod);
  19231. /* 0xffffffffffffffff */
  19232. sp_256_mont_mul_9(t2, t2, t1, p256_mod, p256_mp_mod);
  19233. /* 0xffffffff00000001 */
  19234. sp_256_mont_mul_9(r, t1, a, p256_mod, p256_mp_mod);
  19235. /* 0xffffffff000000010000000000000000000000000000000000000000 */
  19236. sp_256_mont_sqr_n_9(r, r, 160, p256_mod, p256_mp_mod);
  19237. /* 0xffffffff00000001000000000000000000000000ffffffffffffffff */
  19238. sp_256_mont_mul_9(r, r, t2, p256_mod, p256_mp_mod);
  19239. /* 0xffffffff00000001000000000000000000000000ffffffffffffffff00000000 */
  19240. sp_256_mont_sqr_n_9(r, r, 32, p256_mod, p256_mp_mod);
  19241. /* 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffd */
  19242. sp_256_mont_mul_9(r, r, t3, p256_mod, p256_mp_mod);
  19243. #endif /* WOLFSSL_SP_SMALL */
  19244. }
  19245. /* Map the Montgomery form projective coordinate point to an affine point.
  19246. *
  19247. * r Resulting affine coordinate point.
  19248. * p Montgomery form projective coordinate point.
  19249. * t Temporary ordinate data.
  19250. */
  19251. static void sp_256_map_9(sp_point_256* r, const sp_point_256* p,
  19252. sp_digit* t)
  19253. {
  19254. sp_digit* t1 = t;
  19255. sp_digit* t2 = t + 2*9;
  19256. sp_int32 n;
  19257. sp_256_mont_inv_9(t1, p->z, t + 2*9);
  19258. sp_256_mont_sqr_9(t2, t1, p256_mod, p256_mp_mod);
  19259. sp_256_mont_mul_9(t1, t2, t1, p256_mod, p256_mp_mod);
  19260. /* x /= z^2 */
  19261. sp_256_mont_mul_9(r->x, p->x, t2, p256_mod, p256_mp_mod);
  19262. XMEMSET(r->x + 9, 0, sizeof(sp_digit) * 9U);
  19263. sp_256_mont_reduce_9(r->x, p256_mod, p256_mp_mod);
  19264. /* Reduce x to less than modulus */
  19265. n = sp_256_cmp_9(r->x, p256_mod);
  19266. sp_256_cond_sub_9(r->x, r->x, p256_mod, ~(n >> 28));
  19267. sp_256_norm_9(r->x);
  19268. /* y /= z^3 */
  19269. sp_256_mont_mul_9(r->y, p->y, t1, p256_mod, p256_mp_mod);
  19270. XMEMSET(r->y + 9, 0, sizeof(sp_digit) * 9U);
  19271. sp_256_mont_reduce_9(r->y, p256_mod, p256_mp_mod);
  19272. /* Reduce y to less than modulus */
  19273. n = sp_256_cmp_9(r->y, p256_mod);
  19274. sp_256_cond_sub_9(r->y, r->y, p256_mod, ~(n >> 28));
  19275. sp_256_norm_9(r->y);
  19276. XMEMSET(r->z, 0, sizeof(r->z) / 2);
  19277. r->z[0] = 1;
  19278. }
  19279. /* Add two Montgomery form numbers (r = a + b % m).
  19280. *
  19281. * r Result of addition.
  19282. * a First number to add in Montgomery form.
  19283. * b Second number to add in Montgomery form.
  19284. * m Modulus (prime).
  19285. */
  19286. static void sp_256_mont_add_9(sp_digit* r, const sp_digit* a, const sp_digit* b,
  19287. const sp_digit* m)
  19288. {
  19289. sp_digit over;
  19290. (void)sp_256_add_9(r, a, b);
  19291. sp_256_norm_9(r);
  19292. over = r[8] >> 24;
  19293. sp_256_cond_sub_9(r, r, m, ~((over - 1) >> 31));
  19294. sp_256_norm_9(r);
  19295. }
  19296. /* Double a Montgomery form number (r = a + a % m).
  19297. *
  19298. * r Result of doubling.
  19299. * a Number to double in Montgomery form.
  19300. * m Modulus (prime).
  19301. */
  19302. static void sp_256_mont_dbl_9(sp_digit* r, const sp_digit* a, const sp_digit* m)
  19303. {
  19304. sp_digit over;
  19305. (void)sp_256_add_9(r, a, a);
  19306. sp_256_norm_9(r);
  19307. over = r[8] >> 24;
  19308. sp_256_cond_sub_9(r, r, m, ~((over - 1) >> 31));
  19309. sp_256_norm_9(r);
  19310. }
  19311. /* Triple a Montgomery form number (r = a + a + a % m).
  19312. *
  19313. * r Result of Tripling.
  19314. * a Number to triple in Montgomery form.
  19315. * m Modulus (prime).
  19316. */
  19317. static void sp_256_mont_tpl_9(sp_digit* r, const sp_digit* a, const sp_digit* m)
  19318. {
  19319. sp_digit over;
  19320. (void)sp_256_add_9(r, a, a);
  19321. sp_256_norm_9(r);
  19322. over = r[8] >> 24;
  19323. sp_256_cond_sub_9(r, r, m, ~((over - 1) >> 31));
  19324. sp_256_norm_9(r);
  19325. (void)sp_256_add_9(r, r, a);
  19326. sp_256_norm_9(r);
  19327. over = r[8] >> 24;
  19328. sp_256_cond_sub_9(r, r, m, ~((over - 1) >> 31));
  19329. sp_256_norm_9(r);
  19330. }
  19331. #ifdef WOLFSSL_SP_SMALL
  19332. /* Conditionally add a and b using the mask m.
  19333. * m is -1 to add and 0 when not.
  19334. *
  19335. * r A single precision number representing conditional add result.
  19336. * a A single precision number to add with.
  19337. * b A single precision number to add.
  19338. * m Mask value to apply.
  19339. */
  19340. static void sp_256_cond_add_9(sp_digit* r, const sp_digit* a,
  19341. const sp_digit* b, const sp_digit m)
  19342. {
  19343. int i;
  19344. for (i = 0; i < 9; i++) {
  19345. r[i] = a[i] + (b[i] & m);
  19346. }
  19347. }
  19348. #endif /* WOLFSSL_SP_SMALL */
  19349. #ifndef WOLFSSL_SP_SMALL
  19350. /* Conditionally add a and b using the mask m.
  19351. * m is -1 to add and 0 when not.
  19352. *
  19353. * r A single precision number representing conditional add result.
  19354. * a A single precision number to add with.
  19355. * b A single precision number to add.
  19356. * m Mask value to apply.
  19357. */
  19358. static void sp_256_cond_add_9(sp_digit* r, const sp_digit* a,
  19359. const sp_digit* b, const sp_digit m)
  19360. {
  19361. r[ 0] = a[ 0] + (b[ 0] & m);
  19362. r[ 1] = a[ 1] + (b[ 1] & m);
  19363. r[ 2] = a[ 2] + (b[ 2] & m);
  19364. r[ 3] = a[ 3] + (b[ 3] & m);
  19365. r[ 4] = a[ 4] + (b[ 4] & m);
  19366. r[ 5] = a[ 5] + (b[ 5] & m);
  19367. r[ 6] = a[ 6] + (b[ 6] & m);
  19368. r[ 7] = a[ 7] + (b[ 7] & m);
  19369. r[ 8] = a[ 8] + (b[ 8] & m);
  19370. }
  19371. #endif /* !WOLFSSL_SP_SMALL */
  19372. /* Subtract two Montgomery form numbers (r = a - b % m).
  19373. *
  19374. * r Result of subtration.
  19375. * a Number to subtract from in Montgomery form.
  19376. * b Number to subtract with in Montgomery form.
  19377. * m Modulus (prime).
  19378. */
  19379. static void sp_256_mont_sub_9(sp_digit* r, const sp_digit* a, const sp_digit* b,
  19380. const sp_digit* m)
  19381. {
  19382. (void)sp_256_sub_9(r, a, b);
  19383. sp_256_norm_9(r);
  19384. sp_256_cond_add_9(r, r, m, r[8] >> 24);
  19385. sp_256_norm_9(r);
  19386. }
  19387. /* Shift number left one bit.
  19388. * Bottom bit is lost.
  19389. *
  19390. * r Result of shift.
  19391. * a Number to shift.
  19392. */
  19393. SP_NOINLINE static void sp_256_rshift1_9(sp_digit* r, const sp_digit* a)
  19394. {
  19395. #ifdef WOLFSSL_SP_SMALL
  19396. int i;
  19397. for (i=0; i<8; i++) {
  19398. r[i] = (a[i] >> 1) + ((a[i + 1] << 28) & 0x1fffffff);
  19399. }
  19400. #else
  19401. r[0] = (a[0] >> 1) + ((a[1] << 28) & 0x1fffffff);
  19402. r[1] = (a[1] >> 1) + ((a[2] << 28) & 0x1fffffff);
  19403. r[2] = (a[2] >> 1) + ((a[3] << 28) & 0x1fffffff);
  19404. r[3] = (a[3] >> 1) + ((a[4] << 28) & 0x1fffffff);
  19405. r[4] = (a[4] >> 1) + ((a[5] << 28) & 0x1fffffff);
  19406. r[5] = (a[5] >> 1) + ((a[6] << 28) & 0x1fffffff);
  19407. r[6] = (a[6] >> 1) + ((a[7] << 28) & 0x1fffffff);
  19408. r[7] = (a[7] >> 1) + ((a[8] << 28) & 0x1fffffff);
  19409. #endif
  19410. r[8] = a[8] >> 1;
  19411. }
  19412. /* Divide the number by 2 mod the modulus (prime). (r = a / 2 % m)
  19413. *
  19414. * r Result of division by 2.
  19415. * a Number to divide.
  19416. * m Modulus (prime).
  19417. */
  19418. static void sp_256_mont_div2_9(sp_digit* r, const sp_digit* a,
  19419. const sp_digit* m)
  19420. {
  19421. sp_256_cond_add_9(r, a, m, 0 - (a[0] & 1));
  19422. sp_256_norm_9(r);
  19423. sp_256_rshift1_9(r, r);
  19424. }
  19425. /* Double the Montgomery form projective point p.
  19426. *
  19427. * r Result of doubling point.
  19428. * p Point to double.
  19429. * t Temporary ordinate data.
  19430. */
  19431. static void sp_256_proj_point_dbl_9(sp_point_256* r, const sp_point_256* p,
  19432. sp_digit* t)
  19433. {
  19434. sp_digit* t1 = t;
  19435. sp_digit* t2 = t + 2*9;
  19436. sp_digit* x;
  19437. sp_digit* y;
  19438. sp_digit* z;
  19439. x = r->x;
  19440. y = r->y;
  19441. z = r->z;
  19442. /* Put infinity into result. */
  19443. if (r != p) {
  19444. r->infinity = p->infinity;
  19445. }
  19446. /* T1 = Z * Z */
  19447. sp_256_mont_sqr_9(t1, p->z, p256_mod, p256_mp_mod);
  19448. /* Z = Y * Z */
  19449. sp_256_mont_mul_9(z, p->y, p->z, p256_mod, p256_mp_mod);
  19450. /* Z = 2Z */
  19451. sp_256_mont_dbl_9(z, z, p256_mod);
  19452. /* T2 = X - T1 */
  19453. sp_256_mont_sub_9(t2, p->x, t1, p256_mod);
  19454. /* T1 = X + T1 */
  19455. sp_256_mont_add_9(t1, p->x, t1, p256_mod);
  19456. /* T2 = T1 * T2 */
  19457. sp_256_mont_mul_9(t2, t1, t2, p256_mod, p256_mp_mod);
  19458. /* T1 = 3T2 */
  19459. sp_256_mont_tpl_9(t1, t2, p256_mod);
  19460. /* Y = 2Y */
  19461. sp_256_mont_dbl_9(y, p->y, p256_mod);
  19462. /* Y = Y * Y */
  19463. sp_256_mont_sqr_9(y, y, p256_mod, p256_mp_mod);
  19464. /* T2 = Y * Y */
  19465. sp_256_mont_sqr_9(t2, y, p256_mod, p256_mp_mod);
  19466. /* T2 = T2/2 */
  19467. sp_256_mont_div2_9(t2, t2, p256_mod);
  19468. /* Y = Y * X */
  19469. sp_256_mont_mul_9(y, y, p->x, p256_mod, p256_mp_mod);
  19470. /* X = T1 * T1 */
  19471. sp_256_mont_sqr_9(x, t1, p256_mod, p256_mp_mod);
  19472. /* X = X - Y */
  19473. sp_256_mont_sub_9(x, x, y, p256_mod);
  19474. /* X = X - Y */
  19475. sp_256_mont_sub_9(x, x, y, p256_mod);
  19476. /* Y = Y - X */
  19477. sp_256_mont_sub_9(y, y, x, p256_mod);
  19478. /* Y = Y * T1 */
  19479. sp_256_mont_mul_9(y, y, t1, p256_mod, p256_mp_mod);
  19480. /* Y = Y - T2 */
  19481. sp_256_mont_sub_9(y, y, t2, p256_mod);
  19482. }
  19483. #ifdef WOLFSSL_SP_NONBLOCK
  19484. typedef struct sp_256_proj_point_dbl_9_ctx {
  19485. int state;
  19486. sp_digit* t1;
  19487. sp_digit* t2;
  19488. sp_digit* x;
  19489. sp_digit* y;
  19490. sp_digit* z;
  19491. } sp_256_proj_point_dbl_9_ctx;
  19492. /* Double the Montgomery form projective point p.
  19493. *
  19494. * r Result of doubling point.
  19495. * p Point to double.
  19496. * t Temporary ordinate data.
  19497. */
  19498. static int sp_256_proj_point_dbl_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
  19499. const sp_point_256* p, sp_digit* t)
  19500. {
  19501. int err = FP_WOULDBLOCK;
  19502. sp_256_proj_point_dbl_9_ctx* ctx = (sp_256_proj_point_dbl_9_ctx*)sp_ctx->data;
  19503. typedef char ctx_size_test[sizeof(sp_256_proj_point_dbl_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  19504. (void)sizeof(ctx_size_test);
  19505. switch (ctx->state) {
  19506. case 0:
  19507. ctx->t1 = t;
  19508. ctx->t2 = t + 2*9;
  19509. ctx->x = r->x;
  19510. ctx->y = r->y;
  19511. ctx->z = r->z;
  19512. /* Put infinity into result. */
  19513. if (r != p) {
  19514. r->infinity = p->infinity;
  19515. }
  19516. ctx->state = 1;
  19517. break;
  19518. case 1:
  19519. /* T1 = Z * Z */
  19520. sp_256_mont_sqr_9(ctx->t1, p->z, p256_mod, p256_mp_mod);
  19521. ctx->state = 2;
  19522. break;
  19523. case 2:
  19524. /* Z = Y * Z */
  19525. sp_256_mont_mul_9(ctx->z, p->y, p->z, p256_mod, p256_mp_mod);
  19526. ctx->state = 3;
  19527. break;
  19528. case 3:
  19529. /* Z = 2Z */
  19530. sp_256_mont_dbl_9(ctx->z, ctx->z, p256_mod);
  19531. ctx->state = 4;
  19532. break;
  19533. case 4:
  19534. /* T2 = X - T1 */
  19535. sp_256_mont_sub_9(ctx->t2, p->x, ctx->t1, p256_mod);
  19536. ctx->state = 5;
  19537. break;
  19538. case 5:
  19539. /* T1 = X + T1 */
  19540. sp_256_mont_add_9(ctx->t1, p->x, ctx->t1, p256_mod);
  19541. ctx->state = 6;
  19542. break;
  19543. case 6:
  19544. /* T2 = T1 * T2 */
  19545. sp_256_mont_mul_9(ctx->t2, ctx->t1, ctx->t2, p256_mod, p256_mp_mod);
  19546. ctx->state = 7;
  19547. break;
  19548. case 7:
  19549. /* T1 = 3T2 */
  19550. sp_256_mont_tpl_9(ctx->t1, ctx->t2, p256_mod);
  19551. ctx->state = 8;
  19552. break;
  19553. case 8:
  19554. /* Y = 2Y */
  19555. sp_256_mont_dbl_9(ctx->y, p->y, p256_mod);
  19556. ctx->state = 9;
  19557. break;
  19558. case 9:
  19559. /* Y = Y * Y */
  19560. sp_256_mont_sqr_9(ctx->y, ctx->y, p256_mod, p256_mp_mod);
  19561. ctx->state = 10;
  19562. break;
  19563. case 10:
  19564. /* T2 = Y * Y */
  19565. sp_256_mont_sqr_9(ctx->t2, ctx->y, p256_mod, p256_mp_mod);
  19566. ctx->state = 11;
  19567. break;
  19568. case 11:
  19569. /* T2 = T2/2 */
  19570. sp_256_mont_div2_9(ctx->t2, ctx->t2, p256_mod);
  19571. ctx->state = 12;
  19572. break;
  19573. case 12:
  19574. /* Y = Y * X */
  19575. sp_256_mont_mul_9(ctx->y, ctx->y, p->x, p256_mod, p256_mp_mod);
  19576. ctx->state = 13;
  19577. break;
  19578. case 13:
  19579. /* X = T1 * T1 */
  19580. sp_256_mont_sqr_9(ctx->x, ctx->t1, p256_mod, p256_mp_mod);
  19581. ctx->state = 14;
  19582. break;
  19583. case 14:
  19584. /* X = X - Y */
  19585. sp_256_mont_sub_9(ctx->x, ctx->x, ctx->y, p256_mod);
  19586. ctx->state = 15;
  19587. break;
  19588. case 15:
  19589. /* X = X - Y */
  19590. sp_256_mont_sub_9(ctx->x, ctx->x, ctx->y, p256_mod);
  19591. ctx->state = 16;
  19592. break;
  19593. case 16:
  19594. /* Y = Y - X */
  19595. sp_256_mont_sub_9(ctx->y, ctx->y, ctx->x, p256_mod);
  19596. ctx->state = 17;
  19597. break;
  19598. case 17:
  19599. /* Y = Y * T1 */
  19600. sp_256_mont_mul_9(ctx->y, ctx->y, ctx->t1, p256_mod, p256_mp_mod);
  19601. ctx->state = 18;
  19602. break;
  19603. case 18:
  19604. /* Y = Y - T2 */
  19605. sp_256_mont_sub_9(ctx->y, ctx->y, ctx->t2, p256_mod);
  19606. ctx->state = 19;
  19607. /* fall-through */
  19608. case 19:
  19609. err = MP_OKAY;
  19610. break;
  19611. }
  19612. if (err == MP_OKAY && ctx->state != 19) {
  19613. err = FP_WOULDBLOCK;
  19614. }
  19615. return err;
  19616. }
  19617. #endif /* WOLFSSL_SP_NONBLOCK */
  19618. /* Compare two numbers to determine if they are equal.
  19619. * Constant time implementation.
  19620. *
  19621. * a First number to compare.
  19622. * b Second number to compare.
  19623. * returns 1 when equal and 0 otherwise.
  19624. */
  19625. static int sp_256_cmp_equal_9(const sp_digit* a, const sp_digit* b)
  19626. {
  19627. return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
  19628. (a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
  19629. (a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8])) == 0;
  19630. }
  19631. /* Returns 1 if the number of zero.
  19632. * Implementation is constant time.
  19633. *
  19634. * a Number to check.
  19635. * returns 1 if the number is zero and 0 otherwise.
  19636. */
  19637. static int sp_256_iszero_9(const sp_digit* a)
  19638. {
  19639. return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7] |
  19640. a[8]) == 0;
  19641. }
  19642. /* Add two Montgomery form projective points.
  19643. *
  19644. * r Result of addition.
  19645. * p First point to add.
  19646. * q Second point to add.
  19647. * t Temporary ordinate data.
  19648. */
  19649. static void sp_256_proj_point_add_9(sp_point_256* r,
  19650. const sp_point_256* p, const sp_point_256* q, sp_digit* t)
  19651. {
  19652. sp_digit* t6 = t;
  19653. sp_digit* t1 = t + 2*9;
  19654. sp_digit* t2 = t + 4*9;
  19655. sp_digit* t3 = t + 6*9;
  19656. sp_digit* t4 = t + 8*9;
  19657. sp_digit* t5 = t + 10*9;
  19658. /* U1 = X1*Z2^2 */
  19659. sp_256_mont_sqr_9(t1, q->z, p256_mod, p256_mp_mod);
  19660. sp_256_mont_mul_9(t3, t1, q->z, p256_mod, p256_mp_mod);
  19661. sp_256_mont_mul_9(t1, t1, p->x, p256_mod, p256_mp_mod);
  19662. /* U2 = X2*Z1^2 */
  19663. sp_256_mont_sqr_9(t2, p->z, p256_mod, p256_mp_mod);
  19664. sp_256_mont_mul_9(t4, t2, p->z, p256_mod, p256_mp_mod);
  19665. sp_256_mont_mul_9(t2, t2, q->x, p256_mod, p256_mp_mod);
  19666. /* S1 = Y1*Z2^3 */
  19667. sp_256_mont_mul_9(t3, t3, p->y, p256_mod, p256_mp_mod);
  19668. /* S2 = Y2*Z1^3 */
  19669. sp_256_mont_mul_9(t4, t4, q->y, p256_mod, p256_mp_mod);
  19670. /* Check double */
  19671. if ((~p->infinity) & (~q->infinity) &
  19672. sp_256_cmp_equal_9(t2, t1) &
  19673. sp_256_cmp_equal_9(t4, t3)) {
  19674. sp_256_proj_point_dbl_9(r, p, t);
  19675. }
  19676. else {
  19677. sp_digit* x = t6;
  19678. sp_digit* y = t1;
  19679. sp_digit* z = t2;
  19680. /* H = U2 - U1 */
  19681. sp_256_mont_sub_9(t2, t2, t1, p256_mod);
  19682. /* R = S2 - S1 */
  19683. sp_256_mont_sub_9(t4, t4, t3, p256_mod);
  19684. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  19685. sp_256_mont_sqr_9(t5, t2, p256_mod, p256_mp_mod);
  19686. sp_256_mont_mul_9(y, t1, t5, p256_mod, p256_mp_mod);
  19687. sp_256_mont_mul_9(t5, t5, t2, p256_mod, p256_mp_mod);
  19688. /* Z3 = H*Z1*Z2 */
  19689. sp_256_mont_mul_9(z, p->z, t2, p256_mod, p256_mp_mod);
  19690. sp_256_mont_mul_9(z, z, q->z, p256_mod, p256_mp_mod);
  19691. sp_256_mont_sqr_9(x, t4, p256_mod, p256_mp_mod);
  19692. sp_256_mont_sub_9(x, x, t5, p256_mod);
  19693. sp_256_mont_mul_9(t5, t5, t3, p256_mod, p256_mp_mod);
  19694. sp_256_mont_dbl_9(t3, y, p256_mod);
  19695. sp_256_mont_sub_9(x, x, t3, p256_mod);
  19696. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  19697. sp_256_mont_sub_9(y, y, x, p256_mod);
  19698. sp_256_mont_mul_9(y, y, t4, p256_mod, p256_mp_mod);
  19699. sp_256_mont_sub_9(y, y, t5, p256_mod);
  19700. {
  19701. int i;
  19702. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  19703. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  19704. sp_digit maskt = ~(maskp | maskq);
  19705. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  19706. for (i = 0; i < 9; i++) {
  19707. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  19708. (x[i] & maskt);
  19709. }
  19710. for (i = 0; i < 9; i++) {
  19711. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  19712. (y[i] & maskt);
  19713. }
  19714. for (i = 0; i < 9; i++) {
  19715. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  19716. (z[i] & maskt);
  19717. }
  19718. r->z[0] |= inf;
  19719. r->infinity = (word32)inf;
  19720. }
  19721. }
  19722. }
  19723. #ifdef WOLFSSL_SP_NONBLOCK
  19724. typedef struct sp_256_proj_point_add_9_ctx {
  19725. int state;
  19726. sp_256_proj_point_dbl_9_ctx dbl_ctx;
  19727. const sp_point_256* ap[2];
  19728. sp_point_256* rp[2];
  19729. sp_digit* t1;
  19730. sp_digit* t2;
  19731. sp_digit* t3;
  19732. sp_digit* t4;
  19733. sp_digit* t5;
  19734. sp_digit* t6;
  19735. sp_digit* x;
  19736. sp_digit* y;
  19737. sp_digit* z;
  19738. } sp_256_proj_point_add_9_ctx;
  19739. /* Add two Montgomery form projective points.
  19740. *
  19741. * r Result of addition.
  19742. * p First point to add.
  19743. * q Second point to add.
  19744. * t Temporary ordinate data.
  19745. */
  19746. static int sp_256_proj_point_add_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
  19747. const sp_point_256* p, const sp_point_256* q, sp_digit* t)
  19748. {
  19749. int err = FP_WOULDBLOCK;
  19750. sp_256_proj_point_add_9_ctx* ctx = (sp_256_proj_point_add_9_ctx*)sp_ctx->data;
  19751. /* Ensure only the first point is the same as the result. */
  19752. if (q == r) {
  19753. const sp_point_256* a = p;
  19754. p = q;
  19755. q = a;
  19756. }
  19757. typedef char ctx_size_test[sizeof(sp_256_proj_point_add_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  19758. (void)sizeof(ctx_size_test);
  19759. switch (ctx->state) {
  19760. case 0: /* INIT */
  19761. ctx->t6 = t;
  19762. ctx->t1 = t + 2*9;
  19763. ctx->t2 = t + 4*9;
  19764. ctx->t3 = t + 6*9;
  19765. ctx->t4 = t + 8*9;
  19766. ctx->t5 = t + 10*9;
  19767. ctx->x = ctx->t6;
  19768. ctx->y = ctx->t1;
  19769. ctx->z = ctx->t2;
  19770. ctx->state = 1;
  19771. break;
  19772. case 1:
  19773. /* U1 = X1*Z2^2 */
  19774. sp_256_mont_sqr_9(ctx->t1, q->z, p256_mod, p256_mp_mod);
  19775. ctx->state = 2;
  19776. break;
  19777. case 2:
  19778. sp_256_mont_mul_9(ctx->t3, ctx->t1, q->z, p256_mod, p256_mp_mod);
  19779. ctx->state = 3;
  19780. break;
  19781. case 3:
  19782. sp_256_mont_mul_9(ctx->t1, ctx->t1, p->x, p256_mod, p256_mp_mod);
  19783. ctx->state = 4;
  19784. break;
  19785. case 4:
  19786. /* U2 = X2*Z1^2 */
  19787. sp_256_mont_sqr_9(ctx->t2, p->z, p256_mod, p256_mp_mod);
  19788. ctx->state = 5;
  19789. break;
  19790. case 5:
  19791. sp_256_mont_mul_9(ctx->t4, ctx->t2, p->z, p256_mod, p256_mp_mod);
  19792. ctx->state = 6;
  19793. break;
  19794. case 6:
  19795. sp_256_mont_mul_9(ctx->t2, ctx->t2, q->x, p256_mod, p256_mp_mod);
  19796. ctx->state = 7;
  19797. break;
  19798. case 7:
  19799. /* S1 = Y1*Z2^3 */
  19800. sp_256_mont_mul_9(ctx->t3, ctx->t3, p->y, p256_mod, p256_mp_mod);
  19801. ctx->state = 8;
  19802. break;
  19803. case 8:
  19804. /* S2 = Y2*Z1^3 */
  19805. sp_256_mont_mul_9(ctx->t4, ctx->t4, q->y, p256_mod, p256_mp_mod);
  19806. ctx->state = 9;
  19807. break;
  19808. case 9:
  19809. /* Check double */
  19810. if ((~p->infinity) & (~q->infinity) &
  19811. sp_256_cmp_equal_9(ctx->t2, ctx->t1) &
  19812. sp_256_cmp_equal_9(ctx->t4, ctx->t3)) {
  19813. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  19814. sp_256_proj_point_dbl_9(r, p, t);
  19815. ctx->state = 25;
  19816. }
  19817. else {
  19818. ctx->state = 10;
  19819. }
  19820. break;
  19821. case 10:
  19822. /* H = U2 - U1 */
  19823. sp_256_mont_sub_9(ctx->t2, ctx->t2, ctx->t1, p256_mod);
  19824. ctx->state = 11;
  19825. break;
  19826. case 11:
  19827. /* R = S2 - S1 */
  19828. sp_256_mont_sub_9(ctx->t4, ctx->t4, ctx->t3, p256_mod);
  19829. ctx->state = 12;
  19830. break;
  19831. case 12:
  19832. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  19833. sp_256_mont_sqr_9(ctx->t5, ctx->t2, p256_mod, p256_mp_mod);
  19834. ctx->state = 13;
  19835. break;
  19836. case 13:
  19837. sp_256_mont_mul_9(ctx->y, ctx->t1, ctx->t5, p256_mod, p256_mp_mod);
  19838. ctx->state = 14;
  19839. break;
  19840. case 14:
  19841. sp_256_mont_mul_9(ctx->t5, ctx->t5, ctx->t2, p256_mod, p256_mp_mod);
  19842. ctx->state = 15;
  19843. break;
  19844. case 15:
  19845. /* Z3 = H*Z1*Z2 */
  19846. sp_256_mont_mul_9(ctx->z, p->z, ctx->t2, p256_mod, p256_mp_mod);
  19847. ctx->state = 16;
  19848. break;
  19849. case 16:
  19850. sp_256_mont_mul_9(ctx->z, ctx->z, q->z, p256_mod, p256_mp_mod);
  19851. ctx->state = 17;
  19852. break;
  19853. case 17:
  19854. sp_256_mont_sqr_9(ctx->x, ctx->t4, p256_mod, p256_mp_mod);
  19855. ctx->state = 18;
  19856. break;
  19857. case 18:
  19858. sp_256_mont_sub_9(ctx->x, ctx->x, ctx->t5, p256_mod);
  19859. ctx->state = 19;
  19860. break;
  19861. case 19:
  19862. sp_256_mont_mul_9(ctx->t5, ctx->t5, ctx->t3, p256_mod, p256_mp_mod);
  19863. ctx->state = 20;
  19864. break;
  19865. case 20:
  19866. sp_256_mont_dbl_9(ctx->t3, ctx->y, p256_mod);
  19867. sp_256_mont_sub_9(ctx->x, ctx->x, ctx->t3, p256_mod);
  19868. ctx->state = 21;
  19869. break;
  19870. case 21:
  19871. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  19872. sp_256_mont_sub_9(ctx->y, ctx->y, ctx->x, p256_mod);
  19873. ctx->state = 22;
  19874. break;
  19875. case 22:
  19876. sp_256_mont_mul_9(ctx->y, ctx->y, ctx->t4, p256_mod, p256_mp_mod);
  19877. ctx->state = 23;
  19878. break;
  19879. case 23:
  19880. sp_256_mont_sub_9(ctx->y, ctx->y, ctx->t5, p256_mod);
  19881. ctx->state = 24;
  19882. break;
  19883. case 24:
  19884. {
  19885. {
  19886. int i;
  19887. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  19888. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  19889. sp_digit maskt = ~(maskp | maskq);
  19890. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  19891. for (i = 0; i < 9; i++) {
  19892. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  19893. (ctx->x[i] & maskt);
  19894. }
  19895. for (i = 0; i < 9; i++) {
  19896. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  19897. (ctx->y[i] & maskt);
  19898. }
  19899. for (i = 0; i < 9; i++) {
  19900. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  19901. (ctx->z[i] & maskt);
  19902. }
  19903. r->z[0] |= inf;
  19904. r->infinity = (word32)inf;
  19905. }
  19906. ctx->state = 25;
  19907. break;
  19908. }
  19909. case 25:
  19910. err = MP_OKAY;
  19911. break;
  19912. }
  19913. if (err == MP_OKAY && ctx->state != 25) {
  19914. err = FP_WOULDBLOCK;
  19915. }
  19916. return err;
  19917. }
  19918. #endif /* WOLFSSL_SP_NONBLOCK */
  19919. /* Multiply a number by Montgomery normalizer mod modulus (prime).
  19920. *
  19921. * r The resulting Montgomery form number.
  19922. * a The number to convert.
  19923. * m The modulus (prime).
  19924. * returns MEMORY_E when memory allocation fails and MP_OKAY otherwise.
  19925. */
  19926. static int sp_256_mod_mul_norm_9(sp_digit* r, const sp_digit* a, const sp_digit* m)
  19927. {
  19928. #ifdef WOLFSSL_SP_SMALL_STACK
  19929. int64_t* t = NULL;
  19930. #else
  19931. int64_t t[2 * 8];
  19932. #endif
  19933. int64_t* a32 = NULL;
  19934. int64_t o;
  19935. int err = MP_OKAY;
  19936. (void)m;
  19937. #ifdef WOLFSSL_SP_SMALL_STACK
  19938. t = (int64_t*)XMALLOC(sizeof(int64_t) * 2 * 8, NULL, DYNAMIC_TYPE_ECC);
  19939. if (t == NULL)
  19940. return MEMORY_E;
  19941. #endif
  19942. if (err == MP_OKAY) {
  19943. a32 = t + 8;
  19944. a32[0] = a[0];
  19945. a32[0] |= a[1] << 29U;
  19946. a32[0] &= 0xffffffffL;
  19947. a32[1] = (a[1] >> 3);
  19948. a32[1] |= a[2] << 26U;
  19949. a32[1] &= 0xffffffffL;
  19950. a32[2] = (a[2] >> 6);
  19951. a32[2] |= a[3] << 23U;
  19952. a32[2] &= 0xffffffffL;
  19953. a32[3] = (a[3] >> 9);
  19954. a32[3] |= a[4] << 20U;
  19955. a32[3] &= 0xffffffffL;
  19956. a32[4] = (a[4] >> 12);
  19957. a32[4] |= a[5] << 17U;
  19958. a32[4] &= 0xffffffffL;
  19959. a32[5] = (a[5] >> 15);
  19960. a32[5] |= a[6] << 14U;
  19961. a32[5] &= 0xffffffffL;
  19962. a32[6] = (a[6] >> 18);
  19963. a32[6] |= a[7] << 11U;
  19964. a32[6] &= 0xffffffffL;
  19965. a32[7] = (a[7] >> 21);
  19966. a32[7] |= a[8] << 8U;
  19967. a32[7] &= 0xffffffffL;
  19968. /* 1 1 0 -1 -1 -1 -1 0 */
  19969. t[0] = 0 + a32[0] + a32[1] - a32[3] - a32[4] - a32[5] - a32[6];
  19970. /* 0 1 1 0 -1 -1 -1 -1 */
  19971. t[1] = 0 + a32[1] + a32[2] - a32[4] - a32[5] - a32[6] - a32[7];
  19972. /* 0 0 1 1 0 -1 -1 -1 */
  19973. t[2] = 0 + a32[2] + a32[3] - a32[5] - a32[6] - a32[7];
  19974. /* -1 -1 0 2 2 1 0 -1 */
  19975. t[3] = 0 - a32[0] - a32[1] + 2 * a32[3] + 2 * a32[4] + a32[5] - a32[7];
  19976. /* 0 -1 -1 0 2 2 1 0 */
  19977. t[4] = 0 - a32[1] - a32[2] + 2 * a32[4] + 2 * a32[5] + a32[6];
  19978. /* 0 0 -1 -1 0 2 2 1 */
  19979. t[5] = 0 - a32[2] - a32[3] + 2 * a32[5] + 2 * a32[6] + a32[7];
  19980. /* -1 -1 0 0 0 1 3 2 */
  19981. t[6] = 0 - a32[0] - a32[1] + a32[5] + 3 * a32[6] + 2 * a32[7];
  19982. /* 1 0 -1 -1 -1 -1 0 3 */
  19983. t[7] = 0 + a32[0] - a32[2] - a32[3] - a32[4] - a32[5] + 3 * a32[7];
  19984. t[1] += t[0] >> 32U; t[0] &= 0xffffffffL;
  19985. t[2] += t[1] >> 32U; t[1] &= 0xffffffffL;
  19986. t[3] += t[2] >> 32U; t[2] &= 0xffffffffL;
  19987. t[4] += t[3] >> 32U; t[3] &= 0xffffffffL;
  19988. t[5] += t[4] >> 32U; t[4] &= 0xffffffffL;
  19989. t[6] += t[5] >> 32U; t[5] &= 0xffffffffL;
  19990. t[7] += t[6] >> 32U; t[6] &= 0xffffffffL;
  19991. o = t[7] >> 32U; t[7] &= 0xffffffffL;
  19992. t[0] += o;
  19993. t[3] -= o;
  19994. t[6] -= o;
  19995. t[7] += o;
  19996. t[1] += t[0] >> 32U; t[0] &= 0xffffffffL;
  19997. t[2] += t[1] >> 32U; t[1] &= 0xffffffffL;
  19998. t[3] += t[2] >> 32U; t[2] &= 0xffffffffL;
  19999. t[4] += t[3] >> 32U; t[3] &= 0xffffffffL;
  20000. t[5] += t[4] >> 32U; t[4] &= 0xffffffffL;
  20001. t[6] += t[5] >> 32U; t[5] &= 0xffffffffL;
  20002. t[7] += t[6] >> 32U; t[6] &= 0xffffffffL;
  20003. r[0] = (sp_digit)(t[0]) & 0x1fffffffL;
  20004. r[1] = (sp_digit)(t[0] >> 29U);
  20005. r[1] |= (sp_digit)(t[1] << 3U);
  20006. r[1] &= 0x1fffffffL;
  20007. r[2] = (sp_digit)(t[1] >> 26U);
  20008. r[2] |= (sp_digit)(t[2] << 6U);
  20009. r[2] &= 0x1fffffffL;
  20010. r[3] = (sp_digit)(t[2] >> 23U);
  20011. r[3] |= (sp_digit)(t[3] << 9U);
  20012. r[3] &= 0x1fffffffL;
  20013. r[4] = (sp_digit)(t[3] >> 20U);
  20014. r[4] |= (sp_digit)(t[4] << 12U);
  20015. r[4] &= 0x1fffffffL;
  20016. r[5] = (sp_digit)(t[4] >> 17U);
  20017. r[5] |= (sp_digit)(t[5] << 15U);
  20018. r[5] &= 0x1fffffffL;
  20019. r[6] = (sp_digit)(t[5] >> 14U);
  20020. r[6] |= (sp_digit)(t[6] << 18U);
  20021. r[6] &= 0x1fffffffL;
  20022. r[7] = (sp_digit)(t[6] >> 11U);
  20023. r[7] |= (sp_digit)(t[7] << 21U);
  20024. r[7] &= 0x1fffffffL;
  20025. r[8] = (sp_digit)(t[7] >> 8U);
  20026. }
  20027. #ifdef WOLFSSL_SP_SMALL_STACK
  20028. if (t != NULL)
  20029. XFREE(t, NULL, DYNAMIC_TYPE_ECC);
  20030. #endif
  20031. return err;
  20032. }
  20033. #ifdef WOLFSSL_SP_SMALL
  20034. /* Multiply the point by the scalar and return the result.
  20035. * If map is true then convert result to affine coordinates.
  20036. *
  20037. * Small implementation using add and double that is cache attack resistant but
  20038. * allocates memory rather than use large stacks.
  20039. * 256 adds and doubles.
  20040. *
  20041. * r Resulting point.
  20042. * g Point to multiply.
  20043. * k Scalar to multiply by.
  20044. * map Indicates whether to convert result to affine.
  20045. * ct Constant time required.
  20046. * heap Heap to use for allocation.
  20047. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  20048. */
  20049. static int sp_256_ecc_mulmod_9(sp_point_256* r, const sp_point_256* g,
  20050. const sp_digit* k, int map, int ct, void* heap)
  20051. {
  20052. #ifdef WOLFSSL_SP_SMALL_STACK
  20053. sp_point_256* t = NULL;
  20054. sp_digit* tmp = NULL;
  20055. #else
  20056. sp_point_256 t[3];
  20057. sp_digit tmp[2 * 9 * 6];
  20058. #endif
  20059. sp_digit n;
  20060. int i;
  20061. int c;
  20062. int y;
  20063. int err = MP_OKAY;
  20064. /* Implementation is constant time. */
  20065. (void)ct;
  20066. (void)heap;
  20067. #ifdef WOLFSSL_SP_SMALL_STACK
  20068. t = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 3, heap,
  20069. DYNAMIC_TYPE_ECC);
  20070. if (t == NULL)
  20071. err = MEMORY_E;
  20072. if (err == MP_OKAY) {
  20073. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 6, heap,
  20074. DYNAMIC_TYPE_ECC);
  20075. if (tmp == NULL)
  20076. err = MEMORY_E;
  20077. }
  20078. #endif
  20079. if (err == MP_OKAY) {
  20080. XMEMSET(t, 0, sizeof(sp_point_256) * 3);
  20081. /* t[0] = {0, 0, 1} * norm */
  20082. t[0].infinity = 1;
  20083. /* t[1] = {g->x, g->y, g->z} * norm */
  20084. err = sp_256_mod_mul_norm_9(t[1].x, g->x, p256_mod);
  20085. }
  20086. if (err == MP_OKAY)
  20087. err = sp_256_mod_mul_norm_9(t[1].y, g->y, p256_mod);
  20088. if (err == MP_OKAY)
  20089. err = sp_256_mod_mul_norm_9(t[1].z, g->z, p256_mod);
  20090. if (err == MP_OKAY) {
  20091. i = 8;
  20092. c = 24;
  20093. n = k[i--] << (29 - c);
  20094. for (; ; c--) {
  20095. if (c == 0) {
  20096. if (i == -1)
  20097. break;
  20098. n = k[i--];
  20099. c = 29;
  20100. }
  20101. y = (n >> 28) & 1;
  20102. n <<= 1;
  20103. sp_256_proj_point_add_9(&t[y^1], &t[0], &t[1], tmp);
  20104. XMEMCPY(&t[2], (void*)(((size_t)&t[0] & addr_mask[y^1]) +
  20105. ((size_t)&t[1] & addr_mask[y])),
  20106. sizeof(sp_point_256));
  20107. sp_256_proj_point_dbl_9(&t[2], &t[2], tmp);
  20108. XMEMCPY((void*)(((size_t)&t[0] & addr_mask[y^1]) +
  20109. ((size_t)&t[1] & addr_mask[y])), &t[2],
  20110. sizeof(sp_point_256));
  20111. }
  20112. if (map != 0) {
  20113. sp_256_map_9(r, &t[0], tmp);
  20114. }
  20115. else {
  20116. XMEMCPY(r, &t[0], sizeof(sp_point_256));
  20117. }
  20118. }
  20119. #ifdef WOLFSSL_SP_SMALL_STACK
  20120. if (tmp != NULL)
  20121. #endif
  20122. {
  20123. ForceZero(tmp, sizeof(sp_digit) * 2 * 9 * 6);
  20124. #ifdef WOLFSSL_SP_SMALL_STACK
  20125. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  20126. #endif
  20127. }
  20128. #ifdef WOLFSSL_SP_SMALL_STACK
  20129. if (t != NULL)
  20130. #endif
  20131. {
  20132. ForceZero(t, sizeof(sp_point_256) * 3);
  20133. #ifdef WOLFSSL_SP_SMALL_STACK
  20134. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  20135. #endif
  20136. }
  20137. return err;
  20138. }
  20139. #ifdef WOLFSSL_SP_NONBLOCK
  20140. typedef struct sp_256_ecc_mulmod_9_ctx {
  20141. int state;
  20142. union {
  20143. sp_256_proj_point_dbl_9_ctx dbl_ctx;
  20144. sp_256_proj_point_add_9_ctx add_ctx;
  20145. };
  20146. sp_point_256 t[3];
  20147. sp_digit tmp[2 * 9 * 6];
  20148. sp_digit n;
  20149. int i;
  20150. int c;
  20151. int y;
  20152. } sp_256_ecc_mulmod_9_ctx;
  20153. static int sp_256_ecc_mulmod_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
  20154. const sp_point_256* g, const sp_digit* k, int map, int ct, void* heap)
  20155. {
  20156. int err = FP_WOULDBLOCK;
  20157. sp_256_ecc_mulmod_9_ctx* ctx = (sp_256_ecc_mulmod_9_ctx*)sp_ctx->data;
  20158. typedef char ctx_size_test[sizeof(sp_256_ecc_mulmod_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  20159. (void)sizeof(ctx_size_test);
  20160. /* Implementation is constant time. */
  20161. (void)ct;
  20162. switch (ctx->state) {
  20163. case 0: /* INIT */
  20164. XMEMSET(ctx->t, 0, sizeof(sp_point_256) * 3);
  20165. ctx->i = 8;
  20166. ctx->c = 24;
  20167. ctx->n = k[ctx->i--] << (29 - ctx->c);
  20168. /* t[0] = {0, 0, 1} * norm */
  20169. ctx->t[0].infinity = 1;
  20170. ctx->state = 1;
  20171. break;
  20172. case 1: /* T1X */
  20173. /* t[1] = {g->x, g->y, g->z} * norm */
  20174. err = sp_256_mod_mul_norm_9(ctx->t[1].x, g->x, p256_mod);
  20175. ctx->state = 2;
  20176. break;
  20177. case 2: /* T1Y */
  20178. err = sp_256_mod_mul_norm_9(ctx->t[1].y, g->y, p256_mod);
  20179. ctx->state = 3;
  20180. break;
  20181. case 3: /* T1Z */
  20182. err = sp_256_mod_mul_norm_9(ctx->t[1].z, g->z, p256_mod);
  20183. ctx->state = 4;
  20184. break;
  20185. case 4: /* ADDPREP */
  20186. if (ctx->c == 0) {
  20187. if (ctx->i == -1) {
  20188. ctx->state = 7;
  20189. break;
  20190. }
  20191. ctx->n = k[ctx->i--];
  20192. ctx->c = 29;
  20193. }
  20194. ctx->y = (ctx->n >> 28) & 1;
  20195. ctx->n <<= 1;
  20196. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  20197. ctx->state = 5;
  20198. break;
  20199. case 5: /* ADD */
  20200. err = sp_256_proj_point_add_9_nb((sp_ecc_ctx_t*)&ctx->add_ctx,
  20201. &ctx->t[ctx->y^1], &ctx->t[0], &ctx->t[1], ctx->tmp);
  20202. if (err == MP_OKAY) {
  20203. XMEMCPY(&ctx->t[2], (void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  20204. ((size_t)&ctx->t[1] & addr_mask[ctx->y])),
  20205. sizeof(sp_point_256));
  20206. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  20207. ctx->state = 6;
  20208. }
  20209. break;
  20210. case 6: /* DBL */
  20211. err = sp_256_proj_point_dbl_9_nb((sp_ecc_ctx_t*)&ctx->dbl_ctx, &ctx->t[2],
  20212. &ctx->t[2], ctx->tmp);
  20213. if (err == MP_OKAY) {
  20214. XMEMCPY((void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  20215. ((size_t)&ctx->t[1] & addr_mask[ctx->y])), &ctx->t[2],
  20216. sizeof(sp_point_256));
  20217. ctx->state = 4;
  20218. ctx->c--;
  20219. }
  20220. break;
  20221. case 7: /* MAP */
  20222. if (map != 0) {
  20223. sp_256_map_9(r, &ctx->t[0], ctx->tmp);
  20224. }
  20225. else {
  20226. XMEMCPY(r, &ctx->t[0], sizeof(sp_point_256));
  20227. }
  20228. err = MP_OKAY;
  20229. break;
  20230. }
  20231. if (err == MP_OKAY && ctx->state != 7) {
  20232. err = FP_WOULDBLOCK;
  20233. }
  20234. if (err != FP_WOULDBLOCK) {
  20235. ForceZero(ctx->tmp, sizeof(ctx->tmp));
  20236. ForceZero(ctx->t, sizeof(ctx->t));
  20237. }
  20238. (void)heap;
  20239. return err;
  20240. }
  20241. #endif /* WOLFSSL_SP_NONBLOCK */
  20242. #else
  20243. /* A table entry for pre-computed points. */
  20244. typedef struct sp_table_entry_256 {
  20245. sp_digit x[9];
  20246. sp_digit y[9];
  20247. } sp_table_entry_256;
  20248. /* Conditionally copy a into r using the mask m.
  20249. * m is -1 to copy and 0 when not.
  20250. *
  20251. * r A single precision number to copy over.
  20252. * a A single precision number to copy.
  20253. * m Mask value to apply.
  20254. */
  20255. static void sp_256_cond_copy_9(sp_digit* r, const sp_digit* a, const sp_digit m)
  20256. {
  20257. sp_digit t[9];
  20258. #ifdef WOLFSSL_SP_SMALL
  20259. int i;
  20260. for (i = 0; i < 9; i++) {
  20261. t[i] = r[i] ^ a[i];
  20262. }
  20263. for (i = 0; i < 9; i++) {
  20264. r[i] ^= t[i] & m;
  20265. }
  20266. #else
  20267. t[ 0] = r[ 0] ^ a[ 0];
  20268. t[ 1] = r[ 1] ^ a[ 1];
  20269. t[ 2] = r[ 2] ^ a[ 2];
  20270. t[ 3] = r[ 3] ^ a[ 3];
  20271. t[ 4] = r[ 4] ^ a[ 4];
  20272. t[ 5] = r[ 5] ^ a[ 5];
  20273. t[ 6] = r[ 6] ^ a[ 6];
  20274. t[ 7] = r[ 7] ^ a[ 7];
  20275. t[ 8] = r[ 8] ^ a[ 8];
  20276. r[ 0] ^= t[ 0] & m;
  20277. r[ 1] ^= t[ 1] & m;
  20278. r[ 2] ^= t[ 2] & m;
  20279. r[ 3] ^= t[ 3] & m;
  20280. r[ 4] ^= t[ 4] & m;
  20281. r[ 5] ^= t[ 5] & m;
  20282. r[ 6] ^= t[ 6] & m;
  20283. r[ 7] ^= t[ 7] & m;
  20284. r[ 8] ^= t[ 8] & m;
  20285. #endif /* WOLFSSL_SP_SMALL */
  20286. }
  20287. /* Double the Montgomery form projective point p a number of times.
  20288. *
  20289. * r Result of repeated doubling of point.
  20290. * p Point to double.
  20291. * n Number of times to double
  20292. * t Temporary ordinate data.
  20293. */
  20294. static void sp_256_proj_point_dbl_n_9(sp_point_256* p, int i,
  20295. sp_digit* t)
  20296. {
  20297. sp_digit* w = t;
  20298. sp_digit* a = t + 2*9;
  20299. sp_digit* b = t + 4*9;
  20300. sp_digit* t1 = t + 6*9;
  20301. sp_digit* t2 = t + 8*9;
  20302. sp_digit* x;
  20303. sp_digit* y;
  20304. sp_digit* z;
  20305. volatile int n = i;
  20306. x = p->x;
  20307. y = p->y;
  20308. z = p->z;
  20309. /* Y = 2*Y */
  20310. sp_256_mont_dbl_9(y, y, p256_mod);
  20311. /* W = Z^4 */
  20312. sp_256_mont_sqr_9(w, z, p256_mod, p256_mp_mod);
  20313. sp_256_mont_sqr_9(w, w, p256_mod, p256_mp_mod);
  20314. #ifndef WOLFSSL_SP_SMALL
  20315. while (--n > 0)
  20316. #else
  20317. while (--n >= 0)
  20318. #endif
  20319. {
  20320. /* A = 3*(X^2 - W) */
  20321. sp_256_mont_sqr_9(t1, x, p256_mod, p256_mp_mod);
  20322. sp_256_mont_sub_9(t1, t1, w, p256_mod);
  20323. sp_256_mont_tpl_9(a, t1, p256_mod);
  20324. /* B = X*Y^2 */
  20325. sp_256_mont_sqr_9(t1, y, p256_mod, p256_mp_mod);
  20326. sp_256_mont_mul_9(b, t1, x, p256_mod, p256_mp_mod);
  20327. /* X = A^2 - 2B */
  20328. sp_256_mont_sqr_9(x, a, p256_mod, p256_mp_mod);
  20329. sp_256_mont_dbl_9(t2, b, p256_mod);
  20330. sp_256_mont_sub_9(x, x, t2, p256_mod);
  20331. /* B = 2.(B - X) */
  20332. sp_256_mont_sub_9(t2, b, x, p256_mod);
  20333. sp_256_mont_dbl_9(b, t2, p256_mod);
  20334. /* Z = Z*Y */
  20335. sp_256_mont_mul_9(z, z, y, p256_mod, p256_mp_mod);
  20336. /* t1 = Y^4 */
  20337. sp_256_mont_sqr_9(t1, t1, p256_mod, p256_mp_mod);
  20338. #ifdef WOLFSSL_SP_SMALL
  20339. if (n != 0)
  20340. #endif
  20341. {
  20342. /* W = W*Y^4 */
  20343. sp_256_mont_mul_9(w, w, t1, p256_mod, p256_mp_mod);
  20344. }
  20345. /* y = 2*A*(B - X) - Y^4 */
  20346. sp_256_mont_mul_9(y, b, a, p256_mod, p256_mp_mod);
  20347. sp_256_mont_sub_9(y, y, t1, p256_mod);
  20348. }
  20349. #ifndef WOLFSSL_SP_SMALL
  20350. /* A = 3*(X^2 - W) */
  20351. sp_256_mont_sqr_9(t1, x, p256_mod, p256_mp_mod);
  20352. sp_256_mont_sub_9(t1, t1, w, p256_mod);
  20353. sp_256_mont_tpl_9(a, t1, p256_mod);
  20354. /* B = X*Y^2 */
  20355. sp_256_mont_sqr_9(t1, y, p256_mod, p256_mp_mod);
  20356. sp_256_mont_mul_9(b, t1, x, p256_mod, p256_mp_mod);
  20357. /* X = A^2 - 2B */
  20358. sp_256_mont_sqr_9(x, a, p256_mod, p256_mp_mod);
  20359. sp_256_mont_dbl_9(t2, b, p256_mod);
  20360. sp_256_mont_sub_9(x, x, t2, p256_mod);
  20361. /* B = 2.(B - X) */
  20362. sp_256_mont_sub_9(t2, b, x, p256_mod);
  20363. sp_256_mont_dbl_9(b, t2, p256_mod);
  20364. /* Z = Z*Y */
  20365. sp_256_mont_mul_9(z, z, y, p256_mod, p256_mp_mod);
  20366. /* t1 = Y^4 */
  20367. sp_256_mont_sqr_9(t1, t1, p256_mod, p256_mp_mod);
  20368. /* y = 2*A*(B - X) - Y^4 */
  20369. sp_256_mont_mul_9(y, b, a, p256_mod, p256_mp_mod);
  20370. sp_256_mont_sub_9(y, y, t1, p256_mod);
  20371. #endif /* WOLFSSL_SP_SMALL */
  20372. /* Y = Y/2 */
  20373. sp_256_mont_div2_9(y, y, p256_mod);
  20374. }
  20375. /* Double the Montgomery form projective point p a number of times.
  20376. *
  20377. * r Result of repeated doubling of point.
  20378. * p Point to double.
  20379. * n Number of times to double
  20380. * t Temporary ordinate data.
  20381. */
  20382. static void sp_256_proj_point_dbl_n_store_9(sp_point_256* r,
  20383. const sp_point_256* p, int n, int m, sp_digit* t)
  20384. {
  20385. sp_digit* w = t;
  20386. sp_digit* a = t + 2*9;
  20387. sp_digit* b = t + 4*9;
  20388. sp_digit* t1 = t + 6*9;
  20389. sp_digit* t2 = t + 8*9;
  20390. sp_digit* x = r[2*m].x;
  20391. sp_digit* y = r[(1<<n)*m].y;
  20392. sp_digit* z = r[2*m].z;
  20393. int i;
  20394. int j;
  20395. for (i=0; i<9; i++) {
  20396. x[i] = p->x[i];
  20397. }
  20398. for (i=0; i<9; i++) {
  20399. y[i] = p->y[i];
  20400. }
  20401. for (i=0; i<9; i++) {
  20402. z[i] = p->z[i];
  20403. }
  20404. /* Y = 2*Y */
  20405. sp_256_mont_dbl_9(y, y, p256_mod);
  20406. /* W = Z^4 */
  20407. sp_256_mont_sqr_9(w, z, p256_mod, p256_mp_mod);
  20408. sp_256_mont_sqr_9(w, w, p256_mod, p256_mp_mod);
  20409. j = m;
  20410. for (i=1; i<=n; i++) {
  20411. j *= 2;
  20412. /* A = 3*(X^2 - W) */
  20413. sp_256_mont_sqr_9(t1, x, p256_mod, p256_mp_mod);
  20414. sp_256_mont_sub_9(t1, t1, w, p256_mod);
  20415. sp_256_mont_tpl_9(a, t1, p256_mod);
  20416. /* B = X*Y^2 */
  20417. sp_256_mont_sqr_9(t1, y, p256_mod, p256_mp_mod);
  20418. sp_256_mont_mul_9(b, t1, x, p256_mod, p256_mp_mod);
  20419. x = r[j].x;
  20420. /* X = A^2 - 2B */
  20421. sp_256_mont_sqr_9(x, a, p256_mod, p256_mp_mod);
  20422. sp_256_mont_dbl_9(t2, b, p256_mod);
  20423. sp_256_mont_sub_9(x, x, t2, p256_mod);
  20424. /* B = 2.(B - X) */
  20425. sp_256_mont_sub_9(t2, b, x, p256_mod);
  20426. sp_256_mont_dbl_9(b, t2, p256_mod);
  20427. /* Z = Z*Y */
  20428. sp_256_mont_mul_9(r[j].z, z, y, p256_mod, p256_mp_mod);
  20429. z = r[j].z;
  20430. /* t1 = Y^4 */
  20431. sp_256_mont_sqr_9(t1, t1, p256_mod, p256_mp_mod);
  20432. if (i != n) {
  20433. /* W = W*Y^4 */
  20434. sp_256_mont_mul_9(w, w, t1, p256_mod, p256_mp_mod);
  20435. }
  20436. /* y = 2*A*(B - X) - Y^4 */
  20437. sp_256_mont_mul_9(y, b, a, p256_mod, p256_mp_mod);
  20438. sp_256_mont_sub_9(y, y, t1, p256_mod);
  20439. /* Y = Y/2 */
  20440. sp_256_mont_div2_9(r[j].y, y, p256_mod);
  20441. r[j].infinity = 0;
  20442. }
  20443. }
  20444. /* Add two Montgomery form projective points.
  20445. *
  20446. * ra Result of addition.
  20447. * rs Result of subtraction.
  20448. * p First point to add.
  20449. * q Second point to add.
  20450. * t Temporary ordinate data.
  20451. */
  20452. static void sp_256_proj_point_add_sub_9(sp_point_256* ra,
  20453. sp_point_256* rs, const sp_point_256* p, const sp_point_256* q,
  20454. sp_digit* t)
  20455. {
  20456. sp_digit* t1 = t;
  20457. sp_digit* t2 = t + 2*9;
  20458. sp_digit* t3 = t + 4*9;
  20459. sp_digit* t4 = t + 6*9;
  20460. sp_digit* t5 = t + 8*9;
  20461. sp_digit* t6 = t + 10*9;
  20462. sp_digit* xa = ra->x;
  20463. sp_digit* ya = ra->y;
  20464. sp_digit* za = ra->z;
  20465. sp_digit* xs = rs->x;
  20466. sp_digit* ys = rs->y;
  20467. sp_digit* zs = rs->z;
  20468. XMEMCPY(xa, p->x, sizeof(p->x) / 2);
  20469. XMEMCPY(ya, p->y, sizeof(p->y) / 2);
  20470. XMEMCPY(za, p->z, sizeof(p->z) / 2);
  20471. ra->infinity = 0;
  20472. rs->infinity = 0;
  20473. /* U1 = X1*Z2^2 */
  20474. sp_256_mont_sqr_9(t1, q->z, p256_mod, p256_mp_mod);
  20475. sp_256_mont_mul_9(t3, t1, q->z, p256_mod, p256_mp_mod);
  20476. sp_256_mont_mul_9(t1, t1, xa, p256_mod, p256_mp_mod);
  20477. /* U2 = X2*Z1^2 */
  20478. sp_256_mont_sqr_9(t2, za, p256_mod, p256_mp_mod);
  20479. sp_256_mont_mul_9(t4, t2, za, p256_mod, p256_mp_mod);
  20480. sp_256_mont_mul_9(t2, t2, q->x, p256_mod, p256_mp_mod);
  20481. /* S1 = Y1*Z2^3 */
  20482. sp_256_mont_mul_9(t3, t3, ya, p256_mod, p256_mp_mod);
  20483. /* S2 = Y2*Z1^3 */
  20484. sp_256_mont_mul_9(t4, t4, q->y, p256_mod, p256_mp_mod);
  20485. /* H = U2 - U1 */
  20486. sp_256_mont_sub_9(t2, t2, t1, p256_mod);
  20487. /* RS = S2 + S1 */
  20488. sp_256_mont_add_9(t6, t4, t3, p256_mod);
  20489. /* R = S2 - S1 */
  20490. sp_256_mont_sub_9(t4, t4, t3, p256_mod);
  20491. /* Z3 = H*Z1*Z2 */
  20492. /* ZS = H*Z1*Z2 */
  20493. sp_256_mont_mul_9(za, za, q->z, p256_mod, p256_mp_mod);
  20494. sp_256_mont_mul_9(za, za, t2, p256_mod, p256_mp_mod);
  20495. XMEMCPY(zs, za, sizeof(p->z)/2);
  20496. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  20497. /* XS = RS^2 - H^3 - 2*U1*H^2 */
  20498. sp_256_mont_sqr_9(xa, t4, p256_mod, p256_mp_mod);
  20499. sp_256_mont_sqr_9(xs, t6, p256_mod, p256_mp_mod);
  20500. sp_256_mont_sqr_9(t5, t2, p256_mod, p256_mp_mod);
  20501. sp_256_mont_mul_9(ya, t1, t5, p256_mod, p256_mp_mod);
  20502. sp_256_mont_mul_9(t5, t5, t2, p256_mod, p256_mp_mod);
  20503. sp_256_mont_sub_9(xa, xa, t5, p256_mod);
  20504. sp_256_mont_sub_9(xs, xs, t5, p256_mod);
  20505. sp_256_mont_dbl_9(t1, ya, p256_mod);
  20506. sp_256_mont_sub_9(xa, xa, t1, p256_mod);
  20507. sp_256_mont_sub_9(xs, xs, t1, p256_mod);
  20508. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  20509. /* YS = -RS*(U1*H^2 - XS) - S1*H^3 */
  20510. sp_256_mont_sub_9(ys, ya, xs, p256_mod);
  20511. sp_256_mont_sub_9(ya, ya, xa, p256_mod);
  20512. sp_256_mont_mul_9(ya, ya, t4, p256_mod, p256_mp_mod);
  20513. sp_256_sub_9(t6, p256_mod, t6);
  20514. sp_256_mont_mul_9(ys, ys, t6, p256_mod, p256_mp_mod);
  20515. sp_256_mont_mul_9(t5, t5, t3, p256_mod, p256_mp_mod);
  20516. sp_256_mont_sub_9(ya, ya, t5, p256_mod);
  20517. sp_256_mont_sub_9(ys, ys, t5, p256_mod);
  20518. }
  20519. /* Structure used to describe recoding of scalar multiplication. */
  20520. typedef struct ecc_recode_256 {
  20521. /* Index into pre-computation table. */
  20522. uint8_t i;
  20523. /* Use the negative of the point. */
  20524. uint8_t neg;
  20525. } ecc_recode_256;
  20526. /* The index into pre-computation table to use. */
  20527. static const uint8_t recode_index_9_6[66] = {
  20528. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  20529. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  20530. 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
  20531. 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
  20532. 0, 1,
  20533. };
  20534. /* Whether to negate y-ordinate. */
  20535. static const uint8_t recode_neg_9_6[66] = {
  20536. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  20537. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  20538. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  20539. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  20540. 0, 0,
  20541. };
  20542. /* Recode the scalar for multiplication using pre-computed values and
  20543. * subtraction.
  20544. *
  20545. * k Scalar to multiply by.
  20546. * v Vector of operations to perform.
  20547. */
  20548. static void sp_256_ecc_recode_6_9(const sp_digit* k, ecc_recode_256* v)
  20549. {
  20550. int i;
  20551. int j;
  20552. uint8_t y;
  20553. int carry = 0;
  20554. int o;
  20555. sp_digit n;
  20556. j = 0;
  20557. n = k[j];
  20558. o = 0;
  20559. for (i=0; i<43; i++) {
  20560. y = (int8_t)n;
  20561. if (o + 6 < 29) {
  20562. y &= 0x3f;
  20563. n >>= 6;
  20564. o += 6;
  20565. }
  20566. else if (o + 6 == 29) {
  20567. n >>= 6;
  20568. if (++j < 9)
  20569. n = k[j];
  20570. o = 0;
  20571. }
  20572. else if (++j < 9) {
  20573. n = k[j];
  20574. y |= (uint8_t)((n << (29 - o)) & 0x3f);
  20575. o -= 23;
  20576. n >>= o;
  20577. }
  20578. y += (uint8_t)carry;
  20579. v[i].i = recode_index_9_6[y];
  20580. v[i].neg = recode_neg_9_6[y];
  20581. carry = (y >> 6) + v[i].neg;
  20582. }
  20583. }
  20584. #ifndef WC_NO_CACHE_RESISTANT
  20585. /* Touch each possible point that could be being copied.
  20586. *
  20587. * r Point to copy into.
  20588. * table Table - start of the entries to access
  20589. * idx Index of entry to retrieve.
  20590. */
  20591. static void sp_256_get_point_33_9(sp_point_256* r, const sp_point_256* table,
  20592. int idx)
  20593. {
  20594. int i;
  20595. sp_digit mask;
  20596. r->x[0] = 0;
  20597. r->x[1] = 0;
  20598. r->x[2] = 0;
  20599. r->x[3] = 0;
  20600. r->x[4] = 0;
  20601. r->x[5] = 0;
  20602. r->x[6] = 0;
  20603. r->x[7] = 0;
  20604. r->x[8] = 0;
  20605. r->y[0] = 0;
  20606. r->y[1] = 0;
  20607. r->y[2] = 0;
  20608. r->y[3] = 0;
  20609. r->y[4] = 0;
  20610. r->y[5] = 0;
  20611. r->y[6] = 0;
  20612. r->y[7] = 0;
  20613. r->y[8] = 0;
  20614. r->z[0] = 0;
  20615. r->z[1] = 0;
  20616. r->z[2] = 0;
  20617. r->z[3] = 0;
  20618. r->z[4] = 0;
  20619. r->z[5] = 0;
  20620. r->z[6] = 0;
  20621. r->z[7] = 0;
  20622. r->z[8] = 0;
  20623. for (i = 1; i < 33; i++) {
  20624. mask = 0 - (i == idx);
  20625. r->x[0] |= mask & table[i].x[0];
  20626. r->x[1] |= mask & table[i].x[1];
  20627. r->x[2] |= mask & table[i].x[2];
  20628. r->x[3] |= mask & table[i].x[3];
  20629. r->x[4] |= mask & table[i].x[4];
  20630. r->x[5] |= mask & table[i].x[5];
  20631. r->x[6] |= mask & table[i].x[6];
  20632. r->x[7] |= mask & table[i].x[7];
  20633. r->x[8] |= mask & table[i].x[8];
  20634. r->y[0] |= mask & table[i].y[0];
  20635. r->y[1] |= mask & table[i].y[1];
  20636. r->y[2] |= mask & table[i].y[2];
  20637. r->y[3] |= mask & table[i].y[3];
  20638. r->y[4] |= mask & table[i].y[4];
  20639. r->y[5] |= mask & table[i].y[5];
  20640. r->y[6] |= mask & table[i].y[6];
  20641. r->y[7] |= mask & table[i].y[7];
  20642. r->y[8] |= mask & table[i].y[8];
  20643. r->z[0] |= mask & table[i].z[0];
  20644. r->z[1] |= mask & table[i].z[1];
  20645. r->z[2] |= mask & table[i].z[2];
  20646. r->z[3] |= mask & table[i].z[3];
  20647. r->z[4] |= mask & table[i].z[4];
  20648. r->z[5] |= mask & table[i].z[5];
  20649. r->z[6] |= mask & table[i].z[6];
  20650. r->z[7] |= mask & table[i].z[7];
  20651. r->z[8] |= mask & table[i].z[8];
  20652. }
  20653. }
  20654. #endif /* !WC_NO_CACHE_RESISTANT */
  20655. /* Multiply the point by the scalar and return the result.
  20656. * If map is true then convert result to affine coordinates.
  20657. *
  20658. * Window technique of 6 bits. (Add-Sub variation.)
  20659. * Calculate 0..32 times the point. Use function that adds and
  20660. * subtracts the same two points.
  20661. * Recode to add or subtract one of the computed points.
  20662. * Double to push up.
  20663. * NOT a sliding window.
  20664. *
  20665. * r Resulting point.
  20666. * g Point to multiply.
  20667. * k Scalar to multiply by.
  20668. * map Indicates whether to convert result to affine.
  20669. * ct Constant time required.
  20670. * heap Heap to use for allocation.
  20671. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  20672. */
  20673. static int sp_256_ecc_mulmod_win_add_sub_9(sp_point_256* r, const sp_point_256* g,
  20674. const sp_digit* k, int map, int ct, void* heap)
  20675. {
  20676. #ifdef WOLFSSL_SP_SMALL_STACK
  20677. sp_point_256* t = NULL;
  20678. sp_digit* tmp = NULL;
  20679. #else
  20680. sp_point_256 t[33+2];
  20681. sp_digit tmp[2 * 9 * 6];
  20682. #endif
  20683. sp_point_256* rt = NULL;
  20684. sp_point_256* p = NULL;
  20685. sp_digit* negy;
  20686. int i;
  20687. ecc_recode_256 v[43];
  20688. int err = MP_OKAY;
  20689. /* Constant time used for cache attack resistance implementation. */
  20690. (void)ct;
  20691. (void)heap;
  20692. #ifdef WOLFSSL_SP_SMALL_STACK
  20693. t = (sp_point_256*)XMALLOC(sizeof(sp_point_256) *
  20694. (33+2), heap, DYNAMIC_TYPE_ECC);
  20695. if (t == NULL)
  20696. err = MEMORY_E;
  20697. if (err == MP_OKAY) {
  20698. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 6,
  20699. heap, DYNAMIC_TYPE_ECC);
  20700. if (tmp == NULL)
  20701. err = MEMORY_E;
  20702. }
  20703. #endif
  20704. if (err == MP_OKAY) {
  20705. rt = t + 33;
  20706. p = t + 33+1;
  20707. /* t[0] = {0, 0, 1} * norm */
  20708. XMEMSET(&t[0], 0, sizeof(t[0]));
  20709. t[0].infinity = 1;
  20710. /* t[1] = {g->x, g->y, g->z} * norm */
  20711. err = sp_256_mod_mul_norm_9(t[1].x, g->x, p256_mod);
  20712. }
  20713. if (err == MP_OKAY) {
  20714. err = sp_256_mod_mul_norm_9(t[1].y, g->y, p256_mod);
  20715. }
  20716. if (err == MP_OKAY) {
  20717. err = sp_256_mod_mul_norm_9(t[1].z, g->z, p256_mod);
  20718. }
  20719. if (err == MP_OKAY) {
  20720. t[1].infinity = 0;
  20721. /* t[2] ... t[32] */
  20722. sp_256_proj_point_dbl_n_store_9(t, &t[ 1], 5, 1, tmp);
  20723. sp_256_proj_point_add_9(&t[ 3], &t[ 2], &t[ 1], tmp);
  20724. sp_256_proj_point_dbl_9(&t[ 6], &t[ 3], tmp);
  20725. sp_256_proj_point_add_sub_9(&t[ 7], &t[ 5], &t[ 6], &t[ 1], tmp);
  20726. sp_256_proj_point_dbl_9(&t[10], &t[ 5], tmp);
  20727. sp_256_proj_point_add_sub_9(&t[11], &t[ 9], &t[10], &t[ 1], tmp);
  20728. sp_256_proj_point_dbl_9(&t[12], &t[ 6], tmp);
  20729. sp_256_proj_point_dbl_9(&t[14], &t[ 7], tmp);
  20730. sp_256_proj_point_add_sub_9(&t[15], &t[13], &t[14], &t[ 1], tmp);
  20731. sp_256_proj_point_dbl_9(&t[18], &t[ 9], tmp);
  20732. sp_256_proj_point_add_sub_9(&t[19], &t[17], &t[18], &t[ 1], tmp);
  20733. sp_256_proj_point_dbl_9(&t[20], &t[10], tmp);
  20734. sp_256_proj_point_dbl_9(&t[22], &t[11], tmp);
  20735. sp_256_proj_point_add_sub_9(&t[23], &t[21], &t[22], &t[ 1], tmp);
  20736. sp_256_proj_point_dbl_9(&t[24], &t[12], tmp);
  20737. sp_256_proj_point_dbl_9(&t[26], &t[13], tmp);
  20738. sp_256_proj_point_add_sub_9(&t[27], &t[25], &t[26], &t[ 1], tmp);
  20739. sp_256_proj_point_dbl_9(&t[28], &t[14], tmp);
  20740. sp_256_proj_point_dbl_9(&t[30], &t[15], tmp);
  20741. sp_256_proj_point_add_sub_9(&t[31], &t[29], &t[30], &t[ 1], tmp);
  20742. negy = t[0].y;
  20743. sp_256_ecc_recode_6_9(k, v);
  20744. i = 42;
  20745. #ifndef WC_NO_CACHE_RESISTANT
  20746. if (ct) {
  20747. sp_256_get_point_33_9(rt, t, v[i].i);
  20748. rt->infinity = !v[i].i;
  20749. }
  20750. else
  20751. #endif
  20752. {
  20753. XMEMCPY(rt, &t[v[i].i], sizeof(sp_point_256));
  20754. }
  20755. for (--i; i>=0; i--) {
  20756. sp_256_proj_point_dbl_n_9(rt, 6, tmp);
  20757. #ifndef WC_NO_CACHE_RESISTANT
  20758. if (ct) {
  20759. sp_256_get_point_33_9(p, t, v[i].i);
  20760. p->infinity = !v[i].i;
  20761. }
  20762. else
  20763. #endif
  20764. {
  20765. XMEMCPY(p, &t[v[i].i], sizeof(sp_point_256));
  20766. }
  20767. sp_256_sub_9(negy, p256_mod, p->y);
  20768. sp_256_norm_9(negy);
  20769. sp_256_cond_copy_9(p->y, negy, (sp_digit)0 - v[i].neg);
  20770. sp_256_proj_point_add_9(rt, rt, p, tmp);
  20771. }
  20772. if (map != 0) {
  20773. sp_256_map_9(r, rt, tmp);
  20774. }
  20775. else {
  20776. XMEMCPY(r, rt, sizeof(sp_point_256));
  20777. }
  20778. }
  20779. #ifdef WOLFSSL_SP_SMALL_STACK
  20780. if (t != NULL)
  20781. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  20782. if (tmp != NULL)
  20783. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  20784. #endif
  20785. return err;
  20786. }
  20787. #ifdef FP_ECC
  20788. #endif /* FP_ECC */
  20789. /* Add two Montgomery form projective points. The second point has a q value of
  20790. * one.
  20791. * Only the first point can be the same pointer as the result point.
  20792. *
  20793. * r Result of addition.
  20794. * p First point to add.
  20795. * q Second point to add.
  20796. * t Temporary ordinate data.
  20797. */
  20798. static void sp_256_proj_point_add_qz1_9(sp_point_256* r,
  20799. const sp_point_256* p, const sp_point_256* q, sp_digit* t)
  20800. {
  20801. sp_digit* t2 = t;
  20802. sp_digit* t3 = t + 2*9;
  20803. sp_digit* t6 = t + 4*9;
  20804. sp_digit* t1 = t + 6*9;
  20805. sp_digit* t4 = t + 8*9;
  20806. sp_digit* t5 = t + 10*9;
  20807. /* Calculate values to subtract from P->x and P->y. */
  20808. /* U2 = X2*Z1^2 */
  20809. sp_256_mont_sqr_9(t2, p->z, p256_mod, p256_mp_mod);
  20810. sp_256_mont_mul_9(t4, t2, p->z, p256_mod, p256_mp_mod);
  20811. sp_256_mont_mul_9(t2, t2, q->x, p256_mod, p256_mp_mod);
  20812. /* S2 = Y2*Z1^3 */
  20813. sp_256_mont_mul_9(t4, t4, q->y, p256_mod, p256_mp_mod);
  20814. if ((~p->infinity) & (~q->infinity) &
  20815. sp_256_cmp_equal_9(p->x, t2) &
  20816. sp_256_cmp_equal_9(p->y, t4)) {
  20817. sp_256_proj_point_dbl_9(r, p, t);
  20818. }
  20819. else {
  20820. sp_digit* x = t2;
  20821. sp_digit* y = t3;
  20822. sp_digit* z = t6;
  20823. /* H = U2 - X1 */
  20824. sp_256_mont_sub_9(t2, t2, p->x, p256_mod);
  20825. /* R = S2 - Y1 */
  20826. sp_256_mont_sub_9(t4, t4, p->y, p256_mod);
  20827. /* Z3 = H*Z1 */
  20828. sp_256_mont_mul_9(z, p->z, t2, p256_mod, p256_mp_mod);
  20829. /* X3 = R^2 - H^3 - 2*X1*H^2 */
  20830. sp_256_mont_sqr_9(t1, t2, p256_mod, p256_mp_mod);
  20831. sp_256_mont_mul_9(t3, p->x, t1, p256_mod, p256_mp_mod);
  20832. sp_256_mont_mul_9(t1, t1, t2, p256_mod, p256_mp_mod);
  20833. sp_256_mont_sqr_9(t2, t4, p256_mod, p256_mp_mod);
  20834. sp_256_mont_sub_9(t2, t2, t1, p256_mod);
  20835. sp_256_mont_dbl_9(t5, t3, p256_mod);
  20836. sp_256_mont_sub_9(x, t2, t5, p256_mod);
  20837. /* Y3 = R*(X1*H^2 - X3) - Y1*H^3 */
  20838. sp_256_mont_sub_9(t3, t3, x, p256_mod);
  20839. sp_256_mont_mul_9(t3, t3, t4, p256_mod, p256_mp_mod);
  20840. sp_256_mont_mul_9(t1, t1, p->y, p256_mod, p256_mp_mod);
  20841. sp_256_mont_sub_9(y, t3, t1, p256_mod);
  20842. {
  20843. int i;
  20844. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  20845. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  20846. sp_digit maskt = ~(maskp | maskq);
  20847. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  20848. for (i = 0; i < 9; i++) {
  20849. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  20850. (x[i] & maskt);
  20851. }
  20852. for (i = 0; i < 9; i++) {
  20853. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  20854. (y[i] & maskt);
  20855. }
  20856. for (i = 0; i < 9; i++) {
  20857. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  20858. (z[i] & maskt);
  20859. }
  20860. r->z[0] |= inf;
  20861. r->infinity = (word32)inf;
  20862. }
  20863. }
  20864. }
  20865. #ifdef FP_ECC
  20866. /* Convert the projective point to affine.
  20867. * Ordinates are in Montgomery form.
  20868. *
  20869. * a Point to convert.
  20870. * t Temporary data.
  20871. */
  20872. static void sp_256_proj_to_affine_9(sp_point_256* a, sp_digit* t)
  20873. {
  20874. sp_digit* t1 = t;
  20875. sp_digit* t2 = t + 2 * 9;
  20876. sp_digit* tmp = t + 4 * 9;
  20877. sp_256_mont_inv_9(t1, a->z, tmp);
  20878. sp_256_mont_sqr_9(t2, t1, p256_mod, p256_mp_mod);
  20879. sp_256_mont_mul_9(t1, t2, t1, p256_mod, p256_mp_mod);
  20880. sp_256_mont_mul_9(a->x, a->x, t2, p256_mod, p256_mp_mod);
  20881. sp_256_mont_mul_9(a->y, a->y, t1, p256_mod, p256_mp_mod);
  20882. XMEMCPY(a->z, p256_norm_mod, sizeof(p256_norm_mod));
  20883. }
  20884. /* Generate the pre-computed table of points for the base point.
  20885. *
  20886. * width = 8
  20887. * 256 entries
  20888. * 32 bits between
  20889. *
  20890. * a The base point.
  20891. * table Place to store generated point data.
  20892. * tmp Temporary data.
  20893. * heap Heap to use for allocation.
  20894. */
  20895. static int sp_256_gen_stripe_table_9(const sp_point_256* a,
  20896. sp_table_entry_256* table, sp_digit* tmp, void* heap)
  20897. {
  20898. #ifdef WOLFSSL_SP_SMALL_STACK
  20899. sp_point_256* t = NULL;
  20900. #else
  20901. sp_point_256 t[3];
  20902. #endif
  20903. sp_point_256* s1 = NULL;
  20904. sp_point_256* s2 = NULL;
  20905. int i;
  20906. int j;
  20907. int err = MP_OKAY;
  20908. (void)heap;
  20909. #ifdef WOLFSSL_SP_SMALL_STACK
  20910. t = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 3, heap,
  20911. DYNAMIC_TYPE_ECC);
  20912. if (t == NULL)
  20913. err = MEMORY_E;
  20914. #endif
  20915. if (err == MP_OKAY) {
  20916. s1 = t + 1;
  20917. s2 = t + 2;
  20918. err = sp_256_mod_mul_norm_9(t->x, a->x, p256_mod);
  20919. }
  20920. if (err == MP_OKAY) {
  20921. err = sp_256_mod_mul_norm_9(t->y, a->y, p256_mod);
  20922. }
  20923. if (err == MP_OKAY) {
  20924. err = sp_256_mod_mul_norm_9(t->z, a->z, p256_mod);
  20925. }
  20926. if (err == MP_OKAY) {
  20927. t->infinity = 0;
  20928. sp_256_proj_to_affine_9(t, tmp);
  20929. XMEMCPY(s1->z, p256_norm_mod, sizeof(p256_norm_mod));
  20930. s1->infinity = 0;
  20931. XMEMCPY(s2->z, p256_norm_mod, sizeof(p256_norm_mod));
  20932. s2->infinity = 0;
  20933. /* table[0] = {0, 0, infinity} */
  20934. XMEMSET(&table[0], 0, sizeof(sp_table_entry_256));
  20935. /* table[1] = Affine version of 'a' in Montgomery form */
  20936. XMEMCPY(table[1].x, t->x, sizeof(table->x));
  20937. XMEMCPY(table[1].y, t->y, sizeof(table->y));
  20938. for (i=1; i<8; i++) {
  20939. sp_256_proj_point_dbl_n_9(t, 32, tmp);
  20940. sp_256_proj_to_affine_9(t, tmp);
  20941. XMEMCPY(table[1<<i].x, t->x, sizeof(table->x));
  20942. XMEMCPY(table[1<<i].y, t->y, sizeof(table->y));
  20943. }
  20944. for (i=1; i<8; i++) {
  20945. XMEMCPY(s1->x, table[1<<i].x, sizeof(table->x));
  20946. XMEMCPY(s1->y, table[1<<i].y, sizeof(table->y));
  20947. for (j=(1<<i)+1; j<(1<<(i+1)); j++) {
  20948. XMEMCPY(s2->x, table[j-(1<<i)].x, sizeof(table->x));
  20949. XMEMCPY(s2->y, table[j-(1<<i)].y, sizeof(table->y));
  20950. sp_256_proj_point_add_qz1_9(t, s1, s2, tmp);
  20951. sp_256_proj_to_affine_9(t, tmp);
  20952. XMEMCPY(table[j].x, t->x, sizeof(table->x));
  20953. XMEMCPY(table[j].y, t->y, sizeof(table->y));
  20954. }
  20955. }
  20956. }
  20957. #ifdef WOLFSSL_SP_SMALL_STACK
  20958. if (t != NULL)
  20959. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  20960. #endif
  20961. return err;
  20962. }
  20963. #endif /* FP_ECC */
  20964. #ifndef WC_NO_CACHE_RESISTANT
  20965. /* Touch each possible entry that could be being copied.
  20966. *
  20967. * r Point to copy into.
  20968. * table Table - start of the entries to access
  20969. * idx Index of entry to retrieve.
  20970. */
  20971. static void sp_256_get_entry_256_9(sp_point_256* r,
  20972. const sp_table_entry_256* table, int idx)
  20973. {
  20974. int i;
  20975. sp_digit mask;
  20976. r->x[0] = 0;
  20977. r->x[1] = 0;
  20978. r->x[2] = 0;
  20979. r->x[3] = 0;
  20980. r->x[4] = 0;
  20981. r->x[5] = 0;
  20982. r->x[6] = 0;
  20983. r->x[7] = 0;
  20984. r->x[8] = 0;
  20985. r->y[0] = 0;
  20986. r->y[1] = 0;
  20987. r->y[2] = 0;
  20988. r->y[3] = 0;
  20989. r->y[4] = 0;
  20990. r->y[5] = 0;
  20991. r->y[6] = 0;
  20992. r->y[7] = 0;
  20993. r->y[8] = 0;
  20994. for (i = 1; i < 256; i++) {
  20995. mask = 0 - (i == idx);
  20996. r->x[0] |= mask & table[i].x[0];
  20997. r->x[1] |= mask & table[i].x[1];
  20998. r->x[2] |= mask & table[i].x[2];
  20999. r->x[3] |= mask & table[i].x[3];
  21000. r->x[4] |= mask & table[i].x[4];
  21001. r->x[5] |= mask & table[i].x[5];
  21002. r->x[6] |= mask & table[i].x[6];
  21003. r->x[7] |= mask & table[i].x[7];
  21004. r->x[8] |= mask & table[i].x[8];
  21005. r->y[0] |= mask & table[i].y[0];
  21006. r->y[1] |= mask & table[i].y[1];
  21007. r->y[2] |= mask & table[i].y[2];
  21008. r->y[3] |= mask & table[i].y[3];
  21009. r->y[4] |= mask & table[i].y[4];
  21010. r->y[5] |= mask & table[i].y[5];
  21011. r->y[6] |= mask & table[i].y[6];
  21012. r->y[7] |= mask & table[i].y[7];
  21013. r->y[8] |= mask & table[i].y[8];
  21014. }
  21015. }
  21016. #endif /* !WC_NO_CACHE_RESISTANT */
  21017. /* Multiply the point by the scalar and return the result.
  21018. * If map is true then convert result to affine coordinates.
  21019. *
  21020. * Stripe implementation.
  21021. * Pre-generated: 2^0, 2^32, ...
  21022. * Pre-generated: products of all combinations of above.
  21023. * 8 doubles and adds (with qz=1)
  21024. *
  21025. * r Resulting point.
  21026. * k Scalar to multiply by.
  21027. * table Pre-computed table.
  21028. * map Indicates whether to convert result to affine.
  21029. * ct Constant time required.
  21030. * heap Heap to use for allocation.
  21031. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  21032. */
  21033. static int sp_256_ecc_mulmod_stripe_9(sp_point_256* r, const sp_point_256* g,
  21034. const sp_table_entry_256* table, const sp_digit* k, int map,
  21035. int ct, void* heap)
  21036. {
  21037. #ifdef WOLFSSL_SP_SMALL_STACK
  21038. sp_point_256* rt = NULL;
  21039. sp_digit* t = NULL;
  21040. #else
  21041. sp_point_256 rt[2];
  21042. sp_digit t[2 * 9 * 6];
  21043. #endif
  21044. sp_point_256* p = NULL;
  21045. int i;
  21046. int j;
  21047. int y;
  21048. int x;
  21049. int err = MP_OKAY;
  21050. (void)g;
  21051. /* Constant time used for cache attack resistance implementation. */
  21052. (void)ct;
  21053. (void)heap;
  21054. #ifdef WOLFSSL_SP_SMALL_STACK
  21055. rt = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap,
  21056. DYNAMIC_TYPE_ECC);
  21057. if (rt == NULL)
  21058. err = MEMORY_E;
  21059. if (err == MP_OKAY) {
  21060. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 6, heap,
  21061. DYNAMIC_TYPE_ECC);
  21062. if (t == NULL)
  21063. err = MEMORY_E;
  21064. }
  21065. #endif
  21066. if (err == MP_OKAY) {
  21067. p = rt + 1;
  21068. XMEMCPY(p->z, p256_norm_mod, sizeof(p256_norm_mod));
  21069. XMEMCPY(rt->z, p256_norm_mod, sizeof(p256_norm_mod));
  21070. y = 0;
  21071. x = 31;
  21072. for (j=0; j<8; j++) {
  21073. y |= (int)(((k[x / 29] >> (x % 29)) & 1) << j);
  21074. x += 32;
  21075. }
  21076. #ifndef WC_NO_CACHE_RESISTANT
  21077. if (ct) {
  21078. sp_256_get_entry_256_9(rt, table, y);
  21079. } else
  21080. #endif
  21081. {
  21082. XMEMCPY(rt->x, table[y].x, sizeof(table[y].x));
  21083. XMEMCPY(rt->y, table[y].y, sizeof(table[y].y));
  21084. }
  21085. rt->infinity = !y;
  21086. for (i=30; i>=0; i--) {
  21087. y = 0;
  21088. x = i;
  21089. for (j=0; j<8; j++) {
  21090. y |= (int)(((k[x / 29] >> (x % 29)) & 1) << j);
  21091. x += 32;
  21092. }
  21093. sp_256_proj_point_dbl_9(rt, rt, t);
  21094. #ifndef WC_NO_CACHE_RESISTANT
  21095. if (ct) {
  21096. sp_256_get_entry_256_9(p, table, y);
  21097. }
  21098. else
  21099. #endif
  21100. {
  21101. XMEMCPY(p->x, table[y].x, sizeof(table[y].x));
  21102. XMEMCPY(p->y, table[y].y, sizeof(table[y].y));
  21103. }
  21104. p->infinity = !y;
  21105. sp_256_proj_point_add_qz1_9(rt, rt, p, t);
  21106. }
  21107. if (map != 0) {
  21108. sp_256_map_9(r, rt, t);
  21109. }
  21110. else {
  21111. XMEMCPY(r, rt, sizeof(sp_point_256));
  21112. }
  21113. }
  21114. #ifdef WOLFSSL_SP_SMALL_STACK
  21115. if (t != NULL)
  21116. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  21117. if (rt != NULL)
  21118. XFREE(rt, heap, DYNAMIC_TYPE_ECC);
  21119. #endif
  21120. return err;
  21121. }
  21122. #ifdef FP_ECC
  21123. #ifndef FP_ENTRIES
  21124. #define FP_ENTRIES 16
  21125. #endif
  21126. /* Cache entry - holds precomputation tables for a point. */
  21127. typedef struct sp_cache_256_t {
  21128. /* X ordinate of point that table was generated from. */
  21129. sp_digit x[9];
  21130. /* Y ordinate of point that table was generated from. */
  21131. sp_digit y[9];
  21132. /* Precomputation table for point. */
  21133. sp_table_entry_256 table[256];
  21134. /* Count of entries in table. */
  21135. uint32_t cnt;
  21136. /* Point and table set in entry. */
  21137. int set;
  21138. } sp_cache_256_t;
  21139. /* Cache of tables. */
  21140. static THREAD_LS_T sp_cache_256_t sp_cache_256[FP_ENTRIES];
  21141. /* Index of last entry in cache. */
  21142. static THREAD_LS_T int sp_cache_256_last = -1;
  21143. /* Cache has been initialized. */
  21144. static THREAD_LS_T int sp_cache_256_inited = 0;
  21145. #ifndef HAVE_THREAD_LS
  21146. static volatile int initCacheMutex_256 = 0;
  21147. static wolfSSL_Mutex sp_cache_256_lock;
  21148. #endif
  21149. /* Get the cache entry for the point.
  21150. *
  21151. * g [in] Point scalar multiplying.
  21152. * cache [out] Cache table to use.
  21153. */
  21154. static void sp_ecc_get_cache_256(const sp_point_256* g, sp_cache_256_t** cache)
  21155. {
  21156. int i;
  21157. int j;
  21158. uint32_t least;
  21159. if (sp_cache_256_inited == 0) {
  21160. for (i=0; i<FP_ENTRIES; i++) {
  21161. sp_cache_256[i].set = 0;
  21162. }
  21163. sp_cache_256_inited = 1;
  21164. }
  21165. /* Compare point with those in cache. */
  21166. for (i=0; i<FP_ENTRIES; i++) {
  21167. if (!sp_cache_256[i].set)
  21168. continue;
  21169. if (sp_256_cmp_equal_9(g->x, sp_cache_256[i].x) &
  21170. sp_256_cmp_equal_9(g->y, sp_cache_256[i].y)) {
  21171. sp_cache_256[i].cnt++;
  21172. break;
  21173. }
  21174. }
  21175. /* No match. */
  21176. if (i == FP_ENTRIES) {
  21177. /* Find empty entry. */
  21178. i = (sp_cache_256_last + 1) % FP_ENTRIES;
  21179. for (; i != sp_cache_256_last; i=(i+1)%FP_ENTRIES) {
  21180. if (!sp_cache_256[i].set) {
  21181. break;
  21182. }
  21183. }
  21184. /* Evict least used. */
  21185. if (i == sp_cache_256_last) {
  21186. least = sp_cache_256[0].cnt;
  21187. for (j=1; j<FP_ENTRIES; j++) {
  21188. if (sp_cache_256[j].cnt < least) {
  21189. i = j;
  21190. least = sp_cache_256[i].cnt;
  21191. }
  21192. }
  21193. }
  21194. XMEMCPY(sp_cache_256[i].x, g->x, sizeof(sp_cache_256[i].x));
  21195. XMEMCPY(sp_cache_256[i].y, g->y, sizeof(sp_cache_256[i].y));
  21196. sp_cache_256[i].set = 1;
  21197. sp_cache_256[i].cnt = 1;
  21198. }
  21199. *cache = &sp_cache_256[i];
  21200. sp_cache_256_last = i;
  21201. }
  21202. #endif /* FP_ECC */
  21203. /* Multiply the base point of P256 by the scalar and return the result.
  21204. * If map is true then convert result to affine coordinates.
  21205. *
  21206. * r Resulting point.
  21207. * g Point to multiply.
  21208. * k Scalar to multiply by.
  21209. * map Indicates whether to convert result to affine.
  21210. * ct Constant time required.
  21211. * heap Heap to use for allocation.
  21212. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  21213. */
  21214. static int sp_256_ecc_mulmod_9(sp_point_256* r, const sp_point_256* g,
  21215. const sp_digit* k, int map, int ct, void* heap)
  21216. {
  21217. #ifndef FP_ECC
  21218. return sp_256_ecc_mulmod_win_add_sub_9(r, g, k, map, ct, heap);
  21219. #else
  21220. #ifdef WOLFSSL_SP_SMALL_STACK
  21221. sp_digit* tmp;
  21222. #else
  21223. sp_digit tmp[2 * 9 * 6];
  21224. #endif
  21225. sp_cache_256_t* cache;
  21226. int err = MP_OKAY;
  21227. #ifdef WOLFSSL_SP_SMALL_STACK
  21228. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 6, heap, DYNAMIC_TYPE_ECC);
  21229. if (tmp == NULL) {
  21230. err = MEMORY_E;
  21231. }
  21232. #endif
  21233. #ifndef HAVE_THREAD_LS
  21234. if (err == MP_OKAY) {
  21235. if (initCacheMutex_256 == 0) {
  21236. wc_InitMutex(&sp_cache_256_lock);
  21237. initCacheMutex_256 = 1;
  21238. }
  21239. if (wc_LockMutex(&sp_cache_256_lock) != 0) {
  21240. err = BAD_MUTEX_E;
  21241. }
  21242. }
  21243. #endif /* HAVE_THREAD_LS */
  21244. if (err == MP_OKAY) {
  21245. sp_ecc_get_cache_256(g, &cache);
  21246. if (cache->cnt == 2)
  21247. sp_256_gen_stripe_table_9(g, cache->table, tmp, heap);
  21248. #ifndef HAVE_THREAD_LS
  21249. wc_UnLockMutex(&sp_cache_256_lock);
  21250. #endif /* HAVE_THREAD_LS */
  21251. if (cache->cnt < 2) {
  21252. err = sp_256_ecc_mulmod_win_add_sub_9(r, g, k, map, ct, heap);
  21253. }
  21254. else {
  21255. err = sp_256_ecc_mulmod_stripe_9(r, g, cache->table, k,
  21256. map, ct, heap);
  21257. }
  21258. }
  21259. #ifdef WOLFSSL_SP_SMALL_STACK
  21260. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  21261. #endif
  21262. return err;
  21263. #endif
  21264. }
  21265. #endif
  21266. /* Multiply the point by the scalar and return the result.
  21267. * If map is true then convert result to affine coordinates.
  21268. *
  21269. * km Scalar to multiply by.
  21270. * p Point to multiply.
  21271. * r Resulting point.
  21272. * map Indicates whether to convert result to affine.
  21273. * heap Heap to use for allocation.
  21274. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  21275. */
  21276. int sp_ecc_mulmod_256(const mp_int* km, const ecc_point* gm, ecc_point* r,
  21277. int map, void* heap)
  21278. {
  21279. #ifdef WOLFSSL_SP_SMALL_STACK
  21280. sp_point_256* point = NULL;
  21281. sp_digit* k = NULL;
  21282. #else
  21283. sp_point_256 point[1];
  21284. sp_digit k[9];
  21285. #endif
  21286. int err = MP_OKAY;
  21287. #ifdef WOLFSSL_SP_SMALL_STACK
  21288. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256), heap,
  21289. DYNAMIC_TYPE_ECC);
  21290. if (point == NULL)
  21291. err = MEMORY_E;
  21292. if (err == MP_OKAY) {
  21293. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9, heap,
  21294. DYNAMIC_TYPE_ECC);
  21295. if (k == NULL)
  21296. err = MEMORY_E;
  21297. }
  21298. #endif
  21299. if (err == MP_OKAY) {
  21300. sp_256_from_mp(k, 9, km);
  21301. sp_256_point_from_ecc_point_9(point, gm);
  21302. err = sp_256_ecc_mulmod_9(point, point, k, map, 1, heap);
  21303. }
  21304. if (err == MP_OKAY) {
  21305. err = sp_256_point_to_ecc_point_9(point, r);
  21306. }
  21307. #ifdef WOLFSSL_SP_SMALL_STACK
  21308. if (k != NULL)
  21309. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  21310. if (point != NULL)
  21311. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  21312. #endif
  21313. return err;
  21314. }
  21315. /* Multiply the point by the scalar, add point a and return the result.
  21316. * If map is true then convert result to affine coordinates.
  21317. *
  21318. * km Scalar to multiply by.
  21319. * p Point to multiply.
  21320. * am Point to add to scalar multiply result.
  21321. * inMont Point to add is in montgomery form.
  21322. * r Resulting point.
  21323. * map Indicates whether to convert result to affine.
  21324. * heap Heap to use for allocation.
  21325. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  21326. */
  21327. int sp_ecc_mulmod_add_256(const mp_int* km, const ecc_point* gm,
  21328. const ecc_point* am, int inMont, ecc_point* r, int map, void* heap)
  21329. {
  21330. #ifdef WOLFSSL_SP_SMALL_STACK
  21331. sp_point_256* point = NULL;
  21332. sp_digit* k = NULL;
  21333. #else
  21334. sp_point_256 point[2];
  21335. sp_digit k[9 + 9 * 2 * 6];
  21336. #endif
  21337. sp_point_256* addP = NULL;
  21338. sp_digit* tmp = NULL;
  21339. int err = MP_OKAY;
  21340. #ifdef WOLFSSL_SP_SMALL_STACK
  21341. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap,
  21342. DYNAMIC_TYPE_ECC);
  21343. if (point == NULL)
  21344. err = MEMORY_E;
  21345. if (err == MP_OKAY) {
  21346. k = (sp_digit*)XMALLOC(
  21347. sizeof(sp_digit) * (9 + 9 * 2 * 6), heap,
  21348. DYNAMIC_TYPE_ECC);
  21349. if (k == NULL)
  21350. err = MEMORY_E;
  21351. }
  21352. #endif
  21353. if (err == MP_OKAY) {
  21354. addP = point + 1;
  21355. tmp = k + 9;
  21356. sp_256_from_mp(k, 9, km);
  21357. sp_256_point_from_ecc_point_9(point, gm);
  21358. sp_256_point_from_ecc_point_9(addP, am);
  21359. }
  21360. if ((err == MP_OKAY) && (!inMont)) {
  21361. err = sp_256_mod_mul_norm_9(addP->x, addP->x, p256_mod);
  21362. }
  21363. if ((err == MP_OKAY) && (!inMont)) {
  21364. err = sp_256_mod_mul_norm_9(addP->y, addP->y, p256_mod);
  21365. }
  21366. if ((err == MP_OKAY) && (!inMont)) {
  21367. err = sp_256_mod_mul_norm_9(addP->z, addP->z, p256_mod);
  21368. }
  21369. if (err == MP_OKAY) {
  21370. err = sp_256_ecc_mulmod_9(point, point, k, 0, 0, heap);
  21371. }
  21372. if (err == MP_OKAY) {
  21373. sp_256_proj_point_add_9(point, point, addP, tmp);
  21374. if (map) {
  21375. sp_256_map_9(point, point, tmp);
  21376. }
  21377. err = sp_256_point_to_ecc_point_9(point, r);
  21378. }
  21379. #ifdef WOLFSSL_SP_SMALL_STACK
  21380. if (k != NULL)
  21381. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  21382. if (point != NULL)
  21383. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  21384. #endif
  21385. return err;
  21386. }
  21387. #ifdef WOLFSSL_SP_SMALL
  21388. /* Multiply the base point of P256 by the scalar and return the result.
  21389. * If map is true then convert result to affine coordinates.
  21390. *
  21391. * r Resulting point.
  21392. * k Scalar to multiply by.
  21393. * map Indicates whether to convert result to affine.
  21394. * heap Heap to use for allocation.
  21395. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  21396. */
  21397. static int sp_256_ecc_mulmod_base_9(sp_point_256* r, const sp_digit* k,
  21398. int map, int ct, void* heap)
  21399. {
  21400. /* No pre-computed values. */
  21401. return sp_256_ecc_mulmod_9(r, &p256_base, k, map, ct, heap);
  21402. }
  21403. #ifdef WOLFSSL_SP_NONBLOCK
  21404. static int sp_256_ecc_mulmod_base_9_nb(sp_ecc_ctx_t* sp_ctx, sp_point_256* r,
  21405. const sp_digit* k, int map, int ct, void* heap)
  21406. {
  21407. /* No pre-computed values. */
  21408. return sp_256_ecc_mulmod_9_nb(sp_ctx, r, &p256_base, k, map, ct, heap);
  21409. }
  21410. #endif /* WOLFSSL_SP_NONBLOCK */
  21411. #else
  21412. /* Striping precomputation table.
  21413. * 8 points combined into a table of 256 points.
  21414. * Distance of 32 between points.
  21415. */
  21416. static const sp_table_entry_256 p256_table[256] = {
  21417. /* 0 */
  21418. { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
  21419. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
  21420. /* 1 */
  21421. { { 0x18a9143c,0x0f3986a0,0x1b6d805e,0x152bf8bf,0x0251075b,0x1995bbb1,
  21422. 0x1719e7ed,0x0ed4a6ea,0x0018905f },
  21423. { 0x0e95560a,0x0f929abe,0x06791737,0x1571c974,0x1f3258b4,0x03446e90,
  21424. 0x16174ba2,0x0304b10b,0x008571ff } },
  21425. /* 2 */
  21426. { { 0x0147519a,0x01443012,0x0cdcbc08,0x103d584d,0x1ebc8d09,0x13e553c2,
  21427. 0x03a6a752,0x01bb7beb,0x00d953c5 },
  21428. { 0x1d590f8f,0x0b1b0e67,0x19b245e7,0x12c4d689,0x164cf72e,0x10881175,
  21429. 0x03cdff65,0x0fd3d651,0x00863ebb } },
  21430. /* 3 */
  21431. { { 0x1cdb6485,0x02b5b11a,0x028be5de,0x1e1d445e,0x0300b808,0x0caa27bf,
  21432. 0x0280f9a3,0x0ab6bff0,0x00000760 },
  21433. { 0x038d2010,0x11a75cdc,0x10dc229d,0x029f7664,0x06606540,0x1e9cc215,
  21434. 0x1b838391,0x0c2686e7,0x00830877 } },
  21435. /* 4 */
  21436. { { 0x16a0d2bb,0x1c917e28,0x188d2653,0x1982d834,0x02c8b0d5,0x079d2be3,
  21437. 0x19fe4907,0x0c3fa36c,0x002f5e69 },
  21438. { 0x15a01797,0x00ae385f,0x05586497,0x01689ac1,0x1db523d2,0x0d9b838f,
  21439. 0x1dec1244,0x02d1ade1,0x00f648f9 } },
  21440. /* 5 */
  21441. { { 0x0137bbbc,0x12b3423f,0x1a82fb27,0x088d3d14,0x13463e43,0x13b0bceb,
  21442. 0x0056c710,0x10a267a0,0x005abe02 },
  21443. { 0x004c7dab,0x15541be6,0x098301e4,0x1b3e9886,0x0cc37573,0x0ab13c73,
  21444. 0x0e0c324c,0x0b6d6dee,0x0094bb72 } },
  21445. /* 6 */
  21446. { { 0x120f141c,0x1fcda47b,0x1d6f1d2e,0x13679a5b,0x045c4619,0x1094a088,
  21447. 0x13bf70fd,0x1965efb8,0x00cdd6bb },
  21448. { 0x0af436fd,0x0533805f,0x04c9afb3,0x08fedb73,0x125226f6,0x13c900a7,
  21449. 0x17d8303e,0x17a97b5c,0x00a361be } },
  21450. /* 7 */
  21451. { { 0x197c13c7,0x05512ac2,0x0df0f84a,0x1ac6bea1,0x09d1dc38,0x0d7679e0,
  21452. 0x04b01c0e,0x013896a5,0x00ba12ca },
  21453. { 0x19f91dfd,0x12047d22,0x1a81fee7,0x0876cd9d,0x00b293af,0x1844cebc,
  21454. 0x1d2c7b3a,0x13ae03fd,0x0053ebb9 } },
  21455. /* 8 */
  21456. { { 0x10e63d34,0x1f3f718d,0x1953ead3,0x000ae553,0x1b5a4f46,0x199a6af3,
  21457. 0x00c70124,0x1240daa9,0x008589fb },
  21458. { 0x0583553a,0x1387ae63,0x1592796a,0x121295c4,0x04652087,0x02838802,
  21459. 0x113f3241,0x0da04a83,0x00ebb069 } },
  21460. /* 9 */
  21461. { { 0x0c1647c5,0x10b650ad,0x13d5e651,0x04fa8f89,0x1fbacb81,0x1551bb26,
  21462. 0x168f7199,0x197a364f,0x00eb2820 },
  21463. { 0x0a87e008,0x0037c6c3,0x08de3ce5,0x1bf53b24,0x0ecb2d87,0x17214066,
  21464. 0x08755bb4,0x136ab4fb,0x001f2828 } },
  21465. /* 10 */
  21466. { { 0x1b89da99,0x1dd50601,0x0a1008aa,0x05af3d70,0x005e8a6f,0x1c315c0e,
  21467. 0x158c9e11,0x0b20bca9,0x00337a4b },
  21468. { 0x01f7794a,0x033a8069,0x1b5fd84f,0x000b6efa,0x1d6e8207,0x1bc08267,
  21469. 0x0f582968,0x1abe985f,0x000d65e0 } },
  21470. /* 11 */
  21471. { { 0x15275d38,0x0e84ddf5,0x1828d636,0x114e8a17,0x0b265426,0x17fa4b9f,
  21472. 0x08cbc1d8,0x084a5e94,0x00c23da2 },
  21473. { 0x0b94520c,0x0d0dc278,0x16f5e397,0x0ccec760,0x09ea1096,0x05c34a69,
  21474. 0x1fc4e937,0x1198f219,0x0019de3b } },
  21475. /* 12 */
  21476. { { 0x06c5fe04,0x01d38b61,0x0e86f6c6,0x11bc1677,0x1712c3b2,0x02c35265,
  21477. 0x0ff5d0cb,0x1a923f99,0x00e34dcb },
  21478. { 0x0aa58403,0x0046a35d,0x1a5e94ed,0x12e90d05,0x0a8af9a6,0x00939b55,
  21479. 0x1dfe78e4,0x088f69c1,0x00e7641f } },
  21480. /* 13 */
  21481. { { 0x1f64ba59,0x0ba9ca0e,0x0090bf1f,0x1e21d816,0x01859d33,0x0fe350ac,
  21482. 0x1efd3c1b,0x0ae0a54a,0x004a12df },
  21483. { 0x1439dbd0,0x1d319c7c,0x194f87ef,0x0497a97b,0x1b314d3c,0x07fd10f8,
  21484. 0x091bf579,0x12776b7d,0x006af5aa } },
  21485. /* 14 */
  21486. { { 0x10c91999,0x1085b4c8,0x16012476,0x09688054,0x020900a2,0x0a5a5c66,
  21487. 0x004cf802,0x0b4cd488,0x005fe347 },
  21488. { 0x193e7b4b,0x07c655ef,0x08fe46ac,0x16a034f8,0x06263292,0x04d7668f,
  21489. 0x04590ba2,0x011d9fd5,0x00b544e3 } },
  21490. /* 15 */
  21491. { { 0x16ddfdce,0x03c63748,0x045e7999,0x0522cdf1,0x067e12c3,0x173b26a7,
  21492. 0x082d3a35,0x17b4d618,0x00e0b6b2 },
  21493. { 0x1b7efb57,0x09896f95,0x031001c3,0x181bbcf2,0x1c9441aa,0x1b56b3cd,
  21494. 0x1dd3e40c,0x1bc4b4c6,0x0071c023 } },
  21495. /* 16 */
  21496. { { 0x1fe20925,0x15461225,0x173a19d8,0x0335871f,0x0706391c,0x12eaee9c,
  21497. 0x13d96a5a,0x1a843a64,0x0061d587 },
  21498. { 0x037173ea,0x03b39d15,0x1de2d97a,0x090010a6,0x0b43e238,0x020f02dd,
  21499. 0x1ef843e1,0x0248c43d,0x00fa11fe } },
  21500. /* 17 */
  21501. { { 0x0cb19ffd,0x0448f959,0x048f08c7,0x151ab763,0x1ca8e01b,0x1eb3c562,
  21502. 0x1b72db40,0x0983e277,0x00586eb0 },
  21503. { 0x07e8ed09,0x01ae3729,0x067b7883,0x03467830,0x052fa1e8,0x0b602b63,
  21504. 0x1c449e3f,0x010e10c9,0x0019d5ac } },
  21505. /* 18 */
  21506. { { 0x109a4e1f,0x14cfac09,0x09c01d07,0x1bce37d2,0x08d20ab7,0x1785f7e9,
  21507. 0x18fc9a97,0x07eff38a,0x00e7c007 },
  21508. { 0x0ef59f76,0x1b6b31d0,0x1f2c1407,0x1676a841,0x002d4669,0x0fbd3d33,
  21509. 0x102b0230,0x1fd8cb67,0x00e08504 } },
  21510. /* 19 */
  21511. { { 0x0031b3ca,0x04c7b46d,0x169b59bc,0x19573dcd,0x046e86d1,0x00fd4a79,
  21512. 0x1ad16ff6,0x104b6132,0x0078f018 },
  21513. { 0x1a25787f,0x1f77ef21,0x132b26ed,0x0df01a3b,0x1fc36801,0x043bd9ad,
  21514. 0x11e833a9,0x170fd28e,0x0043a773 } },
  21515. /* 20 */
  21516. { { 0x12b533d5,0x12bbb9a6,0x0f777018,0x1715ed43,0x0c293673,0x1e4d53cf,
  21517. 0x1ac55df9,0x0a38764c,0x00bb6de6 },
  21518. { 0x165259b3,0x1f4981d5,0x0e9d2039,0x015fa7a0,0x0fc27d6a,0x01e8cd9e,
  21519. 0x066f16b2,0x134ba317,0x0060b461 } },
  21520. /* 21 */
  21521. { { 0x1ae5aa1c,0x0b51c708,0x19cd962f,0x0eca5693,0x187edb8b,0x000a772f,
  21522. 0x1f342c4c,0x1655dd7f,0x009d0f27 },
  21523. { 0x1a730a55,0x1492318b,0x0ef20eb2,0x0ab65fbb,0x19a719c9,0x0ff05600,
  21524. 0x12341f07,0x0da6add8,0x00244a56 } },
  21525. /* 22 */
  21526. { { 0x0acf1f96,0x0d81ca57,0x1309c71b,0x02455204,0x1d3b99f2,0x160dc165,
  21527. 0x1da4989a,0x10e6b03d,0x0045e58c },
  21528. { 0x038f9dbc,0x1ffa3ced,0x02281034,0x15e28dd1,0x0bed7a8a,0x0fd92370,
  21529. 0x1e92516b,0x03983c96,0x00c040e2 } },
  21530. /* 23 */
  21531. { { 0x0f8117b6,0x03d78003,0x08d50ce1,0x12d3fee7,0x075eb651,0x1abb0eca,
  21532. 0x1b1d20ac,0x12ed058d,0x001cdf5c },
  21533. { 0x11f04839,0x0dbbada0,0x1785a61f,0x1d59e891,0x132197db,0x0ee8db85,
  21534. 0x1cf6ca48,0x1f1525bf,0x00046755 } },
  21535. /* 24 */
  21536. { { 0x1ce8ffcd,0x04562e95,0x1986a0b3,0x0789165f,0x0d6c70d5,0x10b93901,
  21537. 0x17cfdbc5,0x02277074,0x00046e5e },
  21538. { 0x18007f01,0x1dc7fb26,0x1d0c60f9,0x03de24b5,0x1a03c7fb,0x0f531af0,
  21539. 0x016c1171,0x186607a0,0x006e0106 } },
  21540. /* 25 */
  21541. { { 0x08dd73b1,0x0639ac24,0x17b43652,0x00e11f32,0x02ab7767,0x0f5462b5,
  21542. 0x1c7ce0e1,0x1dbd2039,0x00442594 },
  21543. { 0x12d4b65b,0x07d51648,0x12430dfe,0x0468772d,0x18d1f94c,0x1250af4b,
  21544. 0x1a3b4c9b,0x0a2985dc,0x00a796fa } },
  21545. /* 26 */
  21546. { { 0x023addd7,0x0cfdb024,0x19a4eccd,0x14c307ca,0x13c809e2,0x1bc71e5f,
  21547. 0x1ba7e216,0x1538d2ec,0x00e4ad2d },
  21548. { 0x0e048a61,0x0bfbfa14,0x04b6680d,0x1a331981,0x0d8ef082,0x0d7a601f,
  21549. 0x050ff0e8,0x08d86f6a,0x00c5e940 } },
  21550. /* 27 */
  21551. { { 0x0be75f9e,0x1b529c61,0x048e9e11,0x0353d196,0x1c04b6fd,0x06f85884,
  21552. 0x1d1f6179,0x15fb68c8,0x0063283d },
  21553. { 0x1af2df15,0x139467bd,0x1669fd33,0x0588aa15,0x0bcc3e59,0x1356f41a,
  21554. 0x04e3eac8,0x15633035,0x0068bd19 } },
  21555. /* 28 */
  21556. { { 0x1887d659,0x04756a88,0x164c16b0,0x09abe966,0x14fe3337,0x14c0e7f3,
  21557. 0x1f5a5a61,0x1ea78dfb,0x00495292 },
  21558. { 0x1acec896,0x143c64f0,0x16d12112,0x096421d8,0x160a7d96,0x1bf13326,
  21559. 0x00dd9a5b,0x01a4c06d,0x000ec753 } },
  21560. /* 29 */
  21561. { { 0x0d2687bb,0x0d09d02d,0x0b887e8b,0x1076d5e6,0x0607ba1f,0x0f7a8eea,
  21562. 0x1c2ce43d,0x14cc90c7,0x000f6207 },
  21563. { 0x0f138233,0x0b3f1dd8,0x0aa9c62f,0x0d72d84e,0x088aedd6,0x02039376,
  21564. 0x173e3b40,0x0e411dad,0x00ff0db0 } },
  21565. /* 30 */
  21566. { { 0x0c95d553,0x04fd080a,0x1a02a29d,0x00a5faba,0x1566fa44,0x018bff9d,
  21567. 0x1a8c60ed,0x07910e81,0x00313b51 },
  21568. { 0x08d11549,0x00171560,0x17b8872d,0x1dc21769,0x0320e071,0x03eea3f9,
  21569. 0x1e049ae6,0x1f30de33,0x002d3abc } },
  21570. /* 31 */
  21571. { { 0x015581a2,0x0144280c,0x08846bd3,0x14daacc6,0x12e999a0,0x1d078655,
  21572. 0x137c66e9,0x021bdb31,0x00c036fa },
  21573. { 0x01fbd009,0x0d7045d6,0x1456058a,0x1163200d,0x00d8f0b6,0x193bcdcf,
  21574. 0x06530bac,0x1896da80,0x00a6b2a2 } },
  21575. /* 32 */
  21576. { { 0x0d3549cf,0x019f287b,0x135997b5,0x06d2dff5,0x1fcb46f3,0x1ed66708,
  21577. 0x0181a56f,0x0a55ef93,0x00810ee2 },
  21578. { 0x1159bb2c,0x0a287f0b,0x02cd5ed9,0x1f7d7ceb,0x1ea72f7d,0x1f3a6b4f,
  21579. 0x1d14ac15,0x0f524e62,0x00d48571 } },
  21580. /* 33 */
  21581. { { 0x10cb5a98,0x0ba0d457,0x0c442fc4,0x151f263e,0x02adfd3d,0x1165d59c,
  21582. 0x01386653,0x14e5f34c,0x006a6045 },
  21583. { 0x02b2411d,0x186069fd,0x03a5b805,0x1d707ca2,0x1b3ccbe0,0x0fb9c432,
  21584. 0x1e40ef32,0x1f5f3c2a,0x00d3e45c } },
  21585. /* 34 */
  21586. { { 0x083f7669,0x10fb4ddf,0x01df5af3,0x115d04e5,0x0278d09f,0x172a1922,
  21587. 0x06725522,0x1bdc7858,0x00207755 },
  21588. { 0x0fef1945,0x1deb0ecb,0x0b4a30e1,0x0279df62,0x164aa188,0x08eb396f,
  21589. 0x00367ef3,0x1cae2a96,0x0048dc5e } },
  21590. /* 35 */
  21591. { { 0x17e5a199,0x11bc85ff,0x0732edc4,0x1f719f31,0x19c79e0e,0x15ff0528,
  21592. 0x111709e8,0x1dbbfede,0x00f2fb0a },
  21593. { 0x10b5025f,0x0e04abaf,0x1ea7c890,0x0a87ae81,0x1fbd0550,0x04569c05,
  21594. 0x14963e8f,0x02bb651a,0x00a13e90 } },
  21595. /* 36 */
  21596. { { 0x02b65cbc,0x0fbd1a85,0x119089be,0x0972e454,0x107a10b0,0x1120f11f,
  21597. 0x09bc9973,0x160292ea,0x002bf0d6 },
  21598. { 0x0b216fb7,0x1ea6e9fa,0x17689ab4,0x0f70cff7,0x0505cf7d,0x1c1fb384,
  21599. 0x027ebade,0x0b42c5fd,0x0042a94a } },
  21600. /* 37 */
  21601. { { 0x0aadf191,0x0235685f,0x089a35d6,0x1491204b,0x1c1f60f8,0x182824a6,
  21602. 0x18f7a180,0x0d38cbdb,0x002c2dd9 },
  21603. { 0x13849c17,0x0810b8ec,0x0894375b,0x0911743b,0x05485460,0x03831e1d,
  21604. 0x16f12043,0x03e858ad,0x00f437fa } },
  21605. /* 38 */
  21606. { { 0x0a0f7dab,0x1506b8a2,0x1dba6b1a,0x092f262e,0x197860f0,0x10287af9,
  21607. 0x0aa14b02,0x066a8e0f,0x00aaf45b },
  21608. { 0x018d364a,0x0f1be19e,0x125c5961,0x17360c7c,0x05444d40,0x0b408af6,
  21609. 0x0af3d05c,0x01be9e4e,0x00cdf631 } },
  21610. /* 39 */
  21611. { { 0x0ea8b7ef,0x039e311c,0x0f08a1dd,0x126a310b,0x08e3408e,0x13b915ed,
  21612. 0x1fc90655,0x175b53c5,0x00f0d008 },
  21613. { 0x0414d3b1,0x089338e9,0x067a9d8a,0x0a930b60,0x1cbdbb37,0x1cb6a29d,
  21614. 0x0e2d7186,0x1eb9510f,0x005bd5c2 } },
  21615. /* 40 */
  21616. { { 0x149a3154,0x187a34f7,0x0acba6bb,0x0b4b2adc,0x04a9c3e8,0x160f5549,
  21617. 0x1c6516ab,0x191413c8,0x00aa12df },
  21618. { 0x0df69f1d,0x1793913a,0x1fd79cc9,0x09905945,0x1dd44e0e,0x0739dbd4,
  21619. 0x0406e763,0x0e7c9195,0x006c036e } },
  21620. /* 41 */
  21621. { { 0x0f6e3138,0x07d70950,0x0b4d1697,0x0dde004b,0x12bc5696,0x0325a2b3,
  21622. 0x1892264f,0x0b12d5f7,0x00292ff6 },
  21623. { 0x1e213402,0x09286a22,0x04b27fb5,0x101c4e87,0x072e8f65,0x1cbfed0e,
  21624. 0x09d825ec,0x1206236e,0x00644e0c } },
  21625. /* 42 */
  21626. { { 0x047153f0,0x0f210f0d,0x01063278,0x1876f324,0x17672b86,0x0743b82e,
  21627. 0x09de4ef7,0x127956f3,0x00f25ae7 },
  21628. { 0x0d869d0c,0x198ca51b,0x01b09907,0x0b910493,0x0945e9d5,0x0f5184b7,
  21629. 0x08f927ed,0x0a627b61,0x0039b8e6 } },
  21630. /* 43 */
  21631. { { 0x16fd2e59,0x1baa1005,0x157263cd,0x0580cd24,0x0573935e,0x190d0715,
  21632. 0x0c1b676a,0x05e1e33b,0x0039122f },
  21633. { 0x03cad53c,0x1de70f00,0x1705f8f3,0x16581fcc,0x13877225,0x18e94d50,
  21634. 0x1e35caeb,0x1f19d01f,0x008de80a } },
  21635. /* 44 */
  21636. { { 0x007bbb76,0x1df546c9,0x1e09d62b,0x18fcf842,0x036b1921,0x1ba58e02,
  21637. 0x10137e8a,0x00c5c6d1,0x00871949 },
  21638. { 0x03993df5,0x0fc945dd,0x0cf49aad,0x1aeb6be7,0x15050639,0x13c542da,
  21639. 0x1784046a,0x0d4b6e9f,0x00fc315e } },
  21640. /* 45 */
  21641. { { 0x08d6ecfa,0x10fea0d7,0x1b1fe195,0x1889ec35,0x0741d5f8,0x153da492,
  21642. 0x02226114,0x15bdc712,0x00e6d4a7 },
  21643. { 0x0593c75d,0x02a9768a,0x09c45898,0x0e1b49ba,0x0c7db70a,0x0f49bdd1,
  21644. 0x195f4abb,0x13537c55,0x0035dfaf } },
  21645. /* 46 */
  21646. { { 0x0a736636,0x1cab7e6d,0x0b2adf9a,0x0a3b2f5c,0x0996609f,0x1fa0879a,
  21647. 0x14afec42,0x1ae39061,0x001da5c7 },
  21648. { 0x1cce6825,0x020f2419,0x15cf0ed7,0x1a231ff2,0x036b815a,0x0963f918,
  21649. 0x075a8a15,0x1fbb7e97,0x007077c0 } },
  21650. /* 47 */
  21651. { { 0x06b9661c,0x1b1ffc6a,0x0b3f5c6f,0x1fa6d61a,0x1f8f7a1d,0x10a05423,
  21652. 0x19100dcf,0x05dca1df,0x0053a863 },
  21653. { 0x096d8051,0x0bb7fb43,0x13d1a282,0x18192b8e,0x026bddae,0x06e1af27,
  21654. 0x13058a65,0x0da69c3f,0x00028ca7 } },
  21655. /* 48 */
  21656. { { 0x1c9877ee,0x08ea3ee7,0x074000b4,0x06c42100,0x060b6c8b,0x008baa61,
  21657. 0x011b400b,0x1b0d2c5e,0x0004c17c },
  21658. { 0x10daddf5,0x0cde84a5,0x1395701b,0x046aea49,0x003b5bea,0x0b73396d,
  21659. 0x11d198cd,0x1d3fdb2e,0x00f7ba4d } },
  21660. /* 49 */
  21661. { { 0x0be1263f,0x06dfd1a7,0x0b9f39b4,0x0c6e6ae3,0x0f523557,0x02a9c153,
  21662. 0x11074910,0x000a4263,0x00e31f96 },
  21663. { 0x0a6b6ec6,0x0ddc90b7,0x10bf1134,0x03a25ce7,0x0a29437a,0x1f5644e8,
  21664. 0x11ef0439,0x0b39c69a,0x00aa3a62 } },
  21665. /* 50 */
  21666. { { 0x16f3dcd3,0x1e7cefa9,0x0fdcd83e,0x1bdaa1a5,0x04f5b6ce,0x087d6fa8,
  21667. 0x0bb9245c,0x0c4fcf3b,0x002398dd },
  21668. { 0x0d09569e,0x1a382d1b,0x127dda73,0x0c3376a2,0x0034cea0,0x01bb9afb,
  21669. 0x0843fe70,0x1643808c,0x005717f5 } },
  21670. /* 51 */
  21671. { { 0x01dd895e,0x1f114e49,0x10a11467,0x030a0081,0x17ecd8e5,0x091c8eb1,
  21672. 0x037be84f,0x0ac1c785,0x00660a2c },
  21673. { 0x167fcbd0,0x06544576,0x0a7c25a7,0x0e48f01d,0x12b4dc84,0x1a40b974,
  21674. 0x114ccacb,0x0989ea44,0x00624ee5 } },
  21675. /* 52 */
  21676. { { 0x1897eccc,0x0aa4e726,0x06202a82,0x13a3b27f,0x07c204d4,0x1211821d,
  21677. 0x0f01c8f0,0x1f7257bf,0x004f392a },
  21678. { 0x1de44fd9,0x0b4fc7d3,0x0cc8559a,0x19f7c8af,0x0bc3cb66,0x14019b47,
  21679. 0x06736cbe,0x0ef99b67,0x008a3e79 } },
  21680. /* 53 */
  21681. { { 0x06c4b125,0x0f0c40f8,0x18f2a337,0x09c601ed,0x013e9ae3,0x0cef2e3d,
  21682. 0x1013bda6,0x046e1848,0x003888d0 },
  21683. { 0x04f91081,0x11401ab2,0x0055411d,0x1f9ec2be,0x0d36e3d9,0x16e43196,
  21684. 0x0cd8609f,0x08e30204,0x00a5e62e } },
  21685. /* 54 */
  21686. { { 0x0facd6c8,0x1412f719,0x0f2f1986,0x18c6a8a9,0x19931699,0x16fbcc6f,
  21687. 0x0b70338f,0x1cc8cd4b,0x002c4768 },
  21688. { 0x10a64bc9,0x1a37fc64,0x1de7d72c,0x14c041c8,0x1e884630,0x08325e02,
  21689. 0x0a836527,0x083f3cca,0x007b5e64 } },
  21690. /* 55 */
  21691. { { 0x1d28444a,0x0b4a1160,0x04da8e48,0x0d8bb17c,0x07fcee99,0x17f2fd86,
  21692. 0x11288e1e,0x196191ae,0x00b8af73 },
  21693. { 0x138b86fd,0x1ef41d51,0x02973fd7,0x07e2b14b,0x09433fee,0x07b79056,
  21694. 0x025727ba,0x0befe7e1,0x00a03639 } },
  21695. /* 56 */
  21696. { { 0x010f7770,0x039e35dd,0x0a838923,0x02db0342,0x02b9fa6f,0x1b4128de,
  21697. 0x14cc4037,0x0030ebf6,0x004be36b },
  21698. { 0x1fb56dbb,0x11304374,0x19e93e24,0x1fdf160f,0x12f20306,0x0602b36a,
  21699. 0x0303bab3,0x10e37b80,0x008cbc9a } },
  21700. /* 57 */
  21701. { { 0x00dac4ab,0x098c4ae6,0x0bfc44b8,0x094880e2,0x0ee57a87,0x173e350e,
  21702. 0x17e18cca,0x07c18106,0x0044e755 },
  21703. { 0x1734002d,0x0a81fffb,0x0d10971b,0x0b971616,0x138b59d3,0x013b0743,
  21704. 0x106257dc,0x074bd71f,0x00470a68 } },
  21705. /* 58 */
  21706. { { 0x10513482,0x0dbb0ee4,0x1a49daa0,0x0e405403,0x13083028,0x00f70673,
  21707. 0x1bbf3691,0x1218c7b8,0x00164106 },
  21708. { 0x0d06a2ed,0x081a5033,0x06c402fd,0x1aee8a31,0x018c9dd4,0x173955c1,
  21709. 0x0d3f6452,0x1faf5797,0x00d73479 } },
  21710. /* 59 */
  21711. { { 0x1ad4c6e5,0x16f7d8b2,0x01b4135f,0x19e11eb6,0x1cb14262,0x0dd8c2ba,
  21712. 0x19ac4bb5,0x1c60ee2c,0x00816469 },
  21713. { 0x161e291e,0x1d5cebca,0x17859875,0x1b5e4583,0x00513eb9,0x13f589af,
  21714. 0x1e73d260,0x047e1ba7,0x000a36dd } },
  21715. /* 60 */
  21716. { { 0x01d5533c,0x0c69963a,0x0118a3c2,0x1eb53d0d,0x1bd117c5,0x1456f1a4,
  21717. 0x0460e688,0x1adfb756,0x00e331df },
  21718. { 0x0bcc6ed8,0x08055b43,0x1e898394,0x01877bde,0x050d7716,0x0cd3de74,
  21719. 0x0e26418f,0x054925c6,0x00d3b478 } },
  21720. /* 61 */
  21721. { { 0x13821f90,0x0a4db747,0x1adeab68,0x1bb3dacd,0x1311692e,0x14a98d00,
  21722. 0x16f42ed9,0x0b4990d4,0x00728127 },
  21723. { 0x13ff47e5,0x01c2c7be,0x00591054,0x0c2d78c2,0x19bb15e1,0x188d3efe,
  21724. 0x01658ac3,0x0fd9c28a,0x002c062e } },
  21725. /* 62 */
  21726. { { 0x0159ac2e,0x1b7ccb78,0x16c9c4e9,0x1cee6d97,0x06047281,0x09440472,
  21727. 0x1bc4ab5b,0x1f2589cf,0x00282a35 },
  21728. { 0x00ce5cd2,0x01aa58f6,0x1e708a67,0x13df9226,0x0c11ecf9,0x179c1f41,
  21729. 0x0af664b2,0x026aa9a5,0x00c71cd5 } },
  21730. /* 63 */
  21731. { { 0x09b578f4,0x042ef4e0,0x0bfe9e92,0x09c4b1c7,0x02f1f188,0x18dbac8c,
  21732. 0x0e8e3dda,0x0819e8fe,0x00c50f67 },
  21733. { 0x174b68ea,0x0e256f99,0x0597f8aa,0x0de646d3,0x13050a40,0x111142d2,
  21734. 0x0370be1a,0x14e4252b,0x00b9ecb3 } },
  21735. /* 64 */
  21736. { { 0x14f8b16a,0x17c20877,0x1ec99a95,0x0835fd88,0x087c1972,0x15c736ce,
  21737. 0x0c6c2901,0x0059a855,0x00803f3e },
  21738. { 0x04dbec69,0x18184d40,0x0eb417df,0x170bee77,0x0197fa83,0x1939d6c7,
  21739. 0x17071825,0x01ca0cf5,0x00c09744 } },
  21740. /* 65 */
  21741. { { 0x0379ab34,0x0352b796,0x077e3461,0x1c0d1708,0x068efa8e,0x022c8bb6,
  21742. 0x1cc080c5,0x1ab22be3,0x00f1af32 },
  21743. { 0x1d75bd50,0x0e1ba98a,0x0bd9ef26,0x19ff75ee,0x1723f837,0x120c246b,
  21744. 0x122c184e,0x061c5a83,0x0023d0f1 } },
  21745. /* 66 */
  21746. { { 0x141500d9,0x0bd5b76f,0x0fab6a21,0x1215cbf9,0x059510d8,0x032444b9,
  21747. 0x0b754bfa,0x1ad8147f,0x00b0288d },
  21748. { 0x050bcb08,0x09907983,0x175b85a1,0x1ec626d2,0x1aa7671a,0x1053dcc4,
  21749. 0x0348c7d4,0x09fe8119,0x00ffd372 } },
  21750. /* 67 */
  21751. { { 0x1458e6cb,0x1cb47325,0x1e974a14,0x1b5a4062,0x15f56992,0x1705bd53,
  21752. 0x1b7ce052,0x095af184,0x00f5590f },
  21753. { 0x0f0ba55a,0x1e125e9e,0x1de2eb83,0x08e49418,0x1674a0fc,0x0327b41d,
  21754. 0x088073a6,0x0a9edee9,0x0018d6da } },
  21755. /* 68 */
  21756. { { 0x15be5a2b,0x0c9f112e,0x0d3cf1bb,0x0f3306b2,0x06ffc6fe,0x04931131,
  21757. 0x05a90c50,0x1b2f3204,0x0050bbb4 },
  21758. { 0x057ec63e,0x1c0c8e37,0x07736c8d,0x04588030,0x0e0f6654,0x04cd811b,
  21759. 0x070d06a0,0x03003fc9,0x002b1001 } },
  21760. /* 69 */
  21761. { { 0x1b391593,0x0345ae2c,0x009c3f3f,0x0beb44b3,0x0dcbbc38,0x19d568cd,
  21762. 0x1831c513,0x13307f75,0x00dd5589 },
  21763. { 0x14b82ff4,0x1dc45c73,0x19cd3264,0x007880e3,0x0322ad2e,0x0f57a1e0,
  21764. 0x010669ea,0x0a2293ac,0x00e6e4c5 } },
  21765. /* 70 */
  21766. { { 0x1e9af288,0x0fb2add8,0x0b6a4c55,0x1c34c9ef,0x020e5647,0x1f25e594,
  21767. 0x1bfd0da5,0x1620fdaa,0x0051e00d },
  21768. { 0x171c327e,0x1e8b4dc3,0x05b0ab50,0x1b641695,0x1477929c,0x08fa9ef5,
  21769. 0x05df01f5,0x08293052,0x00e22f42 } },
  21770. /* 71 */
  21771. { { 0x035f1abb,0x0a2f47a3,0x14e21d33,0x18196ad0,0x0034d7ed,0x160fdad4,
  21772. 0x0327251c,0x07aa5b89,0x00f70937 },
  21773. { 0x08af30d6,0x00cb35dd,0x0deda710,0x1ebe95e2,0x1c47e95b,0x0b1549b0,
  21774. 0x0c44e598,0x111ce4eb,0x00bd52d2 } },
  21775. /* 72 */
  21776. { { 0x1c5fa877,0x18aae3d4,0x0e8f522a,0x15ace4fa,0x189d817d,0x1fcf39e8,
  21777. 0x1e990fd0,0x1c99154e,0x00a0d0f8 },
  21778. { 0x0c94f92d,0x1df57ec6,0x1376ce82,0x11917c18,0x0ba14d81,0x12fc5c17,
  21779. 0x08008b31,0x18f28dad,0x00a56c78 } },
  21780. /* 73 */
  21781. { { 0x0dd09529,0x0b11c8d8,0x0b77f3ca,0x1c1d4c7b,0x1f481803,0x1a8fadad,
  21782. 0x19e8b1dc,0x1f0e6346,0x00d8befd },
  21783. { 0x1c0157f4,0x1c8cea17,0x1239942a,0x195daffd,0x08b0af51,0x05a0016a,
  21784. 0x11e337e7,0x14b9d3ec,0x00854a68 } },
  21785. /* 74 */
  21786. { { 0x03506ea5,0x01afb3db,0x1f8359b7,0x0d891349,0x1cd4d928,0x0e9dff4a,
  21787. 0x0a54fc40,0x0173108d,0x005cacea },
  21788. { 0x1ceac44d,0x086fb064,0x13470eaa,0x0535e86a,0x1babe3db,0x1ef456ae,
  21789. 0x1ea42374,0x0246bc9d,0x00e4982d } },
  21790. /* 75 */
  21791. { { 0x034cd55e,0x18825116,0x00344c88,0x12b7664d,0x1d943586,0x0d7d0fd0,
  21792. 0x1267ecd1,0x1ec2d640,0x008046b7 },
  21793. { 0x18e7d098,0x099ac0f1,0x1bc2dc2d,0x0c3d1be8,0x178c4d7f,0x14f52265,
  21794. 0x1d54c37a,0x0f721055,0x00eb17ca } },
  21795. /* 76 */
  21796. { { 0x16a145b9,0x1a8dacc3,0x0f1c7b05,0x1ed61f83,0x115bba5c,0x1ab29c93,
  21797. 0x04c74f80,0x175f56bc,0x00097b00 },
  21798. { 0x165f69e1,0x1336474a,0x0f94666a,0x11eeb56b,0x1d98477e,0x1d08ed27,
  21799. 0x127980ce,0x0f75fb79,0x00f95c74 } },
  21800. /* 77 */
  21801. { { 0x1ebae45e,0x0c780e9d,0x0f1a5555,0x17d3e189,0x04fc6a8e,0x02d8ede3,
  21802. 0x00debadc,0x03cacddb,0x00351260 },
  21803. { 0x1a1161cd,0x19b78f0f,0x197be1e4,0x1571aa98,0x121e5328,0x17713927,
  21804. 0x0dad1d5f,0x046c0d15,0x000ef971 } },
  21805. /* 78 */
  21806. { { 0x14ca4226,0x12cc67ba,0x190b2380,0x1bc271f0,0x017905ee,0x1fba2347,
  21807. 0x12552258,0x066769f7,0x00fc16d9 },
  21808. { 0x07c800ca,0x14b7d98f,0x1e2b6aaf,0x00c6624c,0x1e8b5138,0x024bb7f9,
  21809. 0x085cf589,0x1e372baf,0x0014ca4a } },
  21810. /* 79 */
  21811. { { 0x1d2f81d5,0x123b8dd5,0x1df4659e,0x1f3ad203,0x1c9071a5,0x1f7be56c,
  21812. 0x0c776262,0x0c7eb384,0x004057b0 },
  21813. { 0x09c05c0a,0x1fec17f4,0x1037e16f,0x0238de3b,0x016dbe49,0x065751ad,
  21814. 0x0c4cefbf,0x0c9e2661,0x001c3b5d } },
  21815. /* 80 */
  21816. { { 0x00ec21fe,0x1f0a5ff4,0x156fa097,0x1c22d584,0x05d67f6c,0x0d0397a5,
  21817. 0x0ebe62f1,0x091b6fcc,0x00fad271 },
  21818. { 0x09ab05b3,0x0605b561,0x0946b9a4,0x1350789c,0x0de7d37a,0x043ae155,
  21819. 0x0a1029f7,0x1c73e1c3,0x0077387d } },
  21820. /* 81 */
  21821. { { 0x056c0dd7,0x14f6624d,0x021b1d07,0x1ff9b08c,0x1aecea5c,0x0a047a82,
  21822. 0x11fa3de8,0x1817de18,0x00b37b85 },
  21823. { 0x0c0e6a8f,0x0cb5b726,0x0e23c8cd,0x1a977ed6,0x0ef4efd6,0x09fd61ce,
  21824. 0x0356ae91,0x191f3ec5,0x009c135a } },
  21825. /* 82 */
  21826. { { 0x04e35743,0x15519014,0x08f37bcc,0x1ad5630b,0x19819320,0x18bb0ef8,
  21827. 0x147ee086,0x03f88670,0x00572136 },
  21828. { 0x11fc9168,0x186d9b53,0x17100f07,0x1174e6bc,0x0d8f55f9,0x143f1bde,
  21829. 0x06f7d932,0x193cd762,0x00dcbac3 } },
  21830. /* 83 */
  21831. { { 0x0518cbe2,0x00eccb42,0x07ac13bc,0x05f83139,0x1eebfd24,0x11e3f23f,
  21832. 0x0189c9d9,0x13c5ac4d,0x00b8c1c8 },
  21833. { 0x08e1d569,0x0d2c5eee,0x16233414,0x1013916f,0x131eb563,0x1fecf88f,
  21834. 0x0b509b09,0x1b45f284,0x005d23bb } },
  21835. /* 84 */
  21836. { { 0x15c8f8be,0x10e394a4,0x1cd8afc2,0x03890077,0x1d4ac296,0x0201efb1,
  21837. 0x04027906,0x19723d9d,0x00c109f9 },
  21838. { 0x18945705,0x1684ae82,0x1ae17030,0x107b2dbb,0x0449bb90,0x15c6bd20,
  21839. 0x1b8611a4,0x09e5ddc3,0x009bc334 } },
  21840. /* 85 */
  21841. { { 0x02913074,0x0ad71ab2,0x0950ac43,0x12364e91,0x0732a554,0x1332d988,
  21842. 0x13051a72,0x0a4be349,0x0029591d },
  21843. { 0x184f983f,0x1b7adb5d,0x17e13879,0x1dde833e,0x0a189be7,0x0a4b405d,
  21844. 0x0cb04803,0x03e31de6,0x00637655 } },
  21845. /* 86 */
  21846. { { 0x162976cc,0x0d2f8a72,0x1c4b0e2f,0x1947cc1d,0x0985222b,0x18323665,
  21847. 0x01eaefe8,0x19011c53,0x00bdb79d },
  21848. { 0x0b06a772,0x0965ae4e,0x14db73bf,0x08eb55fc,0x15db838f,0x10113e15,
  21849. 0x052b0a8f,0x0035ba78,0x008ee860 } },
  21850. /* 87 */
  21851. { { 0x04ade873,0x1f4b4c0d,0x1ee92332,0x13549b89,0x14ba57ee,0x144cad02,
  21852. 0x092cb3b8,0x0f4deef5,0x0092e51d },
  21853. { 0x1190a34d,0x045d7d43,0x0f47b465,0x11eeb7ed,0x11144d69,0x13718657,
  21854. 0x0aab403b,0x0de14ad5,0x005182f8 } },
  21855. /* 88 */
  21856. { { 0x1a4cc99c,0x1d310963,0x1b67287e,0x0136d07c,0x18c5aff6,0x13e5ad64,
  21857. 0x1bc976ec,0x0ba80e74,0x0091dcab },
  21858. { 0x1f575a70,0x0db661ea,0x0361fe80,0x06c272df,0x017360cb,0x074644cc,
  21859. 0x1cac5975,0x1b72f2e9,0x0017a0ce } },
  21860. /* 89 */
  21861. { { 0x076c8d3a,0x0430f150,0x03e492ce,0x155a7242,0x035d9701,0x157209d4,
  21862. 0x1d065343,0x0d8fe99b,0x002e8ce3 },
  21863. { 0x037a862b,0x0939ed58,0x19323ea4,0x15376ec1,0x0f2dd01b,0x09c419dd,
  21864. 0x03cfe591,0x19669ecd,0x00f4ccc6 } },
  21865. /* 90 */
  21866. { { 0x11f79687,0x077a92e7,0x1bea0551,0x12a92b25,0x18d297c5,0x0ba0d2e3,
  21867. 0x0f27848c,0x111341be,0x00ac0db4 },
  21868. { 0x1f01747f,0x15fe388e,0x05f7c4e1,0x1726b1de,0x16bb5592,0x0727ae65,
  21869. 0x128b9620,0x0c32992e,0x0095a64a } },
  21870. /* 91 */
  21871. { { 0x015a4c93,0x160f7ed6,0x1614505c,0x0d36e704,0x10bad402,0x1d8e0b65,
  21872. 0x19ddaa37,0x17452420,0x00231e54 },
  21873. { 0x0ae6d2dc,0x186fc8bc,0x044a4629,0x154c7e72,0x172234d6,0x1935af2d,
  21874. 0x0787d89d,0x065b14e6,0x00ab0be0 } },
  21875. /* 92 */
  21876. { { 0x0d131f2d,0x0bd6874c,0x013c4042,0x1e13c676,0x1a748637,0x10cb6af4,
  21877. 0x19e46b21,0x10059ed4,0x00f1bcc8 },
  21878. { 0x08daacb4,0x0e348a07,0x1d940249,0x1c80aac1,0x137a63c4,0x047e23bc,
  21879. 0x09c56473,0x0d2b5d76,0x00851694 } },
  21880. /* 93 */
  21881. { { 0x11dcf593,0x11ae0a1f,0x062f8ef7,0x00565360,0x19d3d782,0x16e14dee,
  21882. 0x1763a736,0x1a5b55aa,0x008f67d9 },
  21883. { 0x1481ea5f,0x0088b2b3,0x13164321,0x05bbd3c6,0x13fa8e7d,0x01fa0282,
  21884. 0x0d77ff75,0x17380e51,0x00f84572 } },
  21885. /* 94 */
  21886. { { 0x17af71c9,0x10d3d38c,0x1cd95957,0x092888f4,0x15063a14,0x1703870e,
  21887. 0x106686d2,0x020c2d65,0x00edee27 },
  21888. { 0x11734121,0x1781a7a8,0x097a7c2c,0x18dcaa94,0x02ecf1ca,0x0479d206,
  21889. 0x1fd23705,0x13689d7a,0x009fd27e } },
  21890. /* 95 */
  21891. { { 0x16e2cb16,0x063b2c57,0x16466d8f,0x16fa59fc,0x15583e3e,0x0c0b0b46,
  21892. 0x0e1d6a31,0x16d2b1fe,0x00a40c2f },
  21893. { 0x1edcc158,0x04f62b07,0x1c8c15a3,0x10098cab,0x07e127ad,0x13824d18,
  21894. 0x1b3f64e5,0x170fb8db,0x0099bc9b } },
  21895. /* 96 */
  21896. { { 0x127dafc6,0x054a90ec,0x02734661,0x03f6d2b8,0x06dde52c,0x00d07c9b,
  21897. 0x19927656,0x01742daf,0x009abe21 },
  21898. { 0x08915220,0x0057c252,0x1605b192,0x062ed49b,0x1ca5afa7,0x1cc38b40,
  21899. 0x12c31f54,0x0af0fe68,0x007881c2 } },
  21900. /* 97 */
  21901. { { 0x00bcf3ff,0x19ccda8f,0x1fdd3da4,0x05978a24,0x1d9680d0,0x12d16e80,
  21902. 0x05023ed1,0x033461d1,0x0015e6e3 },
  21903. { 0x1e0e05f4,0x036b7069,0x16210119,0x0f7bb886,0x050d3fad,0x03e8e27c,
  21904. 0x0b3af987,0x19e3222e,0x000e55fa } },
  21905. /* 98 */
  21906. { { 0x18787564,0x14ecc037,0x1a17399f,0x062e4263,0x1e8d61a3,0x0c655c0c,
  21907. 0x15ddac05,0x0ecdfd2c,0x00d73d09 },
  21908. { 0x1eb7206e,0x1241a128,0x062ed090,0x12521f8c,0x0a520a51,0x1c2caf18,
  21909. 0x142d772e,0x0e91e2b4,0x009250a3 } },
  21910. /* 99 */
  21911. { { 0x1e577410,0x17f847c5,0x1dea31b2,0x011406a0,0x063a4fd4,0x1944f605,
  21912. 0x102fc7d8,0x10583991,0x00774140 },
  21913. { 0x0b0991cd,0x0d207d37,0x1f70a581,0x1410cc93,0x0fd40c1c,0x11e3d992,
  21914. 0x02e4e9a2,0x09a25d64,0x008cb04f } },
  21915. /* 100 */
  21916. { { 0x0906171c,0x0e1682ab,0x09030fec,0x07d39b60,0x06841907,0x15a7ec48,
  21917. 0x0d476e39,0x1de8e247,0x00e4e429 },
  21918. { 0x18ec36f4,0x1c6ea9e1,0x12da89c2,0x05b803fe,0x09a48f9d,0x1703c3cd,
  21919. 0x15497419,0x1fe78dcc,0x0037bca2 } },
  21920. /* 101 */
  21921. { { 0x1f562470,0x06971e3e,0x0592b253,0x04e54581,0x193be44f,0x0efcc063,
  21922. 0x08a9f1b5,0x1b860056,0x0059913e },
  21923. { 0x1750592a,0x109cd41a,0x00f7809e,0x003b01cf,0x1d64f99e,0x01baf502,
  21924. 0x089b3e30,0x0956027c,0x0043786e } },
  21925. /* 102 */
  21926. { { 0x1e56b5a6,0x1995876c,0x1f1a3e7f,0x01b34db3,0x046a7075,0x1422acbc,
  21927. 0x19ebb057,0x1316fcf3,0x008638ca },
  21928. { 0x0afc24b2,0x1ad704b0,0x0b3a3c8b,0x131d5e9b,0x1a78f053,0x0ee85765,
  21929. 0x1bc0edd9,0x0d4f6754,0x001ecdd3 } },
  21930. /* 103 */
  21931. { { 0x0c5ff2f3,0x09d66b13,0x1cea5e17,0x0a2d8050,0x10d54a2d,0x04fd6908,
  21932. 0x0cb6b653,0x10ba8b3e,0x00d85d0f },
  21933. { 0x10b11da3,0x1b805c68,0x00c63127,0x0458614f,0x0decdd2c,0x047a4904,
  21934. 0x118955a6,0x18769da7,0x00a04f19 } },
  21935. /* 104 */
  21936. { { 0x0d7f93bd,0x03c92647,0x0bd47d82,0x0958ba72,0x171afcb6,0x1985410d,
  21937. 0x02c1f2b8,0x1d4b812a,0x0092b2ee },
  21938. { 0x05b6e235,0x0d6264a4,0x0db03c21,0x19495252,0x08891ab2,0x1359f028,
  21939. 0x1db203ea,0x042b0684,0x001ee782 } },
  21940. /* 105 */
  21941. { { 0x063e79f7,0x10517007,0x067641a9,0x01cf65e7,0x1c09df59,0x02a53303,
  21942. 0x05424084,0x1b0af4dc,0x00f3f2ce },
  21943. { 0x110d9b55,0x0028879f,0x19099208,0x1f9f59b0,0x10e7c9d2,0x0d53f45e,
  21944. 0x0843958c,0x0a87b47c,0x000f56a4 } },
  21945. /* 106 */
  21946. { { 0x1043e0df,0x190dffd0,0x001f9b56,0x096d9938,0x0517a6c7,0x17606a54,
  21947. 0x098c6995,0x08232d3c,0x00bd8f17 },
  21948. { 0x1eb7494a,0x14dddc35,0x1cee0e22,0x0fa8de8b,0x1a79a156,0x0953d272,
  21949. 0x08277de8,0x06a6199f,0x002d1a1c } },
  21950. /* 107 */
  21951. { { 0x106508da,0x0971c09a,0x15e569c6,0x03018943,0x144b3336,0x0ca4bd4c,
  21952. 0x091b376d,0x0bd723f7,0x00a107a6 },
  21953. { 0x0f94d639,0x168e8e28,0x162df5f9,0x15e6eb14,0x1ca1c8b4,0x0ac25e9b,
  21954. 0x0bc869f1,0x015f0f53,0x00183d76 } },
  21955. /* 108 */
  21956. { { 0x0dde59a4,0x0eb4b888,0x02fbe1ca,0x1b1a0e1d,0x0be78f1a,0x04b1a797,
  21957. 0x1d508a6d,0x13b84d3a,0x001d4417 },
  21958. { 0x0390d30e,0x196e067c,0x1a04432c,0x164ea61b,0x0339a0a3,0x0ee295e0,
  21959. 0x0988c6bc,0x1852c0da,0x00771f9c } },
  21960. /* 109 */
  21961. { { 0x05040739,0x0cc9f3bc,0x09aa4e66,0x073b7300,0x0fc26445,0x1b797afc,
  21962. 0x063b3d03,0x06206c4e,0x0064427a },
  21963. { 0x05428aa8,0x1a796c3c,0x1ed26a13,0x15b87fd7,0x101ac7b7,0x1636f91e,
  21964. 0x15b4806c,0x092d5d21,0x0049d9b7 } },
  21965. /* 110 */
  21966. { { 0x035d1099,0x03c6c5e2,0x03468233,0x179a9d1d,0x08a412ad,0x1150165b,
  21967. 0x11140b0b,0x0367ec0a,0x009037d8 },
  21968. { 0x074c7b61,0x06dd6138,0x0ff5cb9f,0x006356af,0x15352fe2,0x164b2cb6,
  21969. 0x0e718733,0x0d4f980c,0x0008c3de } },
  21970. /* 111 */
  21971. { { 0x16d552ab,0x07ee8107,0x13607c48,0x15ff300b,0x1129156b,0x1e1f489a,
  21972. 0x0cbc1bed,0x0848af2d,0x00c69094 },
  21973. { 0x01231bd1,0x1d9d74e2,0x11608145,0x18dd0eb9,0x0a1221ea,0x1bd5fceb,
  21974. 0x0b008220,0x00595fc7,0x003fa3db } },
  21975. /* 112 */
  21976. { { 0x05058880,0x1ad1f328,0x0e50fcb5,0x06cbdec8,0x049257da,0x030e7d59,
  21977. 0x03fd051e,0x161fb701,0x00c5c4bd },
  21978. { 0x1272b56b,0x1a89f1a5,0x0e410e9c,0x04fd2a23,0x04969c83,0x11befc42,
  21979. 0x1ad7f633,0x1288d856,0x002d56db } },
  21980. /* 113 */
  21981. { { 0x1f46ac6b,0x030bc17f,0x08b90949,0x1ef24c0f,0x08de1d19,0x11e204d2,
  21982. 0x090bebfa,0x13bca077,0x000f56bd },
  21983. { 0x145cda49,0x1bea7689,0x1bca6744,0x02b1f902,0x03402821,0x12a5575a,
  21984. 0x17c79f1a,0x13a22e76,0x004003bb } },
  21985. /* 114 */
  21986. { { 0x00803387,0x1c740c4d,0x12f5010e,0x022bea73,0x17f21ece,0x1046e943,
  21987. 0x1e790a5c,0x04540fe5,0x00537655 },
  21988. { 0x08a4182d,0x04c0510d,0x0677de69,0x17a0f464,0x1a2d4a2b,0x05170d0c,
  21989. 0x15259d34,0x0b0d8ba8,0x007a056f } },
  21990. /* 115 */
  21991. { { 0x1d8a2a47,0x03592ac4,0x17c9dcd9,0x10529187,0x0d5395b5,0x000755f8,
  21992. 0x19d547b0,0x1e2f4344,0x0077d482 },
  21993. { 0x07853948,0x050decac,0x1efffbae,0x102f7ad9,0x01e47a6f,0x002bc034,
  21994. 0x0392adbb,0x05656716,0x00411501 } },
  21995. /* 116 */
  21996. { { 0x0de28ced,0x039f87a3,0x04fb11cf,0x1b4ec136,0x063921d5,0x074f372e,
  21997. 0x051986e3,0x0e5f7d41,0x00cdf045 },
  21998. { 0x0c53c3b0,0x059e2c5b,0x1ee10f07,0x1c782088,0x1780e97f,0x0570965c,
  21999. 0x0427ecae,0x1b52e706,0x00ee703d } },
  22000. /* 117 */
  22001. { { 0x1f57e43a,0x028a8a07,0x0e046e0d,0x0cc1a763,0x0b986d44,0x0effc7a1,
  22002. 0x1884aced,0x13b42c59,0x002a0ad8 },
  22003. { 0x0bc277ba,0x072534a3,0x10709d99,0x1192a982,0x16274c78,0x1326655f,
  22004. 0x1964506a,0x0cf58568,0x00d62d0b } },
  22005. /* 118 */
  22006. { { 0x0c054ac4,0x0e2ec3d9,0x1f7de20e,0x00b0b3e4,0x128d6570,0x05f9d8c0,
  22007. 0x109bb7df,0x1e532384,0x00b39a23 },
  22008. { 0x10b16ae5,0x094250af,0x0dbd46e5,0x140b6342,0x007830c6,0x009bf938,
  22009. 0x1314758f,0x12580ce9,0x0004ed00 } },
  22010. /* 119 */
  22011. { { 0x1ae90393,0x1a0c2e8c,0x0f593987,0x0f685294,0x0fc14304,0x00d34c2a,
  22012. 0x0e1eb800,0x18202ef8,0x00a0a91f },
  22013. { 0x0e2c831e,0x1851f80d,0x1c9f85bf,0x0d5d0456,0x075b4bb7,0x0450ad18,
  22014. 0x11063c4b,0x1113da41,0x00084cf9 } },
  22015. /* 120 */
  22016. { { 0x1ca6becf,0x0c284ef7,0x1fecca36,0x1d5d00fb,0x0e8b92fc,0x0ae223bc,
  22017. 0x1df97628,0x164e757e,0x00d57955 },
  22018. { 0x11b5d4f1,0x086d3cf1,0x1e9e8708,0x05e09679,0x1c20baa5,0x1044ee13,
  22019. 0x07c75344,0x08405a28,0x008e14ea } },
  22020. /* 121 */
  22021. { { 0x12897042,0x16a81a2f,0x100b12bb,0x0a663e86,0x1fb218d0,0x00ca645e,
  22022. 0x05632367,0x06e5549a,0x00597e1a },
  22023. { 0x0f0bd68c,0x193f60d6,0x00925140,0x17c1b956,0x03e846d4,0x06bd64ff,
  22024. 0x17a96e72,0x06c33369,0x00ca3f02 } },
  22025. /* 122 */
  22026. { { 0x0170bd20,0x095085ab,0x0fd779d6,0x112fe2da,0x0ade20ea,0x1ff8a259,
  22027. 0x1f928cd8,0x0fc61380,0x00bde7fd },
  22028. { 0x18f5432c,0x0b5db695,0x10d112d4,0x1b8397c0,0x15b5a210,0x0f37fc7c,
  22029. 0x0660f6c0,0x01c14fba,0x00b623ad } },
  22030. /* 123 */
  22031. { { 0x00c7b65b,0x1adeb3ab,0x0928a269,0x18ab2047,0x06795ab8,0x07e86bd9,
  22032. 0x0defe088,0x08cb1d82,0x00d6aa2e },
  22033. { 0x1138bb85,0x055e005a,0x0cea5704,0x03a243b0,0x0a32e8c3,0x18058b81,
  22034. 0x04eac93f,0x1c05b98a,0x00111662 } },
  22035. /* 124 */
  22036. { { 0x0fb42b87,0x008a00af,0x1b137fde,0x1ebae036,0x1c129bd9,0x066bd3eb,
  22037. 0x03e19bb3,0x197296ea,0x00db3ee1 },
  22038. { 0x134837cf,0x1379ed87,0x15e353ec,0x1da31772,0x0657de7e,0x0fc9be2b,
  22039. 0x096574b3,0x084a440d,0x00886a64 } },
  22040. /* 125 */
  22041. { { 0x05b569ea,0x011a67db,0x0846704f,0x022283ee,0x0619e200,0x042ed0ad,
  22042. 0x1ef22eb7,0x1d603142,0x00a70cf4 },
  22043. { 0x0c4a6a65,0x127cbd74,0x0d0de3c8,0x0b9e4e02,0x0096036e,0x104f27bf,
  22044. 0x0ddef8e9,0x157a2e8f,0x00aa4772 } },
  22045. /* 126 */
  22046. { { 0x1aa60cc0,0x1b3b098b,0x1a0457d9,0x02c6c206,0x1bb5ac79,0x05da5de0,
  22047. 0x05d37b66,0x1b861f5f,0x00611a6d },
  22048. { 0x015ee47a,0x073c65e6,0x0365a94c,0x12c5049c,0x1ed882e8,0x0d6f9eec,
  22049. 0x1220dbcd,0x1f02c853,0x005cfffa } },
  22050. /* 127 */
  22051. { { 0x1b7a99cd,0x06aa67fc,0x0f116870,0x07733b08,0x139e17bf,0x0847b163,
  22052. 0x05300e2a,0x046fb833,0x006e5a6b },
  22053. { 0x0ba5db77,0x1c5a2a70,0x1d8358fb,0x1100ff59,0x08378b7b,0x00633b30,
  22054. 0x0f339647,0x11a485b5,0x00481a23 } },
  22055. /* 128 */
  22056. { { 0x15d0b34a,0x1a0bde01,0x09f029f8,0x1670d706,0x162d1440,0x1316d601,
  22057. 0x050e3edc,0x099c19bf,0x002c4111 },
  22058. { 0x0d95a0b1,0x1d2e778d,0x1550d88a,0x166f50cf,0x086c9c09,0x06e900f2,
  22059. 0x0a5c9b5b,0x17e85ff2,0x0020477a } },
  22060. /* 129 */
  22061. { { 0x18d65dbf,0x1ba8b9e0,0x07b6b60b,0x1f281c67,0x1001c77b,0x0935ee78,
  22062. 0x1ad9c08b,0x1358ee72,0x00ac6640 },
  22063. { 0x06261cc3,0x185d9b7e,0x039fa422,0x1ef79232,0x06c10213,0x075d522f,
  22064. 0x1e159507,0x0eb98245,0x00ce8e69 } },
  22065. /* 130 */
  22066. { { 0x1c0a67d2,0x1890da0d,0x13492283,0x08ec1488,0x1473762d,0x078eb2cd,
  22067. 0x12a03811,0x0ca4a176,0x0008fde3 },
  22068. { 0x048bf287,0x07761ed4,0x0da75bab,0x0c4305a6,0x09482c2a,0x0fee4922,
  22069. 0x135cd60b,0x1a4acbad,0x002f7e2f } },
  22070. /* 131 */
  22071. { { 0x03770fa7,0x125c96de,0x0410fe6b,0x1d1ab86f,0x01171095,0x074e8bbb,
  22072. 0x0ab953cd,0x05d20ee0,0x00c65be9 },
  22073. { 0x16fd0a40,0x1ac5181f,0x139e12c9,0x1045c779,0x167bfe7d,0x1ac2a7cb,
  22074. 0x0ce9eb93,0x08fa2327,0x004bff8e } },
  22075. /* 132 */
  22076. { { 0x00ff1480,0x0a0e90f8,0x1536c5b3,0x11f6fa0e,0x0f3ea2ab,0x0977ddf0,
  22077. 0x19f6b207,0x1ccaee52,0x003e4e4a },
  22078. { 0x1c5303e6,0x10c79b69,0x0988e5df,0x13329724,0x0c3c03bd,0x07130992,
  22079. 0x00a27b5c,0x1fab1d8c,0x005388ae } },
  22080. /* 133 */
  22081. { { 0x1e5d7713,0x0898bf5a,0x179276ab,0x130bdceb,0x1b26109b,0x1e27e3a7,
  22082. 0x1838cbd6,0x1a29eeb7,0x005cf908 },
  22083. { 0x0e657b12,0x1021a884,0x1bb6799d,0x08434b72,0x0ccc2bfd,0x1a8fc4b8,
  22084. 0x138838a7,0x080c1e01,0x00a698ba } },
  22085. /* 134 */
  22086. { { 0x0f748fec,0x1ed8b437,0x074b3e5c,0x0eab44fd,0x05effe6e,0x12a26713,
  22087. 0x16358c2d,0x114f5d75,0x00b142ef },
  22088. { 0x17d5770a,0x098d7cf8,0x0cd04beb,0x1e76ce59,0x159de66a,0x068def99,
  22089. 0x01d5af58,0x12cb0a2a,0x00d1896a } },
  22090. /* 135 */
  22091. { { 0x13c41c08,0x02cabd59,0x1a38b87b,0x1d2958a8,0x12f6c87d,0x15b9d623,
  22092. 0x08e46205,0x016f303b,0x00267b0e },
  22093. { 0x0e62b988,0x12aa72ec,0x1b4879db,0x1b8eaa22,0x06f99d8d,0x1d781e95,
  22094. 0x0e4d1843,0x0f542232,0x00b54e28 } },
  22095. /* 136 */
  22096. { { 0x178a876b,0x100915a8,0x14412d02,0x1f2dfe10,0x09f7651f,0x18d58a79,
  22097. 0x1398142c,0x116bf0fa,0x0084abb2 },
  22098. { 0x0270790a,0x0f6a1cfc,0x18fd1af5,0x196b3b0b,0x022122d6,0x0e0db60f,
  22099. 0x1901d7d5,0x0ce2ecaa,0x00e5436f } },
  22100. /* 137 */
  22101. { { 0x0286e8d5,0x1fc812f1,0x1114ef94,0x192b690c,0x0e3a0353,0x1adef204,
  22102. 0x067b60cb,0x116b739d,0x000404f6 },
  22103. { 0x0781e8e5,0x1699def5,0x0f0bd6f2,0x1ea0302c,0x1caa33cd,0x14b0008c,
  22104. 0x1c055d5d,0x1be15838,0x003a4263 } },
  22105. /* 138 */
  22106. { { 0x1aeb596d,0x14b2f664,0x0f24ad30,0x1407ce04,0x1396101e,0x1a5b1700,
  22107. 0x0d9d1c12,0x07f20bd4,0x000ca8fd },
  22108. { 0x151b2b61,0x1291d212,0x03f341a4,0x0f513872,0x0a63e1eb,0x095f01c9,
  22109. 0x10cf9fc7,0x0c89bb61,0x0096dca2 } },
  22110. /* 139 */
  22111. { { 0x187510af,0x01dda1d1,0x08da8048,0x1fd55153,0x10378846,0x0bb817ca,
  22112. 0x077348e9,0x024755ab,0x004363e2 },
  22113. { 0x00246a47,0x121d0e3a,0x17749372,0x0571a5ca,0x1af96b36,0x03022ec7,
  22114. 0x0313e6c2,0x0b9b1773,0x00840e11 } },
  22115. /* 140 */
  22116. { { 0x1023e8a7,0x09102f10,0x171e82fc,0x11519bb1,0x05ddfc80,0x11390b1d,
  22117. 0x1b538a4a,0x17a61bda,0x005e0d6a },
  22118. { 0x1cfc0f64,0x1d390e13,0x157b6201,0x1d803a1c,0x19db242e,0x1f7c8e8f,
  22119. 0x09689a9e,0x1e8528b4,0x007dea48 } },
  22120. /* 141 */
  22121. { { 0x05060a81,0x1efb78e7,0x1e55856a,0x1f38e5f1,0x0268be79,0x162a0356,
  22122. 0x1b473f4d,0x17dd7fa2,0x00abc2a2 },
  22123. { 0x13e2eac7,0x16337c8e,0x174119a2,0x0174c7a5,0x0d31b6f1,0x11bb8141,
  22124. 0x1f059e43,0x128d8fdd,0x004ea353 } },
  22125. /* 142 */
  22126. { { 0x1266309d,0x0c517c6a,0x05168fbb,0x038d8103,0x05dc10a5,0x1a2d2bc6,
  22127. 0x1f0f3b2b,0x1123929f,0x003a76e6 },
  22128. { 0x1d7b0d0f,0x15674523,0x161297e6,0x159d2d1e,0x17fbe963,0x06392734,
  22129. 0x1191468c,0x0148cbcc,0x008212a1 } },
  22130. /* 143 */
  22131. { { 0x0fab8caa,0x1be30e1e,0x0508e43b,0x171d081c,0x133ca18e,0x1fb3bf4b,
  22132. 0x05933477,0x0e2b3396,0x00aa7cab },
  22133. { 0x1c837bd1,0x17e4939d,0x1abd75c0,0x080fa186,0x1da49c06,0x09497a11,
  22134. 0x1f0c5d88,0x0e7fc0c2,0x0040e380 } },
  22135. /* 144 */
  22136. { { 0x07bf9b7c,0x07c04125,0x0f8c343d,0x1a46407f,0x19ce3365,0x09904be7,
  22137. 0x149afef9,0x001660aa,0x00e36047 },
  22138. { 0x0cc6c2c7,0x0e5cc88b,0x132fb993,0x106e1174,0x0d9ec726,0x0a1a31bd,
  22139. 0x057f737b,0x0ef47bdc,0x006542d6 } },
  22140. /* 145 */
  22141. { { 0x1b6c377a,0x1995b683,0x0d122f8f,0x00708f20,0x08af76cb,0x09d4106d,
  22142. 0x1c875bf7,0x1dc1376d,0x00a6534a },
  22143. { 0x1035facf,0x050bc068,0x12d1f98c,0x0ab4673b,0x1f39335e,0x07f0e223,
  22144. 0x1c89ba94,0x05fb935d,0x00f3cb67 } },
  22145. /* 146 */
  22146. { { 0x1b55fd83,0x19b8cff1,0x1777443a,0x0f48d90e,0x0a784e0d,0x0fd482e7,
  22147. 0x039cceb2,0x05d55d0e,0x007cafaa },
  22148. { 0x1d53b338,0x1c0a6820,0x01f9b1a6,0x198141df,0x12b0fe0a,0x088408b3,
  22149. 0x08bbee4f,0x183737aa,0x000aab13 } },
  22150. /* 147 */
  22151. { { 0x12681297,0x0e6713c6,0x02551ab7,0x0a1d636a,0x1aaf2cb3,0x18b9bb30,
  22152. 0x0ba4b710,0x00508e02,0x004b91a6 },
  22153. { 0x12f8ddcf,0x07f884ab,0x0446bd37,0x17ec3d35,0x0430e08e,0x1b0561b9,
  22154. 0x12ad23d0,0x0a6e4643,0x0049534c } },
  22155. /* 148 */
  22156. { { 0x107b7e9d,0x1efbeb8f,0x13545be0,0x11df4627,0x07ee3a47,0x1325b602,
  22157. 0x17b9e3bc,0x09facb58,0x00caf46c },
  22158. { 0x12aa8266,0x026863bc,0x0da12ee8,0x08a8cd22,0x116b0edf,0x08b45725,
  22159. 0x1c3d5b99,0x0ae098ce,0x0014ce9e } },
  22160. /* 149 */
  22161. { { 0x165e8f91,0x0a22f1f4,0x03c924a6,0x19437596,0x0a0a0d3a,0x0387c864,
  22162. 0x09c74c73,0x14a7c993,0x001bb708 },
  22163. { 0x158bdd7a,0x0e54f34a,0x0289ac75,0x140a1003,0x0f1ec734,0x1538a64e,
  22164. 0x040ac24e,0x1e5b4600,0x00f9d126 } },
  22165. /* 150 */
  22166. { { 0x0ff9563e,0x04de53d5,0x0645281d,0x0ef5fd69,0x11671dd0,0x0188dfaf,
  22167. 0x11a789e8,0x172e53d9,0x00807afc },
  22168. { 0x09b08b77,0x1c5499be,0x0f1f8e1f,0x074f0a88,0x1d8ba86c,0x1d2ca3b7,
  22169. 0x163217eb,0x1a2cad19,0x00751adc } },
  22170. /* 151 */
  22171. { { 0x10715c0d,0x1751c5a0,0x1da5fde2,0x07d4e31e,0x1f06dd11,0x158a49fd,
  22172. 0x10fd997a,0x0d04a6ee,0x0029ec44 },
  22173. { 0x150bebbc,0x0ca38ce5,0x1415088f,0x1dcb7fc8,0x1edb1399,0x0d9d4696,
  22174. 0x1df64335,0x1c725480,0x00ff9370 } },
  22175. /* 152 */
  22176. { { 0x06b75b65,0x0d16b4de,0x19947156,0x11f1aa4c,0x1d7d2418,0x199f1ef4,
  22177. 0x0068a2a7,0x1174553a,0x00977647 },
  22178. { 0x129af2c7,0x0293116c,0x1a4248e2,0x1ebada9c,0x051e9334,0x03f2d44d,
  22179. 0x0beb39b3,0x07f585f0,0x0074a631 } },
  22180. /* 153 */
  22181. { { 0x175f079c,0x17a6feed,0x18dbeeec,0x00f92a31,0x136dd85b,0x1e7873e6,
  22182. 0x18f46db3,0x02a1fe90,0x00ab75be },
  22183. { 0x173fc9b7,0x0d9b3e00,0x1653f420,0x14e841a4,0x11236b90,0x1f81e204,
  22184. 0x07d857f6,0x05c1688b,0x004ebeac } },
  22185. /* 154 */
  22186. { { 0x1c9f2c53,0x1b62ff3a,0x0ba5047a,0x0440231d,0x0c5d8d25,0x1b19fcad,
  22187. 0x1ff32221,0x0f658375,0x00df9988 },
  22188. { 0x050aaecb,0x1bc77694,0x15a89cae,0x12303603,0x1bcac9d4,0x0a88d8e6,
  22189. 0x01625e37,0x14eef3e8,0x0027b040 } },
  22190. /* 155 */
  22191. { { 0x173b2eb2,0x0202edbf,0x06c84624,0x1f0a111c,0x0327ee0d,0x18a92cb1,
  22192. 0x0fd5406d,0x06fc99f4,0x00b393dd },
  22193. { 0x1fd75165,0x091873d9,0x14cd5528,0x06898579,0x15022d66,0x18df07bd,
  22194. 0x1065b0db,0x025a08c6,0x0009588c } },
  22195. /* 156 */
  22196. { { 0x02601c3b,0x043049f8,0x170cd7f8,0x04a5f19e,0x0ff28fb0,0x194044a5,
  22197. 0x122e5573,0x153b73ec,0x0081c879 },
  22198. { 0x06f56c51,0x007343e6,0x05d86301,0x08e2d27e,0x1353bfed,0x0520c82c,
  22199. 0x0f1113e2,0x1eabf823,0x00fa0d48 } },
  22200. /* 157 */
  22201. { { 0x01608e4d,0x0370e4ef,0x00a08b2f,0x1bb4226b,0x0c2d7010,0x0ee08abf,
  22202. 0x1f5bdadf,0x0ad6d46c,0x008ea0e1 },
  22203. { 0x0383b3b4,0x1aa70179,0x007d4f28,0x0cd7287e,0x03ca5699,0x119596f0,
  22204. 0x16b13fd9,0x049f4016,0x003f5ab9 } },
  22205. /* 158 */
  22206. { { 0x19739efb,0x1bdd86ca,0x1afb034c,0x0361e9cf,0x067d1c75,0x16eb208d,
  22207. 0x15b8b694,0x10e56e84,0x008bc768 },
  22208. { 0x02d3d253,0x0df1db94,0x035de7e9,0x0cf343eb,0x167bba9f,0x00b470b3,
  22209. 0x0d3e872b,0x120c1f9e,0x00b386f1 } },
  22210. /* 159 */
  22211. { { 0x0fedcfc2,0x0f9e09a9,0x1e2bc34c,0x0d7ec4c5,0x088c2539,0x1a7572b9,
  22212. 0x1136680a,0x1ee360d3,0x004cb460 },
  22213. { 0x1b8095ea,0x133da69a,0x101d80eb,0x17f0b2df,0x0a16592b,0x0fb35b0a,
  22214. 0x088f851d,0x0112bdea,0x0052c0d5 } },
  22215. /* 160 */
  22216. { { 0x15339848,0x18e10870,0x1de32348,0x1451d0e0,0x0e170e87,0x1330b4ab,
  22217. 0x102e7477,0x07057613,0x004ac3c9 },
  22218. { 0x0998987d,0x0df02a8b,0x027d3586,0x06ed895c,0x1933d8b2,0x1bb28d1f,
  22219. 0x17d07782,0x18fc72e0,0x00380d94 } },
  22220. /* 161 */
  22221. { { 0x01542e75,0x0d1aad54,0x006e6dc0,0x0e4943dc,0x1708796c,0x14bbb126,
  22222. 0x1ebdace8,0x0e3bc4c6,0x002ce3e1 },
  22223. { 0x15d5bc1a,0x1f7f5a4f,0x1df8ad73,0x0ac0fc4e,0x1756ca65,0x1617ca89,
  22224. 0x19353faa,0x0a416c49,0x002e6cd8 } },
  22225. /* 162 */
  22226. { { 0x0c31c31d,0x142caa5c,0x1c86830d,0x067a00b7,0x19ec9685,0x11373ae3,
  22227. 0x15502f5d,0x08e858d3,0x00ca1775 },
  22228. { 0x16d2dbb2,0x0376d7ff,0x12a74633,0x1b197a2e,0x178e8fd0,0x03c9d522,
  22229. 0x139a1d7a,0x02739565,0x00a976a7 } },
  22230. /* 163 */
  22231. { { 0x13fb353d,0x1328f8dc,0x1f3e9c82,0x195716af,0x15281d75,0x07d398d8,
  22232. 0x0666aa23,0x02e143e9,0x008720a7 },
  22233. { 0x093e1b90,0x01f469bb,0x1db7f0e3,0x0bb8162d,0x08742d34,0x08055a95,
  22234. 0x04f23aa3,0x0538ed31,0x009719ef } },
  22235. /* 164 */
  22236. { { 0x18e35909,0x10776c6a,0x177045a0,0x0db1b867,0x05026936,0x0ce83710,
  22237. 0x13075fe6,0x0edc2ae0,0x00a50729 },
  22238. { 0x04e70b2e,0x0151bf56,0x042aa280,0x19ecaed1,0x12a5c84d,0x1f8c322d,
  22239. 0x1c9735c6,0x13bef6ee,0x0099389c } },
  22240. /* 165 */
  22241. { { 0x1ada7a4b,0x1c604793,0x0e24d988,0x1d3a07fa,0x1512c3ab,0x1744bb37,
  22242. 0x0b91ad9c,0x15440590,0x00a88806 },
  22243. { 0x1380184e,0x10102256,0x1aa2e159,0x16f18824,0x04f17a8c,0x186056c2,
  22244. 0x13f9e759,0x1f68e71b,0x000043bf } },
  22245. /* 166 */
  22246. { { 0x16d5192e,0x0acdaee1,0x042cabe3,0x110ba68b,0x01781acf,0x168508b0,
  22247. 0x019a0d59,0x00374d89,0x0052f3ef },
  22248. { 0x0edcb64d,0x0c339950,0x1a0de7ce,0x10584700,0x0f3090a4,0x12fd3820,
  22249. 0x19d45b2f,0x1133de4f,0x003296bd } },
  22250. /* 167 */
  22251. { { 0x054d81d7,0x1b55d44a,0x1ae6cf11,0x1bcfdea3,0x179869ea,0x10e6c0e2,
  22252. 0x07a58668,0x17f5dcae,0x003b90fe },
  22253. { 0x1496f7cb,0x1c9811f2,0x0d46f124,0x1c83b0ff,0x0b5ce55b,0x0ea44cdf,
  22254. 0x0c600fc7,0x13b3f021,0x006e8806 } },
  22255. /* 168 */
  22256. { { 0x143ea1db,0x11bd588d,0x1674a4b3,0x1fe352a4,0x0f1860a7,0x0110c7c2,
  22257. 0x144e146c,0x1d5bdf55,0x00a7222b },
  22258. { 0x0b0a9144,0x1563c761,0x1e967168,0x0480a3e5,0x1ce385a0,0x1652b0a3,
  22259. 0x1a424747,0x04778558,0x00be94d5 } },
  22260. /* 169 */
  22261. { { 0x0b226ce7,0x17a4a2f0,0x1fa2dc1c,0x1fae8f2c,0x0c63eb8a,0x0378c2d3,
  22262. 0x1d9bb7a9,0x1fd37d18,0x007782de },
  22263. { 0x1db38626,0x10695521,0x1d9eb45d,0x15cf0eed,0x19cdb460,0x037e2a24,
  22264. 0x192cd06e,0x0cf45125,0x00038385 } },
  22265. /* 170 */
  22266. { { 0x19ec1a0f,0x0c6d77eb,0x0ce725cb,0x19adfb9d,0x01a953bb,0x0ffe2c7b,
  22267. 0x1083d55d,0x1895bef6,0x00dbd986 },
  22268. { 0x15f39eb7,0x0d5440a0,0x0365db20,0x05f9eb73,0x1717d6ee,0x03aee797,
  22269. 0x0f415195,0x188d0c17,0x008e24d3 } },
  22270. /* 171 */
  22271. { { 0x1a587390,0x04ec72a4,0x0fb1621d,0x16329e19,0x183c612b,0x1ed2592c,
  22272. 0x1f211b81,0x18880f75,0x00541a99 },
  22273. { 0x024c8842,0x1920b493,0x1b017ff6,0x098255b0,0x1cf62604,0x0a5a27bf,
  22274. 0x17471674,0x093eafa6,0x00c0092c } },
  22275. /* 172 */
  22276. { { 0x1f2e61ef,0x1e63ae1e,0x06cd72b4,0x1083905c,0x129f47e8,0x1868c84f,
  22277. 0x113718b4,0x068e50d2,0x0075e406 },
  22278. { 0x1bc237d0,0x1ea0fe2d,0x13c07279,0x06f7e1d8,0x1d534c95,0x0d0b1415,
  22279. 0x161a4714,0x0b18f090,0x005b7cb6 } },
  22280. /* 173 */
  22281. { { 0x0a28ead1,0x12538424,0x0ed1fda5,0x1b8a11fa,0x05b39802,0x1fe8bb3f,
  22282. 0x1e866b92,0x1751be12,0x007ae13e },
  22283. { 0x0add384e,0x090b77c7,0x0cbfc1bf,0x0345b36d,0x1b5f3036,0x0c3c25e6,
  22284. 0x0ff4812e,0x0e9c551c,0x00787d80 } },
  22285. /* 174 */
  22286. { { 0x157fbb1c,0x0f12eb5b,0x08077af1,0x17bb6594,0x033ffe47,0x14d1b691,
  22287. 0x12112957,0x0333de50,0x005c2228 },
  22288. { 0x08315250,0x19ea542c,0x1c25f05d,0x04345704,0x1d33f21b,0x0750ef7a,
  22289. 0x0ac2adf1,0x15775e1e,0x00e45d37 } },
  22290. /* 175 */
  22291. { { 0x08511c8a,0x16f8f1a1,0x129b34f4,0x0453917b,0x039a7ebb,0x18d3b13e,
  22292. 0x074d5e29,0x04509bf7,0x00ed7bc1 },
  22293. { 0x13dea561,0x191536fc,0x03c3b473,0x07e31ba9,0x123e8544,0x10a02dd6,
  22294. 0x149f62e1,0x1928b94d,0x00aac97c } },
  22295. /* 176 */
  22296. { { 0x016bd00a,0x1aa753a5,0x102f307a,0x13d35beb,0x1fc06d83,0x1bf88fcd,
  22297. 0x113824ae,0x16622c7b,0x00318f97 },
  22298. { 0x030d7138,0x06062df6,0x10c0883b,0x11be4757,0x0360644e,0x0b97d811,
  22299. 0x1d34aede,0x1433509f,0x00fa41fa } },
  22300. /* 177 */
  22301. { { 0x06642269,0x0016cba5,0x0de0ef51,0x10299d37,0x1e60bc81,0x1c723ca0,
  22302. 0x0788e634,0x0583a4dd,0x0038bb6b },
  22303. { 0x0a577f87,0x1272512b,0x047f8731,0x05a4a7b8,0x007288b5,0x155fb114,
  22304. 0x0697fccd,0x00b9cec0,0x0094dd09 } },
  22305. /* 178 */
  22306. { { 0x1e93f92a,0x0b67bee6,0x0d7cc545,0x06679713,0x1e750a01,0x06fce4ca,
  22307. 0x0ba40901,0x0cfa4b85,0x00920778 },
  22308. { 0x0bf39d44,0x1238f008,0x0ed4f5f8,0x1920412d,0x03d8f5f2,0x1bd9ae4e,
  22309. 0x0d453112,0x117a537d,0x0081e842 } },
  22310. /* 179 */
  22311. { { 0x0477199f,0x0ece15d6,0x17b3765b,0x11dddcd6,0x0fd0e8cb,0x0d9ff720,
  22312. 0x12c62bdf,0x0c5b77f4,0x001b94ab },
  22313. { 0x0e47f143,0x0786c59e,0x1d1858d1,0x0c47f8c7,0x1938351e,0x1387e62c,
  22314. 0x03bbc63c,0x0500aab2,0x0006a38e } },
  22315. /* 180 */
  22316. { { 0x13355b49,0x12d809cd,0x1afe66cb,0x04cac169,0x1f3dc20e,0x1d35e934,
  22317. 0x13e3023f,0x04107b3a,0x00a7b36c },
  22318. { 0x1b3e8830,0x068ae1d0,0x07e702d9,0x19d5c351,0x16930d5f,0x12517168,
  22319. 0x08833fbb,0x16945045,0x00be54c6 } },
  22320. /* 181 */
  22321. { { 0x0d91167c,0x166d9efc,0x099897b5,0x187ef3cf,0x0c7f4517,0x12479a35,
  22322. 0x0aedc415,0x157d5c04,0x00bf30a5 },
  22323. { 0x13828a68,0x13bc2df4,0x0fbc0da3,0x038664fe,0x146b2516,0x0ff5ac90,
  22324. 0x04eb846d,0x1bc4e65a,0x00d1c820 } },
  22325. /* 182 */
  22326. { { 0x1038b363,0x01f09a3c,0x01794641,0x023ea8d6,0x0cad158c,0x1d5f3013,
  22327. 0x168d3f95,0x1dad1431,0x00b7d17b },
  22328. { 0x029c2559,0x0652c48f,0x1fff6111,0x1406ecb7,0x069484f7,0x1257ba72,
  22329. 0x11912637,0x0bcc8259,0x003997fd } },
  22330. /* 183 */
  22331. { { 0x0bd61507,0x103a3414,0x09934abc,0x0265aa69,0x015e329e,0x0fd84545,
  22332. 0x0fa3ffb7,0x05278d82,0x000eeb89 },
  22333. { 0x07e259f8,0x0db4d1f5,0x0f9f99fa,0x1b6fcda2,0x1a685ce1,0x0c7b568f,
  22334. 0x1bbc9dcc,0x1f192456,0x00228916 } },
  22335. /* 184 */
  22336. { { 0x0a12ab5b,0x0cd712d8,0x1ef04da5,0x022e3f2a,0x02b0ccc1,0x014f68b7,
  22337. 0x05fa0161,0x03add261,0x00ec05ad },
  22338. { 0x0c3f3708,0x0bdd2df5,0x0d675dc5,0x15f26a61,0x034e531b,0x091b88c1,
  22339. 0x0cdd1ed5,0x0acffe23,0x007d3141 } },
  22340. /* 185 */
  22341. { { 0x16dfefab,0x1ece02e7,0x0cddc1de,0x1e44d1b9,0x0bb95be2,0x16cb9d1c,
  22342. 0x1e8f94fa,0x1f93783a,0x00e9ce66 },
  22343. { 0x0f6a02a1,0x0d50abb3,0x19803b5d,0x010fbec1,0x1c1b938c,0x1f9a3466,
  22344. 0x1947e251,0x002e4500,0x00d9650b } },
  22345. /* 186 */
  22346. { { 0x1a057e60,0x025a6252,0x1bc97914,0x19877d1b,0x1ccbdcbc,0x19040be0,
  22347. 0x1e8a98d4,0x135009d6,0x0014d669 },
  22348. { 0x1b1f411a,0x045420ae,0x035da70b,0x175e17f0,0x177ad09f,0x17c80e17,
  22349. 0x062ad37b,0x0821a86b,0x006f4c68 } },
  22350. /* 187 */
  22351. { { 0x16c24a96,0x1936fa74,0x0f6668e1,0x1b790bf9,0x0e30a534,0x17794595,
  22352. 0x0aecf119,0x1fac2313,0x004c4350 },
  22353. { 0x1855b8da,0x0b3fb8b7,0x0f0e284a,0x0847288c,0x1334341a,0x0a09f574,
  22354. 0x02d70df8,0x084b4623,0x00a726d2 } },
  22355. /* 188 */
  22356. { { 0x148c1086,0x17359f74,0x14e8b876,0x1ca07b97,0x022f3f1d,0x169f81e8,
  22357. 0x0e48fcd7,0x10598d9e,0x0013639e },
  22358. { 0x0dafaa86,0x1649c7de,0x15289626,0x178bf64c,0x11329f45,0x19372282,
  22359. 0x168c658e,0x1c383466,0x00ca9365 } },
  22360. /* 189 */
  22361. { { 0x0c3b2d20,0x10ad63aa,0x138906cd,0x14a82f20,0x1071d742,0x10e2664e,
  22362. 0x0a96c214,0x0692e16e,0x009ce29c },
  22363. { 0x0d3e0ad6,0x0640fb9b,0x1e10d323,0x01b53de5,0x062d9806,0x0e8d3674,
  22364. 0x1e60d7b4,0x1af56855,0x0048c4ab } },
  22365. /* 190 */
  22366. { { 0x00c7485a,0x110d8662,0x09d36ff4,0x08ab77ca,0x1d2e8ead,0x1b4c4931,
  22367. 0x0f2d24f1,0x065ecf66,0x0078017c },
  22368. { 0x130cb5ee,0x0e9abb4c,0x1023b4ae,0x029d2818,0x11a4dc0d,0x1faa9397,
  22369. 0x1013e2de,0x0a9bcb83,0x0053cd04 } },
  22370. /* 191 */
  22371. { { 0x1d28ccac,0x06ac2fd2,0x16dd1baf,0x047cac00,0x123aa5f8,0x1850e680,
  22372. 0x0a3df1e7,0x183a7aff,0x00eea465 },
  22373. { 0x0551803b,0x00832cf8,0x19abdc1e,0x16b33ef9,0x08e706c0,0x13b81494,
  22374. 0x064d0656,0x148f5cd2,0x001b6e42 } },
  22375. /* 192 */
  22376. { { 0x167d04c3,0x14049be7,0x1bae044b,0x0257c513,0x14d601e3,0x0c43c92c,
  22377. 0x14f55ad7,0x02830ff7,0x000224da },
  22378. { 0x0c5fe36f,0x1d5dc318,0x1d47d7e1,0x1e78c09d,0x029ec580,0x18dfd9da,
  22379. 0x1cce593e,0x1e0857ff,0x0060838e } },
  22380. /* 193 */
  22381. { { 0x1e0bbe99,0x19659793,0x0a8e7b90,0x1489e609,0x139037bd,0x1e3d4fd4,
  22382. 0x190d7d25,0x0045a662,0x00636eb2 },
  22383. { 0x13ae00aa,0x07e8730c,0x0b9b4bff,0x1401fc63,0x1901c875,0x0c514fc9,
  22384. 0x0eb3d0d9,0x16c72431,0x008844ee } },
  22385. /* 194 */
  22386. { { 0x0b3bae58,0x0a0b8e93,0x18e7cf84,0x07bee22f,0x0eada7db,0x1e3fc0d4,
  22387. 0x027b34de,0x1b8a3f6f,0x0027ba83 },
  22388. { 0x1bf54de5,0x1efa1cff,0x1f869c69,0x0e06176b,0x17a48727,0x071aed94,
  22389. 0x12ad0bba,0x0690fe74,0x00adb62d } },
  22390. /* 195 */
  22391. { { 0x0175df2a,0x188b4515,0x030cba66,0x15409ec3,0x10916082,0x19738a35,
  22392. 0x02cb2793,0x0ecebcf9,0x00b990fd },
  22393. { 0x0df37313,0x014ecb5a,0x0d01e242,0x00aaf3a1,0x077111c2,0x17253c04,
  22394. 0x06359b26,0x1f29a21a,0x0081707e } },
  22395. /* 196 */
  22396. { { 0x03d6ff96,0x1ebe5590,0x010cd825,0x0a37f81b,0x0db4b5b8,0x11e26821,
  22397. 0x09709a20,0x1d5ab515,0x003792da },
  22398. { 0x141afa0b,0x140c432c,0x160d9c54,0x13ce8285,0x0e0a7f3e,0x1293adf2,
  22399. 0x06e85f20,0x0bd29600,0x005abd63 } },
  22400. /* 197 */
  22401. { { 0x0ac4927c,0x13fd4270,0x1233c8dc,0x10c06b4f,0x0a0dfe38,0x0af5256e,
  22402. 0x184292f3,0x04308d56,0x005995bf },
  22403. { 0x029dfa33,0x087c305c,0x03f062fa,0x1fc55d2b,0x10366caa,0x17a23c31,
  22404. 0x047a6cee,0x145a9068,0x0044c32c } },
  22405. /* 198 */
  22406. { { 0x040ed80c,0x1a54bf8f,0x14b2a0a9,0x07196263,0x16ad95f9,0x0925be16,
  22407. 0x15314fc8,0x1f701054,0x001f2162 },
  22408. { 0x120b173e,0x1233e62b,0x17c4be5f,0x114ccc10,0x165dc40e,0x0107264e,
  22409. 0x1f2633af,0x05787d20,0x008f1d40 } },
  22410. /* 199 */
  22411. { { 0x1bc4058a,0x1ac97ce7,0x0bd59c13,0x1c296c52,0x18c57b15,0x1f1bde0e,
  22412. 0x0fe71573,0x08724ddb,0x00b1980f },
  22413. { 0x12c76b09,0x0619f049,0x0c1fde26,0x0a4f3a67,0x1b4611df,0x156a431d,
  22414. 0x1915bc23,0x1366e891,0x002828ad } },
  22415. /* 200 */
  22416. { { 0x04cf4ac5,0x0b391626,0x1992beda,0x18347fbb,0x10832f5a,0x1d517044,
  22417. 0x0e401546,0x04eb4296,0x004973f1 },
  22418. { 0x122eac5d,0x0cec19a9,0x166d5a39,0x0fddea17,0x083935e0,0x1907d12c,
  22419. 0x0b1eacd9,0x1a1b62d1,0x006dac8e } },
  22420. /* 201 */
  22421. { { 0x0da835ef,0x1daa2d77,0x043b547d,0x0227a43a,0x01b094aa,0x12f009ba,
  22422. 0x19300d69,0x0b24173b,0x004b23ef },
  22423. { 0x1c4c7341,0x015db401,0x162f0dfa,0x0ee0da7e,0x03ee8d45,0x1c31d28f,
  22424. 0x0939cd49,0x069bbe93,0x004dd715 } },
  22425. /* 202 */
  22426. { { 0x15476cd9,0x1ca23394,0x069c96ef,0x1a0e5fc6,0x167e0648,0x045c7e25,
  22427. 0x16ec5107,0x0005e949,0x00fd3170 },
  22428. { 0x0995d0e1,0x05a1ffa4,0x1dca6a87,0x0d2ba21d,0x1898276e,0x1cbb20bc,
  22429. 0x0d978357,0x1192ad3e,0x0014fac5 } },
  22430. /* 203 */
  22431. { { 0x1312ae18,0x0cd0032f,0x124ff26b,0x0b1b81f9,0x12846519,0x0120453e,
  22432. 0x09436685,0x0a26d57b,0x00ed7c76 },
  22433. { 0x05d4abbc,0x113878d1,0x0844fa91,0x1bb1e7e3,0x1952f9b5,0x183aada8,
  22434. 0x1d4f1826,0x1ee9a5d3,0x00fefcb7 } },
  22435. /* 204 */
  22436. { { 0x1a119185,0x084a4bd5,0x1116e92f,0x1d186155,0x01179d54,0x1cef5529,
  22437. 0x002d2491,0x0fd0fc1b,0x001801a5 },
  22438. { 0x1cafffb0,0x19e9fc6f,0x09549001,0x0678175c,0x1dfbc6cf,0x1b1dadaf,
  22439. 0x0191e075,0x03c3d5a2,0x009f8fc1 } },
  22440. /* 205 */
  22441. { { 0x1e69544c,0x0c1d0b8a,0x12de04c5,0x1f0acfe0,0x04c320ea,0x147e93c5,
  22442. 0x06a4788a,0x13a7a74d,0x00a9d380 },
  22443. { 0x19a2da3b,0x1b616162,0x057211e4,0x1979ec31,0x1086938c,0x122731ea,
  22444. 0x1bdd7994,0x15dc22f1,0x003006b9 } },
  22445. /* 206 */
  22446. { { 0x09eead28,0x1d8f9586,0x1d37ef02,0x1ec6bb13,0x089397ee,0x0bfed967,
  22447. 0x1d841d1d,0x1ae8bf1e,0x000ab85f },
  22448. { 0x1e5b4549,0x06d3e499,0x048bc87b,0x0576b92f,0x180404be,0x093a5a1d,
  22449. 0x0b089868,0x0ea23d28,0x00b122d6 } },
  22450. /* 207 */
  22451. { { 0x06a5ae7a,0x1f303df3,0x0b72f8ce,0x0e07f4ed,0x0e5c501e,0x0180a75b,
  22452. 0x0bb2be41,0x18212fb7,0x009f599d },
  22453. { 0x0ff250ed,0x0badb8c0,0x0688371b,0x122ae869,0x027a38eb,0x02d20859,
  22454. 0x0de10958,0x1c114529,0x007d5528 } },
  22455. /* 208 */
  22456. { { 0x00c26def,0x07ac7b31,0x0acb47bc,0x0b0bd4b0,0x03881025,0x0bcd80e7,
  22457. 0x1cc3ef9f,0x002607e2,0x0028ccea },
  22458. { 0x19644ba5,0x0ed5e68b,0x1ffc2e34,0x0c87d00d,0x1e17b1fc,0x1b7e3359,
  22459. 0x0efe9829,0x09143a02,0x00c18baf } },
  22460. /* 209 */
  22461. { { 0x1dc4216d,0x0731c642,0x1850ab0d,0x0020ce40,0x1064a00c,0x10b8cafa,
  22462. 0x05af514e,0x13b6f52b,0x009def80 },
  22463. { 0x07ab8d2c,0x0f432173,0x0de8ad90,0x080866c4,0x0218bb42,0x1536b262,
  22464. 0x1395f541,0x160d1011,0x000357f8 } },
  22465. /* 210 */
  22466. { { 0x0cd2cc88,0x14edf322,0x0e3ce763,0x03851be1,0x0a0c8cc6,0x0c3a6698,
  22467. 0x021d28c2,0x1ba36913,0x00e4a01a },
  22468. { 0x157cd8f9,0x168f7567,0x1653120b,0x0cfa7d7a,0x0f7871b7,0x0e38bde9,
  22469. 0x10c29ca5,0x0f39c219,0x00466d7d } },
  22470. /* 211 */
  22471. { { 0x1dada2c7,0x1e98c494,0x06a89f51,0x014d871f,0x059e14fa,0x1e944105,
  22472. 0x146a4393,0x0448a3d5,0x00c672a5 },
  22473. { 0x1d86b655,0x0303e642,0x0b52bc4c,0x06ba77f3,0x172a6f02,0x03402b88,
  22474. 0x144e6682,0x1f5e54ce,0x005e3d64 } },
  22475. /* 212 */
  22476. { { 0x1b3b4416,0x1320863c,0x0c9b666a,0x1f9f0bd5,0x16a74cd8,0x1ba56db2,
  22477. 0x0bf17aff,0x12bd71c8,0x006c8a7a },
  22478. { 0x102a63bd,0x06305d3d,0x03c011c4,0x1e460717,0x190b06b2,0x1b9c1896,
  22479. 0x0a4631b0,0x0455b059,0x00348ae4 } },
  22480. /* 213 */
  22481. { { 0x1ccda2fb,0x1a3a331a,0x01c9b49f,0x1995431c,0x11f2022a,0x1bc12495,
  22482. 0x14ba16b7,0x1c1b3de5,0x00c1074d },
  22483. { 0x0e9a65b3,0x079e7225,0x15c546ff,0x03c9580b,0x09788fd7,0x0fa86735,
  22484. 0x1ff351c4,0x1b793ca9,0x00fbadfb } },
  22485. /* 214 */
  22486. { { 0x00a99363,0x189f8e69,0x1c89dd45,0x0acb1ed9,0x159b2b91,0x1ae69269,
  22487. 0x1f365a05,0x16906e2d,0x00b7f976 },
  22488. { 0x1d6dbf74,0x1ac7126a,0x10ebcd95,0x0775fae3,0x1dfe38d2,0x1bb00121,
  22489. 0x001523d1,0x05d95f99,0x00f4d41b } },
  22490. /* 215 */
  22491. { { 0x1dabd48d,0x0f8e7947,0x101e2914,0x037c6c65,0x146e9ce8,0x14ba08b8,
  22492. 0x1c41ab38,0x1d5c02c1,0x00180824 },
  22493. { 0x06e58358,0x1c3b4c5b,0x1b28d600,0x0d0ea59c,0x1e6c5635,0x071a2f20,
  22494. 0x149608e0,0x073079ed,0x0067e5f6 } },
  22495. /* 216 */
  22496. { { 0x0f4899ef,0x04e65c6e,0x0ed1303e,0x002be13d,0x18ec9949,0x093b592c,
  22497. 0x1f1951be,0x13409823,0x009fef78 },
  22498. { 0x13d2a071,0x09b3f67a,0x1466c25b,0x1c34ff48,0x02eefb10,0x1fd8308f,
  22499. 0x188329ac,0x10353389,0x00bc80c1 } },
  22500. /* 217 */
  22501. { { 0x05eb82e6,0x1929b7c7,0x1b2e4825,0x109f8fea,0x1da5e1a4,0x10b8a85a,
  22502. 0x1c431e38,0x0c53f19b,0x0049270e },
  22503. { 0x0a6b50ad,0x11cdbddf,0x0e23ff06,0x05098344,0x1197b9a0,0x158bc083,
  22504. 0x1dfd500f,0x1f2c26e5,0x00d2ee52 } },
  22505. /* 218 */
  22506. { { 0x08e0362a,0x1be6942c,0x09765374,0x1f514f1f,0x0a526442,0x1b72d21a,
  22507. 0x1ccebfe0,0x17dcb576,0x00dfb478 },
  22508. { 0x073eede6,0x08f8e73b,0x16cbc12a,0x1215a856,0x0da2fa53,0x1bdfaa98,
  22509. 0x1ce9799b,0x16811be8,0x00d9a140 } },
  22510. /* 219 */
  22511. { { 0x0e8ea498,0x10110dab,0x18fb8243,0x08f0526a,0x12ade623,0x01c899ae,
  22512. 0x0c6b81ae,0x11ac47e9,0x00760c05 },
  22513. { 0x0198aa79,0x1c4dac66,0x1eae9fc2,0x1121a5e0,0x0556af74,0x00887ef1,
  22514. 0x10253881,0x05b1e320,0x00714198 } },
  22515. /* 220 */
  22516. { { 0x0d4b0f45,0x1850719a,0x0aa5385b,0x10167072,0x01d5ed92,0x126359e3,
  22517. 0x191cebcc,0x19d13aa9,0x003af9d1 },
  22518. { 0x00930371,0x0c7bcc09,0x105c25ff,0x04cc9843,0x0309beda,0x02ee6e21,
  22519. 0x17583a55,0x186e72af,0x00b1f815 } },
  22520. /* 221 */
  22521. { { 0x09fec44a,0x07d53c74,0x0a932be1,0x055c8e79,0x0a624c8c,0x003ee0db,
  22522. 0x0149a472,0x0282a87e,0x00a41aed },
  22523. { 0x1d5ffe04,0x121a9ccb,0x16db8810,0x1965bec4,0x177758ba,0x105f43c0,
  22524. 0x03be1759,0x1bb0df6c,0x00d6e9c1 } },
  22525. /* 222 */
  22526. { { 0x06853264,0x15174bf6,0x0c1282ce,0x0a676fc4,0x0e9be771,0x15dbdc75,
  22527. 0x03086e44,0x0215d37f,0x009c9c6e },
  22528. { 0x0030b74c,0x1184d2cf,0x18c7a428,0x0e929ad4,0x179f24ed,0x0591d24d,
  22529. 0x06da27d1,0x12c81f4c,0x00566bd5 } },
  22530. /* 223 */
  22531. { { 0x018061f3,0x136008c6,0x00ff1c01,0x164ba6f9,0x13245190,0x04701393,
  22532. 0x117bc17f,0x121ea4a6,0x00cf2c73 },
  22533. { 0x10eb30cf,0x04de75a0,0x1ddc0ea8,0x05d7741a,0x1f255cfd,0x021d0a87,
  22534. 0x05e7a10b,0x0ab15441,0x0002f517 } },
  22535. /* 224 */
  22536. { { 0x0ddb7d07,0x0b77bca5,0x1155400e,0x1f8e8448,0x0a3ce0b4,0x075663c5,
  22537. 0x05f7ebfe,0x14bd1a9b,0x0014e9ad },
  22538. { 0x0f7079e2,0x15240509,0x0c2003b6,0x15479bc9,0x0157d45b,0x0f16bc1c,
  22539. 0x0ba005d9,0x1571d3b3,0x00a0ad4f } },
  22540. /* 225 */
  22541. { { 0x0a653618,0x1fdbb10a,0x1aaa97c2,0x05027863,0x09d5e187,0x139ba24a,
  22542. 0x1478554f,0x170dcadd,0x00bcd530 },
  22543. { 0x12e9c47b,0x14df4299,0x00166ac5,0x0eedfd6a,0x1fbb4dc2,0x0bb08c95,
  22544. 0x107736ea,0x19ed2f26,0x00909283 } },
  22545. /* 226 */
  22546. { { 0x16e81a13,0x1d801923,0x05c48e59,0x1c3532c4,0x019d69be,0x1b0de997,
  22547. 0x126823b4,0x19359c2a,0x0035eeb7 },
  22548. { 0x1e4e5bdc,0x140572d3,0x13bb1b84,0x1a59a76d,0x06bc12dc,0x11263713,
  22549. 0x01914b90,0x1e88915d,0x009a8b2c } },
  22550. /* 227 */
  22551. { { 0x09d03b59,0x1238df90,0x16bcaafd,0x1cc5476c,0x1eec9c90,0x18b475ea,
  22552. 0x0de7fdff,0x1e9a8922,0x006bdb60 },
  22553. { 0x0a55bc30,0x16d7f5e4,0x025ff836,0x1d5a2c20,0x03bddc79,0x0ba0a60f,
  22554. 0x02a50b86,0x1fb29741,0x0001ec3c } },
  22555. /* 228 */
  22556. { { 0x1c9485c2,0x1313bf5e,0x1ec431ee,0x1934f245,0x08d8a48c,0x0b07b851,
  22557. 0x13d93d87,0x1808ea8c,0x00d1acb1 },
  22558. { 0x06f36612,0x13481589,0x186362f4,0x07489dc0,0x157ee59c,0x14099841,
  22559. 0x1b0937e2,0x13a80ac4,0x007dcd07 } },
  22560. /* 229 */
  22561. { { 0x105a4b48,0x073ea69f,0x08c1dc97,0x1a52a46e,0x0915aadc,0x1cb8c095,
  22562. 0x06e3463d,0x1126efa3,0x000bf535 },
  22563. { 0x0c68ea73,0x0f66cad3,0x0e96134d,0x07779504,0x1a723c7f,0x1a637a39,
  22564. 0x1bf27ed9,0x1b3c2cd0,0x00d28be4 } },
  22565. /* 230 */
  22566. { { 0x18fa8e4b,0x095cc831,0x0ff63f17,0x1e30dd12,0x1b6fc559,0x115521b7,
  22567. 0x0338e9b7,0x154a21f1,0x00d76007 },
  22568. { 0x123a4988,0x088555b2,0x17409ccb,0x0b9e88e9,0x07278b45,0x184151a0,
  22569. 0x0c05fd19,0x0d166077,0x00f2b52f } },
  22570. /* 231 */
  22571. { { 0x1835b4ca,0x0abf57d4,0x19a72f03,0x0465f976,0x031982d2,0x1b406332,
  22572. 0x14ea3bba,0x11d98b5d,0x00d8dbe9 },
  22573. { 0x05a02709,0x1d4df1fe,0x0e87ea32,0x1cd1cbeb,0x0a85230b,0x01e6f887,
  22574. 0x1c17faf5,0x147dcab2,0x00e01593 } },
  22575. /* 232 */
  22576. { { 0x0a75a0a6,0x1f2d7a87,0x01600cf4,0x044d58af,0x16406512,0x0a87e80b,
  22577. 0x1c19bf9b,0x1635d71d,0x00afec07 },
  22578. { 0x00bb0a31,0x1dccab3c,0x0c26ab9f,0x15e7986e,0x1f3896f1,0x10ad00d5,
  22579. 0x1f76454e,0x0a8dc5b7,0x00a71b93 } },
  22580. /* 233 */
  22581. { { 0x18f593d2,0x1c709700,0x1e048aef,0x12085140,0x0f2add1a,0x02ed85d2,
  22582. 0x0f645414,0x0b8c50a4,0x0053a200 },
  22583. { 0x07f2b935,0x1e45b1cf,0x00a58681,0x1f2eb583,0x0ca2c2bf,0x1753ba8c,
  22584. 0x18f61af3,0x1367ab11,0x00bf47d1 } },
  22585. /* 234 */
  22586. { { 0x1d7665d5,0x194b3d3e,0x0bd37959,0x0060ae5e,0x0903f4e3,0x02d7406a,
  22587. 0x06d85100,0x0fe73934,0x00001c2c },
  22588. { 0x09efc6d6,0x01d400a3,0x11e9c905,0x017b54f7,0x150a4c81,0x1385d3c0,
  22589. 0x066d7d95,0x1cf0dff7,0x00fdadf8 } },
  22590. /* 235 */
  22591. { { 0x1fc00785,0x09c65c47,0x123ad9ff,0x14eb2276,0x08fbc77f,0x082adf9b,
  22592. 0x12501153,0x09ab5487,0x003a838e },
  22593. { 0x1e97bb9a,0x10b31949,0x07653655,0x1266c688,0x12a839eb,0x08d3056d,
  22594. 0x168d4556,0x0af0e7c3,0x003cdb82 } },
  22595. /* 236 */
  22596. { { 0x1de77eab,0x1b8a054b,0x19204244,0x038a1a82,0x1d0dff7e,0x05696758,
  22597. 0x1ee9d8b7,0x113e3eaf,0x005a60cc },
  22598. { 0x00d45673,0x059b1c12,0x04f19560,0x057c32b2,0x0b7411b8,0x025c6eb2,
  22599. 0x1f0015ca,0x0dfb7fb1,0x00922ff5 } },
  22600. /* 237 */
  22601. { { 0x09a129a1,0x1932ef76,0x0a138106,0x039caf98,0x1be3ca5b,0x0623675f,
  22602. 0x158810e0,0x0fbed8b9,0x0072919a },
  22603. { 0x0fb90f9a,0x0c7a29d4,0x1900c6ca,0x13801711,0x11856d71,0x073bbcb7,
  22604. 0x026b8cb0,0x1006c481,0x005e7917 } },
  22605. /* 238 */
  22606. { { 0x1f63cdfb,0x00b762ab,0x12b93f57,0x146ae3e3,0x197ca8e6,0x15f52b02,
  22607. 0x1eaff389,0x0e3c4985,0x004e0a53 },
  22608. { 0x05765357,0x1b52069d,0x1ce8ad09,0x135e881a,0x11a323c8,0x185720e8,
  22609. 0x13bae3cd,0x031aacc0,0x00f5ff78 } },
  22610. /* 239 */
  22611. { { 0x1a09df21,0x1f9f1ff0,0x1ba391fe,0x0ba51dcc,0x0901526d,0x1e8514e4,
  22612. 0x1990825a,0x1d2a67eb,0x00e41df0 },
  22613. { 0x13ba9e3f,0x02fed205,0x0136254c,0x0819d64c,0x167c7f23,0x10c93f81,
  22614. 0x157c219b,0x0dd589e2,0x008edd7d } },
  22615. /* 240 */
  22616. { { 0x0bfc8ff3,0x0d0ee070,0x0dbd0bf2,0x1fb057d2,0x181ef14e,0x17be6651,
  22617. 0x1a599c05,0x195db15d,0x001432c1 },
  22618. { 0x10b23c26,0x0342414b,0x0d6c9cfb,0x1fd0e60e,0x10f5aa64,0x1b72f577,
  22619. 0x0b1b8e27,0x016b591a,0x00caef48 } },
  22620. /* 241 */
  22621. { { 0x15315922,0x122e4bc3,0x18f32954,0x12a2e260,0x0f2cbd82,0x10685b27,
  22622. 0x08dbcf39,0x0fd1df5c,0x00d0ba17 },
  22623. { 0x11b3af60,0x1d4d747d,0x0b688394,0x12d5ca7a,0x0ef281a7,0x1b02efcf,
  22624. 0x18580758,0x0f838a95,0x00f31c95 } },
  22625. /* 242 */
  22626. { { 0x09cc4597,0x07ac6a92,0x18280a30,0x002b6175,0x0814adc5,0x1e2ab9a5,
  22627. 0x10ebbf17,0x1972dc2f,0x00013404 },
  22628. { 0x09a824bf,0x14f12c2e,0x07abb5ec,0x0630bc00,0x168acd59,0x134130f7,
  22629. 0x19b235bb,0x09723267,0x006f377c } },
  22630. /* 243 */
  22631. { { 0x08333fd2,0x1c9dd68d,0x0aa56e27,0x060404b4,0x15acea89,0x081bf57b,
  22632. 0x14188479,0x09da5a12,0x006dba3e },
  22633. { 0x104399cd,0x0477cc66,0x0dceb7a9,0x038cddcd,0x0caf3181,0x03a960bf,
  22634. 0x129dcbd8,0x08477d9e,0x00f13cf3 } },
  22635. /* 244 */
  22636. { { 0x0919e2eb,0x175cf605,0x0b03da33,0x13432bec,0x0229983a,0x1ddb3d5d,
  22637. 0x0b4f3ee8,0x1524e977,0x00c83fa9 },
  22638. { 0x02fa1ce0,0x0be8d85b,0x063befc3,0x16c1ea68,0x06f04e58,0x17cf2938,
  22639. 0x1a0efea3,0x1e8bae04,0x00b49d70 } },
  22640. /* 245 */
  22641. { { 0x1ad5513b,0x0a63a887,0x1d478b64,0x065dd962,0x19d5905f,0x020c6cfd,
  22642. 0x073db614,0x1761861e,0x0059cfad },
  22643. { 0x15cb7fd6,0x0b3d611a,0x0109a8f8,0x06cf7104,0x18864249,0x02c64853,
  22644. 0x0d9fabbb,0x0c46a949,0x005babf3 } },
  22645. /* 246 */
  22646. { { 0x0e424865,0x1e4c0e8f,0x1955dfcd,0x0050f1e5,0x0c0588b0,0x1878dcf0,
  22647. 0x03c1c0a5,0x14f204d9,0x006188c6 },
  22648. { 0x10f244da,0x17cd0cde,0x02021cc1,0x19dab9f6,0x136371ec,0x07cdcf90,
  22649. 0x0764d51c,0x0ebbea17,0x00993fe4 } },
  22650. /* 247 */
  22651. { { 0x1b2c3609,0x0718e6fc,0x11b53a9a,0x16338058,0x1510184e,0x160d4d3b,
  22652. 0x05adeb27,0x0cc9900c,0x0081f764 },
  22653. { 0x15fbe978,0x0be152d3,0x00ecd587,0x07fda7e3,0x1d2bf674,0x0f82280e,
  22654. 0x18360e34,0x054bfd20,0x00564a81 } },
  22655. /* 248 */
  22656. { { 0x1a817d1d,0x12d327a7,0x0a0b83de,0x12d0897d,0x1f9aa55f,0x0d07e6ab,
  22657. 0x15b2d7fd,0x19e01ca3,0x00226bf3 },
  22658. { 0x0f2833cf,0x168d4fc9,0x13e26a35,0x0146b49e,0x17f7720a,0x1624c79f,
  22659. 0x00d8454d,0x08ffe4af,0x0068779f } },
  22660. /* 249 */
  22661. { { 0x13043d08,0x0d860e0b,0x10083e9e,0x08cee83f,0x126d0a54,0x1f144d36,
  22662. 0x182f4dd9,0x1a3d6125,0x0097bcb0 },
  22663. { 0x132ed3c3,0x15b75547,0x006f120a,0x09e2a365,0x178f3c8a,0x1a79dfd0,
  22664. 0x1955346f,0x1d014f08,0x00a872ff } },
  22665. /* 250 */
  22666. { { 0x032b2086,0x0d5bc9ad,0x183d21ac,0x16e21d02,0x0e6bee1e,0x06c89db5,
  22667. 0x0daa6f43,0x1f96e654,0x0002812b },
  22668. { 0x0f605318,0x11febe56,0x1f5b4769,0x1cbaa1fb,0x0d619646,0x01cc1081,
  22669. 0x1abe875a,0x193fca72,0x0007391c } },
  22670. /* 251 */
  22671. { { 0x0b80d02b,0x080abf84,0x01dfdff1,0x0667a2c5,0x142ae6b8,0x0d7c3c6a,
  22672. 0x0821eb28,0x1b8fcda5,0x00355d2a },
  22673. { 0x087386e1,0x00f99ad1,0x190c9d6d,0x0e5529f1,0x189eafd2,0x1166f3cc,
  22674. 0x09e4a1b2,0x1c6f8547,0x003dc2b1 } },
  22675. /* 252 */
  22676. { { 0x04581352,0x144e90e0,0x19e0afb5,0x01904a6e,0x1701f0a0,0x0ac84ff6,
  22677. 0x11ac80ef,0x020799b0,0x00c47869 },
  22678. { 0x04c768ed,0x0dd3b841,0x107d95d7,0x1dd404d0,0x0ce0e72f,0x1f6ab566,
  22679. 0x14c9ccc4,0x0d1ab769,0x00ccc429 } },
  22680. /* 253 */
  22681. { { 0x1d7620b9,0x07286f09,0x04a95aa5,0x14b914b3,0x087c9d89,0x1b2033aa,
  22682. 0x073f7001,0x0855490e,0x00e147eb },
  22683. { 0x0cf3ae46,0x1a55a775,0x0d43ef89,0x126df6a0,0x040eafd4,0x1f23a464,
  22684. 0x1b8f7cab,0x08e101d2,0x00239ac0 } },
  22685. /* 254 */
  22686. { { 0x0bfee8d4,0x00e8f9a9,0x1ec3fb12,0x016b9ff4,0x1af3cce8,0x064f1674,
  22687. 0x16744171,0x147ebefc,0x00c55fa1 },
  22688. { 0x0257c227,0x0c378a74,0x0af802cc,0x02ca7e68,0x04fb2c5b,0x04cc5548,
  22689. 0x1a6426bf,0x139a9e96,0x00094cd9 } },
  22690. /* 255 */
  22691. { { 0x1703beba,0x14c0e426,0x13aca462,0x03a2a065,0x149ec863,0x1964f1de,
  22692. 0x14ce9117,0x16c85575,0x00b90a30 },
  22693. { 0x14a5abf9,0x032a027d,0x16dd80ed,0x0ea186eb,0x1d89f004,0x0166651a,
  22694. 0x13ddbe69,0x13436f24,0x00019f8b } },
  22695. };
  22696. /* Multiply the base point of P256 by the scalar and return the result.
  22697. * If map is true then convert result to affine coordinates.
  22698. *
  22699. * Stripe implementation.
  22700. * Pre-generated: 2^0, 2^32, ...
  22701. * Pre-generated: products of all combinations of above.
  22702. * 8 doubles and adds (with qz=1)
  22703. *
  22704. * r Resulting point.
  22705. * k Scalar to multiply by.
  22706. * map Indicates whether to convert result to affine.
  22707. * ct Constant time required.
  22708. * heap Heap to use for allocation.
  22709. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  22710. */
  22711. static int sp_256_ecc_mulmod_base_9(sp_point_256* r, const sp_digit* k,
  22712. int map, int ct, void* heap)
  22713. {
  22714. return sp_256_ecc_mulmod_stripe_9(r, &p256_base, p256_table,
  22715. k, map, ct, heap);
  22716. }
  22717. #endif
  22718. /* Multiply the base point of P256 by the scalar and return the result.
  22719. * If map is true then convert result to affine coordinates.
  22720. *
  22721. * km Scalar to multiply by.
  22722. * r Resulting point.
  22723. * map Indicates whether to convert result to affine.
  22724. * heap Heap to use for allocation.
  22725. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  22726. */
  22727. int sp_ecc_mulmod_base_256(const mp_int* km, ecc_point* r, int map, void* heap)
  22728. {
  22729. #ifdef WOLFSSL_SP_SMALL_STACK
  22730. sp_point_256* point = NULL;
  22731. sp_digit* k = NULL;
  22732. #else
  22733. sp_point_256 point[1];
  22734. sp_digit k[9];
  22735. #endif
  22736. int err = MP_OKAY;
  22737. #ifdef WOLFSSL_SP_SMALL_STACK
  22738. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256), heap,
  22739. DYNAMIC_TYPE_ECC);
  22740. if (point == NULL)
  22741. err = MEMORY_E;
  22742. if (err == MP_OKAY) {
  22743. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9, heap,
  22744. DYNAMIC_TYPE_ECC);
  22745. if (k == NULL)
  22746. err = MEMORY_E;
  22747. }
  22748. #endif
  22749. if (err == MP_OKAY) {
  22750. sp_256_from_mp(k, 9, km);
  22751. err = sp_256_ecc_mulmod_base_9(point, k, map, 1, heap);
  22752. }
  22753. if (err == MP_OKAY) {
  22754. err = sp_256_point_to_ecc_point_9(point, r);
  22755. }
  22756. #ifdef WOLFSSL_SP_SMALL_STACK
  22757. if (k != NULL)
  22758. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  22759. if (point != NULL)
  22760. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  22761. #endif
  22762. return err;
  22763. }
  22764. /* Multiply the base point of P256 by the scalar, add point a and return
  22765. * the result. If map is true then convert result to affine coordinates.
  22766. *
  22767. * km Scalar to multiply by.
  22768. * am Point to add to scalar multiply result.
  22769. * inMont Point to add is in montgomery form.
  22770. * r Resulting point.
  22771. * map Indicates whether to convert result to affine.
  22772. * heap Heap to use for allocation.
  22773. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  22774. */
  22775. int sp_ecc_mulmod_base_add_256(const mp_int* km, const ecc_point* am,
  22776. int inMont, ecc_point* r, int map, void* heap)
  22777. {
  22778. #ifdef WOLFSSL_SP_SMALL_STACK
  22779. sp_point_256* point = NULL;
  22780. sp_digit* k = NULL;
  22781. #else
  22782. sp_point_256 point[2];
  22783. sp_digit k[9 + 9 * 2 * 6];
  22784. #endif
  22785. sp_point_256* addP = NULL;
  22786. sp_digit* tmp = NULL;
  22787. int err = MP_OKAY;
  22788. #ifdef WOLFSSL_SP_SMALL_STACK
  22789. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap,
  22790. DYNAMIC_TYPE_ECC);
  22791. if (point == NULL)
  22792. err = MEMORY_E;
  22793. if (err == MP_OKAY) {
  22794. k = (sp_digit*)XMALLOC(
  22795. sizeof(sp_digit) * (9 + 9 * 2 * 6),
  22796. heap, DYNAMIC_TYPE_ECC);
  22797. if (k == NULL)
  22798. err = MEMORY_E;
  22799. }
  22800. #endif
  22801. if (err == MP_OKAY) {
  22802. addP = point + 1;
  22803. tmp = k + 9;
  22804. sp_256_from_mp(k, 9, km);
  22805. sp_256_point_from_ecc_point_9(addP, am);
  22806. }
  22807. if ((err == MP_OKAY) && (!inMont)) {
  22808. err = sp_256_mod_mul_norm_9(addP->x, addP->x, p256_mod);
  22809. }
  22810. if ((err == MP_OKAY) && (!inMont)) {
  22811. err = sp_256_mod_mul_norm_9(addP->y, addP->y, p256_mod);
  22812. }
  22813. if ((err == MP_OKAY) && (!inMont)) {
  22814. err = sp_256_mod_mul_norm_9(addP->z, addP->z, p256_mod);
  22815. }
  22816. if (err == MP_OKAY) {
  22817. err = sp_256_ecc_mulmod_base_9(point, k, 0, 0, heap);
  22818. }
  22819. if (err == MP_OKAY) {
  22820. sp_256_proj_point_add_9(point, point, addP, tmp);
  22821. if (map) {
  22822. sp_256_map_9(point, point, tmp);
  22823. }
  22824. err = sp_256_point_to_ecc_point_9(point, r);
  22825. }
  22826. #ifdef WOLFSSL_SP_SMALL_STACK
  22827. if (k != NULL)
  22828. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  22829. if (point)
  22830. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  22831. #endif
  22832. return err;
  22833. }
  22834. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  22835. defined(HAVE_ECC_VERIFY)
  22836. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN | HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  22837. /* Add 1 to a. (a = a + 1)
  22838. *
  22839. * r A single precision integer.
  22840. * a A single precision integer.
  22841. */
  22842. SP_NOINLINE static void sp_256_add_one_9(sp_digit* a)
  22843. {
  22844. a[0]++;
  22845. sp_256_norm_9(a);
  22846. }
  22847. /* Read big endian unsigned byte array into r.
  22848. *
  22849. * r A single precision integer.
  22850. * size Maximum number of bytes to convert
  22851. * a Byte array.
  22852. * n Number of bytes in array to read.
  22853. */
  22854. static void sp_256_from_bin(sp_digit* r, int size, const byte* a, int n)
  22855. {
  22856. int i;
  22857. int j = 0;
  22858. word32 s = 0;
  22859. r[0] = 0;
  22860. for (i = n-1; i >= 0; i--) {
  22861. r[j] |= (((sp_digit)a[i]) << s);
  22862. if (s >= 21U) {
  22863. r[j] &= 0x1fffffff;
  22864. s = 29U - s;
  22865. if (j + 1 >= size) {
  22866. break;
  22867. }
  22868. r[++j] = (sp_digit)a[i] >> s;
  22869. s = 8U - s;
  22870. }
  22871. else {
  22872. s += 8U;
  22873. }
  22874. }
  22875. for (j++; j < size; j++) {
  22876. r[j] = 0;
  22877. }
  22878. }
  22879. /* Generates a scalar that is in the range 1..order-1.
  22880. *
  22881. * rng Random number generator.
  22882. * k Scalar value.
  22883. * returns RNG failures, MEMORY_E when memory allocation fails and
  22884. * MP_OKAY on success.
  22885. */
  22886. static int sp_256_ecc_gen_k_9(WC_RNG* rng, sp_digit* k)
  22887. {
  22888. int err;
  22889. byte buf[32];
  22890. do {
  22891. err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
  22892. if (err == 0) {
  22893. sp_256_from_bin(k, 9, buf, (int)sizeof(buf));
  22894. if (sp_256_cmp_9(k, p256_order2) <= 0) {
  22895. sp_256_add_one_9(k);
  22896. break;
  22897. }
  22898. }
  22899. }
  22900. while (err == 0);
  22901. return err;
  22902. }
  22903. /* Makes a random EC key pair.
  22904. *
  22905. * rng Random number generator.
  22906. * priv Generated private value.
  22907. * pub Generated public point.
  22908. * heap Heap to use for allocation.
  22909. * returns ECC_INF_E when the point does not have the correct order, RNG
  22910. * failures, MEMORY_E when memory allocation fails and MP_OKAY on success.
  22911. */
  22912. int sp_ecc_make_key_256(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
  22913. {
  22914. #ifdef WOLFSSL_SP_SMALL_STACK
  22915. sp_point_256* point = NULL;
  22916. sp_digit* k = NULL;
  22917. #else
  22918. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22919. sp_point_256 point[2];
  22920. #else
  22921. sp_point_256 point[1];
  22922. #endif
  22923. sp_digit k[9];
  22924. #endif
  22925. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22926. sp_point_256* infinity = NULL;
  22927. #endif
  22928. int err = MP_OKAY;
  22929. (void)heap;
  22930. #ifdef WOLFSSL_SP_SMALL_STACK
  22931. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22932. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap, DYNAMIC_TYPE_ECC);
  22933. #else
  22934. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256), heap, DYNAMIC_TYPE_ECC);
  22935. #endif
  22936. if (point == NULL)
  22937. err = MEMORY_E;
  22938. if (err == MP_OKAY) {
  22939. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9, heap,
  22940. DYNAMIC_TYPE_ECC);
  22941. if (k == NULL)
  22942. err = MEMORY_E;
  22943. }
  22944. #endif
  22945. if (err == MP_OKAY) {
  22946. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22947. infinity = point + 1;
  22948. #endif
  22949. err = sp_256_ecc_gen_k_9(rng, k);
  22950. }
  22951. if (err == MP_OKAY) {
  22952. err = sp_256_ecc_mulmod_base_9(point, k, 1, 1, NULL);
  22953. }
  22954. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22955. if (err == MP_OKAY) {
  22956. err = sp_256_ecc_mulmod_9(infinity, point, p256_order, 1, 1, NULL);
  22957. }
  22958. if (err == MP_OKAY) {
  22959. if (sp_256_iszero_9(point->x) || sp_256_iszero_9(point->y)) {
  22960. err = ECC_INF_E;
  22961. }
  22962. }
  22963. #endif
  22964. if (err == MP_OKAY) {
  22965. err = sp_256_to_mp(k, priv);
  22966. }
  22967. if (err == MP_OKAY) {
  22968. err = sp_256_point_to_ecc_point_9(point, pub);
  22969. }
  22970. #ifdef WOLFSSL_SP_SMALL_STACK
  22971. if (k != NULL)
  22972. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  22973. if (point != NULL) {
  22974. /* point is not sensitive, so no need to zeroize */
  22975. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  22976. }
  22977. #endif
  22978. return err;
  22979. }
  22980. #ifdef WOLFSSL_SP_NONBLOCK
  22981. typedef struct sp_ecc_key_gen_256_ctx {
  22982. int state;
  22983. sp_256_ecc_mulmod_9_ctx mulmod_ctx;
  22984. sp_digit k[9];
  22985. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22986. sp_point_256 point[2];
  22987. #else
  22988. sp_point_256 point[1];
  22989. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  22990. } sp_ecc_key_gen_256_ctx;
  22991. int sp_ecc_make_key_256_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng, mp_int* priv,
  22992. ecc_point* pub, void* heap)
  22993. {
  22994. int err = FP_WOULDBLOCK;
  22995. sp_ecc_key_gen_256_ctx* ctx = (sp_ecc_key_gen_256_ctx*)sp_ctx->data;
  22996. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  22997. sp_point_256* infinity = ctx->point + 1;
  22998. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  22999. typedef char ctx_size_test[sizeof(sp_ecc_key_gen_256_ctx)
  23000. >= sizeof(*sp_ctx) ? -1 : 1];
  23001. (void)sizeof(ctx_size_test);
  23002. switch (ctx->state) {
  23003. case 0:
  23004. err = sp_256_ecc_gen_k_9(rng, ctx->k);
  23005. if (err == MP_OKAY) {
  23006. err = FP_WOULDBLOCK;
  23007. ctx->state = 1;
  23008. }
  23009. break;
  23010. case 1:
  23011. err = sp_256_ecc_mulmod_base_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  23012. ctx->point, ctx->k, 1, 1, heap);
  23013. if (err == MP_OKAY) {
  23014. err = FP_WOULDBLOCK;
  23015. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  23016. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  23017. ctx->state = 2;
  23018. #else
  23019. ctx->state = 3;
  23020. #endif
  23021. }
  23022. break;
  23023. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  23024. case 2:
  23025. err = sp_256_ecc_mulmod_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  23026. infinity, ctx->point, p256_order, 1, 1);
  23027. if (err == MP_OKAY) {
  23028. if (sp_256_iszero_9(ctx->point->x) ||
  23029. sp_256_iszero_9(ctx->point->y)) {
  23030. err = ECC_INF_E;
  23031. }
  23032. else {
  23033. err = FP_WOULDBLOCK;
  23034. ctx->state = 3;
  23035. }
  23036. }
  23037. break;
  23038. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  23039. case 3:
  23040. err = sp_256_to_mp(ctx->k, priv);
  23041. if (err == MP_OKAY) {
  23042. err = sp_256_point_to_ecc_point_9(ctx->point, pub);
  23043. }
  23044. break;
  23045. }
  23046. if (err != FP_WOULDBLOCK) {
  23047. XMEMSET(ctx, 0, sizeof(sp_ecc_key_gen_256_ctx));
  23048. }
  23049. return err;
  23050. }
  23051. #endif /* WOLFSSL_SP_NONBLOCK */
  23052. #ifdef HAVE_ECC_DHE
  23053. /* Write r as big endian to byte array.
  23054. * Fixed length number of bytes written: 32
  23055. *
  23056. * r A single precision integer.
  23057. * a Byte array.
  23058. */
  23059. static void sp_256_to_bin_9(sp_digit* r, byte* a)
  23060. {
  23061. int i;
  23062. int j;
  23063. int s = 0;
  23064. int b;
  23065. for (i=0; i<8; i++) {
  23066. r[i+1] += r[i] >> 29;
  23067. r[i] &= 0x1fffffff;
  23068. }
  23069. j = 263 / 8 - 1;
  23070. a[j] = 0;
  23071. for (i=0; i<9 && j>=0; i++) {
  23072. b = 0;
  23073. /* lint allow cast of mismatch sp_digit and int */
  23074. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  23075. b += 8 - s;
  23076. if (j < 0) {
  23077. break;
  23078. }
  23079. while (b < 29) {
  23080. a[j--] = (byte)(r[i] >> b);
  23081. b += 8;
  23082. if (j < 0) {
  23083. break;
  23084. }
  23085. }
  23086. s = 8 - (b - 29);
  23087. if (j >= 0) {
  23088. a[j] = 0;
  23089. }
  23090. if (s != 0) {
  23091. j++;
  23092. }
  23093. }
  23094. }
  23095. /* Multiply the point by the scalar and serialize the X ordinate.
  23096. * The number is 0 padded to maximum size on output.
  23097. *
  23098. * priv Scalar to multiply the point by.
  23099. * pub Point to multiply.
  23100. * out Buffer to hold X ordinate.
  23101. * outLen On entry, size of the buffer in bytes.
  23102. * On exit, length of data in buffer in bytes.
  23103. * heap Heap to use for allocation.
  23104. * returns BUFFER_E if the buffer is to small for output size,
  23105. * MEMORY_E when memory allocation fails and MP_OKAY on success.
  23106. */
  23107. int sp_ecc_secret_gen_256(const mp_int* priv, const ecc_point* pub, byte* out,
  23108. word32* outLen, void* heap)
  23109. {
  23110. #ifdef WOLFSSL_SP_SMALL_STACK
  23111. sp_point_256* point = NULL;
  23112. sp_digit* k = NULL;
  23113. #else
  23114. sp_point_256 point[1];
  23115. sp_digit k[9];
  23116. #endif
  23117. int err = MP_OKAY;
  23118. if (*outLen < 32U) {
  23119. err = BUFFER_E;
  23120. }
  23121. #ifdef WOLFSSL_SP_SMALL_STACK
  23122. if (err == MP_OKAY) {
  23123. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256), heap,
  23124. DYNAMIC_TYPE_ECC);
  23125. if (point == NULL)
  23126. err = MEMORY_E;
  23127. }
  23128. if (err == MP_OKAY) {
  23129. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9, heap,
  23130. DYNAMIC_TYPE_ECC);
  23131. if (k == NULL)
  23132. err = MEMORY_E;
  23133. }
  23134. #endif
  23135. if (err == MP_OKAY) {
  23136. sp_256_from_mp(k, 9, priv);
  23137. sp_256_point_from_ecc_point_9(point, pub);
  23138. err = sp_256_ecc_mulmod_9(point, point, k, 1, 1, heap);
  23139. }
  23140. if (err == MP_OKAY) {
  23141. sp_256_to_bin_9(point->x, out);
  23142. *outLen = 32;
  23143. }
  23144. #ifdef WOLFSSL_SP_SMALL_STACK
  23145. if (k != NULL)
  23146. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  23147. if (point != NULL)
  23148. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  23149. #endif
  23150. return err;
  23151. }
  23152. #ifdef WOLFSSL_SP_NONBLOCK
  23153. typedef struct sp_ecc_sec_gen_256_ctx {
  23154. int state;
  23155. union {
  23156. sp_256_ecc_mulmod_9_ctx mulmod_ctx;
  23157. };
  23158. sp_digit k[9];
  23159. sp_point_256 point;
  23160. } sp_ecc_sec_gen_256_ctx;
  23161. int sp_ecc_secret_gen_256_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv,
  23162. const ecc_point* pub, byte* out, word32* outLen, void* heap)
  23163. {
  23164. int err = FP_WOULDBLOCK;
  23165. sp_ecc_sec_gen_256_ctx* ctx = (sp_ecc_sec_gen_256_ctx*)sp_ctx->data;
  23166. typedef char ctx_size_test[sizeof(sp_ecc_sec_gen_256_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  23167. (void)sizeof(ctx_size_test);
  23168. if (*outLen < 32U) {
  23169. err = BUFFER_E;
  23170. }
  23171. switch (ctx->state) {
  23172. case 0:
  23173. sp_256_from_mp(ctx->k, 9, priv);
  23174. sp_256_point_from_ecc_point_9(&ctx->point, pub);
  23175. ctx->state = 1;
  23176. break;
  23177. case 1:
  23178. err = sp_256_ecc_mulmod_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  23179. &ctx->point, &ctx->point, ctx->k, 1, 1, heap);
  23180. if (err == MP_OKAY) {
  23181. sp_256_to_bin_9(ctx->point.x, out);
  23182. *outLen = 32;
  23183. }
  23184. break;
  23185. }
  23186. if (err == MP_OKAY && ctx->state != 1) {
  23187. err = FP_WOULDBLOCK;
  23188. }
  23189. if (err != FP_WOULDBLOCK) {
  23190. XMEMSET(ctx, 0, sizeof(sp_ecc_sec_gen_256_ctx));
  23191. }
  23192. return err;
  23193. }
  23194. #endif /* WOLFSSL_SP_NONBLOCK */
  23195. #endif /* HAVE_ECC_DHE */
  23196. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  23197. #endif
  23198. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  23199. SP_NOINLINE static void sp_256_rshift_9(sp_digit* r, const sp_digit* a,
  23200. byte n)
  23201. {
  23202. int i;
  23203. #ifdef WOLFSSL_SP_SMALL
  23204. for (i=0; i<8; i++) {
  23205. r[i] = ((a[i] >> n) | (a[i + 1] << (29 - n))) & 0x1fffffff;
  23206. }
  23207. #else
  23208. for (i=0; i<8; i += 8) {
  23209. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (29 - n)) & 0x1fffffff);
  23210. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (29 - n)) & 0x1fffffff);
  23211. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (29 - n)) & 0x1fffffff);
  23212. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (29 - n)) & 0x1fffffff);
  23213. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (29 - n)) & 0x1fffffff);
  23214. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (29 - n)) & 0x1fffffff);
  23215. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (29 - n)) & 0x1fffffff);
  23216. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (29 - n)) & 0x1fffffff);
  23217. }
  23218. #endif /* WOLFSSL_SP_SMALL */
  23219. r[8] = a[8] >> n;
  23220. }
  23221. /* Multiply a by scalar b into r. (r = a * b)
  23222. *
  23223. * r A single precision integer.
  23224. * a A single precision integer.
  23225. * b A scalar.
  23226. */
  23227. SP_NOINLINE static void sp_256_mul_d_9(sp_digit* r, const sp_digit* a,
  23228. sp_digit b)
  23229. {
  23230. #ifdef WOLFSSL_SP_SMALL
  23231. sp_int64 tb = b;
  23232. sp_int64 t = 0;
  23233. int i;
  23234. for (i = 0; i < 9; i++) {
  23235. t += tb * a[i];
  23236. r[i] = (sp_digit)(t & 0x1fffffff);
  23237. t >>= 29;
  23238. }
  23239. r[9] = (sp_digit)t;
  23240. #else
  23241. sp_int64 tb = b;
  23242. sp_int64 t[9];
  23243. t[ 0] = tb * a[ 0];
  23244. t[ 1] = tb * a[ 1];
  23245. t[ 2] = tb * a[ 2];
  23246. t[ 3] = tb * a[ 3];
  23247. t[ 4] = tb * a[ 4];
  23248. t[ 5] = tb * a[ 5];
  23249. t[ 6] = tb * a[ 6];
  23250. t[ 7] = tb * a[ 7];
  23251. t[ 8] = tb * a[ 8];
  23252. r[ 0] = (sp_digit) (t[ 0] & 0x1fffffff);
  23253. r[ 1] = (sp_digit)((t[ 0] >> 29) + (t[ 1] & 0x1fffffff));
  23254. r[ 2] = (sp_digit)((t[ 1] >> 29) + (t[ 2] & 0x1fffffff));
  23255. r[ 3] = (sp_digit)((t[ 2] >> 29) + (t[ 3] & 0x1fffffff));
  23256. r[ 4] = (sp_digit)((t[ 3] >> 29) + (t[ 4] & 0x1fffffff));
  23257. r[ 5] = (sp_digit)((t[ 4] >> 29) + (t[ 5] & 0x1fffffff));
  23258. r[ 6] = (sp_digit)((t[ 5] >> 29) + (t[ 6] & 0x1fffffff));
  23259. r[ 7] = (sp_digit)((t[ 6] >> 29) + (t[ 7] & 0x1fffffff));
  23260. r[ 8] = (sp_digit)((t[ 7] >> 29) + (t[ 8] & 0x1fffffff));
  23261. r[ 9] = (sp_digit) (t[ 8] >> 29);
  23262. #endif /* WOLFSSL_SP_SMALL */
  23263. }
  23264. SP_NOINLINE static void sp_256_lshift_18(sp_digit* r, const sp_digit* a,
  23265. byte n)
  23266. {
  23267. #ifdef WOLFSSL_SP_SMALL
  23268. int i;
  23269. r[18] = a[17] >> (29 - n);
  23270. for (i=17; i>0; i--) {
  23271. r[i] = ((a[i] << n) | (a[i-1] >> (29 - n))) & 0x1fffffff;
  23272. }
  23273. #else
  23274. sp_int_digit s;
  23275. sp_int_digit t;
  23276. s = (sp_int_digit)a[17];
  23277. r[18] = s >> (29U - n);
  23278. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  23279. r[17] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23280. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  23281. r[16] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23282. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  23283. r[15] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23284. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  23285. r[14] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23286. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  23287. r[13] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23288. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  23289. r[12] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23290. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  23291. r[11] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23292. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  23293. r[10] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23294. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  23295. r[9] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23296. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  23297. r[8] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23298. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  23299. r[7] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23300. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  23301. r[6] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23302. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  23303. r[5] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23304. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  23305. r[4] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23306. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  23307. r[3] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23308. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  23309. r[2] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23310. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  23311. r[1] = ((s << n) | (t >> (29U - n))) & 0x1fffffff;
  23312. #endif /* WOLFSSL_SP_SMALL */
  23313. r[0] = (a[0] << n) & 0x1fffffff;
  23314. }
  23315. /* Divide d in a and put remainder into r (m*d + r = a)
  23316. * m is not calculated as it is not needed at this time.
  23317. *
  23318. * Simplified based on top word of divisor being (1 << 29) - 1
  23319. *
  23320. * a Number to be divided.
  23321. * d Number to divide with.
  23322. * m Multiplier result.
  23323. * r Remainder from the division.
  23324. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  23325. */
  23326. static int sp_256_div_9(const sp_digit* a, const sp_digit* d,
  23327. const sp_digit* m, sp_digit* r)
  23328. {
  23329. int i;
  23330. sp_digit r1;
  23331. sp_digit mask;
  23332. #ifdef WOLFSSL_SP_SMALL_STACK
  23333. sp_digit* t1 = NULL;
  23334. #else
  23335. sp_digit t1[4 * 9 + 3];
  23336. #endif
  23337. sp_digit* t2 = NULL;
  23338. sp_digit* sd = NULL;
  23339. int err = MP_OKAY;
  23340. (void)m;
  23341. #ifdef WOLFSSL_SP_SMALL_STACK
  23342. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 9 + 3), NULL,
  23343. DYNAMIC_TYPE_TMP_BUFFER);
  23344. if (t1 == NULL)
  23345. err = MEMORY_E;
  23346. #endif
  23347. (void)m;
  23348. if (err == MP_OKAY) {
  23349. t2 = t1 + 18 + 1;
  23350. sd = t2 + 9 + 1;
  23351. sp_256_mul_d_9(sd, d, (sp_digit)1 << 5);
  23352. sp_256_lshift_18(t1, a, 5);
  23353. t1[9 + 9] += t1[9 + 9 - 1] >> 29;
  23354. t1[9 + 9 - 1] &= 0x1fffffff;
  23355. for (i=8; i>=0; i--) {
  23356. r1 = t1[9 + i];
  23357. sp_256_mul_d_9(t2, sd, r1);
  23358. (void)sp_256_sub_9(&t1[i], &t1[i], t2);
  23359. t1[9 + i] -= t2[9];
  23360. sp_256_norm_9(&t1[i + 1]);
  23361. mask = ~((t1[9 + i] - 1) >> 31);
  23362. sp_256_cond_sub_9(t1 + i, t1 + i, sd, mask);
  23363. sp_256_norm_9(&t1[i + 1]);
  23364. }
  23365. sp_256_norm_9(t1);
  23366. sp_256_rshift_9(r, t1, 5);
  23367. }
  23368. #ifdef WOLFSSL_SP_SMALL_STACK
  23369. if (t1 != NULL)
  23370. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  23371. #endif
  23372. return err;
  23373. }
  23374. /* Reduce a modulo m into r. (r = a mod m)
  23375. *
  23376. * r A single precision number that is the reduced result.
  23377. * a A single precision number that is to be reduced.
  23378. * m A single precision number that is the modulus to reduce with.
  23379. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  23380. */
  23381. static int sp_256_mod_9(sp_digit* r, const sp_digit* a, const sp_digit* m)
  23382. {
  23383. return sp_256_div_9(a, m, NULL, r);
  23384. }
  23385. #endif
  23386. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  23387. /* Multiply two number mod the order of P256 curve. (r = a * b mod order)
  23388. *
  23389. * r Result of the multiplication.
  23390. * a First operand of the multiplication.
  23391. * b Second operand of the multiplication.
  23392. */
  23393. static void sp_256_mont_mul_order_9(sp_digit* r, const sp_digit* a, const sp_digit* b)
  23394. {
  23395. sp_256_mul_9(r, a, b);
  23396. sp_256_mont_reduce_order_9(r, p256_order, p256_mp_order);
  23397. }
  23398. #if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL))
  23399. #ifdef WOLFSSL_SP_SMALL
  23400. /* Order-2 for the P256 curve. */
  23401. static const uint32_t p256_order_minus_2[8] = {
  23402. 0xfc63254fU,0xf3b9cac2U,0xa7179e84U,0xbce6faadU,0xffffffffU,0xffffffffU,
  23403. 0x00000000U,0xffffffffU
  23404. };
  23405. #else
  23406. /* The low half of the order-2 of the P256 curve. */
  23407. static const sp_int_digit p256_order_low[4] = {
  23408. 0xfc63254fU,0xf3b9cac2U,0xa7179e84U,0xbce6faadU
  23409. };
  23410. #endif /* WOLFSSL_SP_SMALL */
  23411. /* Square number mod the order of P256 curve. (r = a * a mod order)
  23412. *
  23413. * r Result of the squaring.
  23414. * a Number to square.
  23415. */
  23416. static void sp_256_mont_sqr_order_9(sp_digit* r, const sp_digit* a)
  23417. {
  23418. sp_256_sqr_9(r, a);
  23419. sp_256_mont_reduce_order_9(r, p256_order, p256_mp_order);
  23420. }
  23421. #ifndef WOLFSSL_SP_SMALL
  23422. /* Square number mod the order of P256 curve a number of times.
  23423. * (r = a ^ n mod order)
  23424. *
  23425. * r Result of the squaring.
  23426. * a Number to square.
  23427. */
  23428. static void sp_256_mont_sqr_n_order_9(sp_digit* r, const sp_digit* a, int n)
  23429. {
  23430. int i;
  23431. sp_256_mont_sqr_order_9(r, a);
  23432. for (i=1; i<n; i++) {
  23433. sp_256_mont_sqr_order_9(r, r);
  23434. }
  23435. }
  23436. #endif /* !WOLFSSL_SP_SMALL */
  23437. /* Invert the number, in Montgomery form, modulo the order of the P256 curve.
  23438. * (r = 1 / a mod order)
  23439. *
  23440. * r Inverse result.
  23441. * a Number to invert.
  23442. * td Temporary data.
  23443. */
  23444. #ifdef WOLFSSL_SP_NONBLOCK
  23445. typedef struct sp_256_mont_inv_order_9_ctx {
  23446. int state;
  23447. int i;
  23448. } sp_256_mont_inv_order_9_ctx;
  23449. static int sp_256_mont_inv_order_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_digit* a,
  23450. sp_digit* t)
  23451. {
  23452. int err = FP_WOULDBLOCK;
  23453. sp_256_mont_inv_order_9_ctx* ctx = (sp_256_mont_inv_order_9_ctx*)sp_ctx;
  23454. typedef char ctx_size_test[sizeof(sp_256_mont_inv_order_9_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  23455. (void)sizeof(ctx_size_test);
  23456. switch (ctx->state) {
  23457. case 0:
  23458. XMEMCPY(t, a, sizeof(sp_digit) * 9);
  23459. ctx->i = 254;
  23460. ctx->state = 1;
  23461. break;
  23462. case 1:
  23463. sp_256_mont_sqr_order_9(t, t);
  23464. ctx->state = 2;
  23465. break;
  23466. case 2:
  23467. if ((p256_order_minus_2[ctx->i / 32] & ((sp_int_digit)1 << (ctx->i % 32))) != 0) {
  23468. sp_256_mont_mul_order_9(t, t, a);
  23469. }
  23470. ctx->i--;
  23471. ctx->state = (ctx->i == 0) ? 3 : 1;
  23472. break;
  23473. case 3:
  23474. XMEMCPY(r, t, sizeof(sp_digit) * 9U);
  23475. err = MP_OKAY;
  23476. break;
  23477. }
  23478. return err;
  23479. }
  23480. #endif /* WOLFSSL_SP_NONBLOCK */
  23481. static void sp_256_mont_inv_order_9(sp_digit* r, const sp_digit* a,
  23482. sp_digit* td)
  23483. {
  23484. #ifdef WOLFSSL_SP_SMALL
  23485. sp_digit* t = td;
  23486. int i;
  23487. XMEMCPY(t, a, sizeof(sp_digit) * 9);
  23488. for (i=254; i>=0; i--) {
  23489. sp_256_mont_sqr_order_9(t, t);
  23490. if ((p256_order_minus_2[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  23491. sp_256_mont_mul_order_9(t, t, a);
  23492. }
  23493. }
  23494. XMEMCPY(r, t, sizeof(sp_digit) * 9U);
  23495. #else
  23496. sp_digit* t = td;
  23497. sp_digit* t2 = td + 2 * 9;
  23498. sp_digit* t3 = td + 4 * 9;
  23499. int i;
  23500. /* t = a^2 */
  23501. sp_256_mont_sqr_order_9(t, a);
  23502. /* t = a^3 = t * a */
  23503. sp_256_mont_mul_order_9(t, t, a);
  23504. /* t2= a^c = t ^ 2 ^ 2 */
  23505. sp_256_mont_sqr_n_order_9(t2, t, 2);
  23506. /* t3= a^f = t2 * t */
  23507. sp_256_mont_mul_order_9(t3, t2, t);
  23508. /* t2= a^f0 = t3 ^ 2 ^ 4 */
  23509. sp_256_mont_sqr_n_order_9(t2, t3, 4);
  23510. /* t = a^ff = t2 * t3 */
  23511. sp_256_mont_mul_order_9(t, t2, t3);
  23512. /* t2= a^ff00 = t ^ 2 ^ 8 */
  23513. sp_256_mont_sqr_n_order_9(t2, t, 8);
  23514. /* t = a^ffff = t2 * t */
  23515. sp_256_mont_mul_order_9(t, t2, t);
  23516. /* t2= a^ffff0000 = t ^ 2 ^ 16 */
  23517. sp_256_mont_sqr_n_order_9(t2, t, 16);
  23518. /* t = a^ffffffff = t2 * t */
  23519. sp_256_mont_mul_order_9(t, t2, t);
  23520. /* t2= a^ffffffff0000000000000000 = t ^ 2 ^ 64 */
  23521. sp_256_mont_sqr_n_order_9(t2, t, 64);
  23522. /* t2= a^ffffffff00000000ffffffff = t2 * t */
  23523. sp_256_mont_mul_order_9(t2, t2, t);
  23524. /* t2= a^ffffffff00000000ffffffff00000000 = t2 ^ 2 ^ 32 */
  23525. sp_256_mont_sqr_n_order_9(t2, t2, 32);
  23526. /* t2= a^ffffffff00000000ffffffffffffffff = t2 * t */
  23527. sp_256_mont_mul_order_9(t2, t2, t);
  23528. /* t2= a^ffffffff00000000ffffffffffffffffbce6 */
  23529. sp_256_mont_sqr_order_9(t2, t2);
  23530. sp_256_mont_mul_order_9(t2, t2, a);
  23531. sp_256_mont_sqr_n_order_9(t2, t2, 5);
  23532. sp_256_mont_mul_order_9(t2, t2, t3);
  23533. for (i=121; i>=112; i--) {
  23534. sp_256_mont_sqr_order_9(t2, t2);
  23535. if ((p256_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  23536. sp_256_mont_mul_order_9(t2, t2, a);
  23537. }
  23538. }
  23539. /* t2= a^ffffffff00000000ffffffffffffffffbce6f */
  23540. sp_256_mont_sqr_n_order_9(t2, t2, 4);
  23541. sp_256_mont_mul_order_9(t2, t2, t3);
  23542. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84 */
  23543. for (i=107; i>=64; i--) {
  23544. sp_256_mont_sqr_order_9(t2, t2);
  23545. if ((p256_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  23546. sp_256_mont_mul_order_9(t2, t2, a);
  23547. }
  23548. }
  23549. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84f */
  23550. sp_256_mont_sqr_n_order_9(t2, t2, 4);
  23551. sp_256_mont_mul_order_9(t2, t2, t3);
  23552. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2 */
  23553. for (i=59; i>=32; i--) {
  23554. sp_256_mont_sqr_order_9(t2, t2);
  23555. if ((p256_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  23556. sp_256_mont_mul_order_9(t2, t2, a);
  23557. }
  23558. }
  23559. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f */
  23560. sp_256_mont_sqr_n_order_9(t2, t2, 4);
  23561. sp_256_mont_mul_order_9(t2, t2, t3);
  23562. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254 */
  23563. for (i=27; i>=0; i--) {
  23564. sp_256_mont_sqr_order_9(t2, t2);
  23565. if ((p256_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  23566. sp_256_mont_mul_order_9(t2, t2, a);
  23567. }
  23568. }
  23569. /* t2= a^ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632540 */
  23570. sp_256_mont_sqr_n_order_9(t2, t2, 4);
  23571. /* r = a^ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f */
  23572. sp_256_mont_mul_order_9(r, t2, t3);
  23573. #endif /* WOLFSSL_SP_SMALL */
  23574. }
  23575. #endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */
  23576. #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  23577. #ifdef HAVE_ECC_SIGN
  23578. #ifndef SP_ECC_MAX_SIG_GEN
  23579. #define SP_ECC_MAX_SIG_GEN 64
  23580. #endif
  23581. /* Calculate second signature value S from R, k and private value.
  23582. *
  23583. * s = (r * x + e) / k
  23584. *
  23585. * s Signature value.
  23586. * r First signature value.
  23587. * k Ephemeral private key.
  23588. * x Private key as a number.
  23589. * e Hash of message as a number.
  23590. * tmp Temporary storage for intermediate numbers.
  23591. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  23592. */
  23593. static int sp_256_calc_s_9(sp_digit* s, const sp_digit* r, sp_digit* k,
  23594. sp_digit* x, const sp_digit* e, sp_digit* tmp)
  23595. {
  23596. int err;
  23597. sp_digit carry;
  23598. sp_int32 c;
  23599. sp_digit* kInv = k;
  23600. /* Conv k to Montgomery form (mod order) */
  23601. sp_256_mul_9(k, k, p256_norm_order);
  23602. err = sp_256_mod_9(k, k, p256_order);
  23603. if (err == MP_OKAY) {
  23604. sp_256_norm_9(k);
  23605. /* kInv = 1/k mod order */
  23606. sp_256_mont_inv_order_9(kInv, k, tmp);
  23607. sp_256_norm_9(kInv);
  23608. /* s = r * x + e */
  23609. sp_256_mul_9(x, x, r);
  23610. err = sp_256_mod_9(x, x, p256_order);
  23611. }
  23612. if (err == MP_OKAY) {
  23613. sp_256_norm_9(x);
  23614. carry = sp_256_add_9(s, e, x);
  23615. sp_256_cond_sub_9(s, s, p256_order, 0 - carry);
  23616. sp_256_norm_9(s);
  23617. c = sp_256_cmp_9(s, p256_order);
  23618. sp_256_cond_sub_9(s, s, p256_order,
  23619. (sp_digit)0 - (sp_digit)(c >= 0));
  23620. sp_256_norm_9(s);
  23621. /* s = s * k^-1 mod order */
  23622. sp_256_mont_mul_order_9(s, s, kInv);
  23623. sp_256_norm_9(s);
  23624. }
  23625. return err;
  23626. }
  23627. /* Sign the hash using the private key.
  23628. * e = [hash, 256 bits] from binary
  23629. * r = (k.G)->x mod order
  23630. * s = (r * x + e) / k mod order
  23631. * The hash is truncated to the first 256 bits.
  23632. *
  23633. * hash Hash to sign.
  23634. * hashLen Length of the hash data.
  23635. * rng Random number generator.
  23636. * priv Private part of key - scalar.
  23637. * rm First part of result as an mp_int.
  23638. * sm Sirst part of result as an mp_int.
  23639. * heap Heap to use for allocation.
  23640. * returns RNG failures, MEMORY_E when memory allocation fails and
  23641. * MP_OKAY on success.
  23642. */
  23643. int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
  23644. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  23645. {
  23646. #ifdef WOLFSSL_SP_SMALL_STACK
  23647. sp_digit* e = NULL;
  23648. sp_point_256* point = NULL;
  23649. #else
  23650. sp_digit e[7 * 2 * 9];
  23651. sp_point_256 point[1];
  23652. #endif
  23653. sp_digit* x = NULL;
  23654. sp_digit* k = NULL;
  23655. sp_digit* r = NULL;
  23656. sp_digit* tmp = NULL;
  23657. sp_digit* s = NULL;
  23658. sp_int32 c;
  23659. int err = MP_OKAY;
  23660. int i;
  23661. (void)heap;
  23662. #ifdef WOLFSSL_SP_SMALL_STACK
  23663. if (err == MP_OKAY) {
  23664. point = (sp_point_256*)XMALLOC(sizeof(sp_point_256), heap,
  23665. DYNAMIC_TYPE_ECC);
  23666. if (point == NULL)
  23667. err = MEMORY_E;
  23668. }
  23669. if (err == MP_OKAY) {
  23670. e = (sp_digit*)XMALLOC(sizeof(sp_digit) * 7 * 2 * 9, heap,
  23671. DYNAMIC_TYPE_ECC);
  23672. if (e == NULL)
  23673. err = MEMORY_E;
  23674. }
  23675. #endif
  23676. if (err == MP_OKAY) {
  23677. x = e + 2 * 9;
  23678. k = e + 4 * 9;
  23679. r = e + 6 * 9;
  23680. tmp = e + 8 * 9;
  23681. s = e;
  23682. if (hashLen > 32U) {
  23683. hashLen = 32U;
  23684. }
  23685. }
  23686. for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
  23687. /* New random point. */
  23688. if (km == NULL || mp_iszero(km)) {
  23689. err = sp_256_ecc_gen_k_9(rng, k);
  23690. }
  23691. else {
  23692. sp_256_from_mp(k, 9, km);
  23693. mp_zero(km);
  23694. }
  23695. if (err == MP_OKAY) {
  23696. err = sp_256_ecc_mulmod_base_9(point, k, 1, 1, heap);
  23697. }
  23698. if (err == MP_OKAY) {
  23699. /* r = point->x mod order */
  23700. XMEMCPY(r, point->x, sizeof(sp_digit) * 9U);
  23701. sp_256_norm_9(r);
  23702. c = sp_256_cmp_9(r, p256_order);
  23703. sp_256_cond_sub_9(r, r, p256_order,
  23704. (sp_digit)0 - (sp_digit)(c >= 0));
  23705. sp_256_norm_9(r);
  23706. if (!sp_256_iszero_9(r)) {
  23707. /* x is modified in calculation of s. */
  23708. sp_256_from_mp(x, 9, priv);
  23709. /* s ptr == e ptr, e is modified in calculation of s. */
  23710. sp_256_from_bin(e, 9, hash, (int)hashLen);
  23711. err = sp_256_calc_s_9(s, r, k, x, e, tmp);
  23712. /* Check that signature is usable. */
  23713. if ((err == MP_OKAY) && (!sp_256_iszero_9(s))) {
  23714. break;
  23715. }
  23716. }
  23717. }
  23718. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  23719. i = 1;
  23720. #endif
  23721. }
  23722. if (i == 0) {
  23723. err = RNG_FAILURE_E;
  23724. }
  23725. if (err == MP_OKAY) {
  23726. err = sp_256_to_mp(r, rm);
  23727. }
  23728. if (err == MP_OKAY) {
  23729. err = sp_256_to_mp(s, sm);
  23730. }
  23731. #ifdef WOLFSSL_SP_SMALL_STACK
  23732. if (e != NULL)
  23733. #endif
  23734. {
  23735. ForceZero(e, sizeof(sp_digit) * 7 * 2 * 9);
  23736. #ifdef WOLFSSL_SP_SMALL_STACK
  23737. XFREE(e, heap, DYNAMIC_TYPE_ECC);
  23738. #endif
  23739. }
  23740. #ifdef WOLFSSL_SP_SMALL_STACK
  23741. if (point != NULL)
  23742. #endif
  23743. {
  23744. ForceZero(point, sizeof(sp_point_256));
  23745. #ifdef WOLFSSL_SP_SMALL_STACK
  23746. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  23747. #endif
  23748. }
  23749. return err;
  23750. }
  23751. #ifdef WOLFSSL_SP_NONBLOCK
  23752. typedef struct sp_ecc_sign_256_ctx {
  23753. int state;
  23754. union {
  23755. sp_256_ecc_mulmod_9_ctx mulmod_ctx;
  23756. sp_256_mont_inv_order_9_ctx mont_inv_order_ctx;
  23757. };
  23758. sp_digit e[2*9];
  23759. sp_digit x[2*9];
  23760. sp_digit k[2*9];
  23761. sp_digit r[2*9];
  23762. sp_digit tmp[3 * 2*9];
  23763. sp_point_256 point;
  23764. sp_digit* s;
  23765. sp_digit* kInv;
  23766. int i;
  23767. } sp_ecc_sign_256_ctx;
  23768. int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, WC_RNG* rng,
  23769. mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  23770. {
  23771. int err = FP_WOULDBLOCK;
  23772. sp_ecc_sign_256_ctx* ctx = (sp_ecc_sign_256_ctx*)sp_ctx->data;
  23773. typedef char ctx_size_test[sizeof(sp_ecc_sign_256_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  23774. (void)sizeof(ctx_size_test);
  23775. switch (ctx->state) {
  23776. case 0: /* INIT */
  23777. ctx->s = ctx->e;
  23778. ctx->kInv = ctx->k;
  23779. ctx->i = SP_ECC_MAX_SIG_GEN;
  23780. ctx->state = 1;
  23781. break;
  23782. case 1: /* GEN */
  23783. /* New random point. */
  23784. if (km == NULL || mp_iszero(km)) {
  23785. err = sp_256_ecc_gen_k_9(rng, ctx->k);
  23786. }
  23787. else {
  23788. sp_256_from_mp(ctx->k, 9, km);
  23789. mp_zero(km);
  23790. }
  23791. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  23792. ctx->state = 2;
  23793. break;
  23794. case 2: /* MULMOD */
  23795. err = sp_256_ecc_mulmod_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  23796. &ctx->point, &p256_base, ctx->k, 1, 1, heap);
  23797. if (err == MP_OKAY) {
  23798. ctx->state = 3;
  23799. }
  23800. break;
  23801. case 3: /* MODORDER */
  23802. {
  23803. sp_int32 c;
  23804. /* r = point->x mod order */
  23805. XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 9U);
  23806. sp_256_norm_9(ctx->r);
  23807. c = sp_256_cmp_9(ctx->r, p256_order);
  23808. sp_256_cond_sub_9(ctx->r, ctx->r, p256_order,
  23809. (sp_digit)0 - (sp_digit)(c >= 0));
  23810. sp_256_norm_9(ctx->r);
  23811. if (hashLen > 32U) {
  23812. hashLen = 32U;
  23813. }
  23814. sp_256_from_mp(ctx->x, 9, priv);
  23815. sp_256_from_bin(ctx->e, 9, hash, (int)hashLen);
  23816. ctx->state = 4;
  23817. break;
  23818. }
  23819. case 4: /* KMODORDER */
  23820. /* Conv k to Montgomery form (mod order) */
  23821. sp_256_mul_9(ctx->k, ctx->k, p256_norm_order);
  23822. err = sp_256_mod_9(ctx->k, ctx->k, p256_order);
  23823. if (err == MP_OKAY) {
  23824. sp_256_norm_9(ctx->k);
  23825. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  23826. ctx->state = 5;
  23827. }
  23828. break;
  23829. case 5: /* KINV */
  23830. /* kInv = 1/k mod order */
  23831. err = sp_256_mont_inv_order_9_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->kInv, ctx->k, ctx->tmp);
  23832. if (err == MP_OKAY) {
  23833. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  23834. ctx->state = 6;
  23835. }
  23836. break;
  23837. case 6: /* KINVNORM */
  23838. sp_256_norm_9(ctx->kInv);
  23839. ctx->state = 7;
  23840. break;
  23841. case 7: /* R */
  23842. /* s = r * x + e */
  23843. sp_256_mul_9(ctx->x, ctx->x, ctx->r);
  23844. ctx->state = 8;
  23845. break;
  23846. case 8: /* S1 */
  23847. err = sp_256_mod_9(ctx->x, ctx->x, p256_order);
  23848. if (err == MP_OKAY)
  23849. ctx->state = 9;
  23850. break;
  23851. case 9: /* S2 */
  23852. {
  23853. sp_digit carry;
  23854. sp_int32 c;
  23855. sp_256_norm_9(ctx->x);
  23856. carry = sp_256_add_9(ctx->s, ctx->e, ctx->x);
  23857. sp_256_cond_sub_9(ctx->s, ctx->s,
  23858. p256_order, 0 - carry);
  23859. sp_256_norm_9(ctx->s);
  23860. c = sp_256_cmp_9(ctx->s, p256_order);
  23861. sp_256_cond_sub_9(ctx->s, ctx->s, p256_order,
  23862. (sp_digit)0 - (sp_digit)(c >= 0));
  23863. sp_256_norm_9(ctx->s);
  23864. /* s = s * k^-1 mod order */
  23865. sp_256_mont_mul_order_9(ctx->s, ctx->s, ctx->kInv);
  23866. sp_256_norm_9(ctx->s);
  23867. /* Check that signature is usable. */
  23868. if (sp_256_iszero_9(ctx->s) == 0) {
  23869. ctx->state = 10;
  23870. break;
  23871. }
  23872. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  23873. ctx->i = 1;
  23874. #endif
  23875. /* not usable gen, try again */
  23876. ctx->i--;
  23877. if (ctx->i == 0) {
  23878. err = RNG_FAILURE_E;
  23879. }
  23880. ctx->state = 1;
  23881. break;
  23882. }
  23883. case 10: /* RES */
  23884. err = sp_256_to_mp(ctx->r, rm);
  23885. if (err == MP_OKAY) {
  23886. err = sp_256_to_mp(ctx->s, sm);
  23887. }
  23888. break;
  23889. }
  23890. if (err == MP_OKAY && ctx->state != 10) {
  23891. err = FP_WOULDBLOCK;
  23892. }
  23893. if (err != FP_WOULDBLOCK) {
  23894. XMEMSET(ctx->e, 0, sizeof(sp_digit) * 2U * 9U);
  23895. XMEMSET(ctx->x, 0, sizeof(sp_digit) * 2U * 9U);
  23896. XMEMSET(ctx->k, 0, sizeof(sp_digit) * 2U * 9U);
  23897. XMEMSET(ctx->r, 0, sizeof(sp_digit) * 2U * 9U);
  23898. XMEMSET(ctx->tmp, 0, sizeof(sp_digit) * 3U * 2U * 9U);
  23899. }
  23900. return err;
  23901. }
  23902. #endif /* WOLFSSL_SP_NONBLOCK */
  23903. #endif /* HAVE_ECC_SIGN */
  23904. #ifndef WOLFSSL_SP_SMALL
  23905. static const char sp_256_tab32_9[32] = {
  23906. 1, 10, 2, 11, 14, 22, 3, 30,
  23907. 12, 15, 17, 19, 23, 26, 4, 31,
  23908. 9, 13, 21, 29, 16, 18, 25, 8,
  23909. 20, 28, 24, 7, 27, 6, 5, 32};
  23910. static int sp_256_num_bits_29_9(sp_digit v)
  23911. {
  23912. v |= v >> 1;
  23913. v |= v >> 2;
  23914. v |= v >> 4;
  23915. v |= v >> 8;
  23916. v |= v >> 16;
  23917. return sp_256_tab32_9[(uint32_t)(v*0x07C4ACDD) >> 27];
  23918. }
  23919. static int sp_256_num_bits_9(const sp_digit* a)
  23920. {
  23921. int i;
  23922. int r = 0;
  23923. for (i = 8; i >= 0; i--) {
  23924. if (a[i] != 0) {
  23925. r = sp_256_num_bits_29_9(a[i]);
  23926. r += i * 29;
  23927. break;
  23928. }
  23929. }
  23930. return r;
  23931. }
  23932. /* Non-constant time modular inversion.
  23933. *
  23934. * @param [out] r Resulting number.
  23935. * @param [in] a Number to invert.
  23936. * @param [in] m Modulus.
  23937. * @return MP_OKAY on success.
  23938. * @return MEMEORY_E when dynamic memory allocation fails.
  23939. */
  23940. static int sp_256_mod_inv_9(sp_digit* r, const sp_digit* a, const sp_digit* m)
  23941. {
  23942. int err = MP_OKAY;
  23943. #ifdef WOLFSSL_SP_SMALL_STACK
  23944. sp_digit* u = NULL;
  23945. #else
  23946. sp_digit u[9 * 4];
  23947. #endif
  23948. sp_digit* v = NULL;
  23949. sp_digit* b = NULL;
  23950. sp_digit* d = NULL;
  23951. int ut;
  23952. int vt;
  23953. #ifdef WOLFSSL_SP_SMALL_STACK
  23954. u = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 4, NULL,
  23955. DYNAMIC_TYPE_ECC);
  23956. if (u == NULL)
  23957. err = MEMORY_E;
  23958. #endif
  23959. if (err == MP_OKAY) {
  23960. v = u + 9;
  23961. b = u + 2 * 9;
  23962. d = u + 3 * 9;
  23963. XMEMCPY(u, m, sizeof(sp_digit) * 9);
  23964. XMEMCPY(v, a, sizeof(sp_digit) * 9);
  23965. ut = sp_256_num_bits_9(u);
  23966. vt = sp_256_num_bits_9(v);
  23967. XMEMSET(b, 0, sizeof(sp_digit) * 9);
  23968. if ((v[0] & 1) == 0) {
  23969. sp_256_rshift1_9(v, v);
  23970. XMEMCPY(d, m, sizeof(sp_digit) * 9);
  23971. d[0]++;
  23972. sp_256_rshift1_9(d, d);
  23973. vt--;
  23974. while ((v[0] & 1) == 0) {
  23975. sp_256_rshift1_9(v, v);
  23976. if (d[0] & 1)
  23977. sp_256_add_9(d, d, m);
  23978. sp_256_rshift1_9(d, d);
  23979. vt--;
  23980. }
  23981. }
  23982. else {
  23983. XMEMSET(d+1, 0, sizeof(sp_digit) * (9 - 1));
  23984. d[0] = 1;
  23985. }
  23986. while (ut > 1 && vt > 1) {
  23987. if ((ut > vt) || ((ut == vt) &&
  23988. (sp_256_cmp_9(u, v) >= 0))) {
  23989. sp_256_sub_9(u, u, v);
  23990. sp_256_norm_9(u);
  23991. sp_256_sub_9(b, b, d);
  23992. sp_256_norm_9(b);
  23993. if (b[8] < 0)
  23994. sp_256_add_9(b, b, m);
  23995. sp_256_norm_9(b);
  23996. ut = sp_256_num_bits_9(u);
  23997. do {
  23998. sp_256_rshift1_9(u, u);
  23999. if (b[0] & 1)
  24000. sp_256_add_9(b, b, m);
  24001. sp_256_rshift1_9(b, b);
  24002. ut--;
  24003. }
  24004. while (ut > 0 && (u[0] & 1) == 0);
  24005. }
  24006. else {
  24007. sp_256_sub_9(v, v, u);
  24008. sp_256_norm_9(v);
  24009. sp_256_sub_9(d, d, b);
  24010. sp_256_norm_9(d);
  24011. if (d[8] < 0)
  24012. sp_256_add_9(d, d, m);
  24013. sp_256_norm_9(d);
  24014. vt = sp_256_num_bits_9(v);
  24015. do {
  24016. sp_256_rshift1_9(v, v);
  24017. if (d[0] & 1)
  24018. sp_256_add_9(d, d, m);
  24019. sp_256_rshift1_9(d, d);
  24020. vt--;
  24021. }
  24022. while (vt > 0 && (v[0] & 1) == 0);
  24023. }
  24024. }
  24025. if (ut == 1)
  24026. XMEMCPY(r, b, sizeof(sp_digit) * 9);
  24027. else
  24028. XMEMCPY(r, d, sizeof(sp_digit) * 9);
  24029. }
  24030. #ifdef WOLFSSL_SP_SMALL_STACK
  24031. if (u != NULL)
  24032. XFREE(u, NULL, DYNAMIC_TYPE_ECC);
  24033. #endif
  24034. return err;
  24035. }
  24036. #endif /* WOLFSSL_SP_SMALL */
  24037. /* Add point p1 into point p2. Handles p1 == p2 and result at infinity.
  24038. *
  24039. * p1 First point to add and holds result.
  24040. * p2 Second point to add.
  24041. * tmp Temporary storage for intermediate numbers.
  24042. */
  24043. static void sp_256_add_points_9(sp_point_256* p1, const sp_point_256* p2,
  24044. sp_digit* tmp)
  24045. {
  24046. sp_256_proj_point_add_9(p1, p1, p2, tmp);
  24047. if (sp_256_iszero_9(p1->z)) {
  24048. if (sp_256_iszero_9(p1->x) && sp_256_iszero_9(p1->y)) {
  24049. sp_256_proj_point_dbl_9(p1, p2, tmp);
  24050. }
  24051. else {
  24052. /* Y ordinate is not used from here - don't set. */
  24053. p1->x[0] = 0;
  24054. p1->x[1] = 0;
  24055. p1->x[2] = 0;
  24056. p1->x[3] = 0;
  24057. p1->x[4] = 0;
  24058. p1->x[5] = 0;
  24059. p1->x[6] = 0;
  24060. p1->x[7] = 0;
  24061. p1->x[8] = 0;
  24062. XMEMCPY(p1->z, p256_norm_mod, sizeof(p256_norm_mod));
  24063. }
  24064. }
  24065. }
  24066. /* Calculate the verification point: [e/s]G + [r/s]Q
  24067. *
  24068. * p1 Calculated point.
  24069. * p2 Public point and temporary.
  24070. * s Second part of signature as a number.
  24071. * u1 Temporary number.
  24072. * u2 Temporary number.
  24073. * heap Heap to use for allocation.
  24074. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  24075. */
  24076. static int sp_256_calc_vfy_point_9(sp_point_256* p1, sp_point_256* p2,
  24077. sp_digit* s, sp_digit* u1, sp_digit* u2, sp_digit* tmp, void* heap)
  24078. {
  24079. int err;
  24080. #ifndef WOLFSSL_SP_SMALL
  24081. err = sp_256_mod_inv_9(s, s, p256_order);
  24082. if (err == MP_OKAY)
  24083. #endif /* !WOLFSSL_SP_SMALL */
  24084. {
  24085. sp_256_mul_9(s, s, p256_norm_order);
  24086. err = sp_256_mod_9(s, s, p256_order);
  24087. }
  24088. if (err == MP_OKAY) {
  24089. sp_256_norm_9(s);
  24090. #ifdef WOLFSSL_SP_SMALL
  24091. {
  24092. sp_256_mont_inv_order_9(s, s, tmp);
  24093. sp_256_mont_mul_order_9(u1, u1, s);
  24094. sp_256_mont_mul_order_9(u2, u2, s);
  24095. }
  24096. #else
  24097. {
  24098. sp_256_mont_mul_order_9(u1, u1, s);
  24099. sp_256_mont_mul_order_9(u2, u2, s);
  24100. }
  24101. #endif /* WOLFSSL_SP_SMALL */
  24102. {
  24103. err = sp_256_ecc_mulmod_base_9(p1, u1, 0, 0, heap);
  24104. }
  24105. }
  24106. if ((err == MP_OKAY) && sp_256_iszero_9(p1->z)) {
  24107. p1->infinity = 1;
  24108. }
  24109. if (err == MP_OKAY) {
  24110. err = sp_256_ecc_mulmod_9(p2, p2, u2, 0, 0, heap);
  24111. }
  24112. if ((err == MP_OKAY) && sp_256_iszero_9(p2->z)) {
  24113. p2->infinity = 1;
  24114. }
  24115. if (err == MP_OKAY) {
  24116. sp_256_add_points_9(p1, p2, tmp);
  24117. }
  24118. return err;
  24119. }
  24120. #ifdef HAVE_ECC_VERIFY
  24121. /* Verify the signature values with the hash and public key.
  24122. * e = Truncate(hash, 256)
  24123. * u1 = e/s mod order
  24124. * u2 = r/s mod order
  24125. * r == (u1.G + u2.Q)->x mod order
  24126. * Optimization: Leave point in projective form.
  24127. * (x, y, 1) == (x' / z'*z', y' / z'*z'*z', z' / z')
  24128. * (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x'
  24129. * The hash is truncated to the first 256 bits.
  24130. *
  24131. * hash Hash to sign.
  24132. * hashLen Length of the hash data.
  24133. * rng Random number generator.
  24134. * priv Private part of key - scalar.
  24135. * rm First part of result as an mp_int.
  24136. * sm Sirst part of result as an mp_int.
  24137. * heap Heap to use for allocation.
  24138. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  24139. */
  24140. int sp_ecc_verify_256(const byte* hash, word32 hashLen, const mp_int* pX,
  24141. const mp_int* pY, const mp_int* pZ, const mp_int* rm, const mp_int* sm,
  24142. int* res, void* heap)
  24143. {
  24144. #ifdef WOLFSSL_SP_SMALL_STACK
  24145. sp_digit* u1 = NULL;
  24146. sp_point_256* p1 = NULL;
  24147. #else
  24148. sp_digit u1[18 * 9];
  24149. sp_point_256 p1[2];
  24150. #endif
  24151. sp_digit* u2 = NULL;
  24152. sp_digit* s = NULL;
  24153. sp_digit* tmp = NULL;
  24154. sp_point_256* p2 = NULL;
  24155. sp_digit carry;
  24156. sp_int32 c = 0;
  24157. int err = MP_OKAY;
  24158. #ifdef WOLFSSL_SP_SMALL_STACK
  24159. if (err == MP_OKAY) {
  24160. p1 = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap,
  24161. DYNAMIC_TYPE_ECC);
  24162. if (p1 == NULL)
  24163. err = MEMORY_E;
  24164. }
  24165. if (err == MP_OKAY) {
  24166. u1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 18 * 9, heap,
  24167. DYNAMIC_TYPE_ECC);
  24168. if (u1 == NULL)
  24169. err = MEMORY_E;
  24170. }
  24171. #endif
  24172. if (err == MP_OKAY) {
  24173. u2 = u1 + 2 * 9;
  24174. s = u1 + 4 * 9;
  24175. tmp = u1 + 6 * 9;
  24176. p2 = p1 + 1;
  24177. if (hashLen > 32U) {
  24178. hashLen = 32U;
  24179. }
  24180. sp_256_from_bin(u1, 9, hash, (int)hashLen);
  24181. sp_256_from_mp(u2, 9, rm);
  24182. sp_256_from_mp(s, 9, sm);
  24183. sp_256_from_mp(p2->x, 9, pX);
  24184. sp_256_from_mp(p2->y, 9, pY);
  24185. sp_256_from_mp(p2->z, 9, pZ);
  24186. err = sp_256_calc_vfy_point_9(p1, p2, s, u1, u2, tmp, heap);
  24187. }
  24188. if (err == MP_OKAY) {
  24189. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  24190. /* Reload r and convert to Montgomery form. */
  24191. sp_256_from_mp(u2, 9, rm);
  24192. err = sp_256_mod_mul_norm_9(u2, u2, p256_mod);
  24193. }
  24194. if (err == MP_OKAY) {
  24195. /* u1 = r.z'.z' mod prime */
  24196. sp_256_mont_sqr_9(p1->z, p1->z, p256_mod, p256_mp_mod);
  24197. sp_256_mont_mul_9(u1, u2, p1->z, p256_mod, p256_mp_mod);
  24198. *res = (int)(sp_256_cmp_9(p1->x, u1) == 0);
  24199. if (*res == 0) {
  24200. /* Reload r and add order. */
  24201. sp_256_from_mp(u2, 9, rm);
  24202. carry = sp_256_add_9(u2, u2, p256_order);
  24203. /* Carry means result is greater than mod and is not valid. */
  24204. if (carry == 0) {
  24205. sp_256_norm_9(u2);
  24206. /* Compare with mod and if greater or equal then not valid. */
  24207. c = sp_256_cmp_9(u2, p256_mod);
  24208. }
  24209. }
  24210. if ((*res == 0) && (c < 0)) {
  24211. /* Convert to Montogomery form */
  24212. err = sp_256_mod_mul_norm_9(u2, u2, p256_mod);
  24213. if (err == MP_OKAY) {
  24214. /* u1 = (r + 1*order).z'.z' mod prime */
  24215. {
  24216. sp_256_mont_mul_9(u1, u2, p1->z, p256_mod, p256_mp_mod);
  24217. }
  24218. *res = (sp_256_cmp_9(p1->x, u1) == 0);
  24219. }
  24220. }
  24221. }
  24222. #ifdef WOLFSSL_SP_SMALL_STACK
  24223. if (u1 != NULL)
  24224. XFREE(u1, heap, DYNAMIC_TYPE_ECC);
  24225. if (p1 != NULL)
  24226. XFREE(p1, heap, DYNAMIC_TYPE_ECC);
  24227. #endif
  24228. return err;
  24229. }
  24230. #ifdef WOLFSSL_SP_NONBLOCK
  24231. typedef struct sp_ecc_verify_256_ctx {
  24232. int state;
  24233. union {
  24234. sp_256_ecc_mulmod_9_ctx mulmod_ctx;
  24235. sp_256_mont_inv_order_9_ctx mont_inv_order_ctx;
  24236. sp_256_proj_point_dbl_9_ctx dbl_ctx;
  24237. sp_256_proj_point_add_9_ctx add_ctx;
  24238. };
  24239. sp_digit u1[2*9];
  24240. sp_digit u2[2*9];
  24241. sp_digit s[2*9];
  24242. sp_digit tmp[2*9 * 6];
  24243. sp_point_256 p1;
  24244. sp_point_256 p2;
  24245. } sp_ecc_verify_256_ctx;
  24246. int sp_ecc_verify_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash,
  24247. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  24248. const mp_int* rm, const mp_int* sm, int* res, void* heap)
  24249. {
  24250. int err = FP_WOULDBLOCK;
  24251. sp_ecc_verify_256_ctx* ctx = (sp_ecc_verify_256_ctx*)sp_ctx->data;
  24252. typedef char ctx_size_test[sizeof(sp_ecc_verify_256_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  24253. (void)sizeof(ctx_size_test);
  24254. switch (ctx->state) {
  24255. case 0: /* INIT */
  24256. if (hashLen > 32U) {
  24257. hashLen = 32U;
  24258. }
  24259. sp_256_from_bin(ctx->u1, 9, hash, (int)hashLen);
  24260. sp_256_from_mp(ctx->u2, 9, rm);
  24261. sp_256_from_mp(ctx->s, 9, sm);
  24262. sp_256_from_mp(ctx->p2.x, 9, pX);
  24263. sp_256_from_mp(ctx->p2.y, 9, pY);
  24264. sp_256_from_mp(ctx->p2.z, 9, pZ);
  24265. ctx->state = 1;
  24266. break;
  24267. case 1: /* NORMS0 */
  24268. sp_256_mul_9(ctx->s, ctx->s, p256_norm_order);
  24269. err = sp_256_mod_9(ctx->s, ctx->s, p256_order);
  24270. if (err == MP_OKAY)
  24271. ctx->state = 2;
  24272. break;
  24273. case 2: /* NORMS1 */
  24274. sp_256_norm_9(ctx->s);
  24275. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  24276. ctx->state = 3;
  24277. break;
  24278. case 3: /* NORMS2 */
  24279. err = sp_256_mont_inv_order_9_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->s, ctx->s, ctx->tmp);
  24280. if (err == MP_OKAY) {
  24281. ctx->state = 4;
  24282. }
  24283. break;
  24284. case 4: /* NORMS3 */
  24285. sp_256_mont_mul_order_9(ctx->u1, ctx->u1, ctx->s);
  24286. ctx->state = 5;
  24287. break;
  24288. case 5: /* NORMS4 */
  24289. sp_256_mont_mul_order_9(ctx->u2, ctx->u2, ctx->s);
  24290. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  24291. ctx->state = 6;
  24292. break;
  24293. case 6: /* MULBASE */
  24294. err = sp_256_ecc_mulmod_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p1, &p256_base, ctx->u1, 0, 0, heap);
  24295. if (err == MP_OKAY) {
  24296. if (sp_256_iszero_9(ctx->p1.z)) {
  24297. ctx->p1.infinity = 1;
  24298. }
  24299. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  24300. ctx->state = 7;
  24301. }
  24302. break;
  24303. case 7: /* MULMOD */
  24304. err = sp_256_ecc_mulmod_9_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p2, &ctx->p2, ctx->u2, 0, 0, heap);
  24305. if (err == MP_OKAY) {
  24306. if (sp_256_iszero_9(ctx->p2.z)) {
  24307. ctx->p2.infinity = 1;
  24308. }
  24309. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  24310. ctx->state = 8;
  24311. }
  24312. break;
  24313. case 8: /* ADD */
  24314. err = sp_256_proj_point_add_9_nb((sp_ecc_ctx_t*)&ctx->add_ctx, &ctx->p1, &ctx->p1, &ctx->p2, ctx->tmp);
  24315. if (err == MP_OKAY)
  24316. ctx->state = 9;
  24317. break;
  24318. case 9: /* MONT */
  24319. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  24320. /* Reload r and convert to Montgomery form. */
  24321. sp_256_from_mp(ctx->u2, 9, rm);
  24322. err = sp_256_mod_mul_norm_9(ctx->u2, ctx->u2, p256_mod);
  24323. if (err == MP_OKAY)
  24324. ctx->state = 10;
  24325. break;
  24326. case 10: /* SQR */
  24327. /* u1 = r.z'.z' mod prime */
  24328. sp_256_mont_sqr_9(ctx->p1.z, ctx->p1.z, p256_mod, p256_mp_mod);
  24329. ctx->state = 11;
  24330. break;
  24331. case 11: /* MUL */
  24332. sp_256_mont_mul_9(ctx->u1, ctx->u2, ctx->p1.z, p256_mod, p256_mp_mod);
  24333. ctx->state = 12;
  24334. break;
  24335. case 12: /* RES */
  24336. {
  24337. sp_int32 c = 0;
  24338. err = MP_OKAY; /* math okay, now check result */
  24339. *res = (int)(sp_256_cmp_9(ctx->p1.x, ctx->u1) == 0);
  24340. if (*res == 0) {
  24341. sp_digit carry;
  24342. /* Reload r and add order. */
  24343. sp_256_from_mp(ctx->u2, 9, rm);
  24344. carry = sp_256_add_9(ctx->u2, ctx->u2, p256_order);
  24345. /* Carry means result is greater than mod and is not valid. */
  24346. if (carry == 0) {
  24347. sp_256_norm_9(ctx->u2);
  24348. /* Compare with mod and if greater or equal then not valid. */
  24349. c = sp_256_cmp_9(ctx->u2, p256_mod);
  24350. }
  24351. }
  24352. if ((*res == 0) && (c < 0)) {
  24353. /* Convert to Montogomery form */
  24354. err = sp_256_mod_mul_norm_9(ctx->u2, ctx->u2, p256_mod);
  24355. if (err == MP_OKAY) {
  24356. /* u1 = (r + 1*order).z'.z' mod prime */
  24357. sp_256_mont_mul_9(ctx->u1, ctx->u2, ctx->p1.z, p256_mod,
  24358. p256_mp_mod);
  24359. *res = (int)(sp_256_cmp_9(ctx->p1.x, ctx->u1) == 0);
  24360. }
  24361. }
  24362. break;
  24363. }
  24364. } /* switch */
  24365. if (err == MP_OKAY && ctx->state != 12) {
  24366. err = FP_WOULDBLOCK;
  24367. }
  24368. return err;
  24369. }
  24370. #endif /* WOLFSSL_SP_NONBLOCK */
  24371. #endif /* HAVE_ECC_VERIFY */
  24372. #ifdef HAVE_ECC_CHECK_KEY
  24373. /* Check that the x and y ordinates are a valid point on the curve.
  24374. *
  24375. * point EC point.
  24376. * heap Heap to use if dynamically allocating.
  24377. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  24378. * not on the curve and MP_OKAY otherwise.
  24379. */
  24380. static int sp_256_ecc_is_point_9(const sp_point_256* point,
  24381. void* heap)
  24382. {
  24383. #ifdef WOLFSSL_SP_SMALL_STACK
  24384. sp_digit* t1 = NULL;
  24385. #else
  24386. sp_digit t1[9 * 4];
  24387. #endif
  24388. sp_digit* t2 = NULL;
  24389. int err = MP_OKAY;
  24390. #ifdef WOLFSSL_SP_SMALL_STACK
  24391. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 4, heap, DYNAMIC_TYPE_ECC);
  24392. if (t1 == NULL)
  24393. err = MEMORY_E;
  24394. #endif
  24395. (void)heap;
  24396. if (err == MP_OKAY) {
  24397. t2 = t1 + 2 * 9;
  24398. /* y^2 - x^3 - a.x = b */
  24399. sp_256_sqr_9(t1, point->y);
  24400. (void)sp_256_mod_9(t1, t1, p256_mod);
  24401. sp_256_sqr_9(t2, point->x);
  24402. (void)sp_256_mod_9(t2, t2, p256_mod);
  24403. sp_256_mul_9(t2, t2, point->x);
  24404. (void)sp_256_mod_9(t2, t2, p256_mod);
  24405. sp_256_mont_sub_9(t1, t1, t2, p256_mod);
  24406. /* y^2 - x^3 + 3.x = b, when a = -3 */
  24407. sp_256_mont_add_9(t1, t1, point->x, p256_mod);
  24408. sp_256_mont_add_9(t1, t1, point->x, p256_mod);
  24409. sp_256_mont_add_9(t1, t1, point->x, p256_mod);
  24410. if (sp_256_cmp_9(t1, p256_b) != 0) {
  24411. err = MP_VAL;
  24412. }
  24413. }
  24414. #ifdef WOLFSSL_SP_SMALL_STACK
  24415. if (t1 != NULL)
  24416. XFREE(t1, heap, DYNAMIC_TYPE_ECC);
  24417. #endif
  24418. return err;
  24419. }
  24420. /* Check that the x and y ordinates are a valid point on the curve.
  24421. *
  24422. * pX X ordinate of EC point.
  24423. * pY Y ordinate of EC point.
  24424. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  24425. * not on the curve and MP_OKAY otherwise.
  24426. */
  24427. int sp_ecc_is_point_256(const mp_int* pX, const mp_int* pY)
  24428. {
  24429. #ifdef WOLFSSL_SP_SMALL_STACK
  24430. sp_point_256* pub = NULL;
  24431. #else
  24432. sp_point_256 pub[1];
  24433. #endif
  24434. const byte one[1] = { 1 };
  24435. int err = MP_OKAY;
  24436. #ifdef WOLFSSL_SP_SMALL_STACK
  24437. pub = (sp_point_256*)XMALLOC(sizeof(sp_point_256), NULL,
  24438. DYNAMIC_TYPE_ECC);
  24439. if (pub == NULL)
  24440. err = MEMORY_E;
  24441. #endif
  24442. if (err == MP_OKAY) {
  24443. sp_256_from_mp(pub->x, 9, pX);
  24444. sp_256_from_mp(pub->y, 9, pY);
  24445. sp_256_from_bin(pub->z, 9, one, (int)sizeof(one));
  24446. err = sp_256_ecc_is_point_9(pub, NULL);
  24447. }
  24448. #ifdef WOLFSSL_SP_SMALL_STACK
  24449. if (pub != NULL)
  24450. XFREE(pub, NULL, DYNAMIC_TYPE_ECC);
  24451. #endif
  24452. return err;
  24453. }
  24454. /* Check that the private scalar generates the EC point (px, py), the point is
  24455. * on the curve and the point has the correct order.
  24456. *
  24457. * pX X ordinate of EC point.
  24458. * pY Y ordinate of EC point.
  24459. * privm Private scalar that generates EC point.
  24460. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  24461. * not on the curve, ECC_INF_E if the point does not have the correct order,
  24462. * ECC_PRIV_KEY_E when the private scalar doesn't generate the EC point and
  24463. * MP_OKAY otherwise.
  24464. */
  24465. int sp_ecc_check_key_256(const mp_int* pX, const mp_int* pY,
  24466. const mp_int* privm, void* heap)
  24467. {
  24468. #ifdef WOLFSSL_SP_SMALL_STACK
  24469. sp_digit* priv = NULL;
  24470. sp_point_256* pub = NULL;
  24471. #else
  24472. sp_digit priv[9];
  24473. sp_point_256 pub[2];
  24474. #endif
  24475. sp_point_256* p = NULL;
  24476. const byte one[1] = { 1 };
  24477. int err = MP_OKAY;
  24478. /* Quick check the lengs of public key ordinates and private key are in
  24479. * range. Proper check later.
  24480. */
  24481. if (((mp_count_bits(pX) > 256) ||
  24482. (mp_count_bits(pY) > 256) ||
  24483. ((privm != NULL) && (mp_count_bits(privm) > 256)))) {
  24484. err = ECC_OUT_OF_RANGE_E;
  24485. }
  24486. #ifdef WOLFSSL_SP_SMALL_STACK
  24487. if (err == MP_OKAY) {
  24488. pub = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, heap,
  24489. DYNAMIC_TYPE_ECC);
  24490. if (pub == NULL)
  24491. err = MEMORY_E;
  24492. }
  24493. if (err == MP_OKAY && privm) {
  24494. priv = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9, heap,
  24495. DYNAMIC_TYPE_ECC);
  24496. if (priv == NULL)
  24497. err = MEMORY_E;
  24498. }
  24499. #endif
  24500. if (err == MP_OKAY) {
  24501. p = pub + 1;
  24502. sp_256_from_mp(pub->x, 9, pX);
  24503. sp_256_from_mp(pub->y, 9, pY);
  24504. sp_256_from_bin(pub->z, 9, one, (int)sizeof(one));
  24505. if (privm)
  24506. sp_256_from_mp(priv, 9, privm);
  24507. /* Check point at infinitiy. */
  24508. if ((sp_256_iszero_9(pub->x) != 0) &&
  24509. (sp_256_iszero_9(pub->y) != 0)) {
  24510. err = ECC_INF_E;
  24511. }
  24512. }
  24513. /* Check range of X and Y */
  24514. if ((err == MP_OKAY) &&
  24515. ((sp_256_cmp_9(pub->x, p256_mod) >= 0) ||
  24516. (sp_256_cmp_9(pub->y, p256_mod) >= 0))) {
  24517. err = ECC_OUT_OF_RANGE_E;
  24518. }
  24519. if (err == MP_OKAY) {
  24520. /* Check point is on curve */
  24521. err = sp_256_ecc_is_point_9(pub, heap);
  24522. }
  24523. if (err == MP_OKAY) {
  24524. /* Point * order = infinity */
  24525. err = sp_256_ecc_mulmod_9(p, pub, p256_order, 1, 1, heap);
  24526. }
  24527. /* Check result is infinity */
  24528. if ((err == MP_OKAY) && ((sp_256_iszero_9(p->x) == 0) ||
  24529. (sp_256_iszero_9(p->y) == 0))) {
  24530. err = ECC_INF_E;
  24531. }
  24532. if (privm) {
  24533. if (err == MP_OKAY) {
  24534. /* Base * private = point */
  24535. err = sp_256_ecc_mulmod_base_9(p, priv, 1, 1, heap);
  24536. }
  24537. /* Check result is public key */
  24538. if ((err == MP_OKAY) &&
  24539. ((sp_256_cmp_9(p->x, pub->x) != 0) ||
  24540. (sp_256_cmp_9(p->y, pub->y) != 0))) {
  24541. err = ECC_PRIV_KEY_E;
  24542. }
  24543. }
  24544. #ifdef WOLFSSL_SP_SMALL_STACK
  24545. if (pub != NULL)
  24546. XFREE(pub, heap, DYNAMIC_TYPE_ECC);
  24547. if (priv != NULL)
  24548. XFREE(priv, heap, DYNAMIC_TYPE_ECC);
  24549. #endif
  24550. return err;
  24551. }
  24552. #endif
  24553. #ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
  24554. /* Add two projective EC points together.
  24555. * (pX, pY, pZ) + (qX, qY, qZ) = (rX, rY, rZ)
  24556. *
  24557. * pX First EC point's X ordinate.
  24558. * pY First EC point's Y ordinate.
  24559. * pZ First EC point's Z ordinate.
  24560. * qX Second EC point's X ordinate.
  24561. * qY Second EC point's Y ordinate.
  24562. * qZ Second EC point's Z ordinate.
  24563. * rX Resultant EC point's X ordinate.
  24564. * rY Resultant EC point's Y ordinate.
  24565. * rZ Resultant EC point's Z ordinate.
  24566. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  24567. */
  24568. int sp_ecc_proj_add_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  24569. mp_int* qX, mp_int* qY, mp_int* qZ,
  24570. mp_int* rX, mp_int* rY, mp_int* rZ)
  24571. {
  24572. #ifdef WOLFSSL_SP_SMALL_STACK
  24573. sp_digit* tmp = NULL;
  24574. sp_point_256* p = NULL;
  24575. #else
  24576. sp_digit tmp[2 * 9 * 6];
  24577. sp_point_256 p[2];
  24578. #endif
  24579. sp_point_256* q = NULL;
  24580. int err = MP_OKAY;
  24581. #ifdef WOLFSSL_SP_SMALL_STACK
  24582. if (err == MP_OKAY) {
  24583. p = (sp_point_256*)XMALLOC(sizeof(sp_point_256) * 2, NULL,
  24584. DYNAMIC_TYPE_ECC);
  24585. if (p == NULL)
  24586. err = MEMORY_E;
  24587. }
  24588. if (err == MP_OKAY) {
  24589. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 6, NULL,
  24590. DYNAMIC_TYPE_ECC);
  24591. if (tmp == NULL) {
  24592. err = MEMORY_E;
  24593. }
  24594. }
  24595. #endif
  24596. if (err == MP_OKAY) {
  24597. q = p + 1;
  24598. sp_256_from_mp(p->x, 9, pX);
  24599. sp_256_from_mp(p->y, 9, pY);
  24600. sp_256_from_mp(p->z, 9, pZ);
  24601. sp_256_from_mp(q->x, 9, qX);
  24602. sp_256_from_mp(q->y, 9, qY);
  24603. sp_256_from_mp(q->z, 9, qZ);
  24604. p->infinity = sp_256_iszero_9(p->x) &
  24605. sp_256_iszero_9(p->y);
  24606. q->infinity = sp_256_iszero_9(q->x) &
  24607. sp_256_iszero_9(q->y);
  24608. sp_256_proj_point_add_9(p, p, q, tmp);
  24609. }
  24610. if (err == MP_OKAY) {
  24611. err = sp_256_to_mp(p->x, rX);
  24612. }
  24613. if (err == MP_OKAY) {
  24614. err = sp_256_to_mp(p->y, rY);
  24615. }
  24616. if (err == MP_OKAY) {
  24617. err = sp_256_to_mp(p->z, rZ);
  24618. }
  24619. #ifdef WOLFSSL_SP_SMALL_STACK
  24620. if (tmp != NULL)
  24621. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  24622. if (p != NULL)
  24623. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  24624. #endif
  24625. return err;
  24626. }
  24627. /* Double a projective EC point.
  24628. * (pX, pY, pZ) + (pX, pY, pZ) = (rX, rY, rZ)
  24629. *
  24630. * pX EC point's X ordinate.
  24631. * pY EC point's Y ordinate.
  24632. * pZ EC point's Z ordinate.
  24633. * rX Resultant EC point's X ordinate.
  24634. * rY Resultant EC point's Y ordinate.
  24635. * rZ Resultant EC point's Z ordinate.
  24636. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  24637. */
  24638. int sp_ecc_proj_dbl_point_256(mp_int* pX, mp_int* pY, mp_int* pZ,
  24639. mp_int* rX, mp_int* rY, mp_int* rZ)
  24640. {
  24641. #ifdef WOLFSSL_SP_SMALL_STACK
  24642. sp_digit* tmp = NULL;
  24643. sp_point_256* p = NULL;
  24644. #else
  24645. sp_digit tmp[2 * 9 * 2];
  24646. sp_point_256 p[1];
  24647. #endif
  24648. int err = MP_OKAY;
  24649. #ifdef WOLFSSL_SP_SMALL_STACK
  24650. if (err == MP_OKAY) {
  24651. p = (sp_point_256*)XMALLOC(sizeof(sp_point_256), NULL,
  24652. DYNAMIC_TYPE_ECC);
  24653. if (p == NULL)
  24654. err = MEMORY_E;
  24655. }
  24656. if (err == MP_OKAY) {
  24657. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 2, NULL,
  24658. DYNAMIC_TYPE_ECC);
  24659. if (tmp == NULL)
  24660. err = MEMORY_E;
  24661. }
  24662. #endif
  24663. if (err == MP_OKAY) {
  24664. sp_256_from_mp(p->x, 9, pX);
  24665. sp_256_from_mp(p->y, 9, pY);
  24666. sp_256_from_mp(p->z, 9, pZ);
  24667. p->infinity = sp_256_iszero_9(p->x) &
  24668. sp_256_iszero_9(p->y);
  24669. sp_256_proj_point_dbl_9(p, p, tmp);
  24670. }
  24671. if (err == MP_OKAY) {
  24672. err = sp_256_to_mp(p->x, rX);
  24673. }
  24674. if (err == MP_OKAY) {
  24675. err = sp_256_to_mp(p->y, rY);
  24676. }
  24677. if (err == MP_OKAY) {
  24678. err = sp_256_to_mp(p->z, rZ);
  24679. }
  24680. #ifdef WOLFSSL_SP_SMALL_STACK
  24681. if (tmp != NULL)
  24682. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  24683. if (p != NULL)
  24684. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  24685. #endif
  24686. return err;
  24687. }
  24688. /* Map a projective EC point to affine in place.
  24689. * pZ will be one.
  24690. *
  24691. * pX EC point's X ordinate.
  24692. * pY EC point's Y ordinate.
  24693. * pZ EC point's Z ordinate.
  24694. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  24695. */
  24696. int sp_ecc_map_256(mp_int* pX, mp_int* pY, mp_int* pZ)
  24697. {
  24698. #ifdef WOLFSSL_SP_SMALL_STACK
  24699. sp_digit* tmp = NULL;
  24700. sp_point_256* p = NULL;
  24701. #else
  24702. sp_digit tmp[2 * 9 * 4];
  24703. sp_point_256 p[1];
  24704. #endif
  24705. int err = MP_OKAY;
  24706. #ifdef WOLFSSL_SP_SMALL_STACK
  24707. if (err == MP_OKAY) {
  24708. p = (sp_point_256*)XMALLOC(sizeof(sp_point_256), NULL,
  24709. DYNAMIC_TYPE_ECC);
  24710. if (p == NULL)
  24711. err = MEMORY_E;
  24712. }
  24713. if (err == MP_OKAY) {
  24714. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 9 * 4, NULL,
  24715. DYNAMIC_TYPE_ECC);
  24716. if (tmp == NULL)
  24717. err = MEMORY_E;
  24718. }
  24719. #endif
  24720. if (err == MP_OKAY) {
  24721. sp_256_from_mp(p->x, 9, pX);
  24722. sp_256_from_mp(p->y, 9, pY);
  24723. sp_256_from_mp(p->z, 9, pZ);
  24724. p->infinity = sp_256_iszero_9(p->x) &
  24725. sp_256_iszero_9(p->y);
  24726. sp_256_map_9(p, p, tmp);
  24727. }
  24728. if (err == MP_OKAY) {
  24729. err = sp_256_to_mp(p->x, pX);
  24730. }
  24731. if (err == MP_OKAY) {
  24732. err = sp_256_to_mp(p->y, pY);
  24733. }
  24734. if (err == MP_OKAY) {
  24735. err = sp_256_to_mp(p->z, pZ);
  24736. }
  24737. #ifdef WOLFSSL_SP_SMALL_STACK
  24738. if (tmp != NULL)
  24739. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  24740. if (p != NULL)
  24741. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  24742. #endif
  24743. return err;
  24744. }
  24745. #endif /* WOLFSSL_PUBLIC_ECC_ADD_DBL */
  24746. #ifdef HAVE_COMP_KEY
  24747. /* Find the square root of a number mod the prime of the curve.
  24748. *
  24749. * y The number to operate on and the result.
  24750. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  24751. */
  24752. static int sp_256_mont_sqrt_9(sp_digit* y)
  24753. {
  24754. #ifdef WOLFSSL_SP_SMALL_STACK
  24755. sp_digit* t1 = NULL;
  24756. #else
  24757. sp_digit t1[4 * 9];
  24758. #endif
  24759. sp_digit* t2 = NULL;
  24760. int err = MP_OKAY;
  24761. #ifdef WOLFSSL_SP_SMALL_STACK
  24762. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 4 * 9, NULL, DYNAMIC_TYPE_ECC);
  24763. if (t1 == NULL) {
  24764. err = MEMORY_E;
  24765. }
  24766. #endif
  24767. if (err == MP_OKAY) {
  24768. t2 = t1 + 2 * 9;
  24769. {
  24770. /* t2 = y ^ 0x2 */
  24771. sp_256_mont_sqr_9(t2, y, p256_mod, p256_mp_mod);
  24772. /* t1 = y ^ 0x3 */
  24773. sp_256_mont_mul_9(t1, t2, y, p256_mod, p256_mp_mod);
  24774. /* t2 = y ^ 0xc */
  24775. sp_256_mont_sqr_n_9(t2, t1, 2, p256_mod, p256_mp_mod);
  24776. /* t1 = y ^ 0xf */
  24777. sp_256_mont_mul_9(t1, t1, t2, p256_mod, p256_mp_mod);
  24778. /* t2 = y ^ 0xf0 */
  24779. sp_256_mont_sqr_n_9(t2, t1, 4, p256_mod, p256_mp_mod);
  24780. /* t1 = y ^ 0xff */
  24781. sp_256_mont_mul_9(t1, t1, t2, p256_mod, p256_mp_mod);
  24782. /* t2 = y ^ 0xff00 */
  24783. sp_256_mont_sqr_n_9(t2, t1, 8, p256_mod, p256_mp_mod);
  24784. /* t1 = y ^ 0xffff */
  24785. sp_256_mont_mul_9(t1, t1, t2, p256_mod, p256_mp_mod);
  24786. /* t2 = y ^ 0xffff0000 */
  24787. sp_256_mont_sqr_n_9(t2, t1, 16, p256_mod, p256_mp_mod);
  24788. /* t1 = y ^ 0xffffffff */
  24789. sp_256_mont_mul_9(t1, t1, t2, p256_mod, p256_mp_mod);
  24790. /* t1 = y ^ 0xffffffff00000000 */
  24791. sp_256_mont_sqr_n_9(t1, t1, 32, p256_mod, p256_mp_mod);
  24792. /* t1 = y ^ 0xffffffff00000001 */
  24793. sp_256_mont_mul_9(t1, t1, y, p256_mod, p256_mp_mod);
  24794. /* t1 = y ^ 0xffffffff00000001000000000000000000000000 */
  24795. sp_256_mont_sqr_n_9(t1, t1, 96, p256_mod, p256_mp_mod);
  24796. /* t1 = y ^ 0xffffffff00000001000000000000000000000001 */
  24797. sp_256_mont_mul_9(t1, t1, y, p256_mod, p256_mp_mod);
  24798. sp_256_mont_sqr_n_9(y, t1, 94, p256_mod, p256_mp_mod);
  24799. }
  24800. }
  24801. #ifdef WOLFSSL_SP_SMALL_STACK
  24802. if (t1 != NULL)
  24803. XFREE(t1, NULL, DYNAMIC_TYPE_ECC);
  24804. #endif
  24805. return err;
  24806. }
  24807. /* Uncompress the point given the X ordinate.
  24808. *
  24809. * xm X ordinate.
  24810. * odd Whether the Y ordinate is odd.
  24811. * ym Calculated Y ordinate.
  24812. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  24813. */
  24814. int sp_ecc_uncompress_256(mp_int* xm, int odd, mp_int* ym)
  24815. {
  24816. #ifdef WOLFSSL_SP_SMALL_STACK
  24817. sp_digit* x = NULL;
  24818. #else
  24819. sp_digit x[4 * 9];
  24820. #endif
  24821. sp_digit* y = NULL;
  24822. int err = MP_OKAY;
  24823. #ifdef WOLFSSL_SP_SMALL_STACK
  24824. x = (sp_digit*)XMALLOC(sizeof(sp_digit) * 4 * 9, NULL, DYNAMIC_TYPE_ECC);
  24825. if (x == NULL)
  24826. err = MEMORY_E;
  24827. #endif
  24828. if (err == MP_OKAY) {
  24829. y = x + 2 * 9;
  24830. sp_256_from_mp(x, 9, xm);
  24831. err = sp_256_mod_mul_norm_9(x, x, p256_mod);
  24832. }
  24833. if (err == MP_OKAY) {
  24834. /* y = x^3 */
  24835. {
  24836. sp_256_mont_sqr_9(y, x, p256_mod, p256_mp_mod);
  24837. sp_256_mont_mul_9(y, y, x, p256_mod, p256_mp_mod);
  24838. }
  24839. /* y = x^3 - 3x */
  24840. sp_256_mont_sub_9(y, y, x, p256_mod);
  24841. sp_256_mont_sub_9(y, y, x, p256_mod);
  24842. sp_256_mont_sub_9(y, y, x, p256_mod);
  24843. /* y = x^3 - 3x + b */
  24844. err = sp_256_mod_mul_norm_9(x, p256_b, p256_mod);
  24845. }
  24846. if (err == MP_OKAY) {
  24847. sp_256_mont_add_9(y, y, x, p256_mod);
  24848. /* y = sqrt(x^3 - 3x + b) */
  24849. err = sp_256_mont_sqrt_9(y);
  24850. }
  24851. if (err == MP_OKAY) {
  24852. XMEMSET(y + 9, 0, 9U * sizeof(sp_digit));
  24853. sp_256_mont_reduce_9(y, p256_mod, p256_mp_mod);
  24854. if ((((word32)y[0] ^ (word32)odd) & 1U) != 0U) {
  24855. sp_256_mont_sub_9(y, p256_mod, y, p256_mod);
  24856. }
  24857. err = sp_256_to_mp(y, ym);
  24858. }
  24859. #ifdef WOLFSSL_SP_SMALL_STACK
  24860. if (x != NULL)
  24861. XFREE(x, NULL, DYNAMIC_TYPE_ECC);
  24862. #endif
  24863. return err;
  24864. }
  24865. #endif
  24866. #endif /* !WOLFSSL_SP_NO_256 */
  24867. #ifdef WOLFSSL_SP_384
  24868. /* Point structure to use. */
  24869. typedef struct sp_point_384 {
  24870. /* X ordinate of point. */
  24871. sp_digit x[2 * 15];
  24872. /* Y ordinate of point. */
  24873. sp_digit y[2 * 15];
  24874. /* Z ordinate of point. */
  24875. sp_digit z[2 * 15];
  24876. /* Indicates point is at infinity. */
  24877. int infinity;
  24878. } sp_point_384;
  24879. /* The modulus (prime) of the curve P384. */
  24880. static const sp_digit p384_mod[15] = {
  24881. 0x3ffffff,0x000003f,0x0000000,0x3fc0000,0x2ffffff,0x3ffffff,0x3ffffff,
  24882. 0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,
  24883. 0x00fffff
  24884. };
  24885. /* The Montgomery normalizer for modulus of the curve P384. */
  24886. static const sp_digit p384_norm_mod[15] = {
  24887. 0x0000001,0x3ffffc0,0x3ffffff,0x003ffff,0x1000000,0x0000000,0x0000000,
  24888. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  24889. 0x0000000
  24890. };
  24891. /* The Montgomery multiplier for modulus of the curve P384. */
  24892. static sp_digit p384_mp_mod = 0x000001;
  24893. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  24894. defined(HAVE_ECC_VERIFY)
  24895. /* The order of the curve P384. */
  24896. static const sp_digit p384_order[15] = {
  24897. 0x0c52973,0x3065ab3,0x277aece,0x2c922c2,0x3581a0d,0x10dcb77,0x234d81f,
  24898. 0x3ffff1d,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,
  24899. 0x00fffff
  24900. };
  24901. #endif
  24902. /* The order of the curve P384 minus 2. */
  24903. static const sp_digit p384_order2[15] = {
  24904. 0x0c52971,0x3065ab3,0x277aece,0x2c922c2,0x3581a0d,0x10dcb77,0x234d81f,
  24905. 0x3ffff1d,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,0x3ffffff,
  24906. 0x00fffff
  24907. };
  24908. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  24909. /* The Montgomery normalizer for order of the curve P384. */
  24910. static const sp_digit p384_norm_order[15] = {
  24911. 0x33ad68d,0x0f9a54c,0x1885131,0x136dd3d,0x0a7e5f2,0x2f23488,0x1cb27e0,
  24912. 0x00000e2,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  24913. 0x0000000
  24914. };
  24915. #endif
  24916. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  24917. /* The Montgomery multiplier for order of the curve P384. */
  24918. static sp_digit p384_mp_order = 0x8fdc45;
  24919. #endif
  24920. /* The base point of curve P384. */
  24921. static const sp_point_384 p384_base = {
  24922. /* X ordinate */
  24923. {
  24924. 0x2760ab7,0x1178e1c,0x296c3a5,0x176fd54,0x05502f2,0x0950a8e,0x3741e08,
  24925. 0x26e6167,0x3628ba7,0x11b874e,0x3320ad7,0x2c71c7b,0x305378e,0x288afa2,
  24926. 0x00aa87c,
  24927. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24928. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24929. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  24930. },
  24931. /* Y ordinate */
  24932. {
  24933. 0x0ea0e5f,0x0c75f24,0x019d7a4,0x33875fa,0x00a60b1,0x17c2e30,0x1a3113b,
  24934. 0x051f3a7,0x1bd289a,0x27e3d07,0x1292dc2,0x27a62fe,0x22c6f5d,0x392a589,
  24935. 0x003617d,
  24936. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24937. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24938. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  24939. },
  24940. /* Z ordinate */
  24941. {
  24942. 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  24943. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  24944. 0x0000000,
  24945. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24946. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  24947. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
  24948. },
  24949. /* infinity */
  24950. 0
  24951. };
  24952. #if defined(HAVE_ECC_CHECK_KEY) || defined(HAVE_COMP_KEY)
  24953. static const sp_digit p384_b[15] = {
  24954. 0x3ec2aef,0x1723b74,0x119d2a8,0x23628bb,0x2c65639,0x004e1d6,0x14088f5,
  24955. 0x104480c,0x06efe81,0x2460767,0x23f82d1,0x23815af,0x2e7e498,0x3e9f88f,
  24956. 0x00b3312
  24957. };
  24958. #endif
  24959. #ifdef WOLFSSL_SP_SMALL
  24960. /* Multiply a and b into r. (r = a * b)
  24961. *
  24962. * r A single precision integer.
  24963. * a A single precision integer.
  24964. * b A single precision integer.
  24965. */
  24966. SP_NOINLINE static void sp_384_mul_15(sp_digit* r, const sp_digit* a,
  24967. const sp_digit* b)
  24968. {
  24969. int i;
  24970. int imax;
  24971. int k;
  24972. sp_uint64 c;
  24973. sp_uint64 lo;
  24974. c = ((sp_uint64)a[14]) * b[14];
  24975. r[29] = (sp_digit)(c >> 26);
  24976. c &= 0x3ffffff;
  24977. for (k = 27; k >= 0; k--) {
  24978. if (k >= 15) {
  24979. i = k - 14;
  24980. imax = 14;
  24981. }
  24982. else {
  24983. i = 0;
  24984. imax = k;
  24985. }
  24986. lo = 0;
  24987. for (; i <= imax; i++) {
  24988. lo += ((sp_uint64)a[i]) * b[k - i];
  24989. }
  24990. c += lo >> 26;
  24991. r[k + 2] += (sp_digit)(c >> 26);
  24992. r[k + 1] = (sp_digit)(c & 0x3ffffff);
  24993. c = lo & 0x3ffffff;
  24994. }
  24995. r[0] = (sp_digit)c;
  24996. }
  24997. #else
  24998. /* Multiply a and b into r. (r = a * b)
  24999. *
  25000. * r A single precision integer.
  25001. * a A single precision integer.
  25002. * b A single precision integer.
  25003. */
  25004. SP_NOINLINE static void sp_384_mul_15(sp_digit* r, const sp_digit* a,
  25005. const sp_digit* b)
  25006. {
  25007. sp_int64 t0;
  25008. sp_int64 t1;
  25009. sp_digit t[15];
  25010. t0 = ((sp_int64)a[ 0]) * b[ 0];
  25011. t1 = ((sp_int64)a[ 0]) * b[ 1]
  25012. + ((sp_int64)a[ 1]) * b[ 0];
  25013. t[ 0] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25014. t0 = ((sp_int64)a[ 0]) * b[ 2]
  25015. + ((sp_int64)a[ 1]) * b[ 1]
  25016. + ((sp_int64)a[ 2]) * b[ 0];
  25017. t[ 1] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25018. t1 = ((sp_int64)a[ 0]) * b[ 3]
  25019. + ((sp_int64)a[ 1]) * b[ 2]
  25020. + ((sp_int64)a[ 2]) * b[ 1]
  25021. + ((sp_int64)a[ 3]) * b[ 0];
  25022. t[ 2] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25023. t0 = ((sp_int64)a[ 0]) * b[ 4]
  25024. + ((sp_int64)a[ 1]) * b[ 3]
  25025. + ((sp_int64)a[ 2]) * b[ 2]
  25026. + ((sp_int64)a[ 3]) * b[ 1]
  25027. + ((sp_int64)a[ 4]) * b[ 0];
  25028. t[ 3] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25029. t1 = ((sp_int64)a[ 0]) * b[ 5]
  25030. + ((sp_int64)a[ 1]) * b[ 4]
  25031. + ((sp_int64)a[ 2]) * b[ 3]
  25032. + ((sp_int64)a[ 3]) * b[ 2]
  25033. + ((sp_int64)a[ 4]) * b[ 1]
  25034. + ((sp_int64)a[ 5]) * b[ 0];
  25035. t[ 4] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25036. t0 = ((sp_int64)a[ 0]) * b[ 6]
  25037. + ((sp_int64)a[ 1]) * b[ 5]
  25038. + ((sp_int64)a[ 2]) * b[ 4]
  25039. + ((sp_int64)a[ 3]) * b[ 3]
  25040. + ((sp_int64)a[ 4]) * b[ 2]
  25041. + ((sp_int64)a[ 5]) * b[ 1]
  25042. + ((sp_int64)a[ 6]) * b[ 0];
  25043. t[ 5] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25044. t1 = ((sp_int64)a[ 0]) * b[ 7]
  25045. + ((sp_int64)a[ 1]) * b[ 6]
  25046. + ((sp_int64)a[ 2]) * b[ 5]
  25047. + ((sp_int64)a[ 3]) * b[ 4]
  25048. + ((sp_int64)a[ 4]) * b[ 3]
  25049. + ((sp_int64)a[ 5]) * b[ 2]
  25050. + ((sp_int64)a[ 6]) * b[ 1]
  25051. + ((sp_int64)a[ 7]) * b[ 0];
  25052. t[ 6] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25053. t0 = ((sp_int64)a[ 0]) * b[ 8]
  25054. + ((sp_int64)a[ 1]) * b[ 7]
  25055. + ((sp_int64)a[ 2]) * b[ 6]
  25056. + ((sp_int64)a[ 3]) * b[ 5]
  25057. + ((sp_int64)a[ 4]) * b[ 4]
  25058. + ((sp_int64)a[ 5]) * b[ 3]
  25059. + ((sp_int64)a[ 6]) * b[ 2]
  25060. + ((sp_int64)a[ 7]) * b[ 1]
  25061. + ((sp_int64)a[ 8]) * b[ 0];
  25062. t[ 7] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25063. t1 = ((sp_int64)a[ 0]) * b[ 9]
  25064. + ((sp_int64)a[ 1]) * b[ 8]
  25065. + ((sp_int64)a[ 2]) * b[ 7]
  25066. + ((sp_int64)a[ 3]) * b[ 6]
  25067. + ((sp_int64)a[ 4]) * b[ 5]
  25068. + ((sp_int64)a[ 5]) * b[ 4]
  25069. + ((sp_int64)a[ 6]) * b[ 3]
  25070. + ((sp_int64)a[ 7]) * b[ 2]
  25071. + ((sp_int64)a[ 8]) * b[ 1]
  25072. + ((sp_int64)a[ 9]) * b[ 0];
  25073. t[ 8] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25074. t0 = ((sp_int64)a[ 0]) * b[10]
  25075. + ((sp_int64)a[ 1]) * b[ 9]
  25076. + ((sp_int64)a[ 2]) * b[ 8]
  25077. + ((sp_int64)a[ 3]) * b[ 7]
  25078. + ((sp_int64)a[ 4]) * b[ 6]
  25079. + ((sp_int64)a[ 5]) * b[ 5]
  25080. + ((sp_int64)a[ 6]) * b[ 4]
  25081. + ((sp_int64)a[ 7]) * b[ 3]
  25082. + ((sp_int64)a[ 8]) * b[ 2]
  25083. + ((sp_int64)a[ 9]) * b[ 1]
  25084. + ((sp_int64)a[10]) * b[ 0];
  25085. t[ 9] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25086. t1 = ((sp_int64)a[ 0]) * b[11]
  25087. + ((sp_int64)a[ 1]) * b[10]
  25088. + ((sp_int64)a[ 2]) * b[ 9]
  25089. + ((sp_int64)a[ 3]) * b[ 8]
  25090. + ((sp_int64)a[ 4]) * b[ 7]
  25091. + ((sp_int64)a[ 5]) * b[ 6]
  25092. + ((sp_int64)a[ 6]) * b[ 5]
  25093. + ((sp_int64)a[ 7]) * b[ 4]
  25094. + ((sp_int64)a[ 8]) * b[ 3]
  25095. + ((sp_int64)a[ 9]) * b[ 2]
  25096. + ((sp_int64)a[10]) * b[ 1]
  25097. + ((sp_int64)a[11]) * b[ 0];
  25098. t[10] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25099. t0 = ((sp_int64)a[ 0]) * b[12]
  25100. + ((sp_int64)a[ 1]) * b[11]
  25101. + ((sp_int64)a[ 2]) * b[10]
  25102. + ((sp_int64)a[ 3]) * b[ 9]
  25103. + ((sp_int64)a[ 4]) * b[ 8]
  25104. + ((sp_int64)a[ 5]) * b[ 7]
  25105. + ((sp_int64)a[ 6]) * b[ 6]
  25106. + ((sp_int64)a[ 7]) * b[ 5]
  25107. + ((sp_int64)a[ 8]) * b[ 4]
  25108. + ((sp_int64)a[ 9]) * b[ 3]
  25109. + ((sp_int64)a[10]) * b[ 2]
  25110. + ((sp_int64)a[11]) * b[ 1]
  25111. + ((sp_int64)a[12]) * b[ 0];
  25112. t[11] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25113. t1 = ((sp_int64)a[ 0]) * b[13]
  25114. + ((sp_int64)a[ 1]) * b[12]
  25115. + ((sp_int64)a[ 2]) * b[11]
  25116. + ((sp_int64)a[ 3]) * b[10]
  25117. + ((sp_int64)a[ 4]) * b[ 9]
  25118. + ((sp_int64)a[ 5]) * b[ 8]
  25119. + ((sp_int64)a[ 6]) * b[ 7]
  25120. + ((sp_int64)a[ 7]) * b[ 6]
  25121. + ((sp_int64)a[ 8]) * b[ 5]
  25122. + ((sp_int64)a[ 9]) * b[ 4]
  25123. + ((sp_int64)a[10]) * b[ 3]
  25124. + ((sp_int64)a[11]) * b[ 2]
  25125. + ((sp_int64)a[12]) * b[ 1]
  25126. + ((sp_int64)a[13]) * b[ 0];
  25127. t[12] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25128. t0 = ((sp_int64)a[ 0]) * b[14]
  25129. + ((sp_int64)a[ 1]) * b[13]
  25130. + ((sp_int64)a[ 2]) * b[12]
  25131. + ((sp_int64)a[ 3]) * b[11]
  25132. + ((sp_int64)a[ 4]) * b[10]
  25133. + ((sp_int64)a[ 5]) * b[ 9]
  25134. + ((sp_int64)a[ 6]) * b[ 8]
  25135. + ((sp_int64)a[ 7]) * b[ 7]
  25136. + ((sp_int64)a[ 8]) * b[ 6]
  25137. + ((sp_int64)a[ 9]) * b[ 5]
  25138. + ((sp_int64)a[10]) * b[ 4]
  25139. + ((sp_int64)a[11]) * b[ 3]
  25140. + ((sp_int64)a[12]) * b[ 2]
  25141. + ((sp_int64)a[13]) * b[ 1]
  25142. + ((sp_int64)a[14]) * b[ 0];
  25143. t[13] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25144. t1 = ((sp_int64)a[ 1]) * b[14]
  25145. + ((sp_int64)a[ 2]) * b[13]
  25146. + ((sp_int64)a[ 3]) * b[12]
  25147. + ((sp_int64)a[ 4]) * b[11]
  25148. + ((sp_int64)a[ 5]) * b[10]
  25149. + ((sp_int64)a[ 6]) * b[ 9]
  25150. + ((sp_int64)a[ 7]) * b[ 8]
  25151. + ((sp_int64)a[ 8]) * b[ 7]
  25152. + ((sp_int64)a[ 9]) * b[ 6]
  25153. + ((sp_int64)a[10]) * b[ 5]
  25154. + ((sp_int64)a[11]) * b[ 4]
  25155. + ((sp_int64)a[12]) * b[ 3]
  25156. + ((sp_int64)a[13]) * b[ 2]
  25157. + ((sp_int64)a[14]) * b[ 1];
  25158. t[14] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25159. t0 = ((sp_int64)a[ 2]) * b[14]
  25160. + ((sp_int64)a[ 3]) * b[13]
  25161. + ((sp_int64)a[ 4]) * b[12]
  25162. + ((sp_int64)a[ 5]) * b[11]
  25163. + ((sp_int64)a[ 6]) * b[10]
  25164. + ((sp_int64)a[ 7]) * b[ 9]
  25165. + ((sp_int64)a[ 8]) * b[ 8]
  25166. + ((sp_int64)a[ 9]) * b[ 7]
  25167. + ((sp_int64)a[10]) * b[ 6]
  25168. + ((sp_int64)a[11]) * b[ 5]
  25169. + ((sp_int64)a[12]) * b[ 4]
  25170. + ((sp_int64)a[13]) * b[ 3]
  25171. + ((sp_int64)a[14]) * b[ 2];
  25172. r[15] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25173. t1 = ((sp_int64)a[ 3]) * b[14]
  25174. + ((sp_int64)a[ 4]) * b[13]
  25175. + ((sp_int64)a[ 5]) * b[12]
  25176. + ((sp_int64)a[ 6]) * b[11]
  25177. + ((sp_int64)a[ 7]) * b[10]
  25178. + ((sp_int64)a[ 8]) * b[ 9]
  25179. + ((sp_int64)a[ 9]) * b[ 8]
  25180. + ((sp_int64)a[10]) * b[ 7]
  25181. + ((sp_int64)a[11]) * b[ 6]
  25182. + ((sp_int64)a[12]) * b[ 5]
  25183. + ((sp_int64)a[13]) * b[ 4]
  25184. + ((sp_int64)a[14]) * b[ 3];
  25185. r[16] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25186. t0 = ((sp_int64)a[ 4]) * b[14]
  25187. + ((sp_int64)a[ 5]) * b[13]
  25188. + ((sp_int64)a[ 6]) * b[12]
  25189. + ((sp_int64)a[ 7]) * b[11]
  25190. + ((sp_int64)a[ 8]) * b[10]
  25191. + ((sp_int64)a[ 9]) * b[ 9]
  25192. + ((sp_int64)a[10]) * b[ 8]
  25193. + ((sp_int64)a[11]) * b[ 7]
  25194. + ((sp_int64)a[12]) * b[ 6]
  25195. + ((sp_int64)a[13]) * b[ 5]
  25196. + ((sp_int64)a[14]) * b[ 4];
  25197. r[17] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25198. t1 = ((sp_int64)a[ 5]) * b[14]
  25199. + ((sp_int64)a[ 6]) * b[13]
  25200. + ((sp_int64)a[ 7]) * b[12]
  25201. + ((sp_int64)a[ 8]) * b[11]
  25202. + ((sp_int64)a[ 9]) * b[10]
  25203. + ((sp_int64)a[10]) * b[ 9]
  25204. + ((sp_int64)a[11]) * b[ 8]
  25205. + ((sp_int64)a[12]) * b[ 7]
  25206. + ((sp_int64)a[13]) * b[ 6]
  25207. + ((sp_int64)a[14]) * b[ 5];
  25208. r[18] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25209. t0 = ((sp_int64)a[ 6]) * b[14]
  25210. + ((sp_int64)a[ 7]) * b[13]
  25211. + ((sp_int64)a[ 8]) * b[12]
  25212. + ((sp_int64)a[ 9]) * b[11]
  25213. + ((sp_int64)a[10]) * b[10]
  25214. + ((sp_int64)a[11]) * b[ 9]
  25215. + ((sp_int64)a[12]) * b[ 8]
  25216. + ((sp_int64)a[13]) * b[ 7]
  25217. + ((sp_int64)a[14]) * b[ 6];
  25218. r[19] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25219. t1 = ((sp_int64)a[ 7]) * b[14]
  25220. + ((sp_int64)a[ 8]) * b[13]
  25221. + ((sp_int64)a[ 9]) * b[12]
  25222. + ((sp_int64)a[10]) * b[11]
  25223. + ((sp_int64)a[11]) * b[10]
  25224. + ((sp_int64)a[12]) * b[ 9]
  25225. + ((sp_int64)a[13]) * b[ 8]
  25226. + ((sp_int64)a[14]) * b[ 7];
  25227. r[20] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25228. t0 = ((sp_int64)a[ 8]) * b[14]
  25229. + ((sp_int64)a[ 9]) * b[13]
  25230. + ((sp_int64)a[10]) * b[12]
  25231. + ((sp_int64)a[11]) * b[11]
  25232. + ((sp_int64)a[12]) * b[10]
  25233. + ((sp_int64)a[13]) * b[ 9]
  25234. + ((sp_int64)a[14]) * b[ 8];
  25235. r[21] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25236. t1 = ((sp_int64)a[ 9]) * b[14]
  25237. + ((sp_int64)a[10]) * b[13]
  25238. + ((sp_int64)a[11]) * b[12]
  25239. + ((sp_int64)a[12]) * b[11]
  25240. + ((sp_int64)a[13]) * b[10]
  25241. + ((sp_int64)a[14]) * b[ 9];
  25242. r[22] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25243. t0 = ((sp_int64)a[10]) * b[14]
  25244. + ((sp_int64)a[11]) * b[13]
  25245. + ((sp_int64)a[12]) * b[12]
  25246. + ((sp_int64)a[13]) * b[11]
  25247. + ((sp_int64)a[14]) * b[10];
  25248. r[23] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25249. t1 = ((sp_int64)a[11]) * b[14]
  25250. + ((sp_int64)a[12]) * b[13]
  25251. + ((sp_int64)a[13]) * b[12]
  25252. + ((sp_int64)a[14]) * b[11];
  25253. r[24] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25254. t0 = ((sp_int64)a[12]) * b[14]
  25255. + ((sp_int64)a[13]) * b[13]
  25256. + ((sp_int64)a[14]) * b[12];
  25257. r[25] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25258. t1 = ((sp_int64)a[13]) * b[14]
  25259. + ((sp_int64)a[14]) * b[13];
  25260. r[26] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25261. t0 = ((sp_int64)a[14]) * b[14];
  25262. r[27] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25263. r[28] = t0 & 0x3ffffff;
  25264. r[29] = (sp_digit)(t0 >> 26);
  25265. XMEMCPY(r, t, sizeof(t));
  25266. }
  25267. #endif /* WOLFSSL_SP_SMALL */
  25268. #ifdef WOLFSSL_SP_SMALL
  25269. /* Square a and put result in r. (r = a * a)
  25270. *
  25271. * r A single precision integer.
  25272. * a A single precision integer.
  25273. */
  25274. SP_NOINLINE static void sp_384_sqr_15(sp_digit* r, const sp_digit* a)
  25275. {
  25276. int i;
  25277. int imax;
  25278. int k;
  25279. sp_uint64 c;
  25280. sp_uint64 t;
  25281. c = ((sp_uint64)a[14]) * a[14];
  25282. r[29] = (sp_digit)(c >> 26);
  25283. c = (c & 0x3ffffff) << 26;
  25284. for (k = 27; k >= 0; k--) {
  25285. i = (k + 1) / 2;
  25286. if ((k & 1) == 0) {
  25287. c += ((sp_uint64)a[i]) * a[i];
  25288. i++;
  25289. }
  25290. if (k < 14) {
  25291. imax = k;
  25292. }
  25293. else {
  25294. imax = 14;
  25295. }
  25296. t = 0;
  25297. for (; i <= imax; i++) {
  25298. t += ((sp_uint64)a[i]) * a[k - i];
  25299. }
  25300. c += t * 2;
  25301. r[k + 2] += (sp_digit) (c >> 52);
  25302. r[k + 1] = (sp_digit)((c >> 26) & 0x3ffffff);
  25303. c = (c & 0x3ffffff) << 26;
  25304. }
  25305. r[0] = (sp_digit)(c >> 26);
  25306. }
  25307. #else
  25308. /* Square a and put result in r. (r = a * a)
  25309. *
  25310. * r A single precision integer.
  25311. * a A single precision integer.
  25312. */
  25313. SP_NOINLINE static void sp_384_sqr_15(sp_digit* r, const sp_digit* a)
  25314. {
  25315. sp_int64 t0;
  25316. sp_int64 t1;
  25317. sp_digit t[15];
  25318. t0 = ((sp_int64)a[ 0]) * a[ 0];
  25319. t1 = (((sp_int64)a[ 0]) * a[ 1]) * 2;
  25320. t[ 0] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25321. t0 = (((sp_int64)a[ 0]) * a[ 2]) * 2
  25322. + ((sp_int64)a[ 1]) * a[ 1];
  25323. t[ 1] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25324. t1 = (((sp_int64)a[ 0]) * a[ 3]
  25325. + ((sp_int64)a[ 1]) * a[ 2]) * 2;
  25326. t[ 2] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25327. t0 = (((sp_int64)a[ 0]) * a[ 4]
  25328. + ((sp_int64)a[ 1]) * a[ 3]) * 2
  25329. + ((sp_int64)a[ 2]) * a[ 2];
  25330. t[ 3] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25331. t1 = (((sp_int64)a[ 0]) * a[ 5]
  25332. + ((sp_int64)a[ 1]) * a[ 4]
  25333. + ((sp_int64)a[ 2]) * a[ 3]) * 2;
  25334. t[ 4] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25335. t0 = (((sp_int64)a[ 0]) * a[ 6]
  25336. + ((sp_int64)a[ 1]) * a[ 5]
  25337. + ((sp_int64)a[ 2]) * a[ 4]) * 2
  25338. + ((sp_int64)a[ 3]) * a[ 3];
  25339. t[ 5] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25340. t1 = (((sp_int64)a[ 0]) * a[ 7]
  25341. + ((sp_int64)a[ 1]) * a[ 6]
  25342. + ((sp_int64)a[ 2]) * a[ 5]
  25343. + ((sp_int64)a[ 3]) * a[ 4]) * 2;
  25344. t[ 6] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25345. t0 = (((sp_int64)a[ 0]) * a[ 8]
  25346. + ((sp_int64)a[ 1]) * a[ 7]
  25347. + ((sp_int64)a[ 2]) * a[ 6]
  25348. + ((sp_int64)a[ 3]) * a[ 5]) * 2
  25349. + ((sp_int64)a[ 4]) * a[ 4];
  25350. t[ 7] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25351. t1 = (((sp_int64)a[ 0]) * a[ 9]
  25352. + ((sp_int64)a[ 1]) * a[ 8]
  25353. + ((sp_int64)a[ 2]) * a[ 7]
  25354. + ((sp_int64)a[ 3]) * a[ 6]
  25355. + ((sp_int64)a[ 4]) * a[ 5]) * 2;
  25356. t[ 8] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25357. t0 = (((sp_int64)a[ 0]) * a[10]
  25358. + ((sp_int64)a[ 1]) * a[ 9]
  25359. + ((sp_int64)a[ 2]) * a[ 8]
  25360. + ((sp_int64)a[ 3]) * a[ 7]
  25361. + ((sp_int64)a[ 4]) * a[ 6]) * 2
  25362. + ((sp_int64)a[ 5]) * a[ 5];
  25363. t[ 9] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25364. t1 = (((sp_int64)a[ 0]) * a[11]
  25365. + ((sp_int64)a[ 1]) * a[10]
  25366. + ((sp_int64)a[ 2]) * a[ 9]
  25367. + ((sp_int64)a[ 3]) * a[ 8]
  25368. + ((sp_int64)a[ 4]) * a[ 7]
  25369. + ((sp_int64)a[ 5]) * a[ 6]) * 2;
  25370. t[10] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25371. t0 = (((sp_int64)a[ 0]) * a[12]
  25372. + ((sp_int64)a[ 1]) * a[11]
  25373. + ((sp_int64)a[ 2]) * a[10]
  25374. + ((sp_int64)a[ 3]) * a[ 9]
  25375. + ((sp_int64)a[ 4]) * a[ 8]
  25376. + ((sp_int64)a[ 5]) * a[ 7]) * 2
  25377. + ((sp_int64)a[ 6]) * a[ 6];
  25378. t[11] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25379. t1 = (((sp_int64)a[ 0]) * a[13]
  25380. + ((sp_int64)a[ 1]) * a[12]
  25381. + ((sp_int64)a[ 2]) * a[11]
  25382. + ((sp_int64)a[ 3]) * a[10]
  25383. + ((sp_int64)a[ 4]) * a[ 9]
  25384. + ((sp_int64)a[ 5]) * a[ 8]
  25385. + ((sp_int64)a[ 6]) * a[ 7]) * 2;
  25386. t[12] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25387. t0 = (((sp_int64)a[ 0]) * a[14]
  25388. + ((sp_int64)a[ 1]) * a[13]
  25389. + ((sp_int64)a[ 2]) * a[12]
  25390. + ((sp_int64)a[ 3]) * a[11]
  25391. + ((sp_int64)a[ 4]) * a[10]
  25392. + ((sp_int64)a[ 5]) * a[ 9]
  25393. + ((sp_int64)a[ 6]) * a[ 8]) * 2
  25394. + ((sp_int64)a[ 7]) * a[ 7];
  25395. t[13] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25396. t1 = (((sp_int64)a[ 1]) * a[14]
  25397. + ((sp_int64)a[ 2]) * a[13]
  25398. + ((sp_int64)a[ 3]) * a[12]
  25399. + ((sp_int64)a[ 4]) * a[11]
  25400. + ((sp_int64)a[ 5]) * a[10]
  25401. + ((sp_int64)a[ 6]) * a[ 9]
  25402. + ((sp_int64)a[ 7]) * a[ 8]) * 2;
  25403. t[14] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25404. t0 = (((sp_int64)a[ 2]) * a[14]
  25405. + ((sp_int64)a[ 3]) * a[13]
  25406. + ((sp_int64)a[ 4]) * a[12]
  25407. + ((sp_int64)a[ 5]) * a[11]
  25408. + ((sp_int64)a[ 6]) * a[10]
  25409. + ((sp_int64)a[ 7]) * a[ 9]) * 2
  25410. + ((sp_int64)a[ 8]) * a[ 8];
  25411. r[15] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25412. t1 = (((sp_int64)a[ 3]) * a[14]
  25413. + ((sp_int64)a[ 4]) * a[13]
  25414. + ((sp_int64)a[ 5]) * a[12]
  25415. + ((sp_int64)a[ 6]) * a[11]
  25416. + ((sp_int64)a[ 7]) * a[10]
  25417. + ((sp_int64)a[ 8]) * a[ 9]) * 2;
  25418. r[16] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25419. t0 = (((sp_int64)a[ 4]) * a[14]
  25420. + ((sp_int64)a[ 5]) * a[13]
  25421. + ((sp_int64)a[ 6]) * a[12]
  25422. + ((sp_int64)a[ 7]) * a[11]
  25423. + ((sp_int64)a[ 8]) * a[10]) * 2
  25424. + ((sp_int64)a[ 9]) * a[ 9];
  25425. r[17] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25426. t1 = (((sp_int64)a[ 5]) * a[14]
  25427. + ((sp_int64)a[ 6]) * a[13]
  25428. + ((sp_int64)a[ 7]) * a[12]
  25429. + ((sp_int64)a[ 8]) * a[11]
  25430. + ((sp_int64)a[ 9]) * a[10]) * 2;
  25431. r[18] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25432. t0 = (((sp_int64)a[ 6]) * a[14]
  25433. + ((sp_int64)a[ 7]) * a[13]
  25434. + ((sp_int64)a[ 8]) * a[12]
  25435. + ((sp_int64)a[ 9]) * a[11]) * 2
  25436. + ((sp_int64)a[10]) * a[10];
  25437. r[19] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25438. t1 = (((sp_int64)a[ 7]) * a[14]
  25439. + ((sp_int64)a[ 8]) * a[13]
  25440. + ((sp_int64)a[ 9]) * a[12]
  25441. + ((sp_int64)a[10]) * a[11]) * 2;
  25442. r[20] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25443. t0 = (((sp_int64)a[ 8]) * a[14]
  25444. + ((sp_int64)a[ 9]) * a[13]
  25445. + ((sp_int64)a[10]) * a[12]) * 2
  25446. + ((sp_int64)a[11]) * a[11];
  25447. r[21] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25448. t1 = (((sp_int64)a[ 9]) * a[14]
  25449. + ((sp_int64)a[10]) * a[13]
  25450. + ((sp_int64)a[11]) * a[12]) * 2;
  25451. r[22] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25452. t0 = (((sp_int64)a[10]) * a[14]
  25453. + ((sp_int64)a[11]) * a[13]) * 2
  25454. + ((sp_int64)a[12]) * a[12];
  25455. r[23] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25456. t1 = (((sp_int64)a[11]) * a[14]
  25457. + ((sp_int64)a[12]) * a[13]) * 2;
  25458. r[24] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25459. t0 = (((sp_int64)a[12]) * a[14]) * 2
  25460. + ((sp_int64)a[13]) * a[13];
  25461. r[25] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25462. t1 = (((sp_int64)a[13]) * a[14]) * 2;
  25463. r[26] = t0 & 0x3ffffff; t1 += t0 >> 26;
  25464. t0 = ((sp_int64)a[14]) * a[14];
  25465. r[27] = t1 & 0x3ffffff; t0 += t1 >> 26;
  25466. r[28] = t0 & 0x3ffffff;
  25467. r[29] = (sp_digit)(t0 >> 26);
  25468. XMEMCPY(r, t, sizeof(t));
  25469. }
  25470. #endif /* WOLFSSL_SP_SMALL */
  25471. #ifdef WOLFSSL_SP_SMALL
  25472. /* Add b to a into r. (r = a + b)
  25473. *
  25474. * r A single precision integer.
  25475. * a A single precision integer.
  25476. * b A single precision integer.
  25477. */
  25478. SP_NOINLINE static int sp_384_add_15(sp_digit* r, const sp_digit* a,
  25479. const sp_digit* b)
  25480. {
  25481. int i;
  25482. for (i = 0; i < 15; i++) {
  25483. r[i] = a[i] + b[i];
  25484. }
  25485. return 0;
  25486. }
  25487. #else
  25488. /* Add b to a into r. (r = a + b)
  25489. *
  25490. * r A single precision integer.
  25491. * a A single precision integer.
  25492. * b A single precision integer.
  25493. */
  25494. SP_NOINLINE static int sp_384_add_15(sp_digit* r, const sp_digit* a,
  25495. const sp_digit* b)
  25496. {
  25497. r[ 0] = a[ 0] + b[ 0];
  25498. r[ 1] = a[ 1] + b[ 1];
  25499. r[ 2] = a[ 2] + b[ 2];
  25500. r[ 3] = a[ 3] + b[ 3];
  25501. r[ 4] = a[ 4] + b[ 4];
  25502. r[ 5] = a[ 5] + b[ 5];
  25503. r[ 6] = a[ 6] + b[ 6];
  25504. r[ 7] = a[ 7] + b[ 7];
  25505. r[ 8] = a[ 8] + b[ 8];
  25506. r[ 9] = a[ 9] + b[ 9];
  25507. r[10] = a[10] + b[10];
  25508. r[11] = a[11] + b[11];
  25509. r[12] = a[12] + b[12];
  25510. r[13] = a[13] + b[13];
  25511. r[14] = a[14] + b[14];
  25512. return 0;
  25513. }
  25514. #endif /* WOLFSSL_SP_SMALL */
  25515. #ifdef WOLFSSL_SP_SMALL
  25516. /* Sub b from a into r. (r = a - b)
  25517. *
  25518. * r A single precision integer.
  25519. * a A single precision integer.
  25520. * b A single precision integer.
  25521. */
  25522. SP_NOINLINE static int sp_384_sub_15(sp_digit* r, const sp_digit* a,
  25523. const sp_digit* b)
  25524. {
  25525. int i;
  25526. for (i = 0; i < 15; i++) {
  25527. r[i] = a[i] - b[i];
  25528. }
  25529. return 0;
  25530. }
  25531. #else
  25532. /* Sub b from a into r. (r = a - b)
  25533. *
  25534. * r A single precision integer.
  25535. * a A single precision integer.
  25536. * b A single precision integer.
  25537. */
  25538. SP_NOINLINE static int sp_384_sub_15(sp_digit* r, const sp_digit* a,
  25539. const sp_digit* b)
  25540. {
  25541. r[ 0] = a[ 0] - b[ 0];
  25542. r[ 1] = a[ 1] - b[ 1];
  25543. r[ 2] = a[ 2] - b[ 2];
  25544. r[ 3] = a[ 3] - b[ 3];
  25545. r[ 4] = a[ 4] - b[ 4];
  25546. r[ 5] = a[ 5] - b[ 5];
  25547. r[ 6] = a[ 6] - b[ 6];
  25548. r[ 7] = a[ 7] - b[ 7];
  25549. r[ 8] = a[ 8] - b[ 8];
  25550. r[ 9] = a[ 9] - b[ 9];
  25551. r[10] = a[10] - b[10];
  25552. r[11] = a[11] - b[11];
  25553. r[12] = a[12] - b[12];
  25554. r[13] = a[13] - b[13];
  25555. r[14] = a[14] - b[14];
  25556. return 0;
  25557. }
  25558. #endif /* WOLFSSL_SP_SMALL */
  25559. /* Convert an mp_int to an array of sp_digit.
  25560. *
  25561. * r A single precision integer.
  25562. * size Maximum number of bytes to convert
  25563. * a A multi-precision integer.
  25564. */
  25565. static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
  25566. {
  25567. #if DIGIT_BIT == 26
  25568. int i;
  25569. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  25570. int o = 0;
  25571. for (i = 0; i < size; i++) {
  25572. sp_digit mask = (sp_digit)0 - (j >> 25);
  25573. r[i] = a->dp[o] & mask;
  25574. j++;
  25575. o += (int)(j >> 25);
  25576. }
  25577. #elif DIGIT_BIT > 26
  25578. unsigned int i;
  25579. int j = 0;
  25580. word32 s = 0;
  25581. r[0] = 0;
  25582. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  25583. r[j] |= ((sp_digit)a->dp[i] << s);
  25584. r[j] &= 0x3ffffff;
  25585. s = 26U - s;
  25586. if (j + 1 >= size) {
  25587. break;
  25588. }
  25589. /* lint allow cast of mismatch word32 and mp_digit */
  25590. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  25591. while ((s + 26U) <= (word32)DIGIT_BIT) {
  25592. s += 26U;
  25593. r[j] &= 0x3ffffff;
  25594. if (j + 1 >= size) {
  25595. break;
  25596. }
  25597. if (s < (word32)DIGIT_BIT) {
  25598. /* lint allow cast of mismatch word32 and mp_digit */
  25599. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  25600. }
  25601. else {
  25602. r[++j] = (sp_digit)0;
  25603. }
  25604. }
  25605. s = (word32)DIGIT_BIT - s;
  25606. }
  25607. for (j++; j < size; j++) {
  25608. r[j] = 0;
  25609. }
  25610. #else
  25611. unsigned int i;
  25612. int j = 0;
  25613. int s = 0;
  25614. r[0] = 0;
  25615. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  25616. r[j] |= ((sp_digit)a->dp[i]) << s;
  25617. if (s + DIGIT_BIT >= 26) {
  25618. r[j] &= 0x3ffffff;
  25619. if (j + 1 >= size) {
  25620. break;
  25621. }
  25622. s = 26 - s;
  25623. if (s == DIGIT_BIT) {
  25624. r[++j] = 0;
  25625. s = 0;
  25626. }
  25627. else {
  25628. r[++j] = a->dp[i] >> s;
  25629. s = DIGIT_BIT - s;
  25630. }
  25631. }
  25632. else {
  25633. s += DIGIT_BIT;
  25634. }
  25635. }
  25636. for (j++; j < size; j++) {
  25637. r[j] = 0;
  25638. }
  25639. #endif
  25640. }
  25641. /* Convert a point of type ecc_point to type sp_point_384.
  25642. *
  25643. * p Point of type sp_point_384 (result).
  25644. * pm Point of type ecc_point.
  25645. */
  25646. static void sp_384_point_from_ecc_point_15(sp_point_384* p,
  25647. const ecc_point* pm)
  25648. {
  25649. XMEMSET(p->x, 0, sizeof(p->x));
  25650. XMEMSET(p->y, 0, sizeof(p->y));
  25651. XMEMSET(p->z, 0, sizeof(p->z));
  25652. sp_384_from_mp(p->x, 15, pm->x);
  25653. sp_384_from_mp(p->y, 15, pm->y);
  25654. sp_384_from_mp(p->z, 15, pm->z);
  25655. p->infinity = 0;
  25656. }
  25657. /* Convert an array of sp_digit to an mp_int.
  25658. *
  25659. * a A single precision integer.
  25660. * r A multi-precision integer.
  25661. */
  25662. static int sp_384_to_mp(const sp_digit* a, mp_int* r)
  25663. {
  25664. int err;
  25665. err = mp_grow(r, (384 + DIGIT_BIT - 1) / DIGIT_BIT);
  25666. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  25667. #if DIGIT_BIT == 26
  25668. XMEMCPY(r->dp, a, sizeof(sp_digit) * 15);
  25669. r->used = 15;
  25670. mp_clamp(r);
  25671. #elif DIGIT_BIT < 26
  25672. int i;
  25673. int j = 0;
  25674. int s = 0;
  25675. r->dp[0] = 0;
  25676. for (i = 0; i < 15; i++) {
  25677. r->dp[j] |= (mp_digit)(a[i] << s);
  25678. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  25679. s = DIGIT_BIT - s;
  25680. r->dp[++j] = (mp_digit)(a[i] >> s);
  25681. while (s + DIGIT_BIT <= 26) {
  25682. s += DIGIT_BIT;
  25683. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  25684. if (s == SP_WORD_SIZE) {
  25685. r->dp[j] = 0;
  25686. }
  25687. else {
  25688. r->dp[j] = (mp_digit)(a[i] >> s);
  25689. }
  25690. }
  25691. s = 26 - s;
  25692. }
  25693. r->used = (384 + DIGIT_BIT - 1) / DIGIT_BIT;
  25694. mp_clamp(r);
  25695. #else
  25696. int i;
  25697. int j = 0;
  25698. int s = 0;
  25699. r->dp[0] = 0;
  25700. for (i = 0; i < 15; i++) {
  25701. r->dp[j] |= ((mp_digit)a[i]) << s;
  25702. if (s + 26 >= DIGIT_BIT) {
  25703. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  25704. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  25705. #endif
  25706. s = DIGIT_BIT - s;
  25707. r->dp[++j] = a[i] >> s;
  25708. s = 26 - s;
  25709. }
  25710. else {
  25711. s += 26;
  25712. }
  25713. }
  25714. r->used = (384 + DIGIT_BIT - 1) / DIGIT_BIT;
  25715. mp_clamp(r);
  25716. #endif
  25717. }
  25718. return err;
  25719. }
  25720. /* Convert a point of type sp_point_384 to type ecc_point.
  25721. *
  25722. * p Point of type sp_point_384.
  25723. * pm Point of type ecc_point (result).
  25724. * returns MEMORY_E when allocation of memory in ecc_point fails otherwise
  25725. * MP_OKAY.
  25726. */
  25727. static int sp_384_point_to_ecc_point_15(const sp_point_384* p, ecc_point* pm)
  25728. {
  25729. int err;
  25730. err = sp_384_to_mp(p->x, pm->x);
  25731. if (err == MP_OKAY) {
  25732. err = sp_384_to_mp(p->y, pm->y);
  25733. }
  25734. if (err == MP_OKAY) {
  25735. err = sp_384_to_mp(p->z, pm->z);
  25736. }
  25737. return err;
  25738. }
  25739. /* Compare a with b in constant time.
  25740. *
  25741. * a A single precision integer.
  25742. * b A single precision integer.
  25743. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  25744. * respectively.
  25745. */
  25746. static sp_digit sp_384_cmp_15(const sp_digit* a, const sp_digit* b)
  25747. {
  25748. sp_digit r = 0;
  25749. #ifdef WOLFSSL_SP_SMALL
  25750. int i;
  25751. for (i=14; i>=0; i--) {
  25752. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 25);
  25753. }
  25754. #else
  25755. r |= (a[14] - b[14]) & (0 - (sp_digit)1);
  25756. r |= (a[13] - b[13]) & ~(((sp_digit)0 - r) >> 25);
  25757. r |= (a[12] - b[12]) & ~(((sp_digit)0 - r) >> 25);
  25758. r |= (a[11] - b[11]) & ~(((sp_digit)0 - r) >> 25);
  25759. r |= (a[10] - b[10]) & ~(((sp_digit)0 - r) >> 25);
  25760. r |= (a[ 9] - b[ 9]) & ~(((sp_digit)0 - r) >> 25);
  25761. r |= (a[ 8] - b[ 8]) & ~(((sp_digit)0 - r) >> 25);
  25762. r |= (a[ 7] - b[ 7]) & ~(((sp_digit)0 - r) >> 25);
  25763. r |= (a[ 6] - b[ 6]) & ~(((sp_digit)0 - r) >> 25);
  25764. r |= (a[ 5] - b[ 5]) & ~(((sp_digit)0 - r) >> 25);
  25765. r |= (a[ 4] - b[ 4]) & ~(((sp_digit)0 - r) >> 25);
  25766. r |= (a[ 3] - b[ 3]) & ~(((sp_digit)0 - r) >> 25);
  25767. r |= (a[ 2] - b[ 2]) & ~(((sp_digit)0 - r) >> 25);
  25768. r |= (a[ 1] - b[ 1]) & ~(((sp_digit)0 - r) >> 25);
  25769. r |= (a[ 0] - b[ 0]) & ~(((sp_digit)0 - r) >> 25);
  25770. #endif /* WOLFSSL_SP_SMALL */
  25771. return r;
  25772. }
  25773. /* Conditionally subtract b from a using the mask m.
  25774. * m is -1 to subtract and 0 when not.
  25775. *
  25776. * r A single precision number representing condition subtract result.
  25777. * a A single precision number to subtract from.
  25778. * b A single precision number to subtract.
  25779. * m Mask value to apply.
  25780. */
  25781. static void sp_384_cond_sub_15(sp_digit* r, const sp_digit* a,
  25782. const sp_digit* b, const sp_digit m)
  25783. {
  25784. #ifdef WOLFSSL_SP_SMALL
  25785. int i;
  25786. for (i = 0; i < 15; i++) {
  25787. r[i] = a[i] - (b[i] & m);
  25788. }
  25789. #else
  25790. r[ 0] = a[ 0] - (b[ 0] & m);
  25791. r[ 1] = a[ 1] - (b[ 1] & m);
  25792. r[ 2] = a[ 2] - (b[ 2] & m);
  25793. r[ 3] = a[ 3] - (b[ 3] & m);
  25794. r[ 4] = a[ 4] - (b[ 4] & m);
  25795. r[ 5] = a[ 5] - (b[ 5] & m);
  25796. r[ 6] = a[ 6] - (b[ 6] & m);
  25797. r[ 7] = a[ 7] - (b[ 7] & m);
  25798. r[ 8] = a[ 8] - (b[ 8] & m);
  25799. r[ 9] = a[ 9] - (b[ 9] & m);
  25800. r[10] = a[10] - (b[10] & m);
  25801. r[11] = a[11] - (b[11] & m);
  25802. r[12] = a[12] - (b[12] & m);
  25803. r[13] = a[13] - (b[13] & m);
  25804. r[14] = a[14] - (b[14] & m);
  25805. #endif /* WOLFSSL_SP_SMALL */
  25806. }
  25807. /* Mul a by scalar b and add into r. (r += a * b)
  25808. *
  25809. * r A single precision integer.
  25810. * a A single precision integer.
  25811. * b A scalar.
  25812. */
  25813. SP_NOINLINE static void sp_384_mul_add_15(sp_digit* r, const sp_digit* a,
  25814. const sp_digit b)
  25815. {
  25816. #ifdef WOLFSSL_SP_SMALL
  25817. sp_int64 tb = b;
  25818. sp_int64 t[4];
  25819. int i;
  25820. t[0] = 0;
  25821. for (i = 0; i < 12; i += 4) {
  25822. t[0] += (tb * a[i+0]) + r[i+0];
  25823. t[1] = (tb * a[i+1]) + r[i+1];
  25824. t[2] = (tb * a[i+2]) + r[i+2];
  25825. t[3] = (tb * a[i+3]) + r[i+3];
  25826. r[i+0] = t[0] & 0x3ffffff;
  25827. t[1] += t[0] >> 26;
  25828. r[i+1] = t[1] & 0x3ffffff;
  25829. t[2] += t[1] >> 26;
  25830. r[i+2] = t[2] & 0x3ffffff;
  25831. t[3] += t[2] >> 26;
  25832. r[i+3] = t[3] & 0x3ffffff;
  25833. t[0] = t[3] >> 26;
  25834. }
  25835. t[0] += (tb * a[12]) + r[12];
  25836. t[1] = (tb * a[13]) + r[13];
  25837. t[2] = (tb * a[14]) + r[14];
  25838. r[12] = t[0] & 0x3ffffff;
  25839. t[1] += t[0] >> 26;
  25840. r[13] = t[1] & 0x3ffffff;
  25841. t[2] += t[1] >> 26;
  25842. r[14] = t[2] & 0x3ffffff;
  25843. r[15] += (sp_digit)(t[2] >> 26);
  25844. #else
  25845. sp_int64 tb = b;
  25846. sp_int64 t[15];
  25847. t[ 0] = tb * a[ 0];
  25848. t[ 1] = tb * a[ 1];
  25849. t[ 2] = tb * a[ 2];
  25850. t[ 3] = tb * a[ 3];
  25851. t[ 4] = tb * a[ 4];
  25852. t[ 5] = tb * a[ 5];
  25853. t[ 6] = tb * a[ 6];
  25854. t[ 7] = tb * a[ 7];
  25855. t[ 8] = tb * a[ 8];
  25856. t[ 9] = tb * a[ 9];
  25857. t[10] = tb * a[10];
  25858. t[11] = tb * a[11];
  25859. t[12] = tb * a[12];
  25860. t[13] = tb * a[13];
  25861. t[14] = tb * a[14];
  25862. r[ 0] += (sp_digit) (t[ 0] & 0x3ffffff);
  25863. r[ 1] += (sp_digit)((t[ 0] >> 26) + (t[ 1] & 0x3ffffff));
  25864. r[ 2] += (sp_digit)((t[ 1] >> 26) + (t[ 2] & 0x3ffffff));
  25865. r[ 3] += (sp_digit)((t[ 2] >> 26) + (t[ 3] & 0x3ffffff));
  25866. r[ 4] += (sp_digit)((t[ 3] >> 26) + (t[ 4] & 0x3ffffff));
  25867. r[ 5] += (sp_digit)((t[ 4] >> 26) + (t[ 5] & 0x3ffffff));
  25868. r[ 6] += (sp_digit)((t[ 5] >> 26) + (t[ 6] & 0x3ffffff));
  25869. r[ 7] += (sp_digit)((t[ 6] >> 26) + (t[ 7] & 0x3ffffff));
  25870. r[ 8] += (sp_digit)((t[ 7] >> 26) + (t[ 8] & 0x3ffffff));
  25871. r[ 9] += (sp_digit)((t[ 8] >> 26) + (t[ 9] & 0x3ffffff));
  25872. r[10] += (sp_digit)((t[ 9] >> 26) + (t[10] & 0x3ffffff));
  25873. r[11] += (sp_digit)((t[10] >> 26) + (t[11] & 0x3ffffff));
  25874. r[12] += (sp_digit)((t[11] >> 26) + (t[12] & 0x3ffffff));
  25875. r[13] += (sp_digit)((t[12] >> 26) + (t[13] & 0x3ffffff));
  25876. r[14] += (sp_digit)((t[13] >> 26) + (t[14] & 0x3ffffff));
  25877. r[15] += (sp_digit) (t[14] >> 26);
  25878. #endif /* WOLFSSL_SP_SMALL */
  25879. }
  25880. /* Normalize the values in each word to 26 bits.
  25881. *
  25882. * a Array of sp_digit to normalize.
  25883. */
  25884. static void sp_384_norm_15(sp_digit* a)
  25885. {
  25886. #ifdef WOLFSSL_SP_SMALL
  25887. int i;
  25888. for (i = 0; i < 14; i++) {
  25889. a[i+1] += a[i] >> 26;
  25890. a[i] &= 0x3ffffff;
  25891. }
  25892. #else
  25893. a[1] += a[0] >> 26; a[0] &= 0x3ffffff;
  25894. a[2] += a[1] >> 26; a[1] &= 0x3ffffff;
  25895. a[3] += a[2] >> 26; a[2] &= 0x3ffffff;
  25896. a[4] += a[3] >> 26; a[3] &= 0x3ffffff;
  25897. a[5] += a[4] >> 26; a[4] &= 0x3ffffff;
  25898. a[6] += a[5] >> 26; a[5] &= 0x3ffffff;
  25899. a[7] += a[6] >> 26; a[6] &= 0x3ffffff;
  25900. a[8] += a[7] >> 26; a[7] &= 0x3ffffff;
  25901. a[9] += a[8] >> 26; a[8] &= 0x3ffffff;
  25902. a[10] += a[9] >> 26; a[9] &= 0x3ffffff;
  25903. a[11] += a[10] >> 26; a[10] &= 0x3ffffff;
  25904. a[12] += a[11] >> 26; a[11] &= 0x3ffffff;
  25905. a[13] += a[12] >> 26; a[12] &= 0x3ffffff;
  25906. a[14] += a[13] >> 26; a[13] &= 0x3ffffff;
  25907. #endif /* WOLFSSL_SP_SMALL */
  25908. }
  25909. /* Shift the result in the high 384 bits down to the bottom.
  25910. *
  25911. * r A single precision number.
  25912. * a A single precision number.
  25913. */
  25914. static void sp_384_mont_shift_15(sp_digit* r, const sp_digit* a)
  25915. {
  25916. #ifdef WOLFSSL_SP_SMALL
  25917. int i;
  25918. sp_int64 n = a[14] >> 20;
  25919. n += ((sp_int64)a[15]) << 6;
  25920. for (i = 0; i < 14; i++) {
  25921. r[i] = n & 0x3ffffff;
  25922. n >>= 26;
  25923. n += ((sp_int64)a[16 + i]) << 6;
  25924. }
  25925. r[14] = (sp_digit)n;
  25926. #else
  25927. sp_int64 n = a[14] >> 20;
  25928. n += ((sp_int64)a[15]) << 6;
  25929. r[ 0] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[16]) << 6;
  25930. r[ 1] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[17]) << 6;
  25931. r[ 2] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[18]) << 6;
  25932. r[ 3] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[19]) << 6;
  25933. r[ 4] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[20]) << 6;
  25934. r[ 5] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[21]) << 6;
  25935. r[ 6] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[22]) << 6;
  25936. r[ 7] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[23]) << 6;
  25937. r[ 8] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[24]) << 6;
  25938. r[ 9] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[25]) << 6;
  25939. r[10] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[26]) << 6;
  25940. r[11] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[27]) << 6;
  25941. r[12] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[28]) << 6;
  25942. r[13] = n & 0x3ffffff; n >>= 26; n += ((sp_int64)a[29]) << 6;
  25943. r[14] = (sp_digit)n;
  25944. #endif /* WOLFSSL_SP_SMALL */
  25945. XMEMSET(&r[15], 0, sizeof(*r) * 15U);
  25946. }
  25947. /* Reduce the number back to 384 bits using Montgomery reduction.
  25948. *
  25949. * a A single precision number to reduce in place.
  25950. * m The single precision number representing the modulus.
  25951. * mp The digit representing the negative inverse of m mod 2^n.
  25952. */
  25953. static void sp_384_mont_reduce_order_15(sp_digit* a, const sp_digit* m, sp_digit mp)
  25954. {
  25955. int i;
  25956. sp_digit mu;
  25957. sp_digit over;
  25958. sp_384_norm_15(a + 15);
  25959. for (i=0; i<14; i++) {
  25960. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x3ffffff;
  25961. sp_384_mul_add_15(a+i, m, mu);
  25962. a[i+1] += a[i] >> 26;
  25963. }
  25964. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0xfffffL;
  25965. sp_384_mul_add_15(a+i, m, mu);
  25966. a[i+1] += a[i] >> 26;
  25967. a[i] &= 0x3ffffff;
  25968. sp_384_mont_shift_15(a, a);
  25969. over = a[14] >> 20;
  25970. sp_384_cond_sub_15(a, a, m, ~((over - 1) >> 31));
  25971. sp_384_norm_15(a);
  25972. }
  25973. /* Reduce the number back to 384 bits using Montgomery reduction.
  25974. *
  25975. * a A single precision number to reduce in place.
  25976. * m The single precision number representing the modulus.
  25977. * mp The digit representing the negative inverse of m mod 2^n.
  25978. */
  25979. static void sp_384_mont_reduce_15(sp_digit* a, const sp_digit* m, sp_digit mp)
  25980. {
  25981. int i;
  25982. sp_digit am;
  25983. (void)m;
  25984. (void)mp;
  25985. for (i = 0; i < 14; i++) {
  25986. am = (a[i] * 0x1) & 0x3ffffff;
  25987. a[i + 1] += (am << 6) & 0x3ffffff;
  25988. a[i + 2] += am >> 20;
  25989. a[i + 3] -= (am << 18) & 0x3ffffff;
  25990. a[i + 4] -= am >> 8;
  25991. a[i + 4] -= (am << 24) & 0x3ffffff;
  25992. a[i + 5] -= am >> 2;
  25993. a[i + 14] += (am << 20) & 0x3ffffff;
  25994. a[i + 15] += am >> 6;
  25995. a[i + 1] += a[i] >> 26;
  25996. }
  25997. am = (a[14] * 0x1) & 0xfffff;
  25998. a[14 + 1] += (am << 6) & 0x3ffffff;
  25999. a[14 + 2] += am >> 20;
  26000. a[14 + 3] -= (am << 18) & 0x3ffffff;
  26001. a[14 + 4] -= am >> 8;
  26002. a[14 + 4] -= (am << 24) & 0x3ffffff;
  26003. a[14 + 5] -= am >> 2;
  26004. a[14 + 14] += (am << 20) & 0x3ffffff;
  26005. a[14 + 15] += am >> 6;
  26006. a[0] = (a[14] >> 20) + ((a[15] << 6) & 0x3ffffff);
  26007. a[1] = (a[15] >> 20) + ((a[16] << 6) & 0x3ffffff);
  26008. a[2] = (a[16] >> 20) + ((a[17] << 6) & 0x3ffffff);
  26009. a[3] = (a[17] >> 20) + ((a[18] << 6) & 0x3ffffff);
  26010. a[4] = (a[18] >> 20) + ((a[19] << 6) & 0x3ffffff);
  26011. a[5] = (a[19] >> 20) + ((a[20] << 6) & 0x3ffffff);
  26012. a[6] = (a[20] >> 20) + ((a[21] << 6) & 0x3ffffff);
  26013. a[7] = (a[21] >> 20) + ((a[22] << 6) & 0x3ffffff);
  26014. a[8] = (a[22] >> 20) + ((a[23] << 6) & 0x3ffffff);
  26015. a[9] = (a[23] >> 20) + ((a[24] << 6) & 0x3ffffff);
  26016. a[10] = (a[24] >> 20) + ((a[25] << 6) & 0x3ffffff);
  26017. a[11] = (a[25] >> 20) + ((a[26] << 6) & 0x3ffffff);
  26018. a[12] = (a[26] >> 20) + ((a[27] << 6) & 0x3ffffff);
  26019. a[13] = (a[27] >> 20) + ((a[28] << 6) & 0x3ffffff);
  26020. a[14] = (a[14 + 14] >> 20) + (a[29] << 6);
  26021. a[1] += a[0] >> 26; a[0] &= 0x3ffffff;
  26022. a[2] += a[1] >> 26; a[1] &= 0x3ffffff;
  26023. a[3] += a[2] >> 26; a[2] &= 0x3ffffff;
  26024. a[4] += a[3] >> 26; a[3] &= 0x3ffffff;
  26025. a[5] += a[4] >> 26; a[4] &= 0x3ffffff;
  26026. a[6] += a[5] >> 26; a[5] &= 0x3ffffff;
  26027. a[7] += a[6] >> 26; a[6] &= 0x3ffffff;
  26028. a[8] += a[7] >> 26; a[7] &= 0x3ffffff;
  26029. a[9] += a[8] >> 26; a[8] &= 0x3ffffff;
  26030. a[10] += a[9] >> 26; a[9] &= 0x3ffffff;
  26031. a[11] += a[10] >> 26; a[10] &= 0x3ffffff;
  26032. a[12] += a[11] >> 26; a[11] &= 0x3ffffff;
  26033. a[13] += a[12] >> 26; a[12] &= 0x3ffffff;
  26034. a[14] += a[13] >> 26; a[13] &= 0x3ffffff;
  26035. /* Get the bit over, if any. */
  26036. am = a[14] >> 20;
  26037. /* Create mask. */
  26038. am = 0 - am;
  26039. a[0] -= 0x03ffffff & am;
  26040. a[1] -= 0x0000003f & am;
  26041. /* p384_mod[2] is zero */
  26042. a[3] -= 0x03fc0000 & am;
  26043. a[4] -= 0x02ffffff & am;
  26044. a[5] -= 0x03ffffff & am;
  26045. a[6] -= 0x03ffffff & am;
  26046. a[7] -= 0x03ffffff & am;
  26047. a[8] -= 0x03ffffff & am;
  26048. a[9] -= 0x03ffffff & am;
  26049. a[10] -= 0x03ffffff & am;
  26050. a[11] -= 0x03ffffff & am;
  26051. a[12] -= 0x03ffffff & am;
  26052. a[13] -= 0x03ffffff & am;
  26053. a[14] -= 0x000fffff & am;
  26054. a[1] += a[0] >> 26; a[0] &= 0x3ffffff;
  26055. a[2] += a[1] >> 26; a[1] &= 0x3ffffff;
  26056. a[3] += a[2] >> 26; a[2] &= 0x3ffffff;
  26057. a[4] += a[3] >> 26; a[3] &= 0x3ffffff;
  26058. a[5] += a[4] >> 26; a[4] &= 0x3ffffff;
  26059. a[6] += a[5] >> 26; a[5] &= 0x3ffffff;
  26060. a[7] += a[6] >> 26; a[6] &= 0x3ffffff;
  26061. a[8] += a[7] >> 26; a[7] &= 0x3ffffff;
  26062. a[9] += a[8] >> 26; a[8] &= 0x3ffffff;
  26063. a[10] += a[9] >> 26; a[9] &= 0x3ffffff;
  26064. a[11] += a[10] >> 26; a[10] &= 0x3ffffff;
  26065. a[12] += a[11] >> 26; a[11] &= 0x3ffffff;
  26066. a[13] += a[12] >> 26; a[12] &= 0x3ffffff;
  26067. a[14] += a[13] >> 26; a[13] &= 0x3ffffff;
  26068. }
  26069. /* Multiply two Montgomery form numbers mod the modulus (prime).
  26070. * (r = a * b mod m)
  26071. *
  26072. * r Result of multiplication.
  26073. * a First number to multiply in Montgomery form.
  26074. * b Second number to multiply in Montgomery form.
  26075. * m Modulus (prime).
  26076. * mp Montgomery multiplier.
  26077. */
  26078. SP_NOINLINE static void sp_384_mont_mul_15(sp_digit* r, const sp_digit* a,
  26079. const sp_digit* b, const sp_digit* m, sp_digit mp)
  26080. {
  26081. sp_384_mul_15(r, a, b);
  26082. sp_384_mont_reduce_15(r, m, mp);
  26083. }
  26084. /* Square the Montgomery form number. (r = a * a mod m)
  26085. *
  26086. * r Result of squaring.
  26087. * a Number to square in Montgomery form.
  26088. * m Modulus (prime).
  26089. * mp Montgomery multiplier.
  26090. */
  26091. SP_NOINLINE static void sp_384_mont_sqr_15(sp_digit* r, const sp_digit* a,
  26092. const sp_digit* m, sp_digit mp)
  26093. {
  26094. sp_384_sqr_15(r, a);
  26095. sp_384_mont_reduce_15(r, m, mp);
  26096. }
  26097. #if !defined(WOLFSSL_SP_SMALL) || defined(HAVE_COMP_KEY)
  26098. /* Square the Montgomery form number a number of times. (r = a ^ n mod m)
  26099. *
  26100. * r Result of squaring.
  26101. * a Number to square in Montgomery form.
  26102. * n Number of times to square.
  26103. * m Modulus (prime).
  26104. * mp Montgomery multiplier.
  26105. */
  26106. SP_NOINLINE static void sp_384_mont_sqr_n_15(sp_digit* r,
  26107. const sp_digit* a, int n, const sp_digit* m, sp_digit mp)
  26108. {
  26109. sp_384_mont_sqr_15(r, a, m, mp);
  26110. for (; n > 1; n--) {
  26111. sp_384_mont_sqr_15(r, r, m, mp);
  26112. }
  26113. }
  26114. #endif /* !WOLFSSL_SP_SMALL || HAVE_COMP_KEY */
  26115. #ifdef WOLFSSL_SP_SMALL
  26116. /* Mod-2 for the P384 curve. */
  26117. static const uint32_t p384_mod_minus_2[12] = {
  26118. 0xfffffffdU,0x00000000U,0x00000000U,0xffffffffU,0xfffffffeU,0xffffffffU,
  26119. 0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU
  26120. };
  26121. #endif /* !WOLFSSL_SP_SMALL */
  26122. /* Invert the number, in Montgomery form, modulo the modulus (prime) of the
  26123. * P384 curve. (r = 1 / a mod m)
  26124. *
  26125. * r Inverse result.
  26126. * a Number to invert.
  26127. * td Temporary data.
  26128. */
  26129. static void sp_384_mont_inv_15(sp_digit* r, const sp_digit* a, sp_digit* td)
  26130. {
  26131. #ifdef WOLFSSL_SP_SMALL
  26132. sp_digit* t = td;
  26133. int i;
  26134. XMEMCPY(t, a, sizeof(sp_digit) * 15);
  26135. for (i=382; i>=0; i--) {
  26136. sp_384_mont_sqr_15(t, t, p384_mod, p384_mp_mod);
  26137. if (p384_mod_minus_2[i / 32] & ((sp_digit)1 << (i % 32)))
  26138. sp_384_mont_mul_15(t, t, a, p384_mod, p384_mp_mod);
  26139. }
  26140. XMEMCPY(r, t, sizeof(sp_digit) * 15);
  26141. #else
  26142. sp_digit* t1 = td;
  26143. sp_digit* t2 = td + 2 * 15;
  26144. sp_digit* t3 = td + 4 * 15;
  26145. sp_digit* t4 = td + 6 * 15;
  26146. sp_digit* t5 = td + 8 * 15;
  26147. /* 0x2 */
  26148. sp_384_mont_sqr_15(t1, a, p384_mod, p384_mp_mod);
  26149. /* 0x3 */
  26150. sp_384_mont_mul_15(t5, t1, a, p384_mod, p384_mp_mod);
  26151. /* 0xc */
  26152. sp_384_mont_sqr_n_15(t1, t5, 2, p384_mod, p384_mp_mod);
  26153. /* 0xf */
  26154. sp_384_mont_mul_15(t2, t5, t1, p384_mod, p384_mp_mod);
  26155. /* 0x1e */
  26156. sp_384_mont_sqr_15(t1, t2, p384_mod, p384_mp_mod);
  26157. /* 0x1f */
  26158. sp_384_mont_mul_15(t4, t1, a, p384_mod, p384_mp_mod);
  26159. /* 0x3e0 */
  26160. sp_384_mont_sqr_n_15(t1, t4, 5, p384_mod, p384_mp_mod);
  26161. /* 0x3ff */
  26162. sp_384_mont_mul_15(t2, t4, t1, p384_mod, p384_mp_mod);
  26163. /* 0x7fe0 */
  26164. sp_384_mont_sqr_n_15(t1, t2, 5, p384_mod, p384_mp_mod);
  26165. /* 0x7fff */
  26166. sp_384_mont_mul_15(t4, t4, t1, p384_mod, p384_mp_mod);
  26167. /* 0x3fff8000 */
  26168. sp_384_mont_sqr_n_15(t1, t4, 15, p384_mod, p384_mp_mod);
  26169. /* 0x3fffffff */
  26170. sp_384_mont_mul_15(t2, t4, t1, p384_mod, p384_mp_mod);
  26171. /* 0xfffffffc */
  26172. sp_384_mont_sqr_n_15(t3, t2, 2, p384_mod, p384_mp_mod);
  26173. /* 0xfffffffd */
  26174. sp_384_mont_mul_15(r, t3, a, p384_mod, p384_mp_mod);
  26175. /* 0xffffffff */
  26176. sp_384_mont_mul_15(t3, t5, t3, p384_mod, p384_mp_mod);
  26177. /* 0xfffffffc0000000 */
  26178. sp_384_mont_sqr_n_15(t1, t2, 30, p384_mod, p384_mp_mod);
  26179. /* 0xfffffffffffffff */
  26180. sp_384_mont_mul_15(t2, t2, t1, p384_mod, p384_mp_mod);
  26181. /* 0xfffffffffffffff000000000000000 */
  26182. sp_384_mont_sqr_n_15(t1, t2, 60, p384_mod, p384_mp_mod);
  26183. /* 0xffffffffffffffffffffffffffffff */
  26184. sp_384_mont_mul_15(t2, t2, t1, p384_mod, p384_mp_mod);
  26185. /* 0xffffffffffffffffffffffffffffff000000000000000000000000000000 */
  26186. sp_384_mont_sqr_n_15(t1, t2, 120, p384_mod, p384_mp_mod);
  26187. /* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  26188. sp_384_mont_mul_15(t2, t2, t1, p384_mod, p384_mp_mod);
  26189. /* 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8000 */
  26190. sp_384_mont_sqr_n_15(t1, t2, 15, p384_mod, p384_mp_mod);
  26191. /* 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  26192. sp_384_mont_mul_15(t2, t4, t1, p384_mod, p384_mp_mod);
  26193. /* 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00000000 */
  26194. sp_384_mont_sqr_n_15(t1, t2, 33, p384_mod, p384_mp_mod);
  26195. /* 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff */
  26196. sp_384_mont_mul_15(t2, t3, t1, p384_mod, p384_mp_mod);
  26197. /* 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff000000000000000000000000 */
  26198. sp_384_mont_sqr_n_15(t1, t2, 96, p384_mod, p384_mp_mod);
  26199. /* 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffd */
  26200. sp_384_mont_mul_15(r, r, t1, p384_mod, p384_mp_mod);
  26201. #endif /* WOLFSSL_SP_SMALL */
  26202. }
  26203. /* Map the Montgomery form projective coordinate point to an affine point.
  26204. *
  26205. * r Resulting affine coordinate point.
  26206. * p Montgomery form projective coordinate point.
  26207. * t Temporary ordinate data.
  26208. */
  26209. static void sp_384_map_15(sp_point_384* r, const sp_point_384* p,
  26210. sp_digit* t)
  26211. {
  26212. sp_digit* t1 = t;
  26213. sp_digit* t2 = t + 2*15;
  26214. sp_int32 n;
  26215. sp_384_mont_inv_15(t1, p->z, t + 2*15);
  26216. sp_384_mont_sqr_15(t2, t1, p384_mod, p384_mp_mod);
  26217. sp_384_mont_mul_15(t1, t2, t1, p384_mod, p384_mp_mod);
  26218. /* x /= z^2 */
  26219. sp_384_mont_mul_15(r->x, p->x, t2, p384_mod, p384_mp_mod);
  26220. XMEMSET(r->x + 15, 0, sizeof(sp_digit) * 15U);
  26221. sp_384_mont_reduce_15(r->x, p384_mod, p384_mp_mod);
  26222. /* Reduce x to less than modulus */
  26223. n = sp_384_cmp_15(r->x, p384_mod);
  26224. sp_384_cond_sub_15(r->x, r->x, p384_mod, ~(n >> 25));
  26225. sp_384_norm_15(r->x);
  26226. /* y /= z^3 */
  26227. sp_384_mont_mul_15(r->y, p->y, t1, p384_mod, p384_mp_mod);
  26228. XMEMSET(r->y + 15, 0, sizeof(sp_digit) * 15U);
  26229. sp_384_mont_reduce_15(r->y, p384_mod, p384_mp_mod);
  26230. /* Reduce y to less than modulus */
  26231. n = sp_384_cmp_15(r->y, p384_mod);
  26232. sp_384_cond_sub_15(r->y, r->y, p384_mod, ~(n >> 25));
  26233. sp_384_norm_15(r->y);
  26234. XMEMSET(r->z, 0, sizeof(r->z) / 2);
  26235. r->z[0] = 1;
  26236. }
  26237. /* Add two Montgomery form numbers (r = a + b % m).
  26238. *
  26239. * r Result of addition.
  26240. * a First number to add in Montgomery form.
  26241. * b Second number to add in Montgomery form.
  26242. * m Modulus (prime).
  26243. */
  26244. static void sp_384_mont_add_15(sp_digit* r, const sp_digit* a, const sp_digit* b,
  26245. const sp_digit* m)
  26246. {
  26247. sp_digit over;
  26248. (void)sp_384_add_15(r, a, b);
  26249. sp_384_norm_15(r);
  26250. over = r[14] >> 20;
  26251. sp_384_cond_sub_15(r, r, m, ~((over - 1) >> 31));
  26252. sp_384_norm_15(r);
  26253. }
  26254. /* Double a Montgomery form number (r = a + a % m).
  26255. *
  26256. * r Result of doubling.
  26257. * a Number to double in Montgomery form.
  26258. * m Modulus (prime).
  26259. */
  26260. static void sp_384_mont_dbl_15(sp_digit* r, const sp_digit* a, const sp_digit* m)
  26261. {
  26262. sp_digit over;
  26263. (void)sp_384_add_15(r, a, a);
  26264. sp_384_norm_15(r);
  26265. over = r[14] >> 20;
  26266. sp_384_cond_sub_15(r, r, m, ~((over - 1) >> 31));
  26267. sp_384_norm_15(r);
  26268. }
  26269. /* Triple a Montgomery form number (r = a + a + a % m).
  26270. *
  26271. * r Result of Tripling.
  26272. * a Number to triple in Montgomery form.
  26273. * m Modulus (prime).
  26274. */
  26275. static void sp_384_mont_tpl_15(sp_digit* r, const sp_digit* a, const sp_digit* m)
  26276. {
  26277. sp_digit over;
  26278. (void)sp_384_add_15(r, a, a);
  26279. sp_384_norm_15(r);
  26280. over = r[14] >> 20;
  26281. sp_384_cond_sub_15(r, r, m, ~((over - 1) >> 31));
  26282. sp_384_norm_15(r);
  26283. (void)sp_384_add_15(r, r, a);
  26284. sp_384_norm_15(r);
  26285. over = r[14] >> 20;
  26286. sp_384_cond_sub_15(r, r, m, ~((over - 1) >> 31));
  26287. sp_384_norm_15(r);
  26288. }
  26289. #ifdef WOLFSSL_SP_SMALL
  26290. /* Conditionally add a and b using the mask m.
  26291. * m is -1 to add and 0 when not.
  26292. *
  26293. * r A single precision number representing conditional add result.
  26294. * a A single precision number to add with.
  26295. * b A single precision number to add.
  26296. * m Mask value to apply.
  26297. */
  26298. static void sp_384_cond_add_15(sp_digit* r, const sp_digit* a,
  26299. const sp_digit* b, const sp_digit m)
  26300. {
  26301. int i;
  26302. for (i = 0; i < 15; i++) {
  26303. r[i] = a[i] + (b[i] & m);
  26304. }
  26305. }
  26306. #endif /* WOLFSSL_SP_SMALL */
  26307. #ifndef WOLFSSL_SP_SMALL
  26308. /* Conditionally add a and b using the mask m.
  26309. * m is -1 to add and 0 when not.
  26310. *
  26311. * r A single precision number representing conditional add result.
  26312. * a A single precision number to add with.
  26313. * b A single precision number to add.
  26314. * m Mask value to apply.
  26315. */
  26316. static void sp_384_cond_add_15(sp_digit* r, const sp_digit* a,
  26317. const sp_digit* b, const sp_digit m)
  26318. {
  26319. r[ 0] = a[ 0] + (b[ 0] & m);
  26320. r[ 1] = a[ 1] + (b[ 1] & m);
  26321. r[ 2] = a[ 2] + (b[ 2] & m);
  26322. r[ 3] = a[ 3] + (b[ 3] & m);
  26323. r[ 4] = a[ 4] + (b[ 4] & m);
  26324. r[ 5] = a[ 5] + (b[ 5] & m);
  26325. r[ 6] = a[ 6] + (b[ 6] & m);
  26326. r[ 7] = a[ 7] + (b[ 7] & m);
  26327. r[ 8] = a[ 8] + (b[ 8] & m);
  26328. r[ 9] = a[ 9] + (b[ 9] & m);
  26329. r[10] = a[10] + (b[10] & m);
  26330. r[11] = a[11] + (b[11] & m);
  26331. r[12] = a[12] + (b[12] & m);
  26332. r[13] = a[13] + (b[13] & m);
  26333. r[14] = a[14] + (b[14] & m);
  26334. }
  26335. #endif /* !WOLFSSL_SP_SMALL */
  26336. /* Subtract two Montgomery form numbers (r = a - b % m).
  26337. *
  26338. * r Result of subtration.
  26339. * a Number to subtract from in Montgomery form.
  26340. * b Number to subtract with in Montgomery form.
  26341. * m Modulus (prime).
  26342. */
  26343. static void sp_384_mont_sub_15(sp_digit* r, const sp_digit* a, const sp_digit* b,
  26344. const sp_digit* m)
  26345. {
  26346. (void)sp_384_sub_15(r, a, b);
  26347. sp_384_norm_15(r);
  26348. sp_384_cond_add_15(r, r, m, r[14] >> 20);
  26349. sp_384_norm_15(r);
  26350. }
  26351. /* Shift number left one bit.
  26352. * Bottom bit is lost.
  26353. *
  26354. * r Result of shift.
  26355. * a Number to shift.
  26356. */
  26357. SP_NOINLINE static void sp_384_rshift1_15(sp_digit* r, const sp_digit* a)
  26358. {
  26359. #ifdef WOLFSSL_SP_SMALL
  26360. int i;
  26361. for (i=0; i<14; i++) {
  26362. r[i] = (a[i] >> 1) + ((a[i + 1] << 25) & 0x3ffffff);
  26363. }
  26364. #else
  26365. r[0] = (a[0] >> 1) + ((a[1] << 25) & 0x3ffffff);
  26366. r[1] = (a[1] >> 1) + ((a[2] << 25) & 0x3ffffff);
  26367. r[2] = (a[2] >> 1) + ((a[3] << 25) & 0x3ffffff);
  26368. r[3] = (a[3] >> 1) + ((a[4] << 25) & 0x3ffffff);
  26369. r[4] = (a[4] >> 1) + ((a[5] << 25) & 0x3ffffff);
  26370. r[5] = (a[5] >> 1) + ((a[6] << 25) & 0x3ffffff);
  26371. r[6] = (a[6] >> 1) + ((a[7] << 25) & 0x3ffffff);
  26372. r[7] = (a[7] >> 1) + ((a[8] << 25) & 0x3ffffff);
  26373. r[8] = (a[8] >> 1) + ((a[9] << 25) & 0x3ffffff);
  26374. r[9] = (a[9] >> 1) + ((a[10] << 25) & 0x3ffffff);
  26375. r[10] = (a[10] >> 1) + ((a[11] << 25) & 0x3ffffff);
  26376. r[11] = (a[11] >> 1) + ((a[12] << 25) & 0x3ffffff);
  26377. r[12] = (a[12] >> 1) + ((a[13] << 25) & 0x3ffffff);
  26378. r[13] = (a[13] >> 1) + ((a[14] << 25) & 0x3ffffff);
  26379. #endif
  26380. r[14] = a[14] >> 1;
  26381. }
  26382. /* Divide the number by 2 mod the modulus (prime). (r = a / 2 % m)
  26383. *
  26384. * r Result of division by 2.
  26385. * a Number to divide.
  26386. * m Modulus (prime).
  26387. */
  26388. static void sp_384_mont_div2_15(sp_digit* r, const sp_digit* a,
  26389. const sp_digit* m)
  26390. {
  26391. sp_384_cond_add_15(r, a, m, 0 - (a[0] & 1));
  26392. sp_384_norm_15(r);
  26393. sp_384_rshift1_15(r, r);
  26394. }
  26395. /* Double the Montgomery form projective point p.
  26396. *
  26397. * r Result of doubling point.
  26398. * p Point to double.
  26399. * t Temporary ordinate data.
  26400. */
  26401. static void sp_384_proj_point_dbl_15(sp_point_384* r, const sp_point_384* p,
  26402. sp_digit* t)
  26403. {
  26404. sp_digit* t1 = t;
  26405. sp_digit* t2 = t + 2*15;
  26406. sp_digit* x;
  26407. sp_digit* y;
  26408. sp_digit* z;
  26409. x = r->x;
  26410. y = r->y;
  26411. z = r->z;
  26412. /* Put infinity into result. */
  26413. if (r != p) {
  26414. r->infinity = p->infinity;
  26415. }
  26416. /* T1 = Z * Z */
  26417. sp_384_mont_sqr_15(t1, p->z, p384_mod, p384_mp_mod);
  26418. /* Z = Y * Z */
  26419. sp_384_mont_mul_15(z, p->y, p->z, p384_mod, p384_mp_mod);
  26420. /* Z = 2Z */
  26421. sp_384_mont_dbl_15(z, z, p384_mod);
  26422. /* T2 = X - T1 */
  26423. sp_384_mont_sub_15(t2, p->x, t1, p384_mod);
  26424. /* T1 = X + T1 */
  26425. sp_384_mont_add_15(t1, p->x, t1, p384_mod);
  26426. /* T2 = T1 * T2 */
  26427. sp_384_mont_mul_15(t2, t1, t2, p384_mod, p384_mp_mod);
  26428. /* T1 = 3T2 */
  26429. sp_384_mont_tpl_15(t1, t2, p384_mod);
  26430. /* Y = 2Y */
  26431. sp_384_mont_dbl_15(y, p->y, p384_mod);
  26432. /* Y = Y * Y */
  26433. sp_384_mont_sqr_15(y, y, p384_mod, p384_mp_mod);
  26434. /* T2 = Y * Y */
  26435. sp_384_mont_sqr_15(t2, y, p384_mod, p384_mp_mod);
  26436. /* T2 = T2/2 */
  26437. sp_384_mont_div2_15(t2, t2, p384_mod);
  26438. /* Y = Y * X */
  26439. sp_384_mont_mul_15(y, y, p->x, p384_mod, p384_mp_mod);
  26440. /* X = T1 * T1 */
  26441. sp_384_mont_sqr_15(x, t1, p384_mod, p384_mp_mod);
  26442. /* X = X - Y */
  26443. sp_384_mont_sub_15(x, x, y, p384_mod);
  26444. /* X = X - Y */
  26445. sp_384_mont_sub_15(x, x, y, p384_mod);
  26446. /* Y = Y - X */
  26447. sp_384_mont_sub_15(y, y, x, p384_mod);
  26448. /* Y = Y * T1 */
  26449. sp_384_mont_mul_15(y, y, t1, p384_mod, p384_mp_mod);
  26450. /* Y = Y - T2 */
  26451. sp_384_mont_sub_15(y, y, t2, p384_mod);
  26452. }
  26453. #ifdef WOLFSSL_SP_NONBLOCK
  26454. typedef struct sp_384_proj_point_dbl_15_ctx {
  26455. int state;
  26456. sp_digit* t1;
  26457. sp_digit* t2;
  26458. sp_digit* x;
  26459. sp_digit* y;
  26460. sp_digit* z;
  26461. } sp_384_proj_point_dbl_15_ctx;
  26462. /* Double the Montgomery form projective point p.
  26463. *
  26464. * r Result of doubling point.
  26465. * p Point to double.
  26466. * t Temporary ordinate data.
  26467. */
  26468. static int sp_384_proj_point_dbl_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
  26469. const sp_point_384* p, sp_digit* t)
  26470. {
  26471. int err = FP_WOULDBLOCK;
  26472. sp_384_proj_point_dbl_15_ctx* ctx = (sp_384_proj_point_dbl_15_ctx*)sp_ctx->data;
  26473. typedef char ctx_size_test[sizeof(sp_384_proj_point_dbl_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  26474. (void)sizeof(ctx_size_test);
  26475. switch (ctx->state) {
  26476. case 0:
  26477. ctx->t1 = t;
  26478. ctx->t2 = t + 2*15;
  26479. ctx->x = r->x;
  26480. ctx->y = r->y;
  26481. ctx->z = r->z;
  26482. /* Put infinity into result. */
  26483. if (r != p) {
  26484. r->infinity = p->infinity;
  26485. }
  26486. ctx->state = 1;
  26487. break;
  26488. case 1:
  26489. /* T1 = Z * Z */
  26490. sp_384_mont_sqr_15(ctx->t1, p->z, p384_mod, p384_mp_mod);
  26491. ctx->state = 2;
  26492. break;
  26493. case 2:
  26494. /* Z = Y * Z */
  26495. sp_384_mont_mul_15(ctx->z, p->y, p->z, p384_mod, p384_mp_mod);
  26496. ctx->state = 3;
  26497. break;
  26498. case 3:
  26499. /* Z = 2Z */
  26500. sp_384_mont_dbl_15(ctx->z, ctx->z, p384_mod);
  26501. ctx->state = 4;
  26502. break;
  26503. case 4:
  26504. /* T2 = X - T1 */
  26505. sp_384_mont_sub_15(ctx->t2, p->x, ctx->t1, p384_mod);
  26506. ctx->state = 5;
  26507. break;
  26508. case 5:
  26509. /* T1 = X + T1 */
  26510. sp_384_mont_add_15(ctx->t1, p->x, ctx->t1, p384_mod);
  26511. ctx->state = 6;
  26512. break;
  26513. case 6:
  26514. /* T2 = T1 * T2 */
  26515. sp_384_mont_mul_15(ctx->t2, ctx->t1, ctx->t2, p384_mod, p384_mp_mod);
  26516. ctx->state = 7;
  26517. break;
  26518. case 7:
  26519. /* T1 = 3T2 */
  26520. sp_384_mont_tpl_15(ctx->t1, ctx->t2, p384_mod);
  26521. ctx->state = 8;
  26522. break;
  26523. case 8:
  26524. /* Y = 2Y */
  26525. sp_384_mont_dbl_15(ctx->y, p->y, p384_mod);
  26526. ctx->state = 9;
  26527. break;
  26528. case 9:
  26529. /* Y = Y * Y */
  26530. sp_384_mont_sqr_15(ctx->y, ctx->y, p384_mod, p384_mp_mod);
  26531. ctx->state = 10;
  26532. break;
  26533. case 10:
  26534. /* T2 = Y * Y */
  26535. sp_384_mont_sqr_15(ctx->t2, ctx->y, p384_mod, p384_mp_mod);
  26536. ctx->state = 11;
  26537. break;
  26538. case 11:
  26539. /* T2 = T2/2 */
  26540. sp_384_mont_div2_15(ctx->t2, ctx->t2, p384_mod);
  26541. ctx->state = 12;
  26542. break;
  26543. case 12:
  26544. /* Y = Y * X */
  26545. sp_384_mont_mul_15(ctx->y, ctx->y, p->x, p384_mod, p384_mp_mod);
  26546. ctx->state = 13;
  26547. break;
  26548. case 13:
  26549. /* X = T1 * T1 */
  26550. sp_384_mont_sqr_15(ctx->x, ctx->t1, p384_mod, p384_mp_mod);
  26551. ctx->state = 14;
  26552. break;
  26553. case 14:
  26554. /* X = X - Y */
  26555. sp_384_mont_sub_15(ctx->x, ctx->x, ctx->y, p384_mod);
  26556. ctx->state = 15;
  26557. break;
  26558. case 15:
  26559. /* X = X - Y */
  26560. sp_384_mont_sub_15(ctx->x, ctx->x, ctx->y, p384_mod);
  26561. ctx->state = 16;
  26562. break;
  26563. case 16:
  26564. /* Y = Y - X */
  26565. sp_384_mont_sub_15(ctx->y, ctx->y, ctx->x, p384_mod);
  26566. ctx->state = 17;
  26567. break;
  26568. case 17:
  26569. /* Y = Y * T1 */
  26570. sp_384_mont_mul_15(ctx->y, ctx->y, ctx->t1, p384_mod, p384_mp_mod);
  26571. ctx->state = 18;
  26572. break;
  26573. case 18:
  26574. /* Y = Y - T2 */
  26575. sp_384_mont_sub_15(ctx->y, ctx->y, ctx->t2, p384_mod);
  26576. ctx->state = 19;
  26577. /* fall-through */
  26578. case 19:
  26579. err = MP_OKAY;
  26580. break;
  26581. }
  26582. if (err == MP_OKAY && ctx->state != 19) {
  26583. err = FP_WOULDBLOCK;
  26584. }
  26585. return err;
  26586. }
  26587. #endif /* WOLFSSL_SP_NONBLOCK */
  26588. /* Compare two numbers to determine if they are equal.
  26589. * Constant time implementation.
  26590. *
  26591. * a First number to compare.
  26592. * b Second number to compare.
  26593. * returns 1 when equal and 0 otherwise.
  26594. */
  26595. static int sp_384_cmp_equal_15(const sp_digit* a, const sp_digit* b)
  26596. {
  26597. return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
  26598. (a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
  26599. (a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
  26600. (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
  26601. (a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14])) == 0;
  26602. }
  26603. /* Returns 1 if the number of zero.
  26604. * Implementation is constant time.
  26605. *
  26606. * a Number to check.
  26607. * returns 1 if the number is zero and 0 otherwise.
  26608. */
  26609. static int sp_384_iszero_15(const sp_digit* a)
  26610. {
  26611. return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7] |
  26612. a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14]) == 0;
  26613. }
  26614. /* Add two Montgomery form projective points.
  26615. *
  26616. * r Result of addition.
  26617. * p First point to add.
  26618. * q Second point to add.
  26619. * t Temporary ordinate data.
  26620. */
  26621. static void sp_384_proj_point_add_15(sp_point_384* r,
  26622. const sp_point_384* p, const sp_point_384* q, sp_digit* t)
  26623. {
  26624. sp_digit* t6 = t;
  26625. sp_digit* t1 = t + 2*15;
  26626. sp_digit* t2 = t + 4*15;
  26627. sp_digit* t3 = t + 6*15;
  26628. sp_digit* t4 = t + 8*15;
  26629. sp_digit* t5 = t + 10*15;
  26630. /* U1 = X1*Z2^2 */
  26631. sp_384_mont_sqr_15(t1, q->z, p384_mod, p384_mp_mod);
  26632. sp_384_mont_mul_15(t3, t1, q->z, p384_mod, p384_mp_mod);
  26633. sp_384_mont_mul_15(t1, t1, p->x, p384_mod, p384_mp_mod);
  26634. /* U2 = X2*Z1^2 */
  26635. sp_384_mont_sqr_15(t2, p->z, p384_mod, p384_mp_mod);
  26636. sp_384_mont_mul_15(t4, t2, p->z, p384_mod, p384_mp_mod);
  26637. sp_384_mont_mul_15(t2, t2, q->x, p384_mod, p384_mp_mod);
  26638. /* S1 = Y1*Z2^3 */
  26639. sp_384_mont_mul_15(t3, t3, p->y, p384_mod, p384_mp_mod);
  26640. /* S2 = Y2*Z1^3 */
  26641. sp_384_mont_mul_15(t4, t4, q->y, p384_mod, p384_mp_mod);
  26642. /* Check double */
  26643. if ((~p->infinity) & (~q->infinity) &
  26644. sp_384_cmp_equal_15(t2, t1) &
  26645. sp_384_cmp_equal_15(t4, t3)) {
  26646. sp_384_proj_point_dbl_15(r, p, t);
  26647. }
  26648. else {
  26649. sp_digit* x = t6;
  26650. sp_digit* y = t1;
  26651. sp_digit* z = t2;
  26652. /* H = U2 - U1 */
  26653. sp_384_mont_sub_15(t2, t2, t1, p384_mod);
  26654. /* R = S2 - S1 */
  26655. sp_384_mont_sub_15(t4, t4, t3, p384_mod);
  26656. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  26657. sp_384_mont_sqr_15(t5, t2, p384_mod, p384_mp_mod);
  26658. sp_384_mont_mul_15(y, t1, t5, p384_mod, p384_mp_mod);
  26659. sp_384_mont_mul_15(t5, t5, t2, p384_mod, p384_mp_mod);
  26660. /* Z3 = H*Z1*Z2 */
  26661. sp_384_mont_mul_15(z, p->z, t2, p384_mod, p384_mp_mod);
  26662. sp_384_mont_mul_15(z, z, q->z, p384_mod, p384_mp_mod);
  26663. sp_384_mont_sqr_15(x, t4, p384_mod, p384_mp_mod);
  26664. sp_384_mont_sub_15(x, x, t5, p384_mod);
  26665. sp_384_mont_mul_15(t5, t5, t3, p384_mod, p384_mp_mod);
  26666. sp_384_mont_dbl_15(t3, y, p384_mod);
  26667. sp_384_mont_sub_15(x, x, t3, p384_mod);
  26668. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  26669. sp_384_mont_sub_15(y, y, x, p384_mod);
  26670. sp_384_mont_mul_15(y, y, t4, p384_mod, p384_mp_mod);
  26671. sp_384_mont_sub_15(y, y, t5, p384_mod);
  26672. {
  26673. int i;
  26674. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  26675. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  26676. sp_digit maskt = ~(maskp | maskq);
  26677. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  26678. for (i = 0; i < 15; i++) {
  26679. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  26680. (x[i] & maskt);
  26681. }
  26682. for (i = 0; i < 15; i++) {
  26683. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  26684. (y[i] & maskt);
  26685. }
  26686. for (i = 0; i < 15; i++) {
  26687. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  26688. (z[i] & maskt);
  26689. }
  26690. r->z[0] |= inf;
  26691. r->infinity = (word32)inf;
  26692. }
  26693. }
  26694. }
  26695. #ifdef WOLFSSL_SP_NONBLOCK
  26696. typedef struct sp_384_proj_point_add_15_ctx {
  26697. int state;
  26698. sp_384_proj_point_dbl_15_ctx dbl_ctx;
  26699. const sp_point_384* ap[2];
  26700. sp_point_384* rp[2];
  26701. sp_digit* t1;
  26702. sp_digit* t2;
  26703. sp_digit* t3;
  26704. sp_digit* t4;
  26705. sp_digit* t5;
  26706. sp_digit* t6;
  26707. sp_digit* x;
  26708. sp_digit* y;
  26709. sp_digit* z;
  26710. } sp_384_proj_point_add_15_ctx;
  26711. /* Add two Montgomery form projective points.
  26712. *
  26713. * r Result of addition.
  26714. * p First point to add.
  26715. * q Second point to add.
  26716. * t Temporary ordinate data.
  26717. */
  26718. static int sp_384_proj_point_add_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
  26719. const sp_point_384* p, const sp_point_384* q, sp_digit* t)
  26720. {
  26721. int err = FP_WOULDBLOCK;
  26722. sp_384_proj_point_add_15_ctx* ctx = (sp_384_proj_point_add_15_ctx*)sp_ctx->data;
  26723. /* Ensure only the first point is the same as the result. */
  26724. if (q == r) {
  26725. const sp_point_384* a = p;
  26726. p = q;
  26727. q = a;
  26728. }
  26729. typedef char ctx_size_test[sizeof(sp_384_proj_point_add_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  26730. (void)sizeof(ctx_size_test);
  26731. switch (ctx->state) {
  26732. case 0: /* INIT */
  26733. ctx->t6 = t;
  26734. ctx->t1 = t + 2*15;
  26735. ctx->t2 = t + 4*15;
  26736. ctx->t3 = t + 6*15;
  26737. ctx->t4 = t + 8*15;
  26738. ctx->t5 = t + 10*15;
  26739. ctx->x = ctx->t6;
  26740. ctx->y = ctx->t1;
  26741. ctx->z = ctx->t2;
  26742. ctx->state = 1;
  26743. break;
  26744. case 1:
  26745. /* U1 = X1*Z2^2 */
  26746. sp_384_mont_sqr_15(ctx->t1, q->z, p384_mod, p384_mp_mod);
  26747. ctx->state = 2;
  26748. break;
  26749. case 2:
  26750. sp_384_mont_mul_15(ctx->t3, ctx->t1, q->z, p384_mod, p384_mp_mod);
  26751. ctx->state = 3;
  26752. break;
  26753. case 3:
  26754. sp_384_mont_mul_15(ctx->t1, ctx->t1, p->x, p384_mod, p384_mp_mod);
  26755. ctx->state = 4;
  26756. break;
  26757. case 4:
  26758. /* U2 = X2*Z1^2 */
  26759. sp_384_mont_sqr_15(ctx->t2, p->z, p384_mod, p384_mp_mod);
  26760. ctx->state = 5;
  26761. break;
  26762. case 5:
  26763. sp_384_mont_mul_15(ctx->t4, ctx->t2, p->z, p384_mod, p384_mp_mod);
  26764. ctx->state = 6;
  26765. break;
  26766. case 6:
  26767. sp_384_mont_mul_15(ctx->t2, ctx->t2, q->x, p384_mod, p384_mp_mod);
  26768. ctx->state = 7;
  26769. break;
  26770. case 7:
  26771. /* S1 = Y1*Z2^3 */
  26772. sp_384_mont_mul_15(ctx->t3, ctx->t3, p->y, p384_mod, p384_mp_mod);
  26773. ctx->state = 8;
  26774. break;
  26775. case 8:
  26776. /* S2 = Y2*Z1^3 */
  26777. sp_384_mont_mul_15(ctx->t4, ctx->t4, q->y, p384_mod, p384_mp_mod);
  26778. ctx->state = 9;
  26779. break;
  26780. case 9:
  26781. /* Check double */
  26782. if ((~p->infinity) & (~q->infinity) &
  26783. sp_384_cmp_equal_15(ctx->t2, ctx->t1) &
  26784. sp_384_cmp_equal_15(ctx->t4, ctx->t3)) {
  26785. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  26786. sp_384_proj_point_dbl_15(r, p, t);
  26787. ctx->state = 25;
  26788. }
  26789. else {
  26790. ctx->state = 10;
  26791. }
  26792. break;
  26793. case 10:
  26794. /* H = U2 - U1 */
  26795. sp_384_mont_sub_15(ctx->t2, ctx->t2, ctx->t1, p384_mod);
  26796. ctx->state = 11;
  26797. break;
  26798. case 11:
  26799. /* R = S2 - S1 */
  26800. sp_384_mont_sub_15(ctx->t4, ctx->t4, ctx->t3, p384_mod);
  26801. ctx->state = 12;
  26802. break;
  26803. case 12:
  26804. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  26805. sp_384_mont_sqr_15(ctx->t5, ctx->t2, p384_mod, p384_mp_mod);
  26806. ctx->state = 13;
  26807. break;
  26808. case 13:
  26809. sp_384_mont_mul_15(ctx->y, ctx->t1, ctx->t5, p384_mod, p384_mp_mod);
  26810. ctx->state = 14;
  26811. break;
  26812. case 14:
  26813. sp_384_mont_mul_15(ctx->t5, ctx->t5, ctx->t2, p384_mod, p384_mp_mod);
  26814. ctx->state = 15;
  26815. break;
  26816. case 15:
  26817. /* Z3 = H*Z1*Z2 */
  26818. sp_384_mont_mul_15(ctx->z, p->z, ctx->t2, p384_mod, p384_mp_mod);
  26819. ctx->state = 16;
  26820. break;
  26821. case 16:
  26822. sp_384_mont_mul_15(ctx->z, ctx->z, q->z, p384_mod, p384_mp_mod);
  26823. ctx->state = 17;
  26824. break;
  26825. case 17:
  26826. sp_384_mont_sqr_15(ctx->x, ctx->t4, p384_mod, p384_mp_mod);
  26827. ctx->state = 18;
  26828. break;
  26829. case 18:
  26830. sp_384_mont_sub_15(ctx->x, ctx->x, ctx->t5, p384_mod);
  26831. ctx->state = 19;
  26832. break;
  26833. case 19:
  26834. sp_384_mont_mul_15(ctx->t5, ctx->t5, ctx->t3, p384_mod, p384_mp_mod);
  26835. ctx->state = 20;
  26836. break;
  26837. case 20:
  26838. sp_384_mont_dbl_15(ctx->t3, ctx->y, p384_mod);
  26839. sp_384_mont_sub_15(ctx->x, ctx->x, ctx->t3, p384_mod);
  26840. ctx->state = 21;
  26841. break;
  26842. case 21:
  26843. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  26844. sp_384_mont_sub_15(ctx->y, ctx->y, ctx->x, p384_mod);
  26845. ctx->state = 22;
  26846. break;
  26847. case 22:
  26848. sp_384_mont_mul_15(ctx->y, ctx->y, ctx->t4, p384_mod, p384_mp_mod);
  26849. ctx->state = 23;
  26850. break;
  26851. case 23:
  26852. sp_384_mont_sub_15(ctx->y, ctx->y, ctx->t5, p384_mod);
  26853. ctx->state = 24;
  26854. break;
  26855. case 24:
  26856. {
  26857. {
  26858. int i;
  26859. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  26860. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  26861. sp_digit maskt = ~(maskp | maskq);
  26862. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  26863. for (i = 0; i < 15; i++) {
  26864. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  26865. (ctx->x[i] & maskt);
  26866. }
  26867. for (i = 0; i < 15; i++) {
  26868. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  26869. (ctx->y[i] & maskt);
  26870. }
  26871. for (i = 0; i < 15; i++) {
  26872. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  26873. (ctx->z[i] & maskt);
  26874. }
  26875. r->z[0] |= inf;
  26876. r->infinity = (word32)inf;
  26877. }
  26878. ctx->state = 25;
  26879. break;
  26880. }
  26881. case 25:
  26882. err = MP_OKAY;
  26883. break;
  26884. }
  26885. if (err == MP_OKAY && ctx->state != 25) {
  26886. err = FP_WOULDBLOCK;
  26887. }
  26888. return err;
  26889. }
  26890. #endif /* WOLFSSL_SP_NONBLOCK */
  26891. /* Multiply a number by Montgomery normalizer mod modulus (prime).
  26892. *
  26893. * r The resulting Montgomery form number.
  26894. * a The number to convert.
  26895. * m The modulus (prime).
  26896. * returns MEMORY_E when memory allocation fails and MP_OKAY otherwise.
  26897. */
  26898. static int sp_384_mod_mul_norm_15(sp_digit* r, const sp_digit* a, const sp_digit* m)
  26899. {
  26900. #ifdef WOLFSSL_SP_SMALL_STACK
  26901. int64_t* t = NULL;
  26902. #else
  26903. int64_t t[2 * 12];
  26904. #endif
  26905. int64_t* a32 = NULL;
  26906. int64_t o;
  26907. int err = MP_OKAY;
  26908. (void)m;
  26909. #ifdef WOLFSSL_SP_SMALL_STACK
  26910. t = (int64_t*)XMALLOC(sizeof(int64_t) * 2 * 12, NULL, DYNAMIC_TYPE_ECC);
  26911. if (t == NULL)
  26912. err = MEMORY_E;
  26913. #endif
  26914. if (err == MP_OKAY) {
  26915. a32 = t + 12;
  26916. a32[0] = a[0];
  26917. a32[0] |= a[1] << 26U;
  26918. a32[0] &= 0xffffffffL;
  26919. a32[1] = (a[1] >> 6);
  26920. a32[1] |= a[2] << 20U;
  26921. a32[1] &= 0xffffffffL;
  26922. a32[2] = (a[2] >> 12);
  26923. a32[2] |= a[3] << 14U;
  26924. a32[2] &= 0xffffffffL;
  26925. a32[3] = (a[3] >> 18);
  26926. a32[3] |= a[4] << 8U;
  26927. a32[3] &= 0xffffffffL;
  26928. a32[4] = (a[4] >> 24);
  26929. a32[4] |= a[5] << 2U;
  26930. a32[4] |= a[6] << 28U;
  26931. a32[4] &= 0xffffffffL;
  26932. a32[5] = (a[6] >> 4);
  26933. a32[5] |= a[7] << 22U;
  26934. a32[5] &= 0xffffffffL;
  26935. a32[6] = (a[7] >> 10);
  26936. a32[6] |= a[8] << 16U;
  26937. a32[6] &= 0xffffffffL;
  26938. a32[7] = (a[8] >> 16);
  26939. a32[7] |= a[9] << 10U;
  26940. a32[7] &= 0xffffffffL;
  26941. a32[8] = (a[9] >> 22);
  26942. a32[8] |= a[10] << 4U;
  26943. a32[8] |= a[11] << 30U;
  26944. a32[8] &= 0xffffffffL;
  26945. a32[9] = (a[11] >> 2);
  26946. a32[9] |= a[12] << 24U;
  26947. a32[9] &= 0xffffffffL;
  26948. a32[10] = (a[12] >> 8);
  26949. a32[10] |= a[13] << 18U;
  26950. a32[10] &= 0xffffffffL;
  26951. a32[11] = (a[13] >> 14);
  26952. a32[11] |= a[14] << 12U;
  26953. a32[11] &= 0xffffffffL;
  26954. /* 1 0 0 0 0 0 0 0 1 1 0 -1 */
  26955. t[0] = 0 + a32[0] + a32[8] + a32[9] - a32[11];
  26956. /* -1 1 0 0 0 0 0 0 -1 0 1 1 */
  26957. t[1] = 0 - a32[0] + a32[1] - a32[8] + a32[10] + a32[11];
  26958. /* 0 -1 1 0 0 0 0 0 0 -1 0 1 */
  26959. t[2] = 0 - a32[1] + a32[2] - a32[9] + a32[11];
  26960. /* 1 0 -1 1 0 0 0 0 1 1 -1 -1 */
  26961. t[3] = 0 + a32[0] - a32[2] + a32[3] + a32[8] + a32[9] - a32[10] - a32[11];
  26962. /* 1 1 0 -1 1 0 0 0 1 2 1 -2 */
  26963. t[4] = 0 + a32[0] + a32[1] - a32[3] + a32[4] + a32[8] + 2 * a32[9] + a32[10] - 2 * a32[11];
  26964. /* 0 1 1 0 -1 1 0 0 0 1 2 1 */
  26965. t[5] = 0 + a32[1] + a32[2] - a32[4] + a32[5] + a32[9] + 2 * a32[10] + a32[11];
  26966. /* 0 0 1 1 0 -1 1 0 0 0 1 2 */
  26967. t[6] = 0 + a32[2] + a32[3] - a32[5] + a32[6] + a32[10] + 2 * a32[11];
  26968. /* 0 0 0 1 1 0 -1 1 0 0 0 1 */
  26969. t[7] = 0 + a32[3] + a32[4] - a32[6] + a32[7] + a32[11];
  26970. /* 0 0 0 0 1 1 0 -1 1 0 0 0 */
  26971. t[8] = 0 + a32[4] + a32[5] - a32[7] + a32[8];
  26972. /* 0 0 0 0 0 1 1 0 -1 1 0 0 */
  26973. t[9] = 0 + a32[5] + a32[6] - a32[8] + a32[9];
  26974. /* 0 0 0 0 0 0 1 1 0 -1 1 0 */
  26975. t[10] = 0 + a32[6] + a32[7] - a32[9] + a32[10];
  26976. /* 0 0 0 0 0 0 0 1 1 0 -1 1 */
  26977. t[11] = 0 + a32[7] + a32[8] - a32[10] + a32[11];
  26978. t[1] += t[0] >> 32; t[0] &= 0xffffffff;
  26979. t[2] += t[1] >> 32; t[1] &= 0xffffffff;
  26980. t[3] += t[2] >> 32; t[2] &= 0xffffffff;
  26981. t[4] += t[3] >> 32; t[3] &= 0xffffffff;
  26982. t[5] += t[4] >> 32; t[4] &= 0xffffffff;
  26983. t[6] += t[5] >> 32; t[5] &= 0xffffffff;
  26984. t[7] += t[6] >> 32; t[6] &= 0xffffffff;
  26985. t[8] += t[7] >> 32; t[7] &= 0xffffffff;
  26986. t[9] += t[8] >> 32; t[8] &= 0xffffffff;
  26987. t[10] += t[9] >> 32; t[9] &= 0xffffffff;
  26988. t[11] += t[10] >> 32; t[10] &= 0xffffffff;
  26989. o = t[11] >> 32; t[11] &= 0xffffffff;
  26990. t[0] += o;
  26991. t[1] -= o;
  26992. t[3] += o;
  26993. t[4] += o;
  26994. t[1] += t[0] >> 32; t[0] &= 0xffffffff;
  26995. t[2] += t[1] >> 32; t[1] &= 0xffffffff;
  26996. t[3] += t[2] >> 32; t[2] &= 0xffffffff;
  26997. t[4] += t[3] >> 32; t[3] &= 0xffffffff;
  26998. t[5] += t[4] >> 32; t[4] &= 0xffffffff;
  26999. t[6] += t[5] >> 32; t[5] &= 0xffffffff;
  27000. t[7] += t[6] >> 32; t[6] &= 0xffffffff;
  27001. t[8] += t[7] >> 32; t[7] &= 0xffffffff;
  27002. t[9] += t[8] >> 32; t[8] &= 0xffffffff;
  27003. t[10] += t[9] >> 32; t[9] &= 0xffffffff;
  27004. t[11] += t[10] >> 32; t[10] &= 0xffffffff;
  27005. r[0] = (sp_digit)(t[0]) & 0x3ffffffL;
  27006. r[1] = (sp_digit)(t[0] >> 26U);
  27007. r[1] |= (sp_digit)(t[1] << 6U);
  27008. r[1] &= 0x3ffffffL;
  27009. r[2] = (sp_digit)(t[1] >> 20U);
  27010. r[2] |= (sp_digit)(t[2] << 12U);
  27011. r[2] &= 0x3ffffffL;
  27012. r[3] = (sp_digit)(t[2] >> 14U);
  27013. r[3] |= (sp_digit)(t[3] << 18U);
  27014. r[3] &= 0x3ffffffL;
  27015. r[4] = (sp_digit)(t[3] >> 8U);
  27016. r[4] |= (sp_digit)(t[4] << 24U);
  27017. r[4] &= 0x3ffffffL;
  27018. r[5] = (sp_digit)(t[4] >> 2U) & 0x3ffffffL;
  27019. r[6] = (sp_digit)(t[4] >> 28U);
  27020. r[6] |= (sp_digit)(t[5] << 4U);
  27021. r[6] &= 0x3ffffffL;
  27022. r[7] = (sp_digit)(t[5] >> 22U);
  27023. r[7] |= (sp_digit)(t[6] << 10U);
  27024. r[7] &= 0x3ffffffL;
  27025. r[8] = (sp_digit)(t[6] >> 16U);
  27026. r[8] |= (sp_digit)(t[7] << 16U);
  27027. r[8] &= 0x3ffffffL;
  27028. r[9] = (sp_digit)(t[7] >> 10U);
  27029. r[9] |= (sp_digit)(t[8] << 22U);
  27030. r[9] &= 0x3ffffffL;
  27031. r[10] = (sp_digit)(t[8] >> 4U) & 0x3ffffffL;
  27032. r[11] = (sp_digit)(t[8] >> 30U);
  27033. r[11] |= (sp_digit)(t[9] << 2U);
  27034. r[11] &= 0x3ffffffL;
  27035. r[12] = (sp_digit)(t[9] >> 24U);
  27036. r[12] |= (sp_digit)(t[10] << 8U);
  27037. r[12] &= 0x3ffffffL;
  27038. r[13] = (sp_digit)(t[10] >> 18U);
  27039. r[13] |= (sp_digit)(t[11] << 14U);
  27040. r[13] &= 0x3ffffffL;
  27041. r[14] = (sp_digit)(t[11] >> 12U);
  27042. }
  27043. #ifdef WOLFSSL_SP_SMALL_STACK
  27044. if (t != NULL)
  27045. XFREE(t, NULL, DYNAMIC_TYPE_ECC);
  27046. #endif
  27047. return err;
  27048. }
  27049. #ifdef WOLFSSL_SP_SMALL
  27050. /* Multiply the point by the scalar and return the result.
  27051. * If map is true then convert result to affine coordinates.
  27052. *
  27053. * Small implementation using add and double that is cache attack resistant but
  27054. * allocates memory rather than use large stacks.
  27055. * 384 adds and doubles.
  27056. *
  27057. * r Resulting point.
  27058. * g Point to multiply.
  27059. * k Scalar to multiply by.
  27060. * map Indicates whether to convert result to affine.
  27061. * ct Constant time required.
  27062. * heap Heap to use for allocation.
  27063. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  27064. */
  27065. static int sp_384_ecc_mulmod_15(sp_point_384* r, const sp_point_384* g,
  27066. const sp_digit* k, int map, int ct, void* heap)
  27067. {
  27068. #ifdef WOLFSSL_SP_SMALL_STACK
  27069. sp_point_384* t = NULL;
  27070. sp_digit* tmp = NULL;
  27071. #else
  27072. sp_point_384 t[3];
  27073. sp_digit tmp[2 * 15 * 6];
  27074. #endif
  27075. sp_digit n;
  27076. int i;
  27077. int c;
  27078. int y;
  27079. int err = MP_OKAY;
  27080. /* Implementation is constant time. */
  27081. (void)ct;
  27082. (void)heap;
  27083. #ifdef WOLFSSL_SP_SMALL_STACK
  27084. t = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 3, heap,
  27085. DYNAMIC_TYPE_ECC);
  27086. if (t == NULL)
  27087. err = MEMORY_E;
  27088. if (err == MP_OKAY) {
  27089. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 6, heap,
  27090. DYNAMIC_TYPE_ECC);
  27091. if (tmp == NULL)
  27092. err = MEMORY_E;
  27093. }
  27094. #endif
  27095. if (err == MP_OKAY) {
  27096. XMEMSET(t, 0, sizeof(sp_point_384) * 3);
  27097. /* t[0] = {0, 0, 1} * norm */
  27098. t[0].infinity = 1;
  27099. /* t[1] = {g->x, g->y, g->z} * norm */
  27100. err = sp_384_mod_mul_norm_15(t[1].x, g->x, p384_mod);
  27101. }
  27102. if (err == MP_OKAY)
  27103. err = sp_384_mod_mul_norm_15(t[1].y, g->y, p384_mod);
  27104. if (err == MP_OKAY)
  27105. err = sp_384_mod_mul_norm_15(t[1].z, g->z, p384_mod);
  27106. if (err == MP_OKAY) {
  27107. i = 14;
  27108. c = 20;
  27109. n = k[i--] << (26 - c);
  27110. for (; ; c--) {
  27111. if (c == 0) {
  27112. if (i == -1)
  27113. break;
  27114. n = k[i--];
  27115. c = 26;
  27116. }
  27117. y = (n >> 25) & 1;
  27118. n <<= 1;
  27119. sp_384_proj_point_add_15(&t[y^1], &t[0], &t[1], tmp);
  27120. XMEMCPY(&t[2], (void*)(((size_t)&t[0] & addr_mask[y^1]) +
  27121. ((size_t)&t[1] & addr_mask[y])),
  27122. sizeof(sp_point_384));
  27123. sp_384_proj_point_dbl_15(&t[2], &t[2], tmp);
  27124. XMEMCPY((void*)(((size_t)&t[0] & addr_mask[y^1]) +
  27125. ((size_t)&t[1] & addr_mask[y])), &t[2],
  27126. sizeof(sp_point_384));
  27127. }
  27128. if (map != 0) {
  27129. sp_384_map_15(r, &t[0], tmp);
  27130. }
  27131. else {
  27132. XMEMCPY(r, &t[0], sizeof(sp_point_384));
  27133. }
  27134. }
  27135. #ifdef WOLFSSL_SP_SMALL_STACK
  27136. if (tmp != NULL)
  27137. #endif
  27138. {
  27139. ForceZero(tmp, sizeof(sp_digit) * 2 * 15 * 6);
  27140. #ifdef WOLFSSL_SP_SMALL_STACK
  27141. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  27142. #endif
  27143. }
  27144. #ifdef WOLFSSL_SP_SMALL_STACK
  27145. if (t != NULL)
  27146. #endif
  27147. {
  27148. ForceZero(t, sizeof(sp_point_384) * 3);
  27149. #ifdef WOLFSSL_SP_SMALL_STACK
  27150. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  27151. #endif
  27152. }
  27153. return err;
  27154. }
  27155. #ifdef WOLFSSL_SP_NONBLOCK
  27156. typedef struct sp_384_ecc_mulmod_15_ctx {
  27157. int state;
  27158. union {
  27159. sp_384_proj_point_dbl_15_ctx dbl_ctx;
  27160. sp_384_proj_point_add_15_ctx add_ctx;
  27161. };
  27162. sp_point_384 t[3];
  27163. sp_digit tmp[2 * 15 * 6];
  27164. sp_digit n;
  27165. int i;
  27166. int c;
  27167. int y;
  27168. } sp_384_ecc_mulmod_15_ctx;
  27169. static int sp_384_ecc_mulmod_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
  27170. const sp_point_384* g, const sp_digit* k, int map, int ct, void* heap)
  27171. {
  27172. int err = FP_WOULDBLOCK;
  27173. sp_384_ecc_mulmod_15_ctx* ctx = (sp_384_ecc_mulmod_15_ctx*)sp_ctx->data;
  27174. typedef char ctx_size_test[sizeof(sp_384_ecc_mulmod_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  27175. (void)sizeof(ctx_size_test);
  27176. /* Implementation is constant time. */
  27177. (void)ct;
  27178. switch (ctx->state) {
  27179. case 0: /* INIT */
  27180. XMEMSET(ctx->t, 0, sizeof(sp_point_384) * 3);
  27181. ctx->i = 14;
  27182. ctx->c = 20;
  27183. ctx->n = k[ctx->i--] << (26 - ctx->c);
  27184. /* t[0] = {0, 0, 1} * norm */
  27185. ctx->t[0].infinity = 1;
  27186. ctx->state = 1;
  27187. break;
  27188. case 1: /* T1X */
  27189. /* t[1] = {g->x, g->y, g->z} * norm */
  27190. err = sp_384_mod_mul_norm_15(ctx->t[1].x, g->x, p384_mod);
  27191. ctx->state = 2;
  27192. break;
  27193. case 2: /* T1Y */
  27194. err = sp_384_mod_mul_norm_15(ctx->t[1].y, g->y, p384_mod);
  27195. ctx->state = 3;
  27196. break;
  27197. case 3: /* T1Z */
  27198. err = sp_384_mod_mul_norm_15(ctx->t[1].z, g->z, p384_mod);
  27199. ctx->state = 4;
  27200. break;
  27201. case 4: /* ADDPREP */
  27202. if (ctx->c == 0) {
  27203. if (ctx->i == -1) {
  27204. ctx->state = 7;
  27205. break;
  27206. }
  27207. ctx->n = k[ctx->i--];
  27208. ctx->c = 26;
  27209. }
  27210. ctx->y = (ctx->n >> 25) & 1;
  27211. ctx->n <<= 1;
  27212. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  27213. ctx->state = 5;
  27214. break;
  27215. case 5: /* ADD */
  27216. err = sp_384_proj_point_add_15_nb((sp_ecc_ctx_t*)&ctx->add_ctx,
  27217. &ctx->t[ctx->y^1], &ctx->t[0], &ctx->t[1], ctx->tmp);
  27218. if (err == MP_OKAY) {
  27219. XMEMCPY(&ctx->t[2], (void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  27220. ((size_t)&ctx->t[1] & addr_mask[ctx->y])),
  27221. sizeof(sp_point_384));
  27222. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  27223. ctx->state = 6;
  27224. }
  27225. break;
  27226. case 6: /* DBL */
  27227. err = sp_384_proj_point_dbl_15_nb((sp_ecc_ctx_t*)&ctx->dbl_ctx, &ctx->t[2],
  27228. &ctx->t[2], ctx->tmp);
  27229. if (err == MP_OKAY) {
  27230. XMEMCPY((void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  27231. ((size_t)&ctx->t[1] & addr_mask[ctx->y])), &ctx->t[2],
  27232. sizeof(sp_point_384));
  27233. ctx->state = 4;
  27234. ctx->c--;
  27235. }
  27236. break;
  27237. case 7: /* MAP */
  27238. if (map != 0) {
  27239. sp_384_map_15(r, &ctx->t[0], ctx->tmp);
  27240. }
  27241. else {
  27242. XMEMCPY(r, &ctx->t[0], sizeof(sp_point_384));
  27243. }
  27244. err = MP_OKAY;
  27245. break;
  27246. }
  27247. if (err == MP_OKAY && ctx->state != 7) {
  27248. err = FP_WOULDBLOCK;
  27249. }
  27250. if (err != FP_WOULDBLOCK) {
  27251. ForceZero(ctx->tmp, sizeof(ctx->tmp));
  27252. ForceZero(ctx->t, sizeof(ctx->t));
  27253. }
  27254. (void)heap;
  27255. return err;
  27256. }
  27257. #endif /* WOLFSSL_SP_NONBLOCK */
  27258. #else
  27259. /* A table entry for pre-computed points. */
  27260. typedef struct sp_table_entry_384 {
  27261. sp_digit x[15];
  27262. sp_digit y[15];
  27263. } sp_table_entry_384;
  27264. /* Conditionally copy a into r using the mask m.
  27265. * m is -1 to copy and 0 when not.
  27266. *
  27267. * r A single precision number to copy over.
  27268. * a A single precision number to copy.
  27269. * m Mask value to apply.
  27270. */
  27271. static void sp_384_cond_copy_15(sp_digit* r, const sp_digit* a, const sp_digit m)
  27272. {
  27273. sp_digit t[15];
  27274. #ifdef WOLFSSL_SP_SMALL
  27275. int i;
  27276. for (i = 0; i < 15; i++) {
  27277. t[i] = r[i] ^ a[i];
  27278. }
  27279. for (i = 0; i < 15; i++) {
  27280. r[i] ^= t[i] & m;
  27281. }
  27282. #else
  27283. t[ 0] = r[ 0] ^ a[ 0];
  27284. t[ 1] = r[ 1] ^ a[ 1];
  27285. t[ 2] = r[ 2] ^ a[ 2];
  27286. t[ 3] = r[ 3] ^ a[ 3];
  27287. t[ 4] = r[ 4] ^ a[ 4];
  27288. t[ 5] = r[ 5] ^ a[ 5];
  27289. t[ 6] = r[ 6] ^ a[ 6];
  27290. t[ 7] = r[ 7] ^ a[ 7];
  27291. t[ 8] = r[ 8] ^ a[ 8];
  27292. t[ 9] = r[ 9] ^ a[ 9];
  27293. t[10] = r[10] ^ a[10];
  27294. t[11] = r[11] ^ a[11];
  27295. t[12] = r[12] ^ a[12];
  27296. t[13] = r[13] ^ a[13];
  27297. t[14] = r[14] ^ a[14];
  27298. r[ 0] ^= t[ 0] & m;
  27299. r[ 1] ^= t[ 1] & m;
  27300. r[ 2] ^= t[ 2] & m;
  27301. r[ 3] ^= t[ 3] & m;
  27302. r[ 4] ^= t[ 4] & m;
  27303. r[ 5] ^= t[ 5] & m;
  27304. r[ 6] ^= t[ 6] & m;
  27305. r[ 7] ^= t[ 7] & m;
  27306. r[ 8] ^= t[ 8] & m;
  27307. r[ 9] ^= t[ 9] & m;
  27308. r[10] ^= t[10] & m;
  27309. r[11] ^= t[11] & m;
  27310. r[12] ^= t[12] & m;
  27311. r[13] ^= t[13] & m;
  27312. r[14] ^= t[14] & m;
  27313. #endif /* WOLFSSL_SP_SMALL */
  27314. }
  27315. /* Double the Montgomery form projective point p a number of times.
  27316. *
  27317. * r Result of repeated doubling of point.
  27318. * p Point to double.
  27319. * n Number of times to double
  27320. * t Temporary ordinate data.
  27321. */
  27322. static void sp_384_proj_point_dbl_n_15(sp_point_384* p, int i,
  27323. sp_digit* t)
  27324. {
  27325. sp_digit* w = t;
  27326. sp_digit* a = t + 2*15;
  27327. sp_digit* b = t + 4*15;
  27328. sp_digit* t1 = t + 6*15;
  27329. sp_digit* t2 = t + 8*15;
  27330. sp_digit* x;
  27331. sp_digit* y;
  27332. sp_digit* z;
  27333. volatile int n = i;
  27334. x = p->x;
  27335. y = p->y;
  27336. z = p->z;
  27337. /* Y = 2*Y */
  27338. sp_384_mont_dbl_15(y, y, p384_mod);
  27339. /* W = Z^4 */
  27340. sp_384_mont_sqr_15(w, z, p384_mod, p384_mp_mod);
  27341. sp_384_mont_sqr_15(w, w, p384_mod, p384_mp_mod);
  27342. #ifndef WOLFSSL_SP_SMALL
  27343. while (--n > 0)
  27344. #else
  27345. while (--n >= 0)
  27346. #endif
  27347. {
  27348. /* A = 3*(X^2 - W) */
  27349. sp_384_mont_sqr_15(t1, x, p384_mod, p384_mp_mod);
  27350. sp_384_mont_sub_15(t1, t1, w, p384_mod);
  27351. sp_384_mont_tpl_15(a, t1, p384_mod);
  27352. /* B = X*Y^2 */
  27353. sp_384_mont_sqr_15(t1, y, p384_mod, p384_mp_mod);
  27354. sp_384_mont_mul_15(b, t1, x, p384_mod, p384_mp_mod);
  27355. /* X = A^2 - 2B */
  27356. sp_384_mont_sqr_15(x, a, p384_mod, p384_mp_mod);
  27357. sp_384_mont_dbl_15(t2, b, p384_mod);
  27358. sp_384_mont_sub_15(x, x, t2, p384_mod);
  27359. /* B = 2.(B - X) */
  27360. sp_384_mont_sub_15(t2, b, x, p384_mod);
  27361. sp_384_mont_dbl_15(b, t2, p384_mod);
  27362. /* Z = Z*Y */
  27363. sp_384_mont_mul_15(z, z, y, p384_mod, p384_mp_mod);
  27364. /* t1 = Y^4 */
  27365. sp_384_mont_sqr_15(t1, t1, p384_mod, p384_mp_mod);
  27366. #ifdef WOLFSSL_SP_SMALL
  27367. if (n != 0)
  27368. #endif
  27369. {
  27370. /* W = W*Y^4 */
  27371. sp_384_mont_mul_15(w, w, t1, p384_mod, p384_mp_mod);
  27372. }
  27373. /* y = 2*A*(B - X) - Y^4 */
  27374. sp_384_mont_mul_15(y, b, a, p384_mod, p384_mp_mod);
  27375. sp_384_mont_sub_15(y, y, t1, p384_mod);
  27376. }
  27377. #ifndef WOLFSSL_SP_SMALL
  27378. /* A = 3*(X^2 - W) */
  27379. sp_384_mont_sqr_15(t1, x, p384_mod, p384_mp_mod);
  27380. sp_384_mont_sub_15(t1, t1, w, p384_mod);
  27381. sp_384_mont_tpl_15(a, t1, p384_mod);
  27382. /* B = X*Y^2 */
  27383. sp_384_mont_sqr_15(t1, y, p384_mod, p384_mp_mod);
  27384. sp_384_mont_mul_15(b, t1, x, p384_mod, p384_mp_mod);
  27385. /* X = A^2 - 2B */
  27386. sp_384_mont_sqr_15(x, a, p384_mod, p384_mp_mod);
  27387. sp_384_mont_dbl_15(t2, b, p384_mod);
  27388. sp_384_mont_sub_15(x, x, t2, p384_mod);
  27389. /* B = 2.(B - X) */
  27390. sp_384_mont_sub_15(t2, b, x, p384_mod);
  27391. sp_384_mont_dbl_15(b, t2, p384_mod);
  27392. /* Z = Z*Y */
  27393. sp_384_mont_mul_15(z, z, y, p384_mod, p384_mp_mod);
  27394. /* t1 = Y^4 */
  27395. sp_384_mont_sqr_15(t1, t1, p384_mod, p384_mp_mod);
  27396. /* y = 2*A*(B - X) - Y^4 */
  27397. sp_384_mont_mul_15(y, b, a, p384_mod, p384_mp_mod);
  27398. sp_384_mont_sub_15(y, y, t1, p384_mod);
  27399. #endif /* WOLFSSL_SP_SMALL */
  27400. /* Y = Y/2 */
  27401. sp_384_mont_div2_15(y, y, p384_mod);
  27402. }
  27403. /* Double the Montgomery form projective point p a number of times.
  27404. *
  27405. * r Result of repeated doubling of point.
  27406. * p Point to double.
  27407. * n Number of times to double
  27408. * t Temporary ordinate data.
  27409. */
  27410. static void sp_384_proj_point_dbl_n_store_15(sp_point_384* r,
  27411. const sp_point_384* p, int n, int m, sp_digit* t)
  27412. {
  27413. sp_digit* w = t;
  27414. sp_digit* a = t + 2*15;
  27415. sp_digit* b = t + 4*15;
  27416. sp_digit* t1 = t + 6*15;
  27417. sp_digit* t2 = t + 8*15;
  27418. sp_digit* x = r[2*m].x;
  27419. sp_digit* y = r[(1<<n)*m].y;
  27420. sp_digit* z = r[2*m].z;
  27421. int i;
  27422. int j;
  27423. for (i=0; i<15; i++) {
  27424. x[i] = p->x[i];
  27425. }
  27426. for (i=0; i<15; i++) {
  27427. y[i] = p->y[i];
  27428. }
  27429. for (i=0; i<15; i++) {
  27430. z[i] = p->z[i];
  27431. }
  27432. /* Y = 2*Y */
  27433. sp_384_mont_dbl_15(y, y, p384_mod);
  27434. /* W = Z^4 */
  27435. sp_384_mont_sqr_15(w, z, p384_mod, p384_mp_mod);
  27436. sp_384_mont_sqr_15(w, w, p384_mod, p384_mp_mod);
  27437. j = m;
  27438. for (i=1; i<=n; i++) {
  27439. j *= 2;
  27440. /* A = 3*(X^2 - W) */
  27441. sp_384_mont_sqr_15(t1, x, p384_mod, p384_mp_mod);
  27442. sp_384_mont_sub_15(t1, t1, w, p384_mod);
  27443. sp_384_mont_tpl_15(a, t1, p384_mod);
  27444. /* B = X*Y^2 */
  27445. sp_384_mont_sqr_15(t1, y, p384_mod, p384_mp_mod);
  27446. sp_384_mont_mul_15(b, t1, x, p384_mod, p384_mp_mod);
  27447. x = r[j].x;
  27448. /* X = A^2 - 2B */
  27449. sp_384_mont_sqr_15(x, a, p384_mod, p384_mp_mod);
  27450. sp_384_mont_dbl_15(t2, b, p384_mod);
  27451. sp_384_mont_sub_15(x, x, t2, p384_mod);
  27452. /* B = 2.(B - X) */
  27453. sp_384_mont_sub_15(t2, b, x, p384_mod);
  27454. sp_384_mont_dbl_15(b, t2, p384_mod);
  27455. /* Z = Z*Y */
  27456. sp_384_mont_mul_15(r[j].z, z, y, p384_mod, p384_mp_mod);
  27457. z = r[j].z;
  27458. /* t1 = Y^4 */
  27459. sp_384_mont_sqr_15(t1, t1, p384_mod, p384_mp_mod);
  27460. if (i != n) {
  27461. /* W = W*Y^4 */
  27462. sp_384_mont_mul_15(w, w, t1, p384_mod, p384_mp_mod);
  27463. }
  27464. /* y = 2*A*(B - X) - Y^4 */
  27465. sp_384_mont_mul_15(y, b, a, p384_mod, p384_mp_mod);
  27466. sp_384_mont_sub_15(y, y, t1, p384_mod);
  27467. /* Y = Y/2 */
  27468. sp_384_mont_div2_15(r[j].y, y, p384_mod);
  27469. r[j].infinity = 0;
  27470. }
  27471. }
  27472. /* Add two Montgomery form projective points.
  27473. *
  27474. * ra Result of addition.
  27475. * rs Result of subtraction.
  27476. * p First point to add.
  27477. * q Second point to add.
  27478. * t Temporary ordinate data.
  27479. */
  27480. static void sp_384_proj_point_add_sub_15(sp_point_384* ra,
  27481. sp_point_384* rs, const sp_point_384* p, const sp_point_384* q,
  27482. sp_digit* t)
  27483. {
  27484. sp_digit* t1 = t;
  27485. sp_digit* t2 = t + 2*15;
  27486. sp_digit* t3 = t + 4*15;
  27487. sp_digit* t4 = t + 6*15;
  27488. sp_digit* t5 = t + 8*15;
  27489. sp_digit* t6 = t + 10*15;
  27490. sp_digit* xa = ra->x;
  27491. sp_digit* ya = ra->y;
  27492. sp_digit* za = ra->z;
  27493. sp_digit* xs = rs->x;
  27494. sp_digit* ys = rs->y;
  27495. sp_digit* zs = rs->z;
  27496. XMEMCPY(xa, p->x, sizeof(p->x) / 2);
  27497. XMEMCPY(ya, p->y, sizeof(p->y) / 2);
  27498. XMEMCPY(za, p->z, sizeof(p->z) / 2);
  27499. ra->infinity = 0;
  27500. rs->infinity = 0;
  27501. /* U1 = X1*Z2^2 */
  27502. sp_384_mont_sqr_15(t1, q->z, p384_mod, p384_mp_mod);
  27503. sp_384_mont_mul_15(t3, t1, q->z, p384_mod, p384_mp_mod);
  27504. sp_384_mont_mul_15(t1, t1, xa, p384_mod, p384_mp_mod);
  27505. /* U2 = X2*Z1^2 */
  27506. sp_384_mont_sqr_15(t2, za, p384_mod, p384_mp_mod);
  27507. sp_384_mont_mul_15(t4, t2, za, p384_mod, p384_mp_mod);
  27508. sp_384_mont_mul_15(t2, t2, q->x, p384_mod, p384_mp_mod);
  27509. /* S1 = Y1*Z2^3 */
  27510. sp_384_mont_mul_15(t3, t3, ya, p384_mod, p384_mp_mod);
  27511. /* S2 = Y2*Z1^3 */
  27512. sp_384_mont_mul_15(t4, t4, q->y, p384_mod, p384_mp_mod);
  27513. /* H = U2 - U1 */
  27514. sp_384_mont_sub_15(t2, t2, t1, p384_mod);
  27515. /* RS = S2 + S1 */
  27516. sp_384_mont_add_15(t6, t4, t3, p384_mod);
  27517. /* R = S2 - S1 */
  27518. sp_384_mont_sub_15(t4, t4, t3, p384_mod);
  27519. /* Z3 = H*Z1*Z2 */
  27520. /* ZS = H*Z1*Z2 */
  27521. sp_384_mont_mul_15(za, za, q->z, p384_mod, p384_mp_mod);
  27522. sp_384_mont_mul_15(za, za, t2, p384_mod, p384_mp_mod);
  27523. XMEMCPY(zs, za, sizeof(p->z)/2);
  27524. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  27525. /* XS = RS^2 - H^3 - 2*U1*H^2 */
  27526. sp_384_mont_sqr_15(xa, t4, p384_mod, p384_mp_mod);
  27527. sp_384_mont_sqr_15(xs, t6, p384_mod, p384_mp_mod);
  27528. sp_384_mont_sqr_15(t5, t2, p384_mod, p384_mp_mod);
  27529. sp_384_mont_mul_15(ya, t1, t5, p384_mod, p384_mp_mod);
  27530. sp_384_mont_mul_15(t5, t5, t2, p384_mod, p384_mp_mod);
  27531. sp_384_mont_sub_15(xa, xa, t5, p384_mod);
  27532. sp_384_mont_sub_15(xs, xs, t5, p384_mod);
  27533. sp_384_mont_dbl_15(t1, ya, p384_mod);
  27534. sp_384_mont_sub_15(xa, xa, t1, p384_mod);
  27535. sp_384_mont_sub_15(xs, xs, t1, p384_mod);
  27536. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  27537. /* YS = -RS*(U1*H^2 - XS) - S1*H^3 */
  27538. sp_384_mont_sub_15(ys, ya, xs, p384_mod);
  27539. sp_384_mont_sub_15(ya, ya, xa, p384_mod);
  27540. sp_384_mont_mul_15(ya, ya, t4, p384_mod, p384_mp_mod);
  27541. sp_384_sub_15(t6, p384_mod, t6);
  27542. sp_384_mont_mul_15(ys, ys, t6, p384_mod, p384_mp_mod);
  27543. sp_384_mont_mul_15(t5, t5, t3, p384_mod, p384_mp_mod);
  27544. sp_384_mont_sub_15(ya, ya, t5, p384_mod);
  27545. sp_384_mont_sub_15(ys, ys, t5, p384_mod);
  27546. }
  27547. /* Structure used to describe recoding of scalar multiplication. */
  27548. typedef struct ecc_recode_384 {
  27549. /* Index into pre-computation table. */
  27550. uint8_t i;
  27551. /* Use the negative of the point. */
  27552. uint8_t neg;
  27553. } ecc_recode_384;
  27554. /* The index into pre-computation table to use. */
  27555. static const uint8_t recode_index_15_6[66] = {
  27556. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  27557. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  27558. 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
  27559. 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
  27560. 0, 1,
  27561. };
  27562. /* Whether to negate y-ordinate. */
  27563. static const uint8_t recode_neg_15_6[66] = {
  27564. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  27565. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  27566. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  27567. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  27568. 0, 0,
  27569. };
  27570. /* Recode the scalar for multiplication using pre-computed values and
  27571. * subtraction.
  27572. *
  27573. * k Scalar to multiply by.
  27574. * v Vector of operations to perform.
  27575. */
  27576. static void sp_384_ecc_recode_6_15(const sp_digit* k, ecc_recode_384* v)
  27577. {
  27578. int i;
  27579. int j;
  27580. uint8_t y;
  27581. int carry = 0;
  27582. int o;
  27583. sp_digit n;
  27584. j = 0;
  27585. n = k[j];
  27586. o = 0;
  27587. for (i=0; i<65; i++) {
  27588. y = (int8_t)n;
  27589. if (o + 6 < 26) {
  27590. y &= 0x3f;
  27591. n >>= 6;
  27592. o += 6;
  27593. }
  27594. else if (o + 6 == 26) {
  27595. n >>= 6;
  27596. if (++j < 15)
  27597. n = k[j];
  27598. o = 0;
  27599. }
  27600. else if (++j < 15) {
  27601. n = k[j];
  27602. y |= (uint8_t)((n << (26 - o)) & 0x3f);
  27603. o -= 20;
  27604. n >>= o;
  27605. }
  27606. y += (uint8_t)carry;
  27607. v[i].i = recode_index_15_6[y];
  27608. v[i].neg = recode_neg_15_6[y];
  27609. carry = (y >> 6) + v[i].neg;
  27610. }
  27611. }
  27612. #ifndef WC_NO_CACHE_RESISTANT
  27613. /* Touch each possible point that could be being copied.
  27614. *
  27615. * r Point to copy into.
  27616. * table Table - start of the entries to access
  27617. * idx Index of entry to retrieve.
  27618. */
  27619. static void sp_384_get_point_33_15(sp_point_384* r, const sp_point_384* table,
  27620. int idx)
  27621. {
  27622. int i;
  27623. sp_digit mask;
  27624. r->x[0] = 0;
  27625. r->x[1] = 0;
  27626. r->x[2] = 0;
  27627. r->x[3] = 0;
  27628. r->x[4] = 0;
  27629. r->x[5] = 0;
  27630. r->x[6] = 0;
  27631. r->x[7] = 0;
  27632. r->x[8] = 0;
  27633. r->x[9] = 0;
  27634. r->x[10] = 0;
  27635. r->x[11] = 0;
  27636. r->x[12] = 0;
  27637. r->x[13] = 0;
  27638. r->x[14] = 0;
  27639. r->y[0] = 0;
  27640. r->y[1] = 0;
  27641. r->y[2] = 0;
  27642. r->y[3] = 0;
  27643. r->y[4] = 0;
  27644. r->y[5] = 0;
  27645. r->y[6] = 0;
  27646. r->y[7] = 0;
  27647. r->y[8] = 0;
  27648. r->y[9] = 0;
  27649. r->y[10] = 0;
  27650. r->y[11] = 0;
  27651. r->y[12] = 0;
  27652. r->y[13] = 0;
  27653. r->y[14] = 0;
  27654. r->z[0] = 0;
  27655. r->z[1] = 0;
  27656. r->z[2] = 0;
  27657. r->z[3] = 0;
  27658. r->z[4] = 0;
  27659. r->z[5] = 0;
  27660. r->z[6] = 0;
  27661. r->z[7] = 0;
  27662. r->z[8] = 0;
  27663. r->z[9] = 0;
  27664. r->z[10] = 0;
  27665. r->z[11] = 0;
  27666. r->z[12] = 0;
  27667. r->z[13] = 0;
  27668. r->z[14] = 0;
  27669. for (i = 1; i < 33; i++) {
  27670. mask = 0 - (i == idx);
  27671. r->x[0] |= mask & table[i].x[0];
  27672. r->x[1] |= mask & table[i].x[1];
  27673. r->x[2] |= mask & table[i].x[2];
  27674. r->x[3] |= mask & table[i].x[3];
  27675. r->x[4] |= mask & table[i].x[4];
  27676. r->x[5] |= mask & table[i].x[5];
  27677. r->x[6] |= mask & table[i].x[6];
  27678. r->x[7] |= mask & table[i].x[7];
  27679. r->x[8] |= mask & table[i].x[8];
  27680. r->x[9] |= mask & table[i].x[9];
  27681. r->x[10] |= mask & table[i].x[10];
  27682. r->x[11] |= mask & table[i].x[11];
  27683. r->x[12] |= mask & table[i].x[12];
  27684. r->x[13] |= mask & table[i].x[13];
  27685. r->x[14] |= mask & table[i].x[14];
  27686. r->y[0] |= mask & table[i].y[0];
  27687. r->y[1] |= mask & table[i].y[1];
  27688. r->y[2] |= mask & table[i].y[2];
  27689. r->y[3] |= mask & table[i].y[3];
  27690. r->y[4] |= mask & table[i].y[4];
  27691. r->y[5] |= mask & table[i].y[5];
  27692. r->y[6] |= mask & table[i].y[6];
  27693. r->y[7] |= mask & table[i].y[7];
  27694. r->y[8] |= mask & table[i].y[8];
  27695. r->y[9] |= mask & table[i].y[9];
  27696. r->y[10] |= mask & table[i].y[10];
  27697. r->y[11] |= mask & table[i].y[11];
  27698. r->y[12] |= mask & table[i].y[12];
  27699. r->y[13] |= mask & table[i].y[13];
  27700. r->y[14] |= mask & table[i].y[14];
  27701. r->z[0] |= mask & table[i].z[0];
  27702. r->z[1] |= mask & table[i].z[1];
  27703. r->z[2] |= mask & table[i].z[2];
  27704. r->z[3] |= mask & table[i].z[3];
  27705. r->z[4] |= mask & table[i].z[4];
  27706. r->z[5] |= mask & table[i].z[5];
  27707. r->z[6] |= mask & table[i].z[6];
  27708. r->z[7] |= mask & table[i].z[7];
  27709. r->z[8] |= mask & table[i].z[8];
  27710. r->z[9] |= mask & table[i].z[9];
  27711. r->z[10] |= mask & table[i].z[10];
  27712. r->z[11] |= mask & table[i].z[11];
  27713. r->z[12] |= mask & table[i].z[12];
  27714. r->z[13] |= mask & table[i].z[13];
  27715. r->z[14] |= mask & table[i].z[14];
  27716. }
  27717. }
  27718. #endif /* !WC_NO_CACHE_RESISTANT */
  27719. /* Multiply the point by the scalar and return the result.
  27720. * If map is true then convert result to affine coordinates.
  27721. *
  27722. * Window technique of 6 bits. (Add-Sub variation.)
  27723. * Calculate 0..32 times the point. Use function that adds and
  27724. * subtracts the same two points.
  27725. * Recode to add or subtract one of the computed points.
  27726. * Double to push up.
  27727. * NOT a sliding window.
  27728. *
  27729. * r Resulting point.
  27730. * g Point to multiply.
  27731. * k Scalar to multiply by.
  27732. * map Indicates whether to convert result to affine.
  27733. * ct Constant time required.
  27734. * heap Heap to use for allocation.
  27735. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  27736. */
  27737. static int sp_384_ecc_mulmod_win_add_sub_15(sp_point_384* r, const sp_point_384* g,
  27738. const sp_digit* k, int map, int ct, void* heap)
  27739. {
  27740. #ifdef WOLFSSL_SP_SMALL_STACK
  27741. sp_point_384* t = NULL;
  27742. sp_digit* tmp = NULL;
  27743. #else
  27744. sp_point_384 t[33+2];
  27745. sp_digit tmp[2 * 15 * 6];
  27746. #endif
  27747. sp_point_384* rt = NULL;
  27748. sp_point_384* p = NULL;
  27749. sp_digit* negy;
  27750. int i;
  27751. ecc_recode_384 v[65];
  27752. int err = MP_OKAY;
  27753. /* Constant time used for cache attack resistance implementation. */
  27754. (void)ct;
  27755. (void)heap;
  27756. #ifdef WOLFSSL_SP_SMALL_STACK
  27757. t = (sp_point_384*)XMALLOC(sizeof(sp_point_384) *
  27758. (33+2), heap, DYNAMIC_TYPE_ECC);
  27759. if (t == NULL)
  27760. err = MEMORY_E;
  27761. if (err == MP_OKAY) {
  27762. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 6,
  27763. heap, DYNAMIC_TYPE_ECC);
  27764. if (tmp == NULL)
  27765. err = MEMORY_E;
  27766. }
  27767. #endif
  27768. if (err == MP_OKAY) {
  27769. rt = t + 33;
  27770. p = t + 33+1;
  27771. /* t[0] = {0, 0, 1} * norm */
  27772. XMEMSET(&t[0], 0, sizeof(t[0]));
  27773. t[0].infinity = 1;
  27774. /* t[1] = {g->x, g->y, g->z} * norm */
  27775. err = sp_384_mod_mul_norm_15(t[1].x, g->x, p384_mod);
  27776. }
  27777. if (err == MP_OKAY) {
  27778. err = sp_384_mod_mul_norm_15(t[1].y, g->y, p384_mod);
  27779. }
  27780. if (err == MP_OKAY) {
  27781. err = sp_384_mod_mul_norm_15(t[1].z, g->z, p384_mod);
  27782. }
  27783. if (err == MP_OKAY) {
  27784. t[1].infinity = 0;
  27785. /* t[2] ... t[32] */
  27786. sp_384_proj_point_dbl_n_store_15(t, &t[ 1], 5, 1, tmp);
  27787. sp_384_proj_point_add_15(&t[ 3], &t[ 2], &t[ 1], tmp);
  27788. sp_384_proj_point_dbl_15(&t[ 6], &t[ 3], tmp);
  27789. sp_384_proj_point_add_sub_15(&t[ 7], &t[ 5], &t[ 6], &t[ 1], tmp);
  27790. sp_384_proj_point_dbl_15(&t[10], &t[ 5], tmp);
  27791. sp_384_proj_point_add_sub_15(&t[11], &t[ 9], &t[10], &t[ 1], tmp);
  27792. sp_384_proj_point_dbl_15(&t[12], &t[ 6], tmp);
  27793. sp_384_proj_point_dbl_15(&t[14], &t[ 7], tmp);
  27794. sp_384_proj_point_add_sub_15(&t[15], &t[13], &t[14], &t[ 1], tmp);
  27795. sp_384_proj_point_dbl_15(&t[18], &t[ 9], tmp);
  27796. sp_384_proj_point_add_sub_15(&t[19], &t[17], &t[18], &t[ 1], tmp);
  27797. sp_384_proj_point_dbl_15(&t[20], &t[10], tmp);
  27798. sp_384_proj_point_dbl_15(&t[22], &t[11], tmp);
  27799. sp_384_proj_point_add_sub_15(&t[23], &t[21], &t[22], &t[ 1], tmp);
  27800. sp_384_proj_point_dbl_15(&t[24], &t[12], tmp);
  27801. sp_384_proj_point_dbl_15(&t[26], &t[13], tmp);
  27802. sp_384_proj_point_add_sub_15(&t[27], &t[25], &t[26], &t[ 1], tmp);
  27803. sp_384_proj_point_dbl_15(&t[28], &t[14], tmp);
  27804. sp_384_proj_point_dbl_15(&t[30], &t[15], tmp);
  27805. sp_384_proj_point_add_sub_15(&t[31], &t[29], &t[30], &t[ 1], tmp);
  27806. negy = t[0].y;
  27807. sp_384_ecc_recode_6_15(k, v);
  27808. i = 64;
  27809. #ifndef WC_NO_CACHE_RESISTANT
  27810. if (ct) {
  27811. sp_384_get_point_33_15(rt, t, v[i].i);
  27812. rt->infinity = !v[i].i;
  27813. }
  27814. else
  27815. #endif
  27816. {
  27817. XMEMCPY(rt, &t[v[i].i], sizeof(sp_point_384));
  27818. }
  27819. for (--i; i>=0; i--) {
  27820. sp_384_proj_point_dbl_n_15(rt, 6, tmp);
  27821. #ifndef WC_NO_CACHE_RESISTANT
  27822. if (ct) {
  27823. sp_384_get_point_33_15(p, t, v[i].i);
  27824. p->infinity = !v[i].i;
  27825. }
  27826. else
  27827. #endif
  27828. {
  27829. XMEMCPY(p, &t[v[i].i], sizeof(sp_point_384));
  27830. }
  27831. sp_384_sub_15(negy, p384_mod, p->y);
  27832. sp_384_norm_15(negy);
  27833. sp_384_cond_copy_15(p->y, negy, (sp_digit)0 - v[i].neg);
  27834. sp_384_proj_point_add_15(rt, rt, p, tmp);
  27835. }
  27836. if (map != 0) {
  27837. sp_384_map_15(r, rt, tmp);
  27838. }
  27839. else {
  27840. XMEMCPY(r, rt, sizeof(sp_point_384));
  27841. }
  27842. }
  27843. #ifdef WOLFSSL_SP_SMALL_STACK
  27844. if (t != NULL)
  27845. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  27846. if (tmp != NULL)
  27847. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  27848. #endif
  27849. return err;
  27850. }
  27851. #ifdef FP_ECC
  27852. #endif /* FP_ECC */
  27853. /* Add two Montgomery form projective points. The second point has a q value of
  27854. * one.
  27855. * Only the first point can be the same pointer as the result point.
  27856. *
  27857. * r Result of addition.
  27858. * p First point to add.
  27859. * q Second point to add.
  27860. * t Temporary ordinate data.
  27861. */
  27862. static void sp_384_proj_point_add_qz1_15(sp_point_384* r,
  27863. const sp_point_384* p, const sp_point_384* q, sp_digit* t)
  27864. {
  27865. sp_digit* t2 = t;
  27866. sp_digit* t3 = t + 2*15;
  27867. sp_digit* t6 = t + 4*15;
  27868. sp_digit* t1 = t + 6*15;
  27869. sp_digit* t4 = t + 8*15;
  27870. sp_digit* t5 = t + 10*15;
  27871. /* Calculate values to subtract from P->x and P->y. */
  27872. /* U2 = X2*Z1^2 */
  27873. sp_384_mont_sqr_15(t2, p->z, p384_mod, p384_mp_mod);
  27874. sp_384_mont_mul_15(t4, t2, p->z, p384_mod, p384_mp_mod);
  27875. sp_384_mont_mul_15(t2, t2, q->x, p384_mod, p384_mp_mod);
  27876. /* S2 = Y2*Z1^3 */
  27877. sp_384_mont_mul_15(t4, t4, q->y, p384_mod, p384_mp_mod);
  27878. if ((~p->infinity) & (~q->infinity) &
  27879. sp_384_cmp_equal_15(p->x, t2) &
  27880. sp_384_cmp_equal_15(p->y, t4)) {
  27881. sp_384_proj_point_dbl_15(r, p, t);
  27882. }
  27883. else {
  27884. sp_digit* x = t2;
  27885. sp_digit* y = t3;
  27886. sp_digit* z = t6;
  27887. /* H = U2 - X1 */
  27888. sp_384_mont_sub_15(t2, t2, p->x, p384_mod);
  27889. /* R = S2 - Y1 */
  27890. sp_384_mont_sub_15(t4, t4, p->y, p384_mod);
  27891. /* Z3 = H*Z1 */
  27892. sp_384_mont_mul_15(z, p->z, t2, p384_mod, p384_mp_mod);
  27893. /* X3 = R^2 - H^3 - 2*X1*H^2 */
  27894. sp_384_mont_sqr_15(t1, t2, p384_mod, p384_mp_mod);
  27895. sp_384_mont_mul_15(t3, p->x, t1, p384_mod, p384_mp_mod);
  27896. sp_384_mont_mul_15(t1, t1, t2, p384_mod, p384_mp_mod);
  27897. sp_384_mont_sqr_15(t2, t4, p384_mod, p384_mp_mod);
  27898. sp_384_mont_sub_15(t2, t2, t1, p384_mod);
  27899. sp_384_mont_dbl_15(t5, t3, p384_mod);
  27900. sp_384_mont_sub_15(x, t2, t5, p384_mod);
  27901. /* Y3 = R*(X1*H^2 - X3) - Y1*H^3 */
  27902. sp_384_mont_sub_15(t3, t3, x, p384_mod);
  27903. sp_384_mont_mul_15(t3, t3, t4, p384_mod, p384_mp_mod);
  27904. sp_384_mont_mul_15(t1, t1, p->y, p384_mod, p384_mp_mod);
  27905. sp_384_mont_sub_15(y, t3, t1, p384_mod);
  27906. {
  27907. int i;
  27908. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  27909. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  27910. sp_digit maskt = ~(maskp | maskq);
  27911. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  27912. for (i = 0; i < 15; i++) {
  27913. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  27914. (x[i] & maskt);
  27915. }
  27916. for (i = 0; i < 15; i++) {
  27917. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  27918. (y[i] & maskt);
  27919. }
  27920. for (i = 0; i < 15; i++) {
  27921. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  27922. (z[i] & maskt);
  27923. }
  27924. r->z[0] |= inf;
  27925. r->infinity = (word32)inf;
  27926. }
  27927. }
  27928. }
  27929. #ifdef FP_ECC
  27930. /* Convert the projective point to affine.
  27931. * Ordinates are in Montgomery form.
  27932. *
  27933. * a Point to convert.
  27934. * t Temporary data.
  27935. */
  27936. static void sp_384_proj_to_affine_15(sp_point_384* a, sp_digit* t)
  27937. {
  27938. sp_digit* t1 = t;
  27939. sp_digit* t2 = t + 2 * 15;
  27940. sp_digit* tmp = t + 4 * 15;
  27941. sp_384_mont_inv_15(t1, a->z, tmp);
  27942. sp_384_mont_sqr_15(t2, t1, p384_mod, p384_mp_mod);
  27943. sp_384_mont_mul_15(t1, t2, t1, p384_mod, p384_mp_mod);
  27944. sp_384_mont_mul_15(a->x, a->x, t2, p384_mod, p384_mp_mod);
  27945. sp_384_mont_mul_15(a->y, a->y, t1, p384_mod, p384_mp_mod);
  27946. XMEMCPY(a->z, p384_norm_mod, sizeof(p384_norm_mod));
  27947. }
  27948. /* Generate the pre-computed table of points for the base point.
  27949. *
  27950. * width = 8
  27951. * 256 entries
  27952. * 48 bits between
  27953. *
  27954. * a The base point.
  27955. * table Place to store generated point data.
  27956. * tmp Temporary data.
  27957. * heap Heap to use for allocation.
  27958. */
  27959. static int sp_384_gen_stripe_table_15(const sp_point_384* a,
  27960. sp_table_entry_384* table, sp_digit* tmp, void* heap)
  27961. {
  27962. #ifdef WOLFSSL_SP_SMALL_STACK
  27963. sp_point_384* t = NULL;
  27964. #else
  27965. sp_point_384 t[3];
  27966. #endif
  27967. sp_point_384* s1 = NULL;
  27968. sp_point_384* s2 = NULL;
  27969. int i;
  27970. int j;
  27971. int err = MP_OKAY;
  27972. (void)heap;
  27973. #ifdef WOLFSSL_SP_SMALL_STACK
  27974. t = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 3, heap,
  27975. DYNAMIC_TYPE_ECC);
  27976. if (t == NULL)
  27977. err = MEMORY_E;
  27978. #endif
  27979. if (err == MP_OKAY) {
  27980. s1 = t + 1;
  27981. s2 = t + 2;
  27982. err = sp_384_mod_mul_norm_15(t->x, a->x, p384_mod);
  27983. }
  27984. if (err == MP_OKAY) {
  27985. err = sp_384_mod_mul_norm_15(t->y, a->y, p384_mod);
  27986. }
  27987. if (err == MP_OKAY) {
  27988. err = sp_384_mod_mul_norm_15(t->z, a->z, p384_mod);
  27989. }
  27990. if (err == MP_OKAY) {
  27991. t->infinity = 0;
  27992. sp_384_proj_to_affine_15(t, tmp);
  27993. XMEMCPY(s1->z, p384_norm_mod, sizeof(p384_norm_mod));
  27994. s1->infinity = 0;
  27995. XMEMCPY(s2->z, p384_norm_mod, sizeof(p384_norm_mod));
  27996. s2->infinity = 0;
  27997. /* table[0] = {0, 0, infinity} */
  27998. XMEMSET(&table[0], 0, sizeof(sp_table_entry_384));
  27999. /* table[1] = Affine version of 'a' in Montgomery form */
  28000. XMEMCPY(table[1].x, t->x, sizeof(table->x));
  28001. XMEMCPY(table[1].y, t->y, sizeof(table->y));
  28002. for (i=1; i<8; i++) {
  28003. sp_384_proj_point_dbl_n_15(t, 48, tmp);
  28004. sp_384_proj_to_affine_15(t, tmp);
  28005. XMEMCPY(table[1<<i].x, t->x, sizeof(table->x));
  28006. XMEMCPY(table[1<<i].y, t->y, sizeof(table->y));
  28007. }
  28008. for (i=1; i<8; i++) {
  28009. XMEMCPY(s1->x, table[1<<i].x, sizeof(table->x));
  28010. XMEMCPY(s1->y, table[1<<i].y, sizeof(table->y));
  28011. for (j=(1<<i)+1; j<(1<<(i+1)); j++) {
  28012. XMEMCPY(s2->x, table[j-(1<<i)].x, sizeof(table->x));
  28013. XMEMCPY(s2->y, table[j-(1<<i)].y, sizeof(table->y));
  28014. sp_384_proj_point_add_qz1_15(t, s1, s2, tmp);
  28015. sp_384_proj_to_affine_15(t, tmp);
  28016. XMEMCPY(table[j].x, t->x, sizeof(table->x));
  28017. XMEMCPY(table[j].y, t->y, sizeof(table->y));
  28018. }
  28019. }
  28020. }
  28021. #ifdef WOLFSSL_SP_SMALL_STACK
  28022. if (t != NULL)
  28023. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  28024. #endif
  28025. return err;
  28026. }
  28027. #endif /* FP_ECC */
  28028. #ifndef WC_NO_CACHE_RESISTANT
  28029. /* Touch each possible entry that could be being copied.
  28030. *
  28031. * r Point to copy into.
  28032. * table Table - start of the entries to access
  28033. * idx Index of entry to retrieve.
  28034. */
  28035. static void sp_384_get_entry_256_15(sp_point_384* r,
  28036. const sp_table_entry_384* table, int idx)
  28037. {
  28038. int i;
  28039. sp_digit mask;
  28040. r->x[0] = 0;
  28041. r->x[1] = 0;
  28042. r->x[2] = 0;
  28043. r->x[3] = 0;
  28044. r->x[4] = 0;
  28045. r->x[5] = 0;
  28046. r->x[6] = 0;
  28047. r->x[7] = 0;
  28048. r->x[8] = 0;
  28049. r->x[9] = 0;
  28050. r->x[10] = 0;
  28051. r->x[11] = 0;
  28052. r->x[12] = 0;
  28053. r->x[13] = 0;
  28054. r->x[14] = 0;
  28055. r->y[0] = 0;
  28056. r->y[1] = 0;
  28057. r->y[2] = 0;
  28058. r->y[3] = 0;
  28059. r->y[4] = 0;
  28060. r->y[5] = 0;
  28061. r->y[6] = 0;
  28062. r->y[7] = 0;
  28063. r->y[8] = 0;
  28064. r->y[9] = 0;
  28065. r->y[10] = 0;
  28066. r->y[11] = 0;
  28067. r->y[12] = 0;
  28068. r->y[13] = 0;
  28069. r->y[14] = 0;
  28070. for (i = 1; i < 256; i++) {
  28071. mask = 0 - (i == idx);
  28072. r->x[0] |= mask & table[i].x[0];
  28073. r->x[1] |= mask & table[i].x[1];
  28074. r->x[2] |= mask & table[i].x[2];
  28075. r->x[3] |= mask & table[i].x[3];
  28076. r->x[4] |= mask & table[i].x[4];
  28077. r->x[5] |= mask & table[i].x[5];
  28078. r->x[6] |= mask & table[i].x[6];
  28079. r->x[7] |= mask & table[i].x[7];
  28080. r->x[8] |= mask & table[i].x[8];
  28081. r->x[9] |= mask & table[i].x[9];
  28082. r->x[10] |= mask & table[i].x[10];
  28083. r->x[11] |= mask & table[i].x[11];
  28084. r->x[12] |= mask & table[i].x[12];
  28085. r->x[13] |= mask & table[i].x[13];
  28086. r->x[14] |= mask & table[i].x[14];
  28087. r->y[0] |= mask & table[i].y[0];
  28088. r->y[1] |= mask & table[i].y[1];
  28089. r->y[2] |= mask & table[i].y[2];
  28090. r->y[3] |= mask & table[i].y[3];
  28091. r->y[4] |= mask & table[i].y[4];
  28092. r->y[5] |= mask & table[i].y[5];
  28093. r->y[6] |= mask & table[i].y[6];
  28094. r->y[7] |= mask & table[i].y[7];
  28095. r->y[8] |= mask & table[i].y[8];
  28096. r->y[9] |= mask & table[i].y[9];
  28097. r->y[10] |= mask & table[i].y[10];
  28098. r->y[11] |= mask & table[i].y[11];
  28099. r->y[12] |= mask & table[i].y[12];
  28100. r->y[13] |= mask & table[i].y[13];
  28101. r->y[14] |= mask & table[i].y[14];
  28102. }
  28103. }
  28104. #endif /* !WC_NO_CACHE_RESISTANT */
  28105. /* Multiply the point by the scalar and return the result.
  28106. * If map is true then convert result to affine coordinates.
  28107. *
  28108. * Stripe implementation.
  28109. * Pre-generated: 2^0, 2^48, ...
  28110. * Pre-generated: products of all combinations of above.
  28111. * 8 doubles and adds (with qz=1)
  28112. *
  28113. * r Resulting point.
  28114. * k Scalar to multiply by.
  28115. * table Pre-computed table.
  28116. * map Indicates whether to convert result to affine.
  28117. * ct Constant time required.
  28118. * heap Heap to use for allocation.
  28119. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  28120. */
  28121. static int sp_384_ecc_mulmod_stripe_15(sp_point_384* r, const sp_point_384* g,
  28122. const sp_table_entry_384* table, const sp_digit* k, int map,
  28123. int ct, void* heap)
  28124. {
  28125. #ifdef WOLFSSL_SP_SMALL_STACK
  28126. sp_point_384* rt = NULL;
  28127. sp_digit* t = NULL;
  28128. #else
  28129. sp_point_384 rt[2];
  28130. sp_digit t[2 * 15 * 6];
  28131. #endif
  28132. sp_point_384* p = NULL;
  28133. int i;
  28134. int j;
  28135. int y;
  28136. int x;
  28137. int err = MP_OKAY;
  28138. (void)g;
  28139. /* Constant time used for cache attack resistance implementation. */
  28140. (void)ct;
  28141. (void)heap;
  28142. #ifdef WOLFSSL_SP_SMALL_STACK
  28143. rt = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap,
  28144. DYNAMIC_TYPE_ECC);
  28145. if (rt == NULL)
  28146. err = MEMORY_E;
  28147. if (err == MP_OKAY) {
  28148. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 6, heap,
  28149. DYNAMIC_TYPE_ECC);
  28150. if (t == NULL)
  28151. err = MEMORY_E;
  28152. }
  28153. #endif
  28154. if (err == MP_OKAY) {
  28155. p = rt + 1;
  28156. XMEMCPY(p->z, p384_norm_mod, sizeof(p384_norm_mod));
  28157. XMEMCPY(rt->z, p384_norm_mod, sizeof(p384_norm_mod));
  28158. y = 0;
  28159. x = 47;
  28160. for (j=0; j<8; j++) {
  28161. y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j);
  28162. x += 48;
  28163. }
  28164. #ifndef WC_NO_CACHE_RESISTANT
  28165. if (ct) {
  28166. sp_384_get_entry_256_15(rt, table, y);
  28167. } else
  28168. #endif
  28169. {
  28170. XMEMCPY(rt->x, table[y].x, sizeof(table[y].x));
  28171. XMEMCPY(rt->y, table[y].y, sizeof(table[y].y));
  28172. }
  28173. rt->infinity = !y;
  28174. for (i=46; i>=0; i--) {
  28175. y = 0;
  28176. x = i;
  28177. for (j=0; j<8; j++) {
  28178. y |= (int)(((k[x / 26] >> (x % 26)) & 1) << j);
  28179. x += 48;
  28180. }
  28181. sp_384_proj_point_dbl_15(rt, rt, t);
  28182. #ifndef WC_NO_CACHE_RESISTANT
  28183. if (ct) {
  28184. sp_384_get_entry_256_15(p, table, y);
  28185. }
  28186. else
  28187. #endif
  28188. {
  28189. XMEMCPY(p->x, table[y].x, sizeof(table[y].x));
  28190. XMEMCPY(p->y, table[y].y, sizeof(table[y].y));
  28191. }
  28192. p->infinity = !y;
  28193. sp_384_proj_point_add_qz1_15(rt, rt, p, t);
  28194. }
  28195. if (map != 0) {
  28196. sp_384_map_15(r, rt, t);
  28197. }
  28198. else {
  28199. XMEMCPY(r, rt, sizeof(sp_point_384));
  28200. }
  28201. }
  28202. #ifdef WOLFSSL_SP_SMALL_STACK
  28203. if (t != NULL)
  28204. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  28205. if (rt != NULL)
  28206. XFREE(rt, heap, DYNAMIC_TYPE_ECC);
  28207. #endif
  28208. return err;
  28209. }
  28210. #ifdef FP_ECC
  28211. #ifndef FP_ENTRIES
  28212. #define FP_ENTRIES 16
  28213. #endif
  28214. /* Cache entry - holds precomputation tables for a point. */
  28215. typedef struct sp_cache_384_t {
  28216. /* X ordinate of point that table was generated from. */
  28217. sp_digit x[15];
  28218. /* Y ordinate of point that table was generated from. */
  28219. sp_digit y[15];
  28220. /* Precomputation table for point. */
  28221. sp_table_entry_384 table[256];
  28222. /* Count of entries in table. */
  28223. uint32_t cnt;
  28224. /* Point and table set in entry. */
  28225. int set;
  28226. } sp_cache_384_t;
  28227. /* Cache of tables. */
  28228. static THREAD_LS_T sp_cache_384_t sp_cache_384[FP_ENTRIES];
  28229. /* Index of last entry in cache. */
  28230. static THREAD_LS_T int sp_cache_384_last = -1;
  28231. /* Cache has been initialized. */
  28232. static THREAD_LS_T int sp_cache_384_inited = 0;
  28233. #ifndef HAVE_THREAD_LS
  28234. static volatile int initCacheMutex_384 = 0;
  28235. static wolfSSL_Mutex sp_cache_384_lock;
  28236. #endif
  28237. /* Get the cache entry for the point.
  28238. *
  28239. * g [in] Point scalar multiplying.
  28240. * cache [out] Cache table to use.
  28241. */
  28242. static void sp_ecc_get_cache_384(const sp_point_384* g, sp_cache_384_t** cache)
  28243. {
  28244. int i;
  28245. int j;
  28246. uint32_t least;
  28247. if (sp_cache_384_inited == 0) {
  28248. for (i=0; i<FP_ENTRIES; i++) {
  28249. sp_cache_384[i].set = 0;
  28250. }
  28251. sp_cache_384_inited = 1;
  28252. }
  28253. /* Compare point with those in cache. */
  28254. for (i=0; i<FP_ENTRIES; i++) {
  28255. if (!sp_cache_384[i].set)
  28256. continue;
  28257. if (sp_384_cmp_equal_15(g->x, sp_cache_384[i].x) &
  28258. sp_384_cmp_equal_15(g->y, sp_cache_384[i].y)) {
  28259. sp_cache_384[i].cnt++;
  28260. break;
  28261. }
  28262. }
  28263. /* No match. */
  28264. if (i == FP_ENTRIES) {
  28265. /* Find empty entry. */
  28266. i = (sp_cache_384_last + 1) % FP_ENTRIES;
  28267. for (; i != sp_cache_384_last; i=(i+1)%FP_ENTRIES) {
  28268. if (!sp_cache_384[i].set) {
  28269. break;
  28270. }
  28271. }
  28272. /* Evict least used. */
  28273. if (i == sp_cache_384_last) {
  28274. least = sp_cache_384[0].cnt;
  28275. for (j=1; j<FP_ENTRIES; j++) {
  28276. if (sp_cache_384[j].cnt < least) {
  28277. i = j;
  28278. least = sp_cache_384[i].cnt;
  28279. }
  28280. }
  28281. }
  28282. XMEMCPY(sp_cache_384[i].x, g->x, sizeof(sp_cache_384[i].x));
  28283. XMEMCPY(sp_cache_384[i].y, g->y, sizeof(sp_cache_384[i].y));
  28284. sp_cache_384[i].set = 1;
  28285. sp_cache_384[i].cnt = 1;
  28286. }
  28287. *cache = &sp_cache_384[i];
  28288. sp_cache_384_last = i;
  28289. }
  28290. #endif /* FP_ECC */
  28291. /* Multiply the base point of P384 by the scalar and return the result.
  28292. * If map is true then convert result to affine coordinates.
  28293. *
  28294. * r Resulting point.
  28295. * g Point to multiply.
  28296. * k Scalar to multiply by.
  28297. * map Indicates whether to convert result to affine.
  28298. * ct Constant time required.
  28299. * heap Heap to use for allocation.
  28300. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  28301. */
  28302. static int sp_384_ecc_mulmod_15(sp_point_384* r, const sp_point_384* g,
  28303. const sp_digit* k, int map, int ct, void* heap)
  28304. {
  28305. #ifndef FP_ECC
  28306. return sp_384_ecc_mulmod_win_add_sub_15(r, g, k, map, ct, heap);
  28307. #else
  28308. #ifdef WOLFSSL_SP_SMALL_STACK
  28309. sp_digit* tmp;
  28310. #else
  28311. sp_digit tmp[2 * 15 * 7];
  28312. #endif
  28313. sp_cache_384_t* cache;
  28314. int err = MP_OKAY;
  28315. #ifdef WOLFSSL_SP_SMALL_STACK
  28316. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 7, heap, DYNAMIC_TYPE_ECC);
  28317. if (tmp == NULL) {
  28318. err = MEMORY_E;
  28319. }
  28320. #endif
  28321. #ifndef HAVE_THREAD_LS
  28322. if (err == MP_OKAY) {
  28323. if (initCacheMutex_384 == 0) {
  28324. wc_InitMutex(&sp_cache_384_lock);
  28325. initCacheMutex_384 = 1;
  28326. }
  28327. if (wc_LockMutex(&sp_cache_384_lock) != 0) {
  28328. err = BAD_MUTEX_E;
  28329. }
  28330. }
  28331. #endif /* HAVE_THREAD_LS */
  28332. if (err == MP_OKAY) {
  28333. sp_ecc_get_cache_384(g, &cache);
  28334. if (cache->cnt == 2)
  28335. sp_384_gen_stripe_table_15(g, cache->table, tmp, heap);
  28336. #ifndef HAVE_THREAD_LS
  28337. wc_UnLockMutex(&sp_cache_384_lock);
  28338. #endif /* HAVE_THREAD_LS */
  28339. if (cache->cnt < 2) {
  28340. err = sp_384_ecc_mulmod_win_add_sub_15(r, g, k, map, ct, heap);
  28341. }
  28342. else {
  28343. err = sp_384_ecc_mulmod_stripe_15(r, g, cache->table, k,
  28344. map, ct, heap);
  28345. }
  28346. }
  28347. #ifdef WOLFSSL_SP_SMALL_STACK
  28348. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  28349. #endif
  28350. return err;
  28351. #endif
  28352. }
  28353. #endif
  28354. /* Multiply the point by the scalar and return the result.
  28355. * If map is true then convert result to affine coordinates.
  28356. *
  28357. * km Scalar to multiply by.
  28358. * p Point to multiply.
  28359. * r Resulting point.
  28360. * map Indicates whether to convert result to affine.
  28361. * heap Heap to use for allocation.
  28362. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  28363. */
  28364. int sp_ecc_mulmod_384(const mp_int* km, const ecc_point* gm, ecc_point* r,
  28365. int map, void* heap)
  28366. {
  28367. #ifdef WOLFSSL_SP_SMALL_STACK
  28368. sp_point_384* point = NULL;
  28369. sp_digit* k = NULL;
  28370. #else
  28371. sp_point_384 point[1];
  28372. sp_digit k[15];
  28373. #endif
  28374. int err = MP_OKAY;
  28375. #ifdef WOLFSSL_SP_SMALL_STACK
  28376. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384), heap,
  28377. DYNAMIC_TYPE_ECC);
  28378. if (point == NULL)
  28379. err = MEMORY_E;
  28380. if (err == MP_OKAY) {
  28381. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15, heap,
  28382. DYNAMIC_TYPE_ECC);
  28383. if (k == NULL)
  28384. err = MEMORY_E;
  28385. }
  28386. #endif
  28387. if (err == MP_OKAY) {
  28388. sp_384_from_mp(k, 15, km);
  28389. sp_384_point_from_ecc_point_15(point, gm);
  28390. err = sp_384_ecc_mulmod_15(point, point, k, map, 1, heap);
  28391. }
  28392. if (err == MP_OKAY) {
  28393. err = sp_384_point_to_ecc_point_15(point, r);
  28394. }
  28395. #ifdef WOLFSSL_SP_SMALL_STACK
  28396. if (k != NULL)
  28397. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  28398. if (point != NULL)
  28399. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  28400. #endif
  28401. return err;
  28402. }
  28403. /* Multiply the point by the scalar, add point a and return the result.
  28404. * If map is true then convert result to affine coordinates.
  28405. *
  28406. * km Scalar to multiply by.
  28407. * p Point to multiply.
  28408. * am Point to add to scalar multiply result.
  28409. * inMont Point to add is in montgomery form.
  28410. * r Resulting point.
  28411. * map Indicates whether to convert result to affine.
  28412. * heap Heap to use for allocation.
  28413. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  28414. */
  28415. int sp_ecc_mulmod_add_384(const mp_int* km, const ecc_point* gm,
  28416. const ecc_point* am, int inMont, ecc_point* r, int map, void* heap)
  28417. {
  28418. #ifdef WOLFSSL_SP_SMALL_STACK
  28419. sp_point_384* point = NULL;
  28420. sp_digit* k = NULL;
  28421. #else
  28422. sp_point_384 point[2];
  28423. sp_digit k[15 + 15 * 2 * 6];
  28424. #endif
  28425. sp_point_384* addP = NULL;
  28426. sp_digit* tmp = NULL;
  28427. int err = MP_OKAY;
  28428. #ifdef WOLFSSL_SP_SMALL_STACK
  28429. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap,
  28430. DYNAMIC_TYPE_ECC);
  28431. if (point == NULL)
  28432. err = MEMORY_E;
  28433. if (err == MP_OKAY) {
  28434. k = (sp_digit*)XMALLOC(
  28435. sizeof(sp_digit) * (15 + 15 * 2 * 6), heap,
  28436. DYNAMIC_TYPE_ECC);
  28437. if (k == NULL)
  28438. err = MEMORY_E;
  28439. }
  28440. #endif
  28441. if (err == MP_OKAY) {
  28442. addP = point + 1;
  28443. tmp = k + 15;
  28444. sp_384_from_mp(k, 15, km);
  28445. sp_384_point_from_ecc_point_15(point, gm);
  28446. sp_384_point_from_ecc_point_15(addP, am);
  28447. }
  28448. if ((err == MP_OKAY) && (!inMont)) {
  28449. err = sp_384_mod_mul_norm_15(addP->x, addP->x, p384_mod);
  28450. }
  28451. if ((err == MP_OKAY) && (!inMont)) {
  28452. err = sp_384_mod_mul_norm_15(addP->y, addP->y, p384_mod);
  28453. }
  28454. if ((err == MP_OKAY) && (!inMont)) {
  28455. err = sp_384_mod_mul_norm_15(addP->z, addP->z, p384_mod);
  28456. }
  28457. if (err == MP_OKAY) {
  28458. err = sp_384_ecc_mulmod_15(point, point, k, 0, 0, heap);
  28459. }
  28460. if (err == MP_OKAY) {
  28461. sp_384_proj_point_add_15(point, point, addP, tmp);
  28462. if (map) {
  28463. sp_384_map_15(point, point, tmp);
  28464. }
  28465. err = sp_384_point_to_ecc_point_15(point, r);
  28466. }
  28467. #ifdef WOLFSSL_SP_SMALL_STACK
  28468. if (k != NULL)
  28469. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  28470. if (point != NULL)
  28471. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  28472. #endif
  28473. return err;
  28474. }
  28475. #ifdef WOLFSSL_SP_SMALL
  28476. /* Multiply the base point of P384 by the scalar and return the result.
  28477. * If map is true then convert result to affine coordinates.
  28478. *
  28479. * r Resulting point.
  28480. * k Scalar to multiply by.
  28481. * map Indicates whether to convert result to affine.
  28482. * heap Heap to use for allocation.
  28483. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  28484. */
  28485. static int sp_384_ecc_mulmod_base_15(sp_point_384* r, const sp_digit* k,
  28486. int map, int ct, void* heap)
  28487. {
  28488. /* No pre-computed values. */
  28489. return sp_384_ecc_mulmod_15(r, &p384_base, k, map, ct, heap);
  28490. }
  28491. #ifdef WOLFSSL_SP_NONBLOCK
  28492. static int sp_384_ecc_mulmod_base_15_nb(sp_ecc_ctx_t* sp_ctx, sp_point_384* r,
  28493. const sp_digit* k, int map, int ct, void* heap)
  28494. {
  28495. /* No pre-computed values. */
  28496. return sp_384_ecc_mulmod_15_nb(sp_ctx, r, &p384_base, k, map, ct, heap);
  28497. }
  28498. #endif /* WOLFSSL_SP_NONBLOCK */
  28499. #else
  28500. /* Striping precomputation table.
  28501. * 8 points combined into a table of 256 points.
  28502. * Distance of 48 between points.
  28503. */
  28504. static const sp_table_entry_384 p384_table[256] = {
  28505. /* 0 */
  28506. { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  28507. 0x00, 0x00, 0x00 },
  28508. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  28509. 0x00, 0x00, 0x00 } },
  28510. /* 1 */
  28511. { { 0x1c0b528,0x01d5992,0x0e383dd,0x38a835b,0x220e378,0x106d35b,
  28512. 0x1c3afc5,0x03bfe1e,0x28459a3,0x2d91521,0x214ede2,0x0bfdc8d,
  28513. 0x2151381,0x3708a67,0x004d3aa },
  28514. { 0x303a4fe,0x10f6b52,0x29ac230,0x2fdeed2,0x0a1bfa8,0x3a0ec14,
  28515. 0x2de7562,0x3ff662e,0x21968f4,0x031b0d4,0x3969a84,0x2000898,
  28516. 0x1c5e9dd,0x2f09685,0x002b78a } },
  28517. /* 2 */
  28518. { { 0x30c535b,0x191d4ca,0x2296298,0x14dc141,0x090dd69,0x05aae6b,
  28519. 0x0cd6b42,0x35da80e,0x3b7be12,0x2cf7e6d,0x1f347bd,0x3d365e1,
  28520. 0x1448913,0x32704fa,0x00222c5 },
  28521. { 0x280dc64,0x39e5bc9,0x24175f8,0x2dd60d4,0x0120e7c,0x041d02e,
  28522. 0x0b5d8ad,0x37b9895,0x2fb5337,0x1f0e2e3,0x14f0224,0x2230b86,
  28523. 0x1bc4cf6,0x17cdb09,0x007b5c7 } },
  28524. /* 3 */
  28525. { { 0x2dffea5,0x28f30e7,0x29fce26,0x070df5f,0x235bbfd,0x2f78fbd,
  28526. 0x27700d9,0x23d6bc3,0x3471a53,0x0c0e03a,0x05bf9eb,0x276a2ec,
  28527. 0x20c3e2e,0x31cc691,0x00dbb93 },
  28528. { 0x126b605,0x2e8983d,0x153737d,0x23bf5e1,0x295d497,0x35ca812,
  28529. 0x2d793ae,0x16c6893,0x3777600,0x089a520,0x1e681f8,0x3d55ee6,
  28530. 0x154ef99,0x155f592,0x00ae5f9 } },
  28531. /* 4 */
  28532. { { 0x26feef9,0x20315fc,0x1240244,0x250e838,0x3c31a26,0x1cf8af1,
  28533. 0x1002c32,0x3b531cd,0x1c53ef1,0x22310ba,0x3f4948e,0x22eafd9,
  28534. 0x3863202,0x3d0e2a5,0x006a502 },
  28535. { 0x34536fe,0x04e91ad,0x30ebf5f,0x2af62a7,0x01d218b,0x1c8c9da,
  28536. 0x336bcc3,0x23060c3,0x331576e,0x1b14c5e,0x1bbcb76,0x0755e9a,
  28537. 0x3d4dcef,0x24c2cf8,0x00917c4 } },
  28538. /* 5 */
  28539. { { 0x349ddd0,0x09b8bb8,0x0250114,0x3e66cbf,0x29f117e,0x3005d29,
  28540. 0x36b480e,0x2119bfc,0x2761845,0x253d2f7,0x0580604,0x0bb6db4,
  28541. 0x3ca922f,0x1744677,0x008adc7 },
  28542. { 0x3d5a7ce,0x27425ed,0x11e9a61,0x3968d10,0x3874275,0x3692d3b,
  28543. 0x03e0470,0x0763d50,0x3d97790,0x3cbaeab,0x2747170,0x18faf3a,
  28544. 0x180365e,0x2511fe7,0x0012a36 } },
  28545. /* 6 */
  28546. { { 0x3c52870,0x2701e93,0x296128f,0x120694e,0x1ce0b37,0x3860a36,
  28547. 0x10fa180,0x0896b55,0x2f76adb,0x22892ae,0x2e58a34,0x07b4295,
  28548. 0x2cb62d1,0x079a522,0x00f3d81 },
  28549. { 0x061ed22,0x2375dd3,0x3c9d861,0x3e602d1,0x10bb747,0x39ae156,
  28550. 0x3f796fd,0x087a48a,0x06d680a,0x37f7f47,0x2af2c9d,0x36c55dc,
  28551. 0x10f3dc0,0x279b07a,0x00a0937 } },
  28552. /* 7 */
  28553. { { 0x085c629,0x319bbf8,0x089a386,0x184256f,0x15fc2a4,0x00fd2d0,
  28554. 0x13d6312,0x363d44d,0x32b7e4b,0x25f2865,0x27df8ce,0x1dce02a,
  28555. 0x24ea3b0,0x0e27b9f,0x00d8a90 },
  28556. { 0x3b14461,0x1d371f9,0x0f781bc,0x0503271,0x0dc2cb0,0x13bc284,
  28557. 0x34b3a68,0x1ff894a,0x25d2032,0x16f79ba,0x260f961,0x07b10d5,
  28558. 0x18173b7,0x2812e2b,0x00eede5 } },
  28559. /* 8 */
  28560. { { 0x13b9a2d,0x132ece2,0x0c5d558,0x02c0214,0x1820c66,0x37cb50f,
  28561. 0x26d8267,0x3a00504,0x3f00109,0x33756ee,0x38172f1,0x2e4bb8c,
  28562. 0x030d985,0x3e4fcc5,0x00609d4 },
  28563. { 0x2daf9d6,0x16681fa,0x1fb01e0,0x1b03c49,0x370e653,0x183c839,
  28564. 0x2207515,0x0ea6b58,0x1ae7aaf,0x3a96522,0x24bae14,0x1c38bd9,
  28565. 0x082497b,0x1c05db4,0x000dd03 } },
  28566. /* 9 */
  28567. { { 0x110521f,0x04efa21,0x0c174cc,0x2a7dc93,0x387315b,0x14f7098,
  28568. 0x1d83bb3,0x2495ed2,0x2fe0c27,0x1e2d9df,0x093c953,0x0287073,
  28569. 0x02c9951,0x336291c,0x0033e30 },
  28570. { 0x208353f,0x3f22748,0x2b2bf0f,0x2373b50,0x10170fa,0x1b8a97d,
  28571. 0x0851ed2,0x0b25824,0x055ecb5,0x12049d9,0x3fe1adf,0x11b1385,
  28572. 0x28eab06,0x11fac21,0x00513f0 } },
  28573. /* 10 */
  28574. { { 0x35bdf53,0x1847d37,0x1a6dc07,0x29d62c4,0x045d331,0x313b8e5,
  28575. 0x165daf1,0x1e34562,0x3e75a58,0x16ea2fa,0x02dd302,0x3302862,
  28576. 0x3eb8bae,0x2266a48,0x00cf2a3 },
  28577. { 0x24fd048,0x324a074,0x025df98,0x1662eec,0x3841bfb,0x26ae754,
  28578. 0x1df8cec,0x0113ae3,0x0b67fef,0x094e293,0x2323666,0x0ab087c,
  28579. 0x2f06509,0x0e142d9,0x00a919d } },
  28580. /* 11 */
  28581. { { 0x1d480d8,0x00ed021,0x3a7d3db,0x1e46ca1,0x28cd9f4,0x2a3ceeb,
  28582. 0x24dc754,0x0624a3c,0x0003db4,0x1520bae,0x1c56e0f,0x2fe7ace,
  28583. 0x1dc6f38,0x0c826a4,0x008b977 },
  28584. { 0x209cfc2,0x2c16c9c,0x1b70a31,0x21416cb,0x34c49bf,0x186549e,
  28585. 0x062498d,0x146e959,0x0391fac,0x08ff944,0x2b4b834,0x013d57a,
  28586. 0x2eabffb,0x0370131,0x00c07c1 } },
  28587. /* 12 */
  28588. { { 0x332f048,0x0bf9336,0x16dfad2,0x2451d7b,0x35f23bf,0x299adb2,
  28589. 0x0ce0c0a,0x0170294,0x289f034,0x2b7d89e,0x395e2d6,0x1d20df7,
  28590. 0x2e64e36,0x16dae90,0x00081c9 },
  28591. { 0x31d6ceb,0x0f80db9,0x0271eba,0x33db1ac,0x1b45bcc,0x1a11c07,
  28592. 0x347e630,0x148fd9e,0x142e712,0x3183e3e,0x1cd47ad,0x108d1c9,
  28593. 0x09cbb82,0x35e61d9,0x0083027 } },
  28594. /* 13 */
  28595. { { 0x215b0b8,0x0a7a98d,0x2c41b39,0x3f69536,0x0b41441,0x16da8da,
  28596. 0x15d556b,0x3c17a26,0x129167e,0x3ea0351,0x2d25a27,0x2f2d285,
  28597. 0x15b68f6,0x2931ef5,0x00210d6 },
  28598. { 0x1351130,0x012aec9,0x37ebf38,0x26640f8,0x01d2df6,0x2130972,
  28599. 0x201efc0,0x23a457c,0x087a1c6,0x14c68a3,0x163f62a,0x36b494d,
  28600. 0x015d481,0x39c35b1,0x005dd6d } },
  28601. /* 14 */
  28602. { { 0x06612ce,0x11c3f61,0x199729f,0x3b36863,0x2986f3e,0x3cd2be1,
  28603. 0x04c1612,0x2be2dae,0x00846dd,0x3d7bc29,0x249e795,0x1016803,
  28604. 0x37a3714,0x2c5aa8b,0x005f491 },
  28605. { 0x341b38d,0x01eb936,0x3caac7f,0x27863ef,0x1ef7d11,0x1110ec6,
  28606. 0x18e0761,0x26498e8,0x01a79a1,0x390d5a1,0x22226fb,0x3d2a473,
  28607. 0x0872191,0x1230f32,0x00dc772 } },
  28608. /* 15 */
  28609. { { 0x0b1ec9d,0x03fc6b9,0x3706d57,0x03b9fbb,0x221d23e,0x2867821,
  28610. 0x1e40f4c,0x2c9c0f3,0x3c4cd4b,0x31f5948,0x3f13aa6,0x307c1b2,
  28611. 0x04b6016,0x116b453,0x005aa72 },
  28612. { 0x0b74de8,0x20519d1,0x134e37f,0x05d882a,0x1839e7a,0x3a2c6a8,
  28613. 0x0d14e8d,0x1d78bdd,0x251f30d,0x3a1e27e,0x081c261,0x2c9014b,
  28614. 0x165ee09,0x19e0cf1,0x00654e2 } },
  28615. /* 16 */
  28616. { { 0x39fbe67,0x081778b,0x0e44378,0x20dfdca,0x1c4afcb,0x20b803c,
  28617. 0x0ec06c6,0x1508f6f,0x1c3114d,0x3bca851,0x3a52463,0x07661d1,
  28618. 0x17b0aa0,0x16c5f5c,0x00fc093 },
  28619. { 0x0d01f95,0x0ef13f5,0x2d34965,0x2a25582,0x39aa83e,0x3e38fcf,
  28620. 0x3943dca,0x385bbdd,0x210e86f,0x3dc1dd2,0x3f9ffdc,0x18b9bc6,
  28621. 0x345c96b,0x0e79621,0x008a72f } },
  28622. /* 17 */
  28623. { { 0x341c342,0x3793688,0x042273a,0x153a9c1,0x3dd326e,0x1d073bc,
  28624. 0x2c7d983,0x05524cd,0x00d59e6,0x347abe8,0x3d9a3ef,0x0fb624a,
  28625. 0x2c7e4cd,0x09b3171,0x0003faf },
  28626. { 0x045f8ac,0x38bf3cc,0x1e73087,0x0c85d3c,0x314a655,0x382be69,
  28627. 0x384f28f,0x24d6cb3,0x2842cdc,0x1777f5e,0x2929c89,0x03c45ed,
  28628. 0x3cfcc4c,0x0b59322,0x0035657 } },
  28629. /* 18 */
  28630. { { 0x18c1bba,0x2eb005f,0x33d57ec,0x30e42c3,0x36058f9,0x1865f43,
  28631. 0x2116e3f,0x2c4a2bb,0x0684033,0x0f1375c,0x0209b98,0x2136e9b,
  28632. 0x1bc4af0,0x0b3e0c7,0x0097c7c },
  28633. { 0x16010e8,0x398777e,0x2a172f4,0x0814a7e,0x0d97e4e,0x274dfc8,
  28634. 0x2666606,0x1b5c93b,0x1ed3d36,0x3f3304e,0x13488e0,0x02dbb88,
  28635. 0x2d53369,0x3717ce9,0x007cad1 } },
  28636. /* 19 */
  28637. { { 0x257a41f,0x2a6a076,0x39b6660,0x04bb000,0x1e74a04,0x3876b45,
  28638. 0x343c6b5,0x0753108,0x3f54668,0x24a13cf,0x23749e8,0x0421fc5,
  28639. 0x32f13b5,0x0f31be7,0x00070f2 },
  28640. { 0x1186e14,0x0847697,0x0dff542,0x0dff76c,0x084748f,0x2c7d060,
  28641. 0x23aab4d,0x0b43906,0x27ba640,0x1497b59,0x02f5835,0x0a492a4,
  28642. 0x0a6892f,0x39f3e91,0x005844e } },
  28643. /* 20 */
  28644. { { 0x33b236f,0x02181cf,0x21dafab,0x0760788,0x019e9d4,0x249ed0a,
  28645. 0x36571e3,0x3c7dbcf,0x1337550,0x010d22a,0x285e62f,0x19ee65a,
  28646. 0x052bf71,0x1d65fd5,0x0062d43 },
  28647. { 0x2955926,0x3fae7bc,0x0353d85,0x07db7de,0x1440a56,0x328dad6,
  28648. 0x1668ec9,0x28058e2,0x1a1a22d,0x1014afc,0x3609325,0x3effdcb,
  28649. 0x209f3bd,0x3ca3888,0x0094e50 } },
  28650. /* 21 */
  28651. { { 0x062e8af,0x0b96ccc,0x136990b,0x1d7a28f,0x1a85723,0x0076dec,
  28652. 0x21b00b2,0x06a88ff,0x2f0ee65,0x1fa49b7,0x39b10ad,0x10b26fa,
  28653. 0x0be7465,0x026e8bf,0x00098e3 },
  28654. { 0x3f1d63f,0x37bacff,0x1374779,0x02882ff,0x323d0e8,0x1da3de5,
  28655. 0x12bb3b8,0x0a15a11,0x34d1f95,0x2b3dd6e,0x29ea3fa,0x39ad000,
  28656. 0x33a538f,0x390204d,0x0012bd3 } },
  28657. /* 22 */
  28658. { { 0x04cbba5,0x0de0344,0x1d4cc02,0x11fe8d7,0x36207e7,0x32a6da8,
  28659. 0x0239281,0x1ec40d7,0x3e89798,0x213fc66,0x0022eee,0x11daefe,
  28660. 0x3e74db8,0x28534ee,0x00aa0a4 },
  28661. { 0x07d4543,0x250cc46,0x206620f,0x1c1e7db,0x1321538,0x31fa0b8,
  28662. 0x30f74ea,0x01aae0e,0x3a2828f,0x3e9dd22,0x026ef35,0x3c0a62b,
  28663. 0x27dbdc5,0x01c23a6,0x000f0c5 } },
  28664. /* 23 */
  28665. { { 0x2f029dd,0x3091337,0x21b80c5,0x21e1419,0x13dabc6,0x3847660,
  28666. 0x12b865f,0x36eb666,0x38f6274,0x0ba6006,0x098da24,0x1398c64,
  28667. 0x13d08e5,0x246a469,0x009929a },
  28668. { 0x1285887,0x3ff5c8d,0x010237b,0x097c506,0x0bc7594,0x34b9b88,
  28669. 0x00cc35f,0x0bb964a,0x00cfbc4,0x29cd718,0x0837619,0x2b4a192,
  28670. 0x0c57bb7,0x08c69de,0x00a3627 } },
  28671. /* 24 */
  28672. { { 0x1361ed8,0x266d724,0x366cae7,0x1d5b18c,0x247d71b,0x2c9969a,
  28673. 0x0dd5211,0x1edd153,0x25998d7,0x0380856,0x3ab29db,0x09366de,
  28674. 0x1e53644,0x2b31ff6,0x008b0ff },
  28675. { 0x3b5d9ef,0x217448d,0x174746d,0x18afea4,0x15b106d,0x3e66e8b,
  28676. 0x0479f85,0x13793b4,0x1231d10,0x3c39bce,0x25e8983,0x2a13210,
  28677. 0x05a7083,0x382be04,0x00a9507 } },
  28678. /* 25 */
  28679. { { 0x0cf381c,0x1a29b85,0x31ccf6c,0x2f708b8,0x3af9d27,0x2a29732,
  28680. 0x168d4da,0x393488d,0x2c0e338,0x3f90c7b,0x0f52ad1,0x2a0a3fa,
  28681. 0x2cd80f1,0x15e7a1a,0x00db6a0 },
  28682. { 0x107832a,0x159cb91,0x1289288,0x17e21f9,0x073fc27,0x1584342,
  28683. 0x3802780,0x3d6c197,0x154075f,0x16366d1,0x09f712b,0x23a3ec4,
  28684. 0x29cf23a,0x3218baf,0x0039f0a } },
  28685. /* 26 */
  28686. { { 0x052edf5,0x2afde13,0x2e53d8f,0x3969626,0x3dcd737,0x1e46ac5,
  28687. 0x118bf0d,0x01b2652,0x156bcff,0x16d7ef6,0x1ca46d4,0x34c0cbb,
  28688. 0x3e486f6,0x1f85068,0x002cdff },
  28689. { 0x1f47ec8,0x12cee98,0x0608667,0x18fbbe1,0x08a8821,0x31a1fe4,
  28690. 0x17c7054,0x3c89e89,0x2edf6cd,0x1b8c32c,0x3f6ea84,0x1319329,
  28691. 0x3cd3c2c,0x05f331a,0x00186fa } },
  28692. /* 27 */
  28693. { { 0x1fcb91e,0x0fd4d87,0x358a48a,0x04d91b4,0x083595e,0x044a1e6,
  28694. 0x15827b9,0x1d5eaf4,0x2b82187,0x08f3984,0x21bd737,0x0c54285,
  28695. 0x2f56887,0x14c2d98,0x00f4684 },
  28696. { 0x01896f6,0x0e542d0,0x2090883,0x269dfcf,0x1e11cb8,0x239fd29,
  28697. 0x312cac4,0x19dfacb,0x369f606,0x0cc4f75,0x16579f9,0x33c22cc,
  28698. 0x0f22bfd,0x3b251ae,0x006429c } },
  28699. /* 28 */
  28700. { { 0x375f9a4,0x137552e,0x3570498,0x2e4a74e,0x24aef06,0x35b9307,
  28701. 0x384ca23,0x3bcd6d7,0x011b083,0x3c93187,0x392ca9f,0x129ce48,
  28702. 0x0a800ce,0x145d9cc,0x00865d6 },
  28703. { 0x22b4a2b,0x37f9d9c,0x3e0eca3,0x3e5ec20,0x112c04b,0x2e1ae29,
  28704. 0x3ce5b51,0x0f83200,0x32d6a7e,0x10ff1d8,0x081adbe,0x265c30b,
  28705. 0x216b1c8,0x0eb4483,0x003cbcd } },
  28706. /* 29 */
  28707. { { 0x030ce93,0x2d331fb,0x20a2fbf,0x1f6dc9c,0x010ed6c,0x1ed5540,
  28708. 0x275bf74,0x3df0fb1,0x103333f,0x0241c96,0x1075bfc,0x30e5cf9,
  28709. 0x0f31bc7,0x32c01eb,0x00b049e },
  28710. { 0x358839c,0x1dbabd3,0x1e4fb40,0x36a8ac1,0x2101896,0x2d0319b,
  28711. 0x2033b0a,0x192e8fd,0x2ebc8d8,0x2867ba7,0x07bf6d2,0x1b3c555,
  28712. 0x2477deb,0x198fe09,0x008e5a9 } },
  28713. /* 30 */
  28714. { { 0x3fbd5e1,0x18bf77d,0x2b1d69e,0x151da44,0x338ecfe,0x0768efe,
  28715. 0x1a3d56d,0x3c35211,0x10e1c86,0x2012525,0x3bc36ce,0x32b6fe4,
  28716. 0x0c8d183,0x15c93f3,0x0041fce },
  28717. { 0x332c144,0x24e70a0,0x246e05f,0x22c21c7,0x2b17f24,0x1ba2bfd,
  28718. 0x0534e26,0x318a4f6,0x1dc3b85,0x0c741bc,0x23131b7,0x01a8cba,
  28719. 0x364e5db,0x21362cf,0x00f2951 } },
  28720. /* 31 */
  28721. { { 0x2ddc103,0x14ffdcd,0x206fd96,0x0de57bd,0x025f43e,0x381b73a,
  28722. 0x2301fcf,0x3bafc27,0x34130b6,0x0216bc8,0x0ff56b2,0x2c4ad4c,
  28723. 0x23c6b79,0x1267fa6,0x009b4fb },
  28724. { 0x1d27ac2,0x13e2494,0x1389015,0x38d5b29,0x2d33167,0x3f01969,
  28725. 0x28ec1fa,0x1b26de0,0x2587f74,0x1c25668,0x0c44f83,0x23c6f8c,
  28726. 0x32fdbb1,0x045f104,0x00a7946 } },
  28727. /* 32 */
  28728. { { 0x23c647b,0x09addd7,0x1348c04,0x0e633c1,0x1bfcbd9,0x1cb034f,
  28729. 0x1312e31,0x11cdcc7,0x1e6ee75,0x057d27f,0x2da7ee6,0x154c3c1,
  28730. 0x3a5fb89,0x2c2ba2c,0x00cf281 },
  28731. { 0x1b8a543,0x125cd50,0x1d30fd1,0x29cc203,0x341a625,0x14e4233,
  28732. 0x3aae076,0x289e38a,0x036ba02,0x230f405,0x3b21b8f,0x34088b9,
  28733. 0x01297a0,0x03a75fb,0x00fdc27 } },
  28734. /* 33 */
  28735. { { 0x07f41d6,0x1cf032f,0x1641008,0x0f86deb,0x3d97611,0x0e110fe,
  28736. 0x136ff42,0x0b914a9,0x0e241e6,0x180c340,0x1f545fc,0x0ba619d,
  28737. 0x1208c53,0x04223a4,0x00cd033 },
  28738. { 0x397612c,0x0132665,0x34e2d1a,0x00bba99,0x1d4393e,0x065d0a8,
  28739. 0x2fa69ee,0x1643b55,0x08085f0,0x3774aad,0x08a2243,0x33bf149,
  28740. 0x03f41a5,0x1ed950e,0x0048cc6 } },
  28741. /* 34 */
  28742. { { 0x014ab48,0x010c3bf,0x2a744e5,0x13c99c1,0x2195b7f,0x32207fd,
  28743. 0x28a228c,0x004f4bf,0x0e2d945,0x2ec6e5a,0x0b92162,0x1aa95e5,
  28744. 0x2754a93,0x1adcd93,0x004fb76 },
  28745. { 0x1e1ff7f,0x24ef28c,0x269113f,0x32b393c,0x2696eb5,0x0ac2780,
  28746. 0x354bf8a,0x0ffe3fd,0x09ce58e,0x0163c4f,0x1678c0b,0x15cd1bc,
  28747. 0x292b3b7,0x036ea19,0x00d5420 } },
  28748. /* 35 */
  28749. { { 0x1da1265,0x0c2ef5b,0x18dd9a0,0x3f3a25c,0x0f7b4f3,0x0d8196e,
  28750. 0x24931f9,0x090729a,0x1875f72,0x1ef39cb,0x2577585,0x2ed472d,
  28751. 0x136756c,0x20553a6,0x00c7161 },
  28752. { 0x2e32189,0x283de4b,0x00b2e81,0x0989df7,0x3ef2fab,0x1c7d1a7,
  28753. 0x24f6feb,0x3e16679,0x233dfda,0x06d1233,0x3e6b5df,0x1707132,
  28754. 0x05f7b3f,0x2c00779,0x00fb8df } },
  28755. /* 36 */
  28756. { { 0x15bb921,0x117e9d3,0x267ec73,0x2f934ad,0x25c7e04,0x20b5e8f,
  28757. 0x2d3a802,0x2ca911f,0x3f87e47,0x39709dd,0x08488e2,0x2cec400,
  28758. 0x35b4589,0x1f0acba,0x009aad7 },
  28759. { 0x2ac34ae,0x06f29f6,0x3326d68,0x3949abe,0x02452e4,0x0687b85,
  28760. 0x0879244,0x1eb7832,0x0d4c240,0x31d0ec1,0x3c17a2a,0x17a666f,
  28761. 0x01a06cb,0x3e0929c,0x004dca2 } },
  28762. /* 37 */
  28763. { { 0x127bc1a,0x0c72984,0x13be68e,0x26c5fab,0x1a3edd5,0x097d685,
  28764. 0x36b645e,0x385799e,0x394a420,0x39d8885,0x0b1e872,0x13f60ed,
  28765. 0x2ce1b79,0x3c0ecb7,0x007cab3 },
  28766. { 0x29b3586,0x26fc572,0x0bd7711,0x0913494,0x0a55459,0x31af3c9,
  28767. 0x3633eac,0x3e2105c,0x0c2b1b6,0x0e6f4c2,0x047d38c,0x2b81bd5,
  28768. 0x1fe1c3b,0x04d7cd0,0x0054dcc } },
  28769. /* 38 */
  28770. { { 0x03caf0d,0x0d66365,0x313356d,0x2a4897f,0x2ce044e,0x18feb7a,
  28771. 0x1f6a7c5,0x3709e7b,0x14473e8,0x2d8cbae,0x3190dca,0x12d19f8,
  28772. 0x31e3181,0x3cc5b6e,0x002d4f4 },
  28773. { 0x143b7ca,0x2604728,0x39508d6,0x0cb79f3,0x24ec1ac,0x1ed7fa0,
  28774. 0x3ab5fd3,0x3c76488,0x2e49390,0x03a0985,0x3580461,0x3fd2c81,
  28775. 0x308f0ab,0x38561d6,0x0011b9b } },
  28776. /* 39 */
  28777. { { 0x3be682c,0x0c68f4e,0x32dd4ae,0x099d3bb,0x0bc7c5d,0x311f750,
  28778. 0x2fd10a3,0x2e7864a,0x23bc14a,0x13b1f82,0x32e495e,0x1b0f746,
  28779. 0x3cd856a,0x17a4c26,0x00085ee },
  28780. { 0x02e67fd,0x06a4223,0x2af2f38,0x2038987,0x132083a,0x1b7bb85,
  28781. 0x0d6a499,0x131e43f,0x3035e52,0x278ee3e,0x1d5b08b,0x30d8364,
  28782. 0x2719f8d,0x0b21fc9,0x003a06e } },
  28783. /* 40 */
  28784. { { 0x237cac0,0x27d6a1c,0x27945cd,0x2750d61,0x293f0b5,0x253db13,
  28785. 0x04a764e,0x20b4d0e,0x12bb627,0x160c13b,0x0de0601,0x236e2cf,
  28786. 0x2190f0b,0x354d76f,0x004336d },
  28787. { 0x2ab473a,0x10d54e4,0x1046574,0x1d6f97b,0x0031c72,0x06426a9,
  28788. 0x38678c2,0x0b76cf9,0x04f9920,0x152adf8,0x2977e63,0x1234819,
  28789. 0x198be26,0x061024c,0x00d427d } },
  28790. /* 41 */
  28791. { { 0x39b5a31,0x2123d43,0x362a822,0x1a2eab6,0x0bb0034,0x0d5d567,
  28792. 0x3a04723,0x3a10c8c,0x08079ae,0x0d27bda,0x2eb9e1e,0x2619e82,
  28793. 0x39a55a8,0x0c6c7db,0x00c1519 },
  28794. { 0x174251e,0x13ac2eb,0x295ed26,0x18d2afc,0x037b9b2,0x1258344,
  28795. 0x00921b0,0x1f702d8,0x1bc4da7,0x1c3794f,0x12b1869,0x366eacf,
  28796. 0x16ddf01,0x31ebdc5,0x00ad54e } },
  28797. /* 42 */
  28798. { { 0x1efdc58,0x1370d5e,0x0ddb8e7,0x1a53fda,0x1456bd3,0x0c825a9,
  28799. 0x0e74ccd,0x20f41c9,0x3423867,0x139073f,0x3c70d8a,0x131fc85,
  28800. 0x219a2a0,0x34bf986,0x0041199 },
  28801. { 0x1c05dd2,0x268f80a,0x3da9d38,0x1af9f8f,0x0535f2a,0x30ad37e,
  28802. 0x2cf72d7,0x14a509b,0x1f4fe74,0x259e09d,0x1d23f51,0x0672732,
  28803. 0x08fc463,0x00b6201,0x001e05a } },
  28804. /* 43 */
  28805. { { 0x0d5ffe8,0x3238bb5,0x17f275c,0x25b6fa8,0x2f8bb48,0x3b8f2d2,
  28806. 0x059790c,0x18594d4,0x285a47c,0x3d301bb,0x12935d2,0x23ffc96,
  28807. 0x3d7c7f9,0x15c8cbf,0x0034c4a },
  28808. { 0x20376a2,0x05201ba,0x1e02c4b,0x1413c45,0x02ea5e7,0x39575f0,
  28809. 0x2d76e21,0x113694c,0x011f310,0x0da3725,0x31b7799,0x1cb9195,
  28810. 0x0cfd592,0x22ee4ea,0x00adaa3 } },
  28811. /* 44 */
  28812. { { 0x14ed72a,0x031c49f,0x39a34bf,0x192e87d,0x0da0e92,0x130e7a9,
  28813. 0x00258bf,0x144e123,0x2d82a71,0x0294e53,0x3f06c66,0x3d4473a,
  28814. 0x037cd4a,0x3bbfb17,0x00fcebc },
  28815. { 0x39ae8c1,0x2dd6a9d,0x206ef23,0x332b479,0x2deff59,0x09d5720,
  28816. 0x3526fd2,0x33bf7cf,0x344bb32,0x359316a,0x115bdef,0x1b8468a,
  28817. 0x3813ea9,0x11a8450,0x00ab197 } },
  28818. /* 45 */
  28819. { { 0x0837d7d,0x1e1617b,0x0ba443c,0x2f2e3b8,0x2ca5b6f,0x176ed7b,
  28820. 0x2924d9d,0x07294d3,0x104bb4f,0x1cfd3e8,0x398640f,0x1162dc8,
  28821. 0x007ea15,0x2aa75fd,0x004231f },
  28822. { 0x16e6896,0x01987be,0x0f9d53e,0x1a740ec,0x1554e4c,0x31e1634,
  28823. 0x3cb07b9,0x013eb53,0x39352cb,0x1dfa549,0x0974e7f,0x17c55d2,
  28824. 0x157c85f,0x1561adb,0x002e3fa } },
  28825. /* 46 */
  28826. { { 0x29951a8,0x35200da,0x2ad042c,0x22109e4,0x3a8b15b,0x2eca69c,
  28827. 0x28bcf9a,0x0cfa063,0x0924099,0x12ff668,0x2fb88dc,0x028d653,
  28828. 0x2445876,0x218d01c,0x0014418 },
  28829. { 0x1caedc7,0x295bba6,0x01c9162,0x3364744,0x28fb12e,0x24c80b6,
  28830. 0x2719673,0x35e5ba9,0x04aa4cc,0x206ab23,0x1cf185a,0x2c140d8,
  28831. 0x1095a7d,0x1b3633f,0x000c9f8 } },
  28832. /* 47 */
  28833. { { 0x0b2a556,0x0a051c4,0x30b29a7,0x190c9ed,0x3767ca9,0x38de66d,
  28834. 0x2d9e125,0x3aca813,0x2dc22a3,0x319e074,0x0d9450a,0x3445bac,
  28835. 0x3e08a5b,0x07f29fa,0x00eccac },
  28836. { 0x02d6e94,0x21113f7,0x321bde6,0x0a4d7b3,0x03621f4,0x2780e8b,
  28837. 0x22d5432,0x1fc2853,0x0d57d3e,0x254f90b,0x33ed00b,0x289b025,
  28838. 0x12272bb,0x30e715f,0x0000297 } },
  28839. /* 48 */
  28840. { { 0x0243a7d,0x2aac42e,0x0c5b3aa,0x0fa3e96,0x06eeef9,0x2b9fdd9,
  28841. 0x26fca39,0x0134fe1,0x22661ab,0x1990416,0x03945d6,0x15e3628,
  28842. 0x3848ca3,0x0f91e46,0x00b08cd },
  28843. { 0x16d2411,0x3717e1d,0x128c45e,0x3669d54,0x0d4a790,0x2797da8,
  28844. 0x0f09634,0x2faab0b,0x27df649,0x3b19b49,0x0467039,0x39b65a2,
  28845. 0x3816f3c,0x31ad0bd,0x0050046 } },
  28846. /* 49 */
  28847. { { 0x2425043,0x3858099,0x389092a,0x3f7c236,0x11ff66a,0x3c58b39,
  28848. 0x2f5a7f8,0x1663ce1,0x2a0fcf5,0x38634b7,0x1a8ca18,0x0dcace8,
  28849. 0x0e6f778,0x03ae334,0x00df0d2 },
  28850. { 0x1bb4045,0x357875d,0x14b77ed,0x33ae5b6,0x2252a47,0x31899dd,
  28851. 0x3293582,0x040c6f6,0x14340dd,0x3614f0e,0x3d5f47f,0x326fb3d,
  28852. 0x0044a9d,0x00beeb9,0x0027c23 } },
  28853. /* 50 */
  28854. { { 0x32d49ce,0x34822a3,0x30a22d1,0x00858b7,0x10d91aa,0x2681fd9,
  28855. 0x1cce870,0x2404a71,0x38b8433,0x377c1c8,0x019442c,0x0a38b21,
  28856. 0x22aba50,0x0d61c81,0x002dcbd },
  28857. { 0x0680967,0x2f0f2f9,0x172cb5f,0x1167e4b,0x12a7bc6,0x05b0da7,
  28858. 0x2c76e11,0x3a36201,0x37a3177,0x1d71419,0x0569df5,0x0dce7ad,
  28859. 0x3f40b75,0x3bd8db0,0x002d481 } },
  28860. /* 51 */
  28861. { { 0x2a1103e,0x34e7f7f,0x1b171a2,0x24a57e0,0x2eaae55,0x166c992,
  28862. 0x10aa18f,0x0bb836f,0x01acb59,0x0e430e7,0x1750cca,0x18be036,
  28863. 0x3cc6cdf,0x0a0f7e5,0x00da4d8 },
  28864. { 0x2201067,0x374d187,0x1f6b0a6,0x165a7ec,0x31531f8,0x3580487,
  28865. 0x15e5521,0x0724522,0x2b04c04,0x202c86a,0x3cc1ccf,0x225b11a,
  28866. 0x1bde79d,0x0eccc50,0x00d24da } },
  28867. /* 52 */
  28868. { { 0x3b0a354,0x2814dd4,0x1cd8575,0x3d031b7,0x0392ff2,0x1855ee5,
  28869. 0x0e8cff5,0x203442e,0x3bd3b1b,0x141cf95,0x3fedee1,0x1d783c0,
  28870. 0x26f192a,0x0392aa3,0x0075238 },
  28871. { 0x158ffe9,0x3889f19,0x14151f4,0x06067b1,0x13a3486,0x1e65c21,
  28872. 0x382d5ef,0x1ab0aac,0x2ffddc4,0x3179b7a,0x3c8d094,0x05101e3,
  28873. 0x237c6e5,0x3947d83,0x00f674f } },
  28874. /* 53 */
  28875. { { 0x363408f,0x21eb96b,0x27376fb,0x2a735d6,0x1a39c36,0x3d31863,
  28876. 0x33313fc,0x32235e0,0x082f034,0x23ef351,0x39b3528,0x1a69d84,
  28877. 0x1d9c944,0x07159ad,0x0077a71 },
  28878. { 0x04f8d65,0x25771e5,0x2ba84a6,0x194586a,0x1e6da5f,0x118059a,
  28879. 0x14e9c32,0x1d24619,0x3f528ae,0x22f22e4,0x0f5580d,0x0747a0e,
  28880. 0x32cc85f,0x286b3a8,0x008ccf9 } },
  28881. /* 54 */
  28882. { { 0x196fee2,0x2c4431c,0x094528a,0x18e1d32,0x175799d,0x26bb6b7,
  28883. 0x2293482,0x23fd289,0x07b2be8,0x1a5c533,0x158d60d,0x04a4f3f,
  28884. 0x164e9f7,0x32ccca9,0x00da6b6 },
  28885. { 0x1d821c2,0x3f76c4f,0x323df43,0x17e4374,0x0f2f278,0x121227e,
  28886. 0x2464190,0x19d2644,0x326d24c,0x3185983,0x0803c15,0x0767a33,
  28887. 0x1c4c996,0x0563eab,0x00631c6 } },
  28888. /* 55 */
  28889. { { 0x1752366,0x0baf83f,0x288bacf,0x0384e6f,0x2b93c34,0x3c805e7,
  28890. 0x3664850,0x29e1663,0x254ff1d,0x3852080,0x0f85c16,0x1e389d9,
  28891. 0x3191352,0x3915eaa,0x00a246e },
  28892. { 0x3763b33,0x187ad14,0x3c0d438,0x3f11702,0x1c49f03,0x35ac7a8,
  28893. 0x3f16bca,0x27266bf,0x08b6fd4,0x0f38ce4,0x37fde8c,0x147a6ff,
  28894. 0x02c5e5c,0x28e7fc5,0x00076a7 } },
  28895. /* 56 */
  28896. { { 0x2338d10,0x0e77fa7,0x011b046,0x1bfd0ad,0x28ee699,0x21d73bc,
  28897. 0x0461d1a,0x342ea58,0x2d695b4,0x30415ed,0x2906e0b,0x18e494a,
  28898. 0x20f8a27,0x026b870,0x002c19f },
  28899. { 0x2f4c43d,0x3f0fc3b,0x0aa95b8,0x2a01ea1,0x3e2e1b1,0x0d74af6,
  28900. 0x0555288,0x0cb757d,0x24d2071,0x143d2bb,0x3907f67,0x3e0ce30,
  28901. 0x131f0e9,0x3724381,0x007a874 } },
  28902. /* 57 */
  28903. { { 0x3c27050,0x08b5165,0x0bf884b,0x3dd679c,0x3bd0b8d,0x25ce2e6,
  28904. 0x1674057,0x1f13ed3,0x1f5cd91,0x0d1fd35,0x13ce6e3,0x2671338,
  28905. 0x10f8b90,0x34e5487,0x00942bf },
  28906. { 0x03b566d,0x23c3da9,0x37de502,0x1a486ff,0x1af6e86,0x1108cb3,
  28907. 0x36f856c,0x01a6a0f,0x179f915,0x1595a01,0x2cfecb8,0x082568b,
  28908. 0x1ba16d1,0x1abb6c0,0x00cf7f0 } },
  28909. /* 58 */
  28910. { { 0x2f96c80,0x1b8f123,0x209c0f5,0x2ccf76d,0x1d521f2,0x3705143,
  28911. 0x2941027,0x07f88af,0x07102a9,0x38b4868,0x1efa37d,0x1bdd3e8,
  28912. 0x028a12e,0x02e055b,0x009a9a9 },
  28913. { 0x1c7dfcb,0x3aa7aa7,0x1d62c54,0x3f0b0b0,0x3c74e66,0x274f819,
  28914. 0x23f9674,0x0e2b67c,0x24654dd,0x0c71f0e,0x1946cee,0x0016211,
  28915. 0x0045dc7,0x0da1173,0x0089856 } },
  28916. /* 59 */
  28917. { { 0x0e73946,0x29f353f,0x056329d,0x2d48c5a,0x28f697d,0x2ea4bb1,
  28918. 0x235e9cc,0x34faa38,0x15f9f91,0x3557519,0x2a50a6c,0x1a27c8e,
  28919. 0x2a1a0f3,0x3098879,0x00dcf21 },
  28920. { 0x1b818bf,0x2f20b98,0x2243cff,0x25b691e,0x3c74a2f,0x2f06833,
  28921. 0x0e980a8,0x32db48d,0x2b57929,0x33cd7f5,0x2fe17d6,0x11a384b,
  28922. 0x2dafb81,0x2b9562c,0x00ddea6 } },
  28923. /* 60 */
  28924. { { 0x2787b2e,0x37a21df,0x310d294,0x07ce6a4,0x1258acc,0x3050997,
  28925. 0x19714aa,0x122824b,0x11c708b,0x0462d56,0x21abbf7,0x331aec3,
  28926. 0x307b927,0x3e8d5a0,0x00c0581 },
  28927. { 0x24d4d58,0x3d628fc,0x23279e0,0x2e38338,0x2febe9b,0x346f9c0,
  28928. 0x3d6a419,0x3264e47,0x245faca,0x3669f62,0x1e50d66,0x3028232,
  28929. 0x18201ab,0x0bdc192,0x0002c34 } },
  28930. /* 61 */
  28931. { { 0x17bdbc2,0x1c501c5,0x1605ccd,0x31ab438,0x372fa89,0x24a8057,
  28932. 0x13da2bb,0x3f95ac7,0x3cda0a3,0x1e2b679,0x24f0673,0x03b72f4,
  28933. 0x35be616,0x2ccd849,0x0079d4d },
  28934. { 0x33497c4,0x0c7f657,0x2fb0d3d,0x3b81064,0x38cafea,0x0e942bc,
  28935. 0x3ca7451,0x2ab9784,0x1678c85,0x3c62098,0x1eb556f,0x01b3aa2,
  28936. 0x149f3ce,0x2656f6d,0x002eef1 } },
  28937. /* 62 */
  28938. { { 0x0596edc,0x1f4fad4,0x03a28ed,0x18a4149,0x3aa3593,0x12db40a,
  28939. 0x12c2c2a,0x3b1a288,0x327c4fb,0x35847f5,0x384f733,0x02e3fde,
  28940. 0x1af0e8a,0x2e417c3,0x00d85a6 },
  28941. { 0x0091cf7,0x2267d75,0x276860e,0x19cbbfc,0x04fef2b,0x030ce59,
  28942. 0x3195cb1,0x1aa3f07,0x3699362,0x2a09d74,0x0d6c840,0x1e413d0,
  28943. 0x28acdc7,0x1ff5ea1,0x0088d8b } },
  28944. /* 63 */
  28945. { { 0x3d98425,0x08dc8de,0x154e85f,0x24b1c2c,0x2d44639,0x19a1e8b,
  28946. 0x300ee29,0x053f72e,0x3f7c832,0x12417f6,0x1359368,0x0674a4c,
  28947. 0x1218e20,0x0e4fbd4,0x000428c },
  28948. { 0x01e909a,0x1d88fe6,0x12da40c,0x215ef86,0x2925133,0x004241f,
  28949. 0x3e480f4,0x2d16523,0x07c3120,0x3375e86,0x21fd8f3,0x35dc0b6,
  28950. 0x0efc5c9,0x14ef8d6,0x0066e47 } },
  28951. /* 64 */
  28952. { { 0x2973cf4,0x34d3845,0x34f7070,0x22df93c,0x120aee0,0x3ae2b4a,
  28953. 0x1af9b95,0x177689a,0x036a6a4,0x0377828,0x23df41e,0x22d4a39,
  28954. 0x0df2aa1,0x06ca898,0x0003cc7 },
  28955. { 0x06b1dd7,0x19dc2a8,0x35d324a,0x0467499,0x25bfa9c,0x1a1110c,
  28956. 0x01e2a19,0x1b3c1cf,0x18d131a,0x10d9815,0x2ee7945,0x0a2720c,
  28957. 0x0ddcdb0,0x2c071b6,0x00a6aef } },
  28958. /* 65 */
  28959. { { 0x1ab5245,0x1192d00,0x13ffba1,0x1b71236,0x09b8d0b,0x0eb49cb,
  28960. 0x1867dc9,0x371de4e,0x05eae9f,0x36faf82,0x094ea8b,0x2b9440e,
  28961. 0x022e173,0x2268e6b,0x00740fc },
  28962. { 0x0e23b23,0x22c28ca,0x04d05e2,0x0bb84c4,0x1235272,0x0289903,
  28963. 0x267a18b,0x0df0fd1,0x32e49bb,0x2ab1d29,0x281e183,0x3dcd3c3,
  28964. 0x1c0eb79,0x2db0ff6,0x00bffe5 } },
  28965. /* 66 */
  28966. { { 0x2a2123f,0x0d63d71,0x1f6db1a,0x257f8a3,0x1927b2d,0x06674be,
  28967. 0x302753f,0x20b7225,0x14c1a3f,0x0429cdd,0x377affe,0x0f40a75,
  28968. 0x2d34d06,0x05fb6b9,0x0054398 },
  28969. { 0x38b83c4,0x1e7bbda,0x1682f79,0x0527651,0x2615cb2,0x1795fab,
  28970. 0x0e4facc,0x11f763c,0x1b81130,0x2010ae2,0x13f3650,0x20d5b72,
  28971. 0x1f32f88,0x34617f4,0x00bf008 } },
  28972. /* 67 */
  28973. { { 0x28068db,0x0aa8913,0x1a47801,0x10695ca,0x1c72cc6,0x0fc1a47,
  28974. 0x33df2c4,0x0517cf0,0x3471d92,0x1be815c,0x397f794,0x3f03cbe,
  28975. 0x121bfae,0x172cbe0,0x00813d7 },
  28976. { 0x383bba6,0x04f1c90,0x0b3f056,0x1c29089,0x2a924ce,0x3c85e69,
  28977. 0x1cecbe5,0x0ad8796,0x0aa79f6,0x25e38ba,0x13ad807,0x30b30ed,
  28978. 0x0fa963a,0x35c763d,0x0055518 } },
  28979. /* 68 */
  28980. { { 0x0623f3b,0x3ca4880,0x2bff03c,0x0457ca7,0x3095c71,0x02a9a08,
  28981. 0x1722478,0x302c10b,0x3a17458,0x001131e,0x0959ec2,0x18bdfbc,
  28982. 0x2929fca,0x2adfe32,0x0040ae2 },
  28983. { 0x127b102,0x14ddeaa,0x1771b8c,0x283700c,0x2398a86,0x085a901,
  28984. 0x108f9dc,0x0cc0012,0x33a918d,0x26d08e9,0x20b9473,0x12c3fc7,
  28985. 0x1f69763,0x1c94b5a,0x00e29de } },
  28986. /* 69 */
  28987. { { 0x035af04,0x3450021,0x12da744,0x077fb06,0x25f255b,0x0db7150,
  28988. 0x17dc123,0x1a2a07c,0x2a7636a,0x3972430,0x3704ca1,0x0327add,
  28989. 0x3d65a96,0x3c79bec,0x009de8c },
  28990. { 0x11d3d06,0x3fb8354,0x12c7c60,0x04fe7ad,0x0466e23,0x01ac245,
  28991. 0x3c0f5f2,0x2a935d0,0x3ac2191,0x090bd56,0x3febdbc,0x3f1f23f,
  28992. 0x0ed1cce,0x02079ba,0x00d4fa6 } },
  28993. /* 70 */
  28994. { { 0x0ab9645,0x10174ec,0x3711b5e,0x26357c7,0x2aeec7f,0x2170a9b,
  28995. 0x1423115,0x1a5122b,0x39e512c,0x18116b2,0x290db1c,0x041b13a,
  28996. 0x26563ae,0x0f56263,0x00b89f3 },
  28997. { 0x3ed2ce4,0x01f365f,0x1b2043b,0x05f7605,0x1f9934e,0x2a068d2,
  28998. 0x38d4d50,0x201859d,0x2de5291,0x0a7985a,0x17e6711,0x01b6c1b,
  28999. 0x08091fa,0x33c6212,0x001da23 } },
  29000. /* 71 */
  29001. { { 0x2f2c4b5,0x311acd0,0x1e47821,0x3bd9816,0x1931513,0x1bd4334,
  29002. 0x30ae436,0x2c49dc0,0x2c943e7,0x010ed4d,0x1fca536,0x189633d,
  29003. 0x17abf00,0x39e5ad5,0x00e4e3e },
  29004. { 0x0c8b22f,0x2ce4009,0x1054bb6,0x307f2fc,0x32eb5e2,0x19d24ab,
  29005. 0x3b18c95,0x0e55e4d,0x2e4acf5,0x1bc250c,0x1dbf3a5,0x17d6a74,
  29006. 0x087cf58,0x07f6f82,0x00f8675 } },
  29007. /* 72 */
  29008. { { 0x110e0b2,0x0e672e7,0x11b7157,0x1598371,0x01c0d59,0x3d60c24,
  29009. 0x096b8a1,0x0121075,0x0268859,0x219962f,0x03213f2,0x3022adc,
  29010. 0x18de488,0x3dcdeb9,0x008d2e0 },
  29011. { 0x06cfee6,0x26f2552,0x3c579b7,0x31fa796,0x2036a26,0x362ba5e,
  29012. 0x103601c,0x012506b,0x387ff3a,0x101a41f,0x2c7eb58,0x23d2efc,
  29013. 0x10a5a07,0x2fd5fa3,0x00e3731 } },
  29014. /* 73 */
  29015. { { 0x1cd0abe,0x08a0af8,0x2fa272f,0x17a1fbf,0x1d4f901,0x30e0d2f,
  29016. 0x1898066,0x273b674,0x0c1b8a2,0x3272337,0x3ee82eb,0x006e7d3,
  29017. 0x2a75606,0x0af1c81,0x0037105 },
  29018. { 0x2f32562,0x2842491,0x1bb476f,0x1305cd4,0x1daad53,0x0d8daed,
  29019. 0x164c37b,0x138030f,0x05145d5,0x300e2a3,0x32c09e7,0x0798600,
  29020. 0x3515130,0x2b9e55c,0x009764e } },
  29021. /* 74 */
  29022. { { 0x3d5256a,0x06c67f2,0x3a3b879,0x3c9b284,0x04007e0,0x33c1a41,
  29023. 0x3794604,0x1d6240e,0x022b6c1,0x22c62a7,0x01d4590,0x32df5f6,
  29024. 0x368f1a1,0x2a7486e,0x006e13f },
  29025. { 0x31e6e16,0x20f18a9,0x09ed471,0x23b861d,0x15cf0ef,0x397b502,
  29026. 0x1c7f9b2,0x05f84b2,0x2cce6e1,0x3c10bba,0x13fb5a7,0x1b52058,
  29027. 0x1feb1b8,0x03b7279,0x00ea1cf } },
  29028. /* 75 */
  29029. { { 0x2a4cc9b,0x15cf273,0x08f36e6,0x076bf3b,0x2541796,0x10e2dbd,
  29030. 0x0bf02aa,0x3aa2201,0x03cdcd4,0x3ee252c,0x3799571,0x3e01fa4,
  29031. 0x156e8d0,0x1fd6188,0x003466a },
  29032. { 0x2515664,0x166b355,0x2b0b51e,0x0f28f17,0x355b0f9,0x2909e76,
  29033. 0x206b026,0x3823a12,0x179c5fa,0x0972141,0x2663a1a,0x01ee36e,
  29034. 0x3fc8dcf,0x2ef3d1b,0x0049a36 } },
  29035. /* 76 */
  29036. { { 0x2d93106,0x3d6b311,0x3c9ce47,0x382aa25,0x265b7ad,0x0b5f92f,
  29037. 0x0f4c941,0x32aa4df,0x380d4b2,0x0e8aba6,0x260357a,0x1f38273,
  29038. 0x0d5f95e,0x199f23b,0x0029f77 },
  29039. { 0x0a0b1c5,0x21a3d6a,0x0ad8df6,0x33d8a5e,0x1240858,0x30000a8,
  29040. 0x3ac101d,0x2a8143d,0x1d7ffe9,0x1c74a2a,0x1b962c9,0x1261359,
  29041. 0x0c8b274,0x002cf4a,0x00a8a7c } },
  29042. /* 77 */
  29043. { { 0x211a338,0x22a14ab,0x16e77c5,0x3c746be,0x3a78613,0x0d5731c,
  29044. 0x1767d25,0x0b799fa,0x009792a,0x09ae8dc,0x124386b,0x183d860,
  29045. 0x176747d,0x14c4445,0x00ab09b },
  29046. { 0x0eb9dd0,0x0121066,0x032895a,0x330541c,0x1e6c17a,0x2271b92,
  29047. 0x06da454,0x054c2bf,0x20abb21,0x0ead169,0x3d7ea93,0x2359649,
  29048. 0x242c6c5,0x3194255,0x00a3ef3 } },
  29049. /* 78 */
  29050. { { 0x3010879,0x1083a77,0x217989d,0x174e55d,0x29d2525,0x0e544ed,
  29051. 0x1efd50e,0x30c4e73,0x05bd5d1,0x0793bf9,0x3f7af77,0x052779c,
  29052. 0x2b06bc0,0x13d0d02,0x0055a6b },
  29053. { 0x3eaf771,0x094947a,0x0288f13,0x0a21e35,0x22ab441,0x23816bf,
  29054. 0x15832e1,0x2d8aff3,0x348cc1f,0x2bbd4a8,0x01c4792,0x34209d3,
  29055. 0x06dc72b,0x211a1df,0x00345c5 } },
  29056. /* 79 */
  29057. { { 0x2a65e90,0x173ac2f,0x199cde1,0x0ac905b,0x00987f7,0x3618f7b,
  29058. 0x1b578df,0x0d5e113,0x34bac6a,0x27d85ed,0x1b48e99,0x18af5eb,
  29059. 0x1a1be9e,0x3987aac,0x00877ca },
  29060. { 0x2358610,0x3776a8e,0x2b0723a,0x344c978,0x22fc4d6,0x1615d53,
  29061. 0x3198f51,0x2d61225,0x12cb392,0x07dd061,0x355f7de,0x09e0132,
  29062. 0x0efae99,0x13b46aa,0x00e9e6c } },
  29063. /* 80 */
  29064. { { 0x0683186,0x36d8e66,0x0ea9867,0x0937731,0x1fb5cf4,0x13c39ef,
  29065. 0x1a7ffed,0x27dfb32,0x31c7a77,0x09f15fd,0x16b25ef,0x1dd01e7,
  29066. 0x0168090,0x240ed02,0x0090eae },
  29067. { 0x2e1fceb,0x2ab9783,0x1a1fdf2,0x093a1b0,0x33ff1da,0x2864fb7,
  29068. 0x3587d6c,0x275aa03,0x123dc9b,0x0e95a55,0x0592030,0x2102402,
  29069. 0x1bdef7b,0x37f2e9b,0x001efa4 } },
  29070. /* 81 */
  29071. { { 0x0540015,0x20e3e78,0x37dcfbd,0x11b0e41,0x02c3239,0x3586449,
  29072. 0x1fb9e6a,0x0baa22c,0x00c0ca6,0x3e58491,0x2dbe00f,0x366d4b0,
  29073. 0x176439a,0x2a86b86,0x00f52ab },
  29074. { 0x0ac32ad,0x226250b,0x0f91d0e,0x1098aa6,0x3dfb79e,0x1dbd572,
  29075. 0x052ecf2,0x0f84995,0x0d27ad2,0x036c6b0,0x1e4986f,0x2317dab,
  29076. 0x2327df6,0x0dee0b3,0x00389ac } },
  29077. /* 82 */
  29078. { { 0x0e60f5b,0x0622d3e,0x2ada511,0x05522a8,0x27fe670,0x206af28,
  29079. 0x333cb83,0x3f25f6c,0x19ddaf3,0x0ec579b,0x36aabc0,0x093dbac,
  29080. 0x348b44b,0x277dca9,0x00c5978 },
  29081. { 0x1cf5279,0x32e294a,0x1a6c26f,0x3f006b6,0x37a3c6b,0x2e2eb26,
  29082. 0x2cf88d4,0x3410619,0x1899c80,0x23d3226,0x30add14,0x2810905,
  29083. 0x01a41f0,0x11e5176,0x005a02f } },
  29084. /* 83 */
  29085. { { 0x1c90202,0x321df30,0x3570fa5,0x103e2b1,0x3d099d4,0x05e207d,
  29086. 0x0a5b1bd,0x0075d0a,0x3db5b25,0x2d87899,0x32e4465,0x226fc13,
  29087. 0x24cb8f8,0x3821daa,0x004da3a },
  29088. { 0x3e66861,0x03f89b8,0x386d3ef,0x14ccc62,0x35e7729,0x11ce5b7,
  29089. 0x035fbc7,0x3f4df0f,0x29c439f,0x1144568,0x32d7037,0x312f65e,
  29090. 0x06b9dbf,0x03a9589,0x0008863 } },
  29091. /* 84 */
  29092. { { 0x0a9e8c9,0x1a19b6e,0x091ecd9,0x2e16ee0,0x2a11963,0x116cf34,
  29093. 0x390d530,0x194131f,0x2b580f3,0x31d569c,0x21d3751,0x3e2ce64,
  29094. 0x193de46,0x32454f0,0x004bffd },
  29095. { 0x09554e7,0x170126e,0x2be6cd1,0x153de89,0x0353c67,0x350765c,
  29096. 0x202370b,0x1db01e5,0x30b12b1,0x3778591,0x00c8809,0x2e845d5,
  29097. 0x1fb1e56,0x170f90d,0x00e2db3 } },
  29098. /* 85 */
  29099. { { 0x328e33f,0x392aad8,0x36d1d71,0x0aebe04,0x1548678,0x1b55c8c,
  29100. 0x24995f8,0x2a5a01e,0x1bd1651,0x37c7c29,0x36803b6,0x3716c91,
  29101. 0x1a935a5,0x32f10b7,0x005c587 },
  29102. { 0x2e8b4c0,0x336ccae,0x11382b6,0x22ec4cc,0x066d159,0x35fa585,
  29103. 0x23b2d25,0x3017528,0x2a674a8,0x3a4f900,0x1a7ce82,0x2b2539b,
  29104. 0x3d46545,0x0a07918,0x00eb9f8 } },
  29105. /* 86 */
  29106. { { 0x2cf5b9b,0x03e747f,0x166a34e,0x0afc81a,0x0a115b1,0x3aa814d,
  29107. 0x11cf3b1,0x163e556,0x3cbfb15,0x157c0a4,0x1bc703a,0x2141e90,
  29108. 0x01f811c,0x207218b,0x0092e6b },
  29109. { 0x1af24e3,0x3af19b3,0x3c70cc9,0x335cbf3,0x068917e,0x055ee92,
  29110. 0x09a9308,0x2cac9b7,0x008b06a,0x1175097,0x36e929c,0x0be339c,
  29111. 0x0932436,0x15f18ba,0x0009f6f } },
  29112. /* 87 */
  29113. { { 0x29375fb,0x35ade34,0x11571c7,0x07b8d74,0x3fabd85,0x090fa91,
  29114. 0x362dcd4,0x02c3fdb,0x0608fe3,0x2477649,0x3fc6e70,0x059b7eb,
  29115. 0x1e6a708,0x1a4c220,0x00c6c4c },
  29116. { 0x2a53fb0,0x1a3e1f5,0x11f9203,0x27e7ad3,0x038718e,0x3f5f9e4,
  29117. 0x308acda,0x0a8700f,0x34472fe,0x3420d7a,0x08076e5,0x014240e,
  29118. 0x0e7317e,0x197a98e,0x00538f7 } },
  29119. /* 88 */
  29120. { { 0x2663b4b,0x0927670,0x38dd0e0,0x16d1f34,0x3e700ab,0x3119567,
  29121. 0x12559d2,0x399b6c6,0x0a84bcd,0x163e7dd,0x3e2aced,0x058548c,
  29122. 0x03a5bad,0x011cf74,0x00c155c },
  29123. { 0x3e454eb,0x2a1e64e,0x1ccd346,0x36e0edf,0x266ee94,0x2e74aaf,
  29124. 0x2d8378a,0x3cd547d,0x1d27733,0x0928e5b,0x353553c,0x26f502b,
  29125. 0x1d94341,0x2635cc7,0x00d0ead } },
  29126. /* 89 */
  29127. { { 0x0142408,0x382c3bb,0x3310908,0x2e50452,0x398943c,0x1d0ac75,
  29128. 0x1bf7d81,0x04bd00f,0x36b6934,0x3349c37,0x0f69e20,0x0195252,
  29129. 0x243a1c5,0x030da5f,0x00a76a9 },
  29130. { 0x224825a,0x28ce111,0x34c2e0f,0x02e2b30,0x382e48c,0x26853ca,
  29131. 0x24bd14e,0x0200dec,0x1e24db3,0x0d3d775,0x132da0a,0x1dea79e,
  29132. 0x253dc0c,0x03c9d31,0x0020db9 } },
  29133. /* 90 */
  29134. { { 0x26c5fd9,0x05e6dc3,0x2eea261,0x08db260,0x2f8bec1,0x1255edf,
  29135. 0x283338d,0x3d9a91d,0x2640a72,0x03311f9,0x1bad935,0x152fda8,
  29136. 0x0e95abd,0x31abd15,0x00dfbf4 },
  29137. { 0x107f4fa,0x29ebe9a,0x27353f7,0x3821972,0x27311fa,0x2925ab6,
  29138. 0x337ab82,0x2de6c91,0x1f115fe,0x044f909,0x21b93c2,0x3a5f142,
  29139. 0x13eb5e9,0x3ab1377,0x00b26b6 } },
  29140. /* 91 */
  29141. { { 0x22e5f2b,0x2ae7d4a,0x1ac481c,0x0a6fce1,0x2f93caf,0x242658e,
  29142. 0x3f35c3c,0x050f3d2,0x30074c9,0x142079c,0x0281b4c,0x295fea3,
  29143. 0x007413e,0x01726cd,0x00e4979 },
  29144. { 0x1ab3cfb,0x1b76295,0x36adf55,0x1ad4636,0x1d444b9,0x3bd2e55,
  29145. 0x35425a5,0x1aa8cd3,0x3acecd2,0x1f769e8,0x1a655e9,0x1f6846f,
  29146. 0x24c70b5,0x3bff080,0x0002da3 } },
  29147. /* 92 */
  29148. { { 0x081d0d9,0x2c00d99,0x1fe2e24,0x396063f,0x03740db,0x243f680,
  29149. 0x3c1f451,0x1ff7b07,0x2803cf2,0x38ca724,0x2934f43,0x0d72d4d,
  29150. 0x0e8fe74,0x2975e21,0x002b505 },
  29151. { 0x11adcc9,0x331a99c,0x21e16cf,0x1714c78,0x1f03432,0x2caa2a6,
  29152. 0x34a9679,0x2f7fe8b,0x0423c21,0x1a757ce,0x31b57d6,0x171e044,
  29153. 0x093b9b2,0x13602e0,0x00db534 } },
  29154. /* 93 */
  29155. { { 0x250a2f5,0x0b999eb,0x21d10d7,0x22b92a1,0x39b7f8d,0x0c37c72,
  29156. 0x29f70f3,0x3bf0e84,0x1d7e04f,0x07a42a9,0x272c3ae,0x1587b2f,
  29157. 0x155faff,0x10a336e,0x000d8fb },
  29158. { 0x3663784,0x0d7dcf5,0x056ad22,0x319f8b1,0x0c05bae,0x2b6ff33,
  29159. 0x0292e42,0x0435797,0x188efb1,0x0d3f45e,0x119d49f,0x395dcd3,
  29160. 0x279fe27,0x133a13d,0x00188ac } },
  29161. /* 94 */
  29162. { { 0x396c53e,0x0d133e9,0x009b7ee,0x13421a0,0x1bbf607,0x1d284a5,
  29163. 0x1594f74,0x18cb47c,0x2dcac11,0x2999ddb,0x04e2fa5,0x1889e2c,
  29164. 0x0a89a18,0x33cb215,0x0052665 },
  29165. { 0x104ab58,0x1d91920,0x3d6d7e3,0x04dc813,0x1167759,0x13a8466,
  29166. 0x0a06a54,0x103761b,0x25b1c92,0x26a8fdd,0x2474614,0x21406a4,
  29167. 0x251d75f,0x38c3734,0x007b982 } },
  29168. /* 95 */
  29169. { { 0x15f3060,0x3a7bf30,0x3be6e44,0x0baa1fa,0x05ad62f,0x1e54035,
  29170. 0x099d41c,0x2a744d9,0x1c0336f,0x3e99b5b,0x1afd3b1,0x2bf1255,
  29171. 0x1822bf8,0x2c93972,0x001d8cc },
  29172. { 0x1d7584b,0x0508ade,0x20dd403,0x203a8fc,0x1c54a05,0x1611a31,
  29173. 0x037c8f9,0x1dcd4fe,0x110fbea,0x30f60bc,0x3dffe2f,0x26a1de1,
  29174. 0x0480367,0x18ec81c,0x0048eba } },
  29175. /* 96 */
  29176. { { 0x346e2f6,0x0435077,0x036789b,0x3e06545,0x313ab57,0x351a721,
  29177. 0x3372b91,0x15e6019,0x2fa4f6c,0x3c30656,0x272c9ac,0x10e84a8,
  29178. 0x2bdacea,0x232d9e2,0x009dadd },
  29179. { 0x182579a,0x15b1af8,0x02d8cce,0x36cb49b,0x086feba,0x2911d17,
  29180. 0x268ee12,0x011e871,0x18698dc,0x35602b3,0x11b9ec2,0x0ade731,
  29181. 0x0f6a05a,0x1821015,0x00007da } },
  29182. /* 97 */
  29183. { { 0x3b00dd0,0x328d485,0x27a69e3,0x32c3a06,0x1046779,0x120b61c,
  29184. 0x19fef3d,0x0fef2e6,0x134d923,0x039bce0,0x348cd0e,0x0b0c007,
  29185. 0x066ae11,0x15d8f1b,0x00934e7 },
  29186. { 0x33234dc,0x353f0f5,0x2fc1b44,0x18a193a,0x2fcae20,0x1afbc86,
  29187. 0x3afe252,0x17f7e10,0x107f3b7,0x2d84d54,0x394c2e6,0x19e96a9,
  29188. 0x0a37283,0x26c6152,0x003d262 } },
  29189. /* 98 */
  29190. { { 0x37cfaf8,0x01863d0,0x0299623,0x32c80cb,0x25b8742,0x0a4d90e,
  29191. 0x1f72472,0x13de652,0x31a0946,0x0ee0103,0x0f25414,0x2518b49,
  29192. 0x07e7604,0x1488d9b,0x00abd6b },
  29193. { 0x1338f55,0x2ce4af5,0x1a0c119,0x3380525,0x21a80a9,0x235d4df,
  29194. 0x118ca7f,0x2dd8bcc,0x1c26bf4,0x32dc56b,0x28482b6,0x1418596,
  29195. 0x3c84d24,0x1f1a5a9,0x00d958d } },
  29196. /* 99 */
  29197. { { 0x1c21f31,0x22aa1ef,0x258c9ad,0x2d2018f,0x0adb3ca,0x01f75ee,
  29198. 0x186283b,0x31ad3bf,0x3621be7,0x3b1ee6d,0x015582d,0x3d61d04,
  29199. 0x2ddf32e,0x14b8a66,0x00c970c },
  29200. { 0x2f24d66,0x00b8a88,0x100a78f,0x041d330,0x2efec1d,0x24c5b86,
  29201. 0x2a6a390,0x37526bc,0x2055849,0x3339f08,0x16bffc4,0x07f9d72,
  29202. 0x06ec09c,0x3f49ee8,0x00cad98 } },
  29203. /* 100 */
  29204. { { 0x248b73e,0x1b8b42d,0x285eed7,0x39473f4,0x1a9f92c,0x3b44f78,
  29205. 0x086c062,0x06a4ea3,0x34ea519,0x3c74e95,0x1ad1b8b,0x1737e2c,
  29206. 0x2cfe338,0x0a291f4,0x00bbecc },
  29207. { 0x1cec548,0x0c9b01a,0x20b298d,0x377c902,0x24f5bc1,0x2415c8d,
  29208. 0x1a70622,0x2529090,0x1c5c682,0x283f1ba,0x2319f17,0x0120e2e,
  29209. 0x01c6f4d,0x33c67ff,0x008b612 } },
  29210. /* 101 */
  29211. { { 0x03830eb,0x02d4053,0x10c59bb,0x0f23b83,0x13d08f8,0x26ea4e2,
  29212. 0x2626427,0x0a45292,0x0449cbc,0x0175750,0x074c46f,0x27ae0f8,
  29213. 0x2d7d6ae,0x163dd3a,0x0063bb7 },
  29214. { 0x2bb29e0,0x034bab1,0x341e1c4,0x21d2c0b,0x295aa2d,0x0f2c666,
  29215. 0x1891755,0x13db64a,0x2fe5158,0x337646e,0x31a1aae,0x057bee4,
  29216. 0x00f9e37,0x396d19e,0x00c1b6a } },
  29217. /* 102 */
  29218. { { 0x2772f41,0x34f92d0,0x39d1cde,0x174ef2d,0x03a700d,0x03fbb98,
  29219. 0x30d50e8,0x352ed10,0x1fcf5e5,0x3d113bc,0x26e358f,0x180653f,
  29220. 0x1b43cc6,0x3cc9aa4,0x00e68a2 },
  29221. { 0x37fe4d2,0x09dd725,0x01eb584,0x171f8a9,0x278fdef,0x3e37c03,
  29222. 0x3bec02f,0x149757c,0x0cd5852,0x37d2e10,0x0e6988b,0x1c120e9,
  29223. 0x0b83708,0x38e7319,0x0039499 } },
  29224. /* 103 */
  29225. { { 0x08df5fe,0x177a02c,0x0362fc0,0x1f18ee8,0x00c1295,0x173c50a,
  29226. 0x379414d,0x1885ba8,0x32a54ef,0x2315644,0x39e65cf,0x357c4be,
  29227. 0x1d66333,0x09e05a5,0x0009c60 },
  29228. { 0x1f7a2fb,0x073b518,0x2eb83ac,0x11353d7,0x1dd8384,0x0c63f2b,
  29229. 0x238c6c8,0x2a1920a,0x2e5e9f1,0x1cc56f8,0x042daf4,0x1ed5dc5,
  29230. 0x25f9e31,0x012a56a,0x0081b59 } },
  29231. /* 104 */
  29232. { { 0x321d232,0x2c71422,0x3a756b6,0x30230b2,0x387f3db,0x3a7c3eb,
  29233. 0x274b46a,0x201e69f,0x185bb7b,0x140da82,0x0d974a2,0x0616e42,
  29234. 0x35ec94f,0x3bc366b,0x005aa7c },
  29235. { 0x3dcfffc,0x19a9c15,0x3225e05,0x36ae114,0x16ea311,0x0cda2aa,
  29236. 0x2a1a8d2,0x154b5cb,0x08348cd,0x17b66c8,0x080ea43,0x21e59f3,
  29237. 0x04173b9,0x31d5b04,0x00ad735 } },
  29238. /* 105 */
  29239. { { 0x2e76ef4,0x216acf3,0x2b93aea,0x112bc74,0x3449974,0x2b2e48f,
  29240. 0x11929be,0x2f03021,0x19051e3,0x0ac202d,0x19be68a,0x3b87619,
  29241. 0x26cdac4,0x086592c,0x00f00de },
  29242. { 0x2e90d4d,0x3ed703c,0x2c648d7,0x29ddf67,0x000e219,0x3471247,
  29243. 0x26febd5,0x1161713,0x3541a8f,0x302038d,0x08d2af9,0x26e1b21,
  29244. 0x398514a,0x36dad99,0x002ed70 } },
  29245. /* 106 */
  29246. { { 0x06f25cb,0x1104596,0x370faee,0x07e83f3,0x0f7b686,0x228d43a,
  29247. 0x12cd201,0x0a1bd57,0x3e592dc,0x1e186fc,0x2226aba,0x2c63fe9,
  29248. 0x17b039a,0x1efaa61,0x00d1582 },
  29249. { 0x2e6acef,0x07d51e4,0x3ac326c,0x322b07e,0x1422c63,0x32ff5c7,
  29250. 0x18760df,0x048928b,0x139b251,0x04d7da9,0x048d1a2,0x2a23e84,
  29251. 0x199dbba,0x2fa7afe,0x0049f1a } },
  29252. /* 107 */
  29253. { { 0x3492b73,0x27d3d3d,0x2b1a16f,0x07b2ce4,0x0cf28ec,0x2729bff,
  29254. 0x3130d46,0x3e96116,0x140b72e,0x14a2ea3,0x1ca066f,0x3a61f1d,
  29255. 0x022ebac,0x09192b4,0x003e399 },
  29256. { 0x12555bb,0x0b6139d,0x239463a,0x12a70ab,0x2aaa93b,0x2254e72,
  29257. 0x00424ec,0x26a6736,0x26daa11,0x25b5ad6,0x379f262,0x140cd30,
  29258. 0x0c7d3bd,0x097bbcf,0x00899e9 } },
  29259. /* 108 */
  29260. { { 0x3825dc4,0x3cd946f,0x0462b7f,0x31102e7,0x30f741c,0x3313ed6,
  29261. 0x1ff5a95,0x15bf9dc,0x09b47fd,0x0f2e7a7,0x1626c0d,0x3c14f6d,
  29262. 0x14098bd,0x19d7df8,0x00a97ce },
  29263. { 0x0934f5e,0x3f968db,0x046f68a,0x12333bf,0x26cd5e1,0x1ea2161,
  29264. 0x358570d,0x235031d,0x35edd55,0x05265e3,0x24ae00c,0x3542229,
  29265. 0x25bb2a1,0x1c83c75,0x0058f2a } },
  29266. /* 109 */
  29267. { { 0x24daedb,0x376928f,0x305266f,0x0499746,0x038318c,0x312efd7,
  29268. 0x1910a24,0x33450a3,0x1c478a9,0x39d8bf9,0x12cc0ae,0x397aeab,
  29269. 0x0654c08,0x095f283,0x00d2cdf },
  29270. { 0x0b717d2,0x1f162c2,0x107a48f,0x128e1b3,0x2380718,0x39f4044,
  29271. 0x00f626a,0x05ec0c9,0x21bc439,0x200fa4d,0x20aea01,0x186a1d8,
  29272. 0x26372f2,0x1a91f87,0x0053f55 } },
  29273. /* 110 */
  29274. { { 0x3512a90,0x33b958b,0x29f1c84,0x0106c3a,0x224b3c0,0x09b307a,
  29275. 0x215d2de,0x3bdf43b,0x22cf0c9,0x176121d,0x1534143,0x09ba717,
  29276. 0x16b3110,0x0f73f6c,0x008f5b7 },
  29277. { 0x2c75d95,0x26fbcb4,0x0dda1f6,0x206f819,0x28d33d5,0x1fb4d79,
  29278. 0x024c125,0x30a0630,0x1f9c309,0x0fe350d,0x1696019,0x0a54187,
  29279. 0x09541fd,0x35e3a79,0x0066618 } },
  29280. /* 111 */
  29281. { { 0x0e382de,0x33f5163,0x0dde571,0x3bb7a40,0x1175806,0x12ae8ed,
  29282. 0x0499653,0x3b25586,0x38ade7a,0x3fa265d,0x3f4aa97,0x3c03dbb,
  29283. 0x30c6de8,0x32d4042,0x00ae971 },
  29284. { 0x2f788f1,0x1fbaf0e,0x3e2d182,0x3ff904f,0x0d46229,0x1d0726d,
  29285. 0x15455b4,0x093ae28,0x290f8e4,0x097c0b9,0x1ae8771,0x28480bb,
  29286. 0x04f6d40,0x3689925,0x0049b3b } },
  29287. /* 112 */
  29288. { { 0x35b2d69,0x31819c0,0x11b0d63,0x035afb6,0x2b50715,0x2bece6c,
  29289. 0x35f82f7,0x0ad987c,0x0011601,0x02e6f67,0x2d0a5f5,0x365e583,
  29290. 0x2f7c900,0x11449c5,0x00ed705 },
  29291. { 0x27abdb4,0x1bbfd04,0x301c157,0x263c079,0x36850d6,0x3f21f8b,
  29292. 0x27d7493,0x0f9227e,0x06fb0ce,0x002daf3,0x37d8c1c,0x3ef87d7,
  29293. 0x19cc6f4,0x0c3809c,0x00cf752 } },
  29294. /* 113 */
  29295. { { 0x22d94ed,0x075b09c,0x020e676,0x084dc62,0x2d1ec3f,0x17439f1,
  29296. 0x240b702,0x33cc596,0x30ebaf3,0x0359fe0,0x393ea43,0x0ece01e,
  29297. 0x16c6963,0x03a82f2,0x0017faa },
  29298. { 0x3866b98,0x3cd20b7,0x12d4e6b,0x3a6a76d,0x1205c1e,0x3e6ae1a,
  29299. 0x2f9bbdf,0x2e61547,0x2d175ee,0x28e18f6,0x13cf442,0x085b0ef,
  29300. 0x0e321ef,0x238fe72,0x003fb22 } },
  29301. /* 114 */
  29302. { { 0x360ac07,0x26dc301,0x3f4d94f,0x2ba75e6,0x1f3c9cc,0x17ff20f,
  29303. 0x0ea084c,0x30e39cf,0x143dc49,0x03bd43e,0x3c9e733,0x19e8aba,
  29304. 0x27fbaf4,0x12d913a,0x005ee53 },
  29305. { 0x3609e7f,0x2d89c80,0x09f020c,0x1558bf7,0x3098443,0x3c515fd,
  29306. 0x1c8e580,0x16506bd,0x26cb4b2,0x1747d42,0x2ec8239,0x32c91f0,
  29307. 0x1ca3377,0x079768f,0x00a5f3e } },
  29308. /* 115 */
  29309. { { 0x185fa94,0x122759f,0x0e47023,0x0dcb6e7,0x10ba405,0x3b5eab4,
  29310. 0x1f7a1fa,0x32d003f,0x1739a4c,0x3295ec3,0x1b18967,0x3f3b265,
  29311. 0x34d2448,0x2dbadc9,0x00f30b5 },
  29312. { 0x01c5338,0x2d1dcf2,0x2bd07cc,0x39a8fb5,0x2b85639,0x355bab6,
  29313. 0x1df95f1,0x01eb5f6,0x17f0a16,0x1b895b5,0x157574d,0x29fff72,
  29314. 0x3a8c46d,0x0118071,0x0065f84 } },
  29315. /* 116 */
  29316. { { 0x3a1e7f1,0x17432f2,0x1f648d4,0x3000ad5,0x2ef0a08,0x1f86624,
  29317. 0x1ca31b1,0x241f9dc,0x2cb4885,0x2b8610f,0x364ce16,0x1e5faf0,
  29318. 0x0b33867,0x2cb637d,0x00816d2 },
  29319. { 0x1aa8671,0x02c394e,0x35f5e87,0x393040a,0x39f0db3,0x1c831a5,
  29320. 0x2966591,0x034a8d0,0x09e613c,0x042b532,0x018ddd6,0x3e402c9,
  29321. 0x2e20e1a,0x29cb4cd,0x00e087c } },
  29322. /* 117 */
  29323. { { 0x3a10079,0x20c7fea,0x3ff2222,0x1edb593,0x00dc5f8,0x3a32ccc,
  29324. 0x1479073,0x0cfed11,0x2a2702a,0x17a056a,0x1fba321,0x235acb9,
  29325. 0x149c833,0x172de7d,0x000f753 },
  29326. { 0x2e95923,0x3b365cb,0x009f471,0x0df1b47,0x21e868b,0x199bbd3,
  29327. 0x07b8ecc,0x12ff0af,0x189808a,0x3bd5059,0x3fbc4d2,0x0fa7b88,
  29328. 0x1125bf2,0x0db0b5d,0x0043572 } },
  29329. /* 118 */
  29330. { { 0x29cdb1b,0x1db656e,0x391efe1,0x004be09,0x245a1ca,0x3793328,
  29331. 0x254af24,0x2f2e65d,0x10e5cc4,0x2af6fe7,0x2d97ac0,0x29f7d42,
  29332. 0x19fd6f6,0x0ac184d,0x00c5211 },
  29333. { 0x305eae3,0x36738d3,0x2c2b696,0x00ba50e,0x3903adc,0x2122f85,
  29334. 0x0753470,0x1cf96a4,0x1702a39,0x247883c,0x2feb67e,0x2ab3071,
  29335. 0x3c6b9e1,0x30cb85a,0x002ca0a } },
  29336. /* 119 */
  29337. { { 0x3871eb5,0x284b93b,0x0a7affe,0x176a2fc,0x294c2f2,0x204d3aa,
  29338. 0x1e4c2a7,0x3ec4134,0x2fb0360,0x3847b45,0x05fc11b,0x0a6db6e,
  29339. 0x390fa40,0x2adfd34,0x005e9f7 },
  29340. { 0x0646612,0x1b5cbcc,0x10d8507,0x0777687,0x3a0afed,0x1687440,
  29341. 0x0222578,0x1af34a4,0x2174e27,0x372d267,0x11246c3,0x34769c5,
  29342. 0x2044316,0x1b4d626,0x00c72d5 } },
  29343. /* 120 */
  29344. { { 0x2e5bb45,0x3ff1d36,0x16dcdf5,0x128986f,0x399068c,0x2a63b1e,
  29345. 0x0afa7aa,0x3a5b770,0x200f121,0x33b74bb,0x1414045,0x0f31ef8,
  29346. 0x2f50e16,0x2f38cd6,0x00b0b1b },
  29347. { 0x1a06293,0x035e140,0x2644d44,0x1f1954b,0x2cdebab,0x31d5f91,
  29348. 0x0b8dbc8,0x38f2d23,0x3783cab,0x2a07e73,0x3123f59,0x3409846,
  29349. 0x3784ddd,0x223bbac,0x003dc7b } },
  29350. /* 121 */
  29351. { { 0x0741456,0x234e631,0x2121e1b,0x00980ca,0x3a9dfa9,0x098c916,
  29352. 0x3fc86d1,0x1c63072,0x3625244,0x13d0471,0x05b0fc5,0x1487550,
  29353. 0x2498596,0x11bb6ea,0x001afab },
  29354. { 0x274b4ad,0x240aea1,0x3d12a75,0x2b56b61,0x1486b43,0x1b83426,
  29355. 0x31c7363,0x35b59ca,0x207bb6c,0x38e6243,0x19bace4,0x0a26671,
  29356. 0x35e3381,0x0c2ded4,0x00d8da4 } },
  29357. /* 122 */
  29358. { { 0x2b75791,0x19590b1,0x2bfb39f,0x2988601,0x0050947,0x0d8bbe1,
  29359. 0x23e3701,0x08e4432,0x2ed8c3d,0x326f182,0x332e1dd,0x12219c5,
  29360. 0x2e0779b,0x367aa63,0x0012d10 },
  29361. { 0x251b7dc,0x0a08b4d,0x1138b6f,0x2ea02af,0x06345a5,0x1cb4f21,
  29362. 0x0332624,0x1d49d88,0x140acc5,0x2f55287,0x024447c,0x291ace9,
  29363. 0x1a4966e,0x015cbec,0x005bc41 } },
  29364. /* 123 */
  29365. { { 0x351cd0e,0x315e8e9,0x07d6e70,0x067ae8f,0x2190d84,0x351f556,
  29366. 0x03bee79,0x31b62c7,0x266f912,0x1b6a504,0x007a6ad,0x3a6ab31,
  29367. 0x3891112,0x3c45ba0,0x00d6ce5 },
  29368. { 0x0e1f2ce,0x32a5edc,0x1434063,0x1ca084f,0x2a3e47c,0x137e042,
  29369. 0x16e2418,0x2069280,0x3b0dfd8,0x35a22b5,0x289bf0a,0x1f667f2,
  29370. 0x02d23a3,0x0ce688f,0x00d8e3f } },
  29371. /* 124 */
  29372. { { 0x10bed6f,0x14c58dd,0x0b0abdf,0x0ca0f9a,0x3808abc,0x2ec228c,
  29373. 0x2366275,0x12afa16,0x20f6b0e,0x37dca8e,0x3af0c6a,0x1c5b467,
  29374. 0x1b25ff7,0x00814de,0x0022dcc },
  29375. { 0x1a56e11,0x02fe37e,0x3f21740,0x35d5a91,0x06cb8ba,0x29bad91,
  29376. 0x17176f7,0x2d919f2,0x0f7d1f5,0x13a3f61,0x04ddb05,0x0c82a51,
  29377. 0x286f598,0x2e8c777,0x0007071 } },
  29378. /* 125 */
  29379. { { 0x0f8fcb9,0x3e83966,0x170c6fd,0x3825343,0x089cec8,0x01b482a,
  29380. 0x0993971,0x3327282,0x39aba8a,0x32456fe,0x1507e01,0x1c3252d,
  29381. 0x21ffb13,0x29822a0,0x0083246 },
  29382. { 0x23c378f,0x1cea7ef,0x1be9a82,0x224d689,0x37e5447,0x3764a75,
  29383. 0x3a49724,0x361e1b3,0x19d365b,0x3a61ffb,0x1c29a7a,0x20ab251,
  29384. 0x17ec549,0x175d777,0x004589a } },
  29385. /* 126 */
  29386. { { 0x15540a9,0x2ec5d2a,0x05b09fa,0x1bc058b,0x07cfb88,0x28f7b86,
  29387. 0x3e766be,0x189305e,0x01fe88e,0x23fdf69,0x0b919c3,0x02dc7ae,
  29388. 0x3f9a9ad,0x0b83cc7,0x0086a52 },
  29389. { 0x28bc259,0x39bdca1,0x39e4bc8,0x0e0f33b,0x16130c6,0x2919955,
  29390. 0x31f4549,0x2fed027,0x30919b2,0x0a39b03,0x0ca7bb2,0x1711b24,
  29391. 0x3b67b94,0x05a136b,0x00acd87 } },
  29392. /* 127 */
  29393. { { 0x0c53841,0x31cb284,0x3ced090,0x06d5693,0x1c20ae0,0x0408d2b,
  29394. 0x37ebd5e,0x081900f,0x26a8589,0x0acfd0a,0x34a1472,0x2f0c302,
  29395. 0x124ccbd,0x10de328,0x00971bc },
  29396. { 0x17ff2ff,0x27d1b54,0x147b6f7,0x38bb2ea,0x26a9c96,0x0a49448,
  29397. 0x39f2f46,0x247c579,0x3b16a4e,0x28c2a5a,0x2d4c72d,0x11f248c,
  29398. 0x1e4df11,0x047d604,0x0065bc3 } },
  29399. /* 128 */
  29400. { { 0x39b3239,0x1f75f44,0x3bae87c,0x139360c,0x18b5782,0x3ffc005,
  29401. 0x3c48789,0x2bc6af2,0x38b909e,0x223ff3b,0x31443a7,0x017d3bb,
  29402. 0x0bfed99,0x128b857,0x00020dd },
  29403. { 0x306d695,0x25a7b28,0x2f60ca2,0x2b6e4f2,0x1df940c,0x1fa9b8e,
  29404. 0x37fab78,0x13f959f,0x10ff98c,0x38343b8,0x019cb91,0x11a1e6b,
  29405. 0x17ab4c6,0x1431f47,0x004b4ea } },
  29406. /* 129 */
  29407. { { 0x20db57e,0x102515e,0x170219e,0x2b66a32,0x1e6017c,0x2f973fe,
  29408. 0x3739e51,0x0e28b6f,0x3cda7a9,0x30d91ac,0x28350df,0x1444215,
  29409. 0x098b504,0x1bcd5b8,0x00ad3bd },
  29410. { 0x22e3e3e,0x3aeaffb,0x26cb935,0x0091ce4,0x2fbd017,0x3a7ed6a,
  29411. 0x335b029,0x3bfc1f1,0x3852e3f,0x2b14a86,0x046b405,0x266af4c,
  29412. 0x3997191,0x33b0e40,0x00e306f } },
  29413. /* 130 */
  29414. { { 0x3e4712c,0x26bb208,0x18eed6d,0x1b30f06,0x27ca837,0x06faf62,
  29415. 0x1831873,0x3fbcf9b,0x3f3d88b,0x1fb55eb,0x0f44edc,0x29917bb,
  29416. 0x3151772,0x342d72e,0x00d4e63 },
  29417. { 0x2ee0ecf,0x39e8733,0x2e8e98c,0x0cd4e0f,0x08f0126,0x1ad157a,
  29418. 0x079078a,0x23018ee,0x196c765,0x2b2f34f,0x0783336,0x075bf9c,
  29419. 0x3713672,0x098d699,0x00f21a7 } },
  29420. /* 131 */
  29421. { { 0x186ba11,0x22cf365,0x048019d,0x2ca2970,0x0d9e0ae,0x08c3bd7,
  29422. 0x261dbf2,0x2fc2790,0x1ee02e6,0x10256a7,0x00dc778,0x18dc8f2,
  29423. 0x157b189,0x2ebc514,0x005c97d },
  29424. { 0x3c4503e,0x1d10d12,0x337097e,0x0c6169a,0x30fb1cb,0x3481752,
  29425. 0x0df2bec,0x19768fa,0x1bcf8f7,0x2925f74,0x2c988a1,0x3be571d,
  29426. 0x04cfa92,0x2ea9937,0x003f924 } },
  29427. /* 132 */
  29428. { { 0x268b448,0x06e375c,0x1b946bf,0x287bf5e,0x3d4c28b,0x138d547,
  29429. 0x21f8c8e,0x21ea4be,0x2d45c91,0x35da78e,0x00326c0,0x210ed35,
  29430. 0x1d66928,0x0251435,0x00fefc8 },
  29431. { 0x0339366,0x216ff64,0x2c3a30c,0x3c5733d,0x04eeb56,0x2333477,
  29432. 0x32b1492,0x25e3839,0x1b5f2ce,0x0dcfba1,0x3165bb2,0x3acafcc,
  29433. 0x10abfcd,0x248d390,0x008106c } },
  29434. /* 133 */
  29435. { { 0x102f4ee,0x3c0585f,0x1225c8d,0x11c6388,0x08a7815,0x2b3e790,
  29436. 0x2895eb6,0x18cf53a,0x0b56e5a,0x2e2c003,0x3e981ff,0x0761b55,
  29437. 0x1bc32f3,0x0a7111d,0x00f5c80 },
  29438. { 0x3568973,0x1587386,0x16ec764,0x20698a6,0x02f809b,0x2821502,
  29439. 0x113d64d,0x38c2679,0x15de61c,0x0309f60,0x272999e,0x29bfe64,
  29440. 0x173f70d,0x1de7fab,0x00bd284 } },
  29441. /* 134 */
  29442. { { 0x31cdf2b,0x0f0be66,0x2151603,0x01af17e,0x32a99cf,0x085dece,
  29443. 0x27d2591,0x1520df4,0x273c448,0x1ec7c54,0x102e229,0x355f604,
  29444. 0x2acb75f,0x005f1fd,0x003d43e },
  29445. { 0x270eb28,0x22ec2ce,0x306b41a,0x238fa02,0x167de2d,0x030a379,
  29446. 0x245a417,0x1808c24,0x0b1a7b2,0x3ab5f6f,0x2cbc6c1,0x2c228d4,
  29447. 0x3041f70,0x2d9a6cc,0x00b504f } },
  29448. /* 135 */
  29449. { { 0x17a27c2,0x216ad7e,0x011ba8e,0x22f0428,0x16ac5ec,0x3ef3c58,
  29450. 0x345533f,0x0298155,0x2856579,0x0005e03,0x19ee75b,0x146fe16,
  29451. 0x29881e4,0x18ece70,0x008907a },
  29452. { 0x20189ed,0x119ce09,0x35cb76d,0x0d91ef4,0x2284a44,0x032ad87,
  29453. 0x0e8c402,0x3c82b5d,0x38c416c,0x398992f,0x1fd820c,0x169b255,
  29454. 0x3b5fcfa,0x1343c92,0x00fa715 } },
  29455. /* 136 */
  29456. { { 0x33f5034,0x20b3b26,0x28fd184,0x16b3679,0x3962d44,0x15d1bc8,
  29457. 0x2fb1d69,0x1292c99,0x25a58c9,0x1b19ab7,0x2d68a5b,0x2f6a09b,
  29458. 0x0d6aedb,0x2935eac,0x0005664 },
  29459. { 0x25e32fc,0x13f9440,0x3252bcd,0x2fea5b7,0x161a5ae,0x0564a8c,
  29460. 0x0a07e23,0x1545f62,0x0de9890,0x1d76765,0x1fd440e,0x2ed0041,
  29461. 0x3db4c96,0x1e8ba01,0x001b0c4 } },
  29462. /* 137 */
  29463. { { 0x0223878,0x29ab202,0x15585c2,0x1a79969,0x1ba08c2,0x2ef09ff,
  29464. 0x2b1b9b9,0x181f748,0x1bf72b9,0x224645c,0x2588dc5,0x2d157e7,
  29465. 0x22d939a,0x05b88d9,0x006d549 },
  29466. { 0x31de0c1,0x23a4e0e,0x278f8da,0x1aa013c,0x1a84d18,0x0d185a5,
  29467. 0x0988ccd,0x2c32efd,0x3bee10e,0x37d7ab8,0x3f2a66e,0x3e2da3e,
  29468. 0x1b5701f,0x3d9f0c1,0x00a68da } },
  29469. /* 138 */
  29470. { { 0x0b2e045,0x0133fd1,0x05d4c10,0x0d92c70,0x391b5e1,0x2292281,
  29471. 0x2e40908,0x2ec694e,0x195ea11,0x29cfeca,0x3d93a4e,0x01215c0,
  29472. 0x08a5f32,0x37a0eff,0x00cce45 },
  29473. { 0x2b3106e,0x12a5fb0,0x0b4faff,0x0c2da12,0x09069c6,0x35d8907,
  29474. 0x2837a6e,0x3db3fb6,0x3136cc3,0x222836b,0x3da018a,0x2741274,
  29475. 0x13ba319,0x1ac7642,0x00f867c } },
  29476. /* 139 */
  29477. { { 0x2527296,0x10a9595,0x178de4d,0x0f739c4,0x0ae26c7,0x3094599,
  29478. 0x20adac6,0x2b875c2,0x3ae5dc0,0x3e04d20,0x1aab2da,0x1d3ab37,
  29479. 0x15f4f75,0x0b730b5,0x00c56b5 },
  29480. { 0x1f32923,0x2f059e5,0x2a89872,0x2056f74,0x04be175,0x1da67c0,
  29481. 0x17f1e7a,0x3780a6d,0x0723ac2,0x257f367,0x1237773,0x2bcee86,
  29482. 0x0b97f83,0x38aff14,0x00a64d4 } },
  29483. /* 140 */
  29484. { { 0x2552b40,0x0b6b883,0x12e8217,0x0974d35,0x062f497,0x1e563e6,
  29485. 0x30ee400,0x375d1e4,0x290751f,0x0d5b68a,0x353e48c,0x064a0d3,
  29486. 0x3c343f1,0x309a394,0x0034d2a },
  29487. { 0x3111286,0x0f08604,0x1827107,0x0536a76,0x0201dac,0x3a574de,
  29488. 0x2c29dbe,0x382c7b0,0x1191f3e,0x324c5bc,0x144ce71,0x24327c1,
  29489. 0x1212778,0x22bc9d8,0x00d7713 } },
  29490. /* 141 */
  29491. { { 0x34ad1cd,0x1179b4e,0x1bc1780,0x1392a92,0x2cd86b9,0x359de85,
  29492. 0x251f1df,0x0da5d5f,0x135fa61,0x0f64a42,0x34f4d89,0x0fe564c,
  29493. 0x3cf9b7a,0x122d757,0x008c9c2 },
  29494. { 0x370d4e9,0x0e9209b,0x0ae99f2,0x1518c64,0x0172734,0x2c20692,
  29495. 0x1d7c135,0x149c52f,0x38928d6,0x3c78b78,0x25841d1,0x2eaa897,
  29496. 0x372e50b,0x29e5d19,0x00c4c18 } },
  29497. /* 142 */
  29498. { { 0x13375ac,0x389a056,0x211310e,0x2f9f757,0x04f3288,0x103cd4e,
  29499. 0x17b2fb2,0x2c78a6a,0x09f1de6,0x23e8442,0x1351bc5,0x1b69588,
  29500. 0x285b551,0x0464b7e,0x00573b6 },
  29501. { 0x0ba7df5,0x259a0db,0x2b4089e,0x05630a2,0x3f299be,0x350ff2f,
  29502. 0x1c9348a,0x3becfa4,0x3cc9a1c,0x17a6ef1,0x338b277,0x2b761d9,
  29503. 0x2aa01c8,0x3cb9dd7,0x006e3b1 } },
  29504. /* 143 */
  29505. { { 0x277788b,0x16a222d,0x173c036,0x310ff58,0x2634ae8,0x392636f,
  29506. 0x0987619,0x1e6acc1,0x26dc8f7,0x242310f,0x0c09aca,0x22b8e11,
  29507. 0x0d17006,0x1c2c806,0x002380c },
  29508. { 0x297c5ec,0x1fef0e8,0x3948cf7,0x14f2915,0x2dacbc8,0x0dafb1f,
  29509. 0x10de043,0x31184da,0x06414ee,0x3c9aeeb,0x1f713ab,0x308f1f8,
  29510. 0x1569ed1,0x3f379bf,0x00f08bb } },
  29511. /* 144 */
  29512. { { 0x0770ee3,0x058fd21,0x17065f8,0x251d128,0x10e0c7f,0x06cb51b,
  29513. 0x0f05f7e,0x3666a72,0x3e7d01f,0x2d05fab,0x11440e5,0x28577d4,
  29514. 0x2fbcf2b,0x14aa469,0x00dc5c5 },
  29515. { 0x270f721,0x1c75d28,0x085b862,0x1d68011,0x132c0a0,0x37be81d,
  29516. 0x1a87e38,0x083fa74,0x3acbf0d,0x16d6429,0x0feda1f,0x031070a,
  29517. 0x2ec2443,0x21e563d,0x00454d2 } },
  29518. /* 145 */
  29519. { { 0x0525435,0x1e98d5f,0x3dbc52b,0x1fcdf12,0x13d9ef5,0x3ff311d,
  29520. 0x393e9ed,0x3cef8ae,0x2987710,0x3bdee2e,0x21b727d,0x3ba1b68,
  29521. 0x10d0142,0x3c64b92,0x0055ac3 },
  29522. { 0x0c1c390,0x38e9bb0,0x1e7b487,0x11511b3,0x1036fb3,0x25aba54,
  29523. 0x1eb2764,0x048d022,0x0d971ed,0x1bb7fb5,0x100f0b4,0x06c3756,
  29524. 0x2f0d366,0x3c6e160,0x0011bd6 } },
  29525. /* 146 */
  29526. { { 0x36bc9d1,0x24d43c1,0x12c35cf,0x2fb3cf3,0x015d903,0x16bc0c7,
  29527. 0x0fc8c22,0x3195c87,0x2488b1c,0x1f82b4c,0x30014e8,0x27ee58d,
  29528. 0x31658dd,0x1684a5f,0x00f0f3a },
  29529. { 0x1f703aa,0x023eebc,0x20babb9,0x080bd9d,0x12f9cc4,0x1a8e2d4,
  29530. 0x0eec666,0x1176803,0x33005d6,0x1137b68,0x37de339,0x33d71cb,
  29531. 0x0c906b9,0x14086b5,0x00aeef6 } },
  29532. /* 147 */
  29533. { { 0x219045d,0x0f22c5e,0x024c058,0x00b414a,0x0ae7c31,0x3db3e96,
  29534. 0x234979f,0x0cf00a8,0x3c962c7,0x27fa77f,0x1c0c4b0,0x1fe8942,
  29535. 0x218053a,0x1eed3f8,0x0051643 },
  29536. { 0x2a23ddb,0x138f570,0x104e945,0x21ca270,0x30726d8,0x3f45490,
  29537. 0x37d9184,0x242ea25,0x33f6d77,0x3f15679,0x065af85,0x34fa1f5,
  29538. 0x2e46b8f,0x31d17fb,0x00a2615 } },
  29539. /* 148 */
  29540. { { 0x335167d,0x181ea10,0x0887c8d,0x01383d7,0x18b42d8,0x263447e,
  29541. 0x1f13df3,0x0319d7e,0x0872074,0x2d6aa94,0x23d9234,0x36a69aa,
  29542. 0x0bad183,0x3138a95,0x00bd3a5 },
  29543. { 0x1b0f658,0x0e4530b,0x373add1,0x1b968fc,0x329dcb6,0x09169ca,
  29544. 0x162df55,0x0211eff,0x02391e4,0x3867460,0x3136b1a,0x37dd36e,
  29545. 0x3bc5bd9,0x2dacfe4,0x0072a06 } },
  29546. /* 149 */
  29547. { { 0x119d96f,0x067b0eb,0x00996da,0x293eca9,0x2b342da,0x1889c7a,
  29548. 0x21633a6,0x0152c39,0x281ce8c,0x18ef3b3,0x0bd62dc,0x3238186,
  29549. 0x38d8b7c,0x3867b95,0x00ae189 },
  29550. { 0x0ed1eed,0x1e89777,0x13ab73e,0x029e1d7,0x2c1257f,0x33fbc09,
  29551. 0x32d5a21,0x3d870b2,0x39bb1fd,0x33663bc,0x24e83e6,0x239bda4,
  29552. 0x3088bcd,0x01db1ed,0x00d71e7 } },
  29553. /* 150 */
  29554. { { 0x14245bf,0x0da0c27,0x153b339,0x05cab0a,0x122d962,0x1b0f0f3,
  29555. 0x3f5a825,0x267a2ce,0x2910d06,0x254326f,0x0f36645,0x025118e,
  29556. 0x37c35ec,0x36e944e,0x006c056 },
  29557. { 0x05ab0e3,0x29aa0c1,0x1295687,0x1fd1172,0x08d40b5,0x05bd655,
  29558. 0x345048a,0x02a1c3c,0x2393d8f,0x0992d71,0x1f71c5e,0x18d4e8a,
  29559. 0x30dd410,0x11d61d3,0x00dd58b } },
  29560. /* 151 */
  29561. { { 0x2230c72,0x30213d8,0x05e367e,0x329204e,0x0f14f6c,0x3369ddd,
  29562. 0x0bb4074,0x2edafd6,0x1b1aa2d,0x0785404,0x0c035ab,0x220da74,
  29563. 0x1f2fdd4,0x092a091,0x00ef83c },
  29564. { 0x3dc2538,0x1cca3e7,0x246afb5,0x24c647f,0x0798082,0x0bb7952,
  29565. 0x0f5c443,0x008b38a,0x299ea1a,0x3c6cf36,0x3df2ec7,0x398e6dc,
  29566. 0x29a1839,0x1cadd83,0x0077b62 } },
  29567. /* 152 */
  29568. { { 0x25d56d5,0x3546f69,0x16e02b1,0x3e5fa9a,0x03a9b71,0x2413d31,
  29569. 0x250ecc9,0x1d2de54,0x2ebe757,0x2a2f135,0x2aeeb9a,0x0d0fe2b,
  29570. 0x204cb0e,0x07464c3,0x00c473c },
  29571. { 0x24cd8ae,0x0c86c41,0x221c282,0x0795588,0x1f4b437,0x06fc488,
  29572. 0x0c81ecd,0x020bf07,0x3a9e2c8,0x2294a81,0x3a64a95,0x0363966,
  29573. 0x32c9a35,0x0f79bec,0x0029e4f } },
  29574. /* 153 */
  29575. { { 0x289aaa5,0x2755b2e,0x059e0aa,0x3031318,0x0f0208a,0x35b7729,
  29576. 0x00d9c6b,0x3dd29d0,0x075f2c2,0x0ece139,0x31562dd,0x04187f2,
  29577. 0x13b8d4c,0x0920b85,0x003924e },
  29578. { 0x09808ab,0x2e36621,0x2a36f38,0x1829246,0x229bf32,0x20883b7,
  29579. 0x159ada8,0x3108a14,0x15bbe5b,0x1e2d1e4,0x1730096,0x0d35cbb,
  29580. 0x15d0da9,0x0e60b94,0x00c4f30 } },
  29581. /* 154 */
  29582. { { 0x31de38b,0x27b9086,0x2760e3e,0x169098d,0x2a124e2,0x00596c6,
  29583. 0x3f73c09,0x0d31642,0x2341464,0x248600a,0x2e1fa10,0x2aa0fc8,
  29584. 0x051e954,0x00f3b67,0x001d4bd },
  29585. { 0x18751e6,0x25a8e1e,0x07f5c2d,0x17e30d4,0x0ed2723,0x23093e2,
  29586. 0x3b80e2c,0x13de2d7,0x2fad37f,0x1be1cfb,0x3224ba9,0x0a7f5d3,
  29587. 0x1714972,0x06667b7,0x009dcd9 } },
  29588. /* 155 */
  29589. { { 0x294f22a,0x3e06993,0x0341ee9,0x24bdc7b,0x2e56098,0x2660a13,
  29590. 0x018ddda,0x2c261b2,0x2953b54,0x267f51c,0x0e8a7cc,0x29ab00c,
  29591. 0x3a38247,0x397ac81,0x00de684 },
  29592. { 0x36b956b,0x347b34a,0x35834bd,0x053c06c,0x0090844,0x148cec5,
  29593. 0x380b325,0x2f17b8b,0x054ef5e,0x09683fb,0x3f8b29a,0x33c979a,
  29594. 0x1e01474,0x3e81fca,0x001c757 } },
  29595. /* 156 */
  29596. { { 0x30fdfe4,0x2d712ba,0x13671bc,0x2cfc226,0x3d7c649,0x16f020e,
  29597. 0x368e3f0,0x2981ebb,0x246a78a,0x115e81b,0x21223a4,0x04dbb30,
  29598. 0x1a50ba2,0x12114bd,0x0089bd6 },
  29599. { 0x055f15a,0x1046e51,0x00fd724,0x1c022a7,0x323dfa9,0x36d8efb,
  29600. 0x0da4d16,0x0910dec,0x2c1fb16,0x2dbe29f,0x298284f,0x2b273bb,
  29601. 0x26022c1,0x20accd5,0x00085a5 } },
  29602. /* 157 */
  29603. { { 0x01f138a,0x2d87e7b,0x0c2815c,0x0c19a3c,0x311c9a2,0x3e4fce3,
  29604. 0x029729d,0x21236b2,0x2984048,0x3f3bc95,0x2bba8fb,0x1a1b680,
  29605. 0x0619a3f,0x29e0447,0x00ed5fe },
  29606. { 0x2d1c833,0x3dcef35,0x3f809b4,0x01a1b9e,0x1509516,0x10ac754,
  29607. 0x2735080,0x27b0a8a,0x2495fb8,0x0a7bdba,0x1ef8b89,0x00233a5,
  29608. 0x0568bf1,0x1a126ba,0x0078a7e } },
  29609. /* 158 */
  29610. { { 0x0470cd8,0x20e9f04,0x30003fe,0x20be1b7,0x1927346,0x2a5026d,
  29611. 0x1ac06bd,0x2717ed7,0x2609493,0x3079ea5,0x1cc116d,0x31b0541,
  29612. 0x2c8ccde,0x10219ae,0x001a52b },
  29613. { 0x2864045,0x0e8d95b,0x2fc1530,0x0aa44e7,0x345eae7,0x3cc7553,
  29614. 0x3ec6466,0x229b60e,0x06f6e95,0x00bed2a,0x0ff4403,0x181c639,
  29615. 0x2e0df67,0x1f8fa46,0x0000811 } },
  29616. /* 159 */
  29617. { { 0x04310a2,0x20cee8e,0x09fc5d5,0x3707f5b,0x0bdfb4e,0x12713ee,
  29618. 0x24f1028,0x0787ee6,0x39a581c,0x3797ec8,0x10a9746,0x112cb9f,
  29619. 0x142b9ba,0x1da0ef6,0x0078f7b },
  29620. { 0x07607ae,0x3232872,0x2a7e076,0x0bb572a,0x182b23c,0x1d8f918,
  29621. 0x181f392,0x37c45a9,0x24a3886,0x0b2a297,0x264e7f2,0x1fa433c,
  29622. 0x0fcfcc8,0x21c0857,0x0004f74 } },
  29623. /* 160 */
  29624. { { 0x01d161c,0x1744585,0x2d17528,0x03a4f13,0x267cd2e,0x30d861f,
  29625. 0x062a647,0x213284b,0x139ed25,0x27d4ca5,0x02fbbd6,0x31ddf11,
  29626. 0x3c50ac4,0x1dd86f7,0x00107de },
  29627. { 0x16beebd,0x1b7317a,0x2151997,0x256a196,0x3be2aff,0x3621cab,
  29628. 0x0a9da19,0x05f3038,0x23da63c,0x3178d5e,0x215cc67,0x07f7f63,
  29629. 0x0c6d8d3,0x3bf5e5c,0x00c44bb } },
  29630. /* 161 */
  29631. { { 0x00c62f1,0x3e0f893,0x1572703,0x3b93865,0x19b1e28,0x389b33b,
  29632. 0x02858bf,0x0e3e9aa,0x04bc436,0x234e072,0x25ba43d,0x3dca19e,
  29633. 0x0274394,0x20f442e,0x003b4a7 },
  29634. { 0x176451e,0x2b5ed5d,0x35c8ee1,0x25c52da,0x0c3d0b5,0x32b306e,
  29635. 0x030954f,0x275ecf7,0x10e472c,0x21577c4,0x02f8a32,0x321bb5c,
  29636. 0x0098f97,0x104e237,0x00d0433 } },
  29637. /* 162 */
  29638. { { 0x0a8f2fe,0x034548b,0x141f1a6,0x121246f,0x1616409,0x237f80d,
  29639. 0x2e29a55,0x1218db6,0x3ea278e,0x1669856,0x1ad7c8e,0x36d11de,
  29640. 0x2c2fcbb,0x18c0b3a,0x001c706 },
  29641. { 0x1699b4b,0x2d531a6,0x17e85e2,0x1b48e78,0x2b509ca,0x2818ea0,
  29642. 0x0165fee,0x0b809ca,0x09db6a2,0x3dad798,0x326ee1d,0x204e416,
  29643. 0x091fa12,0x1c890e5,0x0007b9f } },
  29644. /* 163 */
  29645. { { 0x0ff4e49,0x0bb0512,0x0129159,0x05db591,0x03e4e9f,0x055ab30,
  29646. 0x0f82881,0x0ac2deb,0x3a8bb09,0x356a8d2,0x3d38393,0x03e4089,
  29647. 0x38187cd,0x1377a93,0x0041672 },
  29648. { 0x0139e73,0x3990730,0x187d3c4,0x33e4793,0x2e0fe46,0x2ad87e2,
  29649. 0x33c792c,0x21d4fb6,0x1e4d386,0x2932d1b,0x20f1098,0x1270874,
  29650. 0x0ea6ee4,0x0167d6e,0x005e5fd } },
  29651. /* 164 */
  29652. { { 0x1856031,0x2b7519d,0x3bd07fc,0x337abcb,0x089c7a4,0x2a1f120,
  29653. 0x3523ce7,0x2ba406b,0x09561d9,0x1797f04,0x3cdb95f,0x2d6193e,
  29654. 0x32c7d3f,0x223aed6,0x00beb51 },
  29655. { 0x2e65825,0x158f0ce,0x16413d1,0x310395f,0x3116854,0x250baf4,
  29656. 0x373d341,0x156cc47,0x104c069,0x0893716,0x195a0a6,0x035320e,
  29657. 0x37b7d8a,0x21b5755,0x00fb26b } },
  29658. /* 165 */
  29659. { { 0x286ae17,0x04239f1,0x1a56c53,0x0e74707,0x29090d7,0x2bb142b,
  29660. 0x03b0139,0x1aac916,0x08ba49a,0x0376682,0x3382f85,0x064bbab,
  29661. 0x2910e28,0x1d5bd7f,0x00cc8df },
  29662. { 0x0ab7630,0x208e8e7,0x3fc1877,0x26bee39,0x264984a,0x192ff05,
  29663. 0x08ef9c3,0x0aa6951,0x071c44e,0x26eed3e,0x035c95e,0x06906ad,
  29664. 0x10a0690,0x397eaa9,0x00c6c23 } },
  29665. /* 166 */
  29666. { { 0x034d8dd,0x005b064,0x279bb78,0x12c2c4f,0x1856bb4,0x0c90681,
  29667. 0x06409ab,0x3b48617,0x19a2d78,0x0a34bf8,0x326eddf,0x31f09b5,
  29668. 0x04f04dc,0x3d7c944,0x003ccaf },
  29669. { 0x321f843,0x35fb71a,0x1e4c397,0x377a5d7,0x2da88e4,0x3d6ada7,
  29670. 0x33d3964,0x1b30149,0x0e39aae,0x054dda0,0x3e6f946,0x1273394,
  29671. 0x3ffd3f7,0x2f6655e,0x00021dd } },
  29672. /* 167 */
  29673. { { 0x37233cf,0x11617dd,0x26f07b6,0x3d8250a,0x0fe6771,0x3f9bbbc,
  29674. 0x2aba7ad,0x200a58d,0x3568603,0x198eefa,0x1e8fcf3,0x3b9610b,
  29675. 0x20524ac,0x2a67528,0x0048d9a },
  29676. { 0x1a5e57a,0x1e9d303,0x16c9cff,0x0f39527,0x3c23259,0x03c8a1e,
  29677. 0x104bccf,0x182d5a1,0x18dbc83,0x05b5f42,0x1b402f4,0x317c525,
  29678. 0x11bf1ea,0x3c46e1f,0x0061936 } },
  29679. /* 168 */
  29680. { { 0x0153a9d,0x36859ee,0x2cf0aa9,0x2b27a0f,0x0a49fe3,0x2d984e1,
  29681. 0x018f8e1,0x1378453,0x1ab3843,0x1987093,0x283dae9,0x25cf0e8,
  29682. 0x14fc93d,0x280609d,0x00c99ba },
  29683. { 0x026b1e3,0x34663d3,0x2202477,0x21a9d45,0x212e8e1,0x18ab77e,
  29684. 0x2e52f63,0x0a14ce1,0x295c396,0x00c7a3d,0x2aaedb6,0x30abc4d,
  29685. 0x374acde,0x1318a73,0x00fcfdb } },
  29686. /* 169 */
  29687. { { 0x0a40298,0x3ba5633,0x11956b3,0x14fcbd7,0x3c38781,0x34bab96,
  29688. 0x165630e,0x1f3c831,0x37e3a69,0x2b4226c,0x2d5029e,0x3b4ab1e,
  29689. 0x1da6ac2,0x3eb43c3,0x007e5cd },
  29690. { 0x1b86202,0x109b7f6,0x2054f98,0x2c50cd7,0x2ed1960,0x3c518e7,
  29691. 0x1b02463,0x319c07f,0x1c30db6,0x045fdc2,0x373421e,0x31a1eb9,
  29692. 0x1a8acbf,0x31289b0,0x0013fef } },
  29693. /* 170 */
  29694. { { 0x3fa0a5f,0x068661f,0x2109e36,0x00b18ff,0x1f4b261,0x31d3844,
  29695. 0x0acbc56,0x3aebc99,0x1fa77ab,0x152bd11,0x24cddb7,0x2313f74,
  29696. 0x06eea44,0x15f5114,0x000b131 },
  29697. { 0x2e9993d,0x1ac565c,0x2cbe22a,0x3921797,0x12c3c57,0x360f868,
  29698. 0x33560bf,0x320ee99,0x382c3b8,0x39af88f,0x00bbe38,0x2c4ea59,
  29699. 0x3399b40,0x00ceb45,0x0066eea } },
  29700. /* 171 */
  29701. { { 0x0c6c693,0x31ba56d,0x3d3849f,0x378dabd,0x0efc735,0x17f90bf,
  29702. 0x13343d3,0x2df0f81,0x27c6a9a,0x13c2a90,0x0a0fcb2,0x27c10d9,
  29703. 0x3bc50c7,0x090e4fa,0x0016287 },
  29704. { 0x2927e1e,0x35af405,0x184c5c3,0x3499cee,0x240158e,0x33522e6,
  29705. 0x386fc84,0x0a0b69f,0x1a660ea,0x34590fb,0x22a1bee,0x2ce4fab,
  29706. 0x31a9445,0x0e78655,0x00664c8 } },
  29707. /* 172 */
  29708. { { 0x3eeaf94,0x115d409,0x21e7577,0x097aa67,0x22875c9,0x021ab7a,
  29709. 0x27e7ba5,0x1093f04,0x2a086fe,0x05d9494,0x2b6c028,0x10f31b0,
  29710. 0x1312d11,0x262759c,0x00c9bb2 },
  29711. { 0x1acb0a5,0x30cdf14,0x0f78880,0x0574f18,0x1a37109,0x098adbb,
  29712. 0x2113c09,0x2060925,0x1f89ce4,0x1974976,0x3381358,0x2dab5ca,
  29713. 0x2159c53,0x3af1303,0x000ea3b } },
  29714. /* 173 */
  29715. { { 0x1e49bea,0x29142b1,0x1a59cab,0x055f017,0x0684e54,0x39eb0db,
  29716. 0x29cab9d,0x255ee8b,0x35f2e6f,0x05329e6,0x09b817b,0x1ec091c,
  29717. 0x1df0fef,0x2641f62,0x00eb304 },
  29718. { 0x2fe5096,0x3dcc1d1,0x2aaf508,0x3a0b813,0x0695810,0x144bddb,
  29719. 0x2f1bd93,0x281ae23,0x3513ebc,0x1ddd984,0x0cf158b,0x35218eb,
  29720. 0x257daf7,0x391253b,0x00b2a81 } },
  29721. /* 174 */
  29722. { { 0x153e6ba,0x22396db,0x0ea2ff2,0x2a45121,0x0a90de1,0x34cf23b,
  29723. 0x2db60ce,0x1a900be,0x2f328b6,0x355e75b,0x2c24372,0x0b75b77,
  29724. 0x2ec7d4f,0x3f24759,0x00e9e33 },
  29725. { 0x39eab6e,0x2267480,0x3b5e110,0x1e8fa5e,0x2a31a66,0x3f739a3,
  29726. 0x00166dc,0x3552d88,0x3ae5137,0x3efa0fa,0x0800acd,0x17df61d,
  29727. 0x38c8608,0x04cc31b,0x00cf4ab } },
  29728. /* 175 */
  29729. { { 0x31e08fb,0x1961164,0x22c003f,0x078541b,0x3643855,0x30da587,
  29730. 0x11f0dc9,0x324595e,0x329e3dc,0x29a041e,0x3495d2c,0x0908dd3,
  29731. 0x1895b83,0x198dbb9,0x00d8cfb },
  29732. { 0x0349b1b,0x383c5a8,0x2b86525,0x1b1283e,0x133cd2c,0x2be376a,
  29733. 0x012ee82,0x1eb4d1b,0x0ba71e9,0x01f3109,0x37621eb,0x1d9b77c,
  29734. 0x0d39069,0x3d5a97c,0x0095565 } },
  29735. /* 176 */
  29736. { { 0x20f5e94,0x1eefc86,0x1327e0e,0x054760b,0x2f771e1,0x3ac447e,
  29737. 0x033e3dc,0x198e040,0x04dd342,0x1b49a5d,0x00d01ef,0x3cb6768,
  29738. 0x1ceafbd,0x31c6812,0x001cb80 },
  29739. { 0x221c677,0x060ca27,0x398b17f,0x0146723,0x36452af,0x02d9e65,
  29740. 0x39c5f78,0x3cf50d6,0x0be40f8,0x2970b87,0x26d667c,0x3e45959,
  29741. 0x16e7943,0x01673e7,0x009faaa } },
  29742. /* 177 */
  29743. { { 0x2078fe6,0x0918602,0x11dd8ad,0x399193f,0x0f6cc73,0x0f8dd12,
  29744. 0x2ce34dc,0x06d7d34,0x0c5e327,0x0989254,0x2fc5af7,0x2443d7b,
  29745. 0x32bc662,0x2fe2a84,0x008b585 },
  29746. { 0x039327f,0x08e616a,0x252f117,0x1f52ab0,0x234e2d2,0x0a5b313,
  29747. 0x2f59ef6,0x0f7a500,0x15c4705,0x2c02b81,0x28b4f09,0x08aa5c8,
  29748. 0x0180efc,0x0993e83,0x00a9e86 } },
  29749. /* 178 */
  29750. { { 0x0310ecc,0x2d8892f,0x14ed0b7,0x3c59fe8,0x08a1a74,0x0850e57,
  29751. 0x1d09607,0x044a21f,0x109f5c9,0x237c6cf,0x06b264a,0x3fc8f1a,
  29752. 0x0d4c539,0x2740f96,0x00dc2d4 },
  29753. { 0x1d6f501,0x0adf4ea,0x14f7215,0x0930102,0x3f4c32e,0x24e2643,
  29754. 0x366596d,0x081ff18,0x38f94fb,0x2c21341,0x328594c,0x267c75c,
  29755. 0x196b3fd,0x29932cb,0x0036def } },
  29756. /* 179 */
  29757. { { 0x3ed7cbe,0x26de044,0x3d0e461,0x0565e12,0x295e500,0x31dc17f,
  29758. 0x32251c2,0x3420ca8,0x3995f0d,0x2e8ddab,0x0361a45,0x10971b0,
  29759. 0x11e7b55,0x33bc7ca,0x00812d2 },
  29760. { 0x3d94972,0x1606817,0x0383ccf,0x0e795b7,0x026e20e,0x0f6fefc,
  29761. 0x13685d6,0x315d402,0x0cc36b8,0x1c7f059,0x390ef5e,0x316ae04,
  29762. 0x08c66b9,0x2fac9a4,0x0040086 } },
  29763. /* 180 */
  29764. { { 0x3e3c115,0x153de4d,0x1a8ae5e,0x2330511,0x169b8ee,0x1d965c2,
  29765. 0x2edff2b,0x3ef99e6,0x1631b46,0x1f8a238,0x118d7bb,0x12113c3,
  29766. 0x26424db,0x0f4122a,0x00e0ea2 },
  29767. { 0x3d80a73,0x30393bc,0x0f98714,0x278ef59,0x087a0aa,0x3b18c20,
  29768. 0x04b8a82,0x2068e21,0x030255d,0x3382b27,0x055397f,0x05448dd,
  29769. 0x2015586,0x1190be0,0x000b979 } },
  29770. /* 181 */
  29771. { { 0x2e03080,0x2895692,0x09fb127,0x2d1602a,0x1232306,0x105bd4e,
  29772. 0x28cd6a6,0x0a83813,0x1ee13b0,0x2abadc3,0x0c09684,0x00e33e1,
  29773. 0x033eea3,0x30f0a39,0x00a710e },
  29774. { 0x01b1f7d,0x1c959da,0x017077a,0x254bf0a,0x086fbce,0x15cd6b2,
  29775. 0x008683f,0x23a4f4d,0x22a6bd6,0x14e8c93,0x0027d15,0x31d0d4f,
  29776. 0x271777e,0x1533510,0x00ab603 } },
  29777. /* 182 */
  29778. { { 0x34c209d,0x14d0abb,0x270432a,0x1d02358,0x22ba752,0x209757f,
  29779. 0x34af6fc,0x1ffc52e,0x1ced28e,0x1870e46,0x1e0340f,0x3f0bf73,
  29780. 0x33ba91d,0x2ebca7c,0x00c6580 },
  29781. { 0x1d442cb,0x0879d50,0x24e4ae1,0x3f4e91c,0x04c7727,0x093cd1d,
  29782. 0x16d6a45,0x10a8b95,0x0c77856,0x361f84f,0x217845f,0x0bbeec6,
  29783. 0x0485718,0x33c5385,0x00dcec0 } },
  29784. /* 183 */
  29785. { { 0x1539819,0x225507a,0x1bf11cb,0x13e7653,0x0c8cb3b,0x05f695e,
  29786. 0x353f634,0x2827874,0x3fb8053,0x22de9a5,0x035d8b7,0x2105cc7,
  29787. 0x2a7a98d,0x35bed95,0x0085748 },
  29788. { 0x1859c5d,0x00e51f0,0x22a21fd,0x3054d74,0x06ce965,0x328eab7,
  29789. 0x26a13e0,0x13bfc65,0x01d4fb1,0x36600b9,0x36dd3fc,0x01232ed,
  29790. 0x15bbaa9,0x0ad7a51,0x0089b18 } },
  29791. /* 184 */
  29792. { { 0x3360710,0x1eb5a90,0x136bd77,0x3bd57a6,0x0841287,0x12886c9,
  29793. 0x35c6700,0x21bc6eb,0x25f35ad,0x3bcb01c,0x0707e72,0x23e9943,
  29794. 0x03e5233,0x34bb622,0x002bf8e },
  29795. { 0x16e0d6a,0x04b3d2d,0x290cb02,0x049a10c,0x350537e,0x22cf71b,
  29796. 0x3184a19,0x2dc8b62,0x2350210,0x3b4afa6,0x159781e,0x1d01b6d,
  29797. 0x1853440,0x16442f0,0x005a78d } },
  29798. /* 185 */
  29799. { { 0x348b02c,0x1ea8ab5,0x3b954d5,0x14684ac,0x0be5b34,0x11c4496,
  29800. 0x0a7a456,0x14f6eb7,0x11a3221,0x2d65f82,0x32eb1ea,0x09c4018,
  29801. 0x3f301f3,0x32e8a1c,0x00bd9ad },
  29802. { 0x0543f7f,0x31e744e,0x1fefd1d,0x24a486c,0x1000220,0x3977e3b,
  29803. 0x1b3ef51,0x2512a1b,0x2049e6b,0x122232b,0x391a32b,0x2f4a7b1,
  29804. 0x1c13e71,0x081a9b4,0x00d3516 } },
  29805. /* 186 */
  29806. { { 0x1924f43,0x1ae5495,0x28d52ef,0x2b93e77,0x2d2f401,0x371a010,
  29807. 0x33e8d7a,0x06ed3f1,0x30c0d9d,0x2589fa9,0x3bf3567,0x2ecf8fa,
  29808. 0x2dee4c3,0x152b620,0x007e8a2 },
  29809. { 0x1924407,0x01bd42d,0x044a089,0x18686b5,0x2f14a0e,0x17cdce3,
  29810. 0x0efa216,0x3c586a8,0x1d6ae71,0x375831f,0x3175894,0x20e43eb,
  29811. 0x34c009e,0x3480527,0x00d115c } },
  29812. /* 187 */
  29813. { { 0x12abf77,0x38b0769,0x25682f2,0x295508c,0x0c2a0dc,0x1259b73,
  29814. 0x023ea25,0x340e7b5,0x3c7cd0d,0x1f92324,0x176405c,0x1528894,
  29815. 0x18f2e1e,0x2c59c35,0x001efb5 },
  29816. { 0x0fb1471,0x07e7665,0x141da75,0x07d9f4a,0x0fdb31e,0x0dccda6,
  29817. 0x074eb25,0x3d92a9b,0x11189a0,0x1b4c557,0x24b8d2b,0x0533f92,
  29818. 0x0e9e344,0x2fa3dea,0x008d5a4 } },
  29819. /* 188 */
  29820. { { 0x2669e98,0x1ad3514,0x2a035c9,0x08a3f50,0x24547f9,0x0a145d3,
  29821. 0x1c1319d,0x3fe833d,0x1ae064b,0x1e01734,0x246d27e,0x3a2f13c,
  29822. 0x01e1150,0x263f55e,0x00f89ef },
  29823. { 0x2e0b63f,0x3e57db7,0x23a4b4f,0x11c8899,0x0ad8500,0x348f3a7,
  29824. 0x2918604,0x27d6409,0x1ce5001,0x38f94c2,0x29a508a,0x39bdc89,
  29825. 0x3a52c27,0x194899e,0x00e9376 } },
  29826. /* 189 */
  29827. { { 0x0368708,0x34a2730,0x2e1da04,0x0bd78c1,0x2c45887,0x0c44bfa,
  29828. 0x3a23de3,0x390b9db,0x1746efd,0x05c638e,0x1d20609,0x3263370,
  29829. 0x31987f0,0x2988529,0x005fa3c },
  29830. { 0x0aa9f2a,0x20622f7,0x060deee,0x0c9626a,0x3312cc7,0x18ebac7,
  29831. 0x008dd6c,0x0ad4fe6,0x3db4ea6,0x1dc3f50,0x090b6e9,0x0aff8d2,
  29832. 0x26aa62c,0x18f3e90,0x00105f8 } },
  29833. /* 190 */
  29834. { { 0x38059ad,0x25e576c,0x3ea00b2,0x1fa4191,0x25686b7,0x2d1ce8f,
  29835. 0x30470ed,0x3478bbf,0x340f9b6,0x1c9e348,0x3d594ec,0x2ffe56e,
  29836. 0x3f23deb,0x0cd34e9,0x00f4b72 },
  29837. { 0x1a83f0b,0x2166029,0x28b32a2,0x06a5c5a,0x20786c4,0x0944604,
  29838. 0x0901bd2,0x379b84e,0x221e2fe,0x0346d54,0x1f4eb59,0x01b8993,
  29839. 0x2462e08,0x25f9d8b,0x006c4c8 } },
  29840. /* 191 */
  29841. { { 0x0b41d9d,0x2e417ed,0x265bd10,0x199148e,0x3826ca4,0x1a67e8d,
  29842. 0x1bbd13b,0x23e414d,0x3d773bc,0x356e64c,0x0d2118a,0x0cb587f,
  29843. 0x25fd093,0x24fb529,0x00158c6 },
  29844. { 0x2806e63,0x3ecaa39,0x251b4dd,0x3b2d779,0x2e31ed3,0x066f1a6,
  29845. 0x060e518,0x2c7e3e5,0x0d62c76,0x0d88a70,0x101970a,0x1e3c8c6,
  29846. 0x272b8bb,0x083e73b,0x0031f38 } },
  29847. /* 192 */
  29848. { { 0x09e1c72,0x072bcb0,0x0cf4e93,0x2604a64,0x00715f2,0x10c98b6,
  29849. 0x2ad81d9,0x234fcce,0x37a7304,0x1974a4a,0x1c7415f,0x14aaa93,
  29850. 0x19587b1,0x3f643f4,0x00c3d10 },
  29851. { 0x1ddadd0,0x2cd715d,0x294cf76,0x14479ed,0x19f5f4a,0x0198c09,
  29852. 0x1ab7ebc,0x182c0bc,0x0879202,0x1807273,0x05d39da,0x2c7d868,
  29853. 0x29c4ec4,0x1b13ad2,0x006dcd7 } },
  29854. /* 193 */
  29855. { { 0x1c83f01,0x0245bff,0x24f90ba,0x112554f,0x2354c8b,0x3f17988,
  29856. 0x0c511af,0x39e1e9b,0x26ae95b,0x0ae551c,0x35b41a6,0x0120455,
  29857. 0x1e989cb,0x1b37aff,0x00fa2ae },
  29858. { 0x324659a,0x1aef1c3,0x1c43637,0x3f530a2,0x313a999,0x326af62,
  29859. 0x134184e,0x2ac131c,0x3f6a789,0x30a300a,0x13e526e,0x2107af3,
  29860. 0x093a8ff,0x2479902,0x00442b1 } },
  29861. /* 194 */
  29862. { { 0x22b6e20,0x31b18be,0x18614ca,0x26fdb5a,0x197f29e,0x325b44b,
  29863. 0x0ab1dbb,0x042348a,0x3275e8e,0x15bae44,0x0077124,0x2cf5345,
  29864. 0x2803ad4,0x188f2a2,0x0061b20 },
  29865. { 0x2a560b1,0x3ced069,0x3cf42c2,0x100e167,0x3879e1d,0x0936ff0,
  29866. 0x1b51450,0x14c55f3,0x3153bfa,0x2957423,0x2a93823,0x15f5dce,
  29867. 0x2c9a22f,0x16731a8,0x00a97f2 } },
  29868. /* 195 */
  29869. { { 0x18edbbb,0x18c5ef9,0x1f13c30,0x071e77f,0x225ade5,0x1b60f75,
  29870. 0x1beaf11,0x3e495ad,0x2441dd8,0x2fa00e2,0x32a87b6,0x00050f2,
  29871. 0x038de7f,0x0037d6d,0x00a885d },
  29872. { 0x39e48bd,0x1d9e433,0x2768e9f,0x3c29458,0x3f0bdf9,0x35ed5f2,
  29873. 0x36709fa,0x176dc10,0x012f7c1,0x2df8547,0x1d90ee3,0x053c089,
  29874. 0x21a8d35,0x200cb0d,0x002e84e } },
  29875. /* 196 */
  29876. { { 0x23ec8d8,0x1d81f55,0x0cb7227,0x07f8e4d,0x2a66181,0x163f577,
  29877. 0x272e7af,0x131a8f2,0x2046229,0x25e6276,0x36bbefe,0x2cdc22f,
  29878. 0x17c8288,0x33dd4fb,0x000d524 },
  29879. { 0x330c073,0x1a6728b,0x1cf369f,0x12e7707,0x2f0fa26,0x17c2abd,
  29880. 0x0a45680,0x26ebd13,0x3c7d19b,0x1c3d6c8,0x2abd110,0x064fd07,
  29881. 0x09b8339,0x02b4a9f,0x009e3e1 } },
  29882. /* 197 */
  29883. { { 0x0ae972f,0x2093c35,0x06e7a90,0x0af1ba1,0x243eef0,0x2748582,
  29884. 0x0606122,0x13a45f9,0x0acfe60,0x08a685e,0x0eb184b,0x015bc11,
  29885. 0x0cdf423,0x157fad5,0x004fcad },
  29886. { 0x2728d15,0x3e5bceb,0x0331a0f,0x31b1a80,0x28a2680,0x3b94955,
  29887. 0x04cae07,0x176b57e,0x03ac5a6,0x3d7918b,0x22d23f4,0x0ae077f,
  29888. 0x1eb075d,0x006f16c,0x006e473 } },
  29889. /* 198 */
  29890. { { 0x38219b9,0x0475a2b,0x107a774,0x39946c6,0x1cb883c,0x004e0ed,
  29891. 0x087e571,0x25c3497,0x059982f,0x0a71f66,0x118305d,0x1aaf294,
  29892. 0x3a5dbaa,0x34be404,0x00725fe },
  29893. { 0x3abd109,0x336ebea,0x2528487,0x15a1d61,0x0c0f8cf,0x2b56095,
  29894. 0x2591e68,0x3549a80,0x1d1debb,0x0701c6c,0x161e7e3,0x1f7fa2e,
  29895. 0x3dfe192,0x17e6498,0x0055f89 } },
  29896. /* 199 */
  29897. { { 0x175645b,0x26c036c,0x0b92f89,0x09ed96d,0x351f3a6,0x19ce67b,
  29898. 0x33ac8db,0x2f0828b,0x27fe400,0x0b9c5e1,0x1967b95,0x3324080,
  29899. 0x11de142,0x1d44fb3,0x003d596 },
  29900. { 0x3979775,0x3af37b6,0x3e88d41,0x2f1a8b9,0x299ba61,0x085413c,
  29901. 0x1149a53,0x0beb40e,0x31427ba,0x239f708,0x357d836,0x1558c22,
  29902. 0x280a79f,0x1b255f6,0x002b6d1 } },
  29903. /* 200 */
  29904. { { 0x39ad982,0x3d79d89,0x01a684a,0x0b6722e,0x39bb4c9,0x39a6399,
  29905. 0x1ad44e0,0x3059f5e,0x048265f,0x33a2fa4,0x0c3a4cc,0x0d7df98,
  29906. 0x23a33f1,0x34e2e21,0x00a0a10 },
  29907. { 0x386efd9,0x1c91f34,0x06c2e19,0x3e6d48d,0x00eefd3,0x2181ef2,
  29908. 0x2415f97,0x1d33b08,0x0625086,0x1e8aa3e,0x08c9d60,0x0ab427b,
  29909. 0x2764fa7,0x3b7943e,0x00cd9f0 } },
  29910. /* 201 */
  29911. { { 0x1a46d4d,0x0e471f4,0x1693063,0x0467ac0,0x22df51c,0x127a0f7,
  29912. 0x0498008,0x20e0b16,0x1aa8ad0,0x1923f42,0x2a74273,0x01761ce,
  29913. 0x1600ca4,0x187b87e,0x00ee49e },
  29914. { 0x0c76f73,0x19daf92,0x0b2ad76,0x3d8049d,0x1d9c100,0x0fe1c63,
  29915. 0x0bb67c8,0x035cc44,0x02002fc,0x37b2169,0x344656a,0x1127879,
  29916. 0x1939bc0,0x0dd8df6,0x0028ce7 } },
  29917. /* 202 */
  29918. { { 0x0544ac7,0x26bdc91,0x042697e,0x356e804,0x1f2c658,0x2ceb7ef,
  29919. 0x2dec39f,0x02c1dcc,0x391a2df,0x2344beb,0x2171e20,0x3099c94,
  29920. 0x0fa548a,0x37216c9,0x00f820c },
  29921. { 0x0f4cf77,0x29bbaa5,0x33c6307,0x34a5128,0x118c783,0x2dd06b1,
  29922. 0x139d4c0,0x2db912e,0x1153ffb,0x1075eb3,0x3a255e4,0x2892161,
  29923. 0x36d5006,0x125338c,0x0014fbc } },
  29924. /* 203 */
  29925. { { 0x1584e3c,0x0830314,0x00279b9,0x167df95,0x2c7733c,0x2108aef,
  29926. 0x0ce1398,0x35aaf89,0x012523b,0x3c46b6a,0x388e6de,0x01a2002,
  29927. 0x0582dde,0x19c7fa3,0x007b872 },
  29928. { 0x1e53510,0x11bca1f,0x19684e7,0x267de5c,0x2492f8b,0x364a2b0,
  29929. 0x080bc77,0x2c6d47b,0x248432e,0x3ace44f,0x32028f6,0x0212198,
  29930. 0x2f38bad,0x20d63f0,0x00122bb } },
  29931. /* 204 */
  29932. { { 0x30b29c3,0x3cec78e,0x01510a9,0x0c93e91,0x3837b64,0x1eca3a9,
  29933. 0x105c921,0x05d42e6,0x1379845,0x07ce6f2,0x0e8b6da,0x0e0f093,
  29934. 0x220b2cd,0x1f6c041,0x00299f5 },
  29935. { 0x0afdce3,0x2b0e596,0x2f477b6,0x2ccf417,0x3a15206,0x26ec0bf,
  29936. 0x2e37e2b,0x2593282,0x0ab9db3,0x2841dd8,0x27954be,0x277a681,
  29937. 0x03f82e2,0x2b610c7,0x00446a1 } },
  29938. /* 205 */
  29939. { { 0x06b8195,0x3b3a817,0x31b9c6f,0x317d279,0x3d744a7,0x1de9eb9,
  29940. 0x296acc1,0x1ce9ea3,0x06c3587,0x246815d,0x3756736,0x0588518,
  29941. 0x1c971a4,0x1fde1f4,0x00aa021 },
  29942. { 0x3fd3226,0x274561d,0x00be61e,0x01393d8,0x30f6f23,0x29b7fc1,
  29943. 0x04cebc7,0x0a892a7,0x20109f1,0x27456be,0x0c863ee,0x2eb6c8a,
  29944. 0x38c782b,0x039397a,0x00a2829 } },
  29945. /* 206 */
  29946. { { 0x29de330,0x21fe80f,0x145b55b,0x1986570,0x012b260,0x2482fbc,
  29947. 0x0536e0a,0x16b7382,0x32c4d19,0x1deffdb,0x145f418,0x0c67a76,
  29948. 0x2ce477f,0x218fe24,0x00f9848 },
  29949. { 0x3e37657,0x3f074d3,0x245ad0e,0x20973c3,0x23c58de,0x2c332ef,
  29950. 0x2ad21a8,0x0bf1589,0x208af95,0x1f4a8c4,0x2b43735,0x1e46657,
  29951. 0x15d4f81,0x0c3e63a,0x005f19d } },
  29952. /* 207 */
  29953. { { 0x26865bb,0x20f6683,0x16a672e,0x0efd8d1,0x222f5af,0x18f2367,
  29954. 0x1e9c734,0x25c3902,0x178dfe6,0x2903a79,0x311b91c,0x1adbbe9,
  29955. 0x225a387,0x0b3e509,0x0089551 },
  29956. { 0x34e462b,0x23b6a32,0x27c884c,0x129104b,0x384c015,0x3adedc7,
  29957. 0x325db1c,0x021dc10,0x1e366f7,0x3054df7,0x1992b9a,0x2824e64,
  29958. 0x0ae77f3,0x181b526,0x00a7316 } },
  29959. /* 208 */
  29960. { { 0x2d260f5,0x2434bf2,0x28c0139,0x0a7bb03,0x176c3be,0x3def5f5,
  29961. 0x05bee00,0x3692df7,0x3d2efeb,0x3a6f859,0x1122b87,0x38f779a,
  29962. 0x1415ccc,0x2c260ad,0x0075a28 },
  29963. { 0x04607a6,0x042f37a,0x3f0df68,0x0a1bd36,0x3c6d581,0x2d36bfa,
  29964. 0x2d577d1,0x0a3affa,0x0b2066b,0x2e6f110,0x0b17e84,0x3c76a5e,
  29965. 0x1a57553,0x012f36a,0x0004595 } },
  29966. /* 209 */
  29967. { { 0x29e5836,0x0e6808c,0x269d13e,0x147dc5c,0x32c9e7d,0x09b258e,
  29968. 0x2c58d6f,0x1efd716,0x0437996,0x34ec31b,0x15908d9,0x2efa8fd,
  29969. 0x09ad160,0x079fc1f,0x00d8481 },
  29970. { 0x3d20e4a,0x18269d6,0x3aa8fe7,0x34829c2,0x2e4325d,0x0d800e1,
  29971. 0x11f370b,0x10c08dc,0x22fd092,0x1a5fe55,0x0acc443,0x037030d,
  29972. 0x1cdd404,0x097379e,0x00fd6d7 } },
  29973. /* 210 */
  29974. { { 0x313eafb,0x3f438f3,0x2e5fb3e,0x2ed6a82,0x121009c,0x240889e,
  29975. 0x00c5537,0x269b792,0x334b2fc,0x1dd573c,0x07096ae,0x19296fc,
  29976. 0x3813985,0x2742f48,0x00ddd64 },
  29977. { 0x2045041,0x3842c62,0x1572d0d,0x04f255f,0x06e05b4,0x383ec97,
  29978. 0x1ff8064,0x18bed71,0x39b6411,0x2764cc5,0x257439f,0x3521217,
  29979. 0x172aa42,0x342a2a3,0x0070c5b } },
  29980. /* 211 */
  29981. { { 0x3bdf646,0x1c5ce25,0x1f7ca76,0x2d2acca,0x3aa1485,0x23c97f7,
  29982. 0x3e11d6f,0x0609338,0x07ec622,0x01da8ff,0x3392474,0x17ca07f,
  29983. 0x13a9a04,0x353a5b4,0x0024557 },
  29984. { 0x14c27cd,0x32012f7,0x3fea875,0x3d03d71,0x211c5f0,0x3157fdf,
  29985. 0x0c880bd,0x3c406b2,0x2c51103,0x24ab377,0x399faa8,0x0d06887,
  29986. 0x16b5738,0x28b33a7,0x00c7b67 } },
  29987. /* 212 */
  29988. { { 0x2357586,0x35c93e3,0x0da09a0,0x3d77d92,0x11d7f4f,0x37b98a9,
  29989. 0x3e6c9bf,0x2cdca70,0x2f00389,0x2412673,0x18eab87,0x0101436,
  29990. 0x11617e9,0x06d9b01,0x00e8eef },
  29991. { 0x37e3ca9,0x16ffaf0,0x391debf,0x1b69382,0x07c5e94,0x312fa8a,
  29992. 0x0973142,0x2cadde4,0x109ee67,0x3a07db0,0x1afc5ed,0x08df66f,
  29993. 0x304c7af,0x0804aae,0x00d2e60 } },
  29994. /* 213 */
  29995. { { 0x24f57bf,0x1818322,0x182a615,0x25bfc44,0x0f97586,0x0a5bbc0,
  29996. 0x36773c6,0x1a2660c,0x3ceff66,0x3270152,0x319cd11,0x2845845,
  29997. 0x1acfad6,0x19076f8,0x009824a },
  29998. { 0x289fd01,0x2de97ee,0x39d80b7,0x026227d,0x0f8d3b8,0x15e0a17,
  29999. 0x21ea08f,0x20a2317,0x136ae6d,0x3deb1d1,0x3521ef5,0x0de8801,
  30000. 0x0a25d5d,0x0612c98,0x005ecc4 } },
  30001. /* 214 */
  30002. { { 0x308c8d3,0x3aec669,0x01ecddc,0x13f18fe,0x1e63ed0,0x061cfe5,
  30003. 0x05f5a01,0x1db5741,0x14479f2,0x0ced6b5,0x025ae5b,0x09ca8f5,
  30004. 0x2160581,0x1404433,0x008bfeb },
  30005. { 0x08228bf,0x0e02722,0x37df423,0x33ecabf,0x34bd82a,0x32f529f,
  30006. 0x28f1800,0x0c8f671,0x1246b44,0x1ff35dc,0x091db95,0x303f3da,
  30007. 0x28f7f60,0x3624136,0x00cfbb4 } },
  30008. /* 215 */
  30009. { { 0x326139a,0x2977e4e,0x3eb89a6,0x20ecb31,0x13e076a,0x2a592f3,
  30010. 0x28e82d5,0x235ad1e,0x239b927,0x262938a,0x2444354,0x141b263,
  30011. 0x0d56693,0x2a3fc78,0x0006497 },
  30012. { 0x31efa05,0x3a3664a,0x3e333de,0x2a114e4,0x12da63c,0x3c15e6b,
  30013. 0x2f7277c,0x363aa92,0x2393236,0x16bd2d1,0x32b617f,0x32b656c,
  30014. 0x3b1246c,0x22e2e22,0x00ce76d } },
  30015. /* 216 */
  30016. { { 0x03843dc,0x094de82,0x13b463d,0x0507905,0x089eb35,0x2a6bf25,
  30017. 0x35ebc4e,0x2bb5d45,0x1808ed1,0x1de9949,0x185e829,0x0a55847,
  30018. 0x0b73d67,0x1a2ed61,0x008dd2d },
  30019. { 0x133c3a4,0x04e7980,0x38ea237,0x2ad2f49,0x19de838,0x018bf36,
  30020. 0x29b072c,0x21c1ba0,0x14f63ba,0x31c1cc3,0x13cd05e,0x20120ff,
  30021. 0x1f84d60,0x16e0321,0x00872ab } },
  30022. /* 217 */
  30023. { { 0x19d4d49,0x1ddb4e6,0x05e7fc0,0x37bb0fd,0x1a3eb59,0x36b87f0,
  30024. 0x190e440,0x1c7fef2,0x31ea153,0x14cd65a,0x1bc7ab2,0x11f72ca,
  30025. 0x39582d4,0x0fa4d65,0x00cd5b6 },
  30026. { 0x3d1ff11,0x0d9be9d,0x2903ae3,0x017b7b9,0x259f28f,0x110cefc,
  30027. 0x03fed1a,0x38039bd,0x09bdf9c,0x3055027,0x2ca9c5d,0x2d737b6,
  30028. 0x3bdb421,0x16560b5,0x00f9f33 } },
  30029. /* 218 */
  30030. { { 0x022c792,0x110de25,0x38bf959,0x08f2562,0x1239ea9,0x3c1d950,
  30031. 0x21a247d,0x315112d,0x285bb9f,0x2534a73,0x0b42455,0x1a4a99c,
  30032. 0x069009a,0x1680392,0x006e0ca },
  30033. { 0x1b3bece,0x269e0a1,0x18926b7,0x0e7187e,0x241f35e,0x39d1fe0,
  30034. 0x02099aa,0x1675bfe,0x23fd0ca,0x3d6322b,0x19406b5,0x324c38a,
  30035. 0x242434a,0x3ae677c,0x002ce04 } },
  30036. /* 219 */
  30037. { { 0x2c37b82,0x1ae6506,0x0d83436,0x23496c1,0x0ff0c72,0x2711edf,
  30038. 0x1513611,0x04f9c7d,0x1edbeff,0x376fcb5,0x212a683,0x23bf547,
  30039. 0x0f9c4f7,0x16e6627,0x0082cd8 },
  30040. { 0x0cb5d37,0x31b6db8,0x1a15e23,0x2f5cbb8,0x0818aee,0x21dc6c5,
  30041. 0x12aafd2,0x205f608,0x1d91def,0x3def088,0x1445c51,0x3100e8a,
  30042. 0x3746bda,0x145c4b0,0x00711b0 } },
  30043. /* 220 */
  30044. { { 0x2a99ecc,0x27b5217,0x35e10ed,0x036e32a,0x0f79950,0x15c32f7,
  30045. 0x2c87dcb,0x3ebb2a3,0x2c2d35d,0x114b3ec,0x2e4d80a,0x0c7eb89,
  30046. 0x2abe58d,0x3727737,0x00e6a37 },
  30047. { 0x1eca452,0x1968d07,0x344e5d3,0x29435a2,0x109a5f8,0x181d12c,
  30048. 0x238ea5a,0x127a564,0x00dbb42,0x0fcbfb7,0x2909b2e,0x2571d3a,
  30049. 0x08250e3,0x0694e4e,0x00e156d } },
  30050. /* 221 */
  30051. { { 0x3181ae9,0x1acf411,0x3808d79,0x2a11065,0x0baf44b,0x133cfeb,
  30052. 0x1330943,0x1711b9a,0x2dec3bd,0x1906a9a,0x2ed947c,0x369d763,
  30053. 0x1a5254f,0x104a7a9,0x00acd9d },
  30054. { 0x030301b,0x31568f5,0x2a4965c,0x33ded4b,0x03c9a5b,0x16541fc,
  30055. 0x1319cf1,0x2a3748b,0x1b5de74,0x18bb82e,0x077ac2b,0x309a87a,
  30056. 0x3c31420,0x0f6a4b9,0x00387d7 } },
  30057. /* 222 */
  30058. { { 0x0d3fdac,0x120cfa3,0x1b8e13c,0x1ccccb9,0x376fcd4,0x0bf87f4,
  30059. 0x271b4be,0x363b3fd,0x28b5d98,0x0535cd3,0x114bbc1,0x3ab4f19,
  30060. 0x10494b1,0x2161ece,0x00d14ca },
  30061. { 0x12d37e9,0x110ebd7,0x062295a,0x1cc0119,0x073c6ea,0x15d5411,
  30062. 0x0aeb4b1,0x23fba91,0x175fab5,0x3ee8fe1,0x1c680a6,0x1e76f27,
  30063. 0x3ddfc97,0x3d69ecd,0x00e1ee5 } },
  30064. /* 223 */
  30065. { { 0x2d29f46,0x2d19204,0x3137cd0,0x02c3b54,0x193295b,0x02fbdb2,
  30066. 0x2260948,0x22c02ff,0x3885424,0x1299595,0x00e7f9c,0x310ff2a,
  30067. 0x01ea169,0x0deef85,0x0021908 },
  30068. { 0x1b26cfb,0x38566a8,0x2852875,0x21debff,0x290ca9f,0x0b29663,
  30069. 0x26550d9,0x2b44457,0x05d1938,0x1f8f825,0x366ef93,0x1d8daec,
  30070. 0x069e5ef,0x342ece6,0x00b6034 } },
  30071. /* 224 */
  30072. { { 0x2d8356e,0x1578c09,0x226f4d2,0x3b74c51,0x0f83666,0x0323b59,
  30073. 0x1ddf61d,0x1ed8508,0x3c52667,0x0e5b91c,0x1e9b18b,0x352bdfa,
  30074. 0x13f75da,0x352aa4e,0x00fceff },
  30075. { 0x1c731d5,0x04e2844,0x01d9843,0x286cbc5,0x105bcb3,0x05edd9c,
  30076. 0x21fa956,0x3b1ec83,0x01288cc,0x22fbf3a,0x10f1b56,0x081cf72,
  30077. 0x15cb758,0x18687c1,0x00f5722 } },
  30078. /* 225 */
  30079. { { 0x2973088,0x1209dcd,0x3980f31,0x0221aa7,0x1c008e7,0x011b098,
  30080. 0x395947e,0x2f2806d,0x27dca76,0x037c79a,0x31acddf,0x2bf6219,
  30081. 0x0d8f4ab,0x13644d9,0x00ff705 },
  30082. { 0x2260594,0x18d51f8,0x277e2cf,0x1cb5cec,0x2468a53,0x3e6f4d7,
  30083. 0x019e24e,0x0f30f1d,0x0202404,0x34ad287,0x090b39c,0x23c11ea,
  30084. 0x1a2e3a2,0x3a851be,0x00dca2c } },
  30085. /* 226 */
  30086. { { 0x3277538,0x221cd94,0x3738ab7,0x0973da5,0x1a734e2,0x2c8b8b0,
  30087. 0x2e1d1e6,0x348499b,0x389ebe1,0x18b1854,0x02bb076,0x1b2b500,
  30088. 0x0f207f3,0x170cf99,0x0012088 },
  30089. { 0x0fbfec2,0x1df55a4,0x34ae59e,0x2ab5e95,0x3f9e781,0x3411794,
  30090. 0x1410b05,0x17c3a00,0x0aaa91b,0x074ed7c,0x3fbb352,0x3477c01,
  30091. 0x3ee9ab3,0x0cfb1ca,0x0011c4b } },
  30092. /* 227 */
  30093. { { 0x3c3a7f3,0x2e60ca0,0x2354d32,0x33e2362,0x28083ab,0x03d3b16,
  30094. 0x3164045,0x0a41f7a,0x3f0641e,0x38635d1,0x31bbf03,0x225e2bb,
  30095. 0x0cd894e,0x1f72228,0x0093244 },
  30096. { 0x33d5897,0x383faf3,0x0e6d561,0x0bc4d80,0x3fc3a68,0x05a9adc,
  30097. 0x0b9d73d,0x3d6031e,0x2ded29b,0x339c4ff,0x08d69e5,0x089488c,
  30098. 0x3fda40a,0x295c7fd,0x003a924 } },
  30099. /* 228 */
  30100. { { 0x0093bee,0x115532d,0x2ec0fb6,0x0969631,0x3a6d65a,0x0f43b4d,
  30101. 0x26994d4,0x0b51104,0x2515515,0x3695a26,0x284caa8,0x397aa30,
  30102. 0x25538b8,0x353f47c,0x0033f05 },
  30103. { 0x3615d6e,0x37f8246,0x07dae0f,0x23dc154,0x02ded7e,0x1eef320,
  30104. 0x1631e51,0x3447f75,0x13e267f,0x353e1d1,0x3f89d62,0x369c8ff,
  30105. 0x1a21dc6,0x2b8b8f3,0x0055cbc } },
  30106. /* 229 */
  30107. { { 0x34e84f3,0x2f2539a,0x2c35336,0x0c53bdc,0x1728630,0x3ad5fe6,
  30108. 0x05fdeee,0x3386db6,0x272a42e,0x29fd38c,0x36f0320,0x21b2ed4,
  30109. 0x331e67f,0x28ae48c,0x00f09b6 },
  30110. { 0x2778435,0x0fb3c55,0x32d221d,0x2660c8e,0x32977ba,0x1c12f03,
  30111. 0x1b57fb1,0x01229a8,0x38b389f,0x375ddf3,0x2c6b42c,0x3885d3e,
  30112. 0x2c55a9c,0x2ffc279,0x00404e2 } },
  30113. /* 230 */
  30114. { { 0x04c5ddb,0x2c4d788,0x150e9b9,0x110fbfd,0x29dbfe0,0x30ef83d,
  30115. 0x2ab4bfe,0x395bcd7,0x30d0a43,0x0e2d30f,0x0e73f9b,0x07199cc,
  30116. 0x0c9054c,0x22f4b1e,0x0092ed3 },
  30117. { 0x386e27c,0x00fdaa8,0x0507c70,0x1beb3b6,0x0b9c4f4,0x277d519,
  30118. 0x024ec85,0x1cbaba8,0x1524295,0x112be58,0x21fc119,0x273578b,
  30119. 0x2358c27,0x280ca07,0x00aa376 } },
  30120. /* 231 */
  30121. { { 0x0dbc95c,0x16488cf,0x337a078,0x1abbcb8,0x0aae1aa,0x1caa151,
  30122. 0x00108d4,0x1edf701,0x3e68d03,0x1203214,0x0c7eee2,0x084c572,
  30123. 0x07752d2,0x215a3b9,0x00195d3 },
  30124. { 0x2cd7fbe,0x06e80f6,0x052bd4b,0x07b4f83,0x24b5ac6,0x2aaded4,
  30125. 0x13c0526,0x0ffa9a3,0x08c660e,0x13c35c9,0x3145efb,0x36cfe24,
  30126. 0x0936daf,0x268e3d0,0x00a73fd } },
  30127. /* 232 */
  30128. { { 0x31b17ce,0x2e7bcee,0x3f31891,0x19f1849,0x1140236,0x015487f,
  30129. 0x32e58d3,0x202204a,0x049e350,0x1ce91f9,0x3f75150,0x27f212f,
  30130. 0x0d16ee4,0x1c894c4,0x004023f },
  30131. { 0x33399fa,0x2397b6d,0x2a3ea60,0x36354ca,0x1f12632,0x117a105,
  30132. 0x22758e8,0x361844e,0x3851fc2,0x0ab92db,0x339d02f,0x1e7d6c4,
  30133. 0x19ebd38,0x0a9a036,0x00446d2 } },
  30134. /* 233 */
  30135. { { 0x3e164f1,0x008c092,0x19200f5,0x35a22e0,0x38d09d2,0x212b3bf,
  30136. 0x0056f19,0x3a03545,0x1f075e9,0x0e97137,0x1f496a9,0x32d1f9b,
  30137. 0x36bf738,0x35ace37,0x00899e1 },
  30138. { 0x19eb2a6,0x21fa22d,0x338b69e,0x18e6d1f,0x1280d9d,0x1953a55,
  30139. 0x1411ea3,0x2960566,0x0fd969a,0x1f3e375,0x130742a,0x170aebd,
  30140. 0x33085ff,0x14d868d,0x00a4391 } },
  30141. /* 234 */
  30142. { { 0x0a4bdd2,0x39ca8ea,0x37026ac,0x346da3b,0x0c656cd,0x03136b6,
  30143. 0x233e7e9,0x0714352,0x08a9d95,0x192bb38,0x085d68e,0x20016b8,
  30144. 0x102b8ea,0x1f5dbdd,0x00fdd7a },
  30145. { 0x0d6fa45,0x3ec29a6,0x2b8cce6,0x1c84413,0x0228f86,0x28275f7,
  30146. 0x3d8787d,0x0c19748,0x28b2ae9,0x1954850,0x2a56c36,0x3eae8f7,
  30147. 0x0aca595,0x00e42a2,0x00edbe5 } },
  30148. /* 235 */
  30149. { { 0x3b26c82,0x3682b6f,0x2f9cd64,0x0f254b0,0x0e5d70b,0x1f9dfda,
  30150. 0x28f365f,0x35a57d7,0x00208f2,0x19c8d38,0x112e7be,0x3e403bb,
  30151. 0x3734efa,0x24d12b3,0x0027dc6 },
  30152. { 0x260a46a,0x13fd7b0,0x1c2880e,0x338b70c,0x27da5eb,0x29a7d54,
  30153. 0x1c5d73c,0x2130921,0x32969cc,0x2b37eda,0x2d6d4ec,0x0716bfb,
  30154. 0x0763703,0x1320889,0x00c7bbf } },
  30155. /* 236 */
  30156. { { 0x1fe01b2,0x2dcb1d2,0x11b89d5,0x219e4ea,0x0347851,0x3d1810e,
  30157. 0x3a3c54c,0x06dbe8e,0x03d3ab2,0x2dcfa39,0x3e57b8a,0x337a382,
  30158. 0x0426450,0x0e9f748,0x006488b },
  30159. { 0x1dc4582,0x0e62cf7,0x06fea9e,0x2a56fb1,0x31698c1,0x15b4e10,
  30160. 0x1446ef1,0x0a689fc,0x1d87703,0x20ff497,0x2c71066,0x2c48868,
  30161. 0x2e6cf05,0x30aa9cb,0x0065b2d } },
  30162. /* 237 */
  30163. { { 0x1021d63,0x2217df3,0x1f0821a,0x057fa98,0x23f344b,0x173dcf9,
  30164. 0x1ba6ddc,0x22c8eb5,0x18f227a,0x0455343,0x1c55931,0x1d0dcf3,
  30165. 0x20fa19b,0x1c56618,0x004feab },
  30166. { 0x19ec924,0x224e39f,0x2550509,0x179b51f,0x284d54a,0x2d85d41,
  30167. 0x2d1bdc1,0x1a29068,0x3826158,0x1267f85,0x3005a92,0x0769e00,
  30168. 0x379b617,0x17b5f63,0x00a70bf } },
  30169. /* 238 */
  30170. { { 0x22216c5,0x049437f,0x33510bc,0x141d806,0x22c37e2,0x1bc1adf,
  30171. 0x300175d,0x2e6ded8,0x0a18bfe,0x35377a3,0x382f843,0x08410ca,
  30172. 0x00afd4f,0x0be6c6b,0x008d70e },
  30173. { 0x2e91abb,0x1cede2a,0x28f225c,0x28e18c0,0x30230dc,0x173cc2d,
  30174. 0x123ecfe,0x3c9962e,0x2c25506,0x27b5d53,0x329a5e3,0x106e231,
  30175. 0x3889b8e,0x3b0aeaf,0x00ee67c } },
  30176. /* 239 */
  30177. { { 0x3e46c65,0x0eb3d46,0x1d7ae18,0x23f9d59,0x2978953,0x2589ed3,
  30178. 0x073391d,0x2461e1e,0x0c19f1d,0x22fd2b1,0x0691f5c,0x2e67d8d,
  30179. 0x1fb985d,0x200dd28,0x00a68df },
  30180. { 0x392b5fa,0x123b46f,0x1c323c4,0x104f82f,0x0a098c8,0x26fc05b,
  30181. 0x34cd557,0x0913639,0x09c115e,0x3977c34,0x3410b66,0x062b404,
  30182. 0x0213094,0x132c5e8,0x008b612 } },
  30183. /* 240 */
  30184. { { 0x26e3392,0x3b0ebf0,0x2e00425,0x1c285c8,0x3c07f84,0x08d5ad0,
  30185. 0x028190e,0x1669b73,0x1ffb1ef,0x053b65f,0x063028c,0x0aceb47,
  30186. 0x18988c2,0x0f09a30,0x0007072 },
  30187. { 0x0f49e7d,0x28c0bd3,0x252270d,0x24cfc4a,0x0c5e87c,0x2165052,
  30188. 0x2cdd1d1,0x04931d2,0x3abca74,0x22b57dc,0x169fd47,0x0b928fb,
  30189. 0x17cc3e7,0x21a1ec4,0x0061593 } },
  30190. /* 241 */
  30191. { { 0x1aa0486,0x2e55dea,0x15577b7,0x0d6818f,0x36e41fb,0x2a411f5,
  30192. 0x17d5c7d,0x1eea6c0,0x28068a8,0x0e31d20,0x1f08ad9,0x117e973,
  30193. 0x08a28ab,0x085d30a,0x00cd9fb },
  30194. { 0x347843d,0x1119095,0x11e3595,0x1b29584,0x134d64c,0x2ff3a35,
  30195. 0x247ea14,0x099fc4b,0x2056169,0x145dd03,0x2ed03fb,0x1250e3b,
  30196. 0x3f5135c,0x2b753f0,0x009da30 } },
  30197. /* 242 */
  30198. { { 0x0fa5200,0x214a0b3,0x313dc4e,0x23da866,0x3270760,0x15c9b8b,
  30199. 0x39a53df,0x1f79772,0x3c9e942,0x2984901,0x154d582,0x1685f87,
  30200. 0x2e1183e,0x1f79956,0x00b9987 },
  30201. { 0x15254de,0x3a5cac0,0x37c56f0,0x2c7c29b,0x292a56d,0x195be2c,
  30202. 0x17e4e1a,0x0660f4a,0x052ad98,0x1267f80,0x07cfed8,0x194b4bc,
  30203. 0x01738d3,0x14ba10f,0x00c7843 } },
  30204. /* 243 */
  30205. { { 0x29b2d8a,0x242bc1f,0x19646ee,0x0615f3c,0x0ac8d70,0x07ca3bf,
  30206. 0x2d90317,0x2c83bdb,0x1a96812,0x39fdc35,0x31c61ee,0x2d55fd3,
  30207. 0x2375827,0x355f189,0x00f1c9b },
  30208. { 0x21a6194,0x1f4050a,0x2b845cf,0x02c6242,0x2dd614e,0x3a4f0a9,
  30209. 0x39de100,0x24714fb,0x175e0cd,0x0be633d,0x14befc3,0x13b0318,
  30210. 0x1d68c50,0x299989e,0x00d0513 } },
  30211. /* 244 */
  30212. { { 0x059fb6a,0x2b6eb6a,0x3666a8e,0x39f6ca0,0x1cf8346,0x388b8d5,
  30213. 0x35e61a3,0x271adec,0x22c9963,0x20a4fb3,0x16f241c,0x0058b89,
  30214. 0x21ddafa,0x1ee6fde,0x00d2e6c },
  30215. { 0x0075e63,0x39894d0,0x0286d0d,0x187e7b2,0x02405aa,0x3f91525,
  30216. 0x37830a8,0x2723088,0x2c7364e,0x013f406,0x104ba75,0x270f486,
  30217. 0x3520b4d,0x3852bc6,0x00d589b } },
  30218. /* 245 */
  30219. { { 0x262e53b,0x1da93d1,0x3676135,0x147e41d,0x335ec2f,0x1f02be5,
  30220. 0x297d139,0x22d6198,0x1fe9e59,0x13b4c80,0x1e70f60,0x2f1d4a9,
  30221. 0x2d95149,0x14d6ec4,0x00b54af },
  30222. { 0x12c1c76,0x2930ac8,0x0dfd36e,0x31fac94,0x218f5bb,0x2828691,
  30223. 0x1466cc9,0x3645e83,0x1a4dac2,0x1549593,0x0e95fab,0x19567d2,
  30224. 0x27a3320,0x0642729,0x007487c } },
  30225. /* 246 */
  30226. { { 0x1e98e9c,0x2ff8df7,0x119975a,0x098a904,0x099b90b,0x336c7df,
  30227. 0x010996d,0x159d46d,0x3118b3b,0x3aacd1b,0x31f8ae1,0x214864f,
  30228. 0x398c104,0x089dae2,0x001ec4d },
  30229. { 0x1452baa,0x2f24991,0x2572ba3,0x162b312,0x2387d18,0x147c5c7,
  30230. 0x38eff6e,0x0700251,0x37d931e,0x23cd5c1,0x254c8ca,0x3b9df37,
  30231. 0x1c9a4ff,0x0bfd547,0x00fb489 } },
  30232. /* 247 */
  30233. { { 0x1b8dff8,0x2f6b40b,0x05a25b1,0x3f5688a,0x1d462f4,0x2802d18,
  30234. 0x2aad8ed,0x1b46c75,0x3cf4130,0x250fefb,0x2a13fe1,0x23a1bcd,
  30235. 0x0940442,0x04605fe,0x00c8b2f },
  30236. { 0x0d51afb,0x14a2abc,0x1d06762,0x291526c,0x2a3e2fe,0x28f77d9,
  30237. 0x3ad8f2e,0x3481a1b,0x04b4fbd,0x2836733,0x0189ff5,0x3a5f533,
  30238. 0x319a6cd,0x0f58667,0x00c3679 } },
  30239. /* 248 */
  30240. { { 0x1b85197,0x22426d4,0x2895ea3,0x342d324,0x3ffb17d,0x376cfcf,
  30241. 0x30878b1,0x3c3c83a,0x0ffc57c,0x0ac174a,0x1abd57e,0x2f78b9c,
  30242. 0x01b20d8,0x0a37103,0x007f2be },
  30243. { 0x19a2d48,0x137288a,0x182d655,0x0ba0dde,0x25130ba,0x01c65c6,
  30244. 0x23205f1,0x2097621,0x2827cf2,0x2c57b98,0x03748f2,0x2db15fc,
  30245. 0x385a0d4,0x13690c0,0x00a9e3f } },
  30246. /* 249 */
  30247. { { 0x3fbc9c6,0x2df3b20,0x377e33e,0x31d1505,0x024a311,0x3c1d9ff,
  30248. 0x1377f74,0x00b6b20,0x2364ab7,0x184ab6b,0x2a77969,0x3f2db6c,
  30249. 0x2a6adb7,0x0a10073,0x004a6fb },
  30250. { 0x1fc73de,0x2c74ab3,0x3d325e8,0x2346c0b,0x1d0efae,0x2076146,
  30251. 0x19c190d,0x225c4fe,0x3fafc80,0x2cf063d,0x11b7ae7,0x3dc4f9d,
  30252. 0x3c3f841,0x10d7c1f,0x000a4b3 } },
  30253. /* 250 */
  30254. { { 0x19b7d2e,0x28f1300,0x0b897dd,0x06b5371,0x0631c8d,0x336cc4f,
  30255. 0x09cd6e1,0x2ec1952,0x1104c07,0x07512bb,0x35f000d,0x25f84e9,
  30256. 0x1df4d8f,0x193f769,0x000e9ee },
  30257. { 0x2346910,0x267cecf,0x0ad7eaa,0x087e8a5,0x1622f69,0x342cbfa,
  30258. 0x2aa20d0,0x206e88a,0x3991e58,0x093fb4b,0x0157180,0x3cecb5b,
  30259. 0x2e17c9a,0x1ea371f,0x00919e6 } },
  30260. /* 251 */
  30261. { { 0x2250533,0x13f931d,0x3ef8c72,0x395f605,0x18a2080,0x1cb25d4,
  30262. 0x2fb0f41,0x1c0ba8a,0x1eb17c0,0x266c433,0x09b7e3e,0x0e5d78f,
  30263. 0x0cdc5bf,0x1f7c734,0x0020611 },
  30264. { 0x205ebd5,0x127986f,0x02c0fb0,0x1705b1e,0x1eb0bb5,0x2dffb42,
  30265. 0x2331b8a,0x18fc04e,0x31d6328,0x17db162,0x0d3b619,0x193bdb9,
  30266. 0x3f11662,0x2d8e694,0x0092c51 } },
  30267. /* 252 */
  30268. { { 0x08b364d,0x31ef20a,0x25c4a57,0x021ed07,0x14a562e,0x262a684,
  30269. 0x1d21c66,0x126e5a6,0x181f3f8,0x2a93b65,0x1eb726b,0x08fbbce,
  30270. 0x084f9a2,0x308f30a,0x0013159 },
  30271. { 0x23f4963,0x0c7960e,0x2a81739,0x2242b69,0x3965003,0x2aca542,
  30272. 0x28a1c65,0x2ad48fb,0x149775f,0x1bbb7d2,0x0f2671b,0x3594b85,
  30273. 0x22f5563,0x2470f13,0x00fed44 } },
  30274. /* 253 */
  30275. { { 0x0eb453e,0x3ab70fd,0x1a5b335,0x18f2b74,0x25ff74b,0x3612a46,
  30276. 0x33d0d75,0x28cdda4,0x2b9b49b,0x22728fb,0x004c15b,0x1beb33b,
  30277. 0x1a7e41f,0x0c9b702,0x004ef19 },
  30278. { 0x1ca3233,0x0b4c90f,0x1d4b53d,0x2428896,0x20ee405,0x151bc00,
  30279. 0x022edb5,0x1adc463,0x00109ea,0x06490a6,0x30e91e6,0x3682b76,
  30280. 0x23c50aa,0x3bd2665,0x005fe53 } },
  30281. /* 254 */
  30282. { { 0x0c28c65,0x3741ae4,0x247d372,0x0b04673,0x2176524,0x2c8bf20,
  30283. 0x01fb806,0x3330701,0x307b0a7,0x3999fb7,0x1261bec,0x256679c,
  30284. 0x3f22ac7,0x26e8673,0x00bc69d },
  30285. { 0x3c06819,0x35df344,0x379d009,0x2bb8a0a,0x0635a66,0x096c6fa,
  30286. 0x1ac4a62,0x023e53b,0x0e45240,0x115f53d,0x3056af8,0x0a66b16,
  30287. 0x3c386ee,0x1130e82,0x00cc384 } },
  30288. /* 255 */
  30289. { { 0x14c2356,0x190ec73,0x07be490,0x145d415,0x0740a48,0x1251301,
  30290. 0x3eaf29d,0x2628190,0x079299a,0x26e95c9,0x2e05fdf,0x2ca7c5b,
  30291. 0x32d7b48,0x3d84226,0x0033fb4 },
  30292. { 0x150f955,0x01240aa,0x3ddf867,0x137fb70,0x297e103,0x17eeda8,
  30293. 0x1320b60,0x266ec84,0x13f4322,0x0c8f5ee,0x0590e4a,0x386815e,
  30294. 0x00ce61f,0x161bd63,0x008e1d0 } },
  30295. };
  30296. /* Multiply the base point of P384 by the scalar and return the result.
  30297. * If map is true then convert result to affine coordinates.
  30298. *
  30299. * Stripe implementation.
  30300. * Pre-generated: 2^0, 2^48, ...
  30301. * Pre-generated: products of all combinations of above.
  30302. * 8 doubles and adds (with qz=1)
  30303. *
  30304. * r Resulting point.
  30305. * k Scalar to multiply by.
  30306. * map Indicates whether to convert result to affine.
  30307. * ct Constant time required.
  30308. * heap Heap to use for allocation.
  30309. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  30310. */
  30311. static int sp_384_ecc_mulmod_base_15(sp_point_384* r, const sp_digit* k,
  30312. int map, int ct, void* heap)
  30313. {
  30314. return sp_384_ecc_mulmod_stripe_15(r, &p384_base, p384_table,
  30315. k, map, ct, heap);
  30316. }
  30317. #endif
  30318. /* Multiply the base point of P384 by the scalar and return the result.
  30319. * If map is true then convert result to affine coordinates.
  30320. *
  30321. * km Scalar to multiply by.
  30322. * r Resulting point.
  30323. * map Indicates whether to convert result to affine.
  30324. * heap Heap to use for allocation.
  30325. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  30326. */
  30327. int sp_ecc_mulmod_base_384(const mp_int* km, ecc_point* r, int map, void* heap)
  30328. {
  30329. #ifdef WOLFSSL_SP_SMALL_STACK
  30330. sp_point_384* point = NULL;
  30331. sp_digit* k = NULL;
  30332. #else
  30333. sp_point_384 point[1];
  30334. sp_digit k[15];
  30335. #endif
  30336. int err = MP_OKAY;
  30337. #ifdef WOLFSSL_SP_SMALL_STACK
  30338. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384), heap,
  30339. DYNAMIC_TYPE_ECC);
  30340. if (point == NULL)
  30341. err = MEMORY_E;
  30342. if (err == MP_OKAY) {
  30343. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15, heap,
  30344. DYNAMIC_TYPE_ECC);
  30345. if (k == NULL)
  30346. err = MEMORY_E;
  30347. }
  30348. #endif
  30349. if (err == MP_OKAY) {
  30350. sp_384_from_mp(k, 15, km);
  30351. err = sp_384_ecc_mulmod_base_15(point, k, map, 1, heap);
  30352. }
  30353. if (err == MP_OKAY) {
  30354. err = sp_384_point_to_ecc_point_15(point, r);
  30355. }
  30356. #ifdef WOLFSSL_SP_SMALL_STACK
  30357. if (k != NULL)
  30358. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  30359. if (point != NULL)
  30360. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  30361. #endif
  30362. return err;
  30363. }
  30364. /* Multiply the base point of P384 by the scalar, add point a and return
  30365. * the result. If map is true then convert result to affine coordinates.
  30366. *
  30367. * km Scalar to multiply by.
  30368. * am Point to add to scalar multiply result.
  30369. * inMont Point to add is in montgomery form.
  30370. * r Resulting point.
  30371. * map Indicates whether to convert result to affine.
  30372. * heap Heap to use for allocation.
  30373. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  30374. */
  30375. int sp_ecc_mulmod_base_add_384(const mp_int* km, const ecc_point* am,
  30376. int inMont, ecc_point* r, int map, void* heap)
  30377. {
  30378. #ifdef WOLFSSL_SP_SMALL_STACK
  30379. sp_point_384* point = NULL;
  30380. sp_digit* k = NULL;
  30381. #else
  30382. sp_point_384 point[2];
  30383. sp_digit k[15 + 15 * 2 * 6];
  30384. #endif
  30385. sp_point_384* addP = NULL;
  30386. sp_digit* tmp = NULL;
  30387. int err = MP_OKAY;
  30388. #ifdef WOLFSSL_SP_SMALL_STACK
  30389. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap,
  30390. DYNAMIC_TYPE_ECC);
  30391. if (point == NULL)
  30392. err = MEMORY_E;
  30393. if (err == MP_OKAY) {
  30394. k = (sp_digit*)XMALLOC(
  30395. sizeof(sp_digit) * (15 + 15 * 2 * 6),
  30396. heap, DYNAMIC_TYPE_ECC);
  30397. if (k == NULL)
  30398. err = MEMORY_E;
  30399. }
  30400. #endif
  30401. if (err == MP_OKAY) {
  30402. addP = point + 1;
  30403. tmp = k + 15;
  30404. sp_384_from_mp(k, 15, km);
  30405. sp_384_point_from_ecc_point_15(addP, am);
  30406. }
  30407. if ((err == MP_OKAY) && (!inMont)) {
  30408. err = sp_384_mod_mul_norm_15(addP->x, addP->x, p384_mod);
  30409. }
  30410. if ((err == MP_OKAY) && (!inMont)) {
  30411. err = sp_384_mod_mul_norm_15(addP->y, addP->y, p384_mod);
  30412. }
  30413. if ((err == MP_OKAY) && (!inMont)) {
  30414. err = sp_384_mod_mul_norm_15(addP->z, addP->z, p384_mod);
  30415. }
  30416. if (err == MP_OKAY) {
  30417. err = sp_384_ecc_mulmod_base_15(point, k, 0, 0, heap);
  30418. }
  30419. if (err == MP_OKAY) {
  30420. sp_384_proj_point_add_15(point, point, addP, tmp);
  30421. if (map) {
  30422. sp_384_map_15(point, point, tmp);
  30423. }
  30424. err = sp_384_point_to_ecc_point_15(point, r);
  30425. }
  30426. #ifdef WOLFSSL_SP_SMALL_STACK
  30427. if (k != NULL)
  30428. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  30429. if (point)
  30430. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  30431. #endif
  30432. return err;
  30433. }
  30434. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  30435. defined(HAVE_ECC_VERIFY)
  30436. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN | HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  30437. /* Add 1 to a. (a = a + 1)
  30438. *
  30439. * r A single precision integer.
  30440. * a A single precision integer.
  30441. */
  30442. SP_NOINLINE static void sp_384_add_one_15(sp_digit* a)
  30443. {
  30444. a[0]++;
  30445. sp_384_norm_15(a);
  30446. }
  30447. /* Read big endian unsigned byte array into r.
  30448. *
  30449. * r A single precision integer.
  30450. * size Maximum number of bytes to convert
  30451. * a Byte array.
  30452. * n Number of bytes in array to read.
  30453. */
  30454. static void sp_384_from_bin(sp_digit* r, int size, const byte* a, int n)
  30455. {
  30456. int i;
  30457. int j = 0;
  30458. word32 s = 0;
  30459. r[0] = 0;
  30460. for (i = n-1; i >= 0; i--) {
  30461. r[j] |= (((sp_digit)a[i]) << s);
  30462. if (s >= 18U) {
  30463. r[j] &= 0x3ffffff;
  30464. s = 26U - s;
  30465. if (j + 1 >= size) {
  30466. break;
  30467. }
  30468. r[++j] = (sp_digit)a[i] >> s;
  30469. s = 8U - s;
  30470. }
  30471. else {
  30472. s += 8U;
  30473. }
  30474. }
  30475. for (j++; j < size; j++) {
  30476. r[j] = 0;
  30477. }
  30478. }
  30479. /* Generates a scalar that is in the range 1..order-1.
  30480. *
  30481. * rng Random number generator.
  30482. * k Scalar value.
  30483. * returns RNG failures, MEMORY_E when memory allocation fails and
  30484. * MP_OKAY on success.
  30485. */
  30486. static int sp_384_ecc_gen_k_15(WC_RNG* rng, sp_digit* k)
  30487. {
  30488. int err;
  30489. byte buf[48];
  30490. do {
  30491. err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
  30492. if (err == 0) {
  30493. sp_384_from_bin(k, 15, buf, (int)sizeof(buf));
  30494. if (sp_384_cmp_15(k, p384_order2) <= 0) {
  30495. sp_384_add_one_15(k);
  30496. break;
  30497. }
  30498. }
  30499. }
  30500. while (err == 0);
  30501. return err;
  30502. }
  30503. /* Makes a random EC key pair.
  30504. *
  30505. * rng Random number generator.
  30506. * priv Generated private value.
  30507. * pub Generated public point.
  30508. * heap Heap to use for allocation.
  30509. * returns ECC_INF_E when the point does not have the correct order, RNG
  30510. * failures, MEMORY_E when memory allocation fails and MP_OKAY on success.
  30511. */
  30512. int sp_ecc_make_key_384(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
  30513. {
  30514. #ifdef WOLFSSL_SP_SMALL_STACK
  30515. sp_point_384* point = NULL;
  30516. sp_digit* k = NULL;
  30517. #else
  30518. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30519. sp_point_384 point[2];
  30520. #else
  30521. sp_point_384 point[1];
  30522. #endif
  30523. sp_digit k[15];
  30524. #endif
  30525. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30526. sp_point_384* infinity = NULL;
  30527. #endif
  30528. int err = MP_OKAY;
  30529. (void)heap;
  30530. #ifdef WOLFSSL_SP_SMALL_STACK
  30531. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30532. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap, DYNAMIC_TYPE_ECC);
  30533. #else
  30534. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384), heap, DYNAMIC_TYPE_ECC);
  30535. #endif
  30536. if (point == NULL)
  30537. err = MEMORY_E;
  30538. if (err == MP_OKAY) {
  30539. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15, heap,
  30540. DYNAMIC_TYPE_ECC);
  30541. if (k == NULL)
  30542. err = MEMORY_E;
  30543. }
  30544. #endif
  30545. if (err == MP_OKAY) {
  30546. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30547. infinity = point + 1;
  30548. #endif
  30549. err = sp_384_ecc_gen_k_15(rng, k);
  30550. }
  30551. if (err == MP_OKAY) {
  30552. err = sp_384_ecc_mulmod_base_15(point, k, 1, 1, NULL);
  30553. }
  30554. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30555. if (err == MP_OKAY) {
  30556. err = sp_384_ecc_mulmod_15(infinity, point, p384_order, 1, 1, NULL);
  30557. }
  30558. if (err == MP_OKAY) {
  30559. if (sp_384_iszero_15(point->x) || sp_384_iszero_15(point->y)) {
  30560. err = ECC_INF_E;
  30561. }
  30562. }
  30563. #endif
  30564. if (err == MP_OKAY) {
  30565. err = sp_384_to_mp(k, priv);
  30566. }
  30567. if (err == MP_OKAY) {
  30568. err = sp_384_point_to_ecc_point_15(point, pub);
  30569. }
  30570. #ifdef WOLFSSL_SP_SMALL_STACK
  30571. if (k != NULL)
  30572. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  30573. if (point != NULL) {
  30574. /* point is not sensitive, so no need to zeroize */
  30575. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  30576. }
  30577. #endif
  30578. return err;
  30579. }
  30580. #ifdef WOLFSSL_SP_NONBLOCK
  30581. typedef struct sp_ecc_key_gen_384_ctx {
  30582. int state;
  30583. sp_384_ecc_mulmod_15_ctx mulmod_ctx;
  30584. sp_digit k[15];
  30585. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30586. sp_point_384 point[2];
  30587. #else
  30588. sp_point_384 point[1];
  30589. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  30590. } sp_ecc_key_gen_384_ctx;
  30591. int sp_ecc_make_key_384_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng, mp_int* priv,
  30592. ecc_point* pub, void* heap)
  30593. {
  30594. int err = FP_WOULDBLOCK;
  30595. sp_ecc_key_gen_384_ctx* ctx = (sp_ecc_key_gen_384_ctx*)sp_ctx->data;
  30596. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30597. sp_point_384* infinity = ctx->point + 1;
  30598. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  30599. typedef char ctx_size_test[sizeof(sp_ecc_key_gen_384_ctx)
  30600. >= sizeof(*sp_ctx) ? -1 : 1];
  30601. (void)sizeof(ctx_size_test);
  30602. switch (ctx->state) {
  30603. case 0:
  30604. err = sp_384_ecc_gen_k_15(rng, ctx->k);
  30605. if (err == MP_OKAY) {
  30606. err = FP_WOULDBLOCK;
  30607. ctx->state = 1;
  30608. }
  30609. break;
  30610. case 1:
  30611. err = sp_384_ecc_mulmod_base_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  30612. ctx->point, ctx->k, 1, 1, heap);
  30613. if (err == MP_OKAY) {
  30614. err = FP_WOULDBLOCK;
  30615. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30616. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  30617. ctx->state = 2;
  30618. #else
  30619. ctx->state = 3;
  30620. #endif
  30621. }
  30622. break;
  30623. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  30624. case 2:
  30625. err = sp_384_ecc_mulmod_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  30626. infinity, ctx->point, p384_order, 1, 1);
  30627. if (err == MP_OKAY) {
  30628. if (sp_384_iszero_15(ctx->point->x) ||
  30629. sp_384_iszero_15(ctx->point->y)) {
  30630. err = ECC_INF_E;
  30631. }
  30632. else {
  30633. err = FP_WOULDBLOCK;
  30634. ctx->state = 3;
  30635. }
  30636. }
  30637. break;
  30638. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  30639. case 3:
  30640. err = sp_384_to_mp(ctx->k, priv);
  30641. if (err == MP_OKAY) {
  30642. err = sp_384_point_to_ecc_point_15(ctx->point, pub);
  30643. }
  30644. break;
  30645. }
  30646. if (err != FP_WOULDBLOCK) {
  30647. XMEMSET(ctx, 0, sizeof(sp_ecc_key_gen_384_ctx));
  30648. }
  30649. return err;
  30650. }
  30651. #endif /* WOLFSSL_SP_NONBLOCK */
  30652. #ifdef HAVE_ECC_DHE
  30653. /* Write r as big endian to byte array.
  30654. * Fixed length number of bytes written: 48
  30655. *
  30656. * r A single precision integer.
  30657. * a Byte array.
  30658. */
  30659. static void sp_384_to_bin_15(sp_digit* r, byte* a)
  30660. {
  30661. int i;
  30662. int j;
  30663. int s = 0;
  30664. int b;
  30665. for (i=0; i<14; i++) {
  30666. r[i+1] += r[i] >> 26;
  30667. r[i] &= 0x3ffffff;
  30668. }
  30669. j = 391 / 8 - 1;
  30670. a[j] = 0;
  30671. for (i=0; i<15 && j>=0; i++) {
  30672. b = 0;
  30673. /* lint allow cast of mismatch sp_digit and int */
  30674. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  30675. b += 8 - s;
  30676. if (j < 0) {
  30677. break;
  30678. }
  30679. while (b < 26) {
  30680. a[j--] = (byte)(r[i] >> b);
  30681. b += 8;
  30682. if (j < 0) {
  30683. break;
  30684. }
  30685. }
  30686. s = 8 - (b - 26);
  30687. if (j >= 0) {
  30688. a[j] = 0;
  30689. }
  30690. if (s != 0) {
  30691. j++;
  30692. }
  30693. }
  30694. }
  30695. /* Multiply the point by the scalar and serialize the X ordinate.
  30696. * The number is 0 padded to maximum size on output.
  30697. *
  30698. * priv Scalar to multiply the point by.
  30699. * pub Point to multiply.
  30700. * out Buffer to hold X ordinate.
  30701. * outLen On entry, size of the buffer in bytes.
  30702. * On exit, length of data in buffer in bytes.
  30703. * heap Heap to use for allocation.
  30704. * returns BUFFER_E if the buffer is to small for output size,
  30705. * MEMORY_E when memory allocation fails and MP_OKAY on success.
  30706. */
  30707. int sp_ecc_secret_gen_384(const mp_int* priv, const ecc_point* pub, byte* out,
  30708. word32* outLen, void* heap)
  30709. {
  30710. #ifdef WOLFSSL_SP_SMALL_STACK
  30711. sp_point_384* point = NULL;
  30712. sp_digit* k = NULL;
  30713. #else
  30714. sp_point_384 point[1];
  30715. sp_digit k[15];
  30716. #endif
  30717. int err = MP_OKAY;
  30718. if (*outLen < 48U) {
  30719. err = BUFFER_E;
  30720. }
  30721. #ifdef WOLFSSL_SP_SMALL_STACK
  30722. if (err == MP_OKAY) {
  30723. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384), heap,
  30724. DYNAMIC_TYPE_ECC);
  30725. if (point == NULL)
  30726. err = MEMORY_E;
  30727. }
  30728. if (err == MP_OKAY) {
  30729. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15, heap,
  30730. DYNAMIC_TYPE_ECC);
  30731. if (k == NULL)
  30732. err = MEMORY_E;
  30733. }
  30734. #endif
  30735. if (err == MP_OKAY) {
  30736. sp_384_from_mp(k, 15, priv);
  30737. sp_384_point_from_ecc_point_15(point, pub);
  30738. err = sp_384_ecc_mulmod_15(point, point, k, 1, 1, heap);
  30739. }
  30740. if (err == MP_OKAY) {
  30741. sp_384_to_bin_15(point->x, out);
  30742. *outLen = 48;
  30743. }
  30744. #ifdef WOLFSSL_SP_SMALL_STACK
  30745. if (k != NULL)
  30746. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  30747. if (point != NULL)
  30748. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  30749. #endif
  30750. return err;
  30751. }
  30752. #ifdef WOLFSSL_SP_NONBLOCK
  30753. typedef struct sp_ecc_sec_gen_384_ctx {
  30754. int state;
  30755. union {
  30756. sp_384_ecc_mulmod_15_ctx mulmod_ctx;
  30757. };
  30758. sp_digit k[15];
  30759. sp_point_384 point;
  30760. } sp_ecc_sec_gen_384_ctx;
  30761. int sp_ecc_secret_gen_384_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv,
  30762. const ecc_point* pub, byte* out, word32* outLen, void* heap)
  30763. {
  30764. int err = FP_WOULDBLOCK;
  30765. sp_ecc_sec_gen_384_ctx* ctx = (sp_ecc_sec_gen_384_ctx*)sp_ctx->data;
  30766. typedef char ctx_size_test[sizeof(sp_ecc_sec_gen_384_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  30767. (void)sizeof(ctx_size_test);
  30768. if (*outLen < 32U) {
  30769. err = BUFFER_E;
  30770. }
  30771. switch (ctx->state) {
  30772. case 0:
  30773. sp_384_from_mp(ctx->k, 15, priv);
  30774. sp_384_point_from_ecc_point_15(&ctx->point, pub);
  30775. ctx->state = 1;
  30776. break;
  30777. case 1:
  30778. err = sp_384_ecc_mulmod_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  30779. &ctx->point, &ctx->point, ctx->k, 1, 1, heap);
  30780. if (err == MP_OKAY) {
  30781. sp_384_to_bin_15(ctx->point.x, out);
  30782. *outLen = 48;
  30783. }
  30784. break;
  30785. }
  30786. if (err == MP_OKAY && ctx->state != 1) {
  30787. err = FP_WOULDBLOCK;
  30788. }
  30789. if (err != FP_WOULDBLOCK) {
  30790. XMEMSET(ctx, 0, sizeof(sp_ecc_sec_gen_384_ctx));
  30791. }
  30792. return err;
  30793. }
  30794. #endif /* WOLFSSL_SP_NONBLOCK */
  30795. #endif /* HAVE_ECC_DHE */
  30796. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  30797. #endif
  30798. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  30799. SP_NOINLINE static void sp_384_rshift_15(sp_digit* r, const sp_digit* a,
  30800. byte n)
  30801. {
  30802. int i;
  30803. #ifdef WOLFSSL_SP_SMALL
  30804. for (i=0; i<14; i++) {
  30805. r[i] = ((a[i] >> n) | (a[i + 1] << (26 - n))) & 0x3ffffff;
  30806. }
  30807. #else
  30808. for (i=0; i<8; i += 8) {
  30809. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (26 - n)) & 0x3ffffff);
  30810. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (26 - n)) & 0x3ffffff);
  30811. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (26 - n)) & 0x3ffffff);
  30812. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (26 - n)) & 0x3ffffff);
  30813. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (26 - n)) & 0x3ffffff);
  30814. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (26 - n)) & 0x3ffffff);
  30815. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (26 - n)) & 0x3ffffff);
  30816. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (26 - n)) & 0x3ffffff);
  30817. }
  30818. r[8] = (a[8] >> n) | ((a[9] << (26 - n)) & 0x3ffffff);
  30819. r[9] = (a[9] >> n) | ((a[10] << (26 - n)) & 0x3ffffff);
  30820. r[10] = (a[10] >> n) | ((a[11] << (26 - n)) & 0x3ffffff);
  30821. r[11] = (a[11] >> n) | ((a[12] << (26 - n)) & 0x3ffffff);
  30822. r[12] = (a[12] >> n) | ((a[13] << (26 - n)) & 0x3ffffff);
  30823. r[13] = (a[13] >> n) | ((a[14] << (26 - n)) & 0x3ffffff);
  30824. #endif /* WOLFSSL_SP_SMALL */
  30825. r[14] = a[14] >> n;
  30826. }
  30827. /* Multiply a by scalar b into r. (r = a * b)
  30828. *
  30829. * r A single precision integer.
  30830. * a A single precision integer.
  30831. * b A scalar.
  30832. */
  30833. SP_NOINLINE static void sp_384_mul_d_15(sp_digit* r, const sp_digit* a,
  30834. sp_digit b)
  30835. {
  30836. #ifdef WOLFSSL_SP_SMALL
  30837. sp_int64 tb = b;
  30838. sp_int64 t = 0;
  30839. int i;
  30840. for (i = 0; i < 15; i++) {
  30841. t += tb * a[i];
  30842. r[i] = (sp_digit)(t & 0x3ffffff);
  30843. t >>= 26;
  30844. }
  30845. r[15] = (sp_digit)t;
  30846. #else
  30847. sp_int64 tb = b;
  30848. sp_int64 t[15];
  30849. t[ 0] = tb * a[ 0];
  30850. t[ 1] = tb * a[ 1];
  30851. t[ 2] = tb * a[ 2];
  30852. t[ 3] = tb * a[ 3];
  30853. t[ 4] = tb * a[ 4];
  30854. t[ 5] = tb * a[ 5];
  30855. t[ 6] = tb * a[ 6];
  30856. t[ 7] = tb * a[ 7];
  30857. t[ 8] = tb * a[ 8];
  30858. t[ 9] = tb * a[ 9];
  30859. t[10] = tb * a[10];
  30860. t[11] = tb * a[11];
  30861. t[12] = tb * a[12];
  30862. t[13] = tb * a[13];
  30863. t[14] = tb * a[14];
  30864. r[ 0] = (sp_digit) (t[ 0] & 0x3ffffff);
  30865. r[ 1] = (sp_digit)((t[ 0] >> 26) + (t[ 1] & 0x3ffffff));
  30866. r[ 2] = (sp_digit)((t[ 1] >> 26) + (t[ 2] & 0x3ffffff));
  30867. r[ 3] = (sp_digit)((t[ 2] >> 26) + (t[ 3] & 0x3ffffff));
  30868. r[ 4] = (sp_digit)((t[ 3] >> 26) + (t[ 4] & 0x3ffffff));
  30869. r[ 5] = (sp_digit)((t[ 4] >> 26) + (t[ 5] & 0x3ffffff));
  30870. r[ 6] = (sp_digit)((t[ 5] >> 26) + (t[ 6] & 0x3ffffff));
  30871. r[ 7] = (sp_digit)((t[ 6] >> 26) + (t[ 7] & 0x3ffffff));
  30872. r[ 8] = (sp_digit)((t[ 7] >> 26) + (t[ 8] & 0x3ffffff));
  30873. r[ 9] = (sp_digit)((t[ 8] >> 26) + (t[ 9] & 0x3ffffff));
  30874. r[10] = (sp_digit)((t[ 9] >> 26) + (t[10] & 0x3ffffff));
  30875. r[11] = (sp_digit)((t[10] >> 26) + (t[11] & 0x3ffffff));
  30876. r[12] = (sp_digit)((t[11] >> 26) + (t[12] & 0x3ffffff));
  30877. r[13] = (sp_digit)((t[12] >> 26) + (t[13] & 0x3ffffff));
  30878. r[14] = (sp_digit)((t[13] >> 26) + (t[14] & 0x3ffffff));
  30879. r[15] = (sp_digit) (t[14] >> 26);
  30880. #endif /* WOLFSSL_SP_SMALL */
  30881. }
  30882. SP_NOINLINE static void sp_384_lshift_30(sp_digit* r, const sp_digit* a,
  30883. byte n)
  30884. {
  30885. #ifdef WOLFSSL_SP_SMALL
  30886. int i;
  30887. r[30] = a[29] >> (26 - n);
  30888. for (i=29; i>0; i--) {
  30889. r[i] = ((a[i] << n) | (a[i-1] >> (26 - n))) & 0x3ffffff;
  30890. }
  30891. #else
  30892. sp_int_digit s;
  30893. sp_int_digit t;
  30894. s = (sp_int_digit)a[29];
  30895. r[30] = s >> (26U - n);
  30896. s = (sp_int_digit)(a[29]); t = (sp_int_digit)(a[28]);
  30897. r[29] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30898. s = (sp_int_digit)(a[28]); t = (sp_int_digit)(a[27]);
  30899. r[28] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30900. s = (sp_int_digit)(a[27]); t = (sp_int_digit)(a[26]);
  30901. r[27] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30902. s = (sp_int_digit)(a[26]); t = (sp_int_digit)(a[25]);
  30903. r[26] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30904. s = (sp_int_digit)(a[25]); t = (sp_int_digit)(a[24]);
  30905. r[25] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30906. s = (sp_int_digit)(a[24]); t = (sp_int_digit)(a[23]);
  30907. r[24] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30908. s = (sp_int_digit)(a[23]); t = (sp_int_digit)(a[22]);
  30909. r[23] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30910. s = (sp_int_digit)(a[22]); t = (sp_int_digit)(a[21]);
  30911. r[22] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30912. s = (sp_int_digit)(a[21]); t = (sp_int_digit)(a[20]);
  30913. r[21] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30914. s = (sp_int_digit)(a[20]); t = (sp_int_digit)(a[19]);
  30915. r[20] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30916. s = (sp_int_digit)(a[19]); t = (sp_int_digit)(a[18]);
  30917. r[19] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30918. s = (sp_int_digit)(a[18]); t = (sp_int_digit)(a[17]);
  30919. r[18] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30920. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  30921. r[17] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30922. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  30923. r[16] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30924. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  30925. r[15] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30926. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  30927. r[14] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30928. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  30929. r[13] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30930. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  30931. r[12] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30932. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  30933. r[11] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30934. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  30935. r[10] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30936. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  30937. r[9] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30938. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  30939. r[8] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30940. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  30941. r[7] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30942. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  30943. r[6] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30944. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  30945. r[5] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30946. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  30947. r[4] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30948. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  30949. r[3] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30950. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  30951. r[2] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30952. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  30953. r[1] = ((s << n) | (t >> (26U - n))) & 0x3ffffff;
  30954. #endif /* WOLFSSL_SP_SMALL */
  30955. r[0] = (a[0] << n) & 0x3ffffff;
  30956. }
  30957. /* Divide d in a and put remainder into r (m*d + r = a)
  30958. * m is not calculated as it is not needed at this time.
  30959. *
  30960. * Simplified based on top word of divisor being (1 << 26) - 1
  30961. *
  30962. * a Number to be divided.
  30963. * d Number to divide with.
  30964. * m Multiplier result.
  30965. * r Remainder from the division.
  30966. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  30967. */
  30968. static int sp_384_div_15(const sp_digit* a, const sp_digit* d,
  30969. const sp_digit* m, sp_digit* r)
  30970. {
  30971. int i;
  30972. sp_digit r1;
  30973. sp_digit mask;
  30974. #ifdef WOLFSSL_SP_SMALL_STACK
  30975. sp_digit* t1 = NULL;
  30976. #else
  30977. sp_digit t1[4 * 15 + 3];
  30978. #endif
  30979. sp_digit* t2 = NULL;
  30980. sp_digit* sd = NULL;
  30981. int err = MP_OKAY;
  30982. (void)m;
  30983. #ifdef WOLFSSL_SP_SMALL_STACK
  30984. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 15 + 3), NULL,
  30985. DYNAMIC_TYPE_TMP_BUFFER);
  30986. if (t1 == NULL)
  30987. err = MEMORY_E;
  30988. #endif
  30989. (void)m;
  30990. if (err == MP_OKAY) {
  30991. t2 = t1 + 30 + 1;
  30992. sd = t2 + 15 + 1;
  30993. sp_384_mul_d_15(sd, d, (sp_digit)1 << 6);
  30994. sp_384_lshift_30(t1, a, 6);
  30995. t1[15 + 15] += t1[15 + 15 - 1] >> 26;
  30996. t1[15 + 15 - 1] &= 0x3ffffff;
  30997. for (i=14; i>=0; i--) {
  30998. r1 = t1[15 + i];
  30999. sp_384_mul_d_15(t2, sd, r1);
  31000. (void)sp_384_sub_15(&t1[i], &t1[i], t2);
  31001. t1[15 + i] -= t2[15];
  31002. sp_384_norm_15(&t1[i + 1]);
  31003. mask = ~((t1[15 + i] - 1) >> 31);
  31004. sp_384_cond_sub_15(t1 + i, t1 + i, sd, mask);
  31005. sp_384_norm_15(&t1[i + 1]);
  31006. }
  31007. sp_384_norm_15(t1);
  31008. sp_384_rshift_15(r, t1, 6);
  31009. }
  31010. #ifdef WOLFSSL_SP_SMALL_STACK
  31011. if (t1 != NULL)
  31012. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  31013. #endif
  31014. return err;
  31015. }
  31016. /* Reduce a modulo m into r. (r = a mod m)
  31017. *
  31018. * r A single precision number that is the reduced result.
  31019. * a A single precision number that is to be reduced.
  31020. * m A single precision number that is the modulus to reduce with.
  31021. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  31022. */
  31023. static int sp_384_mod_15(sp_digit* r, const sp_digit* a, const sp_digit* m)
  31024. {
  31025. return sp_384_div_15(a, m, NULL, r);
  31026. }
  31027. #endif
  31028. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  31029. /* Multiply two number mod the order of P384 curve. (r = a * b mod order)
  31030. *
  31031. * r Result of the multiplication.
  31032. * a First operand of the multiplication.
  31033. * b Second operand of the multiplication.
  31034. */
  31035. static void sp_384_mont_mul_order_15(sp_digit* r, const sp_digit* a, const sp_digit* b)
  31036. {
  31037. sp_384_mul_15(r, a, b);
  31038. sp_384_mont_reduce_order_15(r, p384_order, p384_mp_order);
  31039. }
  31040. #if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL))
  31041. #ifdef WOLFSSL_SP_SMALL
  31042. /* Order-2 for the P384 curve. */
  31043. static const uint32_t p384_order_minus_2[12] = {
  31044. 0xccc52971U,0xecec196aU,0x48b0a77aU,0x581a0db2U,0xf4372ddfU,0xc7634d81U,
  31045. 0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU
  31046. };
  31047. #else
  31048. /* The low half of the order-2 of the P384 curve. */
  31049. static const uint32_t p384_order_low[6] = {
  31050. 0xccc52971U,0xecec196aU,0x48b0a77aU,0x581a0db2U,0xf4372ddfU,0xc7634d81U
  31051. };
  31052. #endif /* WOLFSSL_SP_SMALL */
  31053. /* Square number mod the order of P384 curve. (r = a * a mod order)
  31054. *
  31055. * r Result of the squaring.
  31056. * a Number to square.
  31057. */
  31058. static void sp_384_mont_sqr_order_15(sp_digit* r, const sp_digit* a)
  31059. {
  31060. sp_384_sqr_15(r, a);
  31061. sp_384_mont_reduce_order_15(r, p384_order, p384_mp_order);
  31062. }
  31063. #ifndef WOLFSSL_SP_SMALL
  31064. /* Square number mod the order of P384 curve a number of times.
  31065. * (r = a ^ n mod order)
  31066. *
  31067. * r Result of the squaring.
  31068. * a Number to square.
  31069. */
  31070. static void sp_384_mont_sqr_n_order_15(sp_digit* r, const sp_digit* a, int n)
  31071. {
  31072. int i;
  31073. sp_384_mont_sqr_order_15(r, a);
  31074. for (i=1; i<n; i++) {
  31075. sp_384_mont_sqr_order_15(r, r);
  31076. }
  31077. }
  31078. #endif /* !WOLFSSL_SP_SMALL */
  31079. /* Invert the number, in Montgomery form, modulo the order of the P384 curve.
  31080. * (r = 1 / a mod order)
  31081. *
  31082. * r Inverse result.
  31083. * a Number to invert.
  31084. * td Temporary data.
  31085. */
  31086. #ifdef WOLFSSL_SP_NONBLOCK
  31087. typedef struct sp_384_mont_inv_order_15_ctx {
  31088. int state;
  31089. int i;
  31090. } sp_384_mont_inv_order_15_ctx;
  31091. static int sp_384_mont_inv_order_15_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_digit* a,
  31092. sp_digit* t)
  31093. {
  31094. int err = FP_WOULDBLOCK;
  31095. sp_384_mont_inv_order_15_ctx* ctx = (sp_384_mont_inv_order_15_ctx*)sp_ctx;
  31096. typedef char ctx_size_test[sizeof(sp_384_mont_inv_order_15_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  31097. (void)sizeof(ctx_size_test);
  31098. switch (ctx->state) {
  31099. case 0:
  31100. XMEMCPY(t, a, sizeof(sp_digit) * 15);
  31101. ctx->i = 382;
  31102. ctx->state = 1;
  31103. break;
  31104. case 1:
  31105. sp_384_mont_sqr_order_15(t, t);
  31106. ctx->state = 2;
  31107. break;
  31108. case 2:
  31109. if ((p384_order_minus_2[ctx->i / 32] & ((sp_int_digit)1 << (ctx->i % 32))) != 0) {
  31110. sp_384_mont_mul_order_15(t, t, a);
  31111. }
  31112. ctx->i--;
  31113. ctx->state = (ctx->i == 0) ? 3 : 1;
  31114. break;
  31115. case 3:
  31116. XMEMCPY(r, t, sizeof(sp_digit) * 15U);
  31117. err = MP_OKAY;
  31118. break;
  31119. }
  31120. return err;
  31121. }
  31122. #endif /* WOLFSSL_SP_NONBLOCK */
  31123. static void sp_384_mont_inv_order_15(sp_digit* r, const sp_digit* a,
  31124. sp_digit* td)
  31125. {
  31126. #ifdef WOLFSSL_SP_SMALL
  31127. sp_digit* t = td;
  31128. int i;
  31129. XMEMCPY(t, a, sizeof(sp_digit) * 15);
  31130. for (i=382; i>=0; i--) {
  31131. sp_384_mont_sqr_order_15(t, t);
  31132. if ((p384_order_minus_2[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  31133. sp_384_mont_mul_order_15(t, t, a);
  31134. }
  31135. }
  31136. XMEMCPY(r, t, sizeof(sp_digit) * 15U);
  31137. #else
  31138. sp_digit* t = td;
  31139. sp_digit* t2 = td + 2 * 15;
  31140. sp_digit* t3 = td + 4 * 15;
  31141. int i;
  31142. /* t = a^2 */
  31143. sp_384_mont_sqr_order_15(t, a);
  31144. /* t = a^3 = t * a */
  31145. sp_384_mont_mul_order_15(t, t, a);
  31146. /* t2= a^c = t ^ 2 ^ 2 */
  31147. sp_384_mont_sqr_n_order_15(t2, t, 2);
  31148. /* t = a^f = t2 * t */
  31149. sp_384_mont_mul_order_15(t, t2, t);
  31150. /* t2= a^f0 = t ^ 2 ^ 4 */
  31151. sp_384_mont_sqr_n_order_15(t2, t, 4);
  31152. /* t = a^ff = t2 * t */
  31153. sp_384_mont_mul_order_15(t, t2, t);
  31154. /* t2= a^ff00 = t ^ 2 ^ 8 */
  31155. sp_384_mont_sqr_n_order_15(t2, t, 8);
  31156. /* t3= a^ffff = t2 * t */
  31157. sp_384_mont_mul_order_15(t3, t2, t);
  31158. /* t2= a^ffff0000 = t3 ^ 2 ^ 16 */
  31159. sp_384_mont_sqr_n_order_15(t2, t3, 16);
  31160. /* t = a^ffffffff = t2 * t3 */
  31161. sp_384_mont_mul_order_15(t, t2, t3);
  31162. /* t2= a^ffffffff0000 = t ^ 2 ^ 16 */
  31163. sp_384_mont_sqr_n_order_15(t2, t, 16);
  31164. /* t = a^ffffffffffff = t2 * t3 */
  31165. sp_384_mont_mul_order_15(t, t2, t3);
  31166. /* t2= a^ffffffffffff000000000000 = t ^ 2 ^ 48 */
  31167. sp_384_mont_sqr_n_order_15(t2, t, 48);
  31168. /* t= a^fffffffffffffffffffffffff = t2 * t */
  31169. sp_384_mont_mul_order_15(t, t2, t);
  31170. /* t2= a^ffffffffffffffffffffffff000000000000000000000000 */
  31171. sp_384_mont_sqr_n_order_15(t2, t, 96);
  31172. /* t2= a^ffffffffffffffffffffffffffffffffffffffffffffffff = t2 * t */
  31173. sp_384_mont_mul_order_15(t2, t2, t);
  31174. for (i=191; i>=1; i--) {
  31175. sp_384_mont_sqr_order_15(t2, t2);
  31176. if ((p384_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  31177. sp_384_mont_mul_order_15(t2, t2, a);
  31178. }
  31179. }
  31180. sp_384_mont_sqr_order_15(t2, t2);
  31181. sp_384_mont_mul_order_15(r, t2, a);
  31182. #endif /* WOLFSSL_SP_SMALL */
  31183. }
  31184. #endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */
  31185. #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  31186. #ifdef HAVE_ECC_SIGN
  31187. #ifndef SP_ECC_MAX_SIG_GEN
  31188. #define SP_ECC_MAX_SIG_GEN 64
  31189. #endif
  31190. /* Calculate second signature value S from R, k and private value.
  31191. *
  31192. * s = (r * x + e) / k
  31193. *
  31194. * s Signature value.
  31195. * r First signature value.
  31196. * k Ephemeral private key.
  31197. * x Private key as a number.
  31198. * e Hash of message as a number.
  31199. * tmp Temporary storage for intermediate numbers.
  31200. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  31201. */
  31202. static int sp_384_calc_s_15(sp_digit* s, const sp_digit* r, sp_digit* k,
  31203. sp_digit* x, const sp_digit* e, sp_digit* tmp)
  31204. {
  31205. int err;
  31206. sp_digit carry;
  31207. sp_int32 c;
  31208. sp_digit* kInv = k;
  31209. /* Conv k to Montgomery form (mod order) */
  31210. sp_384_mul_15(k, k, p384_norm_order);
  31211. err = sp_384_mod_15(k, k, p384_order);
  31212. if (err == MP_OKAY) {
  31213. sp_384_norm_15(k);
  31214. /* kInv = 1/k mod order */
  31215. sp_384_mont_inv_order_15(kInv, k, tmp);
  31216. sp_384_norm_15(kInv);
  31217. /* s = r * x + e */
  31218. sp_384_mul_15(x, x, r);
  31219. err = sp_384_mod_15(x, x, p384_order);
  31220. }
  31221. if (err == MP_OKAY) {
  31222. sp_384_norm_15(x);
  31223. carry = sp_384_add_15(s, e, x);
  31224. sp_384_cond_sub_15(s, s, p384_order, 0 - carry);
  31225. sp_384_norm_15(s);
  31226. c = sp_384_cmp_15(s, p384_order);
  31227. sp_384_cond_sub_15(s, s, p384_order,
  31228. (sp_digit)0 - (sp_digit)(c >= 0));
  31229. sp_384_norm_15(s);
  31230. /* s = s * k^-1 mod order */
  31231. sp_384_mont_mul_order_15(s, s, kInv);
  31232. sp_384_norm_15(s);
  31233. }
  31234. return err;
  31235. }
  31236. /* Sign the hash using the private key.
  31237. * e = [hash, 384 bits] from binary
  31238. * r = (k.G)->x mod order
  31239. * s = (r * x + e) / k mod order
  31240. * The hash is truncated to the first 384 bits.
  31241. *
  31242. * hash Hash to sign.
  31243. * hashLen Length of the hash data.
  31244. * rng Random number generator.
  31245. * priv Private part of key - scalar.
  31246. * rm First part of result as an mp_int.
  31247. * sm Sirst part of result as an mp_int.
  31248. * heap Heap to use for allocation.
  31249. * returns RNG failures, MEMORY_E when memory allocation fails and
  31250. * MP_OKAY on success.
  31251. */
  31252. int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
  31253. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  31254. {
  31255. #ifdef WOLFSSL_SP_SMALL_STACK
  31256. sp_digit* e = NULL;
  31257. sp_point_384* point = NULL;
  31258. #else
  31259. sp_digit e[7 * 2 * 15];
  31260. sp_point_384 point[1];
  31261. #endif
  31262. sp_digit* x = NULL;
  31263. sp_digit* k = NULL;
  31264. sp_digit* r = NULL;
  31265. sp_digit* tmp = NULL;
  31266. sp_digit* s = NULL;
  31267. sp_int32 c;
  31268. int err = MP_OKAY;
  31269. int i;
  31270. (void)heap;
  31271. #ifdef WOLFSSL_SP_SMALL_STACK
  31272. if (err == MP_OKAY) {
  31273. point = (sp_point_384*)XMALLOC(sizeof(sp_point_384), heap,
  31274. DYNAMIC_TYPE_ECC);
  31275. if (point == NULL)
  31276. err = MEMORY_E;
  31277. }
  31278. if (err == MP_OKAY) {
  31279. e = (sp_digit*)XMALLOC(sizeof(sp_digit) * 7 * 2 * 15, heap,
  31280. DYNAMIC_TYPE_ECC);
  31281. if (e == NULL)
  31282. err = MEMORY_E;
  31283. }
  31284. #endif
  31285. if (err == MP_OKAY) {
  31286. x = e + 2 * 15;
  31287. k = e + 4 * 15;
  31288. r = e + 6 * 15;
  31289. tmp = e + 8 * 15;
  31290. s = e;
  31291. if (hashLen > 48U) {
  31292. hashLen = 48U;
  31293. }
  31294. }
  31295. for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
  31296. /* New random point. */
  31297. if (km == NULL || mp_iszero(km)) {
  31298. err = sp_384_ecc_gen_k_15(rng, k);
  31299. }
  31300. else {
  31301. sp_384_from_mp(k, 15, km);
  31302. mp_zero(km);
  31303. }
  31304. if (err == MP_OKAY) {
  31305. err = sp_384_ecc_mulmod_base_15(point, k, 1, 1, heap);
  31306. }
  31307. if (err == MP_OKAY) {
  31308. /* r = point->x mod order */
  31309. XMEMCPY(r, point->x, sizeof(sp_digit) * 15U);
  31310. sp_384_norm_15(r);
  31311. c = sp_384_cmp_15(r, p384_order);
  31312. sp_384_cond_sub_15(r, r, p384_order,
  31313. (sp_digit)0 - (sp_digit)(c >= 0));
  31314. sp_384_norm_15(r);
  31315. if (!sp_384_iszero_15(r)) {
  31316. /* x is modified in calculation of s. */
  31317. sp_384_from_mp(x, 15, priv);
  31318. /* s ptr == e ptr, e is modified in calculation of s. */
  31319. sp_384_from_bin(e, 15, hash, (int)hashLen);
  31320. err = sp_384_calc_s_15(s, r, k, x, e, tmp);
  31321. /* Check that signature is usable. */
  31322. if ((err == MP_OKAY) && (!sp_384_iszero_15(s))) {
  31323. break;
  31324. }
  31325. }
  31326. }
  31327. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  31328. i = 1;
  31329. #endif
  31330. }
  31331. if (i == 0) {
  31332. err = RNG_FAILURE_E;
  31333. }
  31334. if (err == MP_OKAY) {
  31335. err = sp_384_to_mp(r, rm);
  31336. }
  31337. if (err == MP_OKAY) {
  31338. err = sp_384_to_mp(s, sm);
  31339. }
  31340. #ifdef WOLFSSL_SP_SMALL_STACK
  31341. if (e != NULL)
  31342. #endif
  31343. {
  31344. ForceZero(e, sizeof(sp_digit) * 7 * 2 * 15);
  31345. #ifdef WOLFSSL_SP_SMALL_STACK
  31346. XFREE(e, heap, DYNAMIC_TYPE_ECC);
  31347. #endif
  31348. }
  31349. #ifdef WOLFSSL_SP_SMALL_STACK
  31350. if (point != NULL)
  31351. #endif
  31352. {
  31353. ForceZero(point, sizeof(sp_point_384));
  31354. #ifdef WOLFSSL_SP_SMALL_STACK
  31355. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  31356. #endif
  31357. }
  31358. return err;
  31359. }
  31360. #ifdef WOLFSSL_SP_NONBLOCK
  31361. typedef struct sp_ecc_sign_384_ctx {
  31362. int state;
  31363. union {
  31364. sp_384_ecc_mulmod_15_ctx mulmod_ctx;
  31365. sp_384_mont_inv_order_15_ctx mont_inv_order_ctx;
  31366. };
  31367. sp_digit e[2*15];
  31368. sp_digit x[2*15];
  31369. sp_digit k[2*15];
  31370. sp_digit r[2*15];
  31371. sp_digit tmp[3 * 2*15];
  31372. sp_point_384 point;
  31373. sp_digit* s;
  31374. sp_digit* kInv;
  31375. int i;
  31376. } sp_ecc_sign_384_ctx;
  31377. int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, WC_RNG* rng,
  31378. mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  31379. {
  31380. int err = FP_WOULDBLOCK;
  31381. sp_ecc_sign_384_ctx* ctx = (sp_ecc_sign_384_ctx*)sp_ctx->data;
  31382. typedef char ctx_size_test[sizeof(sp_ecc_sign_384_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  31383. (void)sizeof(ctx_size_test);
  31384. switch (ctx->state) {
  31385. case 0: /* INIT */
  31386. ctx->s = ctx->e;
  31387. ctx->kInv = ctx->k;
  31388. ctx->i = SP_ECC_MAX_SIG_GEN;
  31389. ctx->state = 1;
  31390. break;
  31391. case 1: /* GEN */
  31392. /* New random point. */
  31393. if (km == NULL || mp_iszero(km)) {
  31394. err = sp_384_ecc_gen_k_15(rng, ctx->k);
  31395. }
  31396. else {
  31397. sp_384_from_mp(ctx->k, 15, km);
  31398. mp_zero(km);
  31399. }
  31400. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  31401. ctx->state = 2;
  31402. break;
  31403. case 2: /* MULMOD */
  31404. err = sp_384_ecc_mulmod_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  31405. &ctx->point, &p384_base, ctx->k, 1, 1, heap);
  31406. if (err == MP_OKAY) {
  31407. ctx->state = 3;
  31408. }
  31409. break;
  31410. case 3: /* MODORDER */
  31411. {
  31412. sp_int32 c;
  31413. /* r = point->x mod order */
  31414. XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 15U);
  31415. sp_384_norm_15(ctx->r);
  31416. c = sp_384_cmp_15(ctx->r, p384_order);
  31417. sp_384_cond_sub_15(ctx->r, ctx->r, p384_order,
  31418. (sp_digit)0 - (sp_digit)(c >= 0));
  31419. sp_384_norm_15(ctx->r);
  31420. if (hashLen > 48U) {
  31421. hashLen = 48U;
  31422. }
  31423. sp_384_from_mp(ctx->x, 15, priv);
  31424. sp_384_from_bin(ctx->e, 15, hash, (int)hashLen);
  31425. ctx->state = 4;
  31426. break;
  31427. }
  31428. case 4: /* KMODORDER */
  31429. /* Conv k to Montgomery form (mod order) */
  31430. sp_384_mul_15(ctx->k, ctx->k, p384_norm_order);
  31431. err = sp_384_mod_15(ctx->k, ctx->k, p384_order);
  31432. if (err == MP_OKAY) {
  31433. sp_384_norm_15(ctx->k);
  31434. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  31435. ctx->state = 5;
  31436. }
  31437. break;
  31438. case 5: /* KINV */
  31439. /* kInv = 1/k mod order */
  31440. err = sp_384_mont_inv_order_15_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->kInv, ctx->k, ctx->tmp);
  31441. if (err == MP_OKAY) {
  31442. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  31443. ctx->state = 6;
  31444. }
  31445. break;
  31446. case 6: /* KINVNORM */
  31447. sp_384_norm_15(ctx->kInv);
  31448. ctx->state = 7;
  31449. break;
  31450. case 7: /* R */
  31451. /* s = r * x + e */
  31452. sp_384_mul_15(ctx->x, ctx->x, ctx->r);
  31453. ctx->state = 8;
  31454. break;
  31455. case 8: /* S1 */
  31456. err = sp_384_mod_15(ctx->x, ctx->x, p384_order);
  31457. if (err == MP_OKAY)
  31458. ctx->state = 9;
  31459. break;
  31460. case 9: /* S2 */
  31461. {
  31462. sp_digit carry;
  31463. sp_int32 c;
  31464. sp_384_norm_15(ctx->x);
  31465. carry = sp_384_add_15(ctx->s, ctx->e, ctx->x);
  31466. sp_384_cond_sub_15(ctx->s, ctx->s,
  31467. p384_order, 0 - carry);
  31468. sp_384_norm_15(ctx->s);
  31469. c = sp_384_cmp_15(ctx->s, p384_order);
  31470. sp_384_cond_sub_15(ctx->s, ctx->s, p384_order,
  31471. (sp_digit)0 - (sp_digit)(c >= 0));
  31472. sp_384_norm_15(ctx->s);
  31473. /* s = s * k^-1 mod order */
  31474. sp_384_mont_mul_order_15(ctx->s, ctx->s, ctx->kInv);
  31475. sp_384_norm_15(ctx->s);
  31476. /* Check that signature is usable. */
  31477. if (sp_384_iszero_15(ctx->s) == 0) {
  31478. ctx->state = 10;
  31479. break;
  31480. }
  31481. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  31482. ctx->i = 1;
  31483. #endif
  31484. /* not usable gen, try again */
  31485. ctx->i--;
  31486. if (ctx->i == 0) {
  31487. err = RNG_FAILURE_E;
  31488. }
  31489. ctx->state = 1;
  31490. break;
  31491. }
  31492. case 10: /* RES */
  31493. err = sp_384_to_mp(ctx->r, rm);
  31494. if (err == MP_OKAY) {
  31495. err = sp_384_to_mp(ctx->s, sm);
  31496. }
  31497. break;
  31498. }
  31499. if (err == MP_OKAY && ctx->state != 10) {
  31500. err = FP_WOULDBLOCK;
  31501. }
  31502. if (err != FP_WOULDBLOCK) {
  31503. XMEMSET(ctx->e, 0, sizeof(sp_digit) * 2U * 15U);
  31504. XMEMSET(ctx->x, 0, sizeof(sp_digit) * 2U * 15U);
  31505. XMEMSET(ctx->k, 0, sizeof(sp_digit) * 2U * 15U);
  31506. XMEMSET(ctx->r, 0, sizeof(sp_digit) * 2U * 15U);
  31507. XMEMSET(ctx->tmp, 0, sizeof(sp_digit) * 3U * 2U * 15U);
  31508. }
  31509. return err;
  31510. }
  31511. #endif /* WOLFSSL_SP_NONBLOCK */
  31512. #endif /* HAVE_ECC_SIGN */
  31513. #ifndef WOLFSSL_SP_SMALL
  31514. static const char sp_384_tab32_15[32] = {
  31515. 1, 10, 2, 11, 14, 22, 3, 30,
  31516. 12, 15, 17, 19, 23, 26, 4, 31,
  31517. 9, 13, 21, 29, 16, 18, 25, 8,
  31518. 20, 28, 24, 7, 27, 6, 5, 32};
  31519. static int sp_384_num_bits_26_15(sp_digit v)
  31520. {
  31521. v |= v >> 1;
  31522. v |= v >> 2;
  31523. v |= v >> 4;
  31524. v |= v >> 8;
  31525. v |= v >> 16;
  31526. return sp_384_tab32_15[(uint32_t)(v*0x07C4ACDD) >> 27];
  31527. }
  31528. static int sp_384_num_bits_15(const sp_digit* a)
  31529. {
  31530. int i;
  31531. int r = 0;
  31532. for (i = 14; i >= 0; i--) {
  31533. if (a[i] != 0) {
  31534. r = sp_384_num_bits_26_15(a[i]);
  31535. r += i * 26;
  31536. break;
  31537. }
  31538. }
  31539. return r;
  31540. }
  31541. /* Non-constant time modular inversion.
  31542. *
  31543. * @param [out] r Resulting number.
  31544. * @param [in] a Number to invert.
  31545. * @param [in] m Modulus.
  31546. * @return MP_OKAY on success.
  31547. * @return MEMEORY_E when dynamic memory allocation fails.
  31548. */
  31549. static int sp_384_mod_inv_15(sp_digit* r, const sp_digit* a, const sp_digit* m)
  31550. {
  31551. int err = MP_OKAY;
  31552. #ifdef WOLFSSL_SP_SMALL_STACK
  31553. sp_digit* u = NULL;
  31554. #else
  31555. sp_digit u[15 * 4];
  31556. #endif
  31557. sp_digit* v = NULL;
  31558. sp_digit* b = NULL;
  31559. sp_digit* d = NULL;
  31560. int ut;
  31561. int vt;
  31562. #ifdef WOLFSSL_SP_SMALL_STACK
  31563. u = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15 * 4, NULL,
  31564. DYNAMIC_TYPE_ECC);
  31565. if (u == NULL)
  31566. err = MEMORY_E;
  31567. #endif
  31568. if (err == MP_OKAY) {
  31569. v = u + 15;
  31570. b = u + 2 * 15;
  31571. d = u + 3 * 15;
  31572. XMEMCPY(u, m, sizeof(sp_digit) * 15);
  31573. XMEMCPY(v, a, sizeof(sp_digit) * 15);
  31574. ut = sp_384_num_bits_15(u);
  31575. vt = sp_384_num_bits_15(v);
  31576. XMEMSET(b, 0, sizeof(sp_digit) * 15);
  31577. if ((v[0] & 1) == 0) {
  31578. sp_384_rshift1_15(v, v);
  31579. XMEMCPY(d, m, sizeof(sp_digit) * 15);
  31580. d[0]++;
  31581. sp_384_rshift1_15(d, d);
  31582. vt--;
  31583. while ((v[0] & 1) == 0) {
  31584. sp_384_rshift1_15(v, v);
  31585. if (d[0] & 1)
  31586. sp_384_add_15(d, d, m);
  31587. sp_384_rshift1_15(d, d);
  31588. vt--;
  31589. }
  31590. }
  31591. else {
  31592. XMEMSET(d+1, 0, sizeof(sp_digit) * (15 - 1));
  31593. d[0] = 1;
  31594. }
  31595. while (ut > 1 && vt > 1) {
  31596. if ((ut > vt) || ((ut == vt) &&
  31597. (sp_384_cmp_15(u, v) >= 0))) {
  31598. sp_384_sub_15(u, u, v);
  31599. sp_384_norm_15(u);
  31600. sp_384_sub_15(b, b, d);
  31601. sp_384_norm_15(b);
  31602. if (b[14] < 0)
  31603. sp_384_add_15(b, b, m);
  31604. sp_384_norm_15(b);
  31605. ut = sp_384_num_bits_15(u);
  31606. do {
  31607. sp_384_rshift1_15(u, u);
  31608. if (b[0] & 1)
  31609. sp_384_add_15(b, b, m);
  31610. sp_384_rshift1_15(b, b);
  31611. ut--;
  31612. }
  31613. while (ut > 0 && (u[0] & 1) == 0);
  31614. }
  31615. else {
  31616. sp_384_sub_15(v, v, u);
  31617. sp_384_norm_15(v);
  31618. sp_384_sub_15(d, d, b);
  31619. sp_384_norm_15(d);
  31620. if (d[14] < 0)
  31621. sp_384_add_15(d, d, m);
  31622. sp_384_norm_15(d);
  31623. vt = sp_384_num_bits_15(v);
  31624. do {
  31625. sp_384_rshift1_15(v, v);
  31626. if (d[0] & 1)
  31627. sp_384_add_15(d, d, m);
  31628. sp_384_rshift1_15(d, d);
  31629. vt--;
  31630. }
  31631. while (vt > 0 && (v[0] & 1) == 0);
  31632. }
  31633. }
  31634. if (ut == 1)
  31635. XMEMCPY(r, b, sizeof(sp_digit) * 15);
  31636. else
  31637. XMEMCPY(r, d, sizeof(sp_digit) * 15);
  31638. }
  31639. #ifdef WOLFSSL_SP_SMALL_STACK
  31640. if (u != NULL)
  31641. XFREE(u, NULL, DYNAMIC_TYPE_ECC);
  31642. #endif
  31643. return err;
  31644. }
  31645. #endif /* WOLFSSL_SP_SMALL */
  31646. /* Add point p1 into point p2. Handles p1 == p2 and result at infinity.
  31647. *
  31648. * p1 First point to add and holds result.
  31649. * p2 Second point to add.
  31650. * tmp Temporary storage for intermediate numbers.
  31651. */
  31652. static void sp_384_add_points_15(sp_point_384* p1, const sp_point_384* p2,
  31653. sp_digit* tmp)
  31654. {
  31655. sp_384_proj_point_add_15(p1, p1, p2, tmp);
  31656. if (sp_384_iszero_15(p1->z)) {
  31657. if (sp_384_iszero_15(p1->x) && sp_384_iszero_15(p1->y)) {
  31658. sp_384_proj_point_dbl_15(p1, p2, tmp);
  31659. }
  31660. else {
  31661. /* Y ordinate is not used from here - don't set. */
  31662. p1->x[0] = 0;
  31663. p1->x[1] = 0;
  31664. p1->x[2] = 0;
  31665. p1->x[3] = 0;
  31666. p1->x[4] = 0;
  31667. p1->x[5] = 0;
  31668. p1->x[6] = 0;
  31669. p1->x[7] = 0;
  31670. p1->x[8] = 0;
  31671. p1->x[9] = 0;
  31672. p1->x[10] = 0;
  31673. p1->x[11] = 0;
  31674. p1->x[12] = 0;
  31675. p1->x[13] = 0;
  31676. p1->x[14] = 0;
  31677. XMEMCPY(p1->z, p384_norm_mod, sizeof(p384_norm_mod));
  31678. }
  31679. }
  31680. }
  31681. /* Calculate the verification point: [e/s]G + [r/s]Q
  31682. *
  31683. * p1 Calculated point.
  31684. * p2 Public point and temporary.
  31685. * s Second part of signature as a number.
  31686. * u1 Temporary number.
  31687. * u2 Temporary number.
  31688. * heap Heap to use for allocation.
  31689. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  31690. */
  31691. static int sp_384_calc_vfy_point_15(sp_point_384* p1, sp_point_384* p2,
  31692. sp_digit* s, sp_digit* u1, sp_digit* u2, sp_digit* tmp, void* heap)
  31693. {
  31694. int err;
  31695. #ifndef WOLFSSL_SP_SMALL
  31696. err = sp_384_mod_inv_15(s, s, p384_order);
  31697. if (err == MP_OKAY)
  31698. #endif /* !WOLFSSL_SP_SMALL */
  31699. {
  31700. sp_384_mul_15(s, s, p384_norm_order);
  31701. err = sp_384_mod_15(s, s, p384_order);
  31702. }
  31703. if (err == MP_OKAY) {
  31704. sp_384_norm_15(s);
  31705. #ifdef WOLFSSL_SP_SMALL
  31706. {
  31707. sp_384_mont_inv_order_15(s, s, tmp);
  31708. sp_384_mont_mul_order_15(u1, u1, s);
  31709. sp_384_mont_mul_order_15(u2, u2, s);
  31710. }
  31711. #else
  31712. {
  31713. sp_384_mont_mul_order_15(u1, u1, s);
  31714. sp_384_mont_mul_order_15(u2, u2, s);
  31715. }
  31716. #endif /* WOLFSSL_SP_SMALL */
  31717. {
  31718. err = sp_384_ecc_mulmod_base_15(p1, u1, 0, 0, heap);
  31719. }
  31720. }
  31721. if ((err == MP_OKAY) && sp_384_iszero_15(p1->z)) {
  31722. p1->infinity = 1;
  31723. }
  31724. if (err == MP_OKAY) {
  31725. err = sp_384_ecc_mulmod_15(p2, p2, u2, 0, 0, heap);
  31726. }
  31727. if ((err == MP_OKAY) && sp_384_iszero_15(p2->z)) {
  31728. p2->infinity = 1;
  31729. }
  31730. if (err == MP_OKAY) {
  31731. sp_384_add_points_15(p1, p2, tmp);
  31732. }
  31733. return err;
  31734. }
  31735. #ifdef HAVE_ECC_VERIFY
  31736. /* Verify the signature values with the hash and public key.
  31737. * e = Truncate(hash, 384)
  31738. * u1 = e/s mod order
  31739. * u2 = r/s mod order
  31740. * r == (u1.G + u2.Q)->x mod order
  31741. * Optimization: Leave point in projective form.
  31742. * (x, y, 1) == (x' / z'*z', y' / z'*z'*z', z' / z')
  31743. * (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x'
  31744. * The hash is truncated to the first 384 bits.
  31745. *
  31746. * hash Hash to sign.
  31747. * hashLen Length of the hash data.
  31748. * rng Random number generator.
  31749. * priv Private part of key - scalar.
  31750. * rm First part of result as an mp_int.
  31751. * sm Sirst part of result as an mp_int.
  31752. * heap Heap to use for allocation.
  31753. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  31754. */
  31755. int sp_ecc_verify_384(const byte* hash, word32 hashLen, const mp_int* pX,
  31756. const mp_int* pY, const mp_int* pZ, const mp_int* rm, const mp_int* sm,
  31757. int* res, void* heap)
  31758. {
  31759. #ifdef WOLFSSL_SP_SMALL_STACK
  31760. sp_digit* u1 = NULL;
  31761. sp_point_384* p1 = NULL;
  31762. #else
  31763. sp_digit u1[18 * 15];
  31764. sp_point_384 p1[2];
  31765. #endif
  31766. sp_digit* u2 = NULL;
  31767. sp_digit* s = NULL;
  31768. sp_digit* tmp = NULL;
  31769. sp_point_384* p2 = NULL;
  31770. sp_digit carry;
  31771. sp_int32 c = 0;
  31772. int err = MP_OKAY;
  31773. #ifdef WOLFSSL_SP_SMALL_STACK
  31774. if (err == MP_OKAY) {
  31775. p1 = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap,
  31776. DYNAMIC_TYPE_ECC);
  31777. if (p1 == NULL)
  31778. err = MEMORY_E;
  31779. }
  31780. if (err == MP_OKAY) {
  31781. u1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 18 * 15, heap,
  31782. DYNAMIC_TYPE_ECC);
  31783. if (u1 == NULL)
  31784. err = MEMORY_E;
  31785. }
  31786. #endif
  31787. if (err == MP_OKAY) {
  31788. u2 = u1 + 2 * 15;
  31789. s = u1 + 4 * 15;
  31790. tmp = u1 + 6 * 15;
  31791. p2 = p1 + 1;
  31792. if (hashLen > 48U) {
  31793. hashLen = 48U;
  31794. }
  31795. sp_384_from_bin(u1, 15, hash, (int)hashLen);
  31796. sp_384_from_mp(u2, 15, rm);
  31797. sp_384_from_mp(s, 15, sm);
  31798. sp_384_from_mp(p2->x, 15, pX);
  31799. sp_384_from_mp(p2->y, 15, pY);
  31800. sp_384_from_mp(p2->z, 15, pZ);
  31801. err = sp_384_calc_vfy_point_15(p1, p2, s, u1, u2, tmp, heap);
  31802. }
  31803. if (err == MP_OKAY) {
  31804. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  31805. /* Reload r and convert to Montgomery form. */
  31806. sp_384_from_mp(u2, 15, rm);
  31807. err = sp_384_mod_mul_norm_15(u2, u2, p384_mod);
  31808. }
  31809. if (err == MP_OKAY) {
  31810. /* u1 = r.z'.z' mod prime */
  31811. sp_384_mont_sqr_15(p1->z, p1->z, p384_mod, p384_mp_mod);
  31812. sp_384_mont_mul_15(u1, u2, p1->z, p384_mod, p384_mp_mod);
  31813. *res = (int)(sp_384_cmp_15(p1->x, u1) == 0);
  31814. if (*res == 0) {
  31815. /* Reload r and add order. */
  31816. sp_384_from_mp(u2, 15, rm);
  31817. carry = sp_384_add_15(u2, u2, p384_order);
  31818. /* Carry means result is greater than mod and is not valid. */
  31819. if (carry == 0) {
  31820. sp_384_norm_15(u2);
  31821. /* Compare with mod and if greater or equal then not valid. */
  31822. c = sp_384_cmp_15(u2, p384_mod);
  31823. }
  31824. }
  31825. if ((*res == 0) && (c < 0)) {
  31826. /* Convert to Montogomery form */
  31827. err = sp_384_mod_mul_norm_15(u2, u2, p384_mod);
  31828. if (err == MP_OKAY) {
  31829. /* u1 = (r + 1*order).z'.z' mod prime */
  31830. {
  31831. sp_384_mont_mul_15(u1, u2, p1->z, p384_mod, p384_mp_mod);
  31832. }
  31833. *res = (sp_384_cmp_15(p1->x, u1) == 0);
  31834. }
  31835. }
  31836. }
  31837. #ifdef WOLFSSL_SP_SMALL_STACK
  31838. if (u1 != NULL)
  31839. XFREE(u1, heap, DYNAMIC_TYPE_ECC);
  31840. if (p1 != NULL)
  31841. XFREE(p1, heap, DYNAMIC_TYPE_ECC);
  31842. #endif
  31843. return err;
  31844. }
  31845. #ifdef WOLFSSL_SP_NONBLOCK
  31846. typedef struct sp_ecc_verify_384_ctx {
  31847. int state;
  31848. union {
  31849. sp_384_ecc_mulmod_15_ctx mulmod_ctx;
  31850. sp_384_mont_inv_order_15_ctx mont_inv_order_ctx;
  31851. sp_384_proj_point_dbl_15_ctx dbl_ctx;
  31852. sp_384_proj_point_add_15_ctx add_ctx;
  31853. };
  31854. sp_digit u1[2*15];
  31855. sp_digit u2[2*15];
  31856. sp_digit s[2*15];
  31857. sp_digit tmp[2*15 * 6];
  31858. sp_point_384 p1;
  31859. sp_point_384 p2;
  31860. } sp_ecc_verify_384_ctx;
  31861. int sp_ecc_verify_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash,
  31862. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  31863. const mp_int* rm, const mp_int* sm, int* res, void* heap)
  31864. {
  31865. int err = FP_WOULDBLOCK;
  31866. sp_ecc_verify_384_ctx* ctx = (sp_ecc_verify_384_ctx*)sp_ctx->data;
  31867. typedef char ctx_size_test[sizeof(sp_ecc_verify_384_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  31868. (void)sizeof(ctx_size_test);
  31869. switch (ctx->state) {
  31870. case 0: /* INIT */
  31871. if (hashLen > 48U) {
  31872. hashLen = 48U;
  31873. }
  31874. sp_384_from_bin(ctx->u1, 15, hash, (int)hashLen);
  31875. sp_384_from_mp(ctx->u2, 15, rm);
  31876. sp_384_from_mp(ctx->s, 15, sm);
  31877. sp_384_from_mp(ctx->p2.x, 15, pX);
  31878. sp_384_from_mp(ctx->p2.y, 15, pY);
  31879. sp_384_from_mp(ctx->p2.z, 15, pZ);
  31880. ctx->state = 1;
  31881. break;
  31882. case 1: /* NORMS0 */
  31883. sp_384_mul_15(ctx->s, ctx->s, p384_norm_order);
  31884. err = sp_384_mod_15(ctx->s, ctx->s, p384_order);
  31885. if (err == MP_OKAY)
  31886. ctx->state = 2;
  31887. break;
  31888. case 2: /* NORMS1 */
  31889. sp_384_norm_15(ctx->s);
  31890. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  31891. ctx->state = 3;
  31892. break;
  31893. case 3: /* NORMS2 */
  31894. err = sp_384_mont_inv_order_15_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->s, ctx->s, ctx->tmp);
  31895. if (err == MP_OKAY) {
  31896. ctx->state = 4;
  31897. }
  31898. break;
  31899. case 4: /* NORMS3 */
  31900. sp_384_mont_mul_order_15(ctx->u1, ctx->u1, ctx->s);
  31901. ctx->state = 5;
  31902. break;
  31903. case 5: /* NORMS4 */
  31904. sp_384_mont_mul_order_15(ctx->u2, ctx->u2, ctx->s);
  31905. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  31906. ctx->state = 6;
  31907. break;
  31908. case 6: /* MULBASE */
  31909. err = sp_384_ecc_mulmod_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p1, &p384_base, ctx->u1, 0, 0, heap);
  31910. if (err == MP_OKAY) {
  31911. if (sp_384_iszero_15(ctx->p1.z)) {
  31912. ctx->p1.infinity = 1;
  31913. }
  31914. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  31915. ctx->state = 7;
  31916. }
  31917. break;
  31918. case 7: /* MULMOD */
  31919. err = sp_384_ecc_mulmod_15_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p2, &ctx->p2, ctx->u2, 0, 0, heap);
  31920. if (err == MP_OKAY) {
  31921. if (sp_384_iszero_15(ctx->p2.z)) {
  31922. ctx->p2.infinity = 1;
  31923. }
  31924. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  31925. ctx->state = 8;
  31926. }
  31927. break;
  31928. case 8: /* ADD */
  31929. err = sp_384_proj_point_add_15_nb((sp_ecc_ctx_t*)&ctx->add_ctx, &ctx->p1, &ctx->p1, &ctx->p2, ctx->tmp);
  31930. if (err == MP_OKAY)
  31931. ctx->state = 9;
  31932. break;
  31933. case 9: /* MONT */
  31934. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  31935. /* Reload r and convert to Montgomery form. */
  31936. sp_384_from_mp(ctx->u2, 15, rm);
  31937. err = sp_384_mod_mul_norm_15(ctx->u2, ctx->u2, p384_mod);
  31938. if (err == MP_OKAY)
  31939. ctx->state = 10;
  31940. break;
  31941. case 10: /* SQR */
  31942. /* u1 = r.z'.z' mod prime */
  31943. sp_384_mont_sqr_15(ctx->p1.z, ctx->p1.z, p384_mod, p384_mp_mod);
  31944. ctx->state = 11;
  31945. break;
  31946. case 11: /* MUL */
  31947. sp_384_mont_mul_15(ctx->u1, ctx->u2, ctx->p1.z, p384_mod, p384_mp_mod);
  31948. ctx->state = 12;
  31949. break;
  31950. case 12: /* RES */
  31951. {
  31952. sp_int32 c = 0;
  31953. err = MP_OKAY; /* math okay, now check result */
  31954. *res = (int)(sp_384_cmp_15(ctx->p1.x, ctx->u1) == 0);
  31955. if (*res == 0) {
  31956. sp_digit carry;
  31957. /* Reload r and add order. */
  31958. sp_384_from_mp(ctx->u2, 15, rm);
  31959. carry = sp_384_add_15(ctx->u2, ctx->u2, p384_order);
  31960. /* Carry means result is greater than mod and is not valid. */
  31961. if (carry == 0) {
  31962. sp_384_norm_15(ctx->u2);
  31963. /* Compare with mod and if greater or equal then not valid. */
  31964. c = sp_384_cmp_15(ctx->u2, p384_mod);
  31965. }
  31966. }
  31967. if ((*res == 0) && (c < 0)) {
  31968. /* Convert to Montogomery form */
  31969. err = sp_384_mod_mul_norm_15(ctx->u2, ctx->u2, p384_mod);
  31970. if (err == MP_OKAY) {
  31971. /* u1 = (r + 1*order).z'.z' mod prime */
  31972. sp_384_mont_mul_15(ctx->u1, ctx->u2, ctx->p1.z, p384_mod,
  31973. p384_mp_mod);
  31974. *res = (int)(sp_384_cmp_15(ctx->p1.x, ctx->u1) == 0);
  31975. }
  31976. }
  31977. break;
  31978. }
  31979. } /* switch */
  31980. if (err == MP_OKAY && ctx->state != 12) {
  31981. err = FP_WOULDBLOCK;
  31982. }
  31983. return err;
  31984. }
  31985. #endif /* WOLFSSL_SP_NONBLOCK */
  31986. #endif /* HAVE_ECC_VERIFY */
  31987. #ifdef HAVE_ECC_CHECK_KEY
  31988. /* Check that the x and y ordinates are a valid point on the curve.
  31989. *
  31990. * point EC point.
  31991. * heap Heap to use if dynamically allocating.
  31992. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  31993. * not on the curve and MP_OKAY otherwise.
  31994. */
  31995. static int sp_384_ecc_is_point_15(const sp_point_384* point,
  31996. void* heap)
  31997. {
  31998. #ifdef WOLFSSL_SP_SMALL_STACK
  31999. sp_digit* t1 = NULL;
  32000. #else
  32001. sp_digit t1[15 * 4];
  32002. #endif
  32003. sp_digit* t2 = NULL;
  32004. int err = MP_OKAY;
  32005. #ifdef WOLFSSL_SP_SMALL_STACK
  32006. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15 * 4, heap, DYNAMIC_TYPE_ECC);
  32007. if (t1 == NULL)
  32008. err = MEMORY_E;
  32009. #endif
  32010. (void)heap;
  32011. if (err == MP_OKAY) {
  32012. t2 = t1 + 2 * 15;
  32013. /* y^2 - x^3 - a.x = b */
  32014. sp_384_sqr_15(t1, point->y);
  32015. (void)sp_384_mod_15(t1, t1, p384_mod);
  32016. sp_384_sqr_15(t2, point->x);
  32017. (void)sp_384_mod_15(t2, t2, p384_mod);
  32018. sp_384_mul_15(t2, t2, point->x);
  32019. (void)sp_384_mod_15(t2, t2, p384_mod);
  32020. sp_384_mont_sub_15(t1, t1, t2, p384_mod);
  32021. /* y^2 - x^3 + 3.x = b, when a = -3 */
  32022. sp_384_mont_add_15(t1, t1, point->x, p384_mod);
  32023. sp_384_mont_add_15(t1, t1, point->x, p384_mod);
  32024. sp_384_mont_add_15(t1, t1, point->x, p384_mod);
  32025. if (sp_384_cmp_15(t1, p384_b) != 0) {
  32026. err = MP_VAL;
  32027. }
  32028. }
  32029. #ifdef WOLFSSL_SP_SMALL_STACK
  32030. if (t1 != NULL)
  32031. XFREE(t1, heap, DYNAMIC_TYPE_ECC);
  32032. #endif
  32033. return err;
  32034. }
  32035. /* Check that the x and y ordinates are a valid point on the curve.
  32036. *
  32037. * pX X ordinate of EC point.
  32038. * pY Y ordinate of EC point.
  32039. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  32040. * not on the curve and MP_OKAY otherwise.
  32041. */
  32042. int sp_ecc_is_point_384(const mp_int* pX, const mp_int* pY)
  32043. {
  32044. #ifdef WOLFSSL_SP_SMALL_STACK
  32045. sp_point_384* pub = NULL;
  32046. #else
  32047. sp_point_384 pub[1];
  32048. #endif
  32049. const byte one[1] = { 1 };
  32050. int err = MP_OKAY;
  32051. #ifdef WOLFSSL_SP_SMALL_STACK
  32052. pub = (sp_point_384*)XMALLOC(sizeof(sp_point_384), NULL,
  32053. DYNAMIC_TYPE_ECC);
  32054. if (pub == NULL)
  32055. err = MEMORY_E;
  32056. #endif
  32057. if (err == MP_OKAY) {
  32058. sp_384_from_mp(pub->x, 15, pX);
  32059. sp_384_from_mp(pub->y, 15, pY);
  32060. sp_384_from_bin(pub->z, 15, one, (int)sizeof(one));
  32061. err = sp_384_ecc_is_point_15(pub, NULL);
  32062. }
  32063. #ifdef WOLFSSL_SP_SMALL_STACK
  32064. if (pub != NULL)
  32065. XFREE(pub, NULL, DYNAMIC_TYPE_ECC);
  32066. #endif
  32067. return err;
  32068. }
  32069. /* Check that the private scalar generates the EC point (px, py), the point is
  32070. * on the curve and the point has the correct order.
  32071. *
  32072. * pX X ordinate of EC point.
  32073. * pY Y ordinate of EC point.
  32074. * privm Private scalar that generates EC point.
  32075. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  32076. * not on the curve, ECC_INF_E if the point does not have the correct order,
  32077. * ECC_PRIV_KEY_E when the private scalar doesn't generate the EC point and
  32078. * MP_OKAY otherwise.
  32079. */
  32080. int sp_ecc_check_key_384(const mp_int* pX, const mp_int* pY,
  32081. const mp_int* privm, void* heap)
  32082. {
  32083. #ifdef WOLFSSL_SP_SMALL_STACK
  32084. sp_digit* priv = NULL;
  32085. sp_point_384* pub = NULL;
  32086. #else
  32087. sp_digit priv[15];
  32088. sp_point_384 pub[2];
  32089. #endif
  32090. sp_point_384* p = NULL;
  32091. const byte one[1] = { 1 };
  32092. int err = MP_OKAY;
  32093. /* Quick check the lengs of public key ordinates and private key are in
  32094. * range. Proper check later.
  32095. */
  32096. if (((mp_count_bits(pX) > 384) ||
  32097. (mp_count_bits(pY) > 384) ||
  32098. ((privm != NULL) && (mp_count_bits(privm) > 384)))) {
  32099. err = ECC_OUT_OF_RANGE_E;
  32100. }
  32101. #ifdef WOLFSSL_SP_SMALL_STACK
  32102. if (err == MP_OKAY) {
  32103. pub = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, heap,
  32104. DYNAMIC_TYPE_ECC);
  32105. if (pub == NULL)
  32106. err = MEMORY_E;
  32107. }
  32108. if (err == MP_OKAY && privm) {
  32109. priv = (sp_digit*)XMALLOC(sizeof(sp_digit) * 15, heap,
  32110. DYNAMIC_TYPE_ECC);
  32111. if (priv == NULL)
  32112. err = MEMORY_E;
  32113. }
  32114. #endif
  32115. if (err == MP_OKAY) {
  32116. p = pub + 1;
  32117. sp_384_from_mp(pub->x, 15, pX);
  32118. sp_384_from_mp(pub->y, 15, pY);
  32119. sp_384_from_bin(pub->z, 15, one, (int)sizeof(one));
  32120. if (privm)
  32121. sp_384_from_mp(priv, 15, privm);
  32122. /* Check point at infinitiy. */
  32123. if ((sp_384_iszero_15(pub->x) != 0) &&
  32124. (sp_384_iszero_15(pub->y) != 0)) {
  32125. err = ECC_INF_E;
  32126. }
  32127. }
  32128. /* Check range of X and Y */
  32129. if ((err == MP_OKAY) &&
  32130. ((sp_384_cmp_15(pub->x, p384_mod) >= 0) ||
  32131. (sp_384_cmp_15(pub->y, p384_mod) >= 0))) {
  32132. err = ECC_OUT_OF_RANGE_E;
  32133. }
  32134. if (err == MP_OKAY) {
  32135. /* Check point is on curve */
  32136. err = sp_384_ecc_is_point_15(pub, heap);
  32137. }
  32138. if (err == MP_OKAY) {
  32139. /* Point * order = infinity */
  32140. err = sp_384_ecc_mulmod_15(p, pub, p384_order, 1, 1, heap);
  32141. }
  32142. /* Check result is infinity */
  32143. if ((err == MP_OKAY) && ((sp_384_iszero_15(p->x) == 0) ||
  32144. (sp_384_iszero_15(p->y) == 0))) {
  32145. err = ECC_INF_E;
  32146. }
  32147. if (privm) {
  32148. if (err == MP_OKAY) {
  32149. /* Base * private = point */
  32150. err = sp_384_ecc_mulmod_base_15(p, priv, 1, 1, heap);
  32151. }
  32152. /* Check result is public key */
  32153. if ((err == MP_OKAY) &&
  32154. ((sp_384_cmp_15(p->x, pub->x) != 0) ||
  32155. (sp_384_cmp_15(p->y, pub->y) != 0))) {
  32156. err = ECC_PRIV_KEY_E;
  32157. }
  32158. }
  32159. #ifdef WOLFSSL_SP_SMALL_STACK
  32160. if (pub != NULL)
  32161. XFREE(pub, heap, DYNAMIC_TYPE_ECC);
  32162. if (priv != NULL)
  32163. XFREE(priv, heap, DYNAMIC_TYPE_ECC);
  32164. #endif
  32165. return err;
  32166. }
  32167. #endif
  32168. #ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
  32169. /* Add two projective EC points together.
  32170. * (pX, pY, pZ) + (qX, qY, qZ) = (rX, rY, rZ)
  32171. *
  32172. * pX First EC point's X ordinate.
  32173. * pY First EC point's Y ordinate.
  32174. * pZ First EC point's Z ordinate.
  32175. * qX Second EC point's X ordinate.
  32176. * qY Second EC point's Y ordinate.
  32177. * qZ Second EC point's Z ordinate.
  32178. * rX Resultant EC point's X ordinate.
  32179. * rY Resultant EC point's Y ordinate.
  32180. * rZ Resultant EC point's Z ordinate.
  32181. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  32182. */
  32183. int sp_ecc_proj_add_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  32184. mp_int* qX, mp_int* qY, mp_int* qZ,
  32185. mp_int* rX, mp_int* rY, mp_int* rZ)
  32186. {
  32187. #ifdef WOLFSSL_SP_SMALL_STACK
  32188. sp_digit* tmp = NULL;
  32189. sp_point_384* p = NULL;
  32190. #else
  32191. sp_digit tmp[2 * 15 * 6];
  32192. sp_point_384 p[2];
  32193. #endif
  32194. sp_point_384* q = NULL;
  32195. int err = MP_OKAY;
  32196. #ifdef WOLFSSL_SP_SMALL_STACK
  32197. if (err == MP_OKAY) {
  32198. p = (sp_point_384*)XMALLOC(sizeof(sp_point_384) * 2, NULL,
  32199. DYNAMIC_TYPE_ECC);
  32200. if (p == NULL)
  32201. err = MEMORY_E;
  32202. }
  32203. if (err == MP_OKAY) {
  32204. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 6, NULL,
  32205. DYNAMIC_TYPE_ECC);
  32206. if (tmp == NULL) {
  32207. err = MEMORY_E;
  32208. }
  32209. }
  32210. #endif
  32211. if (err == MP_OKAY) {
  32212. q = p + 1;
  32213. sp_384_from_mp(p->x, 15, pX);
  32214. sp_384_from_mp(p->y, 15, pY);
  32215. sp_384_from_mp(p->z, 15, pZ);
  32216. sp_384_from_mp(q->x, 15, qX);
  32217. sp_384_from_mp(q->y, 15, qY);
  32218. sp_384_from_mp(q->z, 15, qZ);
  32219. p->infinity = sp_384_iszero_15(p->x) &
  32220. sp_384_iszero_15(p->y);
  32221. q->infinity = sp_384_iszero_15(q->x) &
  32222. sp_384_iszero_15(q->y);
  32223. sp_384_proj_point_add_15(p, p, q, tmp);
  32224. }
  32225. if (err == MP_OKAY) {
  32226. err = sp_384_to_mp(p->x, rX);
  32227. }
  32228. if (err == MP_OKAY) {
  32229. err = sp_384_to_mp(p->y, rY);
  32230. }
  32231. if (err == MP_OKAY) {
  32232. err = sp_384_to_mp(p->z, rZ);
  32233. }
  32234. #ifdef WOLFSSL_SP_SMALL_STACK
  32235. if (tmp != NULL)
  32236. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  32237. if (p != NULL)
  32238. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  32239. #endif
  32240. return err;
  32241. }
  32242. /* Double a projective EC point.
  32243. * (pX, pY, pZ) + (pX, pY, pZ) = (rX, rY, rZ)
  32244. *
  32245. * pX EC point's X ordinate.
  32246. * pY EC point's Y ordinate.
  32247. * pZ EC point's Z ordinate.
  32248. * rX Resultant EC point's X ordinate.
  32249. * rY Resultant EC point's Y ordinate.
  32250. * rZ Resultant EC point's Z ordinate.
  32251. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  32252. */
  32253. int sp_ecc_proj_dbl_point_384(mp_int* pX, mp_int* pY, mp_int* pZ,
  32254. mp_int* rX, mp_int* rY, mp_int* rZ)
  32255. {
  32256. #ifdef WOLFSSL_SP_SMALL_STACK
  32257. sp_digit* tmp = NULL;
  32258. sp_point_384* p = NULL;
  32259. #else
  32260. sp_digit tmp[2 * 15 * 2];
  32261. sp_point_384 p[1];
  32262. #endif
  32263. int err = MP_OKAY;
  32264. #ifdef WOLFSSL_SP_SMALL_STACK
  32265. if (err == MP_OKAY) {
  32266. p = (sp_point_384*)XMALLOC(sizeof(sp_point_384), NULL,
  32267. DYNAMIC_TYPE_ECC);
  32268. if (p == NULL)
  32269. err = MEMORY_E;
  32270. }
  32271. if (err == MP_OKAY) {
  32272. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 2, NULL,
  32273. DYNAMIC_TYPE_ECC);
  32274. if (tmp == NULL)
  32275. err = MEMORY_E;
  32276. }
  32277. #endif
  32278. if (err == MP_OKAY) {
  32279. sp_384_from_mp(p->x, 15, pX);
  32280. sp_384_from_mp(p->y, 15, pY);
  32281. sp_384_from_mp(p->z, 15, pZ);
  32282. p->infinity = sp_384_iszero_15(p->x) &
  32283. sp_384_iszero_15(p->y);
  32284. sp_384_proj_point_dbl_15(p, p, tmp);
  32285. }
  32286. if (err == MP_OKAY) {
  32287. err = sp_384_to_mp(p->x, rX);
  32288. }
  32289. if (err == MP_OKAY) {
  32290. err = sp_384_to_mp(p->y, rY);
  32291. }
  32292. if (err == MP_OKAY) {
  32293. err = sp_384_to_mp(p->z, rZ);
  32294. }
  32295. #ifdef WOLFSSL_SP_SMALL_STACK
  32296. if (tmp != NULL)
  32297. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  32298. if (p != NULL)
  32299. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  32300. #endif
  32301. return err;
  32302. }
  32303. /* Map a projective EC point to affine in place.
  32304. * pZ will be one.
  32305. *
  32306. * pX EC point's X ordinate.
  32307. * pY EC point's Y ordinate.
  32308. * pZ EC point's Z ordinate.
  32309. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  32310. */
  32311. int sp_ecc_map_384(mp_int* pX, mp_int* pY, mp_int* pZ)
  32312. {
  32313. #ifdef WOLFSSL_SP_SMALL_STACK
  32314. sp_digit* tmp = NULL;
  32315. sp_point_384* p = NULL;
  32316. #else
  32317. sp_digit tmp[2 * 15 * 6];
  32318. sp_point_384 p[1];
  32319. #endif
  32320. int err = MP_OKAY;
  32321. #ifdef WOLFSSL_SP_SMALL_STACK
  32322. if (err == MP_OKAY) {
  32323. p = (sp_point_384*)XMALLOC(sizeof(sp_point_384), NULL,
  32324. DYNAMIC_TYPE_ECC);
  32325. if (p == NULL)
  32326. err = MEMORY_E;
  32327. }
  32328. if (err == MP_OKAY) {
  32329. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 15 * 6, NULL,
  32330. DYNAMIC_TYPE_ECC);
  32331. if (tmp == NULL)
  32332. err = MEMORY_E;
  32333. }
  32334. #endif
  32335. if (err == MP_OKAY) {
  32336. sp_384_from_mp(p->x, 15, pX);
  32337. sp_384_from_mp(p->y, 15, pY);
  32338. sp_384_from_mp(p->z, 15, pZ);
  32339. p->infinity = sp_384_iszero_15(p->x) &
  32340. sp_384_iszero_15(p->y);
  32341. sp_384_map_15(p, p, tmp);
  32342. }
  32343. if (err == MP_OKAY) {
  32344. err = sp_384_to_mp(p->x, pX);
  32345. }
  32346. if (err == MP_OKAY) {
  32347. err = sp_384_to_mp(p->y, pY);
  32348. }
  32349. if (err == MP_OKAY) {
  32350. err = sp_384_to_mp(p->z, pZ);
  32351. }
  32352. #ifdef WOLFSSL_SP_SMALL_STACK
  32353. if (tmp != NULL)
  32354. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  32355. if (p != NULL)
  32356. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  32357. #endif
  32358. return err;
  32359. }
  32360. #endif /* WOLFSSL_PUBLIC_ECC_ADD_DBL */
  32361. #ifdef HAVE_COMP_KEY
  32362. /* Find the square root of a number mod the prime of the curve.
  32363. *
  32364. * y The number to operate on and the result.
  32365. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  32366. */
  32367. static int sp_384_mont_sqrt_15(sp_digit* y)
  32368. {
  32369. #ifdef WOLFSSL_SP_SMALL_STACK
  32370. sp_digit* t1 = NULL;
  32371. #else
  32372. sp_digit t1[5 * 2 * 15];
  32373. #endif
  32374. sp_digit* t2 = NULL;
  32375. sp_digit* t3 = NULL;
  32376. sp_digit* t4 = NULL;
  32377. sp_digit* t5 = NULL;
  32378. int err = MP_OKAY;
  32379. #ifdef WOLFSSL_SP_SMALL_STACK
  32380. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 5 * 2 * 15, NULL, DYNAMIC_TYPE_ECC);
  32381. if (t1 == NULL)
  32382. err = MEMORY_E;
  32383. #endif
  32384. if (err == MP_OKAY) {
  32385. t2 = t1 + 2 * 15;
  32386. t3 = t1 + 4 * 15;
  32387. t4 = t1 + 6 * 15;
  32388. t5 = t1 + 8 * 15;
  32389. {
  32390. /* t2 = y ^ 0x2 */
  32391. sp_384_mont_sqr_15(t2, y, p384_mod, p384_mp_mod);
  32392. /* t1 = y ^ 0x3 */
  32393. sp_384_mont_mul_15(t1, t2, y, p384_mod, p384_mp_mod);
  32394. /* t5 = y ^ 0xc */
  32395. sp_384_mont_sqr_n_15(t5, t1, 2, p384_mod, p384_mp_mod);
  32396. /* t1 = y ^ 0xf */
  32397. sp_384_mont_mul_15(t1, t1, t5, p384_mod, p384_mp_mod);
  32398. /* t2 = y ^ 0x1e */
  32399. sp_384_mont_sqr_15(t2, t1, p384_mod, p384_mp_mod);
  32400. /* t3 = y ^ 0x1f */
  32401. sp_384_mont_mul_15(t3, t2, y, p384_mod, p384_mp_mod);
  32402. /* t2 = y ^ 0x3e0 */
  32403. sp_384_mont_sqr_n_15(t2, t3, 5, p384_mod, p384_mp_mod);
  32404. /* t1 = y ^ 0x3ff */
  32405. sp_384_mont_mul_15(t1, t3, t2, p384_mod, p384_mp_mod);
  32406. /* t2 = y ^ 0x7fe0 */
  32407. sp_384_mont_sqr_n_15(t2, t1, 5, p384_mod, p384_mp_mod);
  32408. /* t3 = y ^ 0x7fff */
  32409. sp_384_mont_mul_15(t3, t3, t2, p384_mod, p384_mp_mod);
  32410. /* t2 = y ^ 0x3fff800 */
  32411. sp_384_mont_sqr_n_15(t2, t3, 15, p384_mod, p384_mp_mod);
  32412. /* t4 = y ^ 0x3ffffff */
  32413. sp_384_mont_mul_15(t4, t3, t2, p384_mod, p384_mp_mod);
  32414. /* t2 = y ^ 0xffffffc000000 */
  32415. sp_384_mont_sqr_n_15(t2, t4, 30, p384_mod, p384_mp_mod);
  32416. /* t1 = y ^ 0xfffffffffffff */
  32417. sp_384_mont_mul_15(t1, t4, t2, p384_mod, p384_mp_mod);
  32418. /* t2 = y ^ 0xfffffffffffffff000000000000000 */
  32419. sp_384_mont_sqr_n_15(t2, t1, 60, p384_mod, p384_mp_mod);
  32420. /* t1 = y ^ 0xffffffffffffffffffffffffffffff */
  32421. sp_384_mont_mul_15(t1, t1, t2, p384_mod, p384_mp_mod);
  32422. /* t2 = y ^ 0xffffffffffffffffffffffffffffff000000000000000000000000000000 */
  32423. sp_384_mont_sqr_n_15(t2, t1, 120, p384_mod, p384_mp_mod);
  32424. /* t1 = y ^ 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  32425. sp_384_mont_mul_15(t1, t1, t2, p384_mod, p384_mp_mod);
  32426. /* t2 = y ^ 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8000 */
  32427. sp_384_mont_sqr_n_15(t2, t1, 15, p384_mod, p384_mp_mod);
  32428. /* t1 = y ^ 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  32429. sp_384_mont_mul_15(t1, t3, t2, p384_mod, p384_mp_mod);
  32430. /* t2 = y ^ 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000 */
  32431. sp_384_mont_sqr_n_15(t2, t1, 31, p384_mod, p384_mp_mod);
  32432. /* t1 = y ^ 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffff */
  32433. sp_384_mont_mul_15(t1, t4, t2, p384_mod, p384_mp_mod);
  32434. /* t2 = y ^ 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffff0 */
  32435. sp_384_mont_sqr_n_15(t2, t1, 4, p384_mod, p384_mp_mod);
  32436. /* t1 = y ^ 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffc */
  32437. sp_384_mont_mul_15(t1, t5, t2, p384_mod, p384_mp_mod);
  32438. /* t2 = y ^ 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000 */
  32439. sp_384_mont_sqr_n_15(t2, t1, 62, p384_mod, p384_mp_mod);
  32440. /* t1 = y ^ 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000001 */
  32441. sp_384_mont_mul_15(t1, y, t2, p384_mod, p384_mp_mod);
  32442. /* t2 = y ^ 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffc00000000000000040000000 */
  32443. sp_384_mont_sqr_n_15(y, t1, 30, p384_mod, p384_mp_mod);
  32444. }
  32445. }
  32446. #ifdef WOLFSSL_SP_SMALL_STACK
  32447. if (t1 != NULL)
  32448. XFREE(t1, NULL, DYNAMIC_TYPE_ECC);
  32449. #endif
  32450. return err;
  32451. }
  32452. /* Uncompress the point given the X ordinate.
  32453. *
  32454. * xm X ordinate.
  32455. * odd Whether the Y ordinate is odd.
  32456. * ym Calculated Y ordinate.
  32457. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  32458. */
  32459. int sp_ecc_uncompress_384(mp_int* xm, int odd, mp_int* ym)
  32460. {
  32461. #ifdef WOLFSSL_SP_SMALL_STACK
  32462. sp_digit* x = NULL;
  32463. #else
  32464. sp_digit x[4 * 15];
  32465. #endif
  32466. sp_digit* y = NULL;
  32467. int err = MP_OKAY;
  32468. #ifdef WOLFSSL_SP_SMALL_STACK
  32469. x = (sp_digit*)XMALLOC(sizeof(sp_digit) * 4 * 15, NULL, DYNAMIC_TYPE_ECC);
  32470. if (x == NULL)
  32471. err = MEMORY_E;
  32472. #endif
  32473. if (err == MP_OKAY) {
  32474. y = x + 2 * 15;
  32475. sp_384_from_mp(x, 15, xm);
  32476. err = sp_384_mod_mul_norm_15(x, x, p384_mod);
  32477. }
  32478. if (err == MP_OKAY) {
  32479. /* y = x^3 */
  32480. {
  32481. sp_384_mont_sqr_15(y, x, p384_mod, p384_mp_mod);
  32482. sp_384_mont_mul_15(y, y, x, p384_mod, p384_mp_mod);
  32483. }
  32484. /* y = x^3 - 3x */
  32485. sp_384_mont_sub_15(y, y, x, p384_mod);
  32486. sp_384_mont_sub_15(y, y, x, p384_mod);
  32487. sp_384_mont_sub_15(y, y, x, p384_mod);
  32488. /* y = x^3 - 3x + b */
  32489. err = sp_384_mod_mul_norm_15(x, p384_b, p384_mod);
  32490. }
  32491. if (err == MP_OKAY) {
  32492. sp_384_mont_add_15(y, y, x, p384_mod);
  32493. /* y = sqrt(x^3 - 3x + b) */
  32494. err = sp_384_mont_sqrt_15(y);
  32495. }
  32496. if (err == MP_OKAY) {
  32497. XMEMSET(y + 15, 0, 15U * sizeof(sp_digit));
  32498. sp_384_mont_reduce_15(y, p384_mod, p384_mp_mod);
  32499. if ((((word32)y[0] ^ (word32)odd) & 1U) != 0U) {
  32500. sp_384_mont_sub_15(y, p384_mod, y, p384_mod);
  32501. }
  32502. err = sp_384_to_mp(y, ym);
  32503. }
  32504. #ifdef WOLFSSL_SP_SMALL_STACK
  32505. if (x != NULL)
  32506. XFREE(x, NULL, DYNAMIC_TYPE_ECC);
  32507. #endif
  32508. return err;
  32509. }
  32510. #endif
  32511. #endif /* WOLFSSL_SP_384 */
  32512. #ifdef WOLFSSL_SP_521
  32513. /* Point structure to use. */
  32514. typedef struct sp_point_521 {
  32515. /* X ordinate of point. */
  32516. sp_digit x[2 * 21];
  32517. /* Y ordinate of point. */
  32518. sp_digit y[2 * 21];
  32519. /* Z ordinate of point. */
  32520. sp_digit z[2 * 21];
  32521. /* Indicates point is at infinity. */
  32522. int infinity;
  32523. } sp_point_521;
  32524. /* The modulus (prime) of the curve P521. */
  32525. static const sp_digit p521_mod[21] = {
  32526. 0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,
  32527. 0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,
  32528. 0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x01fffff
  32529. };
  32530. /* The Montgomery normalizer for modulus of the curve P521. */
  32531. static const sp_digit p521_norm_mod[21] = {
  32532. 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  32533. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  32534. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000
  32535. };
  32536. /* The Montgomery multiplier for modulus of the curve P521. */
  32537. static sp_digit p521_mp_mod = 0x000001;
  32538. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  32539. defined(HAVE_ECC_VERIFY)
  32540. /* The order of the curve P521. */
  32541. static const sp_digit p521_order[21] = {
  32542. 0x1386409,0x1db8f48,0x1ebaedb,0x1113388,0x1bb5c9b,0x04d2e81,0x00523dc,
  32543. 0x0d6ff98,0x1bf2f96,0x0c343c1,0x1fffe94,0x1ffffff,0x1ffffff,0x1ffffff,
  32544. 0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x01fffff
  32545. };
  32546. #endif
  32547. /* The order of the curve P521 minus 2. */
  32548. static const sp_digit p521_order2[21] = {
  32549. 0x1386407,0x1db8f48,0x1ebaedb,0x1113388,0x1bb5c9b,0x04d2e81,0x00523dc,
  32550. 0x0d6ff98,0x1bf2f96,0x0c343c1,0x1fffe94,0x1ffffff,0x1ffffff,0x1ffffff,
  32551. 0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x1ffffff,0x01fffff
  32552. };
  32553. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  32554. /* The Montgomery normalizer for order of the curve P521. */
  32555. static const sp_digit p521_norm_order[21] = {
  32556. 0x0c79bf7,0x02470b7,0x0145124,0x0eecc77,0x044a364,0x1b2d17e,0x1fadc23,
  32557. 0x1290067,0x040d069,0x13cbc3e,0x000016b,0x0000000,0x0000000,0x0000000,
  32558. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000
  32559. };
  32560. #endif
  32561. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  32562. /* The Montgomery multiplier for order of the curve P521. */
  32563. static sp_digit p521_mp_order = 0x1a995c7;
  32564. #endif
  32565. /* The base point of curve P521. */
  32566. static const sp_point_521 p521_base = {
  32567. /* X ordinate */
  32568. {
  32569. 0x0e5bd66,0x13f18e1,0x0a6fe5f,0x030ad48,0x1348b3c,0x1fd46f1,0x1049e8b,
  32570. 0x051fc3b,0x1efe759,0x0a5af3b,0x14f6ea8,0x1ec0d69,0x01f828a,0x029fda9,
  32571. 0x19204e4,0x1688538,0x1662395,0x0cf1f65,0x1013a73,0x1c0d6e0,0x00c6858,
  32572. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32573. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32574. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32575. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32576. (sp_digit)0
  32577. },
  32578. /* Y ordinate */
  32579. {
  32580. 0x1d16650,0x14a3b4f,0x090222f,0x0d44e58,0x153c708,0x1683b09,0x0e404fe,
  32581. 0x0818aa1,0x15ef426,0x1f7394c,0x1998b25,0x1a2e4e7,0x0817afb,0x0bcda23,
  32582. 0x1d51125,0x037b331,0x1b42c7d,0x02e452f,0x08ef001,0x12d4f13,0x0118392,
  32583. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32584. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32585. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32586. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32587. (sp_digit)0
  32588. },
  32589. /* Z ordinate */
  32590. {
  32591. 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  32592. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  32593. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  32594. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32595. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32596. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32597. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  32598. (sp_digit)0
  32599. },
  32600. /* infinity */
  32601. 0
  32602. };
  32603. #if defined(HAVE_ECC_CHECK_KEY) || defined(HAVE_COMP_KEY)
  32604. static const sp_digit p521_b[21] = {
  32605. 0x1503f00,0x08fea35,0x13c7bd1,0x107a586,0x1573df8,0x18df839,0x102f4ee,
  32606. 0x0f62ca5,0x1ec7e93,0x10c9ca8,0x0427855,0x13231de,0x13b8b48,0x0cd98af,
  32607. 0x169c96e,0x081dd45,0x1a0b685,0x1c94d10,0x1872687,0x1d72c31,0x0051953
  32608. };
  32609. #endif
  32610. #ifdef WOLFSSL_SP_SMALL
  32611. /* Multiply a and b into r. (r = a * b)
  32612. *
  32613. * r A single precision integer.
  32614. * a A single precision integer.
  32615. * b A single precision integer.
  32616. */
  32617. SP_NOINLINE static void sp_521_mul_21(sp_digit* r, const sp_digit* a,
  32618. const sp_digit* b)
  32619. {
  32620. int i;
  32621. int imax;
  32622. int k;
  32623. sp_uint64 c;
  32624. sp_uint64 lo;
  32625. c = ((sp_uint64)a[20]) * b[20];
  32626. r[41] = (sp_digit)(c >> 25);
  32627. c &= 0x1ffffff;
  32628. for (k = 39; k >= 0; k--) {
  32629. if (k >= 21) {
  32630. i = k - 20;
  32631. imax = 20;
  32632. }
  32633. else {
  32634. i = 0;
  32635. imax = k;
  32636. }
  32637. lo = 0;
  32638. for (; i <= imax; i++) {
  32639. lo += ((sp_uint64)a[i]) * b[k - i];
  32640. }
  32641. c += lo >> 25;
  32642. r[k + 2] += (sp_digit)(c >> 25);
  32643. r[k + 1] = (sp_digit)(c & 0x1ffffff);
  32644. c = lo & 0x1ffffff;
  32645. }
  32646. r[0] = (sp_digit)c;
  32647. }
  32648. #else
  32649. /* Multiply a and b into r. (r = a * b)
  32650. *
  32651. * r A single precision integer.
  32652. * a A single precision integer.
  32653. * b A single precision integer.
  32654. */
  32655. SP_NOINLINE static void sp_521_mul_21(sp_digit* r, const sp_digit* a,
  32656. const sp_digit* b)
  32657. {
  32658. int i;
  32659. int j;
  32660. sp_int64 t[42];
  32661. XMEMSET(t, 0, sizeof(t));
  32662. for (i=0; i<21; i++) {
  32663. for (j=0; j<21; j++) {
  32664. t[i+j] += ((sp_int64)a[i]) * b[j];
  32665. }
  32666. }
  32667. for (i=0; i<41; i++) {
  32668. r[i] = t[i] & 0x1ffffff;
  32669. t[i+1] += t[i] >> 25;
  32670. }
  32671. r[41] = (sp_digit)t[41];
  32672. }
  32673. #endif /* WOLFSSL_SP_SMALL */
  32674. #ifdef WOLFSSL_SP_SMALL
  32675. /* Square a and put result in r. (r = a * a)
  32676. *
  32677. * r A single precision integer.
  32678. * a A single precision integer.
  32679. */
  32680. SP_NOINLINE static void sp_521_sqr_21(sp_digit* r, const sp_digit* a)
  32681. {
  32682. int i;
  32683. int imax;
  32684. int k;
  32685. sp_uint64 c;
  32686. sp_uint64 t;
  32687. c = ((sp_uint64)a[20]) * a[20];
  32688. r[41] = (sp_digit)(c >> 25);
  32689. c = (c & 0x1ffffff) << 25;
  32690. for (k = 39; k >= 0; k--) {
  32691. i = (k + 1) / 2;
  32692. if ((k & 1) == 0) {
  32693. c += ((sp_uint64)a[i]) * a[i];
  32694. i++;
  32695. }
  32696. if (k < 20) {
  32697. imax = k;
  32698. }
  32699. else {
  32700. imax = 20;
  32701. }
  32702. t = 0;
  32703. for (; i <= imax; i++) {
  32704. t += ((sp_uint64)a[i]) * a[k - i];
  32705. }
  32706. c += t * 2;
  32707. r[k + 2] += (sp_digit) (c >> 50);
  32708. r[k + 1] = (sp_digit)((c >> 25) & 0x1ffffff);
  32709. c = (c & 0x1ffffff) << 25;
  32710. }
  32711. r[0] = (sp_digit)(c >> 25);
  32712. }
  32713. #else
  32714. /* Square a and put result in r. (r = a * a)
  32715. *
  32716. * r A single precision integer.
  32717. * a A single precision integer.
  32718. */
  32719. SP_NOINLINE static void sp_521_sqr_21(sp_digit* r, const sp_digit* a)
  32720. {
  32721. int i;
  32722. int j;
  32723. sp_int64 t[42];
  32724. XMEMSET(t, 0, sizeof(t));
  32725. for (i=0; i<21; i++) {
  32726. for (j=0; j<i; j++) {
  32727. t[i+j] += (((sp_int64)a[i]) * a[j]) * 2;
  32728. }
  32729. t[i+i] += ((sp_int64)a[i]) * a[i];
  32730. }
  32731. for (i=0; i<41; i++) {
  32732. r[i] = t[i] & 0x1ffffff;
  32733. t[i+1] += t[i] >> 25;
  32734. }
  32735. r[41] = (sp_digit)t[41];
  32736. }
  32737. #endif /* WOLFSSL_SP_SMALL */
  32738. #ifdef WOLFSSL_SP_SMALL
  32739. /* Add b to a into r. (r = a + b)
  32740. *
  32741. * r A single precision integer.
  32742. * a A single precision integer.
  32743. * b A single precision integer.
  32744. */
  32745. SP_NOINLINE static int sp_521_add_21(sp_digit* r, const sp_digit* a,
  32746. const sp_digit* b)
  32747. {
  32748. int i;
  32749. for (i = 0; i < 21; i++) {
  32750. r[i] = a[i] + b[i];
  32751. }
  32752. return 0;
  32753. }
  32754. #else
  32755. /* Add b to a into r. (r = a + b)
  32756. *
  32757. * r A single precision integer.
  32758. * a A single precision integer.
  32759. * b A single precision integer.
  32760. */
  32761. SP_NOINLINE static int sp_521_add_21(sp_digit* r, const sp_digit* a,
  32762. const sp_digit* b)
  32763. {
  32764. int i;
  32765. for (i = 0; i < 16; i += 8) {
  32766. r[i + 0] = a[i + 0] + b[i + 0];
  32767. r[i + 1] = a[i + 1] + b[i + 1];
  32768. r[i + 2] = a[i + 2] + b[i + 2];
  32769. r[i + 3] = a[i + 3] + b[i + 3];
  32770. r[i + 4] = a[i + 4] + b[i + 4];
  32771. r[i + 5] = a[i + 5] + b[i + 5];
  32772. r[i + 6] = a[i + 6] + b[i + 6];
  32773. r[i + 7] = a[i + 7] + b[i + 7];
  32774. }
  32775. r[16] = a[16] + b[16];
  32776. r[17] = a[17] + b[17];
  32777. r[18] = a[18] + b[18];
  32778. r[19] = a[19] + b[19];
  32779. r[20] = a[20] + b[20];
  32780. return 0;
  32781. }
  32782. #endif /* WOLFSSL_SP_SMALL */
  32783. #ifdef WOLFSSL_SP_SMALL
  32784. /* Sub b from a into r. (r = a - b)
  32785. *
  32786. * r A single precision integer.
  32787. * a A single precision integer.
  32788. * b A single precision integer.
  32789. */
  32790. SP_NOINLINE static int sp_521_sub_21(sp_digit* r, const sp_digit* a,
  32791. const sp_digit* b)
  32792. {
  32793. int i;
  32794. for (i = 0; i < 21; i++) {
  32795. r[i] = a[i] - b[i];
  32796. }
  32797. return 0;
  32798. }
  32799. #else
  32800. /* Sub b from a into r. (r = a - b)
  32801. *
  32802. * r A single precision integer.
  32803. * a A single precision integer.
  32804. * b A single precision integer.
  32805. */
  32806. SP_NOINLINE static int sp_521_sub_21(sp_digit* r, const sp_digit* a,
  32807. const sp_digit* b)
  32808. {
  32809. int i;
  32810. for (i = 0; i < 16; i += 8) {
  32811. r[i + 0] = a[i + 0] - b[i + 0];
  32812. r[i + 1] = a[i + 1] - b[i + 1];
  32813. r[i + 2] = a[i + 2] - b[i + 2];
  32814. r[i + 3] = a[i + 3] - b[i + 3];
  32815. r[i + 4] = a[i + 4] - b[i + 4];
  32816. r[i + 5] = a[i + 5] - b[i + 5];
  32817. r[i + 6] = a[i + 6] - b[i + 6];
  32818. r[i + 7] = a[i + 7] - b[i + 7];
  32819. }
  32820. r[16] = a[16] - b[16];
  32821. r[17] = a[17] - b[17];
  32822. r[18] = a[18] - b[18];
  32823. r[19] = a[19] - b[19];
  32824. r[20] = a[20] - b[20];
  32825. return 0;
  32826. }
  32827. #endif /* WOLFSSL_SP_SMALL */
  32828. /* Convert an mp_int to an array of sp_digit.
  32829. *
  32830. * r A single precision integer.
  32831. * size Maximum number of bytes to convert
  32832. * a A multi-precision integer.
  32833. */
  32834. static void sp_521_from_mp(sp_digit* r, int size, const mp_int* a)
  32835. {
  32836. #if DIGIT_BIT == 25
  32837. int i;
  32838. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  32839. int o = 0;
  32840. for (i = 0; i < size; i++) {
  32841. sp_digit mask = (sp_digit)0 - (j >> 24);
  32842. r[i] = a->dp[o] & mask;
  32843. j++;
  32844. o += (int)(j >> 24);
  32845. }
  32846. #elif DIGIT_BIT > 25
  32847. unsigned int i;
  32848. int j = 0;
  32849. word32 s = 0;
  32850. r[0] = 0;
  32851. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  32852. r[j] |= ((sp_digit)a->dp[i] << s);
  32853. r[j] &= 0x1ffffff;
  32854. s = 25U - s;
  32855. if (j + 1 >= size) {
  32856. break;
  32857. }
  32858. /* lint allow cast of mismatch word32 and mp_digit */
  32859. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  32860. while ((s + 25U) <= (word32)DIGIT_BIT) {
  32861. s += 25U;
  32862. r[j] &= 0x1ffffff;
  32863. if (j + 1 >= size) {
  32864. break;
  32865. }
  32866. if (s < (word32)DIGIT_BIT) {
  32867. /* lint allow cast of mismatch word32 and mp_digit */
  32868. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  32869. }
  32870. else {
  32871. r[++j] = (sp_digit)0;
  32872. }
  32873. }
  32874. s = (word32)DIGIT_BIT - s;
  32875. }
  32876. for (j++; j < size; j++) {
  32877. r[j] = 0;
  32878. }
  32879. #else
  32880. unsigned int i;
  32881. int j = 0;
  32882. int s = 0;
  32883. r[0] = 0;
  32884. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  32885. r[j] |= ((sp_digit)a->dp[i]) << s;
  32886. if (s + DIGIT_BIT >= 25) {
  32887. r[j] &= 0x1ffffff;
  32888. if (j + 1 >= size) {
  32889. break;
  32890. }
  32891. s = 25 - s;
  32892. if (s == DIGIT_BIT) {
  32893. r[++j] = 0;
  32894. s = 0;
  32895. }
  32896. else {
  32897. r[++j] = a->dp[i] >> s;
  32898. s = DIGIT_BIT - s;
  32899. }
  32900. }
  32901. else {
  32902. s += DIGIT_BIT;
  32903. }
  32904. }
  32905. for (j++; j < size; j++) {
  32906. r[j] = 0;
  32907. }
  32908. #endif
  32909. }
  32910. /* Convert a point of type ecc_point to type sp_point_521.
  32911. *
  32912. * p Point of type sp_point_521 (result).
  32913. * pm Point of type ecc_point.
  32914. */
  32915. static void sp_521_point_from_ecc_point_21(sp_point_521* p,
  32916. const ecc_point* pm)
  32917. {
  32918. XMEMSET(p->x, 0, sizeof(p->x));
  32919. XMEMSET(p->y, 0, sizeof(p->y));
  32920. XMEMSET(p->z, 0, sizeof(p->z));
  32921. sp_521_from_mp(p->x, 21, pm->x);
  32922. sp_521_from_mp(p->y, 21, pm->y);
  32923. sp_521_from_mp(p->z, 21, pm->z);
  32924. p->infinity = 0;
  32925. }
  32926. /* Convert an array of sp_digit to an mp_int.
  32927. *
  32928. * a A single precision integer.
  32929. * r A multi-precision integer.
  32930. */
  32931. static int sp_521_to_mp(const sp_digit* a, mp_int* r)
  32932. {
  32933. int err;
  32934. err = mp_grow(r, (521 + DIGIT_BIT - 1) / DIGIT_BIT);
  32935. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  32936. #if DIGIT_BIT == 25
  32937. XMEMCPY(r->dp, a, sizeof(sp_digit) * 21);
  32938. r->used = 21;
  32939. mp_clamp(r);
  32940. #elif DIGIT_BIT < 25
  32941. int i;
  32942. int j = 0;
  32943. int s = 0;
  32944. r->dp[0] = 0;
  32945. for (i = 0; i < 21; i++) {
  32946. r->dp[j] |= (mp_digit)(a[i] << s);
  32947. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  32948. s = DIGIT_BIT - s;
  32949. r->dp[++j] = (mp_digit)(a[i] >> s);
  32950. while (s + DIGIT_BIT <= 25) {
  32951. s += DIGIT_BIT;
  32952. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  32953. if (s == SP_WORD_SIZE) {
  32954. r->dp[j] = 0;
  32955. }
  32956. else {
  32957. r->dp[j] = (mp_digit)(a[i] >> s);
  32958. }
  32959. }
  32960. s = 25 - s;
  32961. }
  32962. r->used = (521 + DIGIT_BIT - 1) / DIGIT_BIT;
  32963. mp_clamp(r);
  32964. #else
  32965. int i;
  32966. int j = 0;
  32967. int s = 0;
  32968. r->dp[0] = 0;
  32969. for (i = 0; i < 21; i++) {
  32970. r->dp[j] |= ((mp_digit)a[i]) << s;
  32971. if (s + 25 >= DIGIT_BIT) {
  32972. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  32973. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  32974. #endif
  32975. s = DIGIT_BIT - s;
  32976. r->dp[++j] = a[i] >> s;
  32977. s = 25 - s;
  32978. }
  32979. else {
  32980. s += 25;
  32981. }
  32982. }
  32983. r->used = (521 + DIGIT_BIT - 1) / DIGIT_BIT;
  32984. mp_clamp(r);
  32985. #endif
  32986. }
  32987. return err;
  32988. }
  32989. /* Convert a point of type sp_point_521 to type ecc_point.
  32990. *
  32991. * p Point of type sp_point_521.
  32992. * pm Point of type ecc_point (result).
  32993. * returns MEMORY_E when allocation of memory in ecc_point fails otherwise
  32994. * MP_OKAY.
  32995. */
  32996. static int sp_521_point_to_ecc_point_21(const sp_point_521* p, ecc_point* pm)
  32997. {
  32998. int err;
  32999. err = sp_521_to_mp(p->x, pm->x);
  33000. if (err == MP_OKAY) {
  33001. err = sp_521_to_mp(p->y, pm->y);
  33002. }
  33003. if (err == MP_OKAY) {
  33004. err = sp_521_to_mp(p->z, pm->z);
  33005. }
  33006. return err;
  33007. }
  33008. /* Normalize the values in each word to 25 bits.
  33009. *
  33010. * a Array of sp_digit to normalize.
  33011. */
  33012. static void sp_521_norm_21(sp_digit* a)
  33013. {
  33014. #ifdef WOLFSSL_SP_SMALL
  33015. int i;
  33016. for (i = 0; i < 20; i++) {
  33017. a[i+1] += a[i] >> 25;
  33018. a[i] &= 0x1ffffff;
  33019. }
  33020. #else
  33021. int i;
  33022. for (i = 0; i < 16; i += 8) {
  33023. a[i+1] += a[i+0] >> 25; a[i+0] &= 0x1ffffff;
  33024. a[i+2] += a[i+1] >> 25; a[i+1] &= 0x1ffffff;
  33025. a[i+3] += a[i+2] >> 25; a[i+2] &= 0x1ffffff;
  33026. a[i+4] += a[i+3] >> 25; a[i+3] &= 0x1ffffff;
  33027. a[i+5] += a[i+4] >> 25; a[i+4] &= 0x1ffffff;
  33028. a[i+6] += a[i+5] >> 25; a[i+5] &= 0x1ffffff;
  33029. a[i+7] += a[i+6] >> 25; a[i+6] &= 0x1ffffff;
  33030. a[i+8] += a[i+7] >> 25; a[i+7] &= 0x1ffffff;
  33031. }
  33032. a[17] += a[16] >> 25; a[16] &= 0x1ffffff;
  33033. a[18] += a[17] >> 25; a[17] &= 0x1ffffff;
  33034. a[19] += a[18] >> 25; a[18] &= 0x1ffffff;
  33035. a[20] += a[19] >> 25; a[19] &= 0x1ffffff;
  33036. #endif /* WOLFSSL_SP_SMALL */
  33037. }
  33038. /* Reduce the number back to 521 bits using Montgomery reduction.
  33039. *
  33040. * a A single precision number to reduce in place.
  33041. * m The single precision number representing the modulus.
  33042. * mp The digit representing the negative inverse of m mod 2^n.
  33043. */
  33044. static void sp_521_mont_reduce_21(sp_digit* a, const sp_digit* m, sp_digit mp)
  33045. {
  33046. int i;
  33047. (void)m;
  33048. (void)mp;
  33049. for (i = 0; i < 20; i++) {
  33050. a[i] += ((a[20 + i] >> 21) + (a[20 + i + 1] << 4)) & 0x1ffffff;
  33051. }
  33052. a[20] &= 0x1fffff;
  33053. a[20] += ((a[40] >> 21) + (a[41] << 4)) & 0x1ffffff;
  33054. sp_521_norm_21(a);
  33055. a[0] += a[20] >> 21;
  33056. a[20] &= 0x1fffff;
  33057. }
  33058. /* Compare a with b in constant time.
  33059. *
  33060. * a A single precision integer.
  33061. * b A single precision integer.
  33062. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  33063. * respectively.
  33064. */
  33065. static sp_digit sp_521_cmp_21(const sp_digit* a, const sp_digit* b)
  33066. {
  33067. sp_digit r = 0;
  33068. #ifdef WOLFSSL_SP_SMALL
  33069. int i;
  33070. for (i=20; i>=0; i--) {
  33071. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 24);
  33072. }
  33073. #else
  33074. int i;
  33075. r |= (a[20] - b[20]) & (0 - (sp_digit)1);
  33076. r |= (a[19] - b[19]) & ~(((sp_digit)0 - r) >> 24);
  33077. r |= (a[18] - b[18]) & ~(((sp_digit)0 - r) >> 24);
  33078. r |= (a[17] - b[17]) & ~(((sp_digit)0 - r) >> 24);
  33079. r |= (a[16] - b[16]) & ~(((sp_digit)0 - r) >> 24);
  33080. for (i = 8; i >= 0; i -= 8) {
  33081. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 24);
  33082. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 24);
  33083. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 24);
  33084. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 24);
  33085. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 24);
  33086. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 24);
  33087. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 24);
  33088. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 24);
  33089. }
  33090. #endif /* WOLFSSL_SP_SMALL */
  33091. return r;
  33092. }
  33093. /* Conditionally subtract b from a using the mask m.
  33094. * m is -1 to subtract and 0 when not.
  33095. *
  33096. * r A single precision number representing condition subtract result.
  33097. * a A single precision number to subtract from.
  33098. * b A single precision number to subtract.
  33099. * m Mask value to apply.
  33100. */
  33101. static void sp_521_cond_sub_21(sp_digit* r, const sp_digit* a,
  33102. const sp_digit* b, const sp_digit m)
  33103. {
  33104. #ifdef WOLFSSL_SP_SMALL
  33105. int i;
  33106. for (i = 0; i < 21; i++) {
  33107. r[i] = a[i] - (b[i] & m);
  33108. }
  33109. #else
  33110. int i;
  33111. for (i = 0; i < 16; i += 8) {
  33112. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  33113. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  33114. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  33115. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  33116. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  33117. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  33118. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  33119. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  33120. }
  33121. r[16] = a[16] - (b[16] & m);
  33122. r[17] = a[17] - (b[17] & m);
  33123. r[18] = a[18] - (b[18] & m);
  33124. r[19] = a[19] - (b[19] & m);
  33125. r[20] = a[20] - (b[20] & m);
  33126. #endif /* WOLFSSL_SP_SMALL */
  33127. }
  33128. /* Mul a by scalar b and add into r. (r += a * b)
  33129. *
  33130. * r A single precision integer.
  33131. * a A single precision integer.
  33132. * b A scalar.
  33133. */
  33134. SP_NOINLINE static void sp_521_mul_add_21(sp_digit* r, const sp_digit* a,
  33135. const sp_digit b)
  33136. {
  33137. #ifdef WOLFSSL_SP_SMALL
  33138. sp_int64 tb = b;
  33139. sp_int64 t[4];
  33140. int i;
  33141. t[0] = 0;
  33142. for (i = 0; i < 20; i += 4) {
  33143. t[0] += (tb * a[i+0]) + r[i+0];
  33144. t[1] = (tb * a[i+1]) + r[i+1];
  33145. t[2] = (tb * a[i+2]) + r[i+2];
  33146. t[3] = (tb * a[i+3]) + r[i+3];
  33147. r[i+0] = t[0] & 0x1ffffff;
  33148. t[1] += t[0] >> 25;
  33149. r[i+1] = t[1] & 0x1ffffff;
  33150. t[2] += t[1] >> 25;
  33151. r[i+2] = t[2] & 0x1ffffff;
  33152. t[3] += t[2] >> 25;
  33153. r[i+3] = t[3] & 0x1ffffff;
  33154. t[0] = t[3] >> 25;
  33155. }
  33156. t[0] += (tb * a[20]) + r[20];
  33157. r[20] = t[0] & 0x1ffffff;
  33158. r[21] += (sp_digit)(t[0] >> 25);
  33159. #else
  33160. sp_int64 tb = b;
  33161. sp_int64 t[8];
  33162. int i;
  33163. t[0] = tb * a[0]; r[0] += (sp_digit)(t[0] & 0x1ffffff);
  33164. for (i = 0; i < 16; i += 8) {
  33165. t[1] = tb * a[i+1];
  33166. r[i+1] += (sp_digit)((t[0] >> 25) + (t[1] & 0x1ffffff));
  33167. t[2] = tb * a[i+2];
  33168. r[i+2] += (sp_digit)((t[1] >> 25) + (t[2] & 0x1ffffff));
  33169. t[3] = tb * a[i+3];
  33170. r[i+3] += (sp_digit)((t[2] >> 25) + (t[3] & 0x1ffffff));
  33171. t[4] = tb * a[i+4];
  33172. r[i+4] += (sp_digit)((t[3] >> 25) + (t[4] & 0x1ffffff));
  33173. t[5] = tb * a[i+5];
  33174. r[i+5] += (sp_digit)((t[4] >> 25) + (t[5] & 0x1ffffff));
  33175. t[6] = tb * a[i+6];
  33176. r[i+6] += (sp_digit)((t[5] >> 25) + (t[6] & 0x1ffffff));
  33177. t[7] = tb * a[i+7];
  33178. r[i+7] += (sp_digit)((t[6] >> 25) + (t[7] & 0x1ffffff));
  33179. t[0] = tb * a[i+8];
  33180. r[i+8] += (sp_digit)((t[7] >> 25) + (t[0] & 0x1ffffff));
  33181. }
  33182. t[1] = tb * a[17];
  33183. r[17] += (sp_digit)((t[0] >> 25) + (t[1] & 0x1ffffff));
  33184. t[2] = tb * a[18];
  33185. r[18] += (sp_digit)((t[1] >> 25) + (t[2] & 0x1ffffff));
  33186. t[3] = tb * a[19];
  33187. r[19] += (sp_digit)((t[2] >> 25) + (t[3] & 0x1ffffff));
  33188. t[4] = tb * a[20];
  33189. r[20] += (sp_digit)((t[3] >> 25) + (t[4] & 0x1ffffff));
  33190. r[21] += (sp_digit)(t[4] >> 25);
  33191. #endif /* WOLFSSL_SP_SMALL */
  33192. }
  33193. /* Shift the result in the high 521 bits down to the bottom.
  33194. *
  33195. * r A single precision number.
  33196. * a A single precision number.
  33197. */
  33198. static void sp_521_mont_shift_21(sp_digit* r, const sp_digit* a)
  33199. {
  33200. #ifdef WOLFSSL_SP_SMALL
  33201. int i;
  33202. sp_digit n;
  33203. sp_digit s;
  33204. s = a[21];
  33205. n = a[20] >> 21;
  33206. for (i = 0; i < 20; i++) {
  33207. n += (s & 0x1ffffff) << 4;
  33208. r[i] = n & 0x1ffffff;
  33209. n >>= 25;
  33210. s = a[22 + i] + (s >> 25);
  33211. }
  33212. n += s << 4;
  33213. r[20] = n;
  33214. #else
  33215. sp_digit n;
  33216. sp_digit s;
  33217. int i;
  33218. s = a[21]; n = a[20] >> 21;
  33219. for (i = 0; i < 16; i += 8) {
  33220. n += (s & 0x1ffffff) << 4; r[i+0] = n & 0x1ffffff;
  33221. n >>= 25; s = a[i+22] + (s >> 25);
  33222. n += (s & 0x1ffffff) << 4; r[i+1] = n & 0x1ffffff;
  33223. n >>= 25; s = a[i+23] + (s >> 25);
  33224. n += (s & 0x1ffffff) << 4; r[i+2] = n & 0x1ffffff;
  33225. n >>= 25; s = a[i+24] + (s >> 25);
  33226. n += (s & 0x1ffffff) << 4; r[i+3] = n & 0x1ffffff;
  33227. n >>= 25; s = a[i+25] + (s >> 25);
  33228. n += (s & 0x1ffffff) << 4; r[i+4] = n & 0x1ffffff;
  33229. n >>= 25; s = a[i+26] + (s >> 25);
  33230. n += (s & 0x1ffffff) << 4; r[i+5] = n & 0x1ffffff;
  33231. n >>= 25; s = a[i+27] + (s >> 25);
  33232. n += (s & 0x1ffffff) << 4; r[i+6] = n & 0x1ffffff;
  33233. n >>= 25; s = a[i+28] + (s >> 25);
  33234. n += (s & 0x1ffffff) << 4; r[i+7] = n & 0x1ffffff;
  33235. n >>= 25; s = a[i+29] + (s >> 25);
  33236. }
  33237. n += (s & 0x1ffffff) << 4; r[16] = n & 0x1ffffff;
  33238. n >>= 25; s = a[38] + (s >> 25);
  33239. n += (s & 0x1ffffff) << 4; r[17] = n & 0x1ffffff;
  33240. n >>= 25; s = a[39] + (s >> 25);
  33241. n += (s & 0x1ffffff) << 4; r[18] = n & 0x1ffffff;
  33242. n >>= 25; s = a[40] + (s >> 25);
  33243. n += (s & 0x1ffffff) << 4; r[19] = n & 0x1ffffff;
  33244. n >>= 25; s = a[41] + (s >> 25);
  33245. n += s << 4; r[20] = n;
  33246. #endif /* WOLFSSL_SP_SMALL */
  33247. XMEMSET(&r[21], 0, sizeof(*r) * 21U);
  33248. }
  33249. /* Reduce the number back to 521 bits using Montgomery reduction.
  33250. *
  33251. * a A single precision number to reduce in place.
  33252. * m The single precision number representing the modulus.
  33253. * mp The digit representing the negative inverse of m mod 2^n.
  33254. */
  33255. static void sp_521_mont_reduce_order_21(sp_digit* a, const sp_digit* m, sp_digit mp)
  33256. {
  33257. int i;
  33258. sp_digit mu;
  33259. sp_digit over;
  33260. sp_521_norm_21(a + 21);
  33261. for (i=0; i<20; i++) {
  33262. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1ffffff;
  33263. sp_521_mul_add_21(a+i, m, mu);
  33264. a[i+1] += a[i] >> 25;
  33265. }
  33266. mu = ((sp_uint32)a[i] * (sp_uint32)mp) & 0x1fffffL;
  33267. sp_521_mul_add_21(a+i, m, mu);
  33268. a[i+1] += a[i] >> 25;
  33269. a[i] &= 0x1ffffff;
  33270. sp_521_mont_shift_21(a, a);
  33271. over = a[20] >> 21;
  33272. sp_521_cond_sub_21(a, a, m, ~((over - 1) >> 31));
  33273. sp_521_norm_21(a);
  33274. }
  33275. /* Multiply two Montgomery form numbers mod the modulus (prime).
  33276. * (r = a * b mod m)
  33277. *
  33278. * r Result of multiplication.
  33279. * a First number to multiply in Montgomery form.
  33280. * b Second number to multiply in Montgomery form.
  33281. * m Modulus (prime).
  33282. * mp Montgomery multiplier.
  33283. */
  33284. SP_NOINLINE static void sp_521_mont_mul_21(sp_digit* r, const sp_digit* a,
  33285. const sp_digit* b, const sp_digit* m, sp_digit mp)
  33286. {
  33287. sp_521_mul_21(r, a, b);
  33288. sp_521_mont_reduce_21(r, m, mp);
  33289. }
  33290. /* Square the Montgomery form number. (r = a * a mod m)
  33291. *
  33292. * r Result of squaring.
  33293. * a Number to square in Montgomery form.
  33294. * m Modulus (prime).
  33295. * mp Montgomery multiplier.
  33296. */
  33297. SP_NOINLINE static void sp_521_mont_sqr_21(sp_digit* r, const sp_digit* a,
  33298. const sp_digit* m, sp_digit mp)
  33299. {
  33300. sp_521_sqr_21(r, a);
  33301. sp_521_mont_reduce_21(r, m, mp);
  33302. }
  33303. #ifndef WOLFSSL_SP_SMALL
  33304. /* Square the Montgomery form number a number of times. (r = a ^ n mod m)
  33305. *
  33306. * r Result of squaring.
  33307. * a Number to square in Montgomery form.
  33308. * n Number of times to square.
  33309. * m Modulus (prime).
  33310. * mp Montgomery multiplier.
  33311. */
  33312. SP_NOINLINE static void sp_521_mont_sqr_n_21(sp_digit* r,
  33313. const sp_digit* a, int n, const sp_digit* m, sp_digit mp)
  33314. {
  33315. sp_521_mont_sqr_21(r, a, m, mp);
  33316. for (; n > 1; n--) {
  33317. sp_521_mont_sqr_21(r, r, m, mp);
  33318. }
  33319. }
  33320. #endif /* !WOLFSSL_SP_SMALL */
  33321. #ifdef WOLFSSL_SP_SMALL
  33322. /* Mod-2 for the P521 curve. */
  33323. static const uint32_t p521_mod_minus_2[17] = {
  33324. 0xfffffffdU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,
  33325. 0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,
  33326. 0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0x000001ffU
  33327. };
  33328. #endif /* !WOLFSSL_SP_SMALL */
  33329. /* Invert the number, in Montgomery form, modulo the modulus (prime) of the
  33330. * P521 curve. (r = 1 / a mod m)
  33331. *
  33332. * r Inverse result.
  33333. * a Number to invert.
  33334. * td Temporary data.
  33335. */
  33336. static void sp_521_mont_inv_21(sp_digit* r, const sp_digit* a, sp_digit* td)
  33337. {
  33338. #ifdef WOLFSSL_SP_SMALL
  33339. sp_digit* t = td;
  33340. int i;
  33341. XMEMCPY(t, a, sizeof(sp_digit) * 21);
  33342. for (i=519; i>=0; i--) {
  33343. sp_521_mont_sqr_21(t, t, p521_mod, p521_mp_mod);
  33344. if (p521_mod_minus_2[i / 32] & ((sp_digit)1 << (i % 32)))
  33345. sp_521_mont_mul_21(t, t, a, p521_mod, p521_mp_mod);
  33346. }
  33347. XMEMCPY(r, t, sizeof(sp_digit) * 21);
  33348. #else
  33349. sp_digit* t1 = td;
  33350. sp_digit* t2 = td + 2 * 21;
  33351. sp_digit* t3 = td + 4 * 21;
  33352. /* 0x2 */
  33353. sp_521_mont_sqr_21(t1, a, p521_mod, p521_mp_mod);
  33354. /* 0x3 */
  33355. sp_521_mont_mul_21(t2, t1, a, p521_mod, p521_mp_mod);
  33356. /* 0x6 */
  33357. sp_521_mont_sqr_21(t1, t2, p521_mod, p521_mp_mod);
  33358. /* 0x7 */
  33359. sp_521_mont_mul_21(t3, t1, a, p521_mod, p521_mp_mod);
  33360. /* 0xc */
  33361. sp_521_mont_sqr_n_21(t1, t2, 2, p521_mod, p521_mp_mod);
  33362. /* 0xf */
  33363. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33364. /* 0x78 */
  33365. sp_521_mont_sqr_n_21(t1, t2, 3, p521_mod, p521_mp_mod);
  33366. /* 0x7f */
  33367. sp_521_mont_mul_21(t3, t3, t1, p521_mod, p521_mp_mod);
  33368. /* 0xf0 */
  33369. sp_521_mont_sqr_n_21(t1, t2, 4, p521_mod, p521_mp_mod);
  33370. /* 0xff */
  33371. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33372. /* 0xff00 */
  33373. sp_521_mont_sqr_n_21(t1, t2, 8, p521_mod, p521_mp_mod);
  33374. /* 0xffff */
  33375. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33376. /* 0xffff0000 */
  33377. sp_521_mont_sqr_n_21(t1, t2, 16, p521_mod, p521_mp_mod);
  33378. /* 0xffffffff */
  33379. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33380. /* 0xffffffff00000000 */
  33381. sp_521_mont_sqr_n_21(t1, t2, 32, p521_mod, p521_mp_mod);
  33382. /* 0xffffffffffffffff */
  33383. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33384. /* 0xffffffffffffffff0000000000000000 */
  33385. sp_521_mont_sqr_n_21(t1, t2, 64, p521_mod, p521_mp_mod);
  33386. /* 0xffffffffffffffffffffffffffffffff */
  33387. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33388. /* 0xffffffffffffffffffffffffffffffff00000000000000000000000000000000 */
  33389. sp_521_mont_sqr_n_21(t1, t2, 128, p521_mod, p521_mp_mod);
  33390. /* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  33391. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33392. /* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000 */
  33393. sp_521_mont_sqr_n_21(t1, t2, 256, p521_mod, p521_mp_mod);
  33394. /* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  33395. sp_521_mont_mul_21(t2, t2, t1, p521_mod, p521_mp_mod);
  33396. /* 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80 */
  33397. sp_521_mont_sqr_n_21(t1, t2, 7, p521_mod, p521_mp_mod);
  33398. /* 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff */
  33399. sp_521_mont_mul_21(t2, t3, t1, p521_mod, p521_mp_mod);
  33400. /* 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc */
  33401. sp_521_mont_sqr_n_21(t1, t2, 2, p521_mod, p521_mp_mod);
  33402. /* 0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd */
  33403. sp_521_mont_mul_21(r, t1, a, p521_mod, p521_mp_mod);
  33404. #endif /* WOLFSSL_SP_SMALL */
  33405. }
  33406. /* Map the Montgomery form projective coordinate point to an affine point.
  33407. *
  33408. * r Resulting affine coordinate point.
  33409. * p Montgomery form projective coordinate point.
  33410. * t Temporary ordinate data.
  33411. */
  33412. static void sp_521_map_21(sp_point_521* r, const sp_point_521* p,
  33413. sp_digit* t)
  33414. {
  33415. sp_digit* t1 = t;
  33416. sp_digit* t2 = t + 2*21;
  33417. sp_int32 n;
  33418. sp_521_mont_inv_21(t1, p->z, t + 2*21);
  33419. sp_521_mont_sqr_21(t2, t1, p521_mod, p521_mp_mod);
  33420. sp_521_mont_mul_21(t1, t2, t1, p521_mod, p521_mp_mod);
  33421. /* x /= z^2 */
  33422. sp_521_mont_mul_21(r->x, p->x, t2, p521_mod, p521_mp_mod);
  33423. XMEMSET(r->x + 21, 0, sizeof(sp_digit) * 21U);
  33424. sp_521_mont_reduce_21(r->x, p521_mod, p521_mp_mod);
  33425. /* Reduce x to less than modulus */
  33426. n = sp_521_cmp_21(r->x, p521_mod);
  33427. sp_521_cond_sub_21(r->x, r->x, p521_mod, ~(n >> 24));
  33428. sp_521_norm_21(r->x);
  33429. /* y /= z^3 */
  33430. sp_521_mont_mul_21(r->y, p->y, t1, p521_mod, p521_mp_mod);
  33431. XMEMSET(r->y + 21, 0, sizeof(sp_digit) * 21U);
  33432. sp_521_mont_reduce_21(r->y, p521_mod, p521_mp_mod);
  33433. /* Reduce y to less than modulus */
  33434. n = sp_521_cmp_21(r->y, p521_mod);
  33435. sp_521_cond_sub_21(r->y, r->y, p521_mod, ~(n >> 24));
  33436. sp_521_norm_21(r->y);
  33437. XMEMSET(r->z, 0, sizeof(r->z) / 2);
  33438. r->z[0] = 1;
  33439. }
  33440. /* Add two Montgomery form numbers (r = a + b % m).
  33441. *
  33442. * r Result of addition.
  33443. * a First number to add in Montgomery form.
  33444. * b Second number to add in Montgomery form.
  33445. * m Modulus (prime).
  33446. */
  33447. static void sp_521_mont_add_21(sp_digit* r, const sp_digit* a, const sp_digit* b,
  33448. const sp_digit* m)
  33449. {
  33450. sp_digit over;
  33451. (void)sp_521_add_21(r, a, b);
  33452. sp_521_norm_21(r);
  33453. over = r[20] >> 21;
  33454. sp_521_cond_sub_21(r, r, m, ~((over - 1) >> 31));
  33455. sp_521_norm_21(r);
  33456. }
  33457. /* Double a Montgomery form number (r = a + a % m).
  33458. *
  33459. * r Result of doubling.
  33460. * a Number to double in Montgomery form.
  33461. * m Modulus (prime).
  33462. */
  33463. static void sp_521_mont_dbl_21(sp_digit* r, const sp_digit* a, const sp_digit* m)
  33464. {
  33465. sp_digit over;
  33466. (void)sp_521_add_21(r, a, a);
  33467. sp_521_norm_21(r);
  33468. over = r[20] >> 21;
  33469. sp_521_cond_sub_21(r, r, m, ~((over - 1) >> 31));
  33470. sp_521_norm_21(r);
  33471. }
  33472. /* Triple a Montgomery form number (r = a + a + a % m).
  33473. *
  33474. * r Result of Tripling.
  33475. * a Number to triple in Montgomery form.
  33476. * m Modulus (prime).
  33477. */
  33478. static void sp_521_mont_tpl_21(sp_digit* r, const sp_digit* a, const sp_digit* m)
  33479. {
  33480. sp_digit over;
  33481. (void)sp_521_add_21(r, a, a);
  33482. sp_521_norm_21(r);
  33483. over = r[20] >> 21;
  33484. sp_521_cond_sub_21(r, r, m, ~((over - 1) >> 31));
  33485. sp_521_norm_21(r);
  33486. (void)sp_521_add_21(r, r, a);
  33487. sp_521_norm_21(r);
  33488. over = r[20] >> 21;
  33489. sp_521_cond_sub_21(r, r, m, ~((over - 1) >> 31));
  33490. sp_521_norm_21(r);
  33491. }
  33492. #ifdef WOLFSSL_SP_SMALL
  33493. /* Conditionally add a and b using the mask m.
  33494. * m is -1 to add and 0 when not.
  33495. *
  33496. * r A single precision number representing conditional add result.
  33497. * a A single precision number to add with.
  33498. * b A single precision number to add.
  33499. * m Mask value to apply.
  33500. */
  33501. static void sp_521_cond_add_21(sp_digit* r, const sp_digit* a,
  33502. const sp_digit* b, const sp_digit m)
  33503. {
  33504. int i;
  33505. for (i = 0; i < 21; i++) {
  33506. r[i] = a[i] + (b[i] & m);
  33507. }
  33508. }
  33509. #endif /* WOLFSSL_SP_SMALL */
  33510. #ifndef WOLFSSL_SP_SMALL
  33511. /* Conditionally add a and b using the mask m.
  33512. * m is -1 to add and 0 when not.
  33513. *
  33514. * r A single precision number representing conditional add result.
  33515. * a A single precision number to add with.
  33516. * b A single precision number to add.
  33517. * m Mask value to apply.
  33518. */
  33519. static void sp_521_cond_add_21(sp_digit* r, const sp_digit* a,
  33520. const sp_digit* b, const sp_digit m)
  33521. {
  33522. int i;
  33523. for (i = 0; i < 16; i += 8) {
  33524. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  33525. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  33526. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  33527. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  33528. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  33529. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  33530. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  33531. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  33532. }
  33533. r[16] = a[16] + (b[16] & m);
  33534. r[17] = a[17] + (b[17] & m);
  33535. r[18] = a[18] + (b[18] & m);
  33536. r[19] = a[19] + (b[19] & m);
  33537. r[20] = a[20] + (b[20] & m);
  33538. }
  33539. #endif /* !WOLFSSL_SP_SMALL */
  33540. /* Subtract two Montgomery form numbers (r = a - b % m).
  33541. *
  33542. * r Result of subtration.
  33543. * a Number to subtract from in Montgomery form.
  33544. * b Number to subtract with in Montgomery form.
  33545. * m Modulus (prime).
  33546. */
  33547. static void sp_521_mont_sub_21(sp_digit* r, const sp_digit* a, const sp_digit* b,
  33548. const sp_digit* m)
  33549. {
  33550. (void)sp_521_sub_21(r, a, b);
  33551. sp_521_norm_21(r);
  33552. sp_521_cond_add_21(r, r, m, r[20] >> 21);
  33553. sp_521_norm_21(r);
  33554. }
  33555. /* Shift number left one bit.
  33556. * Bottom bit is lost.
  33557. *
  33558. * r Result of shift.
  33559. * a Number to shift.
  33560. */
  33561. SP_NOINLINE static void sp_521_rshift1_21(sp_digit* r, const sp_digit* a)
  33562. {
  33563. #ifdef WOLFSSL_SP_SMALL
  33564. int i;
  33565. for (i=0; i<20; i++) {
  33566. r[i] = (a[i] >> 1) + ((a[i + 1] << 24) & 0x1ffffff);
  33567. }
  33568. #else
  33569. r[0] = (a[0] >> 1) + ((a[1] << 24) & 0x1ffffff);
  33570. r[1] = (a[1] >> 1) + ((a[2] << 24) & 0x1ffffff);
  33571. r[2] = (a[2] >> 1) + ((a[3] << 24) & 0x1ffffff);
  33572. r[3] = (a[3] >> 1) + ((a[4] << 24) & 0x1ffffff);
  33573. r[4] = (a[4] >> 1) + ((a[5] << 24) & 0x1ffffff);
  33574. r[5] = (a[5] >> 1) + ((a[6] << 24) & 0x1ffffff);
  33575. r[6] = (a[6] >> 1) + ((a[7] << 24) & 0x1ffffff);
  33576. r[7] = (a[7] >> 1) + ((a[8] << 24) & 0x1ffffff);
  33577. r[8] = (a[8] >> 1) + ((a[9] << 24) & 0x1ffffff);
  33578. r[9] = (a[9] >> 1) + ((a[10] << 24) & 0x1ffffff);
  33579. r[10] = (a[10] >> 1) + ((a[11] << 24) & 0x1ffffff);
  33580. r[11] = (a[11] >> 1) + ((a[12] << 24) & 0x1ffffff);
  33581. r[12] = (a[12] >> 1) + ((a[13] << 24) & 0x1ffffff);
  33582. r[13] = (a[13] >> 1) + ((a[14] << 24) & 0x1ffffff);
  33583. r[14] = (a[14] >> 1) + ((a[15] << 24) & 0x1ffffff);
  33584. r[15] = (a[15] >> 1) + ((a[16] << 24) & 0x1ffffff);
  33585. r[16] = (a[16] >> 1) + ((a[17] << 24) & 0x1ffffff);
  33586. r[17] = (a[17] >> 1) + ((a[18] << 24) & 0x1ffffff);
  33587. r[18] = (a[18] >> 1) + ((a[19] << 24) & 0x1ffffff);
  33588. r[19] = (a[19] >> 1) + ((a[20] << 24) & 0x1ffffff);
  33589. #endif
  33590. r[20] = a[20] >> 1;
  33591. }
  33592. /* Divide the number by 2 mod the modulus (prime). (r = a / 2 % m)
  33593. *
  33594. * r Result of division by 2.
  33595. * a Number to divide.
  33596. * m Modulus (prime).
  33597. */
  33598. static void sp_521_mont_div2_21(sp_digit* r, const sp_digit* a,
  33599. const sp_digit* m)
  33600. {
  33601. sp_521_cond_add_21(r, a, m, 0 - (a[0] & 1));
  33602. sp_521_norm_21(r);
  33603. sp_521_rshift1_21(r, r);
  33604. }
  33605. /* Double the Montgomery form projective point p.
  33606. *
  33607. * r Result of doubling point.
  33608. * p Point to double.
  33609. * t Temporary ordinate data.
  33610. */
  33611. static void sp_521_proj_point_dbl_21(sp_point_521* r, const sp_point_521* p,
  33612. sp_digit* t)
  33613. {
  33614. sp_digit* t1 = t;
  33615. sp_digit* t2 = t + 2*21;
  33616. sp_digit* x;
  33617. sp_digit* y;
  33618. sp_digit* z;
  33619. x = r->x;
  33620. y = r->y;
  33621. z = r->z;
  33622. /* Put infinity into result. */
  33623. if (r != p) {
  33624. r->infinity = p->infinity;
  33625. }
  33626. /* T1 = Z * Z */
  33627. sp_521_mont_sqr_21(t1, p->z, p521_mod, p521_mp_mod);
  33628. /* Z = Y * Z */
  33629. sp_521_mont_mul_21(z, p->y, p->z, p521_mod, p521_mp_mod);
  33630. /* Z = 2Z */
  33631. sp_521_mont_dbl_21(z, z, p521_mod);
  33632. /* T2 = X - T1 */
  33633. sp_521_mont_sub_21(t2, p->x, t1, p521_mod);
  33634. /* T1 = X + T1 */
  33635. sp_521_mont_add_21(t1, p->x, t1, p521_mod);
  33636. /* T2 = T1 * T2 */
  33637. sp_521_mont_mul_21(t2, t1, t2, p521_mod, p521_mp_mod);
  33638. /* T1 = 3T2 */
  33639. sp_521_mont_tpl_21(t1, t2, p521_mod);
  33640. /* Y = 2Y */
  33641. sp_521_mont_dbl_21(y, p->y, p521_mod);
  33642. /* Y = Y * Y */
  33643. sp_521_mont_sqr_21(y, y, p521_mod, p521_mp_mod);
  33644. /* T2 = Y * Y */
  33645. sp_521_mont_sqr_21(t2, y, p521_mod, p521_mp_mod);
  33646. /* T2 = T2/2 */
  33647. sp_521_mont_div2_21(t2, t2, p521_mod);
  33648. /* Y = Y * X */
  33649. sp_521_mont_mul_21(y, y, p->x, p521_mod, p521_mp_mod);
  33650. /* X = T1 * T1 */
  33651. sp_521_mont_sqr_21(x, t1, p521_mod, p521_mp_mod);
  33652. /* X = X - Y */
  33653. sp_521_mont_sub_21(x, x, y, p521_mod);
  33654. /* X = X - Y */
  33655. sp_521_mont_sub_21(x, x, y, p521_mod);
  33656. /* Y = Y - X */
  33657. sp_521_mont_sub_21(y, y, x, p521_mod);
  33658. /* Y = Y * T1 */
  33659. sp_521_mont_mul_21(y, y, t1, p521_mod, p521_mp_mod);
  33660. /* Y = Y - T2 */
  33661. sp_521_mont_sub_21(y, y, t2, p521_mod);
  33662. }
  33663. #ifdef WOLFSSL_SP_NONBLOCK
  33664. typedef struct sp_521_proj_point_dbl_21_ctx {
  33665. int state;
  33666. sp_digit* t1;
  33667. sp_digit* t2;
  33668. sp_digit* x;
  33669. sp_digit* y;
  33670. sp_digit* z;
  33671. } sp_521_proj_point_dbl_21_ctx;
  33672. /* Double the Montgomery form projective point p.
  33673. *
  33674. * r Result of doubling point.
  33675. * p Point to double.
  33676. * t Temporary ordinate data.
  33677. */
  33678. static int sp_521_proj_point_dbl_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
  33679. const sp_point_521* p, sp_digit* t)
  33680. {
  33681. int err = FP_WOULDBLOCK;
  33682. sp_521_proj_point_dbl_21_ctx* ctx = (sp_521_proj_point_dbl_21_ctx*)sp_ctx->data;
  33683. typedef char ctx_size_test[sizeof(sp_521_proj_point_dbl_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  33684. (void)sizeof(ctx_size_test);
  33685. switch (ctx->state) {
  33686. case 0:
  33687. ctx->t1 = t;
  33688. ctx->t2 = t + 2*21;
  33689. ctx->x = r->x;
  33690. ctx->y = r->y;
  33691. ctx->z = r->z;
  33692. /* Put infinity into result. */
  33693. if (r != p) {
  33694. r->infinity = p->infinity;
  33695. }
  33696. ctx->state = 1;
  33697. break;
  33698. case 1:
  33699. /* T1 = Z * Z */
  33700. sp_521_mont_sqr_21(ctx->t1, p->z, p521_mod, p521_mp_mod);
  33701. ctx->state = 2;
  33702. break;
  33703. case 2:
  33704. /* Z = Y * Z */
  33705. sp_521_mont_mul_21(ctx->z, p->y, p->z, p521_mod, p521_mp_mod);
  33706. ctx->state = 3;
  33707. break;
  33708. case 3:
  33709. /* Z = 2Z */
  33710. sp_521_mont_dbl_21(ctx->z, ctx->z, p521_mod);
  33711. ctx->state = 4;
  33712. break;
  33713. case 4:
  33714. /* T2 = X - T1 */
  33715. sp_521_mont_sub_21(ctx->t2, p->x, ctx->t1, p521_mod);
  33716. ctx->state = 5;
  33717. break;
  33718. case 5:
  33719. /* T1 = X + T1 */
  33720. sp_521_mont_add_21(ctx->t1, p->x, ctx->t1, p521_mod);
  33721. ctx->state = 6;
  33722. break;
  33723. case 6:
  33724. /* T2 = T1 * T2 */
  33725. sp_521_mont_mul_21(ctx->t2, ctx->t1, ctx->t2, p521_mod, p521_mp_mod);
  33726. ctx->state = 7;
  33727. break;
  33728. case 7:
  33729. /* T1 = 3T2 */
  33730. sp_521_mont_tpl_21(ctx->t1, ctx->t2, p521_mod);
  33731. ctx->state = 8;
  33732. break;
  33733. case 8:
  33734. /* Y = 2Y */
  33735. sp_521_mont_dbl_21(ctx->y, p->y, p521_mod);
  33736. ctx->state = 9;
  33737. break;
  33738. case 9:
  33739. /* Y = Y * Y */
  33740. sp_521_mont_sqr_21(ctx->y, ctx->y, p521_mod, p521_mp_mod);
  33741. ctx->state = 10;
  33742. break;
  33743. case 10:
  33744. /* T2 = Y * Y */
  33745. sp_521_mont_sqr_21(ctx->t2, ctx->y, p521_mod, p521_mp_mod);
  33746. ctx->state = 11;
  33747. break;
  33748. case 11:
  33749. /* T2 = T2/2 */
  33750. sp_521_mont_div2_21(ctx->t2, ctx->t2, p521_mod);
  33751. ctx->state = 12;
  33752. break;
  33753. case 12:
  33754. /* Y = Y * X */
  33755. sp_521_mont_mul_21(ctx->y, ctx->y, p->x, p521_mod, p521_mp_mod);
  33756. ctx->state = 13;
  33757. break;
  33758. case 13:
  33759. /* X = T1 * T1 */
  33760. sp_521_mont_sqr_21(ctx->x, ctx->t1, p521_mod, p521_mp_mod);
  33761. ctx->state = 14;
  33762. break;
  33763. case 14:
  33764. /* X = X - Y */
  33765. sp_521_mont_sub_21(ctx->x, ctx->x, ctx->y, p521_mod);
  33766. ctx->state = 15;
  33767. break;
  33768. case 15:
  33769. /* X = X - Y */
  33770. sp_521_mont_sub_21(ctx->x, ctx->x, ctx->y, p521_mod);
  33771. ctx->state = 16;
  33772. break;
  33773. case 16:
  33774. /* Y = Y - X */
  33775. sp_521_mont_sub_21(ctx->y, ctx->y, ctx->x, p521_mod);
  33776. ctx->state = 17;
  33777. break;
  33778. case 17:
  33779. /* Y = Y * T1 */
  33780. sp_521_mont_mul_21(ctx->y, ctx->y, ctx->t1, p521_mod, p521_mp_mod);
  33781. ctx->state = 18;
  33782. break;
  33783. case 18:
  33784. /* Y = Y - T2 */
  33785. sp_521_mont_sub_21(ctx->y, ctx->y, ctx->t2, p521_mod);
  33786. ctx->state = 19;
  33787. /* fall-through */
  33788. case 19:
  33789. err = MP_OKAY;
  33790. break;
  33791. }
  33792. if (err == MP_OKAY && ctx->state != 19) {
  33793. err = FP_WOULDBLOCK;
  33794. }
  33795. return err;
  33796. }
  33797. #endif /* WOLFSSL_SP_NONBLOCK */
  33798. /* Compare two numbers to determine if they are equal.
  33799. * Constant time implementation.
  33800. *
  33801. * a First number to compare.
  33802. * b Second number to compare.
  33803. * returns 1 when equal and 0 otherwise.
  33804. */
  33805. static int sp_521_cmp_equal_21(const sp_digit* a, const sp_digit* b)
  33806. {
  33807. return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
  33808. (a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
  33809. (a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
  33810. (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
  33811. (a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
  33812. (a[15] ^ b[15]) | (a[16] ^ b[16]) | (a[17] ^ b[17]) |
  33813. (a[18] ^ b[18]) | (a[19] ^ b[19]) | (a[20] ^ b[20])) == 0;
  33814. }
  33815. /* Returns 1 if the number of zero.
  33816. * Implementation is constant time.
  33817. *
  33818. * a Number to check.
  33819. * returns 1 if the number is zero and 0 otherwise.
  33820. */
  33821. static int sp_521_iszero_21(const sp_digit* a)
  33822. {
  33823. return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7] |
  33824. a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15] |
  33825. a[16] | a[17] | a[18] | a[19] | a[20]) == 0;
  33826. }
  33827. /* Add two Montgomery form projective points.
  33828. *
  33829. * r Result of addition.
  33830. * p First point to add.
  33831. * q Second point to add.
  33832. * t Temporary ordinate data.
  33833. */
  33834. static void sp_521_proj_point_add_21(sp_point_521* r,
  33835. const sp_point_521* p, const sp_point_521* q, sp_digit* t)
  33836. {
  33837. sp_digit* t6 = t;
  33838. sp_digit* t1 = t + 2*21;
  33839. sp_digit* t2 = t + 4*21;
  33840. sp_digit* t3 = t + 6*21;
  33841. sp_digit* t4 = t + 8*21;
  33842. sp_digit* t5 = t + 10*21;
  33843. /* U1 = X1*Z2^2 */
  33844. sp_521_mont_sqr_21(t1, q->z, p521_mod, p521_mp_mod);
  33845. sp_521_mont_mul_21(t3, t1, q->z, p521_mod, p521_mp_mod);
  33846. sp_521_mont_mul_21(t1, t1, p->x, p521_mod, p521_mp_mod);
  33847. /* U2 = X2*Z1^2 */
  33848. sp_521_mont_sqr_21(t2, p->z, p521_mod, p521_mp_mod);
  33849. sp_521_mont_mul_21(t4, t2, p->z, p521_mod, p521_mp_mod);
  33850. sp_521_mont_mul_21(t2, t2, q->x, p521_mod, p521_mp_mod);
  33851. /* S1 = Y1*Z2^3 */
  33852. sp_521_mont_mul_21(t3, t3, p->y, p521_mod, p521_mp_mod);
  33853. /* S2 = Y2*Z1^3 */
  33854. sp_521_mont_mul_21(t4, t4, q->y, p521_mod, p521_mp_mod);
  33855. /* Check double */
  33856. if ((~p->infinity) & (~q->infinity) &
  33857. sp_521_cmp_equal_21(t2, t1) &
  33858. sp_521_cmp_equal_21(t4, t3)) {
  33859. sp_521_proj_point_dbl_21(r, p, t);
  33860. }
  33861. else {
  33862. sp_digit* x = t6;
  33863. sp_digit* y = t1;
  33864. sp_digit* z = t2;
  33865. /* H = U2 - U1 */
  33866. sp_521_mont_sub_21(t2, t2, t1, p521_mod);
  33867. /* R = S2 - S1 */
  33868. sp_521_mont_sub_21(t4, t4, t3, p521_mod);
  33869. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  33870. sp_521_mont_sqr_21(t5, t2, p521_mod, p521_mp_mod);
  33871. sp_521_mont_mul_21(y, t1, t5, p521_mod, p521_mp_mod);
  33872. sp_521_mont_mul_21(t5, t5, t2, p521_mod, p521_mp_mod);
  33873. /* Z3 = H*Z1*Z2 */
  33874. sp_521_mont_mul_21(z, p->z, t2, p521_mod, p521_mp_mod);
  33875. sp_521_mont_mul_21(z, z, q->z, p521_mod, p521_mp_mod);
  33876. sp_521_mont_sqr_21(x, t4, p521_mod, p521_mp_mod);
  33877. sp_521_mont_sub_21(x, x, t5, p521_mod);
  33878. sp_521_mont_mul_21(t5, t5, t3, p521_mod, p521_mp_mod);
  33879. sp_521_mont_dbl_21(t3, y, p521_mod);
  33880. sp_521_mont_sub_21(x, x, t3, p521_mod);
  33881. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  33882. sp_521_mont_sub_21(y, y, x, p521_mod);
  33883. sp_521_mont_mul_21(y, y, t4, p521_mod, p521_mp_mod);
  33884. sp_521_mont_sub_21(y, y, t5, p521_mod);
  33885. {
  33886. int i;
  33887. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  33888. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  33889. sp_digit maskt = ~(maskp | maskq);
  33890. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  33891. for (i = 0; i < 21; i++) {
  33892. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  33893. (x[i] & maskt);
  33894. }
  33895. for (i = 0; i < 21; i++) {
  33896. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  33897. (y[i] & maskt);
  33898. }
  33899. for (i = 0; i < 21; i++) {
  33900. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  33901. (z[i] & maskt);
  33902. }
  33903. r->z[0] |= inf;
  33904. r->infinity = (word32)inf;
  33905. }
  33906. }
  33907. }
  33908. #ifdef WOLFSSL_SP_NONBLOCK
  33909. typedef struct sp_521_proj_point_add_21_ctx {
  33910. int state;
  33911. sp_521_proj_point_dbl_21_ctx dbl_ctx;
  33912. const sp_point_521* ap[2];
  33913. sp_point_521* rp[2];
  33914. sp_digit* t1;
  33915. sp_digit* t2;
  33916. sp_digit* t3;
  33917. sp_digit* t4;
  33918. sp_digit* t5;
  33919. sp_digit* t6;
  33920. sp_digit* x;
  33921. sp_digit* y;
  33922. sp_digit* z;
  33923. } sp_521_proj_point_add_21_ctx;
  33924. /* Add two Montgomery form projective points.
  33925. *
  33926. * r Result of addition.
  33927. * p First point to add.
  33928. * q Second point to add.
  33929. * t Temporary ordinate data.
  33930. */
  33931. static int sp_521_proj_point_add_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
  33932. const sp_point_521* p, const sp_point_521* q, sp_digit* t)
  33933. {
  33934. int err = FP_WOULDBLOCK;
  33935. sp_521_proj_point_add_21_ctx* ctx = (sp_521_proj_point_add_21_ctx*)sp_ctx->data;
  33936. /* Ensure only the first point is the same as the result. */
  33937. if (q == r) {
  33938. const sp_point_521* a = p;
  33939. p = q;
  33940. q = a;
  33941. }
  33942. typedef char ctx_size_test[sizeof(sp_521_proj_point_add_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  33943. (void)sizeof(ctx_size_test);
  33944. switch (ctx->state) {
  33945. case 0: /* INIT */
  33946. ctx->t6 = t;
  33947. ctx->t1 = t + 2*21;
  33948. ctx->t2 = t + 4*21;
  33949. ctx->t3 = t + 6*21;
  33950. ctx->t4 = t + 8*21;
  33951. ctx->t5 = t + 10*21;
  33952. ctx->x = ctx->t6;
  33953. ctx->y = ctx->t1;
  33954. ctx->z = ctx->t2;
  33955. ctx->state = 1;
  33956. break;
  33957. case 1:
  33958. /* U1 = X1*Z2^2 */
  33959. sp_521_mont_sqr_21(ctx->t1, q->z, p521_mod, p521_mp_mod);
  33960. ctx->state = 2;
  33961. break;
  33962. case 2:
  33963. sp_521_mont_mul_21(ctx->t3, ctx->t1, q->z, p521_mod, p521_mp_mod);
  33964. ctx->state = 3;
  33965. break;
  33966. case 3:
  33967. sp_521_mont_mul_21(ctx->t1, ctx->t1, p->x, p521_mod, p521_mp_mod);
  33968. ctx->state = 4;
  33969. break;
  33970. case 4:
  33971. /* U2 = X2*Z1^2 */
  33972. sp_521_mont_sqr_21(ctx->t2, p->z, p521_mod, p521_mp_mod);
  33973. ctx->state = 5;
  33974. break;
  33975. case 5:
  33976. sp_521_mont_mul_21(ctx->t4, ctx->t2, p->z, p521_mod, p521_mp_mod);
  33977. ctx->state = 6;
  33978. break;
  33979. case 6:
  33980. sp_521_mont_mul_21(ctx->t2, ctx->t2, q->x, p521_mod, p521_mp_mod);
  33981. ctx->state = 7;
  33982. break;
  33983. case 7:
  33984. /* S1 = Y1*Z2^3 */
  33985. sp_521_mont_mul_21(ctx->t3, ctx->t3, p->y, p521_mod, p521_mp_mod);
  33986. ctx->state = 8;
  33987. break;
  33988. case 8:
  33989. /* S2 = Y2*Z1^3 */
  33990. sp_521_mont_mul_21(ctx->t4, ctx->t4, q->y, p521_mod, p521_mp_mod);
  33991. ctx->state = 9;
  33992. break;
  33993. case 9:
  33994. /* Check double */
  33995. if ((~p->infinity) & (~q->infinity) &
  33996. sp_521_cmp_equal_21(ctx->t2, ctx->t1) &
  33997. sp_521_cmp_equal_21(ctx->t4, ctx->t3)) {
  33998. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  33999. sp_521_proj_point_dbl_21(r, p, t);
  34000. ctx->state = 25;
  34001. }
  34002. else {
  34003. ctx->state = 10;
  34004. }
  34005. break;
  34006. case 10:
  34007. /* H = U2 - U1 */
  34008. sp_521_mont_sub_21(ctx->t2, ctx->t2, ctx->t1, p521_mod);
  34009. ctx->state = 11;
  34010. break;
  34011. case 11:
  34012. /* R = S2 - S1 */
  34013. sp_521_mont_sub_21(ctx->t4, ctx->t4, ctx->t3, p521_mod);
  34014. ctx->state = 12;
  34015. break;
  34016. case 12:
  34017. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  34018. sp_521_mont_sqr_21(ctx->t5, ctx->t2, p521_mod, p521_mp_mod);
  34019. ctx->state = 13;
  34020. break;
  34021. case 13:
  34022. sp_521_mont_mul_21(ctx->y, ctx->t1, ctx->t5, p521_mod, p521_mp_mod);
  34023. ctx->state = 14;
  34024. break;
  34025. case 14:
  34026. sp_521_mont_mul_21(ctx->t5, ctx->t5, ctx->t2, p521_mod, p521_mp_mod);
  34027. ctx->state = 15;
  34028. break;
  34029. case 15:
  34030. /* Z3 = H*Z1*Z2 */
  34031. sp_521_mont_mul_21(ctx->z, p->z, ctx->t2, p521_mod, p521_mp_mod);
  34032. ctx->state = 16;
  34033. break;
  34034. case 16:
  34035. sp_521_mont_mul_21(ctx->z, ctx->z, q->z, p521_mod, p521_mp_mod);
  34036. ctx->state = 17;
  34037. break;
  34038. case 17:
  34039. sp_521_mont_sqr_21(ctx->x, ctx->t4, p521_mod, p521_mp_mod);
  34040. ctx->state = 18;
  34041. break;
  34042. case 18:
  34043. sp_521_mont_sub_21(ctx->x, ctx->x, ctx->t5, p521_mod);
  34044. ctx->state = 19;
  34045. break;
  34046. case 19:
  34047. sp_521_mont_mul_21(ctx->t5, ctx->t5, ctx->t3, p521_mod, p521_mp_mod);
  34048. ctx->state = 20;
  34049. break;
  34050. case 20:
  34051. sp_521_mont_dbl_21(ctx->t3, ctx->y, p521_mod);
  34052. sp_521_mont_sub_21(ctx->x, ctx->x, ctx->t3, p521_mod);
  34053. ctx->state = 21;
  34054. break;
  34055. case 21:
  34056. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  34057. sp_521_mont_sub_21(ctx->y, ctx->y, ctx->x, p521_mod);
  34058. ctx->state = 22;
  34059. break;
  34060. case 22:
  34061. sp_521_mont_mul_21(ctx->y, ctx->y, ctx->t4, p521_mod, p521_mp_mod);
  34062. ctx->state = 23;
  34063. break;
  34064. case 23:
  34065. sp_521_mont_sub_21(ctx->y, ctx->y, ctx->t5, p521_mod);
  34066. ctx->state = 24;
  34067. break;
  34068. case 24:
  34069. {
  34070. {
  34071. int i;
  34072. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  34073. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  34074. sp_digit maskt = ~(maskp | maskq);
  34075. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  34076. for (i = 0; i < 21; i++) {
  34077. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  34078. (ctx->x[i] & maskt);
  34079. }
  34080. for (i = 0; i < 21; i++) {
  34081. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  34082. (ctx->y[i] & maskt);
  34083. }
  34084. for (i = 0; i < 21; i++) {
  34085. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  34086. (ctx->z[i] & maskt);
  34087. }
  34088. r->z[0] |= inf;
  34089. r->infinity = (word32)inf;
  34090. }
  34091. ctx->state = 25;
  34092. break;
  34093. }
  34094. case 25:
  34095. err = MP_OKAY;
  34096. break;
  34097. }
  34098. if (err == MP_OKAY && ctx->state != 25) {
  34099. err = FP_WOULDBLOCK;
  34100. }
  34101. return err;
  34102. }
  34103. #endif /* WOLFSSL_SP_NONBLOCK */
  34104. /* Multiply a number by Montgomery normalizer mod modulus (prime).
  34105. *
  34106. * r The resulting Montgomery form number.
  34107. * a The number to convert.
  34108. * m The modulus (prime).
  34109. * returns MEMORY_E when memory allocation fails and MP_OKAY otherwise.
  34110. */
  34111. static int sp_521_mod_mul_norm_21(sp_digit* r, const sp_digit* a, const sp_digit* m)
  34112. {
  34113. (void)m;
  34114. if (r != a) {
  34115. XMEMCPY(r, a, 21 * sizeof(sp_digit));
  34116. }
  34117. return MP_OKAY;
  34118. }
  34119. #ifdef WOLFSSL_SP_SMALL
  34120. /* Multiply the point by the scalar and return the result.
  34121. * If map is true then convert result to affine coordinates.
  34122. *
  34123. * Small implementation using add and double that is cache attack resistant but
  34124. * allocates memory rather than use large stacks.
  34125. * 521 adds and doubles.
  34126. *
  34127. * r Resulting point.
  34128. * g Point to multiply.
  34129. * k Scalar to multiply by.
  34130. * map Indicates whether to convert result to affine.
  34131. * ct Constant time required.
  34132. * heap Heap to use for allocation.
  34133. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  34134. */
  34135. static int sp_521_ecc_mulmod_21(sp_point_521* r, const sp_point_521* g,
  34136. const sp_digit* k, int map, int ct, void* heap)
  34137. {
  34138. #ifdef WOLFSSL_SP_SMALL_STACK
  34139. sp_point_521* t = NULL;
  34140. sp_digit* tmp = NULL;
  34141. #else
  34142. sp_point_521 t[3];
  34143. sp_digit tmp[2 * 21 * 6];
  34144. #endif
  34145. sp_digit n;
  34146. int i;
  34147. int c;
  34148. int y;
  34149. int err = MP_OKAY;
  34150. /* Implementation is constant time. */
  34151. (void)ct;
  34152. (void)heap;
  34153. #ifdef WOLFSSL_SP_SMALL_STACK
  34154. t = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 3, heap,
  34155. DYNAMIC_TYPE_ECC);
  34156. if (t == NULL)
  34157. err = MEMORY_E;
  34158. if (err == MP_OKAY) {
  34159. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 6, heap,
  34160. DYNAMIC_TYPE_ECC);
  34161. if (tmp == NULL)
  34162. err = MEMORY_E;
  34163. }
  34164. #endif
  34165. if (err == MP_OKAY) {
  34166. XMEMSET(t, 0, sizeof(sp_point_521) * 3);
  34167. /* t[0] = {0, 0, 1} * norm */
  34168. t[0].infinity = 1;
  34169. /* t[1] = {g->x, g->y, g->z} * norm */
  34170. err = sp_521_mod_mul_norm_21(t[1].x, g->x, p521_mod);
  34171. }
  34172. if (err == MP_OKAY)
  34173. err = sp_521_mod_mul_norm_21(t[1].y, g->y, p521_mod);
  34174. if (err == MP_OKAY)
  34175. err = sp_521_mod_mul_norm_21(t[1].z, g->z, p521_mod);
  34176. if (err == MP_OKAY) {
  34177. i = 20;
  34178. c = 21;
  34179. n = k[i--] << (25 - c);
  34180. for (; ; c--) {
  34181. if (c == 0) {
  34182. if (i == -1)
  34183. break;
  34184. n = k[i--];
  34185. c = 25;
  34186. }
  34187. y = (n >> 24) & 1;
  34188. n <<= 1;
  34189. sp_521_proj_point_add_21(&t[y^1], &t[0], &t[1], tmp);
  34190. XMEMCPY(&t[2], (void*)(((size_t)&t[0] & addr_mask[y^1]) +
  34191. ((size_t)&t[1] & addr_mask[y])),
  34192. sizeof(sp_point_521));
  34193. sp_521_proj_point_dbl_21(&t[2], &t[2], tmp);
  34194. XMEMCPY((void*)(((size_t)&t[0] & addr_mask[y^1]) +
  34195. ((size_t)&t[1] & addr_mask[y])), &t[2],
  34196. sizeof(sp_point_521));
  34197. }
  34198. if (map != 0) {
  34199. sp_521_map_21(r, &t[0], tmp);
  34200. }
  34201. else {
  34202. XMEMCPY(r, &t[0], sizeof(sp_point_521));
  34203. }
  34204. }
  34205. #ifdef WOLFSSL_SP_SMALL_STACK
  34206. if (tmp != NULL)
  34207. #endif
  34208. {
  34209. ForceZero(tmp, sizeof(sp_digit) * 2 * 21 * 6);
  34210. #ifdef WOLFSSL_SP_SMALL_STACK
  34211. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  34212. #endif
  34213. }
  34214. #ifdef WOLFSSL_SP_SMALL_STACK
  34215. if (t != NULL)
  34216. #endif
  34217. {
  34218. ForceZero(t, sizeof(sp_point_521) * 3);
  34219. #ifdef WOLFSSL_SP_SMALL_STACK
  34220. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  34221. #endif
  34222. }
  34223. return err;
  34224. }
  34225. #ifdef WOLFSSL_SP_NONBLOCK
  34226. typedef struct sp_521_ecc_mulmod_21_ctx {
  34227. int state;
  34228. union {
  34229. sp_521_proj_point_dbl_21_ctx dbl_ctx;
  34230. sp_521_proj_point_add_21_ctx add_ctx;
  34231. };
  34232. sp_point_521 t[3];
  34233. sp_digit tmp[2 * 21 * 6];
  34234. sp_digit n;
  34235. int i;
  34236. int c;
  34237. int y;
  34238. } sp_521_ecc_mulmod_21_ctx;
  34239. static int sp_521_ecc_mulmod_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
  34240. const sp_point_521* g, const sp_digit* k, int map, int ct, void* heap)
  34241. {
  34242. int err = FP_WOULDBLOCK;
  34243. sp_521_ecc_mulmod_21_ctx* ctx = (sp_521_ecc_mulmod_21_ctx*)sp_ctx->data;
  34244. typedef char ctx_size_test[sizeof(sp_521_ecc_mulmod_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  34245. (void)sizeof(ctx_size_test);
  34246. /* Implementation is constant time. */
  34247. (void)ct;
  34248. switch (ctx->state) {
  34249. case 0: /* INIT */
  34250. XMEMSET(ctx->t, 0, sizeof(sp_point_521) * 3);
  34251. ctx->i = 20;
  34252. ctx->c = 21;
  34253. ctx->n = k[ctx->i--] << (25 - ctx->c);
  34254. /* t[0] = {0, 0, 1} * norm */
  34255. ctx->t[0].infinity = 1;
  34256. ctx->state = 1;
  34257. break;
  34258. case 1: /* T1X */
  34259. /* t[1] = {g->x, g->y, g->z} * norm */
  34260. err = sp_521_mod_mul_norm_21(ctx->t[1].x, g->x, p521_mod);
  34261. ctx->state = 2;
  34262. break;
  34263. case 2: /* T1Y */
  34264. err = sp_521_mod_mul_norm_21(ctx->t[1].y, g->y, p521_mod);
  34265. ctx->state = 3;
  34266. break;
  34267. case 3: /* T1Z */
  34268. err = sp_521_mod_mul_norm_21(ctx->t[1].z, g->z, p521_mod);
  34269. ctx->state = 4;
  34270. break;
  34271. case 4: /* ADDPREP */
  34272. if (ctx->c == 0) {
  34273. if (ctx->i == -1) {
  34274. ctx->state = 7;
  34275. break;
  34276. }
  34277. ctx->n = k[ctx->i--];
  34278. ctx->c = 25;
  34279. }
  34280. ctx->y = (ctx->n >> 24) & 1;
  34281. ctx->n <<= 1;
  34282. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  34283. ctx->state = 5;
  34284. break;
  34285. case 5: /* ADD */
  34286. err = sp_521_proj_point_add_21_nb((sp_ecc_ctx_t*)&ctx->add_ctx,
  34287. &ctx->t[ctx->y^1], &ctx->t[0], &ctx->t[1], ctx->tmp);
  34288. if (err == MP_OKAY) {
  34289. XMEMCPY(&ctx->t[2], (void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  34290. ((size_t)&ctx->t[1] & addr_mask[ctx->y])),
  34291. sizeof(sp_point_521));
  34292. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  34293. ctx->state = 6;
  34294. }
  34295. break;
  34296. case 6: /* DBL */
  34297. err = sp_521_proj_point_dbl_21_nb((sp_ecc_ctx_t*)&ctx->dbl_ctx, &ctx->t[2],
  34298. &ctx->t[2], ctx->tmp);
  34299. if (err == MP_OKAY) {
  34300. XMEMCPY((void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  34301. ((size_t)&ctx->t[1] & addr_mask[ctx->y])), &ctx->t[2],
  34302. sizeof(sp_point_521));
  34303. ctx->state = 4;
  34304. ctx->c--;
  34305. }
  34306. break;
  34307. case 7: /* MAP */
  34308. if (map != 0) {
  34309. sp_521_map_21(r, &ctx->t[0], ctx->tmp);
  34310. }
  34311. else {
  34312. XMEMCPY(r, &ctx->t[0], sizeof(sp_point_521));
  34313. }
  34314. err = MP_OKAY;
  34315. break;
  34316. }
  34317. if (err == MP_OKAY && ctx->state != 7) {
  34318. err = FP_WOULDBLOCK;
  34319. }
  34320. if (err != FP_WOULDBLOCK) {
  34321. ForceZero(ctx->tmp, sizeof(ctx->tmp));
  34322. ForceZero(ctx->t, sizeof(ctx->t));
  34323. }
  34324. (void)heap;
  34325. return err;
  34326. }
  34327. #endif /* WOLFSSL_SP_NONBLOCK */
  34328. #else
  34329. /* A table entry for pre-computed points. */
  34330. typedef struct sp_table_entry_521 {
  34331. sp_digit x[21];
  34332. sp_digit y[21];
  34333. } sp_table_entry_521;
  34334. /* Conditionally copy a into r using the mask m.
  34335. * m is -1 to copy and 0 when not.
  34336. *
  34337. * r A single precision number to copy over.
  34338. * a A single precision number to copy.
  34339. * m Mask value to apply.
  34340. */
  34341. static void sp_521_cond_copy_21(sp_digit* r, const sp_digit* a, const sp_digit m)
  34342. {
  34343. sp_digit t[21];
  34344. #ifdef WOLFSSL_SP_SMALL
  34345. int i;
  34346. for (i = 0; i < 21; i++) {
  34347. t[i] = r[i] ^ a[i];
  34348. }
  34349. for (i = 0; i < 21; i++) {
  34350. r[i] ^= t[i] & m;
  34351. }
  34352. #else
  34353. t[ 0] = r[ 0] ^ a[ 0];
  34354. t[ 1] = r[ 1] ^ a[ 1];
  34355. t[ 2] = r[ 2] ^ a[ 2];
  34356. t[ 3] = r[ 3] ^ a[ 3];
  34357. t[ 4] = r[ 4] ^ a[ 4];
  34358. t[ 5] = r[ 5] ^ a[ 5];
  34359. t[ 6] = r[ 6] ^ a[ 6];
  34360. t[ 7] = r[ 7] ^ a[ 7];
  34361. t[ 8] = r[ 8] ^ a[ 8];
  34362. t[ 9] = r[ 9] ^ a[ 9];
  34363. t[10] = r[10] ^ a[10];
  34364. t[11] = r[11] ^ a[11];
  34365. t[12] = r[12] ^ a[12];
  34366. t[13] = r[13] ^ a[13];
  34367. t[14] = r[14] ^ a[14];
  34368. t[15] = r[15] ^ a[15];
  34369. t[16] = r[16] ^ a[16];
  34370. t[17] = r[17] ^ a[17];
  34371. t[18] = r[18] ^ a[18];
  34372. t[19] = r[19] ^ a[19];
  34373. t[20] = r[20] ^ a[20];
  34374. r[ 0] ^= t[ 0] & m;
  34375. r[ 1] ^= t[ 1] & m;
  34376. r[ 2] ^= t[ 2] & m;
  34377. r[ 3] ^= t[ 3] & m;
  34378. r[ 4] ^= t[ 4] & m;
  34379. r[ 5] ^= t[ 5] & m;
  34380. r[ 6] ^= t[ 6] & m;
  34381. r[ 7] ^= t[ 7] & m;
  34382. r[ 8] ^= t[ 8] & m;
  34383. r[ 9] ^= t[ 9] & m;
  34384. r[10] ^= t[10] & m;
  34385. r[11] ^= t[11] & m;
  34386. r[12] ^= t[12] & m;
  34387. r[13] ^= t[13] & m;
  34388. r[14] ^= t[14] & m;
  34389. r[15] ^= t[15] & m;
  34390. r[16] ^= t[16] & m;
  34391. r[17] ^= t[17] & m;
  34392. r[18] ^= t[18] & m;
  34393. r[19] ^= t[19] & m;
  34394. r[20] ^= t[20] & m;
  34395. #endif /* WOLFSSL_SP_SMALL */
  34396. }
  34397. /* Double the Montgomery form projective point p a number of times.
  34398. *
  34399. * r Result of repeated doubling of point.
  34400. * p Point to double.
  34401. * n Number of times to double
  34402. * t Temporary ordinate data.
  34403. */
  34404. static void sp_521_proj_point_dbl_n_21(sp_point_521* p, int i,
  34405. sp_digit* t)
  34406. {
  34407. sp_digit* w = t;
  34408. sp_digit* a = t + 2*21;
  34409. sp_digit* b = t + 4*21;
  34410. sp_digit* t1 = t + 6*21;
  34411. sp_digit* t2 = t + 8*21;
  34412. sp_digit* x;
  34413. sp_digit* y;
  34414. sp_digit* z;
  34415. volatile int n = i;
  34416. x = p->x;
  34417. y = p->y;
  34418. z = p->z;
  34419. /* Y = 2*Y */
  34420. sp_521_mont_dbl_21(y, y, p521_mod);
  34421. /* W = Z^4 */
  34422. sp_521_mont_sqr_21(w, z, p521_mod, p521_mp_mod);
  34423. sp_521_mont_sqr_21(w, w, p521_mod, p521_mp_mod);
  34424. #ifndef WOLFSSL_SP_SMALL
  34425. while (--n > 0)
  34426. #else
  34427. while (--n >= 0)
  34428. #endif
  34429. {
  34430. /* A = 3*(X^2 - W) */
  34431. sp_521_mont_sqr_21(t1, x, p521_mod, p521_mp_mod);
  34432. sp_521_mont_sub_21(t1, t1, w, p521_mod);
  34433. sp_521_mont_tpl_21(a, t1, p521_mod);
  34434. /* B = X*Y^2 */
  34435. sp_521_mont_sqr_21(t1, y, p521_mod, p521_mp_mod);
  34436. sp_521_mont_mul_21(b, t1, x, p521_mod, p521_mp_mod);
  34437. /* X = A^2 - 2B */
  34438. sp_521_mont_sqr_21(x, a, p521_mod, p521_mp_mod);
  34439. sp_521_mont_dbl_21(t2, b, p521_mod);
  34440. sp_521_mont_sub_21(x, x, t2, p521_mod);
  34441. /* B = 2.(B - X) */
  34442. sp_521_mont_sub_21(t2, b, x, p521_mod);
  34443. sp_521_mont_dbl_21(b, t2, p521_mod);
  34444. /* Z = Z*Y */
  34445. sp_521_mont_mul_21(z, z, y, p521_mod, p521_mp_mod);
  34446. /* t1 = Y^4 */
  34447. sp_521_mont_sqr_21(t1, t1, p521_mod, p521_mp_mod);
  34448. #ifdef WOLFSSL_SP_SMALL
  34449. if (n != 0)
  34450. #endif
  34451. {
  34452. /* W = W*Y^4 */
  34453. sp_521_mont_mul_21(w, w, t1, p521_mod, p521_mp_mod);
  34454. }
  34455. /* y = 2*A*(B - X) - Y^4 */
  34456. sp_521_mont_mul_21(y, b, a, p521_mod, p521_mp_mod);
  34457. sp_521_mont_sub_21(y, y, t1, p521_mod);
  34458. }
  34459. #ifndef WOLFSSL_SP_SMALL
  34460. /* A = 3*(X^2 - W) */
  34461. sp_521_mont_sqr_21(t1, x, p521_mod, p521_mp_mod);
  34462. sp_521_mont_sub_21(t1, t1, w, p521_mod);
  34463. sp_521_mont_tpl_21(a, t1, p521_mod);
  34464. /* B = X*Y^2 */
  34465. sp_521_mont_sqr_21(t1, y, p521_mod, p521_mp_mod);
  34466. sp_521_mont_mul_21(b, t1, x, p521_mod, p521_mp_mod);
  34467. /* X = A^2 - 2B */
  34468. sp_521_mont_sqr_21(x, a, p521_mod, p521_mp_mod);
  34469. sp_521_mont_dbl_21(t2, b, p521_mod);
  34470. sp_521_mont_sub_21(x, x, t2, p521_mod);
  34471. /* B = 2.(B - X) */
  34472. sp_521_mont_sub_21(t2, b, x, p521_mod);
  34473. sp_521_mont_dbl_21(b, t2, p521_mod);
  34474. /* Z = Z*Y */
  34475. sp_521_mont_mul_21(z, z, y, p521_mod, p521_mp_mod);
  34476. /* t1 = Y^4 */
  34477. sp_521_mont_sqr_21(t1, t1, p521_mod, p521_mp_mod);
  34478. /* y = 2*A*(B - X) - Y^4 */
  34479. sp_521_mont_mul_21(y, b, a, p521_mod, p521_mp_mod);
  34480. sp_521_mont_sub_21(y, y, t1, p521_mod);
  34481. #endif /* WOLFSSL_SP_SMALL */
  34482. /* Y = Y/2 */
  34483. sp_521_mont_div2_21(y, y, p521_mod);
  34484. }
  34485. /* Double the Montgomery form projective point p a number of times.
  34486. *
  34487. * r Result of repeated doubling of point.
  34488. * p Point to double.
  34489. * n Number of times to double
  34490. * t Temporary ordinate data.
  34491. */
  34492. static void sp_521_proj_point_dbl_n_store_21(sp_point_521* r,
  34493. const sp_point_521* p, int n, int m, sp_digit* t)
  34494. {
  34495. sp_digit* w = t;
  34496. sp_digit* a = t + 2*21;
  34497. sp_digit* b = t + 4*21;
  34498. sp_digit* t1 = t + 6*21;
  34499. sp_digit* t2 = t + 8*21;
  34500. sp_digit* x = r[2*m].x;
  34501. sp_digit* y = r[(1<<n)*m].y;
  34502. sp_digit* z = r[2*m].z;
  34503. int i;
  34504. int j;
  34505. for (i=0; i<21; i++) {
  34506. x[i] = p->x[i];
  34507. }
  34508. for (i=0; i<21; i++) {
  34509. y[i] = p->y[i];
  34510. }
  34511. for (i=0; i<21; i++) {
  34512. z[i] = p->z[i];
  34513. }
  34514. /* Y = 2*Y */
  34515. sp_521_mont_dbl_21(y, y, p521_mod);
  34516. /* W = Z^4 */
  34517. sp_521_mont_sqr_21(w, z, p521_mod, p521_mp_mod);
  34518. sp_521_mont_sqr_21(w, w, p521_mod, p521_mp_mod);
  34519. j = m;
  34520. for (i=1; i<=n; i++) {
  34521. j *= 2;
  34522. /* A = 3*(X^2 - W) */
  34523. sp_521_mont_sqr_21(t1, x, p521_mod, p521_mp_mod);
  34524. sp_521_mont_sub_21(t1, t1, w, p521_mod);
  34525. sp_521_mont_tpl_21(a, t1, p521_mod);
  34526. /* B = X*Y^2 */
  34527. sp_521_mont_sqr_21(t1, y, p521_mod, p521_mp_mod);
  34528. sp_521_mont_mul_21(b, t1, x, p521_mod, p521_mp_mod);
  34529. x = r[j].x;
  34530. /* X = A^2 - 2B */
  34531. sp_521_mont_sqr_21(x, a, p521_mod, p521_mp_mod);
  34532. sp_521_mont_dbl_21(t2, b, p521_mod);
  34533. sp_521_mont_sub_21(x, x, t2, p521_mod);
  34534. /* B = 2.(B - X) */
  34535. sp_521_mont_sub_21(t2, b, x, p521_mod);
  34536. sp_521_mont_dbl_21(b, t2, p521_mod);
  34537. /* Z = Z*Y */
  34538. sp_521_mont_mul_21(r[j].z, z, y, p521_mod, p521_mp_mod);
  34539. z = r[j].z;
  34540. /* t1 = Y^4 */
  34541. sp_521_mont_sqr_21(t1, t1, p521_mod, p521_mp_mod);
  34542. if (i != n) {
  34543. /* W = W*Y^4 */
  34544. sp_521_mont_mul_21(w, w, t1, p521_mod, p521_mp_mod);
  34545. }
  34546. /* y = 2*A*(B - X) - Y^4 */
  34547. sp_521_mont_mul_21(y, b, a, p521_mod, p521_mp_mod);
  34548. sp_521_mont_sub_21(y, y, t1, p521_mod);
  34549. /* Y = Y/2 */
  34550. sp_521_mont_div2_21(r[j].y, y, p521_mod);
  34551. r[j].infinity = 0;
  34552. }
  34553. }
  34554. /* Add two Montgomery form projective points.
  34555. *
  34556. * ra Result of addition.
  34557. * rs Result of subtraction.
  34558. * p First point to add.
  34559. * q Second point to add.
  34560. * t Temporary ordinate data.
  34561. */
  34562. static void sp_521_proj_point_add_sub_21(sp_point_521* ra,
  34563. sp_point_521* rs, const sp_point_521* p, const sp_point_521* q,
  34564. sp_digit* t)
  34565. {
  34566. sp_digit* t1 = t;
  34567. sp_digit* t2 = t + 2*21;
  34568. sp_digit* t3 = t + 4*21;
  34569. sp_digit* t4 = t + 6*21;
  34570. sp_digit* t5 = t + 8*21;
  34571. sp_digit* t6 = t + 10*21;
  34572. sp_digit* xa = ra->x;
  34573. sp_digit* ya = ra->y;
  34574. sp_digit* za = ra->z;
  34575. sp_digit* xs = rs->x;
  34576. sp_digit* ys = rs->y;
  34577. sp_digit* zs = rs->z;
  34578. XMEMCPY(xa, p->x, sizeof(p->x) / 2);
  34579. XMEMCPY(ya, p->y, sizeof(p->y) / 2);
  34580. XMEMCPY(za, p->z, sizeof(p->z) / 2);
  34581. ra->infinity = 0;
  34582. rs->infinity = 0;
  34583. /* U1 = X1*Z2^2 */
  34584. sp_521_mont_sqr_21(t1, q->z, p521_mod, p521_mp_mod);
  34585. sp_521_mont_mul_21(t3, t1, q->z, p521_mod, p521_mp_mod);
  34586. sp_521_mont_mul_21(t1, t1, xa, p521_mod, p521_mp_mod);
  34587. /* U2 = X2*Z1^2 */
  34588. sp_521_mont_sqr_21(t2, za, p521_mod, p521_mp_mod);
  34589. sp_521_mont_mul_21(t4, t2, za, p521_mod, p521_mp_mod);
  34590. sp_521_mont_mul_21(t2, t2, q->x, p521_mod, p521_mp_mod);
  34591. /* S1 = Y1*Z2^3 */
  34592. sp_521_mont_mul_21(t3, t3, ya, p521_mod, p521_mp_mod);
  34593. /* S2 = Y2*Z1^3 */
  34594. sp_521_mont_mul_21(t4, t4, q->y, p521_mod, p521_mp_mod);
  34595. /* H = U2 - U1 */
  34596. sp_521_mont_sub_21(t2, t2, t1, p521_mod);
  34597. /* RS = S2 + S1 */
  34598. sp_521_mont_add_21(t6, t4, t3, p521_mod);
  34599. /* R = S2 - S1 */
  34600. sp_521_mont_sub_21(t4, t4, t3, p521_mod);
  34601. /* Z3 = H*Z1*Z2 */
  34602. /* ZS = H*Z1*Z2 */
  34603. sp_521_mont_mul_21(za, za, q->z, p521_mod, p521_mp_mod);
  34604. sp_521_mont_mul_21(za, za, t2, p521_mod, p521_mp_mod);
  34605. XMEMCPY(zs, za, sizeof(p->z)/2);
  34606. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  34607. /* XS = RS^2 - H^3 - 2*U1*H^2 */
  34608. sp_521_mont_sqr_21(xa, t4, p521_mod, p521_mp_mod);
  34609. sp_521_mont_sqr_21(xs, t6, p521_mod, p521_mp_mod);
  34610. sp_521_mont_sqr_21(t5, t2, p521_mod, p521_mp_mod);
  34611. sp_521_mont_mul_21(ya, t1, t5, p521_mod, p521_mp_mod);
  34612. sp_521_mont_mul_21(t5, t5, t2, p521_mod, p521_mp_mod);
  34613. sp_521_mont_sub_21(xa, xa, t5, p521_mod);
  34614. sp_521_mont_sub_21(xs, xs, t5, p521_mod);
  34615. sp_521_mont_dbl_21(t1, ya, p521_mod);
  34616. sp_521_mont_sub_21(xa, xa, t1, p521_mod);
  34617. sp_521_mont_sub_21(xs, xs, t1, p521_mod);
  34618. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  34619. /* YS = -RS*(U1*H^2 - XS) - S1*H^3 */
  34620. sp_521_mont_sub_21(ys, ya, xs, p521_mod);
  34621. sp_521_mont_sub_21(ya, ya, xa, p521_mod);
  34622. sp_521_mont_mul_21(ya, ya, t4, p521_mod, p521_mp_mod);
  34623. sp_521_sub_21(t6, p521_mod, t6);
  34624. sp_521_mont_mul_21(ys, ys, t6, p521_mod, p521_mp_mod);
  34625. sp_521_mont_mul_21(t5, t5, t3, p521_mod, p521_mp_mod);
  34626. sp_521_mont_sub_21(ya, ya, t5, p521_mod);
  34627. sp_521_mont_sub_21(ys, ys, t5, p521_mod);
  34628. }
  34629. /* Structure used to describe recoding of scalar multiplication. */
  34630. typedef struct ecc_recode_521 {
  34631. /* Index into pre-computation table. */
  34632. uint8_t i;
  34633. /* Use the negative of the point. */
  34634. uint8_t neg;
  34635. } ecc_recode_521;
  34636. /* The index into pre-computation table to use. */
  34637. static const uint8_t recode_index_21_6[66] = {
  34638. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  34639. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  34640. 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
  34641. 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
  34642. 0, 1,
  34643. };
  34644. /* Whether to negate y-ordinate. */
  34645. static const uint8_t recode_neg_21_6[66] = {
  34646. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  34647. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  34648. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  34649. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  34650. 0, 0,
  34651. };
  34652. /* Recode the scalar for multiplication using pre-computed values and
  34653. * subtraction.
  34654. *
  34655. * k Scalar to multiply by.
  34656. * v Vector of operations to perform.
  34657. */
  34658. static void sp_521_ecc_recode_6_21(const sp_digit* k, ecc_recode_521* v)
  34659. {
  34660. int i;
  34661. int j;
  34662. uint8_t y;
  34663. int carry = 0;
  34664. int o;
  34665. sp_digit n;
  34666. j = 0;
  34667. n = k[j];
  34668. o = 0;
  34669. for (i=0; i<87; i++) {
  34670. y = (int8_t)n;
  34671. if (o + 6 < 25) {
  34672. y &= 0x3f;
  34673. n >>= 6;
  34674. o += 6;
  34675. }
  34676. else if (o + 6 == 25) {
  34677. n >>= 6;
  34678. if (++j < 21)
  34679. n = k[j];
  34680. o = 0;
  34681. }
  34682. else if (++j < 21) {
  34683. n = k[j];
  34684. y |= (uint8_t)((n << (25 - o)) & 0x3f);
  34685. o -= 19;
  34686. n >>= o;
  34687. }
  34688. y += (uint8_t)carry;
  34689. v[i].i = recode_index_21_6[y];
  34690. v[i].neg = recode_neg_21_6[y];
  34691. carry = (y >> 6) + v[i].neg;
  34692. }
  34693. }
  34694. #ifndef WC_NO_CACHE_RESISTANT
  34695. /* Touch each possible point that could be being copied.
  34696. *
  34697. * r Point to copy into.
  34698. * table Table - start of the entries to access
  34699. * idx Index of entry to retrieve.
  34700. */
  34701. static void sp_521_get_point_33_21(sp_point_521* r, const sp_point_521* table,
  34702. int idx)
  34703. {
  34704. int i;
  34705. sp_digit mask;
  34706. r->x[0] = 0;
  34707. r->x[1] = 0;
  34708. r->x[2] = 0;
  34709. r->x[3] = 0;
  34710. r->x[4] = 0;
  34711. r->x[5] = 0;
  34712. r->x[6] = 0;
  34713. r->x[7] = 0;
  34714. r->x[8] = 0;
  34715. r->x[9] = 0;
  34716. r->x[10] = 0;
  34717. r->x[11] = 0;
  34718. r->x[12] = 0;
  34719. r->x[13] = 0;
  34720. r->x[14] = 0;
  34721. r->x[15] = 0;
  34722. r->x[16] = 0;
  34723. r->x[17] = 0;
  34724. r->x[18] = 0;
  34725. r->x[19] = 0;
  34726. r->x[20] = 0;
  34727. r->y[0] = 0;
  34728. r->y[1] = 0;
  34729. r->y[2] = 0;
  34730. r->y[3] = 0;
  34731. r->y[4] = 0;
  34732. r->y[5] = 0;
  34733. r->y[6] = 0;
  34734. r->y[7] = 0;
  34735. r->y[8] = 0;
  34736. r->y[9] = 0;
  34737. r->y[10] = 0;
  34738. r->y[11] = 0;
  34739. r->y[12] = 0;
  34740. r->y[13] = 0;
  34741. r->y[14] = 0;
  34742. r->y[15] = 0;
  34743. r->y[16] = 0;
  34744. r->y[17] = 0;
  34745. r->y[18] = 0;
  34746. r->y[19] = 0;
  34747. r->y[20] = 0;
  34748. r->z[0] = 0;
  34749. r->z[1] = 0;
  34750. r->z[2] = 0;
  34751. r->z[3] = 0;
  34752. r->z[4] = 0;
  34753. r->z[5] = 0;
  34754. r->z[6] = 0;
  34755. r->z[7] = 0;
  34756. r->z[8] = 0;
  34757. r->z[9] = 0;
  34758. r->z[10] = 0;
  34759. r->z[11] = 0;
  34760. r->z[12] = 0;
  34761. r->z[13] = 0;
  34762. r->z[14] = 0;
  34763. r->z[15] = 0;
  34764. r->z[16] = 0;
  34765. r->z[17] = 0;
  34766. r->z[18] = 0;
  34767. r->z[19] = 0;
  34768. r->z[20] = 0;
  34769. for (i = 1; i < 33; i++) {
  34770. mask = 0 - (i == idx);
  34771. r->x[0] |= mask & table[i].x[0];
  34772. r->x[1] |= mask & table[i].x[1];
  34773. r->x[2] |= mask & table[i].x[2];
  34774. r->x[3] |= mask & table[i].x[3];
  34775. r->x[4] |= mask & table[i].x[4];
  34776. r->x[5] |= mask & table[i].x[5];
  34777. r->x[6] |= mask & table[i].x[6];
  34778. r->x[7] |= mask & table[i].x[7];
  34779. r->x[8] |= mask & table[i].x[8];
  34780. r->x[9] |= mask & table[i].x[9];
  34781. r->x[10] |= mask & table[i].x[10];
  34782. r->x[11] |= mask & table[i].x[11];
  34783. r->x[12] |= mask & table[i].x[12];
  34784. r->x[13] |= mask & table[i].x[13];
  34785. r->x[14] |= mask & table[i].x[14];
  34786. r->x[15] |= mask & table[i].x[15];
  34787. r->x[16] |= mask & table[i].x[16];
  34788. r->x[17] |= mask & table[i].x[17];
  34789. r->x[18] |= mask & table[i].x[18];
  34790. r->x[19] |= mask & table[i].x[19];
  34791. r->x[20] |= mask & table[i].x[20];
  34792. r->y[0] |= mask & table[i].y[0];
  34793. r->y[1] |= mask & table[i].y[1];
  34794. r->y[2] |= mask & table[i].y[2];
  34795. r->y[3] |= mask & table[i].y[3];
  34796. r->y[4] |= mask & table[i].y[4];
  34797. r->y[5] |= mask & table[i].y[5];
  34798. r->y[6] |= mask & table[i].y[6];
  34799. r->y[7] |= mask & table[i].y[7];
  34800. r->y[8] |= mask & table[i].y[8];
  34801. r->y[9] |= mask & table[i].y[9];
  34802. r->y[10] |= mask & table[i].y[10];
  34803. r->y[11] |= mask & table[i].y[11];
  34804. r->y[12] |= mask & table[i].y[12];
  34805. r->y[13] |= mask & table[i].y[13];
  34806. r->y[14] |= mask & table[i].y[14];
  34807. r->y[15] |= mask & table[i].y[15];
  34808. r->y[16] |= mask & table[i].y[16];
  34809. r->y[17] |= mask & table[i].y[17];
  34810. r->y[18] |= mask & table[i].y[18];
  34811. r->y[19] |= mask & table[i].y[19];
  34812. r->y[20] |= mask & table[i].y[20];
  34813. r->z[0] |= mask & table[i].z[0];
  34814. r->z[1] |= mask & table[i].z[1];
  34815. r->z[2] |= mask & table[i].z[2];
  34816. r->z[3] |= mask & table[i].z[3];
  34817. r->z[4] |= mask & table[i].z[4];
  34818. r->z[5] |= mask & table[i].z[5];
  34819. r->z[6] |= mask & table[i].z[6];
  34820. r->z[7] |= mask & table[i].z[7];
  34821. r->z[8] |= mask & table[i].z[8];
  34822. r->z[9] |= mask & table[i].z[9];
  34823. r->z[10] |= mask & table[i].z[10];
  34824. r->z[11] |= mask & table[i].z[11];
  34825. r->z[12] |= mask & table[i].z[12];
  34826. r->z[13] |= mask & table[i].z[13];
  34827. r->z[14] |= mask & table[i].z[14];
  34828. r->z[15] |= mask & table[i].z[15];
  34829. r->z[16] |= mask & table[i].z[16];
  34830. r->z[17] |= mask & table[i].z[17];
  34831. r->z[18] |= mask & table[i].z[18];
  34832. r->z[19] |= mask & table[i].z[19];
  34833. r->z[20] |= mask & table[i].z[20];
  34834. }
  34835. }
  34836. #endif /* !WC_NO_CACHE_RESISTANT */
  34837. /* Multiply the point by the scalar and return the result.
  34838. * If map is true then convert result to affine coordinates.
  34839. *
  34840. * Window technique of 6 bits. (Add-Sub variation.)
  34841. * Calculate 0..32 times the point. Use function that adds and
  34842. * subtracts the same two points.
  34843. * Recode to add or subtract one of the computed points.
  34844. * Double to push up.
  34845. * NOT a sliding window.
  34846. *
  34847. * r Resulting point.
  34848. * g Point to multiply.
  34849. * k Scalar to multiply by.
  34850. * map Indicates whether to convert result to affine.
  34851. * ct Constant time required.
  34852. * heap Heap to use for allocation.
  34853. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  34854. */
  34855. static int sp_521_ecc_mulmod_win_add_sub_21(sp_point_521* r, const sp_point_521* g,
  34856. const sp_digit* k, int map, int ct, void* heap)
  34857. {
  34858. #ifdef WOLFSSL_SP_SMALL_STACK
  34859. sp_point_521* t = NULL;
  34860. sp_digit* tmp = NULL;
  34861. #else
  34862. sp_point_521 t[33+2];
  34863. sp_digit tmp[2 * 21 * 6];
  34864. #endif
  34865. sp_point_521* rt = NULL;
  34866. sp_point_521* p = NULL;
  34867. sp_digit* negy;
  34868. int i;
  34869. ecc_recode_521 v[87];
  34870. int err = MP_OKAY;
  34871. /* Constant time used for cache attack resistance implementation. */
  34872. (void)ct;
  34873. (void)heap;
  34874. #ifdef WOLFSSL_SP_SMALL_STACK
  34875. t = (sp_point_521*)XMALLOC(sizeof(sp_point_521) *
  34876. (33+2), heap, DYNAMIC_TYPE_ECC);
  34877. if (t == NULL)
  34878. err = MEMORY_E;
  34879. if (err == MP_OKAY) {
  34880. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 6,
  34881. heap, DYNAMIC_TYPE_ECC);
  34882. if (tmp == NULL)
  34883. err = MEMORY_E;
  34884. }
  34885. #endif
  34886. if (err == MP_OKAY) {
  34887. rt = t + 33;
  34888. p = t + 33+1;
  34889. /* t[0] = {0, 0, 1} * norm */
  34890. XMEMSET(&t[0], 0, sizeof(t[0]));
  34891. t[0].infinity = 1;
  34892. /* t[1] = {g->x, g->y, g->z} * norm */
  34893. err = sp_521_mod_mul_norm_21(t[1].x, g->x, p521_mod);
  34894. }
  34895. if (err == MP_OKAY) {
  34896. err = sp_521_mod_mul_norm_21(t[1].y, g->y, p521_mod);
  34897. }
  34898. if (err == MP_OKAY) {
  34899. err = sp_521_mod_mul_norm_21(t[1].z, g->z, p521_mod);
  34900. }
  34901. if (err == MP_OKAY) {
  34902. t[1].infinity = 0;
  34903. /* t[2] ... t[32] */
  34904. sp_521_proj_point_dbl_n_store_21(t, &t[ 1], 5, 1, tmp);
  34905. sp_521_proj_point_add_21(&t[ 3], &t[ 2], &t[ 1], tmp);
  34906. sp_521_proj_point_dbl_21(&t[ 6], &t[ 3], tmp);
  34907. sp_521_proj_point_add_sub_21(&t[ 7], &t[ 5], &t[ 6], &t[ 1], tmp);
  34908. sp_521_proj_point_dbl_21(&t[10], &t[ 5], tmp);
  34909. sp_521_proj_point_add_sub_21(&t[11], &t[ 9], &t[10], &t[ 1], tmp);
  34910. sp_521_proj_point_dbl_21(&t[12], &t[ 6], tmp);
  34911. sp_521_proj_point_dbl_21(&t[14], &t[ 7], tmp);
  34912. sp_521_proj_point_add_sub_21(&t[15], &t[13], &t[14], &t[ 1], tmp);
  34913. sp_521_proj_point_dbl_21(&t[18], &t[ 9], tmp);
  34914. sp_521_proj_point_add_sub_21(&t[19], &t[17], &t[18], &t[ 1], tmp);
  34915. sp_521_proj_point_dbl_21(&t[20], &t[10], tmp);
  34916. sp_521_proj_point_dbl_21(&t[22], &t[11], tmp);
  34917. sp_521_proj_point_add_sub_21(&t[23], &t[21], &t[22], &t[ 1], tmp);
  34918. sp_521_proj_point_dbl_21(&t[24], &t[12], tmp);
  34919. sp_521_proj_point_dbl_21(&t[26], &t[13], tmp);
  34920. sp_521_proj_point_add_sub_21(&t[27], &t[25], &t[26], &t[ 1], tmp);
  34921. sp_521_proj_point_dbl_21(&t[28], &t[14], tmp);
  34922. sp_521_proj_point_dbl_21(&t[30], &t[15], tmp);
  34923. sp_521_proj_point_add_sub_21(&t[31], &t[29], &t[30], &t[ 1], tmp);
  34924. negy = t[0].y;
  34925. sp_521_ecc_recode_6_21(k, v);
  34926. i = 86;
  34927. #ifndef WC_NO_CACHE_RESISTANT
  34928. if (ct) {
  34929. sp_521_get_point_33_21(rt, t, v[i].i);
  34930. rt->infinity = !v[i].i;
  34931. }
  34932. else
  34933. #endif
  34934. {
  34935. XMEMCPY(rt, &t[v[i].i], sizeof(sp_point_521));
  34936. }
  34937. for (--i; i>=0; i--) {
  34938. sp_521_proj_point_dbl_n_21(rt, 6, tmp);
  34939. #ifndef WC_NO_CACHE_RESISTANT
  34940. if (ct) {
  34941. sp_521_get_point_33_21(p, t, v[i].i);
  34942. p->infinity = !v[i].i;
  34943. }
  34944. else
  34945. #endif
  34946. {
  34947. XMEMCPY(p, &t[v[i].i], sizeof(sp_point_521));
  34948. }
  34949. sp_521_sub_21(negy, p521_mod, p->y);
  34950. sp_521_norm_21(negy);
  34951. sp_521_cond_copy_21(p->y, negy, (sp_digit)0 - v[i].neg);
  34952. sp_521_proj_point_add_21(rt, rt, p, tmp);
  34953. }
  34954. if (map != 0) {
  34955. sp_521_map_21(r, rt, tmp);
  34956. }
  34957. else {
  34958. XMEMCPY(r, rt, sizeof(sp_point_521));
  34959. }
  34960. }
  34961. #ifdef WOLFSSL_SP_SMALL_STACK
  34962. if (t != NULL)
  34963. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  34964. if (tmp != NULL)
  34965. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  34966. #endif
  34967. return err;
  34968. }
  34969. #ifdef FP_ECC
  34970. #endif /* FP_ECC */
  34971. /* Add two Montgomery form projective points. The second point has a q value of
  34972. * one.
  34973. * Only the first point can be the same pointer as the result point.
  34974. *
  34975. * r Result of addition.
  34976. * p First point to add.
  34977. * q Second point to add.
  34978. * t Temporary ordinate data.
  34979. */
  34980. static void sp_521_proj_point_add_qz1_21(sp_point_521* r,
  34981. const sp_point_521* p, const sp_point_521* q, sp_digit* t)
  34982. {
  34983. sp_digit* t2 = t;
  34984. sp_digit* t3 = t + 2*21;
  34985. sp_digit* t6 = t + 4*21;
  34986. sp_digit* t1 = t + 6*21;
  34987. sp_digit* t4 = t + 8*21;
  34988. sp_digit* t5 = t + 10*21;
  34989. /* Calculate values to subtract from P->x and P->y. */
  34990. /* U2 = X2*Z1^2 */
  34991. sp_521_mont_sqr_21(t2, p->z, p521_mod, p521_mp_mod);
  34992. sp_521_mont_mul_21(t4, t2, p->z, p521_mod, p521_mp_mod);
  34993. sp_521_mont_mul_21(t2, t2, q->x, p521_mod, p521_mp_mod);
  34994. /* S2 = Y2*Z1^3 */
  34995. sp_521_mont_mul_21(t4, t4, q->y, p521_mod, p521_mp_mod);
  34996. if ((~p->infinity) & (~q->infinity) &
  34997. sp_521_cmp_equal_21(p->x, t2) &
  34998. sp_521_cmp_equal_21(p->y, t4)) {
  34999. sp_521_proj_point_dbl_21(r, p, t);
  35000. }
  35001. else {
  35002. sp_digit* x = t2;
  35003. sp_digit* y = t3;
  35004. sp_digit* z = t6;
  35005. /* H = U2 - X1 */
  35006. sp_521_mont_sub_21(t2, t2, p->x, p521_mod);
  35007. /* R = S2 - Y1 */
  35008. sp_521_mont_sub_21(t4, t4, p->y, p521_mod);
  35009. /* Z3 = H*Z1 */
  35010. sp_521_mont_mul_21(z, p->z, t2, p521_mod, p521_mp_mod);
  35011. /* X3 = R^2 - H^3 - 2*X1*H^2 */
  35012. sp_521_mont_sqr_21(t1, t2, p521_mod, p521_mp_mod);
  35013. sp_521_mont_mul_21(t3, p->x, t1, p521_mod, p521_mp_mod);
  35014. sp_521_mont_mul_21(t1, t1, t2, p521_mod, p521_mp_mod);
  35015. sp_521_mont_sqr_21(t2, t4, p521_mod, p521_mp_mod);
  35016. sp_521_mont_sub_21(t2, t2, t1, p521_mod);
  35017. sp_521_mont_dbl_21(t5, t3, p521_mod);
  35018. sp_521_mont_sub_21(x, t2, t5, p521_mod);
  35019. /* Y3 = R*(X1*H^2 - X3) - Y1*H^3 */
  35020. sp_521_mont_sub_21(t3, t3, x, p521_mod);
  35021. sp_521_mont_mul_21(t3, t3, t4, p521_mod, p521_mp_mod);
  35022. sp_521_mont_mul_21(t1, t1, p->y, p521_mod, p521_mp_mod);
  35023. sp_521_mont_sub_21(y, t3, t1, p521_mod);
  35024. {
  35025. int i;
  35026. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  35027. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  35028. sp_digit maskt = ~(maskp | maskq);
  35029. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  35030. for (i = 0; i < 21; i++) {
  35031. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  35032. (x[i] & maskt);
  35033. }
  35034. for (i = 0; i < 21; i++) {
  35035. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  35036. (y[i] & maskt);
  35037. }
  35038. for (i = 0; i < 21; i++) {
  35039. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  35040. (z[i] & maskt);
  35041. }
  35042. r->z[0] |= inf;
  35043. r->infinity = (word32)inf;
  35044. }
  35045. }
  35046. }
  35047. #ifdef FP_ECC
  35048. /* Convert the projective point to affine.
  35049. * Ordinates are in Montgomery form.
  35050. *
  35051. * a Point to convert.
  35052. * t Temporary data.
  35053. */
  35054. static void sp_521_proj_to_affine_21(sp_point_521* a, sp_digit* t)
  35055. {
  35056. sp_digit* t1 = t;
  35057. sp_digit* t2 = t + 2 * 21;
  35058. sp_digit* tmp = t + 4 * 21;
  35059. sp_521_mont_inv_21(t1, a->z, tmp);
  35060. sp_521_mont_sqr_21(t2, t1, p521_mod, p521_mp_mod);
  35061. sp_521_mont_mul_21(t1, t2, t1, p521_mod, p521_mp_mod);
  35062. sp_521_mont_mul_21(a->x, a->x, t2, p521_mod, p521_mp_mod);
  35063. sp_521_mont_mul_21(a->y, a->y, t1, p521_mod, p521_mp_mod);
  35064. XMEMCPY(a->z, p521_norm_mod, sizeof(p521_norm_mod));
  35065. }
  35066. /* Generate the pre-computed table of points for the base point.
  35067. *
  35068. * width = 8
  35069. * 256 entries
  35070. * 65 bits between
  35071. *
  35072. * a The base point.
  35073. * table Place to store generated point data.
  35074. * tmp Temporary data.
  35075. * heap Heap to use for allocation.
  35076. */
  35077. static int sp_521_gen_stripe_table_21(const sp_point_521* a,
  35078. sp_table_entry_521* table, sp_digit* tmp, void* heap)
  35079. {
  35080. #ifdef WOLFSSL_SP_SMALL_STACK
  35081. sp_point_521* t = NULL;
  35082. #else
  35083. sp_point_521 t[3];
  35084. #endif
  35085. sp_point_521* s1 = NULL;
  35086. sp_point_521* s2 = NULL;
  35087. int i;
  35088. int j;
  35089. int err = MP_OKAY;
  35090. (void)heap;
  35091. #ifdef WOLFSSL_SP_SMALL_STACK
  35092. t = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 3, heap,
  35093. DYNAMIC_TYPE_ECC);
  35094. if (t == NULL)
  35095. err = MEMORY_E;
  35096. #endif
  35097. if (err == MP_OKAY) {
  35098. s1 = t + 1;
  35099. s2 = t + 2;
  35100. err = sp_521_mod_mul_norm_21(t->x, a->x, p521_mod);
  35101. }
  35102. if (err == MP_OKAY) {
  35103. err = sp_521_mod_mul_norm_21(t->y, a->y, p521_mod);
  35104. }
  35105. if (err == MP_OKAY) {
  35106. err = sp_521_mod_mul_norm_21(t->z, a->z, p521_mod);
  35107. }
  35108. if (err == MP_OKAY) {
  35109. t->infinity = 0;
  35110. sp_521_proj_to_affine_21(t, tmp);
  35111. XMEMCPY(s1->z, p521_norm_mod, sizeof(p521_norm_mod));
  35112. s1->infinity = 0;
  35113. XMEMCPY(s2->z, p521_norm_mod, sizeof(p521_norm_mod));
  35114. s2->infinity = 0;
  35115. /* table[0] = {0, 0, infinity} */
  35116. XMEMSET(&table[0], 0, sizeof(sp_table_entry_521));
  35117. /* table[1] = Affine version of 'a' in Montgomery form */
  35118. XMEMCPY(table[1].x, t->x, sizeof(table->x));
  35119. XMEMCPY(table[1].y, t->y, sizeof(table->y));
  35120. for (i=1; i<8; i++) {
  35121. sp_521_proj_point_dbl_n_21(t, 66, tmp);
  35122. sp_521_proj_to_affine_21(t, tmp);
  35123. XMEMCPY(table[1<<i].x, t->x, sizeof(table->x));
  35124. XMEMCPY(table[1<<i].y, t->y, sizeof(table->y));
  35125. }
  35126. for (i=1; i<8; i++) {
  35127. XMEMCPY(s1->x, table[1<<i].x, sizeof(table->x));
  35128. XMEMCPY(s1->y, table[1<<i].y, sizeof(table->y));
  35129. for (j=(1<<i)+1; j<(1<<(i+1)); j++) {
  35130. XMEMCPY(s2->x, table[j-(1<<i)].x, sizeof(table->x));
  35131. XMEMCPY(s2->y, table[j-(1<<i)].y, sizeof(table->y));
  35132. sp_521_proj_point_add_qz1_21(t, s1, s2, tmp);
  35133. sp_521_proj_to_affine_21(t, tmp);
  35134. XMEMCPY(table[j].x, t->x, sizeof(table->x));
  35135. XMEMCPY(table[j].y, t->y, sizeof(table->y));
  35136. }
  35137. }
  35138. }
  35139. #ifdef WOLFSSL_SP_SMALL_STACK
  35140. if (t != NULL)
  35141. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  35142. #endif
  35143. return err;
  35144. }
  35145. #endif /* FP_ECC */
  35146. #ifndef WC_NO_CACHE_RESISTANT
  35147. /* Touch each possible entry that could be being copied.
  35148. *
  35149. * r Point to copy into.
  35150. * table Table - start of the entries to access
  35151. * idx Index of entry to retrieve.
  35152. */
  35153. static void sp_521_get_entry_256_21(sp_point_521* r,
  35154. const sp_table_entry_521* table, int idx)
  35155. {
  35156. int i;
  35157. sp_digit mask;
  35158. r->x[0] = 0;
  35159. r->x[1] = 0;
  35160. r->x[2] = 0;
  35161. r->x[3] = 0;
  35162. r->x[4] = 0;
  35163. r->x[5] = 0;
  35164. r->x[6] = 0;
  35165. r->x[7] = 0;
  35166. r->x[8] = 0;
  35167. r->x[9] = 0;
  35168. r->x[10] = 0;
  35169. r->x[11] = 0;
  35170. r->x[12] = 0;
  35171. r->x[13] = 0;
  35172. r->x[14] = 0;
  35173. r->x[15] = 0;
  35174. r->x[16] = 0;
  35175. r->x[17] = 0;
  35176. r->x[18] = 0;
  35177. r->x[19] = 0;
  35178. r->x[20] = 0;
  35179. r->y[0] = 0;
  35180. r->y[1] = 0;
  35181. r->y[2] = 0;
  35182. r->y[3] = 0;
  35183. r->y[4] = 0;
  35184. r->y[5] = 0;
  35185. r->y[6] = 0;
  35186. r->y[7] = 0;
  35187. r->y[8] = 0;
  35188. r->y[9] = 0;
  35189. r->y[10] = 0;
  35190. r->y[11] = 0;
  35191. r->y[12] = 0;
  35192. r->y[13] = 0;
  35193. r->y[14] = 0;
  35194. r->y[15] = 0;
  35195. r->y[16] = 0;
  35196. r->y[17] = 0;
  35197. r->y[18] = 0;
  35198. r->y[19] = 0;
  35199. r->y[20] = 0;
  35200. for (i = 1; i < 256; i++) {
  35201. mask = 0 - (i == idx);
  35202. r->x[0] |= mask & table[i].x[0];
  35203. r->x[1] |= mask & table[i].x[1];
  35204. r->x[2] |= mask & table[i].x[2];
  35205. r->x[3] |= mask & table[i].x[3];
  35206. r->x[4] |= mask & table[i].x[4];
  35207. r->x[5] |= mask & table[i].x[5];
  35208. r->x[6] |= mask & table[i].x[6];
  35209. r->x[7] |= mask & table[i].x[7];
  35210. r->x[8] |= mask & table[i].x[8];
  35211. r->x[9] |= mask & table[i].x[9];
  35212. r->x[10] |= mask & table[i].x[10];
  35213. r->x[11] |= mask & table[i].x[11];
  35214. r->x[12] |= mask & table[i].x[12];
  35215. r->x[13] |= mask & table[i].x[13];
  35216. r->x[14] |= mask & table[i].x[14];
  35217. r->x[15] |= mask & table[i].x[15];
  35218. r->x[16] |= mask & table[i].x[16];
  35219. r->x[17] |= mask & table[i].x[17];
  35220. r->x[18] |= mask & table[i].x[18];
  35221. r->x[19] |= mask & table[i].x[19];
  35222. r->x[20] |= mask & table[i].x[20];
  35223. r->y[0] |= mask & table[i].y[0];
  35224. r->y[1] |= mask & table[i].y[1];
  35225. r->y[2] |= mask & table[i].y[2];
  35226. r->y[3] |= mask & table[i].y[3];
  35227. r->y[4] |= mask & table[i].y[4];
  35228. r->y[5] |= mask & table[i].y[5];
  35229. r->y[6] |= mask & table[i].y[6];
  35230. r->y[7] |= mask & table[i].y[7];
  35231. r->y[8] |= mask & table[i].y[8];
  35232. r->y[9] |= mask & table[i].y[9];
  35233. r->y[10] |= mask & table[i].y[10];
  35234. r->y[11] |= mask & table[i].y[11];
  35235. r->y[12] |= mask & table[i].y[12];
  35236. r->y[13] |= mask & table[i].y[13];
  35237. r->y[14] |= mask & table[i].y[14];
  35238. r->y[15] |= mask & table[i].y[15];
  35239. r->y[16] |= mask & table[i].y[16];
  35240. r->y[17] |= mask & table[i].y[17];
  35241. r->y[18] |= mask & table[i].y[18];
  35242. r->y[19] |= mask & table[i].y[19];
  35243. r->y[20] |= mask & table[i].y[20];
  35244. }
  35245. }
  35246. #endif /* !WC_NO_CACHE_RESISTANT */
  35247. /* Multiply the point by the scalar and return the result.
  35248. * If map is true then convert result to affine coordinates.
  35249. *
  35250. * Stripe implementation.
  35251. * Pre-generated: 2^0, 2^65, ...
  35252. * Pre-generated: products of all combinations of above.
  35253. * 8 doubles and adds (with qz=1)
  35254. *
  35255. * r Resulting point.
  35256. * k Scalar to multiply by.
  35257. * table Pre-computed table.
  35258. * map Indicates whether to convert result to affine.
  35259. * ct Constant time required.
  35260. * heap Heap to use for allocation.
  35261. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  35262. */
  35263. static int sp_521_ecc_mulmod_stripe_21(sp_point_521* r, const sp_point_521* g,
  35264. const sp_table_entry_521* table, const sp_digit* k, int map,
  35265. int ct, void* heap)
  35266. {
  35267. #ifdef WOLFSSL_SP_SMALL_STACK
  35268. sp_point_521* rt = NULL;
  35269. sp_digit* t = NULL;
  35270. #else
  35271. sp_point_521 rt[2];
  35272. sp_digit t[2 * 21 * 6];
  35273. #endif
  35274. sp_point_521* p = NULL;
  35275. int i;
  35276. int j;
  35277. int y;
  35278. int x;
  35279. int err = MP_OKAY;
  35280. (void)g;
  35281. /* Constant time used for cache attack resistance implementation. */
  35282. (void)ct;
  35283. (void)heap;
  35284. #ifdef WOLFSSL_SP_SMALL_STACK
  35285. rt = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap,
  35286. DYNAMIC_TYPE_ECC);
  35287. if (rt == NULL)
  35288. err = MEMORY_E;
  35289. if (err == MP_OKAY) {
  35290. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 6, heap,
  35291. DYNAMIC_TYPE_ECC);
  35292. if (t == NULL)
  35293. err = MEMORY_E;
  35294. }
  35295. #endif
  35296. if (err == MP_OKAY) {
  35297. p = rt + 1;
  35298. XMEMCPY(p->z, p521_norm_mod, sizeof(p521_norm_mod));
  35299. XMEMCPY(rt->z, p521_norm_mod, sizeof(p521_norm_mod));
  35300. y = 0;
  35301. x = 65;
  35302. for (j=0; j<8 && x<521; j++) {
  35303. y |= (int)(((k[x / 25] >> (x % 25)) & 1) << j);
  35304. x += 66;
  35305. }
  35306. #ifndef WC_NO_CACHE_RESISTANT
  35307. if (ct) {
  35308. sp_521_get_entry_256_21(rt, table, y);
  35309. } else
  35310. #endif
  35311. {
  35312. XMEMCPY(rt->x, table[y].x, sizeof(table[y].x));
  35313. XMEMCPY(rt->y, table[y].y, sizeof(table[y].y));
  35314. }
  35315. rt->infinity = !y;
  35316. for (i=64; i>=0; i--) {
  35317. y = 0;
  35318. x = i;
  35319. for (j=0; j<8 && x<521; j++) {
  35320. y |= (int)(((k[x / 25] >> (x % 25)) & 1) << j);
  35321. x += 66;
  35322. }
  35323. sp_521_proj_point_dbl_21(rt, rt, t);
  35324. #ifndef WC_NO_CACHE_RESISTANT
  35325. if (ct) {
  35326. sp_521_get_entry_256_21(p, table, y);
  35327. }
  35328. else
  35329. #endif
  35330. {
  35331. XMEMCPY(p->x, table[y].x, sizeof(table[y].x));
  35332. XMEMCPY(p->y, table[y].y, sizeof(table[y].y));
  35333. }
  35334. p->infinity = !y;
  35335. sp_521_proj_point_add_qz1_21(rt, rt, p, t);
  35336. }
  35337. if (map != 0) {
  35338. sp_521_map_21(r, rt, t);
  35339. }
  35340. else {
  35341. XMEMCPY(r, rt, sizeof(sp_point_521));
  35342. }
  35343. }
  35344. #ifdef WOLFSSL_SP_SMALL_STACK
  35345. if (t != NULL)
  35346. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  35347. if (rt != NULL)
  35348. XFREE(rt, heap, DYNAMIC_TYPE_ECC);
  35349. #endif
  35350. return err;
  35351. }
  35352. #ifdef FP_ECC
  35353. #ifndef FP_ENTRIES
  35354. #define FP_ENTRIES 16
  35355. #endif
  35356. /* Cache entry - holds precomputation tables for a point. */
  35357. typedef struct sp_cache_521_t {
  35358. /* X ordinate of point that table was generated from. */
  35359. sp_digit x[21];
  35360. /* Y ordinate of point that table was generated from. */
  35361. sp_digit y[21];
  35362. /* Precomputation table for point. */
  35363. sp_table_entry_521 table[256];
  35364. /* Count of entries in table. */
  35365. uint32_t cnt;
  35366. /* Point and table set in entry. */
  35367. int set;
  35368. } sp_cache_521_t;
  35369. /* Cache of tables. */
  35370. static THREAD_LS_T sp_cache_521_t sp_cache_521[FP_ENTRIES];
  35371. /* Index of last entry in cache. */
  35372. static THREAD_LS_T int sp_cache_521_last = -1;
  35373. /* Cache has been initialized. */
  35374. static THREAD_LS_T int sp_cache_521_inited = 0;
  35375. #ifndef HAVE_THREAD_LS
  35376. static volatile int initCacheMutex_521 = 0;
  35377. static wolfSSL_Mutex sp_cache_521_lock;
  35378. #endif
  35379. /* Get the cache entry for the point.
  35380. *
  35381. * g [in] Point scalar multiplying.
  35382. * cache [out] Cache table to use.
  35383. */
  35384. static void sp_ecc_get_cache_521(const sp_point_521* g, sp_cache_521_t** cache)
  35385. {
  35386. int i;
  35387. int j;
  35388. uint32_t least;
  35389. if (sp_cache_521_inited == 0) {
  35390. for (i=0; i<FP_ENTRIES; i++) {
  35391. sp_cache_521[i].set = 0;
  35392. }
  35393. sp_cache_521_inited = 1;
  35394. }
  35395. /* Compare point with those in cache. */
  35396. for (i=0; i<FP_ENTRIES; i++) {
  35397. if (!sp_cache_521[i].set)
  35398. continue;
  35399. if (sp_521_cmp_equal_21(g->x, sp_cache_521[i].x) &
  35400. sp_521_cmp_equal_21(g->y, sp_cache_521[i].y)) {
  35401. sp_cache_521[i].cnt++;
  35402. break;
  35403. }
  35404. }
  35405. /* No match. */
  35406. if (i == FP_ENTRIES) {
  35407. /* Find empty entry. */
  35408. i = (sp_cache_521_last + 1) % FP_ENTRIES;
  35409. for (; i != sp_cache_521_last; i=(i+1)%FP_ENTRIES) {
  35410. if (!sp_cache_521[i].set) {
  35411. break;
  35412. }
  35413. }
  35414. /* Evict least used. */
  35415. if (i == sp_cache_521_last) {
  35416. least = sp_cache_521[0].cnt;
  35417. for (j=1; j<FP_ENTRIES; j++) {
  35418. if (sp_cache_521[j].cnt < least) {
  35419. i = j;
  35420. least = sp_cache_521[i].cnt;
  35421. }
  35422. }
  35423. }
  35424. XMEMCPY(sp_cache_521[i].x, g->x, sizeof(sp_cache_521[i].x));
  35425. XMEMCPY(sp_cache_521[i].y, g->y, sizeof(sp_cache_521[i].y));
  35426. sp_cache_521[i].set = 1;
  35427. sp_cache_521[i].cnt = 1;
  35428. }
  35429. *cache = &sp_cache_521[i];
  35430. sp_cache_521_last = i;
  35431. }
  35432. #endif /* FP_ECC */
  35433. /* Multiply the base point of P521 by the scalar and return the result.
  35434. * If map is true then convert result to affine coordinates.
  35435. *
  35436. * r Resulting point.
  35437. * g Point to multiply.
  35438. * k Scalar to multiply by.
  35439. * map Indicates whether to convert result to affine.
  35440. * ct Constant time required.
  35441. * heap Heap to use for allocation.
  35442. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  35443. */
  35444. static int sp_521_ecc_mulmod_21(sp_point_521* r, const sp_point_521* g,
  35445. const sp_digit* k, int map, int ct, void* heap)
  35446. {
  35447. #ifndef FP_ECC
  35448. return sp_521_ecc_mulmod_win_add_sub_21(r, g, k, map, ct, heap);
  35449. #else
  35450. #ifdef WOLFSSL_SP_SMALL_STACK
  35451. sp_digit* tmp;
  35452. #else
  35453. sp_digit tmp[2 * 21 * 6];
  35454. #endif
  35455. sp_cache_521_t* cache;
  35456. int err = MP_OKAY;
  35457. #ifdef WOLFSSL_SP_SMALL_STACK
  35458. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 6, heap, DYNAMIC_TYPE_ECC);
  35459. if (tmp == NULL) {
  35460. err = MEMORY_E;
  35461. }
  35462. #endif
  35463. #ifndef HAVE_THREAD_LS
  35464. if (err == MP_OKAY) {
  35465. if (initCacheMutex_521 == 0) {
  35466. wc_InitMutex(&sp_cache_521_lock);
  35467. initCacheMutex_521 = 1;
  35468. }
  35469. if (wc_LockMutex(&sp_cache_521_lock) != 0) {
  35470. err = BAD_MUTEX_E;
  35471. }
  35472. }
  35473. #endif /* HAVE_THREAD_LS */
  35474. if (err == MP_OKAY) {
  35475. sp_ecc_get_cache_521(g, &cache);
  35476. if (cache->cnt == 2)
  35477. sp_521_gen_stripe_table_21(g, cache->table, tmp, heap);
  35478. #ifndef HAVE_THREAD_LS
  35479. wc_UnLockMutex(&sp_cache_521_lock);
  35480. #endif /* HAVE_THREAD_LS */
  35481. if (cache->cnt < 2) {
  35482. err = sp_521_ecc_mulmod_win_add_sub_21(r, g, k, map, ct, heap);
  35483. }
  35484. else {
  35485. err = sp_521_ecc_mulmod_stripe_21(r, g, cache->table, k,
  35486. map, ct, heap);
  35487. }
  35488. }
  35489. #ifdef WOLFSSL_SP_SMALL_STACK
  35490. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  35491. #endif
  35492. return err;
  35493. #endif
  35494. }
  35495. #endif
  35496. /* Multiply the point by the scalar and return the result.
  35497. * If map is true then convert result to affine coordinates.
  35498. *
  35499. * km Scalar to multiply by.
  35500. * p Point to multiply.
  35501. * r Resulting point.
  35502. * map Indicates whether to convert result to affine.
  35503. * heap Heap to use for allocation.
  35504. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  35505. */
  35506. int sp_ecc_mulmod_521(const mp_int* km, const ecc_point* gm, ecc_point* r,
  35507. int map, void* heap)
  35508. {
  35509. #ifdef WOLFSSL_SP_SMALL_STACK
  35510. sp_point_521* point = NULL;
  35511. sp_digit* k = NULL;
  35512. #else
  35513. sp_point_521 point[1];
  35514. sp_digit k[21];
  35515. #endif
  35516. int err = MP_OKAY;
  35517. #ifdef WOLFSSL_SP_SMALL_STACK
  35518. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521), heap,
  35519. DYNAMIC_TYPE_ECC);
  35520. if (point == NULL)
  35521. err = MEMORY_E;
  35522. if (err == MP_OKAY) {
  35523. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21, heap,
  35524. DYNAMIC_TYPE_ECC);
  35525. if (k == NULL)
  35526. err = MEMORY_E;
  35527. }
  35528. #endif
  35529. if (err == MP_OKAY) {
  35530. sp_521_from_mp(k, 21, km);
  35531. sp_521_point_from_ecc_point_21(point, gm);
  35532. err = sp_521_ecc_mulmod_21(point, point, k, map, 1, heap);
  35533. }
  35534. if (err == MP_OKAY) {
  35535. err = sp_521_point_to_ecc_point_21(point, r);
  35536. }
  35537. #ifdef WOLFSSL_SP_SMALL_STACK
  35538. if (k != NULL)
  35539. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  35540. if (point != NULL)
  35541. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  35542. #endif
  35543. return err;
  35544. }
  35545. /* Multiply the point by the scalar, add point a and return the result.
  35546. * If map is true then convert result to affine coordinates.
  35547. *
  35548. * km Scalar to multiply by.
  35549. * p Point to multiply.
  35550. * am Point to add to scalar multiply result.
  35551. * inMont Point to add is in montgomery form.
  35552. * r Resulting point.
  35553. * map Indicates whether to convert result to affine.
  35554. * heap Heap to use for allocation.
  35555. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  35556. */
  35557. int sp_ecc_mulmod_add_521(const mp_int* km, const ecc_point* gm,
  35558. const ecc_point* am, int inMont, ecc_point* r, int map, void* heap)
  35559. {
  35560. #ifdef WOLFSSL_SP_SMALL_STACK
  35561. sp_point_521* point = NULL;
  35562. sp_digit* k = NULL;
  35563. #else
  35564. sp_point_521 point[2];
  35565. sp_digit k[21 + 21 * 2 * 6];
  35566. #endif
  35567. sp_point_521* addP = NULL;
  35568. sp_digit* tmp = NULL;
  35569. int err = MP_OKAY;
  35570. #ifdef WOLFSSL_SP_SMALL_STACK
  35571. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap,
  35572. DYNAMIC_TYPE_ECC);
  35573. if (point == NULL)
  35574. err = MEMORY_E;
  35575. if (err == MP_OKAY) {
  35576. k = (sp_digit*)XMALLOC(
  35577. sizeof(sp_digit) * (21 + 21 * 2 * 6), heap,
  35578. DYNAMIC_TYPE_ECC);
  35579. if (k == NULL)
  35580. err = MEMORY_E;
  35581. }
  35582. #endif
  35583. if (err == MP_OKAY) {
  35584. addP = point + 1;
  35585. tmp = k + 21;
  35586. sp_521_from_mp(k, 21, km);
  35587. sp_521_point_from_ecc_point_21(point, gm);
  35588. sp_521_point_from_ecc_point_21(addP, am);
  35589. }
  35590. if ((err == MP_OKAY) && (!inMont)) {
  35591. err = sp_521_mod_mul_norm_21(addP->x, addP->x, p521_mod);
  35592. }
  35593. if ((err == MP_OKAY) && (!inMont)) {
  35594. err = sp_521_mod_mul_norm_21(addP->y, addP->y, p521_mod);
  35595. }
  35596. if ((err == MP_OKAY) && (!inMont)) {
  35597. err = sp_521_mod_mul_norm_21(addP->z, addP->z, p521_mod);
  35598. }
  35599. if (err == MP_OKAY) {
  35600. err = sp_521_ecc_mulmod_21(point, point, k, 0, 0, heap);
  35601. }
  35602. if (err == MP_OKAY) {
  35603. sp_521_proj_point_add_21(point, point, addP, tmp);
  35604. if (map) {
  35605. sp_521_map_21(point, point, tmp);
  35606. }
  35607. err = sp_521_point_to_ecc_point_21(point, r);
  35608. }
  35609. #ifdef WOLFSSL_SP_SMALL_STACK
  35610. if (k != NULL)
  35611. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  35612. if (point != NULL)
  35613. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  35614. #endif
  35615. return err;
  35616. }
  35617. #ifdef WOLFSSL_SP_SMALL
  35618. /* Multiply the base point of P521 by the scalar and return the result.
  35619. * If map is true then convert result to affine coordinates.
  35620. *
  35621. * r Resulting point.
  35622. * k Scalar to multiply by.
  35623. * map Indicates whether to convert result to affine.
  35624. * heap Heap to use for allocation.
  35625. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  35626. */
  35627. static int sp_521_ecc_mulmod_base_21(sp_point_521* r, const sp_digit* k,
  35628. int map, int ct, void* heap)
  35629. {
  35630. /* No pre-computed values. */
  35631. return sp_521_ecc_mulmod_21(r, &p521_base, k, map, ct, heap);
  35632. }
  35633. #ifdef WOLFSSL_SP_NONBLOCK
  35634. static int sp_521_ecc_mulmod_base_21_nb(sp_ecc_ctx_t* sp_ctx, sp_point_521* r,
  35635. const sp_digit* k, int map, int ct, void* heap)
  35636. {
  35637. /* No pre-computed values. */
  35638. return sp_521_ecc_mulmod_21_nb(sp_ctx, r, &p521_base, k, map, ct, heap);
  35639. }
  35640. #endif /* WOLFSSL_SP_NONBLOCK */
  35641. #else
  35642. /* Striping precomputation table.
  35643. * 8 points combined into a table of 256 points.
  35644. * Distance of 66 between points.
  35645. */
  35646. static const sp_table_entry_521 p521_table[256] = {
  35647. /* 0 */
  35648. { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  35649. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
  35650. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  35651. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
  35652. /* 1 */
  35653. { { 0x0e5bd66,0x13f18e1,0x0a6fe5f,0x030ad48,0x1348b3c,0x1fd46f1,
  35654. 0x1049e8b,0x051fc3b,0x1efe759,0x0a5af3b,0x14f6ea8,0x1ec0d69,
  35655. 0x01f828a,0x029fda9,0x19204e4,0x1688538,0x1662395,0x0cf1f65,
  35656. 0x1013a73,0x1c0d6e0,0x00c6858 },
  35657. { 0x1d16650,0x14a3b4f,0x090222f,0x0d44e58,0x153c708,0x1683b09,
  35658. 0x0e404fe,0x0818aa1,0x15ef426,0x1f7394c,0x1998b25,0x1a2e4e7,
  35659. 0x0817afb,0x0bcda23,0x1d51125,0x037b331,0x1b42c7d,0x02e452f,
  35660. 0x08ef001,0x12d4f13,0x0118392 } },
  35661. /* 2 */
  35662. { { 0x10ccb51,0x0c33387,0x1d2a00e,0x026ca92,0x187e1d0,0x194f6cd,
  35663. 0x13c86ca,0x06efeb1,0x0a3add3,0x16074d5,0x023fec1,0x0ba1d3a,
  35664. 0x07f13b3,0x0b3b0b1,0x02fd132,0x07de9bb,0x014758a,0x1d250c6,
  35665. 0x0010eb6,0x0aedbb4,0x013e96a },
  35666. { 0x12d95a3,0x1127c31,0x00a4af7,0x0298a49,0x19f15ef,0x0d5d0cb,
  35667. 0x018fa6f,0x00f55bb,0x0a962b7,0x0f029fa,0x1636637,0x05bc284,
  35668. 0x1cc598a,0x030e11a,0x0968674,0x1a6593f,0x110e8ff,0x0076a32,
  35669. 0x1de33ab,0x153ba3d,0x01852ae } },
  35670. /* 3 */
  35671. { { 0x0af1fe3,0x08eec75,0x14af42a,0x0488016,0x0db3866,0x15f8690,
  35672. 0x01aa486,0x081fed4,0x0a768c9,0x00943cd,0x1bb0de5,0x1579343,
  35673. 0x1cf3791,0x139c1a1,0x04fef98,0x1578392,0x0abe222,0x1b945a1,
  35674. 0x0e7bcc4,0x18150c5,0x0157874 },
  35675. { 0x0f03d49,0x078c273,0x180c2b2,0x083c917,0x09c357e,0x0e5ef7d,
  35676. 0x17bce05,0x078059c,0x15fd8dc,0x120e3d5,0x0c4275e,0x0f93f5d,
  35677. 0x184bef6,0x1427a69,0x0633286,0x0155c5f,0x07d672f,0x1bf01ea,
  35678. 0x15625a2,0x0356b03,0x000724b } },
  35679. /* 4 */
  35680. { { 0x19314e0,0x196a5ef,0x0ab2413,0x1bcf401,0x1aae850,0x177d81e,
  35681. 0x0420d60,0x1a4f246,0x1ec7fe6,0x078e141,0x15d2a20,0x132c333,
  35682. 0x072d5b3,0x1ca803f,0x0482e6c,0x1e07cbe,0x1734773,0x118691b,
  35683. 0x0de2da1,0x0324e67,0x0121f4c },
  35684. { 0x08b51f0,0x1ffb6fd,0x17c3c40,0x0281c57,0x0e7afb5,0x12a0b8d,
  35685. 0x0e03a0c,0x12a2260,0x0cda10d,0x01a80dc,0x0a3007a,0x0e3c9e7,
  35686. 0x0910577,0x1640383,0x14865aa,0x070431e,0x0aaa562,0x09b04d8,
  35687. 0x12829fc,0x0af20d2,0x01db8c2 } },
  35688. /* 5 */
  35689. { { 0x0c0958d,0x1b86659,0x0e1cc00,0x0cd34f6,0x09aef16,0x064d9c4,
  35690. 0x1cf3d20,0x0924f25,0x0fab3e1,0x194c279,0x12259c2,0x086ca0e,
  35691. 0x0a9751e,0x1699ed9,0x0ae6756,0x09b5539,0x132b44a,0x0a6ca2e,
  35692. 0x1b1dcc9,0x1994a42,0x000aa26 },
  35693. { 0x1e66d18,0x10ea0fc,0x19eb36f,0x0d5422f,0x00aeef9,0x186925c,
  35694. 0x0528b76,0x17e0a64,0x15c98b7,0x0e7d913,0x0f2121b,0x086dbfa,
  35695. 0x0c613e7,0x1e526a9,0x1c0fe84,0x03cc8dc,0x1771855,0x0864714,
  35696. 0x1ea149f,0x121d597,0x01c6f5e } },
  35697. /* 6 */
  35698. { { 0x0b2d58f,0x178f3a5,0x000a8b0,0x185412f,0x01bbf82,0x05dbb56,
  35699. 0x1ac91dc,0x17acb07,0x15667f7,0x1276cf6,0x1a25fa3,0x1b0dfb2,
  35700. 0x15d8c01,0x1fdf078,0x0e5684c,0x1b962cc,0x19dd99c,0x0a8f279,
  35701. 0x0837ac9,0x108494e,0x0082de0 },
  35702. { 0x0ea91af,0x129d930,0x1f765ea,0x0ef463b,0x04384af,0x084ddf5,
  35703. 0x1c8e573,0x1c39b05,0x0f30058,0x0be0ced,0x1e3a5e6,0x018dcb8,
  35704. 0x05443b6,0x0bad8c2,0x0ba6d7d,0x19c2df5,0x13308c2,0x12e7437,
  35705. 0x1d8fea1,0x19cb1e9,0x0073983 } },
  35706. /* 7 */
  35707. { { 0x017609d,0x09898c1,0x1002bba,0x084825f,0x1f8a9dd,0x163194b,
  35708. 0x19930a1,0x0bdc22f,0x07bf1c6,0x01bc16b,0x0fbb973,0x09b71a0,
  35709. 0x19e8c14,0x0d5c9bc,0x0b2b2ca,0x1098e03,0x1b5b077,0x190af58,
  35710. 0x0bff361,0x013f503,0x00f82c4 },
  35711. { 0x18139a4,0x09bb31b,0x0a4c01f,0x176ab7d,0x06d969e,0x045e4ee,
  35712. 0x035bda3,0x0858f8c,0x15f93f2,0x0274230,0x1c5f661,0x1454e82,
  35713. 0x0e8461c,0x185f890,0x04c39e7,0x133af1d,0x0026b56,0x170aaa5,
  35714. 0x093edb7,0x18ee04d,0x007de69 } },
  35715. /* 8 */
  35716. { { 0x1ee80d7,0x08dd825,0x19a586d,0x1eed25b,0x0e1f6a1,0x15e1de8,
  35717. 0x191b283,0x1e106f3,0x1930644,0x005ffd3,0x16c1dc7,0x170e721,
  35718. 0x0997c67,0x1d6d0e7,0x170cf87,0x16a2412,0x0ddac54,0x11e2805,
  35719. 0x0c46195,0x03a6c1a,0x00b0c23 },
  35720. { 0x1bcab2f,0x0494c1c,0x082818a,0x00c9ba4,0x00c0678,0x1ee1506,
  35721. 0x18211d8,0x1c60c5e,0x11938c3,0x074ed39,0x11bae62,0x1e5aa5c,
  35722. 0x1d69be8,0x152ef07,0x17234b5,0x01c4dca,0x163db2c,0x1f9d1fe,
  35723. 0x192ffd5,0x18db3e3,0x014a899 } },
  35724. /* 9 */
  35725. { { 0x005ce88,0x171d0f6,0x080a7fd,0x0d6d5fa,0x18fc249,0x1f5803f,
  35726. 0x081ddbe,0x080173a,0x1eebded,0x087605e,0x1c03ded,0x0e84d26,
  35727. 0x0eaef97,0x1fbd818,0x1b8de84,0x03eef00,0x1171b90,0x1ae78be,
  35728. 0x0a56b83,0x0dcbbf9,0x0159903 },
  35729. { 0x00e8e0c,0x1b25a80,0x17e402b,0x080df69,0x13f2ae0,0x0f91dd6,
  35730. 0x1699d12,0x152bec3,0x0255b25,0x0548c21,0x0f19403,0x07cd1c6,
  35731. 0x01fa6af,0x016013e,0x0dcf003,0x0814a28,0x1a19728,0x04cf9e6,
  35732. 0x03a1090,0x0c56f3a,0x00e798c } },
  35733. /* 10 */
  35734. { { 0x04d0f28,0x1e25457,0x01bba31,0x1eacda0,0x1a8a55e,0x1720119,
  35735. 0x17d9419,0x0ec6f30,0x15d321b,0x0f6655a,0x146c1e3,0x0dad706,
  35736. 0x0b38b96,0x0beaa45,0x022794d,0x156165d,0x02fe631,0x1bd4f47,
  35737. 0x1d714de,0x0c1f2bc,0x005945c },
  35738. { 0x067d79c,0x13e9a3c,0x0602f28,0x0b03903,0x1f460b1,0x15c628b,
  35739. 0x166ae5d,0x1b2fd85,0x061b91e,0x0682243,0x07457ff,0x144bb38,
  35740. 0x19730a7,0x1ca64ed,0x0b3c967,0x0b47714,0x1875dec,0x1473c25,
  35741. 0x1944c7b,0x0a4c0e7,0x0004062 } },
  35742. /* 11 */
  35743. { { 0x1631bba,0x0272e78,0x14937b8,0x1e2ade8,0x00e6c1d,0x0184c82,
  35744. 0x0fcc393,0x18e0cc0,0x16b6abe,0x1b24d21,0x053dbb6,0x0139ed7,
  35745. 0x15354f5,0x1b5bf05,0x1b3d1a4,0x0dba4ff,0x07eba1e,0x153d388,
  35746. 0x0251432,0x1db58ad,0x0022889 },
  35747. { 0x05596f2,0x148b768,0x0e2e404,0x1960479,0x03901da,0x0a55f0f,
  35748. 0x14fb39f,0x0264a03,0x0a9c903,0x140a820,0x051b42c,0x07e38da,
  35749. 0x169dbcd,0x1a770c4,0x08756c5,0x04df6df,0x161a912,0x024d750,
  35750. 0x02a0261,0x19ddbf7,0x0154754 } },
  35751. /* 12 */
  35752. { { 0x070b2f0,0x113d821,0x135ed93,0x117e9ae,0x04b34e4,0x13915d4,
  35753. 0x0fa2c30,0x039630d,0x19ff9b7,0x0a52c4e,0x15af13d,0x09be69f,
  35754. 0x1d9887e,0x1a097a4,0x119a7f5,0x13a2d6f,0x1bb77f8,0x020046c,
  35755. 0x040b81d,0x1284d79,0x01cfafb },
  35756. { 0x02935ca,0x07968b3,0x111b329,0x0732fb9,0x0847c70,0x1e3cfc1,
  35757. 0x1a794d4,0x1e98113,0x15215f0,0x16c6cc4,0x046e767,0x1179012,
  35758. 0x0359cf0,0x16f13d5,0x00d5039,0x0641a96,0x03ef69e,0x1a97a6b,
  35759. 0x13bc64e,0x02ffad2,0x00e6a02 } },
  35760. /* 13 */
  35761. { { 0x0214780,0x0f313ba,0x07aaddf,0x0e40e8b,0x0a06681,0x03fd80e,
  35762. 0x1e6dfa7,0x18fef0a,0x1d6d4b7,0x0aaa460,0x12a8e79,0x03214cd,
  35763. 0x0f45756,0x0c282d2,0x0506c0e,0x0c9d7f0,0x17c4c88,0x1d2e506,
  35764. 0x184a74f,0x15f2a13,0x0053bf8 },
  35765. { 0x1285092,0x194ec42,0x197ef26,0x151ddab,0x02f31da,0x0c555cc,
  35766. 0x1a43bd8,0x1a33866,0x0d2626e,0x1770a7a,0x1638243,0x0e160fd,
  35767. 0x0042295,0x039b682,0x1de483a,0x1a03a32,0x1ffede7,0x1a3f712,
  35768. 0x11eadce,0x0438757,0x01b93c9 } },
  35769. /* 14 */
  35770. { { 0x08b2b14,0x103e650,0x11fc2da,0x177e2e9,0x0a978de,0x0659525,
  35771. 0x0e0a310,0x0705239,0x090adc8,0x0e3c139,0x1b779a5,0x1655183,
  35772. 0x0008da8,0x087de91,0x073acbe,0x1729ce8,0x1e5322d,0x12fc4e4,
  35773. 0x1cf1523,0x0cc10b6,0x007d182 },
  35774. { 0x1efd012,0x1fc1516,0x1fbda7a,0x08b42a6,0x01ecb09,0x18408e8,
  35775. 0x1d4d4fb,0x1d478aa,0x1b2bd4d,0x0e44153,0x05a7216,0x12e4f7f,
  35776. 0x1b00a1f,0x0592d68,0x0eb7d78,0x0c00a0c,0x106f253,0x0260ff9,
  35777. 0x044bf86,0x02b7d88,0x01178e5 } },
  35778. /* 15 */
  35779. { { 0x1e3d3d5,0x03c3ff7,0x089e4c5,0x0b3b12e,0x09e76f6,0x1b567a9,
  35780. 0x1fb4782,0x1b22b8e,0x01c5e8d,0x015bd90,0x199ebe7,0x11e2bea,
  35781. 0x1478803,0x19abb77,0x031d9bf,0x02a95e7,0x1c80040,0x1cf8311,
  35782. 0x1a20ed4,0x078897b,0x009647d },
  35783. { 0x01b21a4,0x1ab1c6f,0x0704c81,0x02ae210,0x1b6399c,0x001accd,
  35784. 0x1819dd7,0x1ea645c,0x1ade60c,0x03fef3f,0x0641657,0x0881df8,
  35785. 0x001b195,0x0ebd9cb,0x1c2b233,0x14e7cfc,0x03d6a6f,0x02552d4,
  35786. 0x0c201d9,0x119f58c,0x004234f } },
  35787. /* 16 */
  35788. { { 0x06492ad,0x0f38d14,0x0b13b8c,0x08cbf0d,0x08f3de4,0x189e5a0,
  35789. 0x0035369,0x009d12e,0x1a86b71,0x1687af4,0x0b0585e,0x1c9e4ae,
  35790. 0x19d9a62,0x12e60e4,0x1488fbc,0x05c18ef,0x1613b96,0x0f6ffb4,
  35791. 0x0762c81,0x1a51e70,0x008e818 },
  35792. { 0x0df1f60,0x118e7c6,0x183dc84,0x16ce2ee,0x0b640f2,0x02d201c,
  35793. 0x1be3381,0x13f7ce4,0x0037068,0x11142ee,0x08372d0,0x1f1ee5d,
  35794. 0x037196b,0x0404331,0x1bde157,0x1fc9142,0x1c7c326,0x06a70cf,
  35795. 0x1da2fd1,0x190add1,0x013efdb } },
  35796. /* 17 */
  35797. { { 0x0a3ace5,0x06827f3,0x070778d,0x1d12c32,0x0dbb603,0x0f687a0,
  35798. 0x0001fdd,0x16b69b8,0x095b259,0x0f0735e,0x17c0805,0x14cc4c2,
  35799. 0x18dfbcb,0x098f51f,0x1b150cf,0x1f04965,0x0e4103f,0x1215858,
  35800. 0x1200ccb,0x02a0c18,0x0111193 },
  35801. { 0x05452f1,0x1f51402,0x1cee665,0x1ee3e7e,0x00b678c,0x1499474,
  35802. 0x0f77107,0x04694a5,0x0e6af1c,0x1f932b7,0x08579ed,0x0b73688,
  35803. 0x0bc4380,0x1852014,0x09cd3cb,0x0edc475,0x0794224,0x1f1e392,
  35804. 0x031833d,0x05d160d,0x01f16dc } },
  35805. /* 18 */
  35806. { { 0x1fc0de5,0x1d737ff,0x1c92f37,0x1f5694b,0x0801814,0x15546ed,
  35807. 0x0d963a8,0x0823202,0x1da4f04,0x1d8e57a,0x001847c,0x19b6682,
  35808. 0x08f24b9,0x0b7067c,0x10c93b6,0x0b90491,0x1342305,0x0a5bf51,
  35809. 0x0424b8a,0x06b6c91,0x01d36e8 },
  35810. { 0x1372f27,0x1bd7383,0x0669fad,0x150775c,0x0779b4f,0x014f5da,
  35811. 0x16b8595,0x07f42eb,0x0fc03ef,0x0176133,0x071f125,0x0d52d32,
  35812. 0x1c0e5fc,0x0b129e9,0x1d8793d,0x1ce7141,0x158de74,0x0bd08ff,
  35813. 0x0937a46,0x0499a8c,0x0002605 } },
  35814. /* 19 */
  35815. { { 0x1342e08,0x0e86500,0x02bd16d,0x016e93e,0x109ed4f,0x14ec022,
  35816. 0x00b6594,0x139d6aa,0x16d8035,0x15843ed,0x0120017,0x150e987,
  35817. 0x04eaa66,0x03ad43c,0x1cb1e83,0x062fdd2,0x0216874,0x0460b4f,
  35818. 0x1727efd,0x0aadc1c,0x014f81c },
  35819. { 0x120674d,0x05895f0,0x02b09ac,0x12433e0,0x06bf09b,0x0c65536,
  35820. 0x1ccb759,0x13c3c3c,0x18292d9,0x1b8e2d7,0x16fe031,0x0a524bf,
  35821. 0x1d5d813,0x1b3361b,0x06f5e60,0x1ed01cc,0x06a1d0d,0x1c6d64a,
  35822. 0x0e7c260,0x19ed098,0x009f58d } },
  35823. /* 20 */
  35824. { { 0x17dc837,0x148813d,0x0710505,0x096a1d6,0x0d71975,0x133a0d9,
  35825. 0x024ab5f,0x07009e8,0x1bc824a,0x0853f8e,0x082f3c7,0x00ad91c,
  35826. 0x10570b2,0x0d0c0ed,0x0cb8ee7,0x0a114ce,0x16e0a7b,0x13c4031,
  35827. 0x07dc124,0x1ea0599,0x004511a },
  35828. { 0x16f4ffa,0x106ca62,0x03e82e0,0x0589e18,0x1c6205a,0x1030350,
  35829. 0x0f53a86,0x1f733e6,0x079b316,0x1d5b233,0x0903f06,0x10a5c9e,
  35830. 0x0305aa0,0x096bee2,0x14e6de2,0x180e644,0x11206e3,0x181b2bf,
  35831. 0x1b6d98c,0x00a5019,0x0059284 } },
  35832. /* 21 */
  35833. { { 0x197760c,0x04388a1,0x141a434,0x0c393f9,0x19020b7,0x1f127bd,
  35834. 0x11fea61,0x1418ffd,0x0522335,0x119dc50,0x0728403,0x15fb5c4,
  35835. 0x0073dbe,0x1d81911,0x0301828,0x0bb4c8b,0x1b8ee14,0x1cdce39,
  35836. 0x1ffd8bb,0x0cc3ca4,0x00aa31c },
  35837. { 0x1430b5e,0x0c75840,0x15a6bd4,0x14a1dc1,0x132f9ce,0x175f45d,
  35838. 0x0c2d6a9,0x1121d9b,0x09fe1d6,0x18afbf9,0x0732687,0x11e634b,
  35839. 0x03ce5d6,0x0455953,0x159e650,0x19ca9e9,0x0ef4347,0x1742d8e,
  35840. 0x01b41dd,0x0847805,0x01768ff } },
  35841. /* 22 */
  35842. { { 0x1dcec23,0x0082619,0x1466159,0x179ba0e,0x1af0d61,0x07984d5,
  35843. 0x0bd4531,0x02a90db,0x1de4887,0x00de47a,0x0e6e8fc,0x15e3a6a,
  35844. 0x0cddd6b,0x1d1df47,0x1f99974,0x10cbf76,0x0c3cb5d,0x07c8ced,
  35845. 0x0485268,0x007b47e,0x0173fe2 },
  35846. { 0x0d4a3d1,0x174d0bc,0x1b6010e,0x110ca62,0x04d5cf5,0x0bb231d,
  35847. 0x09b0104,0x089d5e0,0x1f84afa,0x0b631c7,0x0908b4c,0x072fffd,
  35848. 0x13512f2,0x13115b0,0x07aa811,0x00d1ad2,0x0a397e7,0x02442b7,
  35849. 0x1286ccf,0x0365c7e,0x01b542d } },
  35850. /* 23 */
  35851. { { 0x1487402,0x196af0f,0x1757d46,0x0cf55e3,0x036016e,0x14e1057,
  35852. 0x1c7d5b6,0x1fa3d67,0x1ece45b,0x0dbe9b0,0x0a78609,0x0c6604f,
  35853. 0x0942db0,0x14208b2,0x08a1ddf,0x0e7a17e,0x0c44587,0x07afe70,
  35854. 0x175e97c,0x062a3a5,0x001fb2b },
  35855. { 0x1aa096a,0x1b9f47d,0x01e0409,0x17c1275,0x152726e,0x1f8bc08,
  35856. 0x1341cb1,0x0ecb8a7,0x0ab5dca,0x069efe8,0x1cb528e,0x1b0b0fd,
  35857. 0x02bb4a7,0x1bf588e,0x070804e,0x1445eb9,0x0340b6d,0x0af1a9e,
  35858. 0x0c97b2b,0x1aa14b4,0x0039846 } },
  35859. /* 24 */
  35860. { { 0x077df58,0x13b9b0b,0x15b1db6,0x0e396a1,0x164bd56,0x0407f91,
  35861. 0x11f5c28,0x0600887,0x1865324,0x0542a14,0x04079e8,0x1ba586a,
  35862. 0x1682002,0x0462e6b,0x0f1850d,0x1e27f7d,0x1aeca6c,0x07f8ac8,
  35863. 0x02fe370,0x0f85cd3,0x00fb91c },
  35864. { 0x0de14d5,0x02e5689,0x0089a9f,0x1ecac39,0x1c448c5,0x0dd9ed5,
  35865. 0x190c1f3,0x1af3f1b,0x1c76811,0x02c7808,0x1881267,0x00dcea8,
  35866. 0x091e898,0x04d3a72,0x0ab428b,0x06f87ca,0x05cb2be,0x0901a34,
  35867. 0x082f1cb,0x0c648a1,0x00ec7a8 } },
  35868. /* 25 */
  35869. { { 0x086786e,0x0c610c5,0x0b20ce0,0x08426fc,0x0d537f7,0x1375907,
  35870. 0x043469f,0x006bb2d,0x05cdc48,0x1c87638,0x1ef5d65,0x059049e,
  35871. 0x1446916,0x070f878,0x19fbe75,0x02b9413,0x08bce99,0x1e98609,
  35872. 0x11c489b,0x028becd,0x002d810 },
  35873. { 0x11d87e5,0x1a4fadb,0x1b68c49,0x02f6059,0x05f3b14,0x1d7f8b1,
  35874. 0x1b4bb82,0x04e048a,0x1fcae66,0x1fbd9d4,0x16617e5,0x1f1e6f7,
  35875. 0x010d6eb,0x1fd3686,0x0aa06e5,0x1e26e41,0x00121f2,0x0d94f8d,
  35876. 0x130376c,0x0d45f0b,0x003de32 } },
  35877. /* 26 */
  35878. { { 0x0c2ee78,0x19cc59c,0x0fb89bc,0x034eb41,0x00c3d10,0x0d3fc72,
  35879. 0x05c1959,0x0ba6b46,0x104019e,0x094c2f1,0x1d2dbb4,0x0c85702,
  35880. 0x0a21e2a,0x17c0529,0x0857ba2,0x1b01c4b,0x1e68518,0x12e8f07,
  35881. 0x13dbaa6,0x1782700,0x00848cb },
  35882. { 0x1d45169,0x143486f,0x0341da0,0x10b3a7d,0x18d7e09,0x1c5fe11,
  35883. 0x0204736,0x09046eb,0x0162cf6,0x04caa3d,0x056e321,0x167769a,
  35884. 0x06494ba,0x03024cd,0x0b2f15f,0x19fdb04,0x04ea8a1,0x1d62191,
  35885. 0x1f19662,0x0c68d2a,0x00d9435 } },
  35886. /* 27 */
  35887. { { 0x0271323,0x14929b4,0x135cac1,0x10939a0,0x04d9e0a,0x18e63e9,
  35888. 0x17efcac,0x0c355c6,0x157a3e3,0x07b25a7,0x13a1591,0x0d0c052,
  35889. 0x0e14904,0x01e76a5,0x120bb9d,0x1b48fbb,0x0a57e2c,0x065c953,
  35890. 0x1f07e5a,0x1885df7,0x013f989 },
  35891. { 0x0651600,0x0c5efdc,0x0bbafb6,0x08f479f,0x0c36343,0x18d1134,
  35892. 0x0950cd6,0x00f2742,0x1d58255,0x0c6d3ee,0x1ac7a55,0x16470a5,
  35893. 0x05a5173,0x114afaa,0x16b9614,0x1a203be,0x0ef6646,0x172a371,
  35894. 0x1627e18,0x02d458b,0x01faf7e } },
  35895. /* 28 */
  35896. { { 0x1ec136d,0x0364763,0x146c35d,0x0f9a226,0x18e1d82,0x03d08b7,
  35897. 0x0eb4fc6,0x0caec94,0x1136e84,0x18dcb47,0x060f08b,0x05290a1,
  35898. 0x19d41aa,0x1f38b92,0x08fb312,0x0293842,0x152763c,0x0ee6e55,
  35899. 0x008ae0b,0x0a16302,0x016da7f },
  35900. { 0x0a5e258,0x1299686,0x09efe67,0x0f2f6c5,0x0148ad1,0x1feef7d,
  35901. 0x090bb1d,0x1891a14,0x174f9b6,0x028c5e6,0x048b516,0x0170ffa,
  35902. 0x17c53b3,0x1da8596,0x033464f,0x155d377,0x0eebc01,0x08d0b4d,
  35903. 0x1789b82,0x1362143,0x01c57e4 } },
  35904. /* 29 */
  35905. { { 0x1210716,0x1f33a90,0x1000b2a,0x060fc04,0x01a296a,0x01bcadc,
  35906. 0x1047632,0x0d5295f,0x0dd9efa,0x079019a,0x15a1bda,0x13d6cef,
  35907. 0x155be2f,0x1fae713,0x04fc9de,0x0f8b8d4,0x041b975,0x07bec91,
  35908. 0x1d3d2e3,0x07a5e98,0x013270c },
  35909. { 0x1209aa4,0x0304e46,0x10dbe72,0x05b656a,0x06f413a,0x091a2ea,
  35910. 0x0b468a6,0x09f2d6e,0x19487c3,0x0379575,0x028dd46,0x02ed688,
  35911. 0x0e4fa72,0x1ed29ac,0x10824d9,0x1662074,0x1e3ff25,0x0788f56,
  35912. 0x017582e,0x0e02a6a,0x01a99a5 } },
  35913. /* 30 */
  35914. { { 0x07495bb,0x089c9b7,0x0746b85,0x109210f,0x0bd2fd2,0x1ebb7e7,
  35915. 0x0ac2ca7,0x0393846,0x1c60e72,0x0d06a4d,0x08278a8,0x1706a2f,
  35916. 0x189f582,0x0ec5d6f,0x0de027a,0x1176958,0x09e0ad4,0x1a5526f,
  35917. 0x0db3121,0x0826259,0x0027fd0 },
  35918. { 0x0d4fb6d,0x0817775,0x12fb015,0x1a14c05,0x160c25e,0x1fa503b,
  35919. 0x1a106f5,0x028b174,0x054edce,0x145b019,0x1d85330,0x1c72072,
  35920. 0x13b9d41,0x0c0f76c,0x086dc74,0x0961684,0x1c2332d,0x0e80871,
  35921. 0x0ac3906,0x0b144fb,0x0096dfe } },
  35922. /* 31 */
  35923. { { 0x1ebd24e,0x17e6b3e,0x01d5335,0x0135c56,0x1e3fca6,0x0be1365,
  35924. 0x108bbc8,0x07f4fb1,0x0b9620e,0x01681f0,0x07e1f75,0x042d8ff,
  35925. 0x0e634bf,0x04b97ff,0x0c7b14e,0x07cee45,0x1c1d60d,0x141d4ab,
  35926. 0x1da94df,0x1cbf0c1,0x0162edf },
  35927. { 0x0ea20b8,0x02a0078,0x0401028,0x1c3af2d,0x0872ac7,0x0d86561,
  35928. 0x097243b,0x14eeecb,0x0b62939,0x0fadc98,0x12dc227,0x0edd5e5,
  35929. 0x12f78a6,0x097f5e0,0x01ccafd,0x015a606,0x0deba19,0x09d3320,
  35930. 0x0f9f8d0,0x15c2bf2,0x00d536e } },
  35931. /* 32 */
  35932. { { 0x1c88f3c,0x08cfb50,0x1129b18,0x185d8d2,0x124e5fe,0x017f954,
  35933. 0x0b1815d,0x0f89915,0x0ddb22c,0x056ef0f,0x1496ed8,0x0719f4b,
  35934. 0x0097289,0x1608bef,0x16b13df,0x05383f4,0x0b74829,0x0a0f9ad,
  35935. 0x0bf657d,0x09d1f21,0x0180d1c },
  35936. { 0x1cd8358,0x0739ed3,0x0480bf1,0x0fe5439,0x19361a5,0x0a69441,
  35937. 0x1c4c2b6,0x1c5ede5,0x02b6a78,0x1bf1233,0x098b378,0x1f16f38,
  35938. 0x190babf,0x10dacbd,0x0b807bd,0x09cc8d9,0x1f0a60d,0x0ce0f19,
  35939. 0x1407e11,0x084501b,0x000e52a } },
  35940. /* 33 */
  35941. { { 0x1013755,0x1205207,0x03a5cb5,0x0ff7070,0x0b6dce7,0x1b25988,
  35942. 0x139e5fa,0x06c4f13,0x193ca5a,0x1382585,0x17ff263,0x01feb17,
  35943. 0x1218c36,0x191861b,0x0c7cc8e,0x10ba2a7,0x0885a73,0x1eb59c8,
  35944. 0x1ae4efd,0x0261eaa,0x004a071 },
  35945. { 0x0ef3f88,0x104b5ff,0x0514a68,0x1370567,0x02eba86,0x1332539,
  35946. 0x0612a1c,0x084ffc4,0x1858ff9,0x06e05d0,0x03276a8,0x1d6ae92,
  35947. 0x0833799,0x00ac467,0x0d5bd8a,0x19dc43a,0x07fa7b2,0x0beecde,
  35948. 0x0f3ebba,0x0349d14,0x00d21e6 } },
  35949. /* 34 */
  35950. { { 0x1068656,0x0db14f4,0x137fb17,0x193fdbc,0x023bd70,0x0a2aa33,
  35951. 0x156f7f3,0x0838f15,0x06291a7,0x1cc0ee9,0x19a23bd,0x1b24ec3,
  35952. 0x0f3ac53,0x0adc939,0x05a24a9,0x0dfd8d5,0x1b80654,0x1210bf3,
  35953. 0x0e78bd5,0x1807975,0x015e793 },
  35954. { 0x0ff39be,0x0caa1b7,0x1da023f,0x1db7fe9,0x1a1af07,0x120b0b2,
  35955. 0x1eaf6c0,0x05307a8,0x1d47980,0x1e2e97e,0x0b9becd,0x12f0c16,
  35956. 0x189d86d,0x0746dcc,0x18ca13b,0x17377c7,0x0b5d868,0x1cf824f,
  35957. 0x16b462c,0x1d14f13,0x018e3b3 } },
  35958. /* 35 */
  35959. { { 0x11e61f0,0x1362b72,0x1d5d5c0,0x0660fe4,0x1ddbcaa,0x1757a0e,
  35960. 0x09baec6,0x1752540,0x0e2d7f5,0x19f49be,0x1ab6468,0x003d78b,
  35961. 0x1d1f7cc,0x1723403,0x0ad9974,0x12a3321,0x1555341,0x0e15227,
  35962. 0x0599012,0x18394cf,0x00aa099 },
  35963. { 0x197e387,0x0d484c7,0x15a6d58,0x108bc3b,0x1605177,0x18eb55f,
  35964. 0x144adff,0x1123ff4,0x0d09a9c,0x16d2ad2,0x00b8ad0,0x18e3a45,
  35965. 0x0d5e5a7,0x13a0c2d,0x096880f,0x15dffbf,0x09dea0b,0x10cd89b,
  35966. 0x1b30285,0x1df2283,0x01a3a5e } },
  35967. /* 36 */
  35968. { { 0x0573b81,0x106853d,0x13bcabc,0x10cc329,0x1eac1ca,0x188e1a3,
  35969. 0x0b6342d,0x085de1a,0x0ba099d,0x17500b6,0x1ea329a,0x1a50a0c,
  35970. 0x0fa6609,0x1d09a8f,0x14b1801,0x04c68d4,0x018b11c,0x06d5c2c,
  35971. 0x0c700cf,0x1f48bb7,0x0121f17 },
  35972. { 0x03279d6,0x05c3d7e,0x07867ee,0x178403e,0x030e76a,0x1610eef,
  35973. 0x1aa0e01,0x09e055e,0x1c63f82,0x17ebf15,0x14694fa,0x1c4c8d7,
  35974. 0x047b074,0x1109c8b,0x1bd24c6,0x1b37f9a,0x139c172,0x0d5967e,
  35975. 0x16d673c,0x07d6969,0x010a62f } },
  35976. /* 37 */
  35977. { { 0x0689a1b,0x16f1b70,0x19cb900,0x1afb95f,0x1dccc9f,0x0e85fdc,
  35978. 0x0b5f895,0x1b3c9bd,0x04ada04,0x1f743f7,0x0b9dd35,0x073d7fa,
  35979. 0x1b5a850,0x1b8595c,0x0b1995d,0x0777450,0x026ba10,0x0d3d654,
  35980. 0x1f3541c,0x0051758,0x011aac7 },
  35981. { 0x00c8f04,0x0e9ce34,0x0d78b98,0x1969167,0x0f09c4c,0x1a279e1,
  35982. 0x026f655,0x126262c,0x0aaccb5,0x0b9725a,0x1ec825b,0x0194b5b,
  35983. 0x0fdb706,0x0fe9f66,0x1f6790c,0x054e78c,0x06fe175,0x00a43d1,
  35984. 0x134215f,0x0a6cc6c,0x01e33d9 } },
  35985. /* 38 */
  35986. { { 0x0ec9e7f,0x02835a6,0x063f999,0x0861557,0x044564b,0x1fd1425,
  35987. 0x1407c5c,0x0e4bc36,0x015c974,0x1dbdebf,0x1b00cf9,0x0f5105b,
  35988. 0x02d6cc6,0x0531dbb,0x18ba4d0,0x05f9a3f,0x01b3f8e,0x11d0427,
  35989. 0x0b9b9d4,0x1c9b513,0x00fdccc },
  35990. { 0x12fd820,0x1fc7760,0x1ccc1e5,0x152db48,0x125f892,0x0cbdfa1,
  35991. 0x0907556,0x19eb2fa,0x002b753,0x1779ad6,0x1f3ae8e,0x12bbece,
  35992. 0x0c8a73f,0x08ddd63,0x0a24adf,0x0f160b6,0x183cc52,0x1483a8a,
  35993. 0x11fd17d,0x1daa7f4,0x001c2f5 } },
  35994. /* 39 */
  35995. { { 0x140b79c,0x00b2f55,0x06a0e45,0x104b691,0x1fb6eed,0x16083fd,
  35996. 0x1adf629,0x117b426,0x18e01f2,0x018edc5,0x1e641f5,0x01bb49a,
  35997. 0x0584e5d,0x1238f34,0x0a451ca,0x0dff0d3,0x1699837,0x0ac6834,
  35998. 0x118c47f,0x0d36e98,0x0006ce3 },
  35999. { 0x0dd1452,0x1b9e88d,0x08a9b01,0x0bdb1d3,0x0e4e9c9,0x0ad2061,
  36000. 0x038cb28,0x11fd1ff,0x0af62f1,0x1e5be9b,0x05212cf,0x0ddddd9,
  36001. 0x1b2ca33,0x1d90202,0x15b9ea4,0x106a549,0x031956d,0x1b6c868,
  36002. 0x07280f9,0x0eac07b,0x00e5dd3 } },
  36003. /* 40 */
  36004. { { 0x1481bf7,0x194bec5,0x00f3317,0x0854267,0x06a2a3e,0x005cb60,
  36005. 0x14a3371,0x0793c28,0x11189da,0x115f9af,0x15fe9e6,0x1312d9a,
  36006. 0x0bb8adb,0x09abe99,0x0924d72,0x0df5b83,0x180c2d7,0x0a8fd92,
  36007. 0x13c8f78,0x043d684,0x01ba987 },
  36008. { 0x0a4b397,0x16d57a9,0x1952300,0x181a169,0x03c5f4c,0x1f3ce6e,
  36009. 0x136cded,0x16c537c,0x0b33970,0x1a19b76,0x0231ffc,0x16f9250,
  36010. 0x11ed3dc,0x011446d,0x0a43bfc,0x1ab35d8,0x151e96e,0x19523ce,
  36011. 0x1b63e97,0x1db0e0e,0x00929d7 } },
  36012. /* 41 */
  36013. { { 0x060043c,0x0d785f3,0x1d3763b,0x1602dc0,0x04aa2cc,0x061d9ec,
  36014. 0x1a39f8b,0x1893a46,0x05c269f,0x1da8098,0x0cf8d91,0x1dc27bc,
  36015. 0x04d0194,0x1c4e528,0x0cd86e5,0x1623bb6,0x033984d,0x0466a8c,
  36016. 0x03b24bc,0x1003d99,0x00c6d5b },
  36017. { 0x1ab9887,0x08e0aa3,0x0044cfe,0x14d6b56,0x0f285e2,0x1fe40c1,
  36018. 0x139684c,0x05936e6,0x038d869,0x021ad3a,0x00ba057,0x08f8865,
  36019. 0x0a3c92b,0x0e3de6d,0x048c7d6,0x1190c32,0x1c34d15,0x11d7212,
  36020. 0x1688f32,0x0d1fd78,0x00117f5 } },
  36021. /* 42 */
  36022. { { 0x15caa87,0x1eceadf,0x1276332,0x1ed1bb1,0x17bfc60,0x0a6f6f0,
  36023. 0x136ef1f,0x17ec7d6,0x18270b5,0x1b72ca2,0x063f9ef,0x0f4b981,
  36024. 0x1588713,0x02ebdc7,0x17ada1c,0x14a6794,0x0ee4b25,0x025bef7,
  36025. 0x09c029b,0x08b8649,0x00ef8e0 },
  36026. { 0x0cf52bc,0x00e4938,0x0a60583,0x152198c,0x0bf3f63,0x18147da,
  36027. 0x10872fc,0x1e2bffe,0x1523bef,0x140816b,0x1384142,0x1347173,
  36028. 0x1eff330,0x03310d8,0x0769340,0x0f00f1d,0x09fcc0a,0x14bbafc,
  36029. 0x005e184,0x0890ca0,0x00eb590 } },
  36030. /* 43 */
  36031. { { 0x1bd33ec,0x1327ef5,0x15e6299,0x019cb5a,0x0cf9a66,0x1dab768,
  36032. 0x1b01543,0x0ddd9a0,0x11d5aaa,0x0652fd6,0x09fc1ed,0x1cb7291,
  36033. 0x1a36dae,0x17f0e08,0x18de21f,0x0a897a5,0x0c491d2,0x120fb0d,
  36034. 0x0fff63a,0x1ee0e25,0x00be49d },
  36035. { 0x1acdb56,0x178fab2,0x0f79838,0x08bcbcb,0x12f13c8,0x1d02097,
  36036. 0x14d5385,0x1df72ff,0x1d9c93b,0x11433e7,0x055f922,0x02d64b5,
  36037. 0x1f9ca9d,0x050c31a,0x157066d,0x15ce23e,0x0f58d26,0x0cd9c34,
  36038. 0x1251507,0x0900829,0x0000ac4 } },
  36039. /* 44 */
  36040. { { 0x0ad38db,0x1e7c4ea,0x1445b06,0x027ae28,0x1180f38,0x18121d0,
  36041. 0x09d672d,0x0d8b698,0x1163a71,0x0eb26b1,0x122f6d7,0x1fd426c,
  36042. 0x09bbd2e,0x126f4cb,0x1c61fe7,0x1188b48,0x112e2de,0x1b2ef34,
  36043. 0x0f6b429,0x0be5389,0x0048e07 },
  36044. { 0x04dd88d,0x1aa3a2f,0x0bf000c,0x1100aef,0x1828363,0x19447b8,
  36045. 0x1700489,0x1bdc966,0x1e68989,0x0047ec8,0x1dc6eb4,0x062b9a7,
  36046. 0x0242142,0x1f26d0f,0x0c08ffc,0x05762b9,0x035b566,0x0bf35ce,
  36047. 0x1ec13f9,0x1e82caf,0x0072143 } },
  36048. /* 45 */
  36049. { { 0x0f40f2c,0x1823613,0x0c76c1a,0x18d9af8,0x1d5d246,0x09d4dbd,
  36050. 0x189c065,0x0df554a,0x08f0043,0x16494dc,0x0198356,0x125843a,
  36051. 0x0619373,0x0deb6df,0x1e7b456,0x087f3a4,0x15ad17c,0x09bbe26,
  36052. 0x03f3409,0x1db4a17,0x0179800 },
  36053. { 0x0132f31,0x0ee059b,0x0e8ee23,0x0255bce,0x0f8f4f0,0x1ef15cb,
  36054. 0x07b0c80,0x066710b,0x0231b65,0x0d81c0a,0x024f2bb,0x1a41428,
  36055. 0x19ad08c,0x0e15f17,0x1e1b511,0x1813f73,0x132f6eb,0x0fe9eca,
  36056. 0x0bbd1e3,0x16b1323,0x013d757 } },
  36057. /* 46 */
  36058. { { 0x00f894b,0x168802c,0x11bdf66,0x15b24bc,0x1612488,0x0d3432d,
  36059. 0x1f850b9,0x0268a92,0x117f9a8,0x0370829,0x0cd5072,0x0415f14,
  36060. 0x18d8aa8,0x1d336ab,0x1e41981,0x11c474c,0x0ae5f75,0x023efb0,
  36061. 0x1fe2ad7,0x1a99214,0x0107cad },
  36062. { 0x164ad0e,0x18227b3,0x06ccd5a,0x024a031,0x169fe0e,0x0a6db57,
  36063. 0x129897c,0x0a85bd5,0x11bd77d,0x0f93bcf,0x0a2573a,0x03e4b9f,
  36064. 0x0397991,0x1b78cd6,0x1a533b6,0x08963a9,0x01701af,0x0e1a99a,
  36065. 0x031c9fd,0x087ffea,0x003bcac } },
  36066. /* 47 */
  36067. { { 0x1c1d4cf,0x14a8e41,0x0d3c5d0,0x01648b8,0x003791d,0x16e638f,
  36068. 0x03bda70,0x0cfd51f,0x12a3107,0x152bd14,0x0522f4b,0x0d77625,
  36069. 0x03255b4,0x07f575c,0x1707824,0x17eb255,0x18c449a,0x0d06968,
  36070. 0x12a29a2,0x193feb8,0x00199e8 },
  36071. { 0x128171a,0x1dce6f5,0x01ef27d,0x07aaed3,0x0fd7840,0x1fc1267,
  36072. 0x1cefc8b,0x18ab169,0x1bf333c,0x104d9c9,0x13adcbb,0x0745603,
  36073. 0x0debff8,0x11014ce,0x0cd3114,0x1eea2b7,0x0a066eb,0x1d1e1f4,
  36074. 0x074173c,0x1c0f769,0x01a65de } },
  36075. /* 48 */
  36076. { { 0x114257b,0x0ac6b58,0x18c026a,0x03a92eb,0x129afd4,0x173d88b,
  36077. 0x1e6d4ea,0x1060e50,0x1edd1ac,0x1c8d849,0x19e5d41,0x0fa23d6,
  36078. 0x0acfefc,0x1133ada,0x152f4df,0x0a2fe1c,0x17e8d69,0x1c4d316,
  36079. 0x0084268,0x100bb04,0x006b96f },
  36080. { 0x1b5f9f4,0x0ea8bab,0x1345205,0x0c80b68,0x05c9e43,0x0380b07,
  36081. 0x1778392,0x1f06885,0x11ef6b3,0x09ff7ca,0x05febe5,0x19ebee9,
  36082. 0x17919e4,0x00b7785,0x18f3134,0x1ddda49,0x0872512,0x1fe2e55,
  36083. 0x0ef45c0,0x1480534,0x01b6f1b } },
  36084. /* 49 */
  36085. { { 0x09252ac,0x1421aa9,0x0360a99,0x00e9cf6,0x1da626c,0x1f43559,
  36086. 0x0330782,0x0a6aa10,0x14ed5dc,0x1a529fb,0x107f414,0x028019a,
  36087. 0x1ca9eff,0x0b3a448,0x1f25171,0x16b5a1c,0x095ec53,0x06f525c,
  36088. 0x1454262,0x0cf7de2,0x01ffefc },
  36089. { 0x06033fd,0x0e08498,0x1766623,0x13e6d0e,0x1b28797,0x019ae28,
  36090. 0x0bc9b8f,0x1ac9a73,0x1124e29,0x0392cfe,0x16f7f29,0x0ae1883,
  36091. 0x155d60c,0x06606c4,0x0892d84,0x1ff0c0c,0x0e5eea8,0x1d020ea,
  36092. 0x19361c1,0x01c2b95,0x01fd292 } },
  36093. /* 50 */
  36094. { { 0x167da85,0x0af8666,0x08559b4,0x08b58a9,0x0e98b6f,0x1638e1d,
  36095. 0x18087c6,0x0485e0b,0x0475592,0x1f59113,0x015b707,0x0ac2cdd,
  36096. 0x072a2f1,0x17da5d2,0x1ac5159,0x12416cb,0x1d2a29d,0x19a3445,
  36097. 0x07532e6,0x19d0ddf,0x0061943 },
  36098. { 0x0c91174,0x0b10c55,0x08d2d1a,0x1883bb2,0x05b519e,0x03b1d24,
  36099. 0x0b7ca7c,0x0676fdf,0x1712c8b,0x028bf93,0x0e18c26,0x1d8760a,
  36100. 0x04a02e7,0x0ff9f1f,0x0f116ec,0x0c90c8d,0x16f2949,0x1a35744,
  36101. 0x0f4ae4f,0x162c93d,0x01462ae } },
  36102. /* 51 */
  36103. { { 0x0e4d3c3,0x07a0ff4,0x076c7cd,0x1eb76fd,0x080d87f,0x085abce,
  36104. 0x1b02b64,0x15de042,0x1b87349,0x1125bb0,0x09b300a,0x0a50561,
  36105. 0x17054bc,0x17968ca,0x131c0a6,0x0d9ba76,0x0e2adbe,0x00725c8,
  36106. 0x181828d,0x0e9f024,0x00cf8e7 },
  36107. { 0x0229950,0x1cede17,0x0dc0f1f,0x0db3f05,0x0b11f84,0x0602f9d,
  36108. 0x1668fc4,0x19456f5,0x10f1820,0x01f56a7,0x1eccc88,0x1791997,
  36109. 0x1151dbc,0x0333837,0x1672bc0,0x13abc77,0x0250605,0x12d1cdf,
  36110. 0x12bf993,0x070f91b,0x014c984 } },
  36111. /* 52 */
  36112. { { 0x0011531,0x13abfc7,0x15f1c22,0x0587b9a,0x1f45b17,0x0ccf14b,
  36113. 0x127f70b,0x02b51d5,0x1b93b64,0x0a7740f,0x023a1a7,0x16a94a9,
  36114. 0x10a5833,0x05dbd5b,0x155870c,0x1e753bb,0x184b3bd,0x1daded1,
  36115. 0x177ccca,0x13f1c03,0x0124f90 },
  36116. { 0x141e782,0x0554255,0x0e1f16e,0x0d0a3bb,0x1de2012,0x0415e90,
  36117. 0x0a9f665,0x077e937,0x1f4b641,0x0cb1ef5,0x0788901,0x1f76f9a,
  36118. 0x0eed369,0x0dd6b07,0x1d25774,0x061dbb9,0x093892e,0x0f5a3ab,
  36119. 0x1c2884b,0x0237b15,0x010baaf } },
  36120. /* 53 */
  36121. { { 0x0ec64e2,0x100ba0b,0x1af9c51,0x1efaf8d,0x1fd14ac,0x05b8bb5,
  36122. 0x0128d9a,0x0383c6a,0x1741b04,0x171f9f9,0x0d9ec1c,0x0a945a7,
  36123. 0x0d651fa,0x12bec94,0x0fb728f,0x1e832c4,0x08b72c8,0x194dba7,
  36124. 0x09eaebb,0x13968e6,0x00383d9 },
  36125. { 0x0342a3f,0x0e859ed,0x0552023,0x05bde95,0x1200246,0x1ad4300,
  36126. 0x190bbaa,0x0da3638,0x106e54b,0x10f1502,0x1b3c697,0x021e218,
  36127. 0x109ba17,0x07c81e6,0x13f0d98,0x0cdea66,0x0011341,0x1cb4f00,
  36128. 0x15710d4,0x04c0e82,0x00fafaa } },
  36129. /* 54 */
  36130. { { 0x12de285,0x0687338,0x1717217,0x010d3eb,0x0d2ff8b,0x0769c4e,
  36131. 0x0ae4b7d,0x1086e54,0x055b99c,0x1a92698,0x0800cd8,0x0b45c0f,
  36132. 0x1346fef,0x0b704a4,0x0b20b6b,0x12a5614,0x02172a8,0x159b133,
  36133. 0x1c85fad,0x1963115,0x002c9af },
  36134. { 0x064c5b5,0x0ea3b4d,0x1f874ee,0x1c89899,0x00d8d5d,0x036dffd,
  36135. 0x163bc47,0x1daac10,0x141c14a,0x10ecbc7,0x1fa1533,0x1ce46bd,
  36136. 0x1d251f9,0x023a2ba,0x1430530,0x13807f3,0x18ebda8,0x0069641,
  36137. 0x1b32770,0x1e08166,0x016fa25 } },
  36138. /* 55 */
  36139. { { 0x0ad682d,0x0cef54e,0x0e46c8f,0x068c6d2,0x07acb1b,0x07926bc,
  36140. 0x0662170,0x19d3eb8,0x1d41883,0x1fb17e3,0x15791b7,0x13bea6a,
  36141. 0x05d1ab2,0x048e6d0,0x06c72ca,0x067daad,0x1c452c6,0x06d8a6d,
  36142. 0x08d150a,0x1770d85,0x01941ac },
  36143. { 0x0db8127,0x1386412,0x1d6f61a,0x1e836f9,0x04a6563,0x046cda4,
  36144. 0x16afae4,0x0151b09,0x1899c26,0x1755731,0x0da55ea,0x1656888,
  36145. 0x0d13ed6,0x0854964,0x1253e67,0x1972e77,0x02bd04b,0x1cbc797,
  36146. 0x05a9597,0x0711dee,0x007456a } },
  36147. /* 56 */
  36148. { { 0x0fc1f77,0x16ff24b,0x15a9820,0x1e268f5,0x104c435,0x15f22bd,
  36149. 0x0537097,0x155e84d,0x1b6f764,0x050b834,0x00f6859,0x07aa09b,
  36150. 0x10e0387,0x1064119,0x0e76d4b,0x1367d61,0x14ed423,0x14c4359,
  36151. 0x0620536,0x10fe54b,0x016a765 },
  36152. { 0x1c71a5d,0x07c7475,0x08cda46,0x050a80a,0x09141a4,0x0165e62,
  36153. 0x0273306,0x14fac7e,0x1e09057,0x17f2ce9,0x0763ad2,0x161bc47,
  36154. 0x12e633d,0x1eca4a5,0x12160b7,0x1fac375,0x0414704,0x0c5c8ad,
  36155. 0x13abbf6,0x0cd53bf,0x010ee08 } },
  36156. /* 57 */
  36157. { { 0x0e07a4d,0x0623829,0x1740ad4,0x11cbae8,0x1f6d38b,0x1789133,
  36158. 0x111f386,0x1ef6829,0x139c505,0x1f25a25,0x1ce6f80,0x0f2b0de,
  36159. 0x1c59f3d,0x13e178d,0x066f29f,0x1f5a994,0x01ec063,0x18e28e0,
  36160. 0x1d0a2be,0x126f4af,0x0080da3 },
  36161. { 0x02369fa,0x0654e88,0x18d7a76,0x16e0d81,0x0009bff,0x1aaec07,
  36162. 0x0669e5a,0x0985c14,0x0ac0d09,0x107216f,0x1061eb6,0x058af0f,
  36163. 0x166c1be,0x0e7d025,0x12b8b32,0x0e680da,0x0607657,0x0ad8675,
  36164. 0x1f258a1,0x04a48b8,0x00d82d5 } },
  36165. /* 58 */
  36166. { { 0x093de69,0x191c657,0x1a6db72,0x0677fb5,0x0963c83,0x1bcc1b2,
  36167. 0x07d37a2,0x15c6790,0x0ae8bf8,0x09d1122,0x1aeb338,0x0f0c987,
  36168. 0x160bc6e,0x0aad2d6,0x0de94f1,0x128b350,0x135bc7e,0x0c3aec6,
  36169. 0x07d1bf3,0x00aa69f,0x001fb37 },
  36170. { 0x1b974a1,0x093863f,0x1205e3a,0x01d3da4,0x03448fa,0x1ffdea1,
  36171. 0x1b0f592,0x078282c,0x1d79f4b,0x02d5221,0x1cca828,0x09e2773,
  36172. 0x1ed855a,0x164811a,0x1af3e36,0x0569097,0x1878db5,0x0b2c24c,
  36173. 0x1234274,0x1ab3e3c,0x0183aa4 } },
  36174. /* 59 */
  36175. { { 0x1ffad9f,0x02ebaed,0x03f3b96,0x09e833b,0x04df617,0x0349a2b,
  36176. 0x0fd679b,0x018dee7,0x183d59b,0x003c9e8,0x122542e,0x1f87253,
  36177. 0x0b6baf4,0x14cb15d,0x1116a54,0x024e77a,0x145eaa9,0x1a95b0c,
  36178. 0x1471e16,0x19bffe7,0x01be4fc },
  36179. { 0x0b2857f,0x1c26cbe,0x0fd0170,0x100d6f5,0x0cf8305,0x1673592,
  36180. 0x1745d0e,0x16dea51,0x0bc43d6,0x03dc7d1,0x1592e4b,0x117e29c,
  36181. 0x1a8f0e2,0x095cf80,0x1a6f1cf,0x107cc36,0x1403dd3,0x1d5c5f5,
  36182. 0x1e4651a,0x1d418b2,0x00aeacc } },
  36183. /* 60 */
  36184. { { 0x163c2de,0x05d7700,0x029269a,0x17d64ed,0x042d0b2,0x0d73b3e,
  36185. 0x1c493ff,0x086ad0d,0x10aaca9,0x136d2ea,0x02473e4,0x099dc02,
  36186. 0x0d699c3,0x09925f6,0x0951501,0x141527a,0x0f14193,0x08db5ac,
  36187. 0x1847327,0x0924bda,0x014ff14 },
  36188. { 0x1ed9259,0x0d30660,0x09fdfd8,0x065e3ab,0x1be37aa,0x177a188,
  36189. 0x1c4f41e,0x1740708,0x14e6fa7,0x0f99ea4,0x0dcc326,0x182d17a,
  36190. 0x1c43928,0x0dcaabe,0x13e333d,0x17dcae7,0x060d1a2,0x005e36a,
  36191. 0x0ec5584,0x1a32870,0x014527c } },
  36192. /* 61 */
  36193. { { 0x027af4e,0x1289a9a,0x0df52f9,0x02621b2,0x0e6c0bb,0x1338e19,
  36194. 0x09dab2a,0x0ed7b1d,0x0d3a9c3,0x0bd9fea,0x1c26aa7,0x10c68e2,
  36195. 0x00124ce,0x00c028e,0x1739074,0x1dc3844,0x04ff9e8,0x02a4494,
  36196. 0x0d713b2,0x105392a,0x013d22d },
  36197. { 0x1b15e02,0x0f6ced0,0x01a1ac0,0x18603cb,0x1d092ba,0x1209ad8,
  36198. 0x0860d5d,0x1497f4f,0x16f7159,0x0772cdb,0x0434370,0x00a2301,
  36199. 0x169171a,0x1c0290c,0x054c6ee,0x0f208b8,0x0fc2092,0x0ba0498,
  36200. 0x18cdda1,0x169198e,0x0008963 } },
  36201. /* 62 */
  36202. { { 0x0aaaed5,0x05b107a,0x1ba03fa,0x1bfd0e3,0x1068de7,0x1fe5a58,
  36203. 0x00c3ffa,0x0b65644,0x1c3a215,0x06fdf73,0x06e0175,0x15184ed,
  36204. 0x10a7a26,0x169cf57,0x1f79dc1,0x1e0646e,0x047f615,0x0f8d492,
  36205. 0x0b66dcc,0x1035088,0x012aa1b },
  36206. { 0x1152e8f,0x133e858,0x0530a67,0x0f256bc,0x0e773d9,0x05abd11,
  36207. 0x041cfc7,0x145c1b0,0x0bf1da4,0x1d7854e,0x0d12680,0x0c1d845,
  36208. 0x1d169b1,0x0e96be8,0x0b06b23,0x11dc970,0x0a6bfc9,0x0ba8456,
  36209. 0x0f2fa85,0x124881c,0x0150549 } },
  36210. /* 63 */
  36211. { { 0x13a4602,0x0250550,0x1839c00,0x07a1a58,0x105c71a,0x0bcde2a,
  36212. 0x0918e9b,0x1e949fc,0x0d54d9d,0x03c759d,0x0f1ee3a,0x120ee7a,
  36213. 0x057ecca,0x122767d,0x0eec9e0,0x1a2f2b6,0x01fb124,0x045187b,
  36214. 0x1d8cabc,0x1ca0029,0x01155b7 },
  36215. { 0x0f0021a,0x017664f,0x07518b1,0x0ff0ad9,0x18017fd,0x123c5e2,
  36216. 0x10ee0b9,0x1b621c4,0x11505a4,0x183a334,0x1fba96b,0x143899a,
  36217. 0x0ad9bb0,0x0a95768,0x0e8e68b,0x1e13bd1,0x09ab549,0x003a3a2,
  36218. 0x195fe99,0x11ef7b3,0x013fd5c } },
  36219. /* 64 */
  36220. { { 0x053c22b,0x0673dad,0x11a86f6,0x1af9568,0x18733fc,0x1659ca3,
  36221. 0x0938922,0x01f8899,0x0a38c79,0x0c4458f,0x0d08dea,0x0dd62b8,
  36222. 0x0336afb,0x1db8103,0x04ee2a3,0x011f572,0x0c59175,0x19a5bbe,
  36223. 0x0791cca,0x03af4ff,0x0050a93 },
  36224. { 0x0d21d18,0x121482b,0x0286a42,0x0eab682,0x0266630,0x053582c,
  36225. 0x12a2e25,0x0b968d0,0x1828cf7,0x10d6f31,0x1c0a8e2,0x10b424e,
  36226. 0x094fb2f,0x16fbdb8,0x1fdf416,0x03b6d07,0x092a68d,0x00e9fad,
  36227. 0x024f357,0x19c3b78,0x00f5243 } },
  36228. /* 65 */
  36229. { { 0x17d7891,0x0c1e1e9,0x1b2a3f0,0x13fb0cb,0x17b5014,0x10c2208,
  36230. 0x10f5a3c,0x0b01edc,0x15a07f6,0x1a8f612,0x00c80ab,0x0d975a6,
  36231. 0x158fe5a,0x0833b77,0x179a3cc,0x000192b,0x11fca4e,0x03a8471,
  36232. 0x1dcd495,0x1cb52ae,0x0159783 },
  36233. { 0x0537ad9,0x0dab897,0x13def07,0x1a6b7d3,0x1e87112,0x1fcde5a,
  36234. 0x0ad2355,0x18f76a4,0x0a8b3cb,0x17fbc48,0x136d707,0x1c23cbd,
  36235. 0x0d4f306,0x19c3f3f,0x16a0e48,0x03c7a61,0x0f47232,0x026c8fe,
  36236. 0x104a99f,0x0f76c5c,0x009f848 } },
  36237. /* 66 */
  36238. { { 0x0b8e08e,0x0fc07c6,0x1b5a1bd,0x02492df,0x1cfd2c4,0x1bee6fb,
  36239. 0x0dd0d82,0x0be00c3,0x157f4d0,0x0dd7fef,0x0187c93,0x18548b0,
  36240. 0x04b1993,0x0ef4ca6,0x1b2a342,0x1c0c4d8,0x04d2747,0x077b869,
  36241. 0x066572f,0x0ba9c77,0x00ffd4e },
  36242. { 0x0f40077,0x0f122e3,0x1418c5c,0x0a0e47c,0x1592e04,0x15fec40,
  36243. 0x1bdf9a9,0x1c06b90,0x16d9d9c,0x104ace8,0x15dc32e,0x1fd07d6,
  36244. 0x1d2e7f8,0x0206b1e,0x1ac2207,0x08832b1,0x1daeb9e,0x0ab199d,
  36245. 0x0bf47d3,0x072fbe7,0x0034fb0 } },
  36246. /* 67 */
  36247. { { 0x158815c,0x0702f59,0x1f65ee1,0x09c8210,0x1abcb2d,0x182ebd1,
  36248. 0x162241f,0x0390f4e,0x17a9d48,0x083bc6a,0x1932f4d,0x1ff085a,
  36249. 0x1e9d34c,0x067944f,0x167356b,0x058dc10,0x191dd2b,0x141b96a,
  36250. 0x02d02d8,0x1a905c3,0x006bc06 },
  36251. { 0x04ed375,0x14ad06d,0x0bab441,0x10531b5,0x11baf58,0x1b84962,
  36252. 0x086d3d2,0x06b6051,0x07a335b,0x15c3ed7,0x1fbf622,0x06c40ac,
  36253. 0x14a7359,0x199061b,0x127f040,0x11660f4,0x0c4a355,0x1b9bd65,
  36254. 0x103f3a6,0x0d2d469,0x001ed30 } },
  36255. /* 68 */
  36256. { { 0x13902fe,0x085585e,0x0ecf655,0x170d53a,0x1bba4b4,0x0e561bc,
  36257. 0x182a65d,0x1b874b3,0x1333605,0x02f4398,0x10b1601,0x118435f,
  36258. 0x11f2c59,0x177ce5f,0x1fe35bf,0x0788503,0x1d09bf8,0x0c15f6a,
  36259. 0x0a04c75,0x1b3ab6a,0x01579d1 },
  36260. { 0x119258e,0x0d182aa,0x0aa1a1f,0x1204fbc,0x13f539f,0x11186b3,
  36261. 0x05d1f5a,0x108d3f5,0x15f5d16,0x18d7591,0x1907d6a,0x128ebef,
  36262. 0x135bbfe,0x0b53ff5,0x151aaec,0x0a30f7a,0x0e8e16d,0x0957dea,
  36263. 0x13254f7,0x0f7c277,0x0160743 } },
  36264. /* 69 */
  36265. { { 0x09755a3,0x0b2d4f7,0x0ac557c,0x1570593,0x0c8d5a1,0x15cbf30,
  36266. 0x1916aad,0x0e2cb43,0x0ab05e2,0x00266d8,0x020c3cc,0x16a4db6,
  36267. 0x0b9e0c3,0x1ad65ef,0x187b069,0x1093155,0x084761e,0x1209ea2,
  36268. 0x06e718b,0x1c13776,0x01e9589 },
  36269. { 0x072258d,0x09040ce,0x0f519d4,0x08b82b2,0x01dcd73,0x008fedb,
  36270. 0x1e9ee47,0x11cd8c4,0x1885790,0x0e9f4df,0x0f1a3b4,0x0dfca61,
  36271. 0x1f9aac0,0x15ada27,0x1705aed,0x1dbaa24,0x1b6db90,0x01c4305,
  36272. 0x0efb6d7,0x1d1611f,0x01aa96f } },
  36273. /* 70 */
  36274. { { 0x057c0f8,0x12eec79,0x0364c8e,0x05ba742,0x0884dc9,0x1c6701a,
  36275. 0x1e73aee,0x15207e6,0x1a47262,0x10bd6a9,0x01b1b58,0x002ea5c,
  36276. 0x0da1df2,0x0192146,0x0dc8f83,0x18c59eb,0x0892c30,0x00f2e9c,
  36277. 0x1dfe0b3,0x121e3e8,0x01fdd9a },
  36278. { 0x163ab59,0x093dd0b,0x0fa60c3,0x1ce46f0,0x0f27d93,0x0cb4556,
  36279. 0x0099251,0x1ab02ab,0x01700d5,0x1928d19,0x11b67d8,0x1ce6062,
  36280. 0x12cf6bb,0x132df87,0x173d157,0x047f6d9,0x0ce6323,0x0405500,
  36281. 0x05a91d1,0x13cc59b,0x01496e4 } },
  36282. /* 71 */
  36283. { { 0x0574c09,0x185bf20,0x1a5afbf,0x067fd01,0x176f264,0x11bec8d,
  36284. 0x14d4bac,0x0041677,0x17edc31,0x006315b,0x08db70f,0x1296849,
  36285. 0x1ef9893,0x1e3621a,0x1a99309,0x1a0edd3,0x1c4e388,0x196fe10,
  36286. 0x139a792,0x10a5ed4,0x0139cc3 },
  36287. { 0x1096b91,0x051ffdd,0x10f948e,0x0ae7b1a,0x0e72c9e,0x0bbaac7,
  36288. 0x16c4631,0x169822d,0x0dc47d4,0x07644e9,0x06557d5,0x1a6a85c,
  36289. 0x1c2006d,0x1a1ba3a,0x12bb5a9,0x1208200,0x12a2bee,0x0e0eee1,
  36290. 0x164ccb2,0x082f45d,0x01fb597 } },
  36291. /* 72 */
  36292. { { 0x19bae66,0x18cc0c2,0x106cf03,0x0308baf,0x0b48e9b,0x151e0f5,
  36293. 0x0700d14,0x0738d9d,0x0ff8103,0x1c25006,0x035bf88,0x1c22bf3,
  36294. 0x1bcd7ed,0x1c506ea,0x08038f4,0x0380def,0x08a3c7e,0x1ab6eca,
  36295. 0x194e987,0x034fa31,0x00d09d2 },
  36296. { 0x00eb3fb,0x1edd7c4,0x1f27e73,0x0ebd07e,0x04cfd29,0x053a5a3,
  36297. 0x1f5be8a,0x006c374,0x1dfb13e,0x01006af,0x0984a2e,0x1e96465,
  36298. 0x0e03bc8,0x00d46c3,0x1ee4b0a,0x0dd4fa3,0x1ae706d,0x13433af,
  36299. 0x1eac630,0x10c115d,0x011d9b0 } },
  36300. /* 73 */
  36301. { { 0x1d2f539,0x1b0a35d,0x0e885f3,0x00edc4d,0x16052fc,0x1f2533c,
  36302. 0x0746352,0x1506d04,0x09f3f39,0x1c11a11,0x1e1cea3,0x0d72867,
  36303. 0x0868b84,0x18b7a2b,0x074fcd9,0x0eea0f4,0x0282fd4,0x16fb01f,
  36304. 0x05d7889,0x16058ad,0x000377c },
  36305. { 0x001dd59,0x0d6e9c6,0x0debc9d,0x1d73834,0x1c213a9,0x1e2a01c,
  36306. 0x1441137,0x10cd215,0x007ee0d,0x0177103,0x1f10388,0x1d2acc3,
  36307. 0x16896ed,0x085817a,0x135ce63,0x03448d6,0x191e5af,0x0e65cb4,
  36308. 0x04fdc49,0x05035f8,0x009fd5c } },
  36309. /* 74 */
  36310. { { 0x1073a5a,0x062a5eb,0x11f7216,0x190c3d5,0x07c81a5,0x10100d4,
  36311. 0x128e79c,0x19ca3f0,0x040e003,0x0954fc7,0x06677a5,0x0956b1e,
  36312. 0x0b76bdc,0x0ab6601,0x1c48c8b,0x0c5e639,0x06383f1,0x0db31a7,
  36313. 0x1e5a784,0x002fdd1,0x016984c },
  36314. { 0x089f1fa,0x019b12e,0x01e3c7d,0x016d2f6,0x0a02a63,0x02dbfa2,
  36315. 0x079712c,0x1986662,0x14fede4,0x1e65728,0x096a929,0x10e8960,
  36316. 0x0d0d26e,0x1c26dbd,0x16ddeef,0x183fcfa,0x0a8f571,0x01cf78d,
  36317. 0x0633348,0x1752508,0x018d65e } },
  36318. /* 75 */
  36319. { { 0x0bb2537,0x03355c5,0x05be8de,0x16cb661,0x14ac4cb,0x0145698,
  36320. 0x09fb4a9,0x12d04ff,0x010e9e1,0x0e8cfb1,0x006d3a5,0x0f41130,
  36321. 0x0331eb9,0x15745c1,0x19de98a,0x12c8555,0x02a5f5c,0x04b49eb,
  36322. 0x18da2e1,0x17fd2e7,0x00adff5 },
  36323. { 0x12b0dee,0x1d710a4,0x0b3a8fb,0x1d2c058,0x0143e9e,0x1dccf29,
  36324. 0x1f265bc,0x0b2426c,0x0e93b8f,0x0bc5958,0x1304fb7,0x187020c,
  36325. 0x1a8d541,0x1ab9c73,0x0e5c36b,0x16349cd,0x0168373,0x1d7b766,
  36326. 0x12b8823,0x147e9ee,0x0180dbf } },
  36327. /* 76 */
  36328. { { 0x07a6aa0,0x0310d48,0x07dac09,0x1080f0f,0x0f56cb6,0x14549a7,
  36329. 0x02da205,0x0908987,0x19b9a90,0x06b1c69,0x107c81c,0x154104a,
  36330. 0x106968c,0x0fe445a,0x165c14c,0x0af0818,0x0d5af63,0x1aab26f,
  36331. 0x1352533,0x11318f8,0x0097e7e },
  36332. { 0x16ebb2f,0x04c6cb5,0x049b877,0x18f553c,0x092a17f,0x1516341,
  36333. 0x03f6fe8,0x0376c1e,0x0b2e185,0x0319386,0x0933fa7,0x04cb039,
  36334. 0x15898db,0x188cace,0x02098e2,0x11a3328,0x08ea54b,0x0722798,
  36335. 0x1398c25,0x133d708,0x00d6963 } },
  36336. /* 77 */
  36337. { { 0x03769ee,0x079b15c,0x12cfe80,0x187df89,0x12d040a,0x15eb43b,
  36338. 0x0e2255e,0x0518726,0x1940a71,0x1132212,0x10a8c58,0x191fd84,
  36339. 0x11909c4,0x12d0d2a,0x1923c79,0x042e5a3,0x0f1049c,0x0345eb8,
  36340. 0x026dff5,0x125a56e,0x0041c86 },
  36341. { 0x1816784,0x04550ef,0x173938e,0x0a037ce,0x0a58c8a,0x133c092,
  36342. 0x17fec0a,0x1c13693,0x0eda721,0x1994cf0,0x0997b29,0x03ebccf,
  36343. 0x168a0bd,0x02b638d,0x07a47a2,0x15461b0,0x0f4c005,0x11bd771,
  36344. 0x1656efc,0x000ea00,0x0073d94 } },
  36345. /* 78 */
  36346. { { 0x10c0ef3,0x1562500,0x0682a44,0x109d036,0x0e654bd,0x1a9a848,
  36347. 0x18f713c,0x1351e0a,0x1b47d18,0x06e20f9,0x0302704,0x1a0de47,
  36348. 0x07122ed,0x020d67b,0x1305abf,0x10a4044,0x1348375,0x18e65c9,
  36349. 0x09d6b9b,0x16be524,0x01271a4 },
  36350. { 0x0e688b5,0x1ea399e,0x1a2de4b,0x0fb9538,0x14566d3,0x0b88e80,
  36351. 0x0c9b950,0x151f9d2,0x03cc341,0x1dd0a77,0x0b047f8,0x0998424,
  36352. 0x156b8ab,0x1ae9bcd,0x1e9d8ef,0x05f2381,0x0aef152,0x0caf169,
  36353. 0x073e569,0x04367a6,0x00acd4e } },
  36354. /* 79 */
  36355. { { 0x18e061a,0x1d3bc8e,0x08c1004,0x0159909,0x02707e7,0x17b1b53,
  36356. 0x0099bac,0x13ad581,0x177b25c,0x08bf510,0x1cd73fa,0x177ae1f,
  36357. 0x1eddb78,0x020c4c5,0x0236cac,0x1c88aa0,0x0fcce0a,0x187ac52,
  36358. 0x095f439,0x12472e4,0x0043ed0 },
  36359. { 0x0e129e6,0x0bbd9f1,0x135cb2b,0x0e1e37c,0x1b8c4a8,0x02b199f,
  36360. 0x037fc80,0x0875dca,0x12a6915,0x0132c60,0x189902f,0x199571f,
  36361. 0x0f95dc0,0x0cb2d05,0x13ad610,0x1b33cd2,0x053edd1,0x1be9dd5,
  36362. 0x087b721,0x0276411,0x00832df } },
  36363. /* 80 */
  36364. { { 0x181c3f2,0x09123e8,0x08fffab,0x1de66f6,0x115d35b,0x0483394,
  36365. 0x1f2e9d2,0x143b699,0x1fda7a3,0x07b86c7,0x1d5a1b9,0x0832f24,
  36366. 0x1e226b6,0x17f8fbc,0x010218d,0x149d1d0,0x139cf5f,0x04c7425,
  36367. 0x02827d8,0x1417d3b,0x00da57a },
  36368. { 0x0fcea66,0x0767aa7,0x1ebb503,0x195f8ed,0x18df2ae,0x0ac2d44,
  36369. 0x0692324,0x14ac7e3,0x113f00a,0x088ded3,0x172e7ec,0x1f56896,
  36370. 0x116687a,0x1293106,0x157ec49,0x06b578d,0x11bbacb,0x157ca9f,
  36371. 0x1e53134,0x0126e1f,0x00ed997 } },
  36372. /* 81 */
  36373. { { 0x0b54c89,0x1ab7034,0x108ab27,0x1b9ce6f,0x08ecc17,0x044da98,
  36374. 0x1a0feac,0x036411d,0x1543fbd,0x079d094,0x175c1ac,0x19f1089,
  36375. 0x0d1b204,0x0f61720,0x05d7227,0x1229501,0x1ae9399,0x1845808,
  36376. 0x119d37d,0x1742e0e,0x00176b4 },
  36377. { 0x1dfc175,0x0b754c7,0x0c31c48,0x06fc1eb,0x17b7fc6,0x199d1a3,
  36378. 0x0a17f3a,0x16f11a0,0x10223ea,0x13cc0a7,0x1b648ad,0x0416a38,
  36379. 0x1d90787,0x0e09fa8,0x1675692,0x0c16ab0,0x10bfaed,0x1734fc2,
  36380. 0x14332ac,0x135088d,0x005c249 } },
  36381. /* 82 */
  36382. { { 0x1e7bcf1,0x0c0fdb9,0x1ef9075,0x19ba782,0x16dde61,0x0ccfec8,
  36383. 0x05fb3e8,0x12f8c53,0x1c159db,0x13ac439,0x0ca0c06,0x112cc82,
  36384. 0x184ed77,0x14a1548,0x1cb3a24,0x149772c,0x187816b,0x1f9f722,
  36385. 0x195375f,0x0f42919,0x01234fb },
  36386. { 0x009be8c,0x0c057f8,0x0e87c17,0x0ef1be3,0x02e938d,0x16f3103,
  36387. 0x0ba10c4,0x1734fc4,0x16070c4,0x0694f3f,0x1768dd2,0x07d7436,
  36388. 0x135cd9c,0x1238ba2,0x146f4be,0x13cce3c,0x0b056ab,0x0ca04c5,
  36389. 0x07df1a8,0x1095789,0x0049bb5 } },
  36390. /* 83 */
  36391. { { 0x0a470f7,0x12a980f,0x18c2a7c,0x11d24a9,0x001bf80,0x1001c6d,
  36392. 0x1a7a9c6,0x10e130a,0x15913ca,0x0959770,0x007f6c3,0x0097705,
  36393. 0x0aae170,0x08c72e1,0x171bac0,0x08757b6,0x04c1fa9,0x0d2b563,
  36394. 0x0a4b540,0x1ec8ee3,0x00531aa },
  36395. { 0x0345730,0x0f7a483,0x1f0a59e,0x1d08de6,0x146aaa4,0x1e1d55c,
  36396. 0x09ac069,0x09df02e,0x08166df,0x1c046d1,0x1370fb2,0x1f849c0,
  36397. 0x14e9fb3,0x1b760cd,0x02d876d,0x1a27d3c,0x05eeed6,0x0373fb3,
  36398. 0x1a9d4e1,0x1b180f0,0x00e570e } },
  36399. /* 84 */
  36400. { { 0x08ce13f,0x0b72c08,0x004d991,0x1a1c72f,0x15bfc58,0x1ca4f4d,
  36401. 0x0a12fa8,0x0fa096d,0x075af66,0x14db35e,0x0559afa,0x0db9512,
  36402. 0x1a7cb4d,0x1fb0aca,0x0f3b3c2,0x04a4036,0x13d002e,0x1218963,
  36403. 0x04d697e,0x0ed130c,0x014b81d },
  36404. { 0x01078ec,0x1de12c2,0x1535011,0x0c2f388,0x15aa9c9,0x08fc7e3,
  36405. 0x0182521,0x03ed42c,0x0ce3409,0x0c6a71f,0x15040a6,0x0e0911c,
  36406. 0x1e9a9f6,0x0ed4562,0x0a03e21,0x046197e,0x0a08fec,0x0e32656,
  36407. 0x0252ddd,0x10c960a,0x002b0ac } },
  36408. /* 85 */
  36409. { { 0x15daf7f,0x0371cc7,0x1419ad8,0x122124e,0x0838548,0x02c5392,
  36410. 0x1717023,0x1c7444a,0x0c90f3e,0x19b17e8,0x057c08b,0x15e810f,
  36411. 0x0ac9633,0x0212fad,0x1c42f44,0x1b7f6e2,0x005ec06,0x0e100bf,
  36412. 0x06e2ef3,0x0fb9058,0x01c8d9c },
  36413. { 0x0b8bed9,0x00fef8c,0x0495f6d,0x11c7446,0x0948330,0x08e25df,
  36414. 0x0779dca,0x15f79f2,0x141448a,0x185cb95,0x16918a6,0x0c67889,
  36415. 0x0295dfc,0x00dfa85,0x0e7118c,0x0626321,0x177869e,0x08c5b37,
  36416. 0x086eab6,0x09c5f42,0x00f5a8a } },
  36417. /* 86 */
  36418. { { 0x00251ea,0x0a884e5,0x06c2329,0x164f4d9,0x12aeed8,0x107a947,
  36419. 0x02fad58,0x0ad2035,0x0ae13fc,0x14210f4,0x04f01e6,0x03890b3,
  36420. 0x171349f,0x068d586,0x1820d64,0x1b21253,0x09baeb5,0x1cb7149,
  36421. 0x166699b,0x05e3f1e,0x00ce96c },
  36422. { 0x0be8bd7,0x025a889,0x066f92f,0x1e78cfd,0x14846a0,0x1d1c327,
  36423. 0x11f4d34,0x103b139,0x073f439,0x1b23889,0x13959c7,0x06484db,
  36424. 0x0bc32bc,0x181584b,0x04d3aff,0x1056fee,0x00b0d06,0x0ab0278,
  36425. 0x0f3a2d6,0x07afd5c,0x011cfd2 } },
  36426. /* 87 */
  36427. { { 0x07689a6,0x1236651,0x1cafe25,0x06aac82,0x16a7dc4,0x1e5fe66,
  36428. 0x0923ad5,0x1ca617b,0x15b1adf,0x188fffd,0x162fd26,0x01b6e23,
  36429. 0x1b9f2d8,0x1b872d2,0x1e7f7c2,0x1143bd0,0x1836bd1,0x04ba9a0,
  36430. 0x12ff541,0x0a4d7b1,0x0114c8c },
  36431. { 0x17388bd,0x1392df7,0x1a9f57f,0x1fcfff5,0x11c3dbd,0x16f1567,
  36432. 0x16e25f9,0x1f6f072,0x09ebf1b,0x0d3964d,0x01451a0,0x0e0ed2f,
  36433. 0x0f65265,0x1a93385,0x097b367,0x0fa9072,0x1d283d5,0x121bde6,
  36434. 0x003b2c0,0x0e654f9,0x01ceb5d } },
  36435. /* 88 */
  36436. { { 0x1d376d7,0x0fe6767,0x01369fe,0x1d4cd61,0x0b4eab3,0x1c8dec3,
  36437. 0x0342356,0x1b0d592,0x08aa304,0x11eadbf,0x19a93ea,0x0856ff0,
  36438. 0x0127f3d,0x1dc09d7,0x1467ea2,0x1240d2b,0x0d7e34a,0x0e9c3cc,
  36439. 0x0cb0737,0x1814d34,0x0073df7 },
  36440. { 0x0315b16,0x000dd9c,0x03e6f8b,0x133c319,0x1daa7c8,0x1b5c298,
  36441. 0x0fed022,0x10347a8,0x068092a,0x0acf246,0x1eab52c,0x1b3d06d,
  36442. 0x1077e93,0x1234cb9,0x1b58d86,0x1c8eda9,0x1f66297,0x12b4e59,
  36443. 0x1e047e9,0x1b0307c,0x0185b69 } },
  36444. /* 89 */
  36445. { { 0x19cb764,0x13f59d5,0x15b463c,0x031d783,0x1bbefc2,0x1cd53cd,
  36446. 0x0376c11,0x1ea8eec,0x009e542,0x068b692,0x066e5ad,0x11a378d,
  36447. 0x0ae35c3,0x0646c64,0x0cab896,0x148ba27,0x15267a3,0x042bce0,
  36448. 0x1155301,0x16e6aed,0x00d9773 },
  36449. { 0x018c299,0x0523981,0x08ce588,0x0733ef1,0x09be29b,0x07a0a7b,
  36450. 0x0802521,0x1a88d09,0x19a2ca4,0x163a49b,0x0deacec,0x0e7cd1b,
  36451. 0x1f09c07,0x09ae1ab,0x007c166,0x1c7e4c3,0x03d8b7d,0x0049898,
  36452. 0x03edb82,0x1ff9a1c,0x0060f3e } },
  36453. /* 90 */
  36454. { { 0x05d6530,0x00a5f59,0x103dc8f,0x13352fa,0x1e015b3,0x1bfb112,
  36455. 0x0f12fef,0x1e24138,0x014b4f0,0x1ec62ce,0x1a3b3e0,0x1fbc7ef,
  36456. 0x0fcf002,0x0f58f78,0x14d4f24,0x018c06b,0x0a5201f,0x01ca621,
  36457. 0x0fa3b8d,0x025156f,0x01b5787 },
  36458. { 0x10110cd,0x1be9d5b,0x06d6824,0x188ef22,0x00fa4ef,0x1d260cf,
  36459. 0x0bd6f14,0x1e58d59,0x138d509,0x0980879,0x0b071af,0x1057ca9,
  36460. 0x1f3ee2a,0x127951d,0x1a99f0f,0x18f7263,0x06ef089,0x1bd2653,
  36461. 0x1288d8b,0x14589e6,0x00b05bd } },
  36462. /* 91 */
  36463. { { 0x1f575cd,0x05038e8,0x060ad09,0x034a46e,0x15693b0,0x164ea00,
  36464. 0x0d80a68,0x0c02826,0x19c914a,0x0621a45,0x0cc7054,0x0e7a12b,
  36465. 0x0290245,0x117ea4b,0x05d7f48,0x164eedf,0x086e210,0x1d0b824,
  36466. 0x16ea4de,0x137026d,0x01f6ac2 },
  36467. { 0x15da491,0x0f7aabb,0x160827b,0x1c56d55,0x05953f9,0x1a06ad9,
  36468. 0x084186e,0x1b0cd2d,0x14d5127,0x1e22988,0x0b418b3,0x195303d,
  36469. 0x032f21d,0x179db89,0x0f93c1e,0x1e41a7e,0x0b89646,0x1896683,
  36470. 0x0443d6e,0x06c6d2d,0x015e241 } },
  36471. /* 92 */
  36472. { { 0x0cfc44e,0x027e81f,0x0f54321,0x10a0876,0x0095f2c,0x1e82cd2,
  36473. 0x19f6f26,0x1bf34bf,0x0f65bec,0x1c9947d,0x0587348,0x08e34cf,
  36474. 0x1de3102,0x1ddaefe,0x078e6fe,0x18b75d5,0x0d0133d,0x0c0115b,
  36475. 0x1c4b0de,0x0f5536b,0x0141bed },
  36476. { 0x194d941,0x1802cfe,0x006025b,0x00fa9fe,0x1c6e9f0,0x0f82f1f,
  36477. 0x1d661de,0x133cc75,0x100483c,0x0207859,0x0661c13,0x1ddee54,
  36478. 0x1104d2f,0x0325253,0x1dced6d,0x0fe3db6,0x10f4936,0x1005b3b,
  36479. 0x0a7ef4a,0x1c06025,0x01694f7 } },
  36480. /* 93 */
  36481. { { 0x09095fd,0x0eeb9c5,0x15e837d,0x03a79d0,0x04b7a02,0x16e3b3e,
  36482. 0x1e5af97,0x0112154,0x1180a08,0x124bf7f,0x042aad5,0x1c3ecde,
  36483. 0x06b9856,0x1cc3cbb,0x0a62090,0x00c0262,0x0f73ba8,0x0b0ba46,
  36484. 0x1576a4a,0x120ed8a,0x001207d },
  36485. { 0x044394d,0x04d008e,0x19142c1,0x0e19c93,0x15f25ef,0x14a132f,
  36486. 0x027c2c5,0x1f03c74,0x0109b33,0x02decff,0x04cb90b,0x087f461,
  36487. 0x1207f2a,0x0367c57,0x1aaff2b,0x0ce44e6,0x004f336,0x056fbfd,
  36488. 0x0a749ac,0x1d25f7f,0x00e02f1 } },
  36489. /* 94 */
  36490. { { 0x1be4d4a,0x0725331,0x1246549,0x1acde79,0x1fa57be,0x1d3e668,
  36491. 0x04fe9f9,0x1a7baf9,0x088c5d1,0x07467b5,0x147c79c,0x12f47e4,
  36492. 0x15b2579,0x11aaa67,0x17b163b,0x0e21214,0x0d7065a,0x1346934,
  36493. 0x014227a,0x07a9a41,0x004c7c2 },
  36494. { 0x152d132,0x12badde,0x13158eb,0x0e71903,0x0fb8daa,0x131dcc8,
  36495. 0x1b94793,0x10e12d4,0x0b239d3,0x0eb59b3,0x127fb54,0x10e94ba,
  36496. 0x1aed5f8,0x01d4603,0x1424765,0x0d5c404,0x05ae468,0x10807c2,
  36497. 0x1ad3bd6,0x0b3ae8f,0x01c21af } },
  36498. /* 95 */
  36499. { { 0x1441308,0x1e00f6e,0x02417de,0x090c611,0x0dc3494,0x0b08e68,
  36500. 0x029d1d6,0x0cc55e7,0x14c23ce,0x0d38930,0x0bfb484,0x0f6bf17,
  36501. 0x1937f31,0x0649f03,0x1eee7fd,0x0a59e9d,0x0dd8ecc,0x1440787,
  36502. 0x172760a,0x19ba59b,0x0028480 },
  36503. { 0x1f807ac,0x0e506e1,0x1527a3c,0x057a0e0,0x0a3e4fc,0x1c5db63,
  36504. 0x0285247,0x19b5a7a,0x13d6dfa,0x1f70e7e,0x11bfef8,0x0372bf6,
  36505. 0x1cee46b,0x1eeae7d,0x01eceb1,0x1d16ea4,0x0d9b1b8,0x16ac060,
  36506. 0x1ef7446,0x0cd3e98,0x008452c } },
  36507. /* 96 */
  36508. { { 0x0ace6d5,0x1a3a3e0,0x1eb690a,0x177ce50,0x15acb64,0x1e130a6,
  36509. 0x1226626,0x03de660,0x0ff05c7,0x0bff41b,0x0b11420,0x048da6b,
  36510. 0x1c772eb,0x1bad4e1,0x17f0858,0x1adfafe,0x01acbc0,0x1fdb7cf,
  36511. 0x083a5cc,0x07862ae,0x009a764 },
  36512. { 0x1845ccf,0x10b5a79,0x16f52c8,0x0121780,0x1c174e8,0x02481bc,
  36513. 0x031d358,0x00cf4aa,0x16358c8,0x0b91050,0x1dedb6f,0x188354c,
  36514. 0x0e838f9,0x1371704,0x0ccb065,0x0db4a6e,0x15e496f,0x0d81943,
  36515. 0x10c18c3,0x04e99f3,0x000c52b } },
  36516. /* 97 */
  36517. { { 0x0a58beb,0x173c147,0x0921bb0,0x1a6ccbf,0x0b404c1,0x1a07f81,
  36518. 0x17eb482,0x14aa8da,0x029d3e6,0x1aefbdb,0x006647e,0x08dacd9,
  36519. 0x1ef1868,0x17167f1,0x1a42f79,0x1a2d77c,0x1a01410,0x14bd75c,
  36520. 0x0b323a4,0x102a917,0x00cb59d },
  36521. { 0x0f66a23,0x0e9d6dd,0x0207641,0x0e81bf6,0x0333738,0x007a196,
  36522. 0x0d7792c,0x07cdaaa,0x007d3a0,0x0bff474,0x0f2a038,0x1fee0cd,
  36523. 0x1529544,0x1d6ffd2,0x10ae5b2,0x0dd48c1,0x19445a2,0x04f80c6,
  36524. 0x128d3ff,0x0702ce4,0x011ed54 } },
  36525. /* 98 */
  36526. { { 0x17f8a61,0x039fdde,0x02ed8aa,0x0377cb0,0x1e18cd7,0x1fb4c02,
  36527. 0x07acd99,0x181fab9,0x1571d3d,0x1c6a7b0,0x1e6f22a,0x042af07,
  36528. 0x14e2e45,0x121cc58,0x10ddd2c,0x0236a6d,0x16374d8,0x196da51,
  36529. 0x17af8f0,0x1e252e5,0x01389f7 },
  36530. { 0x18fefb2,0x1f90e3c,0x09caee5,0x0a20f75,0x1c76fcb,0x0ddab44,
  36531. 0x1dd83eb,0x18a25f7,0x1d33ea6,0x13245f3,0x04d2946,0x132646c,
  36532. 0x1b412a2,0x04c2c49,0x0f605a6,0x15b4894,0x18f3e66,0x1b0a24a,
  36533. 0x1a1ed15,0x1f8f36e,0x0140b4d } },
  36534. /* 99 */
  36535. { { 0x0be5bb9,0x0a2b83d,0x06fa0ec,0x11ca3b0,0x0e0cbfd,0x013d7fd,
  36536. 0x17d2726,0x0a841b5,0x0a687b5,0x1d392a4,0x105ccf0,0x07f7dd6,
  36537. 0x0308026,0x09c13e3,0x053f70f,0x16e1ce0,0x184b5e3,0x03e80c7,
  36538. 0x0f3dc5a,0x107c01f,0x00151d4 },
  36539. { 0x1578aa3,0x11e3e35,0x16b8553,0x0ba6087,0x111ce9b,0x004080a,
  36540. 0x07a6ed8,0x0deabf1,0x0f405ac,0x1618889,0x02b1ed3,0x09b0401,
  36541. 0x067e66a,0x12e297d,0x10034e4,0x185d6e7,0x1988aca,0x1f70dcc,
  36542. 0x02d5d14,0x063b2ac,0x008fdfa } },
  36543. /* 100 */
  36544. { { 0x11cf8d8,0x0507012,0x0f4b31d,0x1a083e5,0x14d8949,0x15e7296,
  36545. 0x12924cf,0x15c16e6,0x15c5bcd,0x0d62fa8,0x002e4f8,0x1f982c4,
  36546. 0x0ed3ecd,0x13c9b9b,0x01a899a,0x0d2804a,0x08bea6e,0x0ac2d0e,
  36547. 0x0643e4d,0x19baa72,0x000e081 },
  36548. { 0x1e28412,0x1ccab29,0x192c157,0x05b64e2,0x0d1526f,0x19d6e38,
  36549. 0x097ac77,0x1bb9aac,0x0dd35de,0x16229e5,0x03ff8b4,0x1093507,
  36550. 0x09ed442,0x0e0672c,0x08304dd,0x16c135a,0x081bd99,0x196afdd,
  36551. 0x08bbec1,0x083b98c,0x01ad5be } },
  36552. /* 101 */
  36553. { { 0x1850756,0x17b33c7,0x165d58e,0x1ca5e76,0x06d37aa,0x14217ac,
  36554. 0x0294de5,0x12e21a7,0x1f743f9,0x0d57ccf,0x06a2eb3,0x0bcb27e,
  36555. 0x192fa75,0x004fbe6,0x1c13855,0x0ca1635,0x00ad6d0,0x131dfcd,
  36556. 0x16aff66,0x039d5aa,0x000e67b },
  36557. { 0x1f43178,0x054705a,0x0cccd98,0x1b3986b,0x16bd412,0x07b4042,
  36558. 0x1e98e20,0x0e27af7,0x02e622c,0x19b96b3,0x009115f,0x17cedff,
  36559. 0x11ad7b7,0x06d8272,0x0af7a02,0x0b91a1e,0x1fe4bd1,0x170f3c0,
  36560. 0x03940bc,0x0eb7f77,0x01941f4 } },
  36561. /* 102 */
  36562. { { 0x03543ec,0x015fceb,0x1cf9e52,0x19422fd,0x185cb67,0x066631c,
  36563. 0x018e058,0x03d158a,0x1729bdc,0x0b65f6a,0x1a1b7d5,0x12fb444,
  36564. 0x1cd62ed,0x040f5bb,0x0932d7f,0x05db362,0x16672fa,0x126bda7,
  36565. 0x00cd6e5,0x05354ef,0x017260b },
  36566. { 0x03df7c6,0x1e3db52,0x01b086f,0x077840e,0x05acac2,0x0ecac04,
  36567. 0x0def0d1,0x179d6de,0x0a32a08,0x0c79069,0x14f17a7,0x09eda32,
  36568. 0x10f0892,0x027b406,0x0975f1b,0x12258fa,0x0372de9,0x0327351,
  36569. 0x0b39913,0x180d88a,0x00ebda1 } },
  36570. /* 103 */
  36571. { { 0x11dd110,0x1be2e20,0x1128999,0x1459323,0x0d6787a,0x0b336b0,
  36572. 0x1a90691,0x02aa77c,0x0c15f9f,0x1f38b55,0x131ec9c,0x0c7e1c1,
  36573. 0x10a93b8,0x1531255,0x015c45c,0x184c148,0x16e1a39,0x072f3b2,
  36574. 0x1bdbc4c,0x1af16a5,0x0046af8 },
  36575. { 0x0f38dff,0x10a58b8,0x0415e58,0x1024742,0x1e35d82,0x1f6c091,
  36576. 0x1135255,0x0c208d4,0x00da601,0x0c7d4dd,0x01104d8,0x054aa9f,
  36577. 0x0be7cdd,0x0cf54ad,0x10958f8,0x06169e3,0x014cb2a,0x0e222cf,
  36578. 0x07fe6aa,0x115bacc,0x0183c74 } },
  36579. /* 104 */
  36580. { { 0x1e58caf,0x00f9cce,0x0990ca6,0x1b0ea7d,0x05bb80f,0x08ca430,
  36581. 0x07c90b4,0x015907f,0x003eeb0,0x0486783,0x0f5e73d,0x04a2f8e,
  36582. 0x1b4037f,0x1926a30,0x10827f5,0x0419f08,0x0d22724,0x13581fb,
  36583. 0x0d0e3e8,0x17a53d6,0x01526f4 },
  36584. { 0x189e51c,0x081a561,0x063a593,0x12db6fb,0x0cda55e,0x09e2c1d,
  36585. 0x05f7ba4,0x081655d,0x1feb034,0x1c983bd,0x1878a41,0x06f13a8,
  36586. 0x1eaa16e,0x021dfc5,0x099d4cc,0x1187f61,0x042ba7d,0x04eba4d,
  36587. 0x0ee4977,0x03cdacd,0x00ec7c4 } },
  36588. /* 105 */
  36589. { { 0x1da8398,0x19a2ee2,0x10c0ba6,0x1f76718,0x1c66841,0x1dda3d5,
  36590. 0x11589f0,0x1bb9c75,0x1738d2c,0x1df5895,0x0c46163,0x15aed0e,
  36591. 0x14d4bc2,0x1dea7a7,0x0876c72,0x0361d2a,0x0aefe4e,0x1153486,
  36592. 0x0ffaf8f,0x042bd6f,0x0194375 },
  36593. { 0x0dfd661,0x11a7897,0x07d132c,0x1ddaa58,0x0149984,0x1c7cc60,
  36594. 0x1c98363,0x12065a4,0x07be385,0x13b7272,0x02d9cbf,0x0e7b2bd,
  36595. 0x0254358,0x1958074,0x1b0e5ff,0x03d7122,0x105bad6,0x11dcdfb,
  36596. 0x184c6ef,0x1203055,0x00007ee } },
  36597. /* 106 */
  36598. { { 0x1fbcb5c,0x1f54f49,0x0a6f4db,0x073f50a,0x182be58,0x108dd01,
  36599. 0x0c497f5,0x06e1648,0x1cd8a26,0x0cd71bf,0x151c129,0x0c1c7b1,
  36600. 0x19ab78c,0x02620db,0x0b090f5,0x1398a37,0x1eaeda4,0x1e2000f,
  36601. 0x0f71fa7,0x1d48950,0x00f6988 },
  36602. { 0x077f79e,0x0655278,0x0435364,0x03b3c4b,0x14d1760,0x0da5bbf,
  36603. 0x0eecf48,0x16c23bd,0x09037e1,0x18d9fb0,0x0fb3c00,0x1b0426b,
  36604. 0x1af113e,0x19481ee,0x1004de7,0x1252ded,0x1caa6f1,0x09b5ef3,
  36605. 0x16eeb61,0x076d093,0x006c57d } },
  36606. /* 107 */
  36607. { { 0x0bfccb0,0x1f71c4d,0x198e58f,0x0972ced,0x0c6e2a2,0x1d3693b,
  36608. 0x03c0a12,0x1a3f0ed,0x0465853,0x1c5d1dd,0x0ae6db0,0x06da371,
  36609. 0x116e3ab,0x03d0399,0x1f25d09,0x07e6403,0x1182523,0x17eea0b,
  36610. 0x118779e,0x19f5035,0x00214da },
  36611. { 0x0a3198c,0x14f9bf5,0x0754d96,0x0bf9173,0x0be8a34,0x1af65e6,
  36612. 0x1c4ab53,0x029484f,0x00c2375,0x020ffb0,0x09ec17a,0x18b4514,
  36613. 0x135d9e8,0x1142cff,0x0ddd111,0x1bc6e5a,0x0ffea8b,0x00e0230,
  36614. 0x073d6fe,0x1c93425,0x01810a0 } },
  36615. /* 108 */
  36616. { { 0x1843c3e,0x101d7a2,0x0b9da20,0x07557d7,0x0601e30,0x06fb15a,
  36617. 0x023cd89,0x15072f6,0x0d21e5a,0x1439a45,0x10ac395,0x18e7344,
  36618. 0x0d2cf12,0x1953b63,0x123b404,0x0a34590,0x1c2f527,0x0db9550,
  36619. 0x0b00b41,0x052d872,0x00f3b63 },
  36620. { 0x0f3d1f0,0x1a156e3,0x0e53392,0x065ea65,0x0f0dcc5,0x021ece1,
  36621. 0x0ccd60d,0x196af02,0x0dc8dd9,0x0808c77,0x1c64bed,0x034bdd0,
  36622. 0x023039e,0x0aba0ce,0x1dc99f5,0x0d61932,0x04c30f9,0x123177d,
  36623. 0x134f0d6,0x1f6f2c7,0x01f7454 } },
  36624. /* 109 */
  36625. { { 0x1153926,0x140ca4e,0x152043c,0x03056ae,0x02e28c9,0x0f4a64a,
  36626. 0x0ecc142,0x0ae9684,0x0de9d6b,0x0d66295,0x128c531,0x1873167,
  36627. 0x05aa746,0x031eade,0x13a8c1f,0x193121e,0x1a2e1cc,0x0212aa9,
  36628. 0x1db6465,0x03317fe,0x008e271 },
  36629. { 0x08e672b,0x007231e,0x109f1e4,0x1a7e5bf,0x103675c,0x10b1e4b,
  36630. 0x147debc,0x160e092,0x07aceaa,0x06b4c84,0x148da5d,0x0352fd1,
  36631. 0x15482f2,0x009ee08,0x1ef0772,0x19a27b9,0x08004f6,0x106715e,
  36632. 0x0afebfc,0x08cc590,0x003f2a5 } },
  36633. /* 110 */
  36634. { { 0x188a8bc,0x1a0f30a,0x0b2c373,0x1c4218a,0x0f48cd0,0x073d22b,
  36635. 0x18af5d6,0x0ae670a,0x148b9b9,0x1006aa5,0x026e785,0x10174d7,
  36636. 0x0f461df,0x04c6641,0x1f53c5c,0x0e28fef,0x1cd1497,0x08b3f80,
  36637. 0x045b17e,0x070a22c,0x0048b13 },
  36638. { 0x12617f0,0x1b199ae,0x181b7ad,0x04dd970,0x1f9a577,0x08fe749,
  36639. 0x00cb46e,0x12f5278,0x16c84b9,0x1d21c45,0x1296fbd,0x044b047,
  36640. 0x0bbfe80,0x1ad197b,0x06700a0,0x0b8b0de,0x1ade3cb,0x0f9366a,
  36641. 0x1430776,0x1bb8eed,0x01e77f5 } },
  36642. /* 111 */
  36643. { { 0x0e764c9,0x1f76437,0x0b30f27,0x0d60f90,0x11bec83,0x02d8a16,
  36644. 0x0cb9a80,0x1d4d7e3,0x129e8a5,0x077a8d1,0x189071c,0x131c7ff,
  36645. 0x08517d2,0x194b361,0x0e278a1,0x198ed76,0x0a92c7a,0x09d16d4,
  36646. 0x0ca886d,0x19224ce,0x004a902 },
  36647. { 0x17ce110,0x08dce47,0x1bc65b1,0x0f5d606,0x1cc33a8,0x152cf16,
  36648. 0x1426029,0x00104d2,0x1e78db5,0x1579353,0x0ec0c33,0x070992b,
  36649. 0x0282f3c,0x126217a,0x15ba7dc,0x09414db,0x02970ac,0x03b46ef,
  36650. 0x0f48bbf,0x1b9c960,0x016f4ae } },
  36651. /* 112 */
  36652. { { 0x1ed03c0,0x1819576,0x15341df,0x04b11bb,0x0684a05,0x02df079,
  36653. 0x0f13e6a,0x176da13,0x1e0b9b6,0x0ed063f,0x0d621ef,0x18fde5f,
  36654. 0x1e19689,0x161e673,0x0a5a583,0x055cbf1,0x1d5768d,0x15821ec,
  36655. 0x0c84866,0x101037b,0x006829c },
  36656. { 0x059f006,0x0397d6f,0x1d69afe,0x0d972fd,0x02b9ffc,0x173f7c6,
  36657. 0x0576d62,0x03e6e32,0x1f4ccaa,0x1711e50,0x09f3130,0x0c1d138,
  36658. 0x061af8c,0x0435ee6,0x1975f9f,0x1bc87dd,0x07f9bd8,0x1c912da,
  36659. 0x0c93c22,0x0fe8c69,0x00b453e } },
  36660. /* 113 */
  36661. { { 0x1048bda,0x04b6871,0x1939531,0x128787b,0x02b6749,0x16a84f7,
  36662. 0x127dd30,0x1135840,0x0543c50,0x00fb48f,0x08d96ec,0x014620b,
  36663. 0x09cd996,0x1c58b82,0x164fff9,0x128ce69,0x1b3f82c,0x0814fcc,
  36664. 0x05869d5,0x18bd440,0x0091785 },
  36665. { 0x13dbdb6,0x0fcbc4a,0x067ed15,0x132fd94,0x0a9e84d,0x0a6bad7,
  36666. 0x140a4db,0x1f48e77,0x0c15276,0x0e0be54,0x1d8d5aa,0x02668f8,
  36667. 0x129cf66,0x01cb9c6,0x1a0d82c,0x06c1294,0x0a86973,0x0e9f218,
  36668. 0x0ac9fc8,0x0a65bdc,0x01b40ae } },
  36669. /* 114 */
  36670. { { 0x164cb8b,0x0874128,0x19f5a04,0x1e4aa54,0x0979af4,0x0c2a93b,
  36671. 0x1b43a34,0x189c21a,0x1fb64ea,0x1b62bc3,0x09164b3,0x0c77588,
  36672. 0x1084081,0x1e706c0,0x03ffcdf,0x182b8bb,0x049da84,0x0c59427,
  36673. 0x0998fb2,0x00aace6,0x0010ed8 },
  36674. { 0x1f3ee9e,0x1a01828,0x1c7841b,0x136715b,0x0e8e3ee,0x1eb2249,
  36675. 0x1e9ba84,0x163a790,0x180e1ab,0x1da4fa2,0x15ca609,0x02f217f,
  36676. 0x1fc283d,0x17e3d1a,0x1943e96,0x15a9f1f,0x145ade3,0x13b9ed2,
  36677. 0x068877c,0x1f55c9b,0x01f878b } },
  36678. /* 115 */
  36679. { { 0x1ad5678,0x06c7455,0x096eb98,0x1dcc018,0x0afa72c,0x1447108,
  36680. 0x182d130,0x13f73a9,0x0d254cf,0x0223fbb,0x18ae959,0x17892b3,
  36681. 0x0c1fb36,0x14b0899,0x0f1135c,0x01e3272,0x01ffc14,0x06bd444,
  36682. 0x1425992,0x10c2511,0x009127a },
  36683. { 0x09e690c,0x16010c5,0x0856d4d,0x03d569f,0x05dcc52,0x0772a64,
  36684. 0x1108ec0,0x090135e,0x1af3a8e,0x1bc9a92,0x0c7616c,0x06116ee,
  36685. 0x15e1f36,0x0a0e7da,0x0d875e0,0x08a536a,0x09eeffc,0x07520f9,
  36686. 0x1df498d,0x0eab633,0x00e8cf5 } },
  36687. /* 116 */
  36688. { { 0x012b398,0x0dc06e9,0x0dcc07b,0x03aa7ba,0x1039618,0x097d4ae,
  36689. 0x1811e29,0x0da1c10,0x0a7825e,0x08f3219,0x1b393eb,0x178a661,
  36690. 0x0fe0185,0x183c49b,0x03dcc4e,0x0dd46a1,0x0fd9e7f,0x00ee4c1,
  36691. 0x1555ad8,0x074c05a,0x00e8dbf },
  36692. { 0x19e05bc,0x1191a13,0x0f4f0dd,0x19e888a,0x1f5f40e,0x1183c9b,
  36693. 0x17d35fe,0x0446218,0x0108d7e,0x07fd69b,0x062ef17,0x1de7855,
  36694. 0x00f2f01,0x0bea3fc,0x0ac5c67,0x05c3861,0x118a9b2,0x03de4fc,
  36695. 0x00d37e5,0x1b8a55d,0x01f9f53 } },
  36696. /* 117 */
  36697. { { 0x183f89b,0x15a4f60,0x1b53c99,0x04beb00,0x13fb5f0,0x1618406,
  36698. 0x10ad653,0x02fa614,0x0371cd9,0x1b58ca0,0x1f89b52,0x15576fe,
  36699. 0x04f7541,0x16adbdb,0x149a7ac,0x06d8bca,0x1c17f80,0x0870d42,
  36700. 0x097c99d,0x1e1e45b,0x01cea0f },
  36701. { 0x08e11f8,0x1eab51d,0x0d5180a,0x03ebf35,0x0986402,0x06496b9,
  36702. 0x0b16833,0x0178ce8,0x0523f65,0x122b4f3,0x0afed35,0x1037eff,
  36703. 0x0bc8e46,0x01e4f36,0x09d651f,0x1fe4168,0x0d538f5,0x1159ca9,
  36704. 0x1c12ba8,0x1f1c703,0x01b0818 } },
  36705. /* 118 */
  36706. { { 0x10d90f0,0x0dffd72,0x1370ef9,0x17ea023,0x0cb3b11,0x08efd62,
  36707. 0x09c469a,0x0e7c219,0x14ea1a7,0x176108e,0x1bbad98,0x1d77cb0,
  36708. 0x1d5a979,0x106178f,0x1c5aac6,0x17fd49b,0x17ec57b,0x17f4f1f,
  36709. 0x0b949bd,0x0b2c1cb,0x015e1b0 },
  36710. { 0x030e62e,0x10252c3,0x06dc723,0x1cc88fc,0x1d00310,0x1a223d1,
  36711. 0x1ad850e,0x1479e3c,0x17462e7,0x155dc28,0x09c9364,0x1410000,
  36712. 0x1f8309e,0x12294b6,0x00175c3,0x1b0243b,0x1b33d4e,0x1079c24,
  36713. 0x00d3513,0x17ff78d,0x00962d6 } },
  36714. /* 119 */
  36715. { { 0x0e07711,0x1f2c6a4,0x0ecb44f,0x11a4e14,0x10f8364,0x0ff8263,
  36716. 0x024b633,0x0282a2f,0x051411f,0x0ddb2bc,0x1e29545,0x1b207c9,
  36717. 0x0f6c31c,0x02099b1,0x1e1c548,0x0da9ae7,0x1eeeca0,0x197f012,
  36718. 0x1538c5f,0x0dc82f2,0x00ad32a },
  36719. { 0x1d147df,0x0631fb4,0x0dedf8e,0x1ce217e,0x169bb06,0x0a8a6f5,
  36720. 0x1afbca3,0x1b3729b,0x18d11c3,0x19183fd,0x1718112,0x1bf2070,
  36721. 0x033b369,0x13c0074,0x1a8bd27,0x03838d1,0x0587d50,0x0781459,
  36722. 0x13bde06,0x0f0442b,0x0055970 } },
  36723. /* 120 */
  36724. { { 0x0c1d751,0x1a8edaa,0x1448430,0x03741f2,0x0144530,0x0e45f6c,
  36725. 0x0cd3eff,0x0154efd,0x0cf2368,0x0c6c09c,0x1ca1812,0x0949c09,
  36726. 0x1a928c1,0x0b52db6,0x064b6e8,0x122072c,0x15b5f9a,0x124ef54,
  36727. 0x05c9040,0x1a8af00,0x008580d },
  36728. { 0x009221c,0x1928007,0x015ba41,0x03e43bc,0x02e05b2,0x1304a83,
  36729. 0x0be8783,0x0528919,0x16f7751,0x0bfdcbd,0x0d2b299,0x037be3e,
  36730. 0x165d299,0x04ff8ae,0x1b356b1,0x1d8f34c,0x097d049,0x06e0eb4,
  36731. 0x1caebaa,0x1f9509c,0x0067388 } },
  36732. /* 121 */
  36733. { { 0x0ef1dd3,0x05a4ed3,0x15d9948,0x1c774d9,0x191a045,0x1eafa41,
  36734. 0x0602bcc,0x0953909,0x0ef0747,0x09e7ad9,0x1ec7ab9,0x1d34f17,
  36735. 0x1aa35b2,0x16d4837,0x0a5ff5b,0x059e9d9,0x1891b9f,0x0f8d49b,
  36736. 0x0aca162,0x0a66d27,0x010d667 },
  36737. { 0x1691faf,0x0824b39,0x18616d4,0x13aafd8,0x1c73d3a,0x054292e,
  36738. 0x086ee4c,0x0d2fc52,0x040b05b,0x0a7ab8f,0x0fb7282,0x002e827,
  36739. 0x185e96a,0x068d35c,0x1f53dca,0x1d16f3c,0x1da3ead,0x0aa8a1f,
  36740. 0x05b9153,0x170889a,0x00fb859 } },
  36741. /* 122 */
  36742. { { 0x0667aaf,0x1041f3e,0x12e9f08,0x1295239,0x13545cb,0x1074a51,
  36743. 0x064c632,0x18f943d,0x1e4eaa0,0x1d7ff91,0x15a1130,0x086c85e,
  36744. 0x0ba21ac,0x106a968,0x11a2a2d,0x003a9f9,0x05b6a93,0x0a00d2c,
  36745. 0x01eaf38,0x1eec592,0x00a3547 },
  36746. { 0x1e260ce,0x09f69fd,0x07e98f7,0x1b01b80,0x0717752,0x0ed1f21,
  36747. 0x0dd75bc,0x01dabf5,0x05261f1,0x18b4325,0x135aed7,0x1ec7a41,
  36748. 0x16be7b1,0x110d632,0x18e3040,0x1231d3a,0x0f6673b,0x0189bdc,
  36749. 0x0b68bee,0x1688709,0x017423e } },
  36750. /* 123 */
  36751. { { 0x01fbcf4,0x113e215,0x17b8653,0x16bf59a,0x0c0d285,0x0f3303a,
  36752. 0x1af7645,0x134eb85,0x0ef0a6a,0x134b288,0x13d1607,0x1f420cf,
  36753. 0x1a13c5a,0x1df70fd,0x1804f05,0x0f3ce57,0x0d6dad2,0x0c2d203,
  36754. 0x050b3d6,0x052a3aa,0x0031004 },
  36755. { 0x02bbc45,0x1af60d1,0x1361a9c,0x14feade,0x0ee5391,0x1000ef2,
  36756. 0x1e7408d,0x04a60b5,0x1aa2f8d,0x0590c28,0x16de2aa,0x0db030f,
  36757. 0x030e2c3,0x10d4446,0x13020fe,0x0fab79f,0x17fbd3e,0x1dc8ed5,
  36758. 0x13f7408,0x10a8c1e,0x00f462d } },
  36759. /* 124 */
  36760. { { 0x172d703,0x05d0124,0x080fd5a,0x1a72131,0x1c44ca1,0x14642af,
  36761. 0x1950ab8,0x06dd371,0x05b1b45,0x1ea79b0,0x1df9213,0x00f698f,
  36762. 0x1d2e08b,0x1118411,0x0bcee60,0x1fa2608,0x1131889,0x0e4ffe9,
  36763. 0x1b1a0d6,0x1e0ca58,0x01bb56a },
  36764. { 0x0e0f16a,0x182f103,0x1297b6f,0x15ae8c8,0x1c1ac2f,0x09638d7,
  36765. 0x02a603e,0x143cb34,0x136c800,0x1d71beb,0x05e3704,0x1f8c46c,
  36766. 0x105f20e,0x15a3778,0x0e962e0,0x013c888,0x1cf4425,0x064a8be,
  36767. 0x103b66c,0x17682ac,0x01667d0 } },
  36768. /* 125 */
  36769. { { 0x122842d,0x185309e,0x1380ea8,0x0b6789d,0x0c6e00f,0x1c15bcc,
  36770. 0x13e1db7,0x18b0ec9,0x178d208,0x1496c36,0x02152b6,0x0723cf1,
  36771. 0x140a52d,0x12cd84c,0x06c9bee,0x1f93493,0x1ad04c5,0x02ee099,
  36772. 0x138fc4d,0x0124d26,0x01dda5c },
  36773. { 0x0d6d673,0x0e5617d,0x0ff9bc3,0x0a01e76,0x0d8fdf0,0x0bab74b,
  36774. 0x065058c,0x1c7d9ce,0x10a4d80,0x0c87a49,0x04c004e,0x126c63a,
  36775. 0x18f2aca,0x1aac0b1,0x04659b1,0x0acf3dd,0x174e6dd,0x136f87a,
  36776. 0x135c736,0x0490d19,0x0111be1 } },
  36777. /* 126 */
  36778. { { 0x15cc1b4,0x0639323,0x1e33d91,0x1256e72,0x115fc2f,0x1ebf5bc,
  36779. 0x19b4438,0x1c0cb4f,0x0f40c38,0x1a2710d,0x1493f2e,0x0573c35,
  36780. 0x0598866,0x01ab037,0x02e9377,0x127ee4e,0x02c1a4f,0x1e1c1a5,
  36781. 0x0d8a935,0x0193446,0x002193d },
  36782. { 0x169fd7f,0x1bdc67b,0x0ee78b2,0x0f13442,0x1815da9,0x0887f78,
  36783. 0x03159ae,0x070f69f,0x1269314,0x0445984,0x0cdf008,0x037b24b,
  36784. 0x05477b7,0x1353207,0x126a484,0x18ddf40,0x1bdfd21,0x169eef8,
  36785. 0x0ca95ac,0x1f3afa4,0x00649b5 } },
  36786. /* 127 */
  36787. { { 0x19a9c35,0x056fc33,0x1e5b590,0x0796e9a,0x0dad98e,0x074ed7e,
  36788. 0x03aed7e,0x0788c97,0x0ad4a07,0x19c30a7,0x17955d1,0x01dc5db,
  36789. 0x19bd86c,0x0bb6705,0x0cc5ce1,0x1f72cee,0x1274095,0x0cdae99,
  36790. 0x1826bab,0x015d67d,0x013672f },
  36791. { 0x0e54ba5,0x063b6b2,0x14868e2,0x03b88e9,0x03fe7af,0x13b840b,
  36792. 0x1a746ca,0x15aff47,0x0de1240,0x023da4f,0x00c0e81,0x16cd8e4,
  36793. 0x13d9f64,0x135e810,0x11e00a7,0x07d4b63,0x0700aa0,0x18e578e,
  36794. 0x0ee174a,0x0301d67,0x0103179 } },
  36795. /* 128 */
  36796. { { 0x12ed12f,0x1a7cfd7,0x162ab6f,0x09e701f,0x0e1d19e,0x0f40d76,
  36797. 0x0f6d68e,0x17812af,0x1626ef6,0x0c19990,0x16ca37e,0x0bd419e,
  36798. 0x14110ae,0x101c966,0x0565140,0x0f0ab56,0x0876bc6,0x133e24c,
  36799. 0x0ff5871,0x1cb2714,0x004ace7 },
  36800. { 0x0c7dea9,0x0dcf794,0x0611671,0x1414d4e,0x102f95b,0x013b4e6,
  36801. 0x1095e08,0x12c069b,0x094dd68,0x09d8584,0x1aa5688,0x16ff6bb,
  36802. 0x0903730,0x10be544,0x090fb41,0x140a5fc,0x117fb1b,0x10b67a6,
  36803. 0x09be5b6,0x123ad64,0x01c0d86 } },
  36804. /* 129 */
  36805. { { 0x18015c2,0x16f9fdf,0x0b62a8b,0x1b892a0,0x07f8236,0x1218abf,
  36806. 0x1db829a,0x019d121,0x1a2d04b,0x0c77992,0x076eacc,0x0d1b501,
  36807. 0x019cc06,0x0d33e51,0x09a4deb,0x17893ba,0x12c83fe,0x04793e0,
  36808. 0x126e611,0x07b65e7,0x002987b },
  36809. { 0x12e3dc7,0x1d7687e,0x1554df9,0x16e82bf,0x098e8bd,0x122f92a,
  36810. 0x1b26962,0x1a1f81a,0x0209c85,0x1eadd5d,0x0787ba0,0x1b8daaf,
  36811. 0x0d31ec8,0x12815ff,0x132b42e,0x17de23e,0x0ce1f41,0x0e21973,
  36812. 0x0fff299,0x015f557,0x01913b1 } },
  36813. /* 130 */
  36814. { { 0x1053af7,0x1bef829,0x13d2f67,0x0b65143,0x0030476,0x14821c3,
  36815. 0x1e3f1f3,0x1ba882e,0x0ac8c5d,0x1df69b7,0x07b1863,0x0277f6b,
  36816. 0x0f27b13,0x10d8df6,0x0995bfe,0x0e7533a,0x1459459,0x099a709,
  36817. 0x0d8ad65,0x0311198,0x018c326 },
  36818. { 0x07f6ff8,0x1d20a55,0x11ebd04,0x107f56f,0x092aeb8,0x0183dd0,
  36819. 0x021adf3,0x01df43b,0x1234610,0x040e092,0x10324f7,0x04e6042,
  36820. 0x1593d4d,0x1308241,0x1b5f8f3,0x12be743,0x0cfdf17,0x1715c8f,
  36821. 0x1a7b505,0x1b82346,0x0191160 } },
  36822. /* 131 */
  36823. { { 0x157d7cc,0x17a3745,0x0e1a69c,0x0a97e04,0x1140b0e,0x19d48e9,
  36824. 0x0e5b816,0x1c110d8,0x1a4ec26,0x1cd59d4,0x1d63a46,0x15d78a1,
  36825. 0x10742fe,0x0af1357,0x04b1821,0x1b3ee2b,0x076bb1c,0x0ca1e6a,
  36826. 0x1fc0b22,0x12ffa98,0x017c3ed },
  36827. { 0x0d54964,0x01281f3,0x03014ec,0x058d463,0x19bd116,0x0146116,
  36828. 0x1b3d273,0x08031fe,0x0035346,0x02e3c20,0x1019a29,0x06bd699,
  36829. 0x038ea33,0x1a16df0,0x15c9fe3,0x1879af5,0x111fdf6,0x158abf4,
  36830. 0x1264b5d,0x112993d,0x01b3a7f } },
  36831. /* 132 */
  36832. { { 0x109ea77,0x171cbd7,0x1716479,0x12ebb84,0x06a760b,0x050cbd9,
  36833. 0x03022e5,0x0331808,0x0b68ce6,0x00dd654,0x08d5901,0x1a2ab7a,
  36834. 0x1fa19a0,0x0cbbd99,0x1296e53,0x1a0530d,0x1f8e5fb,0x0f98fc3,
  36835. 0x06407e6,0x18ab4d6,0x00b8f76 },
  36836. { 0x046ec9f,0x1fc619c,0x09185d6,0x193bd59,0x1462205,0x0846f87,
  36837. 0x17b028c,0x0512596,0x1cfaed9,0x1ced941,0x127eca1,0x0008ca0,
  36838. 0x11477dc,0x0b77281,0x1492eb2,0x19c8a91,0x11656ad,0x1d3edb5,
  36839. 0x0c71a13,0x019b575,0x00fc011 } },
  36840. /* 133 */
  36841. { { 0x1308bf2,0x1b36c26,0x0010546,0x1facc70,0x19013c9,0x1c1dfcc,
  36842. 0x17e4bf4,0x1f8d125,0x03ffc8e,0x0877ec2,0x1a8a1e8,0x02d8627,
  36843. 0x00527e3,0x1d06fba,0x1db8f34,0x1a5431d,0x030f6eb,0x165cb72,
  36844. 0x1c3b933,0x17d9e54,0x018cc1e },
  36845. { 0x070404c,0x0a56b8d,0x08c2034,0x01f39c5,0x0ad21dd,0x11f0393,
  36846. 0x0f378ea,0x1217299,0x16363a6,0x15acb08,0x078ad02,0x1e8b8d6,
  36847. 0x1be70bf,0x1367762,0x05b742d,0x0af8025,0x0747477,0x06a6595,
  36848. 0x15f647a,0x11194c7,0x00aa089 } },
  36849. /* 134 */
  36850. { { 0x0db0396,0x0e7e57c,0x09daa8b,0x0f6845b,0x08ae8f3,0x042b927,
  36851. 0x00d2659,0x07eca5f,0x07bf149,0x123e1e2,0x11e93bd,0x168d604,
  36852. 0x0e8b600,0x1d75ed4,0x1cf90e5,0x11be157,0x11fa795,0x1170e91,
  36853. 0x0206eac,0x0d2563f,0x00ef38e },
  36854. { 0x0cf3047,0x00b4493,0x01607cf,0x08b2a73,0x1ad14f9,0x1f905b6,
  36855. 0x17470a4,0x02ffbd0,0x0f57abb,0x152a1b7,0x1378e0b,0x1ff82f2,
  36856. 0x0f0d1a8,0x15ff669,0x0942388,0x0c08537,0x07fdb78,0x0088785,
  36857. 0x1378c7e,0x1cdec8f,0x01962ad } },
  36858. /* 135 */
  36859. { { 0x0c78898,0x1529bff,0x1dff265,0x05bc1f4,0x0b39de7,0x0658478,
  36860. 0x1dab34d,0x0a7eda0,0x0da78d3,0x06c5dc1,0x04b306b,0x09a7407,
  36861. 0x1d5fe80,0x12c0aa4,0x1eb7b7b,0x18db356,0x1a0c067,0x1c41c80,
  36862. 0x1b64fcd,0x0bff449,0x0191585 },
  36863. { 0x19ebef3,0x1871b5f,0x05dca55,0x0bbe966,0x021046a,0x00b5ae7,
  36864. 0x06a569a,0x023f371,0x1288d0e,0x0f9c940,0x04566ab,0x17ca72f,
  36865. 0x12d6baa,0x0e47d5d,0x06bfb81,0x15e2082,0x1afe5c7,0x1f8c961,
  36866. 0x1f738de,0x05d039a,0x00f7aa7 } },
  36867. /* 136 */
  36868. { { 0x0c386ee,0x11e078b,0x00e483e,0x13a9813,0x133b046,0x15189b5,
  36869. 0x15c8a1d,0x00cf3c1,0x03c406c,0x01e0549,0x0f89f4d,0x1c7c9bd,
  36870. 0x0aef220,0x0cb7807,0x15ec784,0x1b9fe13,0x1d824a9,0x0a507ae,
  36871. 0x0707421,0x105d8b3,0x01e2535 },
  36872. { 0x138c7ed,0x1793128,0x0237323,0x08ca8ff,0x1ec4319,0x054a446,
  36873. 0x14eb774,0x1b856dc,0x08257eb,0x1cf8f7d,0x032627a,0x0dd63e1,
  36874. 0x08c583c,0x000b1bb,0x1cda445,0x01c7be2,0x18bdbc2,0x131417f,
  36875. 0x12f5453,0x10200b3,0x00d526b } },
  36876. /* 137 */
  36877. { { 0x0025949,0x0a917d0,0x0514912,0x1e177b1,0x126d888,0x1b90b7d,
  36878. 0x0bd7f98,0x1ec6688,0x0472827,0x0761db2,0x109a076,0x034733f,
  36879. 0x0d91d8a,0x1463b88,0x08cbab5,0x04ec4da,0x02fe51b,0x1c72dff,
  36880. 0x14427e9,0x1e9fdbf,0x00040f9 },
  36881. { 0x14a05e0,0x17528b5,0x03ac654,0x1de438f,0x0b0d48e,0x0befede,
  36882. 0x1986466,0x1fac9a6,0x08b4c21,0x088d902,0x08c0e83,0x136d7d2,
  36883. 0x09a6f56,0x1c62f40,0x03d8259,0x0bb1c57,0x1ab3680,0x139135a,
  36884. 0x0cd2728,0x1fe301b,0x01bdd6c } },
  36885. /* 138 */
  36886. { { 0x03cc612,0x1c2bb4a,0x071e927,0x1d06566,0x0914319,0x056f5ee,
  36887. 0x18a5f33,0x043244b,0x0b06198,0x08c7da1,0x0731f12,0x01084b6,
  36888. 0x10accb3,0x132372f,0x074cd1e,0x07c44ea,0x0ae590e,0x0757da5,
  36889. 0x1128002,0x08c0705,0x0151821 },
  36890. { 0x196a461,0x040eddf,0x0e90f09,0x136a547,0x11c122e,0x06d845a,
  36891. 0x0163919,0x03a4385,0x06d6a08,0x080a5bc,0x0f3bdec,0x1da9ea6,
  36892. 0x1c167d3,0x00aa2fb,0x1ecca52,0x0f73ed9,0x11c449b,0x0f52369,
  36893. 0x18870a6,0x1aec272,0x0081cfa } },
  36894. /* 139 */
  36895. { { 0x18a7f0e,0x0b193a3,0x0177bde,0x05bc2ee,0x114183e,0x108bf44,
  36896. 0x09b7d5c,0x19fa494,0x1b7cd52,0x06d8d84,0x0f0580f,0x13f75b0,
  36897. 0x099e42b,0x184f7c6,0x1c74ba9,0x0999ad2,0x05b8ee5,0x00c4a7e,
  36898. 0x129483f,0x0f69ca6,0x00fcf75 },
  36899. { 0x0b62347,0x08c6643,0x04a1695,0x04f7855,0x0c51c9d,0x13393ff,
  36900. 0x0ac14a5,0x0de5dd4,0x00ae43e,0x045471d,0x0819aef,0x16bc0b9,
  36901. 0x0d80535,0x0419cc3,0x1ff36c6,0x099bb23,0x1ba3237,0x197a52d,
  36902. 0x1480890,0x0c74921,0x0124087 } },
  36903. /* 140 */
  36904. { { 0x0fac14d,0x05cb927,0x14f3926,0x1b4f353,0x16f4bf8,0x103e14d,
  36905. 0x036f75b,0x0701e3d,0x1717715,0x161867e,0x00c98fe,0x1a44e36,
  36906. 0x154c91e,0x0cda2af,0x04e0cd4,0x1257f7f,0x1891270,0x0bb52f3,
  36907. 0x1204ef6,0x0ce9c36,0x0128a97 },
  36908. { 0x03e5924,0x11e20ac,0x1418a6d,0x031e2e3,0x01f9aff,0x113d143,
  36909. 0x0cf36ac,0x0e0568b,0x08a11ab,0x1ceaeed,0x0da5c64,0x0f61d1b,
  36910. 0x052bfb4,0x0760840,0x08de77c,0x03002ac,0x08124ce,0x157ad32,
  36911. 0x13e52ae,0x1188686,0x01508d9 } },
  36912. /* 141 */
  36913. { { 0x1ffc80f,0x0ff39e7,0x0fdb7aa,0x17a868e,0x023e2e9,0x09bdd3f,
  36914. 0x0fb4f27,0x0ae4ff6,0x07a3fc3,0x19bb369,0x1280f5c,0x19e71c0,
  36915. 0x03d0db4,0x15df07a,0x1805d48,0x0de9f19,0x119da98,0x1ec3f5b,
  36916. 0x1f9ac0d,0x16a15c5,0x01536d1 },
  36917. { 0x040bab1,0x1aef7ed,0x098cdc7,0x1f3657b,0x07d6a8a,0x0565438,
  36918. 0x1722435,0x156bd14,0x1643ff8,0x0b9787f,0x03b0bd3,0x01b297f,
  36919. 0x029c4c1,0x075c9f1,0x0c3aae8,0x1fa026d,0x08f1d2d,0x15e2587,
  36920. 0x14d2820,0x0a5cb53,0x01429f2 } },
  36921. /* 142 */
  36922. { { 0x10e7020,0x1ea60be,0x05a12bf,0x156a904,0x1b169aa,0x079a47c,
  36923. 0x05c2162,0x177b7c0,0x1885986,0x175fb7f,0x070e076,0x0fea2bf,
  36924. 0x1bb3398,0x0254a53,0x1157cb0,0x0d092fc,0x042a0ed,0x01cd20a,
  36925. 0x1bdde63,0x15a94c3,0x01541c1 },
  36926. { 0x12709c4,0x1db1403,0x17f9d91,0x171021c,0x1330d68,0x1707b1d,
  36927. 0x021d3a4,0x175a37b,0x1f8bea9,0x02727dc,0x0260685,0x1831063,
  36928. 0x07c15af,0x1b46350,0x071720a,0x016cdc3,0x1a236e0,0x042c62b,
  36929. 0x1f2debb,0x0aa2200,0x00119b2 } },
  36930. /* 143 */
  36931. { { 0x087027d,0x07693e4,0x0a18487,0x0a57f56,0x0050f33,0x0a88f13,
  36932. 0x0f07067,0x1eadc6e,0x17f4c69,0x16a61d4,0x09aed00,0x0d5e4a4,
  36933. 0x10e6f35,0x01f3d61,0x040470e,0x1fbf677,0x03d33d8,0x1a1d861,
  36934. 0x1cba8d8,0x0721ef5,0x000ba8c },
  36935. { 0x0851bac,0x061eb3f,0x13f310c,0x134bea8,0x0991c38,0x1dd030c,
  36936. 0x0f1919f,0x1e800d7,0x097cbdb,0x04e8127,0x12b6b75,0x0fbaee6,
  36937. 0x0a4539b,0x1465b69,0x0ea3e7c,0x1675b21,0x0304de4,0x03d490c,
  36938. 0x1ee5a4a,0x0e65df4,0x006ab28 } },
  36939. /* 144 */
  36940. { { 0x0ed5986,0x15a9691,0x1819c76,0x14b0a67,0x1eee627,0x0aaff1e,
  36941. 0x18deb3c,0x065d1fd,0x17ae8b1,0x0b0a486,0x022e533,0x030a694,
  36942. 0x102706e,0x1ce0ae1,0x17ff54b,0x15a8d50,0x0f351a5,0x1ead112,
  36943. 0x135c02e,0x036daaa,0x01e644d },
  36944. { 0x02e4e9c,0x1834343,0x1f925a0,0x1890ec7,0x1e5cd76,0x01ce557,
  36945. 0x059e702,0x05ac061,0x18d83d6,0x07265f5,0x112b8b0,0x0a9c237,
  36946. 0x02911e2,0x127e503,0x0835f21,0x0e08b2d,0x1d5e9a2,0x07abc2e,
  36947. 0x0f8104b,0x0cefa1e,0x01be2f4 } },
  36948. /* 145 */
  36949. { { 0x101a6dc,0x0096ed5,0x0da5300,0x035c35b,0x191bd6c,0x18283c9,
  36950. 0x16bb2e6,0x03e75cf,0x062a106,0x138a7cf,0x14dadf0,0x1dcf52c,
  36951. 0x0b71978,0x0f0bb2a,0x1046f41,0x07ba9dd,0x0e0efab,0x0e388b3,
  36952. 0x1fb6fd8,0x154ae50,0x01d70f7 },
  36953. { 0x1eb5932,0x137bea8,0x12909ba,0x14bf105,0x154ea0a,0x1cfbee1,
  36954. 0x1825ddc,0x0682eb6,0x09be579,0x19a8c95,0x117b334,0x0846f0a,
  36955. 0x1d9801f,0x1db21e4,0x0e38959,0x157d865,0x1d723e3,0x0dca08e,
  36956. 0x1c71942,0x1bd4d19,0x00ee656 } },
  36957. /* 146 */
  36958. { { 0x0890deb,0x070a050,0x12f534e,0x1b79d70,0x1f7bd87,0x020ef65,
  36959. 0x1fdcae8,0x1d2a3e1,0x0a6820b,0x1f76385,0x018a62b,0x0147189,
  36960. 0x0475519,0x1380876,0x16e9563,0x0f363d9,0x1b88c78,0x0676c8e,
  36961. 0x1d78857,0x1c7c99d,0x014c08d },
  36962. { 0x0266da2,0x09a768b,0x0026705,0x16f6992,0x1ce322e,0x093b444,
  36963. 0x12bbda6,0x09a6fbd,0x105c284,0x09284bf,0x1466ad9,0x1c26358,
  36964. 0x06d23b7,0x12d1e64,0x0baedc9,0x08aead0,0x1b9628c,0x186298e,
  36965. 0x0e014dc,0x01d170e,0x00be2e0 } },
  36966. /* 147 */
  36967. { { 0x1ed32e9,0x1e4002b,0x065ce01,0x1ef8049,0x027e40c,0x1aa4182,
  36968. 0x1aaeeae,0x1e8b0a0,0x1ce820b,0x124bbb7,0x10fa055,0x0527658,
  36969. 0x08b5353,0x07f7b32,0x07a0d4f,0x1b94ace,0x13f903b,0x09390be,
  36970. 0x004ff5e,0x1382135,0x01dc40a },
  36971. { 0x1b21a38,0x153619e,0x1f91afa,0x03ae7de,0x0ae222e,0x0ea83fe,
  36972. 0x0139ef4,0x1563fed,0x0587a77,0x0dd6332,0x12935bd,0x1ec418c,
  36973. 0x0a58c74,0x153e1bc,0x0a0df65,0x1c81299,0x1313e42,0x1fa1efa,
  36974. 0x0d27853,0x14868ff,0x013f8a9 } },
  36975. /* 148 */
  36976. { { 0x12f8923,0x1a76fcc,0x07ce16a,0x00dfa41,0x024aa5e,0x09a0777,
  36977. 0x06e1c6c,0x0804f7d,0x191e0bb,0x0abe88f,0x1318b0a,0x15a5e7a,
  36978. 0x0f425af,0x03ffbd5,0x08c4a1b,0x197d25a,0x12b0114,0x0cb2095,
  36979. 0x0f88d4a,0x0d44638,0x019f670 },
  36980. { 0x05c02af,0x1dde911,0x06341ac,0x0c7f47d,0x13ebc16,0x07a4172,
  36981. 0x0add6e1,0x1bf4dbe,0x12bfc55,0x095a290,0x09cf6a4,0x1a80a25,
  36982. 0x0430bdb,0x1ea9f55,0x03d0f64,0x1faa758,0x1e40c27,0x07e1ac7,
  36983. 0x065092d,0x03077d2,0x00a32cb } },
  36984. /* 149 */
  36985. { { 0x1a6a746,0x186169f,0x12a38e6,0x043ab44,0x084a792,0x06f95af,
  36986. 0x02451e3,0x166e14b,0x130666c,0x144033e,0x1c741a2,0x013deda,
  36987. 0x04b09a7,0x0032e8c,0x001e8f8,0x12890a0,0x14bb8dc,0x0382357,
  36988. 0x19524eb,0x1462538,0x01fd2b6 },
  36989. { 0x05f2771,0x0eadef2,0x16574f5,0x15e865d,0x0542b08,0x19535dc,
  36990. 0x103efc8,0x1645d9a,0x1e8becc,0x1e5b0a1,0x1891fc3,0x02757f1,
  36991. 0x1bcecc5,0x06d181c,0x1755bde,0x141bf2a,0x01956c2,0x148abe3,
  36992. 0x00c7f8a,0x06b97e6,0x018ca6d } },
  36993. /* 150 */
  36994. { { 0x00c4923,0x0058ddf,0x01ef760,0x00d2052,0x046ae74,0x1de8638,
  36995. 0x0cdfe55,0x1704731,0x19655f8,0x1470d4e,0x1d0542a,0x0ff4a01,
  36996. 0x0ecd292,0x10173d7,0x1aa71b4,0x0d25d04,0x0b39f29,0x05a67ac,
  36997. 0x1d055df,0x070d197,0x011f309 },
  36998. { 0x13ed442,0x1af3d19,0x1deeb72,0x1f20dfd,0x0e5c8e2,0x0c79145,
  36999. 0x0048cf6,0x0b85b36,0x07ffe12,0x119796d,0x0c60d51,0x0e63744,
  37000. 0x1259487,0x0969628,0x12ab96c,0x1b38941,0x0589857,0x15f8073,
  37001. 0x13c803d,0x02010ca,0x0172c5d } },
  37002. /* 151 */
  37003. { { 0x1c283e0,0x0a02317,0x0039625,0x08fdc11,0x1763398,0x1e8b117,
  37004. 0x0d03adf,0x1dbf5e3,0x0f598c5,0x07a8a8f,0x0366efb,0x05eefc0,
  37005. 0x146b4d9,0x14621fe,0x10f8ece,0x1a3a4ea,0x12c6511,0x19cca70,
  37006. 0x1c16db4,0x08343b5,0x00c6dd8 },
  37007. { 0x1b991ad,0x10bf011,0x14508f6,0x06e3f74,0x0ab2b21,0x0e0c3cd,
  37008. 0x1b16837,0x1b9682f,0x15f63ac,0x19de456,0x09f5405,0x04203c5,
  37009. 0x082fcf5,0x1083680,0x0dcff41,0x0259ec6,0x1de7db0,0x18f4108,
  37010. 0x1d9517b,0x0ecdb2a,0x018ca07 } },
  37011. /* 152 */
  37012. { { 0x180dfaf,0x1a3dcd7,0x1fce390,0x1f388cc,0x080b631,0x0de11c5,
  37013. 0x16c99b7,0x140dfe3,0x1aa8718,0x0b0f1b2,0x070d7d8,0x19215e6,
  37014. 0x08e7f7a,0x1e34237,0x0e0c747,0x0eb6980,0x1106841,0x10f334e,
  37015. 0x0d2dcc6,0x13ac412,0x00c76da },
  37016. { 0x1e4e78b,0x1acbdd1,0x1e6a607,0x18aa133,0x0c14ded,0x0446309,
  37017. 0x0e6564c,0x0b17e6e,0x19b2074,0x02b4183,0x1da401f,0x188f444,
  37018. 0x13c4440,0x1bf36d7,0x17c8f23,0x122076d,0x0254292,0x1a7b316,
  37019. 0x0cede58,0x14db631,0x00f9f4e } },
  37020. /* 153 */
  37021. { { 0x0d36049,0x0f5c467,0x07e319a,0x03e8373,0x07a4ffe,0x1970844,
  37022. 0x1d58da9,0x114d216,0x065a0bb,0x1eeb546,0x10a5559,0x18b12dc,
  37023. 0x0d42cf8,0x0d55ffd,0x01ad7cc,0x04d48a5,0x0f28f6f,0x18fbefd,
  37024. 0x186b940,0x13c1581,0x0120c5d },
  37025. { 0x0c10da7,0x171ffd6,0x1b96bef,0x1328928,0x07e2d5f,0x01107fb,
  37026. 0x1fa18f1,0x05d1d82,0x0bd6f63,0x137ba0a,0x127bd3f,0x181f87f,
  37027. 0x104a9e3,0x01dfdc3,0x1fcf2e8,0x0685a4b,0x000bb03,0x10c7e9b,
  37028. 0x014334b,0x07cea60,0x01ac1e6 } },
  37029. /* 154 */
  37030. { { 0x13d6a02,0x1e83e47,0x0347760,0x18fde9a,0x11fc143,0x03d7b0b,
  37031. 0x12fc353,0x1e19532,0x0827c5c,0x0549f4c,0x05e20b2,0x18f656d,
  37032. 0x1a4a102,0x052af45,0x0f21f56,0x0c9e0c6,0x02fcc2d,0x00d7441,
  37033. 0x01b407f,0x136a7f3,0x01c12ce },
  37034. { 0x1dc1b79,0x11cfeca,0x05aa165,0x087e9cc,0x0728f75,0x117dcf9,
  37035. 0x0f133b7,0x13cdce0,0x0d50fae,0x017bb40,0x14c3b41,0x187785a,
  37036. 0x0c0546b,0x06eacc5,0x09001af,0x0922001,0x0c9e129,0x09f9943,
  37037. 0x1afe58a,0x1044ab6,0x0146777 } },
  37038. /* 155 */
  37039. { { 0x10c98fe,0x0a10f71,0x1c16be0,0x01f859a,0x1eb0feb,0x0fb5696,
  37040. 0x1329853,0x1d13658,0x09ba314,0x1c09a6f,0x12c5b74,0x1d709e0,
  37041. 0x08a443d,0x183fc65,0x155bb83,0x0722ff8,0x1bb3a4f,0x09e0e41,
  37042. 0x06b7350,0x0fba496,0x0199839 },
  37043. { 0x14781e6,0x0f0bf6f,0x0407280,0x128de3f,0x12d7c31,0x18486d1,
  37044. 0x0984ed4,0x00f444f,0x0a7c8c6,0x04ad8ee,0x1a5c249,0x17ddbb8,
  37045. 0x181cf2f,0x02b0404,0x0f60aed,0x069ae3a,0x1a30851,0x0e7e6ee,
  37046. 0x19e6310,0x02e36b2,0x00d23dd } },
  37047. /* 156 */
  37048. { { 0x0dd7e96,0x007c26a,0x10325e9,0x150813f,0x1114c8e,0x0889c9b,
  37049. 0x0a79aa7,0x1ad8ade,0x18fd8c6,0x1b03310,0x1a79f0e,0x150c004,
  37050. 0x1fad3ba,0x02c94ea,0x04f1ac0,0x06cb628,0x040222e,0x060d6bf,
  37051. 0x1e62abb,0x04c4348,0x01d36a8 },
  37052. { 0x1003c81,0x022e260,0x180abab,0x15e87b0,0x1ef9ef5,0x1bba34c,
  37053. 0x17d7983,0x0b06d4c,0x1bf5d28,0x18973d5,0x0b3bc7c,0x1903909,
  37054. 0x122f53e,0x0e9245a,0x18cb28a,0x0b8c0c7,0x1c581e6,0x1ff4d53,
  37055. 0x0a1065c,0x10d934a,0x0017e36 } },
  37056. /* 157 */
  37057. { { 0x090de99,0x17f32cf,0x0d8c2cb,0x195a0b5,0x1e4485b,0x0724495,
  37058. 0x1a94b85,0x10f8914,0x0226286,0x16c2a18,0x0f6d50a,0x1d2abd6,
  37059. 0x01261f0,0x0a2f2c2,0x1a0618f,0x0ae7291,0x00f8ed7,0x067f0e7,
  37060. 0x1612b79,0x1e3feaf,0x003fbd6 },
  37061. { 0x1bf968c,0x188eee8,0x11cb50d,0x1a91bf4,0x1558d7c,0x12d2b36,
  37062. 0x0488f90,0x08293e1,0x05c26d0,0x07c199c,0x105d0c3,0x03e2f85,
  37063. 0x19be7b8,0x08a1ece,0x0f70cf9,0x07f5dc7,0x03594fd,0x179c2d6,
  37064. 0x1f46046,0x039e853,0x0113755 } },
  37065. /* 158 */
  37066. { { 0x0193bb2,0x07aad90,0x01c924a,0x00e6217,0x16e579d,0x02e93b4,
  37067. 0x18c274d,0x114bdc0,0x0a87186,0x121f219,0x0e1a0e6,0x07c2220,
  37068. 0x0828c11,0x1199788,0x01bb3ce,0x1976905,0x0370385,0x199a455,
  37069. 0x1c5636b,0x1ff955d,0x00c6698 },
  37070. { 0x0908745,0x062a57b,0x0fee811,0x08d466a,0x06b336e,0x10f410d,
  37071. 0x0a14b55,0x0fed298,0x0363491,0x194bcb8,0x184c546,0x077303e,
  37072. 0x0f6e102,0x17a352f,0x05f70af,0x09efed0,0x0af8e11,0x1c9ef50,
  37073. 0x15cb16f,0x1e79abd,0x0136c3c } },
  37074. /* 159 */
  37075. { { 0x1080de4,0x1ccd5bd,0x0e5aee1,0x1bad3b0,0x1b8f781,0x17c7b19,
  37076. 0x0aaaa61,0x194ed68,0x0a54bc5,0x0ba601c,0x0beee57,0x0c0b538,
  37077. 0x1076fcb,0x000bc49,0x146d102,0x0de1b08,0x0389d28,0x1a07806,
  37078. 0x1150c98,0x11d2a41,0x014c303 },
  37079. { 0x177aad9,0x1e1c0b4,0x0f8f252,0x05ae10f,0x0dbfd08,0x0ff6845,
  37080. 0x008321d,0x1f80da1,0x0345656,0x0e7426a,0x1b753b8,0x11c01fa,
  37081. 0x0071c4d,0x152fd5a,0x0ce2c89,0x1d6de46,0x0c10bae,0x06a3bf5,
  37082. 0x1e0309b,0x161176b,0x0078e4d } },
  37083. /* 160 */
  37084. { { 0x078342a,0x0e89508,0x0190044,0x1cab342,0x0534725,0x09ffee8,
  37085. 0x075643f,0x03fd48b,0x106f0ac,0x1b4a54f,0x06f1a73,0x15b67c3,
  37086. 0x00f6d24,0x1ceee68,0x18e3d7a,0x1ba9c79,0x166b632,0x09c2007,
  37087. 0x0578715,0x11fbf7c,0x0085cab },
  37088. { 0x109422f,0x01fb5c6,0x10ec2a5,0x0c1f311,0x17d2975,0x19726c8,
  37089. 0x107e8bb,0x07eab48,0x135f7c1,0x1a1a91d,0x0b4ffd9,0x080fdb5,
  37090. 0x0d274d3,0x09a3921,0x10450d6,0x0c2bab2,0x1013bb8,0x08e5939,
  37091. 0x15de533,0x06e0097,0x007da04 } },
  37092. /* 161 */
  37093. { { 0x1712c44,0x1ccd316,0x15de092,0x114d2c4,0x148368f,0x0f11438,
  37094. 0x010cb59,0x1f11dad,0x06f5bc5,0x0014183,0x0d1e745,0x02429d8,
  37095. 0x10e6cf3,0x09936db,0x16dbd12,0x126d72d,0x098ca32,0x1e52d60,
  37096. 0x1fa886b,0x04918e5,0x004d69e },
  37097. { 0x11269fb,0x0484953,0x0d802aa,0x1030ca1,0x0f6bdba,0x1aaed91,
  37098. 0x10a8e7e,0x1a03b39,0x16311e9,0x1e7586f,0x10b0743,0x0f39215,
  37099. 0x0a6faeb,0x058f9b9,0x04ec88b,0x0832647,0x1dfbc8c,0x0315379,
  37100. 0x1fa399d,0x1461645,0x00019de } },
  37101. /* 162 */
  37102. { { 0x0b3118b,0x144d609,0x0959f7d,0x1ad96dd,0x106ee39,0x1e6cbc6,
  37103. 0x08b0861,0x10f9f98,0x18d537d,0x0c2db40,0x15b6cae,0x02a5d3e,
  37104. 0x1575845,0x0f04c60,0x00e61c5,0x059a41f,0x1c83b21,0x1df4b52,
  37105. 0x06b0711,0x140671b,0x01fb3dd },
  37106. { 0x1a0a9b8,0x1bff067,0x1dd7c1a,0x0fc45b9,0x1478bac,0x1443e44,
  37107. 0x178104d,0x179e702,0x0914c54,0x0c08eef,0x07a993b,0x02c01ea,
  37108. 0x17c8c24,0x064382b,0x045360d,0x17968c7,0x152a8ab,0x1769272,
  37109. 0x1913d4b,0x1d73d04,0x00019e5 } },
  37110. /* 163 */
  37111. { { 0x0d52313,0x0d02733,0x0af47d9,0x0a9a7ee,0x1d69454,0x1bd708f,
  37112. 0x176be9a,0x08e5781,0x0571ab2,0x10fbcec,0x0a35a24,0x12cd5cb,
  37113. 0x13d4c5f,0x1762e70,0x185dc5a,0x17a73fb,0x1a4b764,0x1b87376,
  37114. 0x04359e0,0x12810b3,0x01efffe },
  37115. { 0x08f92e8,0x10713ec,0x08f3cfe,0x1b38ee2,0x021ef0f,0x13a6dd5,
  37116. 0x05d3224,0x0c4c4b3,0x1b9ba27,0x067d252,0x0f2bdb5,0x13a48dd,
  37117. 0x1010c90,0x07c7143,0x05e8436,0x1dd4406,0x1e1453a,0x1d83b8e,
  37118. 0x031ac28,0x188f22d,0x00eadf0 } },
  37119. /* 164 */
  37120. { { 0x0854477,0x00f2426,0x11f046f,0x090c71c,0x0bec25b,0x0e2a6c9,
  37121. 0x180ae1a,0x1a487a9,0x0be1e7e,0x18c6f19,0x18312b8,0x1d60d68,
  37122. 0x1ef5471,0x1521357,0x0b9efce,0x05b8271,0x0ddd845,0x091d713,
  37123. 0x1e0b7a7,0x1f83aaa,0x01649d3 },
  37124. { 0x0de1979,0x0571885,0x1ca361f,0x1a76978,0x0847041,0x01e4df5,
  37125. 0x0f1015b,0x0ce7124,0x0d74ae4,0x17f0c15,0x1926b8d,0x0de9d97,
  37126. 0x1592bff,0x0e20fcf,0x0036e03,0x00e2acd,0x06fe463,0x19add60,
  37127. 0x1b41cc1,0x11698fa,0x00c06d6 } },
  37128. /* 165 */
  37129. { { 0x14dfcf2,0x115f3c2,0x0f436f8,0x1f4d5c7,0x0e21a7d,0x10f6237,
  37130. 0x0eb4694,0x099e8c6,0x041a948,0x14a293d,0x048fcfb,0x1736554,
  37131. 0x121145e,0x0571e54,0x0d2a0ab,0x1b24aac,0x0a0fc85,0x070bb56,
  37132. 0x0420b63,0x19eff83,0x0078504 },
  37133. { 0x199793c,0x073e21b,0x1ed75d3,0x116aa33,0x14ddd61,0x1fcc043,
  37134. 0x17e4e57,0x1cc59ed,0x1b8bf61,0x07522e8,0x13d53c0,0x0c27b9f,
  37135. 0x1026863,0x01801ad,0x108edd8,0x15396ce,0x1344028,0x14fde3a,
  37136. 0x14681df,0x059c6e0,0x00f47b5 } },
  37137. /* 166 */
  37138. { { 0x0bec962,0x1ec56cb,0x01ebafd,0x0c2fc02,0x11cc81f,0x07082c6,
  37139. 0x1142485,0x13ec988,0x142394c,0x014c621,0x18144db,0x0a5a34c,
  37140. 0x03d9100,0x086fc12,0x190dd52,0x1bd4986,0x01efe5c,0x09189df,
  37141. 0x09fedec,0x14c1efa,0x0076249 },
  37142. { 0x0f593a0,0x1ac1c0e,0x1679d25,0x1706c98,0x0c9ceef,0x0e4cc88,
  37143. 0x04ccf81,0x1c65eb4,0x1421808,0x0752f0f,0x1a3d3cc,0x149e9eb,
  37144. 0x0756fb3,0x1b6065a,0x0b9b8ba,0x198d459,0x1fd08bd,0x1b05983,
  37145. 0x1fe3045,0x0f20381,0x001aee1 } },
  37146. /* 167 */
  37147. { { 0x1aa9e14,0x019b5c4,0x003f012,0x03ecece,0x0663427,0x15b4c03,
  37148. 0x010ce41,0x0469b54,0x1ebb7ab,0x0123f70,0x06814cc,0x154fd6b,
  37149. 0x15969b4,0x00007a6,0x03be096,0x0d6b7af,0x0eb4602,0x072ed9c,
  37150. 0x15a15b1,0x087cbaf,0x003b06a },
  37151. { 0x12a0ee7,0x1741c76,0x004ea82,0x11e2dd1,0x04bbe52,0x13209b8,
  37152. 0x17d713a,0x0cf156d,0x006e298,0x1f4065b,0x07b4ad6,0x16e5e8b,
  37153. 0x1af19b1,0x0bb0a90,0x0733934,0x0de76f5,0x194aa51,0x09cd7fc,
  37154. 0x0d05a49,0x125d0d6,0x000797d } },
  37155. /* 168 */
  37156. { { 0x0f3a8ca,0x176f0ad,0x07b096b,0x054b86a,0x1392478,0x1f60401,
  37157. 0x08fefe4,0x16883cf,0x0e6f425,0x027c9e2,0x1d8026c,0x05d903c,
  37158. 0x06e4ec1,0x08c07fe,0x1cd9b51,0x1de74f2,0x1b50e0a,0x0e949e5,
  37159. 0x035c764,0x12d288d,0x0061a14 },
  37160. { 0x15a67a1,0x02a0e33,0x041bd4b,0x011ebfd,0x07d38d3,0x1f4c473,
  37161. 0x0f333da,0x10c54e1,0x0185898,0x101f65f,0x1c116eb,0x0c2ce0c,
  37162. 0x16ecd02,0x086546c,0x0b37664,0x0e6ba3f,0x08230c0,0x03d5085,
  37163. 0x0ca3c87,0x0fcaa86,0x00152a2 } },
  37164. /* 169 */
  37165. { { 0x0057e27,0x104f073,0x1368f75,0x0f8f48a,0x07e8b6a,0x196eadc,
  37166. 0x045147c,0x1c5feb3,0x0d0ef51,0x11cbd44,0x19d51ba,0x0d424aa,
  37167. 0x00c4986,0x19145a4,0x11722c4,0x132f5d4,0x077dd01,0x11edf07,
  37168. 0x14619f4,0x1d451f8,0x01f80e2 },
  37169. { 0x1d0820b,0x0a096b4,0x08618a5,0x0e3d4cb,0x0317312,0x031c068,
  37170. 0x00887ac,0x00d84f9,0x075fe97,0x1fea77e,0x074941f,0x14aeb4e,
  37171. 0x037b396,0x03e5baa,0x1200147,0x17dc6c3,0x0d7ad4d,0x0f03eda,
  37172. 0x0c64b51,0x0903e93,0x01431c7 } },
  37173. /* 170 */
  37174. { { 0x0e1cc4d,0x1968204,0x07b97aa,0x075a5b8,0x093758d,0x0e39c9f,
  37175. 0x1f7f972,0x10619d6,0x1d33796,0x186c354,0x1e1b5d4,0x0795c49,
  37176. 0x0bef528,0x1858dd8,0x1746993,0x09c7956,0x01f54db,0x0cb555e,
  37177. 0x0f00316,0x1b0f987,0x01443e3 },
  37178. { 0x160e7b0,0x141098e,0x0063942,0x16ba67a,0x1c9b629,0x0299c6f,
  37179. 0x1b90bf4,0x1d58a95,0x0e821c6,0x13c7960,0x10272c1,0x0ebe0d5,
  37180. 0x16e5c9d,0x0980c6f,0x0d5d44d,0x18ccf06,0x1ac0bf8,0x0c0e537,
  37181. 0x142b8b7,0x10041d3,0x00e17fc } },
  37182. /* 171 */
  37183. { { 0x1aaa5eb,0x0a3a08d,0x00da2b7,0x12f37b0,0x02cbb75,0x1ff6910,
  37184. 0x0310337,0x083b0d0,0x04e0911,0x011d478,0x122e1c7,0x03da40e,
  37185. 0x0965d14,0x12cf494,0x1a855d5,0x1b7fcb0,0x1cd5006,0x03e346b,
  37186. 0x095a69d,0x15a1be4,0x0148da0 },
  37187. { 0x19069d7,0x062edbf,0x069323f,0x0ab80a6,0x0487d24,0x116d9d1,
  37188. 0x12267a6,0x0418b56,0x0b4fe97,0x15fea9c,0x1cd7914,0x1949a4f,
  37189. 0x1373a04,0x1716d64,0x0ef1527,0x1cfc4f9,0x09dff3e,0x0014391,
  37190. 0x036a4d8,0x130f1a5,0x00d0317 } },
  37191. /* 172 */
  37192. { { 0x166c047,0x1f4dd9d,0x187626d,0x12c0547,0x02e6586,0x0dce001,
  37193. 0x08a5f23,0x14689f0,0x1d08a74,0x13b5651,0x0e63783,0x0e3bf9a,
  37194. 0x0afbf1a,0x0190733,0x0edbaaa,0x13f8a5f,0x0bc179c,0x0541687,
  37195. 0x19eacad,0x019ede9,0x000f4e0 },
  37196. { 0x090c439,0x0074d24,0x1ac9093,0x17786b4,0x17564a2,0x1ba4be9,
  37197. 0x11e7766,0x0852b48,0x1612de9,0x0ff9f86,0x1400ce8,0x0ff9cc1,
  37198. 0x1a35862,0x09120be,0x176a301,0x1070b02,0x0d4ef6b,0x1283082,
  37199. 0x05ba5aa,0x0e51a5e,0x0120800 } },
  37200. /* 173 */
  37201. { { 0x1039042,0x191b955,0x13b65db,0x193f410,0x10e6978,0x1f60a18,
  37202. 0x174bd62,0x187a07f,0x1fe2045,0x1006080,0x16a4a0c,0x1ef5614,
  37203. 0x18e6868,0x130fd7f,0x1257477,0x044ca4d,0x127b7b1,0x1d0f100,
  37204. 0x0a97b45,0x07baf18,0x00898e6 },
  37205. { 0x0bba4ee,0x099ed11,0x15d2ed9,0x0fe92d4,0x1eff639,0x19535c9,
  37206. 0x0a7dc53,0x07e8126,0x11dfdd7,0x041245e,0x1286c68,0x1e5cd37,
  37207. 0x0762f33,0x1d17019,0x05df992,0x1ee8334,0x19375dd,0x05e2874,
  37208. 0x095af47,0x152f3e9,0x0095b87 } },
  37209. /* 174 */
  37210. { { 0x1c1f177,0x19b54b3,0x0f27a0d,0x10c0026,0x1b6d350,0x164d2d8,
  37211. 0x0ee49ba,0x0392849,0x0c27ef3,0x14e00d3,0x0d21c1e,0x174a245,
  37212. 0x05ad93b,0x0e8d64c,0x0e538aa,0x02eb73d,0x006d53f,0x0288e01,
  37213. 0x040b645,0x1d64a4a,0x00b1d13 },
  37214. { 0x15a1171,0x1edf5b3,0x0ac73f9,0x182d81a,0x1228295,0x1e44655,
  37215. 0x16d6815,0x19f1b64,0x0d300e9,0x1f54f4b,0x154badc,0x06fe4d2,
  37216. 0x1fb0e00,0x0f07cc6,0x0740d72,0x0901fd5,0x1b8d290,0x0c30724,
  37217. 0x00dacc6,0x1d2a258,0x0037a35 } },
  37218. /* 175 */
  37219. { { 0x100df48,0x194f747,0x0c13159,0x0c23590,0x189ca7b,0x1d4091d,
  37220. 0x15fe62c,0x1d492f4,0x1c21ca3,0x0218d8c,0x0cf39f8,0x1bd7c57,
  37221. 0x1945a73,0x16e3bc0,0x01b30ae,0x07be25f,0x1e4e5eb,0x02ff802,
  37222. 0x149f73c,0x0bbaf5b,0x005ef95 },
  37223. { 0x0ee402f,0x117fd00,0x0d33830,0x1476617,0x1b335e2,0x1e5880a,
  37224. 0x1474190,0x110a84a,0x13cd196,0x10c1fa2,0x1952d31,0x1e45e17,
  37225. 0x04c6664,0x061066f,0x1d33fb9,0x188eb4b,0x12f80a4,0x0ee554b,
  37226. 0x04447b6,0x15e400b,0x019cde4 } },
  37227. /* 176 */
  37228. { { 0x171f428,0x085e46b,0x0e0a7a7,0x13c8794,0x1ac1ecd,0x09d6781,
  37229. 0x19203ae,0x07f1abd,0x1065a2a,0x11197c0,0x0e29cc5,0x1f545e1,
  37230. 0x021fc04,0x012a3a5,0x037df9c,0x0bede95,0x1f23bb1,0x128d627,
  37231. 0x0254394,0x0436e7c,0x006b66e },
  37232. { 0x1a41dee,0x0c24033,0x0cfd672,0x1cf67c5,0x0cfa95a,0x0a2a709,
  37233. 0x00e1a24,0x148a9b3,0x1eefca6,0x06eedef,0x072dd7c,0x164823d,
  37234. 0x035f691,0x1f79046,0x0e79d9b,0x079ed53,0x00018b3,0x0f46f88,
  37235. 0x0705d2a,0x0ab593a,0x01c4b8a } },
  37236. /* 177 */
  37237. { { 0x04cccb8,0x1ac312e,0x0fbea67,0x125de9a,0x10bf520,0x17e43c3,
  37238. 0x195da27,0x0dc51e9,0x0da1420,0x11b37cb,0x0841f68,0x1400f8a,
  37239. 0x1090331,0x0a50787,0x03533ab,0x08f608f,0x0e2472a,0x0d944cf,
  37240. 0x1081d52,0x0ca69cc,0x0110ae9 },
  37241. { 0x0ed05b0,0x0eb2ae6,0x150cb30,0x1202eb2,0x0bac3f0,0x0bbe6bd,
  37242. 0x1c29239,0x0db75d6,0x140e98d,0x0580449,0x1493c61,0x0ca6c07,
  37243. 0x1d26983,0x12b90b9,0x051620c,0x083bcdc,0x1266111,0x00e9a45,
  37244. 0x1e89fcd,0x04afb9d,0x006be52 } },
  37245. /* 178 */
  37246. { { 0x147e655,0x1c799e4,0x1e56499,0x1411246,0x1f0fb76,0x011ce8f,
  37247. 0x19d15e4,0x19d65bf,0x03cdbb7,0x1043a49,0x1b5073a,0x1b720be,
  37248. 0x0821326,0x1cee2ac,0x06ba6b9,0x02e04b6,0x00ce9c3,0x070a29a,
  37249. 0x0b0e2a7,0x0058534,0x00c3075 },
  37250. { 0x156ace2,0x12788e0,0x14a4304,0x0ef3fe4,0x0c170fe,0x08b8d91,
  37251. 0x06a05b8,0x12ec1bf,0x155de27,0x0cde541,0x131e768,0x0fd4f8d,
  37252. 0x101ad92,0x0eb0fbb,0x1640448,0x00d7650,0x026261c,0x1ff4064,
  37253. 0x08990ae,0x01a6715,0x015e405 } },
  37254. /* 179 */
  37255. { { 0x0ad87bc,0x0bc14f5,0x12f724e,0x0f03d09,0x00ac936,0x0f27ef7,
  37256. 0x10935ab,0x0ad6af3,0x1690d7f,0x05cd5d2,0x1ec2e54,0x13a7a29,
  37257. 0x16f09b2,0x12d073d,0x1a13c8c,0x09fe7a0,0x1d3606f,0x1828a74,
  37258. 0x02b5cce,0x17ba4dd,0x0077e63 },
  37259. { 0x0d25c6d,0x0837670,0x173c2bf,0x1401745,0x1d90021,0x0dd9cc6,
  37260. 0x15dc231,0x1f83604,0x0198ff8,0x1bf836c,0x0b35a01,0x1fe36fc,
  37261. 0x1287d50,0x131d1ab,0x1d7815c,0x0b535de,0x092fa92,0x0df92bc,
  37262. 0x0e743a5,0x1a7be0e,0x0111847 } },
  37263. /* 180 */
  37264. { { 0x0c82924,0x1ce63ff,0x15a54aa,0x134e441,0x1c76dd6,0x1778710,
  37265. 0x09f7a81,0x0094c6a,0x0271839,0x19f28e1,0x001f22a,0x0bd4e2d,
  37266. 0x06f4db3,0x1a47892,0x0fb7829,0x0c12b1e,0x0444115,0x178a49b,
  37267. 0x1d2ce37,0x0b07a30,0x00f75f6 },
  37268. { 0x1927eb7,0x0c4f085,0x049e8e4,0x1385c5e,0x087c635,0x14b37a5,
  37269. 0x108cdff,0x10a16e5,0x0105e55,0x015c1c1,0x10e7e44,0x000dcb1,
  37270. 0x0963fee,0x0c8da99,0x014bb8e,0x1f2f67e,0x14ccbaf,0x03fadc2,
  37271. 0x1e01418,0x1cbed8b,0x016a935 } },
  37272. /* 181 */
  37273. { { 0x1d88d38,0x101aaef,0x1d03c66,0x078a93b,0x155cd8e,0x080370a,
  37274. 0x0a78c13,0x1cc644e,0x0fd0b0c,0x0b5b836,0x0ab4c7c,0x18126be,
  37275. 0x1ff156d,0x1bd1efc,0x031484f,0x0bf6b66,0x092a55e,0x14f94e6,
  37276. 0x0e16368,0x19fba85,0x0144a0e },
  37277. { 0x0658a92,0x08aefa9,0x185ad70,0x0f88502,0x1ce3ed1,0x0c9548d,
  37278. 0x17dc1ff,0x12d4ab2,0x19cd5d8,0x11e45fe,0x11cac59,0x087eb52,
  37279. 0x1d07763,0x1819f0d,0x19132a2,0x005f629,0x1861e5c,0x113d0e4,
  37280. 0x113fecc,0x01e5899,0x01b5ece } },
  37281. /* 182 */
  37282. { { 0x1211943,0x13dd598,0x09705c4,0x0cad086,0x04a8cac,0x0afe1f2,
  37283. 0x02e2361,0x14ba5fc,0x0ce91ee,0x1d5d586,0x11f4491,0x1b88f1d,
  37284. 0x1a5d23d,0x066cff7,0x061b79c,0x0aecd47,0x0678265,0x11963dc,
  37285. 0x1abb1fe,0x080317d,0x00873e5 },
  37286. { 0x18d17c1,0x1437959,0x103725b,0x18e3f40,0x1cbfbd0,0x024ce5c,
  37287. 0x0ade7e2,0x017c223,0x0f71ec8,0x0a3e2e7,0x025a487,0x17828d9,
  37288. 0x11acaa3,0x1e98b19,0x0487038,0x0ecb6bf,0x01ee768,0x018fd04,
  37289. 0x07bfc9c,0x15fabe8,0x00fed5d } },
  37290. /* 183 */
  37291. { { 0x0da1348,0x085cea6,0x04ea2bc,0x044b860,0x10769fd,0x0be115d,
  37292. 0x096c625,0x1888a15,0x1f5acf1,0x057eb63,0x1e00a57,0x02813fd,
  37293. 0x1dcf71a,0x17044fa,0x080a7d7,0x05751c2,0x0fb0fbd,0x04ba954,
  37294. 0x1dc32d6,0x044ebed,0x009061e },
  37295. { 0x1bda16a,0x125628f,0x0a8adc2,0x13e3bf4,0x19910e7,0x0a2fb7b,
  37296. 0x184cb66,0x1df7459,0x0eb4ba4,0x086acd7,0x0b54f51,0x136697e,
  37297. 0x086a8e0,0x131063d,0x0040813,0x18de8ec,0x03d0a53,0x131fc4a,
  37298. 0x1fabd5a,0x123a330,0x013214c } },
  37299. /* 184 */
  37300. { { 0x10d66c3,0x1d89024,0x0813953,0x1141b90,0x0aed732,0x1a14a6f,
  37301. 0x130e012,0x0cf7402,0x131ddc4,0x197d155,0x0bb444f,0x0bd5068,
  37302. 0x0e70ff5,0x1181a70,0x0369cbc,0x1c78363,0x1bebd8a,0x156e186,
  37303. 0x1a51680,0x17bede7,0x009c179 },
  37304. { 0x084c26f,0x09477ba,0x0ec51b2,0x03de55b,0x006b7db,0x0c6ed39,
  37305. 0x1d520fd,0x16c110f,0x04bc7ed,0x0f27106,0x12bf73f,0x043b2eb,
  37306. 0x00484d1,0x035f761,0x0d659c2,0x1b6cf8b,0x088a6d6,0x05abcd5,
  37307. 0x0461d22,0x0db0fc8,0x001522c } },
  37308. /* 185 */
  37309. { { 0x071d4ae,0x083abe2,0x09d82a2,0x0a8743b,0x1ef4b1a,0x1380d0f,
  37310. 0x0c609aa,0x1277125,0x059c65f,0x1a6a729,0x077cd6f,0x1253af1,
  37311. 0x12923af,0x05bce1f,0x12d1b18,0x1e26079,0x0e7cf4c,0x04aac16,
  37312. 0x15fc3b1,0x0103684,0x011c7da },
  37313. { 0x0eef274,0x03572cd,0x020fe4b,0x1e286f8,0x06c5bf4,0x1e4357f,
  37314. 0x0c08f84,0x0c154e9,0x02a2253,0x10ed673,0x027e974,0x057044b,
  37315. 0x0fb3d57,0x0fd3a58,0x128e45b,0x123527a,0x0dcb128,0x0f3b66c,
  37316. 0x07d33ef,0x12347eb,0x019aa03 } },
  37317. /* 186 */
  37318. { { 0x03fc3f1,0x1d34f10,0x08a4152,0x16c420d,0x09168cc,0x0afd4f8,
  37319. 0x01502ab,0x0df6103,0x0bff7ed,0x05c7907,0x052bf7b,0x0c317df,
  37320. 0x1b2c80a,0x1855e8e,0x1763282,0x014f9c4,0x041028e,0x13af33d,
  37321. 0x1ba56e6,0x0cc5bba,0x01b2dd7 },
  37322. { 0x089d7ee,0x1f93cf9,0x01721f7,0x13dd444,0x0d755d5,0x056d632,
  37323. 0x1f55306,0x0335d61,0x17ec010,0x1462367,0x15c290e,0x1cfd691,
  37324. 0x186fc90,0x0859cf7,0x1714f04,0x0b4412c,0x1cc3854,0x122abbb,
  37325. 0x1f7408f,0x0861eea,0x016ea33 } },
  37326. /* 187 */
  37327. { { 0x1f53d2c,0x19ca487,0x06e7ea7,0x0d60069,0x0dc9159,0x0cbcb3c,
  37328. 0x1405356,0x115e214,0x1a8a6b7,0x0eb96d5,0x05ec413,0x0a8116a,
  37329. 0x00ef5de,0x1369cdf,0x0ae42f2,0x0fee028,0x1e9eda1,0x0657551,
  37330. 0x1acc446,0x0d13ac0,0x016da01 },
  37331. { 0x06afff7,0x052b1fa,0x17cfa9b,0x14694bc,0x1945c7b,0x0cc7ec1,
  37332. 0x19322aa,0x0bd83ff,0x0b63f53,0x15300a3,0x1427950,0x1111a3e,
  37333. 0x1b50816,0x0fc6686,0x04636aa,0x0cee5a3,0x0bb78a3,0x13282f3,
  37334. 0x131b719,0x0075033,0x01ef4ab } },
  37335. /* 188 */
  37336. { { 0x176d986,0x04e8a69,0x16c0182,0x0f45b86,0x10f4e07,0x1f96436,
  37337. 0x1c2694f,0x1903822,0x1123c3f,0x17a5d22,0x15bf0bf,0x0b4e36c,
  37338. 0x1b852cd,0x0ff7d45,0x1f1d224,0x016ef6a,0x03e4811,0x0c7829c,
  37339. 0x0b1684a,0x0ba75aa,0x004c4b5 },
  37340. { 0x1827633,0x067f9f9,0x1a59444,0x0bc015f,0x086784d,0x16997d0,
  37341. 0x1e208fa,0x10d9670,0x02b91cd,0x0e7a68b,0x0d8e28f,0x14b1cde,
  37342. 0x02078b6,0x145bfea,0x1e4844b,0x107ce66,0x04dee56,0x1b4b202,
  37343. 0x038a10c,0x08421e5,0x01223b8 } },
  37344. /* 189 */
  37345. { { 0x1ebeb27,0x054d4e1,0x03e1b0a,0x0a7deb2,0x17bcdcb,0x173f9be,
  37346. 0x0b84536,0x193d114,0x0726ea7,0x19a9172,0x104e200,0x070d182,
  37347. 0x1599d50,0x10b10ab,0x0c6bb29,0x0c9b0b3,0x1ebfcc5,0x138cfe7,
  37348. 0x0bae38d,0x0ef5e23,0x00433a5 },
  37349. { 0x1eba922,0x1367037,0x1a4f0fc,0x1c8eb4a,0x1f6c83e,0x1f9bc72,
  37350. 0x19d00a2,0x1e2fef2,0x0bdc3f6,0x152f1b4,0x1642bb4,0x14154dd,
  37351. 0x153d034,0x0523e5e,0x070e931,0x0579076,0x06e4dce,0x1d27855,
  37352. 0x132803a,0x0f5e86e,0x01c097c } },
  37353. /* 190 */
  37354. { { 0x1c28de7,0x1b8bc3c,0x0c3000d,0x1557386,0x017aa2a,0x1e30f5b,
  37355. 0x060999a,0x0088610,0x14d78b5,0x05adae7,0x03f1cb8,0x0a5b30e,
  37356. 0x05d76a7,0x0a05bde,0x11a27d7,0x1a07476,0x06787f2,0x0d4bfec,
  37357. 0x158182a,0x0f6bddf,0x01c06ab },
  37358. { 0x1b71704,0x156d8ff,0x0ec7a67,0x16721fc,0x036e58b,0x078cd52,
  37359. 0x0e0b2ad,0x1b9dd95,0x0e0f3d9,0x12496fd,0x02b44b6,0x097adc4,
  37360. 0x022a0f5,0x1edde93,0x027e83d,0x1d6a95f,0x01ae8d2,0x06e6285,
  37361. 0x1df41d6,0x13f02dd,0x00b7979 } },
  37362. /* 191 */
  37363. { { 0x04f98cc,0x0323108,0x1aba7b1,0x04e55db,0x0511592,0x110c37a,
  37364. 0x0f741f9,0x16cf5d2,0x08d6d69,0x0be7013,0x0ea3cf4,0x0c11fa8,
  37365. 0x17b5347,0x1e055bc,0x1fc704d,0x1323bd0,0x1a8139f,0x11dfacb,
  37366. 0x151f835,0x0750b7c,0x008de29 },
  37367. { 0x0f668b1,0x156e9c7,0x1d90260,0x1ac2392,0x054e6b2,0x0ea131e,
  37368. 0x1ac4870,0x0e679ce,0x0eff64e,0x09a5947,0x0584a8c,0x135850e,
  37369. 0x14af71a,0x1d049ac,0x1222bca,0x011d063,0x112ba91,0x105b248,
  37370. 0x13d0df6,0x178b8ab,0x01138fe } },
  37371. /* 192 */
  37372. { { 0x0a2daa2,0x052c4e2,0x0231fa7,0x18801ec,0x18ea703,0x0ba8818,
  37373. 0x1416354,0x052df19,0x04abb6f,0x1249a39,0x05aad09,0x07c3285,
  37374. 0x1d0be55,0x1628b2b,0x1e4e63e,0x01d5135,0x0ec4f88,0x0f1196f,
  37375. 0x1ec786c,0x02ec3cc,0x01372f8 },
  37376. { 0x020f662,0x0a5e39d,0x1409440,0x1893db2,0x1fb7e77,0x15cb290,
  37377. 0x025bed8,0x0fd13ea,0x1a2e8d3,0x132ce33,0x105c38e,0x144cb00,
  37378. 0x140f2b2,0x0f6a851,0x1d3f39a,0x1801e2c,0x17efdc3,0x1d55229,
  37379. 0x13a6764,0x077fb49,0x0198f3c } },
  37380. /* 193 */
  37381. { { 0x1614189,0x0fae6c0,0x07deeac,0x0a4964b,0x07d56c4,0x1da0af6,
  37382. 0x092c917,0x1f38f75,0x07af6be,0x015e46e,0x123a08c,0x01c0e96,
  37383. 0x1f91b77,0x0db68d8,0x04cdb82,0x0192e94,0x157e668,0x0942e09,
  37384. 0x1f32d89,0x1970278,0x012d59b },
  37385. { 0x0019927,0x0c1da3e,0x156f76b,0x0ec61bf,0x010f266,0x102e91f,
  37386. 0x1b168c7,0x0c02bb7,0x0456ac4,0x15372fd,0x12b208a,0x0a52487,
  37387. 0x0946956,0x06e464f,0x07271fd,0x080cb8d,0x009e24a,0x1d6d93f,
  37388. 0x1904c06,0x0f469d5,0x01ccdfa } },
  37389. /* 194 */
  37390. { { 0x1cb1a7d,0x14326ac,0x03b85da,0x06d5df7,0x0d864ca,0x11586c2,
  37391. 0x0eb2c70,0x03a1dd0,0x1d980df,0x1405375,0x133b65f,0x1988ff2,
  37392. 0x15f582a,0x1d39608,0x073448c,0x0f76f45,0x0a8c710,0x0670951,
  37393. 0x1b6028c,0x1394ac9,0x0150022 },
  37394. { 0x11c180b,0x05d6a97,0x08425dd,0x11ae935,0x108be99,0x0de8dd6,
  37395. 0x122ad5b,0x1352f18,0x00afbea,0x169f1f2,0x1717f1b,0x12f62a7,
  37396. 0x108a8be,0x0df49f6,0x11fc256,0x0477b5b,0x1082cee,0x1469214,
  37397. 0x109ca77,0x0a478db,0x0016417 } },
  37398. /* 195 */
  37399. { { 0x014a31e,0x16678b6,0x10b5d3b,0x0965bc7,0x088e253,0x1621e1a,
  37400. 0x0d665f3,0x06df376,0x1916ac9,0x10822ce,0x1910010,0x18053ef,
  37401. 0x0371d15,0x022a9ac,0x071f049,0x148cf19,0x08dec94,0x0e64baa,
  37402. 0x059eeb6,0x0cf0306,0x014e4ca },
  37403. { 0x10312bf,0x1782ac6,0x19980ce,0x0aa82c3,0x1d1bf4f,0x00bc0ed,
  37404. 0x1169fe9,0x1aa4b32,0x000eef1,0x1a4a6d4,0x0ee340c,0x1d80f38,
  37405. 0x096c505,0x0e4fb73,0x0b86b78,0x01554e1,0x0c17683,0x0014478,
  37406. 0x18a8183,0x19fc774,0x000c7f4 } },
  37407. /* 196 */
  37408. { { 0x17d6006,0x1a23e82,0x02c0362,0x0dfae39,0x18b976e,0x07a07a9,
  37409. 0x180a6af,0x106bcef,0x0f103a7,0x1df71c3,0x1cb12c4,0x1840bc8,
  37410. 0x1420a6a,0x18fe58c,0x0c117d8,0x17e9287,0x19fc00a,0x0f2ee0e,
  37411. 0x1555ade,0x0178e14,0x01b528c },
  37412. { 0x08640b8,0x083f745,0x004aea7,0x07a1c68,0x0561102,0x1257449,
  37413. 0x1956ef8,0x19b8f9c,0x0fa579d,0x1ac7292,0x0eff978,0x0e2a6ef,
  37414. 0x0457ce2,0x1e04a3f,0x19471b0,0x0f04cc8,0x150f4a9,0x12fdec6,
  37415. 0x0b87056,0x1ba51fc,0x008d6fc } },
  37416. /* 197 */
  37417. { { 0x07202c8,0x0517b2e,0x0362d59,0x04b4a96,0x1d63405,0x1a7dfab,
  37418. 0x159c850,0x1470829,0x01d9830,0x08a10af,0x03ef860,0x11aabde,
  37419. 0x1fc7a75,0x137abfc,0x01773e3,0x0d3a6ae,0x056d922,0x1aeea4d,
  37420. 0x16d27e5,0x02baf57,0x00f18f0 },
  37421. { 0x0799ce6,0x188885a,0x1f6c1c4,0x1259796,0x15bbfb9,0x1d10f11,
  37422. 0x0327fde,0x1fd83e0,0x1b18f49,0x04eb489,0x1e566c0,0x12a3579,
  37423. 0x0e8da61,0x06a10a3,0x1a1c84c,0x047e21c,0x017ae5f,0x1aac194,
  37424. 0x0b9ce1a,0x0b76d13,0x0143c9b } },
  37425. /* 198 */
  37426. { { 0x0c74424,0x1946da4,0x0bad08c,0x03a3396,0x12616e1,0x0b710b9,
  37427. 0x064a903,0x0a5ca68,0x00cbdc7,0x0c1d4a6,0x0eec077,0x00a1ae6,
  37428. 0x005c623,0x0dbd229,0x0358c69,0x023919a,0x0259a40,0x0e66e05,
  37429. 0x11b9f35,0x022598c,0x01e622f },
  37430. { 0x01e4c4b,0x1714d1f,0x12291f5,0x113f62a,0x15f8253,0x09f18ce,
  37431. 0x016d53f,0x0ccfc6e,0x00a08b9,0x02672cd,0x0fa36e3,0x13cfb19,
  37432. 0x15bca74,0x17761eb,0x1125baa,0x0627b98,0x03a8a1a,0x00bee39,
  37433. 0x13ae4d8,0x1feef51,0x01a5250 } },
  37434. /* 199 */
  37435. { { 0x029bd79,0x103937f,0x0cd2956,0x009f321,0x0574a81,0x0ab4c1b,
  37436. 0x051b6ab,0x1ded20d,0x150d41f,0x12c055c,0x1dfd143,0x0a28dcd,
  37437. 0x0abc75b,0x1879b8c,0x03325ef,0x0810ea1,0x0a4a563,0x028dd16,
  37438. 0x1936244,0x0720efc,0x017275c },
  37439. { 0x17ca6bd,0x06657fb,0x17d7cdf,0x037b631,0x00a0df4,0x0f00fbf,
  37440. 0x13fe006,0x0573e8d,0x0aa65d7,0x1279ea2,0x198fa6f,0x1158dc6,
  37441. 0x0d7822d,0x1f7cedb,0x0dfe488,0x15354be,0x19dabe4,0x13f8569,
  37442. 0x1a7322e,0x0af8e1e,0x0098a0a } },
  37443. /* 200 */
  37444. { { 0x0fd5286,0x0867a00,0x00f3671,0x0ae5496,0x1ea5b9d,0x0d739f0,
  37445. 0x03e7814,0x049ebcc,0x0951b38,0x14da8a1,0x13599ff,0x05a13f6,
  37446. 0x16b034b,0x16e2842,0x14dea03,0x0045c96,0x0128cb0,0x134f708,
  37447. 0x09522bb,0x173cb8d,0x00ed7c8 },
  37448. { 0x133619b,0x003de6c,0x1865d18,0x1c573bf,0x0ce7668,0x1715170,
  37449. 0x1574f31,0x05f53dd,0x17eebf3,0x0d0a7af,0x113d90d,0x131acf9,
  37450. 0x0c75cb8,0x1c2860b,0x08617f1,0x1392d96,0x07645f7,0x004c3a5,
  37451. 0x1f6d1d1,0x11f15c4,0x0139746 } },
  37452. /* 201 */
  37453. { { 0x08684f6,0x13456e4,0x16ff177,0x16c334f,0x1c1edaa,0x1d0c7ab,
  37454. 0x05cd6c9,0x1d64b1a,0x18ecd89,0x13f3db2,0x07dfaac,0x138db0f,
  37455. 0x1b3d888,0x13eadf7,0x1f725b5,0x1ae7951,0x0ae37ba,0x1e426c3,
  37456. 0x1a395b5,0x1232ed9,0x01a4c7e },
  37457. { 0x119ffa6,0x0d2a031,0x0131400,0x18269d8,0x0cae64e,0x0092160,
  37458. 0x0a5b355,0x1dc3ed3,0x0bf2cae,0x0d12cf7,0x1ba0167,0x0f18517,
  37459. 0x0488e79,0x1c74487,0x1212fae,0x0ffb3d2,0x0d0fb22,0x0072923,
  37460. 0x09758c6,0x054a94c,0x01b78be } },
  37461. /* 202 */
  37462. { { 0x072f13a,0x1aaa57a,0x0472888,0x0eae67d,0x1ac993b,0x00b4517,
  37463. 0x1a7c25b,0x06a4d5f,0x14b1275,0x07f3b0e,0x01c329f,0x10e7cee,
  37464. 0x1684301,0x03f3e6f,0x0daaab7,0x05da8cd,0x1eaa156,0x06d16ea,
  37465. 0x07ebe36,0x145c007,0x0016a81 },
  37466. { 0x03de3bf,0x03ace27,0x022aa20,0x02a5e61,0x0c1e2e1,0x1f5d2d8,
  37467. 0x1b66aa9,0x195965b,0x19f9c11,0x032eaa9,0x1170653,0x1b0f61b,
  37468. 0x010ab9b,0x051fa5b,0x0be325b,0x0bf3fa6,0x1cc28cb,0x1a4c217,
  37469. 0x0438877,0x1c4f997,0x00f431a } },
  37470. /* 203 */
  37471. { { 0x00ccd0a,0x10506b5,0x1554eca,0x04b3276,0x03eeec8,0x1339535,
  37472. 0x01bf677,0x19f6269,0x00da05d,0x0ce28a4,0x061d363,0x089ace7,
  37473. 0x09c4aa4,0x114d1ae,0x13cd6cb,0x0fd5bb3,0x15f8917,0x0eb5ecd,
  37474. 0x0811c28,0x01eb3a5,0x01d69af },
  37475. { 0x07535fd,0x02263dd,0x1ce6cbe,0x1b5085f,0x05bd4c3,0x08cba5a,
  37476. 0x127b7a5,0x1d8bfc2,0x1fd4453,0x0c174cb,0x0df039a,0x00bbcd8,
  37477. 0x0aa63f7,0x0961f7b,0x0c3daa7,0x151ac13,0x1861776,0x05f6e9a,
  37478. 0x17846de,0x1148d5d,0x0176404 } },
  37479. /* 204 */
  37480. { { 0x1a251d1,0x03772a8,0x17f691f,0x041a4f3,0x1ef4bf1,0x08c5145,
  37481. 0x14e33b1,0x0dc985a,0x13880be,0x195bc43,0x06c82c6,0x1f1c37d,
  37482. 0x1ec69cc,0x1bcb50c,0x077fab8,0x17bd5c8,0x1c9fb50,0x012b3b7,
  37483. 0x0f86030,0x02b40a0,0x016a8b8 },
  37484. { 0x1f5ef65,0x042fb29,0x0414b28,0x12ef64a,0x01dfbbf,0x1a37f33,
  37485. 0x01f8e8c,0x1df11d5,0x01b95f7,0x0eefef7,0x17abb09,0x1cd2b6c,
  37486. 0x1b22074,0x0617011,0x01a6855,0x0776a23,0x17742e8,0x0c300da,
  37487. 0x0a1df9f,0x08ca59f,0x0015146 } },
  37488. /* 205 */
  37489. { { 0x1fa58f1,0x029e42b,0x19c0942,0x1099498,0x158a4e6,0x00fa06d,
  37490. 0x1b4286e,0x17a0f72,0x0558e8c,0x0328f08,0x0e233e9,0x08dc85c,
  37491. 0x081a640,0x0221b04,0x0c354e5,0x11fa0a3,0x1b3e26b,0x1615f9a,
  37492. 0x1c0b3f3,0x0f0e12a,0x00fd4ae },
  37493. { 0x153d498,0x0de14ef,0x1890f1e,0x1c226fe,0x0cf31c4,0x11e76fa,
  37494. 0x015b05e,0x0bb276d,0x06cd911,0x030898e,0x03376c9,0x08a7245,
  37495. 0x11ab30a,0x069015f,0x1dd5eda,0x10c25d2,0x07ce610,0x053336f,
  37496. 0x1d809ad,0x01fcca9,0x0051c20 } },
  37497. /* 206 */
  37498. { { 0x1a2b4b5,0x1081e58,0x05a3aa5,0x1d08781,0x18dccbf,0x17fdadc,
  37499. 0x01cb661,0x184d46e,0x0169d3a,0x1d03d79,0x0dc7c4b,0x1734ee2,
  37500. 0x0f8bb85,0x13e14cf,0x18434d3,0x05df9d5,0x069e237,0x09ea5ee,
  37501. 0x17615bc,0x1beebb1,0x0039378 },
  37502. { 0x07ff5d9,0x0817fef,0x0728c7a,0x0464b41,0x0e9a85d,0x0c97e68,
  37503. 0x04e9bd0,0x167ae37,0x115b076,0x0952b9b,0x047473d,0x150cdce,
  37504. 0x19d726a,0x1614940,0x186c77c,0x0bbcc16,0x15cc801,0x191272b,
  37505. 0x02de791,0x1127c23,0x01dc68e } },
  37506. /* 207 */
  37507. { { 0x1feda73,0x127fcb7,0x0062de4,0x0d41b44,0x0709f40,0x0ac26ff,
  37508. 0x083abe2,0x0806d1c,0x08355a0,0x04a8897,0x1df5f00,0x0a51fae,
  37509. 0x08259d4,0x15fc796,0x1125594,0x0623761,0x12844c5,0x0bfb18c,
  37510. 0x119b675,0x1a1c9f0,0x00d5698 },
  37511. { 0x15d204d,0x0b27d00,0x114f843,0x14dba21,0x1b626bf,0x14c64a3,
  37512. 0x0398e9d,0x0ac10ff,0x105337a,0x12d32a3,0x11e0bd4,0x0489beb,
  37513. 0x1f558e2,0x02afdd7,0x0a87906,0x0706091,0x18e47ee,0x1a47910,
  37514. 0x0e118f4,0x0472b22,0x004df25 } },
  37515. /* 208 */
  37516. { { 0x0695310,0x07eb4ec,0x03a9dbd,0x1efd0ed,0x028eb09,0x0a99547,
  37517. 0x0604b83,0x0f20738,0x0c572ac,0x0d33ba2,0x158a4f7,0x01c0f0b,
  37518. 0x121f980,0x1ed3b5d,0x1f8a968,0x0e42e57,0x190a2bc,0x13768ad,
  37519. 0x05e22a3,0x1cc37fa,0x004cd80 },
  37520. { 0x0730056,0x001b80b,0x150ee7d,0x1fb9da7,0x06f45fe,0x1283a12,
  37521. 0x1d8f06a,0x0e615fa,0x0ff92ae,0x0f2e329,0x0818fc8,0x061a376,
  37522. 0x006ef08,0x096912a,0x0c1bb30,0x0003830,0x13a1f15,0x0276ecd,
  37523. 0x0331509,0x164b718,0x01f4e4e } },
  37524. /* 209 */
  37525. { { 0x1db5c18,0x0d38a50,0x1d33b58,0x1cecee0,0x1454e61,0x1b42ef4,
  37526. 0x1ef95ef,0x1cbd2e1,0x1d2145b,0x10d8629,0x0697c88,0x1037dc9,
  37527. 0x03b9318,0x0a588e8,0x0e46be8,0x0426e01,0x0493ec2,0x1e3577f,
  37528. 0x098802b,0x0a9d28a,0x013c505 },
  37529. { 0x164c92e,0x022f3b9,0x03a350b,0x0ae6a43,0x0050026,0x09f9e2f,
  37530. 0x1680a13,0x0d7a503,0x0dbf764,0x097c212,0x1cc13cc,0x1e5490b,
  37531. 0x13e1a88,0x0893d28,0x0fd58c4,0x1c178b0,0x0c71a60,0x076bca8,
  37532. 0x0dedc29,0x0abc209,0x00c6928 } },
  37533. /* 210 */
  37534. { { 0x04614e7,0x10c2e32,0x1092341,0x1c8e934,0x0e906ca,0x03f2941,
  37535. 0x04ba896,0x19ab0a8,0x0d12857,0x1b1cc85,0x164ed4d,0x1ee174a,
  37536. 0x06770c7,0x0eae952,0x13db713,0x1437585,0x0563b69,0x12b26d2,
  37537. 0x01e2576,0x1efc283,0x01c8639 },
  37538. { 0x0589620,0x0b5817c,0x0150172,0x0683c88,0x0fe468a,0x15684e1,
  37539. 0x1684425,0x1dd7e45,0x09c652a,0x039e14c,0x186e3ef,0x1f16a8f,
  37540. 0x13cdef9,0x0bbedfb,0x1cde16a,0x0aa5ae0,0x1aa7e13,0x1854950,
  37541. 0x08e4f4f,0x0c22807,0x015b227 } },
  37542. /* 211 */
  37543. { { 0x1bfaf32,0x0d3d80f,0x1486269,0x017ccc3,0x1c5a62d,0x11da26a,
  37544. 0x03d7bd7,0x0c48f2e,0x1f43bbf,0x15000f6,0x0b9680f,0x050a4c1,
  37545. 0x0ca8e74,0x134be31,0x0267af4,0x0ec87d7,0x1e6751a,0x11b5001,
  37546. 0x081c969,0x0f18a37,0x00eaef1 },
  37547. { 0x1d51f28,0x1c74fcd,0x0112ab3,0x1750e24,0x19febbd,0x1e41b29,
  37548. 0x0b4e96f,0x11f0f01,0x110e6f0,0x0451a66,0x06ac390,0x1421048,
  37549. 0x018104c,0x0c53315,0x0f9c73a,0x091ad08,0x1142320,0x1cee742,
  37550. 0x13cf461,0x14477c3,0x01fa5cb } },
  37551. /* 212 */
  37552. { { 0x173a15c,0x064e914,0x07ccbfa,0x1ba852f,0x06fec8d,0x157d9f3,
  37553. 0x128e42d,0x044735e,0x0ab65ef,0x1d8f21b,0x17f36c2,0x003ccd8,
  37554. 0x0b8f262,0x0d7a438,0x1ffa28d,0x09c4879,0x06f2bb4,0x132d714,
  37555. 0x07745c8,0x1c5074a,0x0114da2 },
  37556. { 0x1e3d708,0x04d2b60,0x1e992a7,0x1e3961d,0x0fe62d3,0x143aa02,
  37557. 0x0a6125f,0x1f5e0e0,0x13cea46,0x1c5beb5,0x01898c4,0x069d071,
  37558. 0x0907806,0x18e1848,0x1a10a01,0x10c8e4f,0x1d7e583,0x1f857bc,
  37559. 0x08da899,0x10cb056,0x0104c1b } },
  37560. /* 213 */
  37561. { { 0x126c894,0x184f6d2,0x148ccbf,0x002958f,0x15abf12,0x0c949a4,
  37562. 0x13734f3,0x0ad6df2,0x092e6b5,0x1d57589,0x1b0c6ff,0x0dd4206,
  37563. 0x0e19379,0x183ff99,0x148df9d,0x0cf7153,0x10d829d,0x1eb2d2d,
  37564. 0x0ca4922,0x1b6aadb,0x01b348e },
  37565. { 0x0d46575,0x0fcd96f,0x0b3dbba,0x15ff4d3,0x096ca08,0x169be8a,
  37566. 0x0ce87c5,0x003ab5d,0x1789e5d,0x1283ed8,0x1f31152,0x1c53904,
  37567. 0x1705e2c,0x14b2733,0x0db9294,0x08de453,0x0ba4c0e,0x082b1d8,
  37568. 0x0f11921,0x1848909,0x00a3e75 } },
  37569. /* 214 */
  37570. { { 0x0f6615d,0x1a3b7e9,0x06a43f2,0x11b31b5,0x0b7f9b7,0x1ef883a,
  37571. 0x17c734a,0x063c5fb,0x09b956f,0x1ed1843,0x1bab7ca,0x05ef6b2,
  37572. 0x18f3cca,0x1aad929,0x1027e2c,0x08db723,0x0f3c6c8,0x12379fb,
  37573. 0x085190b,0x12731c5,0x01ff9bb },
  37574. { 0x17bd645,0x06a7ad0,0x1549446,0x17b7ada,0x17033ea,0x0684aba,
  37575. 0x01bf1cd,0x06a00fd,0x15f53c4,0x065032f,0x1f74666,0x137ffa4,
  37576. 0x0a9949d,0x14a968e,0x1138c11,0x02039bb,0x0fb81ac,0x1c2655a,
  37577. 0x095ac01,0x00f3f29,0x000346d } },
  37578. /* 215 */
  37579. { { 0x0bfdedd,0x1c727d3,0x1be657a,0x1cf4e98,0x193a285,0x04d1294,
  37580. 0x15344f4,0x0cf17ab,0x019a5f7,0x15085f3,0x0ecd03a,0x107c19d,
  37581. 0x03d3db0,0x0edfbd4,0x0ce9e2c,0x047c38c,0x03ec30f,0x093325e,
  37582. 0x1e820de,0x01f1e20,0x01c9663 },
  37583. { 0x0f86a80,0x065a5ef,0x06aeefd,0x107f04b,0x1fa4ec7,0x0a99640,
  37584. 0x1d81182,0x125497e,0x08b909e,0x0ddbd66,0x010581c,0x062e2f1,
  37585. 0x08ca1d7,0x050d5c9,0x1fc52fb,0x0ab4afe,0x16e5f84,0x0dff500,
  37586. 0x1c87a26,0x18ed737,0x002d7b8 } },
  37587. /* 216 */
  37588. { { 0x19f8e7d,0x102b1a5,0x02a11a1,0x0ec7f8b,0x001176b,0x176b451,
  37589. 0x169f8bf,0x121cf4b,0x0651831,0x033bb1f,0x1deb5b3,0x0205d26,
  37590. 0x017d7d0,0x1b81919,0x1f11c81,0x16a0b99,0x031534b,0x0ab9f70,
  37591. 0x1c689da,0x03df181,0x00f31bf },
  37592. { 0x0935667,0x1ae2586,0x0e2d8d7,0x120c1a5,0x14152c3,0x01d2ba3,
  37593. 0x0b0b8df,0x19bdff5,0x00b72e0,0x0afe626,0x18091ff,0x1373e9e,
  37594. 0x13b743f,0x1cf0b79,0x10b8d51,0x1df380b,0x0473074,0x1d111a6,
  37595. 0x056ab38,0x05e4f29,0x0124409 } },
  37596. /* 217 */
  37597. { { 0x10f9170,0x0bc28d9,0x16c56ff,0x126ff9c,0x115aa1e,0x021bdcb,
  37598. 0x157824a,0x0e79ffa,0x1c32f12,0x056692c,0x1878d22,0x19e4917,
  37599. 0x0b5a145,0x1d2de31,0x0d02181,0x0de8c74,0x1151815,0x1b14b75,
  37600. 0x1dd3870,0x1f5a324,0x01e7397 },
  37601. { 0x08225b5,0x1ccfa4e,0x1134d8b,0x128d6ef,0x13efce4,0x00f48d9,
  37602. 0x1d4c215,0x1268a3b,0x038f3d6,0x1e96c9a,0x1ed5382,0x05adce4,
  37603. 0x000b5de,0x1b116ca,0x164a709,0x1529685,0x12356f6,0x09b5673,
  37604. 0x132bc81,0x0319abf,0x004464a } },
  37605. /* 218 */
  37606. { { 0x1a95d63,0x10555d5,0x11b636f,0x02f6966,0x12780c6,0x06c0a14,
  37607. 0x1e18c38,0x098c861,0x0b56ef0,0x1adf015,0x18d8ce1,0x172af0b,
  37608. 0x04c28fe,0x009649f,0x1005e57,0x10547aa,0x1c1e36f,0x144ffa8,
  37609. 0x03babf5,0x11912a2,0x016b3c4 },
  37610. { 0x0f064be,0x03f5d6a,0x0a65e4a,0x0aa9d7b,0x1a77d55,0x1b93f50,
  37611. 0x17bc988,0x18c8ce8,0x189f366,0x088fac8,0x15baf6a,0x0b9b8b3,
  37612. 0x137e543,0x1a92690,0x0136ba9,0x1671a75,0x11c4395,0x0e3d8ee,
  37613. 0x0a08f12,0x07ce083,0x001cca1 } },
  37614. /* 219 */
  37615. { { 0x14d64b0,0x0c30643,0x18318e6,0x042ca79,0x1375b09,0x108cc31,
  37616. 0x00003aa,0x0ba2ce0,0x1621cd1,0x1633c84,0x1c37358,0x1bacefa,
  37617. 0x0dbe1d7,0x182dea6,0x1c3c9c0,0x11e61df,0x021362f,0x003b763,
  37618. 0x19116de,0x00902cf,0x01d8812 },
  37619. { 0x01f9758,0x04d070b,0x138a05d,0x1d4789f,0x060915f,0x0eec57f,
  37620. 0x1390644,0x013ea6f,0x079a51a,0x11b5456,0x173e3bf,0x0968594,
  37621. 0x1567fb5,0x12482bf,0x172b81f,0x096c837,0x0c5a424,0x1db8ff8,
  37622. 0x0d81960,0x0b4a6c9,0x0106481 } },
  37623. /* 220 */
  37624. { { 0x139cc39,0x14e1f77,0x1b45e31,0x09f4c6a,0x1830456,0x17dcc84,
  37625. 0x0d50904,0x14b7a78,0x179dbb2,0x0ea98e9,0x1d78f68,0x0311cfc,
  37626. 0x114865f,0x0580a3d,0x0b13888,0x135605b,0x1ca33d2,0x1facf28,
  37627. 0x1ec1d3b,0x09effc6,0x00f1c96 },
  37628. { 0x0301262,0x0605307,0x08b5c20,0x00a7214,0x1a45806,0x054814c,
  37629. 0x1fe6b32,0x185b4ce,0x114c0f1,0x1d7482b,0x1b67df7,0x1e2cdcc,
  37630. 0x043665f,0x03c2349,0x19b7631,0x060f990,0x18fc4cc,0x062d7f4,
  37631. 0x02fd439,0x0774c7c,0x003960e } },
  37632. /* 221 */
  37633. { { 0x19ecdb3,0x0289b4a,0x06f869e,0x0ff3d2b,0x089af61,0x106e441,
  37634. 0x0cae337,0x02aa28b,0x07c079e,0x1483858,0x089057f,0x09a6a1c,
  37635. 0x02f77f0,0x1ac6b6a,0x0adcdc8,0x0c53567,0x1b9ba7b,0x08a7ea0,
  37636. 0x1003f49,0x05b01ce,0x01937b3 },
  37637. { 0x147886f,0x006a6b8,0x072b976,0x02aed90,0x008ced6,0x138bddf,
  37638. 0x01a4990,0x043c29d,0x0abb4bd,0x0e6f8cc,0x00c22e7,0x0c8cca6,
  37639. 0x07658be,0x0cce8ce,0x1c64b6b,0x1624df7,0x1b3304a,0x0aad1e8,
  37640. 0x089378c,0x1e97cbf,0x000e943 } },
  37641. /* 222 */
  37642. { { 0x1e9ea48,0x1202c3f,0x121b150,0x0ac36ae,0x0f24f82,0x18cba05,
  37643. 0x104f1e1,0x09b3a58,0x170eb87,0x1d4df3c,0x0e8ea89,0x11c16c5,
  37644. 0x0c43fef,0x160df85,0x08fca18,0x061c214,0x0f34af1,0x1a8e13b,
  37645. 0x19573af,0x1a3d355,0x0185f6c },
  37646. { 0x0369093,0x17d3fa0,0x1828937,0x0cb0b03,0x11f1d9d,0x0976cf0,
  37647. 0x0fccf94,0x12d3201,0x1ed1208,0x1c5422c,0x0f0e66f,0x0abd16e,
  37648. 0x1e83245,0x07b7aa7,0x08c15a6,0x046aaa9,0x1a53c25,0x0954eb6,
  37649. 0x0824ecc,0x0df2085,0x016ae6a } },
  37650. /* 223 */
  37651. { { 0x12cdd35,0x091e48a,0x1bc6cb8,0x110c805,0x0e6e43a,0x072dead,
  37652. 0x1c37ee7,0x0291257,0x0758049,0x0565c25,0x0bbb0ad,0x0bffea0,
  37653. 0x0e8c7f5,0x1519f7a,0x029ee4e,0x0400339,0x157fd9d,0x1835881,
  37654. 0x0e8ef3a,0x033fe01,0x00273e3 },
  37655. { 0x1e360a3,0x017bbd5,0x129860b,0x095bfdf,0x17ef5c8,0x05b7e62,
  37656. 0x0329994,0x005349e,0x0aaf0b2,0x1a7c72b,0x1bc558f,0x1141449,
  37657. 0x135c850,0x0f522f8,0x1d8bf64,0x0db7db1,0x1a02803,0x1f96491,
  37658. 0x093440e,0x1949803,0x018a4a9 } },
  37659. /* 224 */
  37660. { { 0x048e339,0x1dbcc2a,0x05d8a8f,0x1e31473,0x1e8770c,0x148b866,
  37661. 0x15d35e9,0x15822c0,0x12b6067,0x1d82e2c,0x04e2ad2,0x1b61090,
  37662. 0x14de0d2,0x0484f3c,0x076ae49,0x02bee29,0x0b67903,0x041d19b,
  37663. 0x0cd6896,0x00e9b34,0x013ccd9 },
  37664. { 0x01b784d,0x0e2f056,0x0b87a0e,0x0ddca4f,0x0b65c8c,0x0447605,
  37665. 0x1851a87,0x0b1a790,0x046c1bf,0x100fbc8,0x0940a88,0x0c4e7fb,
  37666. 0x0571cec,0x112dc83,0x0fe23ac,0x1bf9bfe,0x098c556,0x0360f86,
  37667. 0x013e973,0x0445549,0x00acaa3 } },
  37668. /* 225 */
  37669. { { 0x1b4dfd6,0x1a5e1e4,0x0a4c5f9,0x07f1cec,0x05ba805,0x061a901,
  37670. 0x1701676,0x168060f,0x0b85a20,0x0481b66,0x1c4d647,0x1e14470,
  37671. 0x0ef2c63,0x054afda,0x0676763,0x18d8c35,0x1399850,0x01ebe27,
  37672. 0x00a659a,0x12d392d,0x0169162 },
  37673. { 0x163ee53,0x1e133e5,0x0d4df44,0x02ebd58,0x07b12e6,0x0d5fe53,
  37674. 0x0684464,0x13f666d,0x1ee1af6,0x168324e,0x10479d6,0x1e0023b,
  37675. 0x054d7a6,0x0dcfcbb,0x1c0c2e3,0x0266501,0x1a3f0ab,0x1510000,
  37676. 0x0763318,0x1931a47,0x0194e17 } },
  37677. /* 226 */
  37678. { { 0x18fe898,0x0c05a0e,0x14d1c83,0x0e64308,0x0d7a28b,0x190ba04,
  37679. 0x10e1413,0x15fe3e7,0x1166aa6,0x09c0e6a,0x1838d57,0x010998a,
  37680. 0x0d9cde6,0x0f30f16,0x0107c29,0x12a3596,0x0f5d9b4,0x031088b,
  37681. 0x1b8ab0b,0x1c2da6f,0x00c4509 },
  37682. { 0x06fd79e,0x1106216,0x0c3ae0a,0x1c75ef1,0x15b7ee4,0x0c0ce54,
  37683. 0x18f06eb,0x0d27b36,0x0985525,0x06b3a6f,0x06743c4,0x0965f38,
  37684. 0x0917de6,0x03e2f35,0x0feaebd,0x1b6df40,0x0ad2ce2,0x142c5e2,
  37685. 0x1f27463,0x0470143,0x00c976c } },
  37686. /* 227 */
  37687. { { 0x064f114,0x18f7c58,0x1d32445,0x0a9e5e1,0x03cb156,0x19315bc,
  37688. 0x161515e,0x0d860a4,0x10f3493,0x1463380,0x107fb51,0x05fd334,
  37689. 0x09ef26d,0x13fbfb5,0x168899e,0x1f837ed,0x0dba01b,0x012b1dc,
  37690. 0x0d03b50,0x06d90b8,0x000e14b },
  37691. { 0x1db67e6,0x1f13212,0x017d795,0x12fe5d2,0x05df4e8,0x1621344,
  37692. 0x1945009,0x126f065,0x03e8750,0x095f131,0x0e1a44c,0x17b078a,
  37693. 0x1d856b5,0x0ab9a7c,0x072b956,0x090c2b6,0x1e2d5aa,0x02d03df,
  37694. 0x1a2aed6,0x192de19,0x01d07a4 } },
  37695. /* 228 */
  37696. { { 0x03aa2e9,0x0a682a9,0x0181efd,0x19da7a1,0x08841e0,0x0dfdb4e,
  37697. 0x1db89fe,0x10aad07,0x0162bdf,0x0583fa2,0x0373277,0x10720f6,
  37698. 0x0e62d17,0x12bd29b,0x12ee2ad,0x0fa7945,0x0d27cf4,0x04c5cd0,
  37699. 0x1ba98dc,0x0a9ad0b,0x01f2ff1 },
  37700. { 0x0b232ac,0x1bb452b,0x0aad5a2,0x0c7e54a,0x0e8d6e3,0x1bfe302,
  37701. 0x1e85a20,0x12375d0,0x1d10a76,0x1e2c541,0x157efba,0x15e1f28,
  37702. 0x0ead5e4,0x1eb2a71,0x0835b0d,0x104aa34,0x0b9da7c,0x0c6207e,
  37703. 0x0366e4c,0x1679aec,0x00b26d7 } },
  37704. /* 229 */
  37705. { { 0x12eaf45,0x0861f5d,0x04bdec2,0x18c5ff7,0x0d24d91,0x1b791ef,
  37706. 0x0fa929c,0x1c77e54,0x16ff0fd,0x0dccf5e,0x040bd6d,0x0abb942,
  37707. 0x08bca2b,0x03f0195,0x080f360,0x02f51ec,0x048a8bf,0x0aa085a,
  37708. 0x077156c,0x0cc14fc,0x0109b86 },
  37709. { 0x0a2fbd8,0x058ed01,0x0296c52,0x167645d,0x1ed85e8,0x095a84f,
  37710. 0x083921c,0x02c26f1,0x0c6a3e5,0x02b00a4,0x0ed40da,0x04382c6,
  37711. 0x1171009,0x12a8938,0x049450c,0x0208f27,0x1d207d3,0x1bda498,
  37712. 0x150b82e,0x1ce4570,0x00ea623 } },
  37713. /* 230 */
  37714. { { 0x0972688,0x011e992,0x1d88212,0x04007ea,0x18b83c1,0x06a2942,
  37715. 0x19a41b4,0x0fc329a,0x02c6f74,0x010cac2,0x1b626a1,0x05d2028,
  37716. 0x02c8f8a,0x1a28dde,0x1b0779d,0x109f453,0x0b8f7f2,0x1fb115b,
  37717. 0x0dc7913,0x03b7d2f,0x006083f },
  37718. { 0x19dd56b,0x04999cc,0x17a6659,0x152f48f,0x0cfac0b,0x147d901,
  37719. 0x162baef,0x194ccc1,0x0f61d7b,0x1e14eec,0x1705351,0x0a3b0b5,
  37720. 0x1c6f5fb,0x07cfea0,0x16b1e21,0x07cd9cc,0x1d4ff51,0x10e734e,
  37721. 0x1f9674f,0x1cb23df,0x00231ac } },
  37722. /* 231 */
  37723. { { 0x1fda771,0x1d21c54,0x0038b99,0x190cc62,0x026f652,0x19f91db,
  37724. 0x0792384,0x03fbf63,0x0035d2d,0x0cfc479,0x0fa1e16,0x02251a2,
  37725. 0x071723a,0x1da8e70,0x02a8a4b,0x1750512,0x10ebbd9,0x072f9d3,
  37726. 0x1d1452d,0x104ce66,0x0155dde },
  37727. { 0x0f59a95,0x15bbf6b,0x108022c,0x0604040,0x13f853e,0x163bcbc,
  37728. 0x0ab07ae,0x0eca44a,0x1b56b66,0x166e5cc,0x0a9401b,0x13f32e4,
  37729. 0x104abdb,0x02715d6,0x0843cfc,0x1ba9a4c,0x0ff3034,0x08652d0,
  37730. 0x0b02e03,0x1b0101b,0x0041333 } },
  37731. /* 232 */
  37732. { { 0x1a85a06,0x083849a,0x0d13a14,0x0c85de3,0x0e166e7,0x1d9d36a,
  37733. 0x02dc681,0x0d50952,0x030329e,0x16eb600,0x1549675,0x14ca7aa,
  37734. 0x1e20c4b,0x17c5682,0x0ec9abd,0x1999bdc,0x1412ab4,0x01071ea,
  37735. 0x0501909,0x1312695,0x01bd797 },
  37736. { 0x00c7ff0,0x0e8c247,0x0d03ca8,0x192a876,0x1ae85ef,0x0e98c5d,
  37737. 0x0c6bbd4,0x14dd2c8,0x075878f,0x0e9f6a7,0x057d4b9,0x13b7851,
  37738. 0x1c4d2a2,0x0f88833,0x1c9e1dc,0x09dca75,0x1649e7f,0x13666f4,
  37739. 0x15b5d36,0x111b434,0x0192351 } },
  37740. /* 233 */
  37741. { { 0x1d310ed,0x1909001,0x0c46c20,0x1930f60,0x120ee8c,0x02ac546,
  37742. 0x0749a13,0x1913ca9,0x0b7167e,0x112f9e7,0x156ed57,0x09e897e,
  37743. 0x17acf11,0x030e480,0x07b71dc,0x0878103,0x0e6deb3,0x0bacd22,
  37744. 0x1326d7b,0x1f3efc0,0x007858d },
  37745. { 0x1f13222,0x03f5d9d,0x08453e9,0x1bd40fb,0x1e451dc,0x0c12178,
  37746. 0x1eb0f03,0x03c37d3,0x136eb87,0x192bea6,0x0c64364,0x0eb57d4,
  37747. 0x13f49e7,0x075f159,0x1b4647d,0x0012c80,0x13c0c11,0x033d562,
  37748. 0x0e06b1e,0x0b9f17a,0x01f4521 } },
  37749. /* 234 */
  37750. { { 0x0493b79,0x145477d,0x0ab0e1f,0x169d638,0x120e270,0x1911905,
  37751. 0x0fe827f,0x07b3e72,0x0a91c39,0x170dd57,0x0a36597,0x0c34271,
  37752. 0x04deda9,0x0bdea87,0x0ac8e32,0x191c0d3,0x08a2363,0x17fb46a,
  37753. 0x1931305,0x1c01cb9,0x0158af8 },
  37754. { 0x1c509a1,0x0e78367,0x01d5b33,0x1f84d98,0x00f411e,0x0e2bf83,
  37755. 0x17f5936,0x158da19,0x132e99c,0x0a8a429,0x1a5442a,0x167b171,
  37756. 0x1d58f9a,0x1886e1f,0x1a61c26,0x06a134f,0x03d75ef,0x1c1c842,
  37757. 0x0a4c4b1,0x1993a0b,0x01b628c } },
  37758. /* 235 */
  37759. { { 0x141463f,0x1a78071,0x1e80764,0x1c2a1b4,0x14c8a6c,0x04aa9f8,
  37760. 0x183f104,0x123b690,0x0a93f4a,0x11def2d,0x16019f0,0x0f0e59a,
  37761. 0x009f47c,0x0219ee4,0x0cc0152,0x054fa3a,0x1f975a3,0x08605f3,
  37762. 0x031d76a,0x0eefab1,0x012e08b },
  37763. { 0x1a10d37,0x0940bb0,0x16977f0,0x02b8a1e,0x0d7b618,0x03be307,
  37764. 0x0576de5,0x016515f,0x133c531,0x05515bb,0x06099e8,0x1570a62,
  37765. 0x1f905fa,0x15a0cac,0x03a6059,0x0ef09e8,0x05216b3,0x04e65a1,
  37766. 0x0619ab3,0x0baef8d,0x00c5683 } },
  37767. /* 236 */
  37768. { { 0x1450a66,0x18a6595,0x1053a75,0x18fb7fb,0x1318885,0x1350600,
  37769. 0x03616d1,0x14ccab5,0x15bdfc1,0x1510f4c,0x1e4b440,0x1931cce,
  37770. 0x177a0d7,0x1aa853c,0x006ed5e,0x1a66e54,0x0335d74,0x0a16231,
  37771. 0x036b525,0x09c3811,0x008b7be },
  37772. { 0x1812273,0x1d81fca,0x15fc61c,0x05dc7ee,0x0e26ed3,0x1310bd1,
  37773. 0x03ab9b6,0x09e58e2,0x0261d9f,0x1a85aba,0x0768b66,0x1f536f8,
  37774. 0x0743971,0x02542ef,0x113ee1f,0x026f645,0x051ec22,0x17b961a,
  37775. 0x1ee8649,0x0acd18e,0x0173134 } },
  37776. /* 237 */
  37777. { { 0x03ba183,0x1463d45,0x1e9cf8f,0x17fc713,0x0e8cebb,0x0dd307a,
  37778. 0x11a1c3e,0x1071d48,0x1cb601a,0x08bb71a,0x14b6d15,0x184c25c,
  37779. 0x11f90bd,0x07b895f,0x1e79166,0x0a99b2b,0x00fbea0,0x1cde990,
  37780. 0x157f502,0x0337edb,0x017a2cf },
  37781. { 0x0736feb,0x1b65133,0x18bdc73,0x13bcf9f,0x1de86f4,0x1482b1d,
  37782. 0x0f3a3f0,0x09f8c15,0x0726b6e,0x17451e7,0x048d6ea,0x088a7e5,
  37783. 0x1ed2382,0x1287fd2,0x0d55fd5,0x1ee8949,0x054113e,0x150a29f,
  37784. 0x1909b74,0x0ed4a67,0x01b07c6 } },
  37785. /* 238 */
  37786. { { 0x1d96872,0x101f91a,0x032bd79,0x187f4b7,0x0b1a23c,0x046e2fd,
  37787. 0x01c6fa6,0x17aa8b3,0x1d430c0,0x1974244,0x16730f8,0x13c0ec9,
  37788. 0x0d7ec26,0x1960620,0x08e084b,0x10769ee,0x183887b,0x096ca30,
  37789. 0x1c62904,0x1f4ce25,0x0010281 },
  37790. { 0x0858b37,0x00247b2,0x176600a,0x1e6afbc,0x00e149a,0x0f5d8c7,
  37791. 0x01e4586,0x1416443,0x19f2b0b,0x0810059,0x072eb88,0x15cc207,
  37792. 0x1d5a87e,0x1cabce8,0x1f7376c,0x0a2bc9d,0x0aa2788,0x10d9c47,
  37793. 0x0061e2a,0x0a58799,0x002c1a5 } },
  37794. /* 239 */
  37795. { { 0x0a723dc,0x1fa8007,0x08c5eb1,0x088562a,0x0a5f04f,0x042e430,
  37796. 0x05116fa,0x004c7a9,0x1ff1197,0x0fccc9f,0x1633a98,0x08b9898,
  37797. 0x16c3fba,0x1ce6b01,0x145479a,0x04777cd,0x11557b9,0x13ad1d5,
  37798. 0x1acbf51,0x00f8a59,0x01474ec },
  37799. { 0x188239d,0x11e9976,0x1a5311a,0x0d06b5c,0x0d1b8ae,0x1759738,
  37800. 0x18c967f,0x16be9fb,0x043bc0b,0x11dfb8e,0x0a9c148,0x016f1ec,
  37801. 0x053cd22,0x0ff3ccd,0x092183a,0x0ff2644,0x10324ab,0x1ec2ac3,
  37802. 0x1652562,0x1ee6616,0x010f8e0 } },
  37803. /* 240 */
  37804. { { 0x067d520,0x0e3dd9e,0x07b2bcd,0x1647f95,0x18f4958,0x1d54046,
  37805. 0x1c6522e,0x15c0ef1,0x02135e8,0x0c61867,0x03bfdd0,0x1353911,
  37806. 0x0bcdd8d,0x1b98a25,0x01d77c3,0x14a68e4,0x0954506,0x0daa4e4,
  37807. 0x1eedff1,0x0712f2b,0x011c4ef },
  37808. { 0x1f5e698,0x164d621,0x18e8ff8,0x19c714b,0x0e77fcb,0x04e170e,
  37809. 0x12438c2,0x002da0b,0x1ac1d58,0x13a79ff,0x0e74a96,0x0440703,
  37810. 0x0baeeda,0x1af9cb0,0x162c50f,0x1577db2,0x0510db7,0x032ffe8,
  37811. 0x0816dc6,0x0fcd00f,0x00ce8e9 } },
  37812. /* 241 */
  37813. { { 0x0e86a83,0x0f30dc6,0x0580894,0x1f7efce,0x0604159,0x1819bbc,
  37814. 0x1f75d23,0x085f824,0x1450522,0x1e5961b,0x1a826e1,0x01e9269,
  37815. 0x01bd495,0x0233ca2,0x11b100f,0x082d4a2,0x11023ba,0x0f456a3,
  37816. 0x1d8e3ac,0x1034c15,0x01b389b },
  37817. { 0x0150c69,0x0c9a774,0x12f39a6,0x11c4f82,0x14f7590,0x00ca7fb,
  37818. 0x0a245a8,0x0ecbb81,0x01bd51b,0x07a4e99,0x1e58c0e,0x00bc30e,
  37819. 0x086bc33,0x1e9da53,0x0bcfeff,0x1e313fc,0x177d7ca,0x18a04d9,
  37820. 0x0e3c426,0x1d42773,0x01b3029 } },
  37821. /* 242 */
  37822. { { 0x1a2fd88,0x09c6912,0x180fbde,0x199d740,0x090f2f7,0x136ffa4,
  37823. 0x072035e,0x10c987c,0x02883f9,0x063c79b,0x194c140,0x0b25331,
  37824. 0x13ed92b,0x192eee3,0x02a3c6c,0x0e11403,0x187d5d3,0x1b6ffec,
  37825. 0x147ca2e,0x06aa9e1,0x0059dcd },
  37826. { 0x1a74e7d,0x1720e91,0x17d85f1,0x1cbb665,0x14b61eb,0x1ffd05c,
  37827. 0x1fe9e79,0x01a785f,0x12ebb7a,0x19b315b,0x17e70d1,0x0bdc035,
  37828. 0x04a8641,0x0a33c93,0x00b0c99,0x138ae2a,0x1492fa0,0x10b4889,
  37829. 0x11d2421,0x1e69544,0x0195897 } },
  37830. /* 243 */
  37831. { { 0x1adc253,0x0e9acd5,0x0579211,0x198f2f9,0x0054b92,0x10c1097,
  37832. 0x0d6f668,0x04e4553,0x0a52b88,0x1dc052f,0x0719da6,0x0f1c5cc,
  37833. 0x13ea38e,0x04587c5,0x09d2c68,0x10a99f6,0x0e3db9d,0x1db5521,
  37834. 0x1804b5c,0x044a46a,0x01638ba },
  37835. { 0x1c8c576,0x00737ba,0x1749f3b,0x19c978f,0x0bb20e7,0x0c03935,
  37836. 0x08321a7,0x16e12b1,0x08a023e,0x0846335,0x042c56a,0x01d4ec2,
  37837. 0x06ca9f5,0x0c37b0d,0x0326650,0x0d3b0cd,0x0ed2a0a,0x1ceef91,
  37838. 0x0fe2843,0x1c312f7,0x01e0bfe } },
  37839. /* 244 */
  37840. { { 0x0319e4f,0x0340c24,0x1e809b6,0x0ab4b0d,0x0be6f6b,0x189932b,
  37841. 0x1621899,0x1f57deb,0x198529c,0x0129562,0x0a73eeb,0x0be2c56,
  37842. 0x0de7cc4,0x11531ac,0x0141826,0x158e1dc,0x0a42940,0x07be5ce,
  37843. 0x0216c7c,0x0955d95,0x01adfb4 },
  37844. { 0x198678e,0x1d49b73,0x10e19ad,0x0732a80,0x0a01e10,0x14305be,
  37845. 0x078de05,0x0afe492,0x1b745d8,0x17fea41,0x017b5bb,0x0c5148e,
  37846. 0x175dbb3,0x1952e87,0x15a3526,0x1fdc6af,0x09a2389,0x168d429,
  37847. 0x09ff5a1,0x184a923,0x01addbb } },
  37848. /* 245 */
  37849. { { 0x09686a3,0x05d104b,0x0fd7843,0x0bc780a,0x108b1c5,0x1a38811,
  37850. 0x0c4d09b,0x0702e25,0x1490330,0x1c8b2d8,0x0549ec7,0x002e5a0,
  37851. 0x0245b72,0x154d1a7,0x13d991e,0x06b90df,0x194b0be,0x128faa5,
  37852. 0x08578e0,0x16454ab,0x00e3fcc },
  37853. { 0x14dc0be,0x0f2762d,0x1712a9c,0x11b639a,0x1b13624,0x170803d,
  37854. 0x1fd0c11,0x147e6d7,0x1da9c99,0x134036b,0x06f1416,0x0ddd069,
  37855. 0x109cbfc,0x109f042,0x01c79cf,0x091824d,0x02767f4,0x0af3551,
  37856. 0x169eebe,0x0ef0f85,0x01b9ba7 } },
  37857. /* 246 */
  37858. { { 0x1a73375,0x12c7762,0x10e06af,0x1af5158,0x175df69,0x0541ad0,
  37859. 0x0542b3b,0x01e59e6,0x1f507d3,0x03d8304,0x0c1092e,0x14578c1,
  37860. 0x0c9ae53,0x0087c87,0x0c78609,0x1137692,0x10fadd6,0x122963e,
  37861. 0x1d8c6a3,0x0a69228,0x0013ab4 },
  37862. { 0x084f3af,0x0ec2b46,0x0cfabcb,0x043755c,0x029dc09,0x0b58384,
  37863. 0x0aa162e,0x02c8ca8,0x0e8a825,0x11306a0,0x14c8ad0,0x1b58b86,
  37864. 0x12b9e5e,0x1cf6d06,0x09e5580,0x1721579,0x1c6b962,0x1435e83,
  37865. 0x07b14c0,0x05b58f6,0x010a2e2 } },
  37866. /* 247 */
  37867. { { 0x19d8f0a,0x1e04e91,0x0085997,0x1957142,0x12b2e03,0x19a3bdc,
  37868. 0x05da005,0x009c86d,0x18e3616,0x19c76cf,0x0186faa,0x123b3d6,
  37869. 0x1079b00,0x1f422b3,0x1089950,0x145c19a,0x0c72fe1,0x1d07bbf,
  37870. 0x18280c3,0x0842c4e,0x00931d2 },
  37871. { 0x0646bc3,0x1c1a67c,0x1be7ea7,0x04815d2,0x1df94a5,0x08bbe8b,
  37872. 0x0e240de,0x19b2038,0x0ffeb66,0x0fe8322,0x0491967,0x05d8ef7,
  37873. 0x0f81aec,0x06cc0ea,0x1cedfcb,0x161265b,0x169f377,0x1e4de1f,
  37874. 0x1616762,0x1e69e7b,0x0125dae } },
  37875. /* 248 */
  37876. { { 0x0c123bc,0x0228dd1,0x0952b02,0x101031f,0x11e83a6,0x0abdc56,
  37877. 0x15c0a62,0x02cadba,0x0f0f12f,0x03f971a,0x1e85373,0x1866153,
  37878. 0x0c1f6a9,0x197f3c1,0x1268aee,0x0a9bbdf,0x097709f,0x1e98ce3,
  37879. 0x1918294,0x047197a,0x01dc0b8 },
  37880. { 0x0dfb6f6,0x09480a2,0x149bd92,0x08dc803,0x070d7cb,0x09bd6c1,
  37881. 0x0903921,0x1b234e1,0x170d8db,0x06b30da,0x03562e1,0x0475e2e,
  37882. 0x12ca272,0x11a270e,0x0d33c51,0x1c3f5dd,0x095ab9d,0x1912afe,
  37883. 0x0f717a9,0x1c2215b,0x01f8cd6 } },
  37884. /* 249 */
  37885. { { 0x0b8a0a7,0x1e35cbc,0x17a8a95,0x0dd067d,0x04b4aeb,0x089ff39,
  37886. 0x05f052f,0x1c93c8c,0x0fc2e8e,0x00c3444,0x11fbbf1,0x1493f62,
  37887. 0x1b8d398,0x1733167,0x1c647c4,0x145d9d3,0x089958b,0x0b0c391,
  37888. 0x02e3543,0x1a1e360,0x002dbd6 },
  37889. { 0x0c93cc9,0x07eff12,0x039e257,0x0173ce3,0x09ed778,0x1d7bf59,
  37890. 0x0e960e2,0x0d20391,0x04ddcbf,0x1129c3f,0x035aec0,0x017f430,
  37891. 0x0264b25,0x04a3e3e,0x1a39523,0x1e79ada,0x0329923,0x14153db,
  37892. 0x1440f34,0x006c265,0x000fb8f } },
  37893. /* 250 */
  37894. { { 0x0d9d494,0x059f846,0x07ce066,0x1329e9f,0x1b2065b,0x19c7d4c,
  37895. 0x08880f1,0x196ecc9,0x0d8d229,0x0cfa60a,0x1152cc6,0x0b898a3,
  37896. 0x12ddad7,0x0909d19,0x0cb382f,0x0f65f34,0x085888c,0x179d108,
  37897. 0x0c7fc82,0x1f46c4b,0x00d16de },
  37898. { 0x1a296eb,0x002a40c,0x0c4d138,0x0ba3522,0x1d94ff1,0x1522a78,
  37899. 0x0b4affa,0x0ffafbd,0x14d40bd,0x132d401,0x0692beb,0x08fc300,
  37900. 0x17604f1,0x12f06f3,0x0c123e6,0x0594130,0x0a5ff57,0x1d1d8ce,
  37901. 0x0087445,0x0fb74e3,0x00e0a23 } },
  37902. /* 251 */
  37903. { { 0x1630ee8,0x15fc248,0x0c07b6e,0x040bd6a,0x1e6589c,0x08fa3de,
  37904. 0x0acb681,0x1033efa,0x0212bbe,0x1554fcb,0x048492b,0x1abd285,
  37905. 0x1bdced3,0x1a21af2,0x07d6e27,0x1ecded2,0x0339411,0x10cb026,
  37906. 0x0d5bc36,0x1813948,0x00e6b7f },
  37907. { 0x14f811c,0x07209fb,0x176c4a5,0x03bf1b1,0x1a42d83,0x1a0c648,
  37908. 0x1c85e58,0x1d84fea,0x088ebcd,0x1ef290c,0x016f257,0x00ddd46,
  37909. 0x01fdd5e,0x163345b,0x0798222,0x030c3da,0x016eb81,0x0199d78,
  37910. 0x17773af,0x16325a2,0x01c95ec } },
  37911. /* 252 */
  37912. { { 0x0bde442,0x19bd1f0,0x1cfa49e,0x10cdef4,0x00543fe,0x0886177,
  37913. 0x074823b,0x065a61b,0x1a6617a,0x1bce1a0,0x173e2eb,0x10e1a3a,
  37914. 0x0be7367,0x11d5e7c,0x14373a7,0x0bcf605,0x0dd772b,0x0ff11e9,
  37915. 0x1ff1c31,0x19dd403,0x010b29f },
  37916. { 0x0d803ff,0x05726b1,0x1aa4c6f,0x1fb7860,0x13ee913,0x0083314,
  37917. 0x19eaf63,0x0b15e3b,0x0e7a6d6,0x042bc15,0x1d381b5,0x125c205,
  37918. 0x0691265,0x09b7d7f,0x08c49fc,0x0242723,0x0408837,0x0235c9a,
  37919. 0x0c7858d,0x1687014,0x00ba53b } },
  37920. /* 253 */
  37921. { { 0x05636b0,0x08bfe65,0x171d8b9,0x02d5742,0x0296e02,0x173d96a,
  37922. 0x1f5f084,0x108b551,0x15717ad,0x08be736,0x0bcd5e5,0x10b7316,
  37923. 0x1ce762b,0x0facd83,0x1e65ad7,0x1ede085,0x0bbf37e,0x0f9b995,
  37924. 0x150ad22,0x028bd48,0x015da5d },
  37925. { 0x07f6e3f,0x1e2af55,0x16f079d,0x0f54940,0x1f4d99a,0x0141139,
  37926. 0x1f5dd16,0x1f74ada,0x177b748,0x1844afd,0x07d7476,0x199c0c5,
  37927. 0x1b1c484,0x1acc01f,0x0c72428,0x171a1eb,0x1291720,0x121d627,
  37928. 0x0ab04fc,0x017fd0e,0x00e98c1 } },
  37929. /* 254 */
  37930. { { 0x06c4fd6,0x023c2e0,0x0e76747,0x0ba4b85,0x1f4b902,0x0c17925,
  37931. 0x17ac752,0x0560826,0x0ba4fef,0x159f6e1,0x181eace,0x073f31b,
  37932. 0x1d55a52,0x04b7a5b,0x1f126ac,0x1902bab,0x1603844,0x1e28514,
  37933. 0x159daca,0x0291a02,0x0047db1 },
  37934. { 0x0f3bad9,0x1ce6288,0x0753127,0x1804520,0x090888f,0x1da26fa,
  37935. 0x157af11,0x0d122f4,0x0f39f2b,0x05975e3,0x0658a88,0x075e09d,
  37936. 0x170c58e,0x0b9eead,0x0adf06d,0x1eed8a5,0x1d6a329,0x195aa56,
  37937. 0x0bd328e,0x15a3d70,0x010859d } },
  37938. /* 255 */
  37939. { { 0x182d1ad,0x0209450,0x111598b,0x1c4122d,0x1751796,0x140b23b,
  37940. 0x109cae9,0x1834ee0,0x0b92c85,0x164587d,0x0cb81fe,0x05bf5df,
  37941. 0x0d207ab,0x1c30d99,0x0d4c281,0x1a28b8e,0x16588ae,0x0b1edf6,
  37942. 0x094e927,0x179b941,0x00bd547 },
  37943. { 0x1056b51,0x09c17c3,0x044a9f0,0x16261f3,0x03d91ed,0x002da16,
  37944. 0x1791b4e,0x12bef8f,0x1fd31a9,0x0b080f5,0x1ee2a91,0x05699a7,
  37945. 0x0e1efd2,0x0f58bde,0x0e477de,0x01865fc,0x0c6616c,0x05a6a60,
  37946. 0x046fbbd,0x00477ce,0x011219f } },
  37947. };
  37948. /* Multiply the base point of P521 by the scalar and return the result.
  37949. * If map is true then convert result to affine coordinates.
  37950. *
  37951. * Stripe implementation.
  37952. * Pre-generated: 2^0, 2^65, ...
  37953. * Pre-generated: products of all combinations of above.
  37954. * 8 doubles and adds (with qz=1)
  37955. *
  37956. * r Resulting point.
  37957. * k Scalar to multiply by.
  37958. * map Indicates whether to convert result to affine.
  37959. * ct Constant time required.
  37960. * heap Heap to use for allocation.
  37961. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  37962. */
  37963. static int sp_521_ecc_mulmod_base_21(sp_point_521* r, const sp_digit* k,
  37964. int map, int ct, void* heap)
  37965. {
  37966. return sp_521_ecc_mulmod_stripe_21(r, &p521_base, p521_table,
  37967. k, map, ct, heap);
  37968. }
  37969. #endif
  37970. /* Multiply the base point of P521 by the scalar and return the result.
  37971. * If map is true then convert result to affine coordinates.
  37972. *
  37973. * km Scalar to multiply by.
  37974. * r Resulting point.
  37975. * map Indicates whether to convert result to affine.
  37976. * heap Heap to use for allocation.
  37977. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  37978. */
  37979. int sp_ecc_mulmod_base_521(const mp_int* km, ecc_point* r, int map, void* heap)
  37980. {
  37981. #ifdef WOLFSSL_SP_SMALL_STACK
  37982. sp_point_521* point = NULL;
  37983. sp_digit* k = NULL;
  37984. #else
  37985. sp_point_521 point[1];
  37986. sp_digit k[21];
  37987. #endif
  37988. int err = MP_OKAY;
  37989. #ifdef WOLFSSL_SP_SMALL_STACK
  37990. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521), heap,
  37991. DYNAMIC_TYPE_ECC);
  37992. if (point == NULL)
  37993. err = MEMORY_E;
  37994. if (err == MP_OKAY) {
  37995. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21, heap,
  37996. DYNAMIC_TYPE_ECC);
  37997. if (k == NULL)
  37998. err = MEMORY_E;
  37999. }
  38000. #endif
  38001. if (err == MP_OKAY) {
  38002. sp_521_from_mp(k, 21, km);
  38003. err = sp_521_ecc_mulmod_base_21(point, k, map, 1, heap);
  38004. }
  38005. if (err == MP_OKAY) {
  38006. err = sp_521_point_to_ecc_point_21(point, r);
  38007. }
  38008. #ifdef WOLFSSL_SP_SMALL_STACK
  38009. if (k != NULL)
  38010. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  38011. if (point != NULL)
  38012. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  38013. #endif
  38014. return err;
  38015. }
  38016. /* Multiply the base point of P521 by the scalar, add point a and return
  38017. * the result. If map is true then convert result to affine coordinates.
  38018. *
  38019. * km Scalar to multiply by.
  38020. * am Point to add to scalar multiply result.
  38021. * inMont Point to add is in montgomery form.
  38022. * r Resulting point.
  38023. * map Indicates whether to convert result to affine.
  38024. * heap Heap to use for allocation.
  38025. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  38026. */
  38027. int sp_ecc_mulmod_base_add_521(const mp_int* km, const ecc_point* am,
  38028. int inMont, ecc_point* r, int map, void* heap)
  38029. {
  38030. #ifdef WOLFSSL_SP_SMALL_STACK
  38031. sp_point_521* point = NULL;
  38032. sp_digit* k = NULL;
  38033. #else
  38034. sp_point_521 point[2];
  38035. sp_digit k[21 + 21 * 2 * 6];
  38036. #endif
  38037. sp_point_521* addP = NULL;
  38038. sp_digit* tmp = NULL;
  38039. int err = MP_OKAY;
  38040. #ifdef WOLFSSL_SP_SMALL_STACK
  38041. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap,
  38042. DYNAMIC_TYPE_ECC);
  38043. if (point == NULL)
  38044. err = MEMORY_E;
  38045. if (err == MP_OKAY) {
  38046. k = (sp_digit*)XMALLOC(
  38047. sizeof(sp_digit) * (21 + 21 * 2 * 6),
  38048. heap, DYNAMIC_TYPE_ECC);
  38049. if (k == NULL)
  38050. err = MEMORY_E;
  38051. }
  38052. #endif
  38053. if (err == MP_OKAY) {
  38054. addP = point + 1;
  38055. tmp = k + 21;
  38056. sp_521_from_mp(k, 21, km);
  38057. sp_521_point_from_ecc_point_21(addP, am);
  38058. }
  38059. if ((err == MP_OKAY) && (!inMont)) {
  38060. err = sp_521_mod_mul_norm_21(addP->x, addP->x, p521_mod);
  38061. }
  38062. if ((err == MP_OKAY) && (!inMont)) {
  38063. err = sp_521_mod_mul_norm_21(addP->y, addP->y, p521_mod);
  38064. }
  38065. if ((err == MP_OKAY) && (!inMont)) {
  38066. err = sp_521_mod_mul_norm_21(addP->z, addP->z, p521_mod);
  38067. }
  38068. if (err == MP_OKAY) {
  38069. err = sp_521_ecc_mulmod_base_21(point, k, 0, 0, heap);
  38070. }
  38071. if (err == MP_OKAY) {
  38072. sp_521_proj_point_add_21(point, point, addP, tmp);
  38073. if (map) {
  38074. sp_521_map_21(point, point, tmp);
  38075. }
  38076. err = sp_521_point_to_ecc_point_21(point, r);
  38077. }
  38078. #ifdef WOLFSSL_SP_SMALL_STACK
  38079. if (k != NULL)
  38080. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  38081. if (point)
  38082. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  38083. #endif
  38084. return err;
  38085. }
  38086. #if defined(WOLFSSL_VALIDATE_ECC_KEYGEN) || defined(HAVE_ECC_SIGN) || \
  38087. defined(HAVE_ECC_VERIFY)
  38088. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN | HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  38089. /* Add 1 to a. (a = a + 1)
  38090. *
  38091. * r A single precision integer.
  38092. * a A single precision integer.
  38093. */
  38094. SP_NOINLINE static void sp_521_add_one_21(sp_digit* a)
  38095. {
  38096. a[0]++;
  38097. sp_521_norm_21(a);
  38098. }
  38099. /* Read big endian unsigned byte array into r.
  38100. *
  38101. * r A single precision integer.
  38102. * size Maximum number of bytes to convert
  38103. * a Byte array.
  38104. * n Number of bytes in array to read.
  38105. */
  38106. static void sp_521_from_bin(sp_digit* r, int size, const byte* a, int n)
  38107. {
  38108. int i;
  38109. int j = 0;
  38110. word32 s = 0;
  38111. r[0] = 0;
  38112. for (i = n-1; i >= 0; i--) {
  38113. r[j] |= (((sp_digit)a[i]) << s);
  38114. if (s >= 17U) {
  38115. r[j] &= 0x1ffffff;
  38116. s = 25U - s;
  38117. if (j + 1 >= size) {
  38118. break;
  38119. }
  38120. r[++j] = (sp_digit)a[i] >> s;
  38121. s = 8U - s;
  38122. }
  38123. else {
  38124. s += 8U;
  38125. }
  38126. }
  38127. for (j++; j < size; j++) {
  38128. r[j] = 0;
  38129. }
  38130. }
  38131. /* Generates a scalar that is in the range 1..order-1.
  38132. *
  38133. * rng Random number generator.
  38134. * k Scalar value.
  38135. * returns RNG failures, MEMORY_E when memory allocation fails and
  38136. * MP_OKAY on success.
  38137. */
  38138. static int sp_521_ecc_gen_k_21(WC_RNG* rng, sp_digit* k)
  38139. {
  38140. int err;
  38141. byte buf[66];
  38142. do {
  38143. err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
  38144. if (err == 0) {
  38145. buf[0] &= 0x1;
  38146. sp_521_from_bin(k, 21, buf, (int)sizeof(buf));
  38147. if (sp_521_cmp_21(k, p521_order2) <= 0) {
  38148. sp_521_add_one_21(k);
  38149. break;
  38150. }
  38151. }
  38152. }
  38153. while (err == 0);
  38154. return err;
  38155. }
  38156. /* Makes a random EC key pair.
  38157. *
  38158. * rng Random number generator.
  38159. * priv Generated private value.
  38160. * pub Generated public point.
  38161. * heap Heap to use for allocation.
  38162. * returns ECC_INF_E when the point does not have the correct order, RNG
  38163. * failures, MEMORY_E when memory allocation fails and MP_OKAY on success.
  38164. */
  38165. int sp_ecc_make_key_521(WC_RNG* rng, mp_int* priv, ecc_point* pub, void* heap)
  38166. {
  38167. #ifdef WOLFSSL_SP_SMALL_STACK
  38168. sp_point_521* point = NULL;
  38169. sp_digit* k = NULL;
  38170. #else
  38171. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38172. sp_point_521 point[2];
  38173. #else
  38174. sp_point_521 point[1];
  38175. #endif
  38176. sp_digit k[21];
  38177. #endif
  38178. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38179. sp_point_521* infinity = NULL;
  38180. #endif
  38181. int err = MP_OKAY;
  38182. (void)heap;
  38183. #ifdef WOLFSSL_SP_SMALL_STACK
  38184. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38185. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap, DYNAMIC_TYPE_ECC);
  38186. #else
  38187. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521), heap, DYNAMIC_TYPE_ECC);
  38188. #endif
  38189. if (point == NULL)
  38190. err = MEMORY_E;
  38191. if (err == MP_OKAY) {
  38192. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21, heap,
  38193. DYNAMIC_TYPE_ECC);
  38194. if (k == NULL)
  38195. err = MEMORY_E;
  38196. }
  38197. #endif
  38198. if (err == MP_OKAY) {
  38199. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38200. infinity = point + 1;
  38201. #endif
  38202. err = sp_521_ecc_gen_k_21(rng, k);
  38203. }
  38204. if (err == MP_OKAY) {
  38205. err = sp_521_ecc_mulmod_base_21(point, k, 1, 1, NULL);
  38206. }
  38207. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38208. if (err == MP_OKAY) {
  38209. err = sp_521_ecc_mulmod_21(infinity, point, p521_order, 1, 1, NULL);
  38210. }
  38211. if (err == MP_OKAY) {
  38212. if (sp_521_iszero_21(point->x) || sp_521_iszero_21(point->y)) {
  38213. err = ECC_INF_E;
  38214. }
  38215. }
  38216. #endif
  38217. if (err == MP_OKAY) {
  38218. err = sp_521_to_mp(k, priv);
  38219. }
  38220. if (err == MP_OKAY) {
  38221. err = sp_521_point_to_ecc_point_21(point, pub);
  38222. }
  38223. #ifdef WOLFSSL_SP_SMALL_STACK
  38224. if (k != NULL)
  38225. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  38226. if (point != NULL) {
  38227. /* point is not sensitive, so no need to zeroize */
  38228. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  38229. }
  38230. #endif
  38231. return err;
  38232. }
  38233. #ifdef WOLFSSL_SP_NONBLOCK
  38234. typedef struct sp_ecc_key_gen_521_ctx {
  38235. int state;
  38236. sp_521_ecc_mulmod_21_ctx mulmod_ctx;
  38237. sp_digit k[21];
  38238. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38239. sp_point_521 point[2];
  38240. #else
  38241. sp_point_521 point[1];
  38242. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  38243. } sp_ecc_key_gen_521_ctx;
  38244. int sp_ecc_make_key_521_nb(sp_ecc_ctx_t* sp_ctx, WC_RNG* rng, mp_int* priv,
  38245. ecc_point* pub, void* heap)
  38246. {
  38247. int err = FP_WOULDBLOCK;
  38248. sp_ecc_key_gen_521_ctx* ctx = (sp_ecc_key_gen_521_ctx*)sp_ctx->data;
  38249. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38250. sp_point_521* infinity = ctx->point + 1;
  38251. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  38252. typedef char ctx_size_test[sizeof(sp_ecc_key_gen_521_ctx)
  38253. >= sizeof(*sp_ctx) ? -1 : 1];
  38254. (void)sizeof(ctx_size_test);
  38255. switch (ctx->state) {
  38256. case 0:
  38257. err = sp_521_ecc_gen_k_21(rng, ctx->k);
  38258. if (err == MP_OKAY) {
  38259. err = FP_WOULDBLOCK;
  38260. ctx->state = 1;
  38261. }
  38262. break;
  38263. case 1:
  38264. err = sp_521_ecc_mulmod_base_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  38265. ctx->point, ctx->k, 1, 1, heap);
  38266. if (err == MP_OKAY) {
  38267. err = FP_WOULDBLOCK;
  38268. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38269. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  38270. ctx->state = 2;
  38271. #else
  38272. ctx->state = 3;
  38273. #endif
  38274. }
  38275. break;
  38276. #ifdef WOLFSSL_VALIDATE_ECC_KEYGEN
  38277. case 2:
  38278. err = sp_521_ecc_mulmod_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  38279. infinity, ctx->point, p521_order, 1, 1);
  38280. if (err == MP_OKAY) {
  38281. if (sp_521_iszero_21(ctx->point->x) ||
  38282. sp_521_iszero_21(ctx->point->y)) {
  38283. err = ECC_INF_E;
  38284. }
  38285. else {
  38286. err = FP_WOULDBLOCK;
  38287. ctx->state = 3;
  38288. }
  38289. }
  38290. break;
  38291. #endif /* WOLFSSL_VALIDATE_ECC_KEYGEN */
  38292. case 3:
  38293. err = sp_521_to_mp(ctx->k, priv);
  38294. if (err == MP_OKAY) {
  38295. err = sp_521_point_to_ecc_point_21(ctx->point, pub);
  38296. }
  38297. break;
  38298. }
  38299. if (err != FP_WOULDBLOCK) {
  38300. XMEMSET(ctx, 0, sizeof(sp_ecc_key_gen_521_ctx));
  38301. }
  38302. return err;
  38303. }
  38304. #endif /* WOLFSSL_SP_NONBLOCK */
  38305. #ifdef HAVE_ECC_DHE
  38306. /* Write r as big endian to byte array.
  38307. * Fixed length number of bytes written: 66
  38308. *
  38309. * r A single precision integer.
  38310. * a Byte array.
  38311. */
  38312. static void sp_521_to_bin_21(sp_digit* r, byte* a)
  38313. {
  38314. int i;
  38315. int j;
  38316. int s = 0;
  38317. int b;
  38318. for (i=0; i<20; i++) {
  38319. r[i+1] += r[i] >> 25;
  38320. r[i] &= 0x1ffffff;
  38321. }
  38322. j = 528 / 8 - 1;
  38323. a[j] = 0;
  38324. for (i=0; i<21 && j>=0; i++) {
  38325. b = 0;
  38326. /* lint allow cast of mismatch sp_digit and int */
  38327. a[j--] |= (byte)(r[i] << s); /*lint !e9033*/
  38328. b += 8 - s;
  38329. if (j < 0) {
  38330. break;
  38331. }
  38332. while (b < 25) {
  38333. a[j--] = (byte)(r[i] >> b);
  38334. b += 8;
  38335. if (j < 0) {
  38336. break;
  38337. }
  38338. }
  38339. s = 8 - (b - 25);
  38340. if (j >= 0) {
  38341. a[j] = 0;
  38342. }
  38343. if (s != 0) {
  38344. j++;
  38345. }
  38346. }
  38347. }
  38348. /* Multiply the point by the scalar and serialize the X ordinate.
  38349. * The number is 0 padded to maximum size on output.
  38350. *
  38351. * priv Scalar to multiply the point by.
  38352. * pub Point to multiply.
  38353. * out Buffer to hold X ordinate.
  38354. * outLen On entry, size of the buffer in bytes.
  38355. * On exit, length of data in buffer in bytes.
  38356. * heap Heap to use for allocation.
  38357. * returns BUFFER_E if the buffer is to small for output size,
  38358. * MEMORY_E when memory allocation fails and MP_OKAY on success.
  38359. */
  38360. int sp_ecc_secret_gen_521(const mp_int* priv, const ecc_point* pub, byte* out,
  38361. word32* outLen, void* heap)
  38362. {
  38363. #ifdef WOLFSSL_SP_SMALL_STACK
  38364. sp_point_521* point = NULL;
  38365. sp_digit* k = NULL;
  38366. #else
  38367. sp_point_521 point[1];
  38368. sp_digit k[21];
  38369. #endif
  38370. int err = MP_OKAY;
  38371. if (*outLen < 65U) {
  38372. err = BUFFER_E;
  38373. }
  38374. #ifdef WOLFSSL_SP_SMALL_STACK
  38375. if (err == MP_OKAY) {
  38376. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521), heap,
  38377. DYNAMIC_TYPE_ECC);
  38378. if (point == NULL)
  38379. err = MEMORY_E;
  38380. }
  38381. if (err == MP_OKAY) {
  38382. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21, heap,
  38383. DYNAMIC_TYPE_ECC);
  38384. if (k == NULL)
  38385. err = MEMORY_E;
  38386. }
  38387. #endif
  38388. if (err == MP_OKAY) {
  38389. sp_521_from_mp(k, 21, priv);
  38390. sp_521_point_from_ecc_point_21(point, pub);
  38391. err = sp_521_ecc_mulmod_21(point, point, k, 1, 1, heap);
  38392. }
  38393. if (err == MP_OKAY) {
  38394. sp_521_to_bin_21(point->x, out);
  38395. *outLen = 66;
  38396. }
  38397. #ifdef WOLFSSL_SP_SMALL_STACK
  38398. if (k != NULL)
  38399. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  38400. if (point != NULL)
  38401. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  38402. #endif
  38403. return err;
  38404. }
  38405. #ifdef WOLFSSL_SP_NONBLOCK
  38406. typedef struct sp_ecc_sec_gen_521_ctx {
  38407. int state;
  38408. union {
  38409. sp_521_ecc_mulmod_21_ctx mulmod_ctx;
  38410. };
  38411. sp_digit k[21];
  38412. sp_point_521 point;
  38413. } sp_ecc_sec_gen_521_ctx;
  38414. int sp_ecc_secret_gen_521_nb(sp_ecc_ctx_t* sp_ctx, const mp_int* priv,
  38415. const ecc_point* pub, byte* out, word32* outLen, void* heap)
  38416. {
  38417. int err = FP_WOULDBLOCK;
  38418. sp_ecc_sec_gen_521_ctx* ctx = (sp_ecc_sec_gen_521_ctx*)sp_ctx->data;
  38419. typedef char ctx_size_test[sizeof(sp_ecc_sec_gen_521_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  38420. (void)sizeof(ctx_size_test);
  38421. if (*outLen < 32U) {
  38422. err = BUFFER_E;
  38423. }
  38424. switch (ctx->state) {
  38425. case 0:
  38426. sp_521_from_mp(ctx->k, 21, priv);
  38427. sp_521_point_from_ecc_point_21(&ctx->point, pub);
  38428. ctx->state = 1;
  38429. break;
  38430. case 1:
  38431. err = sp_521_ecc_mulmod_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  38432. &ctx->point, &ctx->point, ctx->k, 1, 1, heap);
  38433. if (err == MP_OKAY) {
  38434. sp_521_to_bin_21(ctx->point.x, out);
  38435. *outLen = 66;
  38436. }
  38437. break;
  38438. }
  38439. if (err == MP_OKAY && ctx->state != 1) {
  38440. err = FP_WOULDBLOCK;
  38441. }
  38442. if (err != FP_WOULDBLOCK) {
  38443. XMEMSET(ctx, 0, sizeof(sp_ecc_sec_gen_521_ctx));
  38444. }
  38445. return err;
  38446. }
  38447. #endif /* WOLFSSL_SP_NONBLOCK */
  38448. #endif /* HAVE_ECC_DHE */
  38449. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  38450. SP_NOINLINE static void sp_521_rshift_21(sp_digit* r, const sp_digit* a,
  38451. byte n)
  38452. {
  38453. int i;
  38454. #ifdef WOLFSSL_SP_SMALL
  38455. for (i=0; i<20; i++) {
  38456. r[i] = ((a[i] >> n) | (a[i + 1] << (25 - n))) & 0x1ffffff;
  38457. }
  38458. #else
  38459. for (i=0; i<16; i += 8) {
  38460. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (25 - n)) & 0x1ffffff);
  38461. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (25 - n)) & 0x1ffffff);
  38462. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (25 - n)) & 0x1ffffff);
  38463. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (25 - n)) & 0x1ffffff);
  38464. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (25 - n)) & 0x1ffffff);
  38465. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (25 - n)) & 0x1ffffff);
  38466. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (25 - n)) & 0x1ffffff);
  38467. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (25 - n)) & 0x1ffffff);
  38468. }
  38469. r[16] = (a[16] >> n) | ((a[17] << (25 - n)) & 0x1ffffff);
  38470. r[17] = (a[17] >> n) | ((a[18] << (25 - n)) & 0x1ffffff);
  38471. r[18] = (a[18] >> n) | ((a[19] << (25 - n)) & 0x1ffffff);
  38472. r[19] = (a[19] >> n) | ((a[20] << (25 - n)) & 0x1ffffff);
  38473. #endif /* WOLFSSL_SP_SMALL */
  38474. r[20] = a[20] >> n;
  38475. }
  38476. #endif
  38477. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  38478. /* Multiply a by scalar b into r. (r = a * b)
  38479. *
  38480. * r A single precision integer.
  38481. * a A single precision integer.
  38482. * b A scalar.
  38483. */
  38484. SP_NOINLINE static void sp_521_mul_d_21(sp_digit* r, const sp_digit* a,
  38485. sp_digit b)
  38486. {
  38487. #ifdef WOLFSSL_SP_SMALL
  38488. sp_int64 tb = b;
  38489. sp_int64 t = 0;
  38490. int i;
  38491. for (i = 0; i < 21; i++) {
  38492. t += tb * a[i];
  38493. r[i] = (sp_digit)(t & 0x1ffffff);
  38494. t >>= 25;
  38495. }
  38496. r[21] = (sp_digit)t;
  38497. #else
  38498. sp_int64 tb = b;
  38499. sp_int64 t = 0;
  38500. sp_digit t2;
  38501. sp_int64 p[4];
  38502. int i;
  38503. for (i = 0; i < 20; i += 4) {
  38504. p[0] = tb * a[i + 0];
  38505. p[1] = tb * a[i + 1];
  38506. p[2] = tb * a[i + 2];
  38507. p[3] = tb * a[i + 3];
  38508. t += p[0];
  38509. t2 = (sp_digit)(t & 0x1ffffff);
  38510. t >>= 25;
  38511. r[i + 0] = (sp_digit)t2;
  38512. t += p[1];
  38513. t2 = (sp_digit)(t & 0x1ffffff);
  38514. t >>= 25;
  38515. r[i + 1] = (sp_digit)t2;
  38516. t += p[2];
  38517. t2 = (sp_digit)(t & 0x1ffffff);
  38518. t >>= 25;
  38519. r[i + 2] = (sp_digit)t2;
  38520. t += p[3];
  38521. t2 = (sp_digit)(t & 0x1ffffff);
  38522. t >>= 25;
  38523. r[i + 3] = (sp_digit)t2;
  38524. }
  38525. t += tb * a[20];
  38526. r[20] = (sp_digit)(t & 0x1ffffff);
  38527. t >>= 25;
  38528. r[21] = (sp_digit)(t & 0x1ffffff);
  38529. #endif /* WOLFSSL_SP_SMALL */
  38530. }
  38531. SP_NOINLINE static void sp_521_lshift_42(sp_digit* r, const sp_digit* a,
  38532. byte n)
  38533. {
  38534. #ifdef WOLFSSL_SP_SMALL
  38535. int i;
  38536. r[42] = a[41] >> (25 - n);
  38537. for (i=41; i>0; i--) {
  38538. r[i] = ((a[i] << n) | (a[i-1] >> (25 - n))) & 0x1ffffff;
  38539. }
  38540. #else
  38541. sp_int_digit s;
  38542. sp_int_digit t;
  38543. s = (sp_int_digit)a[41];
  38544. r[42] = s >> (25U - n);
  38545. s = (sp_int_digit)(a[41]); t = (sp_int_digit)(a[40]);
  38546. r[41] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38547. s = (sp_int_digit)(a[40]); t = (sp_int_digit)(a[39]);
  38548. r[40] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38549. s = (sp_int_digit)(a[39]); t = (sp_int_digit)(a[38]);
  38550. r[39] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38551. s = (sp_int_digit)(a[38]); t = (sp_int_digit)(a[37]);
  38552. r[38] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38553. s = (sp_int_digit)(a[37]); t = (sp_int_digit)(a[36]);
  38554. r[37] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38555. s = (sp_int_digit)(a[36]); t = (sp_int_digit)(a[35]);
  38556. r[36] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38557. s = (sp_int_digit)(a[35]); t = (sp_int_digit)(a[34]);
  38558. r[35] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38559. s = (sp_int_digit)(a[34]); t = (sp_int_digit)(a[33]);
  38560. r[34] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38561. s = (sp_int_digit)(a[33]); t = (sp_int_digit)(a[32]);
  38562. r[33] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38563. s = (sp_int_digit)(a[32]); t = (sp_int_digit)(a[31]);
  38564. r[32] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38565. s = (sp_int_digit)(a[31]); t = (sp_int_digit)(a[30]);
  38566. r[31] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38567. s = (sp_int_digit)(a[30]); t = (sp_int_digit)(a[29]);
  38568. r[30] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38569. s = (sp_int_digit)(a[29]); t = (sp_int_digit)(a[28]);
  38570. r[29] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38571. s = (sp_int_digit)(a[28]); t = (sp_int_digit)(a[27]);
  38572. r[28] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38573. s = (sp_int_digit)(a[27]); t = (sp_int_digit)(a[26]);
  38574. r[27] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38575. s = (sp_int_digit)(a[26]); t = (sp_int_digit)(a[25]);
  38576. r[26] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38577. s = (sp_int_digit)(a[25]); t = (sp_int_digit)(a[24]);
  38578. r[25] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38579. s = (sp_int_digit)(a[24]); t = (sp_int_digit)(a[23]);
  38580. r[24] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38581. s = (sp_int_digit)(a[23]); t = (sp_int_digit)(a[22]);
  38582. r[23] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38583. s = (sp_int_digit)(a[22]); t = (sp_int_digit)(a[21]);
  38584. r[22] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38585. s = (sp_int_digit)(a[21]); t = (sp_int_digit)(a[20]);
  38586. r[21] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38587. s = (sp_int_digit)(a[20]); t = (sp_int_digit)(a[19]);
  38588. r[20] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38589. s = (sp_int_digit)(a[19]); t = (sp_int_digit)(a[18]);
  38590. r[19] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38591. s = (sp_int_digit)(a[18]); t = (sp_int_digit)(a[17]);
  38592. r[18] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38593. s = (sp_int_digit)(a[17]); t = (sp_int_digit)(a[16]);
  38594. r[17] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38595. s = (sp_int_digit)(a[16]); t = (sp_int_digit)(a[15]);
  38596. r[16] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38597. s = (sp_int_digit)(a[15]); t = (sp_int_digit)(a[14]);
  38598. r[15] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38599. s = (sp_int_digit)(a[14]); t = (sp_int_digit)(a[13]);
  38600. r[14] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38601. s = (sp_int_digit)(a[13]); t = (sp_int_digit)(a[12]);
  38602. r[13] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38603. s = (sp_int_digit)(a[12]); t = (sp_int_digit)(a[11]);
  38604. r[12] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38605. s = (sp_int_digit)(a[11]); t = (sp_int_digit)(a[10]);
  38606. r[11] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38607. s = (sp_int_digit)(a[10]); t = (sp_int_digit)(a[9]);
  38608. r[10] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38609. s = (sp_int_digit)(a[9]); t = (sp_int_digit)(a[8]);
  38610. r[9] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38611. s = (sp_int_digit)(a[8]); t = (sp_int_digit)(a[7]);
  38612. r[8] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38613. s = (sp_int_digit)(a[7]); t = (sp_int_digit)(a[6]);
  38614. r[7] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38615. s = (sp_int_digit)(a[6]); t = (sp_int_digit)(a[5]);
  38616. r[6] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38617. s = (sp_int_digit)(a[5]); t = (sp_int_digit)(a[4]);
  38618. r[5] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38619. s = (sp_int_digit)(a[4]); t = (sp_int_digit)(a[3]);
  38620. r[4] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38621. s = (sp_int_digit)(a[3]); t = (sp_int_digit)(a[2]);
  38622. r[3] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38623. s = (sp_int_digit)(a[2]); t = (sp_int_digit)(a[1]);
  38624. r[2] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38625. s = (sp_int_digit)(a[1]); t = (sp_int_digit)(a[0]);
  38626. r[1] = ((s << n) | (t >> (25U - n))) & 0x1ffffff;
  38627. #endif /* WOLFSSL_SP_SMALL */
  38628. r[0] = (a[0] << n) & 0x1ffffff;
  38629. }
  38630. /* Divide d in a and put remainder into r (m*d + r = a)
  38631. * m is not calculated as it is not needed at this time.
  38632. *
  38633. * Simplified based on top word of divisor being (1 << 25) - 1
  38634. *
  38635. * a Number to be divided.
  38636. * d Number to divide with.
  38637. * m Multiplier result.
  38638. * r Remainder from the division.
  38639. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  38640. */
  38641. static int sp_521_div_21(const sp_digit* a, const sp_digit* d,
  38642. const sp_digit* m, sp_digit* r)
  38643. {
  38644. int i;
  38645. sp_digit r1;
  38646. sp_digit mask;
  38647. #ifdef WOLFSSL_SP_SMALL_STACK
  38648. sp_digit* t1 = NULL;
  38649. #else
  38650. sp_digit t1[4 * 21 + 3];
  38651. #endif
  38652. sp_digit* t2 = NULL;
  38653. sp_digit* sd = NULL;
  38654. int err = MP_OKAY;
  38655. (void)m;
  38656. #ifdef WOLFSSL_SP_SMALL_STACK
  38657. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 21 + 3), NULL,
  38658. DYNAMIC_TYPE_TMP_BUFFER);
  38659. if (t1 == NULL)
  38660. err = MEMORY_E;
  38661. #endif
  38662. (void)m;
  38663. if (err == MP_OKAY) {
  38664. t2 = t1 + 42 + 1;
  38665. sd = t2 + 21 + 1;
  38666. sp_521_mul_d_21(sd, d, (sp_digit)1 << 4);
  38667. sp_521_lshift_42(t1, a, 4);
  38668. t1[21 + 21] += t1[21 + 21 - 1] >> 25;
  38669. t1[21 + 21 - 1] &= 0x1ffffff;
  38670. for (i=20; i>=0; i--) {
  38671. r1 = t1[21 + i];
  38672. sp_521_mul_d_21(t2, sd, r1);
  38673. (void)sp_521_sub_21(&t1[i], &t1[i], t2);
  38674. t1[21 + i] -= t2[21];
  38675. sp_521_norm_21(&t1[i + 1]);
  38676. mask = ~((t1[21 + i] - 1) >> 31);
  38677. sp_521_cond_sub_21(t1 + i, t1 + i, sd, mask);
  38678. sp_521_norm_21(&t1[i + 1]);
  38679. }
  38680. sp_521_norm_21(t1);
  38681. sp_521_rshift_21(r, t1, 4);
  38682. }
  38683. #ifdef WOLFSSL_SP_SMALL_STACK
  38684. if (t1 != NULL)
  38685. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  38686. #endif
  38687. return err;
  38688. }
  38689. /* Reduce a modulo m into r. (r = a mod m)
  38690. *
  38691. * r A single precision number that is the reduced result.
  38692. * a A single precision number that is to be reduced.
  38693. * m A single precision number that is the modulus to reduce with.
  38694. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  38695. */
  38696. static int sp_521_mod_21(sp_digit* r, const sp_digit* a, const sp_digit* m)
  38697. {
  38698. return sp_521_div_21(a, m, NULL, r);
  38699. }
  38700. #endif
  38701. #if defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY)
  38702. /* Multiply two number mod the order of P521 curve. (r = a * b mod order)
  38703. *
  38704. * r Result of the multiplication.
  38705. * a First operand of the multiplication.
  38706. * b Second operand of the multiplication.
  38707. */
  38708. static void sp_521_mont_mul_order_21(sp_digit* r, const sp_digit* a, const sp_digit* b)
  38709. {
  38710. sp_521_mul_21(r, a, b);
  38711. sp_521_mont_reduce_order_21(r, p521_order, p521_mp_order);
  38712. }
  38713. #if defined(HAVE_ECC_SIGN) || (defined(HAVE_ECC_VERIFY) && defined(WOLFSSL_SP_SMALL))
  38714. #ifdef WOLFSSL_SP_SMALL
  38715. /* Order-2 for the P521 curve. */
  38716. static const uint32_t p521_order_minus_2[17] = {
  38717. 0x91386407U,0xbb6fb71eU,0x899c47aeU,0x3bb5c9b8U,0xf709a5d0U,0x7fcc0148U,
  38718. 0xbf2f966bU,0x51868783U,0xfffffffaU,0xffffffffU,0xffffffffU,0xffffffffU,
  38719. 0xffffffffU,0xffffffffU,0xffffffffU,0xffffffffU,0x000001ffU
  38720. };
  38721. #else
  38722. /* The low half of the order-2 of the P521 curve. */
  38723. static const uint32_t p521_order_low[9] = {
  38724. 0x91386407U,0xbb6fb71eU,0x899c47aeU,0x3bb5c9b8U,0xf709a5d0U,0x7fcc0148U,
  38725. 0xbf2f966bU,0x51868783U,0xfffffffaU
  38726. };
  38727. #endif /* WOLFSSL_SP_SMALL */
  38728. /* Square number mod the order of P521 curve. (r = a * a mod order)
  38729. *
  38730. * r Result of the squaring.
  38731. * a Number to square.
  38732. */
  38733. static void sp_521_mont_sqr_order_21(sp_digit* r, const sp_digit* a)
  38734. {
  38735. sp_521_sqr_21(r, a);
  38736. sp_521_mont_reduce_order_21(r, p521_order, p521_mp_order);
  38737. }
  38738. #ifndef WOLFSSL_SP_SMALL
  38739. /* Square number mod the order of P521 curve a number of times.
  38740. * (r = a ^ n mod order)
  38741. *
  38742. * r Result of the squaring.
  38743. * a Number to square.
  38744. */
  38745. static void sp_521_mont_sqr_n_order_21(sp_digit* r, const sp_digit* a, int n)
  38746. {
  38747. int i;
  38748. sp_521_mont_sqr_order_21(r, a);
  38749. for (i=1; i<n; i++) {
  38750. sp_521_mont_sqr_order_21(r, r);
  38751. }
  38752. }
  38753. #endif /* !WOLFSSL_SP_SMALL */
  38754. /* Invert the number, in Montgomery form, modulo the order of the P521 curve.
  38755. * (r = 1 / a mod order)
  38756. *
  38757. * r Inverse result.
  38758. * a Number to invert.
  38759. * td Temporary data.
  38760. */
  38761. #ifdef WOLFSSL_SP_NONBLOCK
  38762. typedef struct sp_521_mont_inv_order_21_ctx {
  38763. int state;
  38764. int i;
  38765. } sp_521_mont_inv_order_21_ctx;
  38766. static int sp_521_mont_inv_order_21_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_digit* a,
  38767. sp_digit* t)
  38768. {
  38769. int err = FP_WOULDBLOCK;
  38770. sp_521_mont_inv_order_21_ctx* ctx = (sp_521_mont_inv_order_21_ctx*)sp_ctx;
  38771. typedef char ctx_size_test[sizeof(sp_521_mont_inv_order_21_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  38772. (void)sizeof(ctx_size_test);
  38773. switch (ctx->state) {
  38774. case 0:
  38775. XMEMCPY(t, a, sizeof(sp_digit) * 21);
  38776. ctx->i = 519;
  38777. ctx->state = 1;
  38778. break;
  38779. case 1:
  38780. sp_521_mont_sqr_order_21(t, t);
  38781. ctx->state = 2;
  38782. break;
  38783. case 2:
  38784. if ((p521_order_minus_2[ctx->i / 32] & ((sp_int_digit)1 << (ctx->i % 32))) != 0) {
  38785. sp_521_mont_mul_order_21(t, t, a);
  38786. }
  38787. ctx->i--;
  38788. ctx->state = (ctx->i == 0) ? 3 : 1;
  38789. break;
  38790. case 3:
  38791. XMEMCPY(r, t, sizeof(sp_digit) * 21U);
  38792. err = MP_OKAY;
  38793. break;
  38794. }
  38795. return err;
  38796. }
  38797. #endif /* WOLFSSL_SP_NONBLOCK */
  38798. static void sp_521_mont_inv_order_21(sp_digit* r, const sp_digit* a,
  38799. sp_digit* td)
  38800. {
  38801. #ifdef WOLFSSL_SP_SMALL
  38802. sp_digit* t = td;
  38803. int i;
  38804. XMEMCPY(t, a, sizeof(sp_digit) * 21);
  38805. for (i=519; i>=0; i--) {
  38806. sp_521_mont_sqr_order_21(t, t);
  38807. if ((p521_order_minus_2[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  38808. sp_521_mont_mul_order_21(t, t, a);
  38809. }
  38810. }
  38811. XMEMCPY(r, t, sizeof(sp_digit) * 21U);
  38812. #else
  38813. sp_digit* t = td;
  38814. sp_digit* t2 = td + 2 * 21;
  38815. sp_digit* t3 = td + 4 * 21;
  38816. int i;
  38817. /* t = a^2 */
  38818. sp_521_mont_sqr_order_21(t, a);
  38819. /* t = a^3 = t * a */
  38820. sp_521_mont_mul_order_21(t, t, a);
  38821. /* t= a^c = t ^ 2 ^ 2 */
  38822. sp_521_mont_sqr_n_order_21(t2, t, 2);
  38823. /* t = a^f = t2 * t */
  38824. sp_521_mont_mul_order_21(t, t2, t);
  38825. /* t3 = a^1e */
  38826. sp_521_mont_sqr_order_21(t3, t);
  38827. /* t3 = a^1f = t3 * a */
  38828. sp_521_mont_mul_order_21(t3, t3, a);
  38829. /* t2= a^f0 = t ^ 2 ^ 4 */
  38830. sp_521_mont_sqr_n_order_21(t2, t, 4);
  38831. /* t = a^ff = t2 * t */
  38832. sp_521_mont_mul_order_21(t, t2, t);
  38833. /* t2= a^ff00 = t ^ 2 ^ 8 */
  38834. sp_521_mont_sqr_n_order_21(t2, t, 8);
  38835. /* t3= a^ffff = t2 * t */
  38836. sp_521_mont_mul_order_21(t, t2, t);
  38837. /* t2= a^ffff0000 = t ^ 2 ^ 16 */
  38838. sp_521_mont_sqr_n_order_21(t2, t, 16);
  38839. /* t = a^ffffffff = t2 * t */
  38840. sp_521_mont_mul_order_21(t, t2, t);
  38841. /* t2= a^ffffffff00000000 = t ^ 2 ^ 32 */
  38842. sp_521_mont_sqr_n_order_21(t2, t, 32);
  38843. /* t = a^ffffffffffffffff = t2 * t */
  38844. sp_521_mont_mul_order_21(t, t2, t);
  38845. /* t2= a^ffffffffffffffff0000000000000000 = t ^ 2 ^ 64 */
  38846. sp_521_mont_sqr_n_order_21(t2, t, 64);
  38847. /* t = a^ffffffffffffffffffffffffffffffff = t2 * t */
  38848. sp_521_mont_mul_order_21(t, t2, t);
  38849. /* t2= a^ffffffffffffffffffffffffffffffff00000000000000000000000000000000 = t ^ 2 ^ 128 */
  38850. sp_521_mont_sqr_n_order_21(t2, t, 128);
  38851. /* t = a^ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff = t2 * t */
  38852. sp_521_mont_mul_order_21(t, t2, t);
  38853. /* t2 = a^1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0 */
  38854. sp_521_mont_sqr_n_order_21(t2, t, 5);
  38855. /* t2 = a^1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff = t * t3 */
  38856. sp_521_mont_mul_order_21(t2, t2, t3);
  38857. for (i=259; i>=1; i--) {
  38858. sp_521_mont_sqr_order_21(t2, t2);
  38859. if ((p521_order_low[i / 32] & ((sp_int_digit)1 << (i % 32))) != 0) {
  38860. sp_521_mont_mul_order_21(t2, t2, a);
  38861. }
  38862. }
  38863. sp_521_mont_sqr_order_21(t2, t2);
  38864. sp_521_mont_mul_order_21(r, t2, a);
  38865. #endif /* WOLFSSL_SP_SMALL */
  38866. }
  38867. #endif /* HAVE_ECC_SIGN || (HAVE_ECC_VERIFY && WOLFSSL_SP_SMALL) */
  38868. #endif /* HAVE_ECC_SIGN | HAVE_ECC_VERIFY */
  38869. #ifdef HAVE_ECC_SIGN
  38870. #ifndef SP_ECC_MAX_SIG_GEN
  38871. #define SP_ECC_MAX_SIG_GEN 64
  38872. #endif
  38873. /* Calculate second signature value S from R, k and private value.
  38874. *
  38875. * s = (r * x + e) / k
  38876. *
  38877. * s Signature value.
  38878. * r First signature value.
  38879. * k Ephemeral private key.
  38880. * x Private key as a number.
  38881. * e Hash of message as a number.
  38882. * tmp Temporary storage for intermediate numbers.
  38883. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  38884. */
  38885. static int sp_521_calc_s_21(sp_digit* s, const sp_digit* r, sp_digit* k,
  38886. sp_digit* x, const sp_digit* e, sp_digit* tmp)
  38887. {
  38888. int err;
  38889. sp_digit carry;
  38890. sp_int32 c;
  38891. sp_digit* kInv = k;
  38892. /* Conv k to Montgomery form (mod order) */
  38893. sp_521_mul_21(k, k, p521_norm_order);
  38894. err = sp_521_mod_21(k, k, p521_order);
  38895. if (err == MP_OKAY) {
  38896. sp_521_norm_21(k);
  38897. /* kInv = 1/k mod order */
  38898. sp_521_mont_inv_order_21(kInv, k, tmp);
  38899. sp_521_norm_21(kInv);
  38900. /* s = r * x + e */
  38901. sp_521_mul_21(x, x, r);
  38902. err = sp_521_mod_21(x, x, p521_order);
  38903. }
  38904. if (err == MP_OKAY) {
  38905. sp_521_norm_21(x);
  38906. carry = sp_521_add_21(s, e, x);
  38907. sp_521_cond_sub_21(s, s, p521_order, 0 - carry);
  38908. sp_521_norm_21(s);
  38909. c = sp_521_cmp_21(s, p521_order);
  38910. sp_521_cond_sub_21(s, s, p521_order,
  38911. (sp_digit)0 - (sp_digit)(c >= 0));
  38912. sp_521_norm_21(s);
  38913. /* s = s * k^-1 mod order */
  38914. sp_521_mont_mul_order_21(s, s, kInv);
  38915. sp_521_norm_21(s);
  38916. }
  38917. return err;
  38918. }
  38919. /* Sign the hash using the private key.
  38920. * e = [hash, 521 bits] from binary
  38921. * r = (k.G)->x mod order
  38922. * s = (r * x + e) / k mod order
  38923. * The hash is truncated to the first 521 bits.
  38924. *
  38925. * hash Hash to sign.
  38926. * hashLen Length of the hash data.
  38927. * rng Random number generator.
  38928. * priv Private part of key - scalar.
  38929. * rm First part of result as an mp_int.
  38930. * sm Sirst part of result as an mp_int.
  38931. * heap Heap to use for allocation.
  38932. * returns RNG failures, MEMORY_E when memory allocation fails and
  38933. * MP_OKAY on success.
  38934. */
  38935. int sp_ecc_sign_521(const byte* hash, word32 hashLen, WC_RNG* rng,
  38936. const mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  38937. {
  38938. #ifdef WOLFSSL_SP_SMALL_STACK
  38939. sp_digit* e = NULL;
  38940. sp_point_521* point = NULL;
  38941. #else
  38942. sp_digit e[7 * 2 * 21];
  38943. sp_point_521 point[1];
  38944. #endif
  38945. sp_digit* x = NULL;
  38946. sp_digit* k = NULL;
  38947. sp_digit* r = NULL;
  38948. sp_digit* tmp = NULL;
  38949. sp_digit* s = NULL;
  38950. sp_int32 c;
  38951. int err = MP_OKAY;
  38952. int i;
  38953. (void)heap;
  38954. #ifdef WOLFSSL_SP_SMALL_STACK
  38955. if (err == MP_OKAY) {
  38956. point = (sp_point_521*)XMALLOC(sizeof(sp_point_521), heap,
  38957. DYNAMIC_TYPE_ECC);
  38958. if (point == NULL)
  38959. err = MEMORY_E;
  38960. }
  38961. if (err == MP_OKAY) {
  38962. e = (sp_digit*)XMALLOC(sizeof(sp_digit) * 7 * 2 * 21, heap,
  38963. DYNAMIC_TYPE_ECC);
  38964. if (e == NULL)
  38965. err = MEMORY_E;
  38966. }
  38967. #endif
  38968. if (err == MP_OKAY) {
  38969. x = e + 2 * 21;
  38970. k = e + 4 * 21;
  38971. r = e + 6 * 21;
  38972. tmp = e + 8 * 21;
  38973. s = e;
  38974. if (hashLen > 66U) {
  38975. hashLen = 66U;
  38976. }
  38977. }
  38978. for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
  38979. /* New random point. */
  38980. if (km == NULL || mp_iszero(km)) {
  38981. err = sp_521_ecc_gen_k_21(rng, k);
  38982. }
  38983. else {
  38984. sp_521_from_mp(k, 21, km);
  38985. mp_zero(km);
  38986. }
  38987. if (err == MP_OKAY) {
  38988. err = sp_521_ecc_mulmod_base_21(point, k, 1, 1, heap);
  38989. }
  38990. if (err == MP_OKAY) {
  38991. /* r = point->x mod order */
  38992. XMEMCPY(r, point->x, sizeof(sp_digit) * 21U);
  38993. sp_521_norm_21(r);
  38994. c = sp_521_cmp_21(r, p521_order);
  38995. sp_521_cond_sub_21(r, r, p521_order,
  38996. (sp_digit)0 - (sp_digit)(c >= 0));
  38997. sp_521_norm_21(r);
  38998. if (!sp_521_iszero_21(r)) {
  38999. /* x is modified in calculation of s. */
  39000. sp_521_from_mp(x, 21, priv);
  39001. /* s ptr == e ptr, e is modified in calculation of s. */
  39002. sp_521_from_bin(e, 21, hash, (int)hashLen);
  39003. /* Take 521 leftmost bits of hash. */
  39004. if (hashLen == 66U) {
  39005. sp_521_rshift_21(e, e, 7);
  39006. e[20] |= ((sp_digit)hash[0]) << 13;
  39007. }
  39008. err = sp_521_calc_s_21(s, r, k, x, e, tmp);
  39009. /* Check that signature is usable. */
  39010. if ((err == MP_OKAY) && (!sp_521_iszero_21(s))) {
  39011. break;
  39012. }
  39013. }
  39014. }
  39015. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  39016. i = 1;
  39017. #endif
  39018. }
  39019. if (i == 0) {
  39020. err = RNG_FAILURE_E;
  39021. }
  39022. if (err == MP_OKAY) {
  39023. err = sp_521_to_mp(r, rm);
  39024. }
  39025. if (err == MP_OKAY) {
  39026. err = sp_521_to_mp(s, sm);
  39027. }
  39028. #ifdef WOLFSSL_SP_SMALL_STACK
  39029. if (e != NULL)
  39030. #endif
  39031. {
  39032. ForceZero(e, sizeof(sp_digit) * 7 * 2 * 21);
  39033. #ifdef WOLFSSL_SP_SMALL_STACK
  39034. XFREE(e, heap, DYNAMIC_TYPE_ECC);
  39035. #endif
  39036. }
  39037. #ifdef WOLFSSL_SP_SMALL_STACK
  39038. if (point != NULL)
  39039. #endif
  39040. {
  39041. ForceZero(point, sizeof(sp_point_521));
  39042. #ifdef WOLFSSL_SP_SMALL_STACK
  39043. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  39044. #endif
  39045. }
  39046. return err;
  39047. }
  39048. #ifdef WOLFSSL_SP_NONBLOCK
  39049. typedef struct sp_ecc_sign_521_ctx {
  39050. int state;
  39051. union {
  39052. sp_521_ecc_mulmod_21_ctx mulmod_ctx;
  39053. sp_521_mont_inv_order_21_ctx mont_inv_order_ctx;
  39054. };
  39055. sp_digit e[2*21];
  39056. sp_digit x[2*21];
  39057. sp_digit k[2*21];
  39058. sp_digit r[2*21];
  39059. sp_digit tmp[3 * 2*21];
  39060. sp_point_521 point;
  39061. sp_digit* s;
  39062. sp_digit* kInv;
  39063. int i;
  39064. } sp_ecc_sign_521_ctx;
  39065. int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, WC_RNG* rng,
  39066. mp_int* priv, mp_int* rm, mp_int* sm, mp_int* km, void* heap)
  39067. {
  39068. int err = FP_WOULDBLOCK;
  39069. sp_ecc_sign_521_ctx* ctx = (sp_ecc_sign_521_ctx*)sp_ctx->data;
  39070. typedef char ctx_size_test[sizeof(sp_ecc_sign_521_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  39071. (void)sizeof(ctx_size_test);
  39072. switch (ctx->state) {
  39073. case 0: /* INIT */
  39074. ctx->s = ctx->e;
  39075. ctx->kInv = ctx->k;
  39076. ctx->i = SP_ECC_MAX_SIG_GEN;
  39077. ctx->state = 1;
  39078. break;
  39079. case 1: /* GEN */
  39080. /* New random point. */
  39081. if (km == NULL || mp_iszero(km)) {
  39082. err = sp_521_ecc_gen_k_21(rng, ctx->k);
  39083. }
  39084. else {
  39085. sp_521_from_mp(ctx->k, 21, km);
  39086. mp_zero(km);
  39087. }
  39088. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  39089. ctx->state = 2;
  39090. break;
  39091. case 2: /* MULMOD */
  39092. err = sp_521_ecc_mulmod_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx,
  39093. &ctx->point, &p521_base, ctx->k, 1, 1, heap);
  39094. if (err == MP_OKAY) {
  39095. ctx->state = 3;
  39096. }
  39097. break;
  39098. case 3: /* MODORDER */
  39099. {
  39100. sp_int32 c;
  39101. /* r = point->x mod order */
  39102. XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 21U);
  39103. sp_521_norm_21(ctx->r);
  39104. c = sp_521_cmp_21(ctx->r, p521_order);
  39105. sp_521_cond_sub_21(ctx->r, ctx->r, p521_order,
  39106. (sp_digit)0 - (sp_digit)(c >= 0));
  39107. sp_521_norm_21(ctx->r);
  39108. if (hashLen > 66U) {
  39109. hashLen = 66U;
  39110. }
  39111. sp_521_from_mp(ctx->x, 21, priv);
  39112. sp_521_from_bin(ctx->e, 21, hash, (int)hashLen);
  39113. if (hashLen == 66U) {
  39114. sp_521_rshift_21(ctx->e, ctx->e, 7);
  39115. ctx->e[20] |= ((sp_digit)hash[0]) << 13;
  39116. }
  39117. ctx->state = 4;
  39118. break;
  39119. }
  39120. case 4: /* KMODORDER */
  39121. /* Conv k to Montgomery form (mod order) */
  39122. sp_521_mul_21(ctx->k, ctx->k, p521_norm_order);
  39123. err = sp_521_mod_21(ctx->k, ctx->k, p521_order);
  39124. if (err == MP_OKAY) {
  39125. sp_521_norm_21(ctx->k);
  39126. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  39127. ctx->state = 5;
  39128. }
  39129. break;
  39130. case 5: /* KINV */
  39131. /* kInv = 1/k mod order */
  39132. err = sp_521_mont_inv_order_21_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->kInv, ctx->k, ctx->tmp);
  39133. if (err == MP_OKAY) {
  39134. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  39135. ctx->state = 6;
  39136. }
  39137. break;
  39138. case 6: /* KINVNORM */
  39139. sp_521_norm_21(ctx->kInv);
  39140. ctx->state = 7;
  39141. break;
  39142. case 7: /* R */
  39143. /* s = r * x + e */
  39144. sp_521_mul_21(ctx->x, ctx->x, ctx->r);
  39145. ctx->state = 8;
  39146. break;
  39147. case 8: /* S1 */
  39148. err = sp_521_mod_21(ctx->x, ctx->x, p521_order);
  39149. if (err == MP_OKAY)
  39150. ctx->state = 9;
  39151. break;
  39152. case 9: /* S2 */
  39153. {
  39154. sp_digit carry;
  39155. sp_int32 c;
  39156. sp_521_norm_21(ctx->x);
  39157. carry = sp_521_add_21(ctx->s, ctx->e, ctx->x);
  39158. sp_521_cond_sub_21(ctx->s, ctx->s,
  39159. p521_order, 0 - carry);
  39160. sp_521_norm_21(ctx->s);
  39161. c = sp_521_cmp_21(ctx->s, p521_order);
  39162. sp_521_cond_sub_21(ctx->s, ctx->s, p521_order,
  39163. (sp_digit)0 - (sp_digit)(c >= 0));
  39164. sp_521_norm_21(ctx->s);
  39165. /* s = s * k^-1 mod order */
  39166. sp_521_mont_mul_order_21(ctx->s, ctx->s, ctx->kInv);
  39167. sp_521_norm_21(ctx->s);
  39168. /* Check that signature is usable. */
  39169. if (sp_521_iszero_21(ctx->s) == 0) {
  39170. ctx->state = 10;
  39171. break;
  39172. }
  39173. #ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
  39174. ctx->i = 1;
  39175. #endif
  39176. /* not usable gen, try again */
  39177. ctx->i--;
  39178. if (ctx->i == 0) {
  39179. err = RNG_FAILURE_E;
  39180. }
  39181. ctx->state = 1;
  39182. break;
  39183. }
  39184. case 10: /* RES */
  39185. err = sp_521_to_mp(ctx->r, rm);
  39186. if (err == MP_OKAY) {
  39187. err = sp_521_to_mp(ctx->s, sm);
  39188. }
  39189. break;
  39190. }
  39191. if (err == MP_OKAY && ctx->state != 10) {
  39192. err = FP_WOULDBLOCK;
  39193. }
  39194. if (err != FP_WOULDBLOCK) {
  39195. XMEMSET(ctx->e, 0, sizeof(sp_digit) * 2U * 21U);
  39196. XMEMSET(ctx->x, 0, sizeof(sp_digit) * 2U * 21U);
  39197. XMEMSET(ctx->k, 0, sizeof(sp_digit) * 2U * 21U);
  39198. XMEMSET(ctx->r, 0, sizeof(sp_digit) * 2U * 21U);
  39199. XMEMSET(ctx->tmp, 0, sizeof(sp_digit) * 3U * 2U * 21U);
  39200. }
  39201. return err;
  39202. }
  39203. #endif /* WOLFSSL_SP_NONBLOCK */
  39204. #endif /* HAVE_ECC_SIGN */
  39205. #ifndef WOLFSSL_SP_SMALL
  39206. static const char sp_521_tab32_21[32] = {
  39207. 1, 10, 2, 11, 14, 22, 3, 30,
  39208. 12, 15, 17, 19, 23, 26, 4, 31,
  39209. 9, 13, 21, 29, 16, 18, 25, 8,
  39210. 20, 28, 24, 7, 27, 6, 5, 32};
  39211. static int sp_521_num_bits_25_21(sp_digit v)
  39212. {
  39213. v |= v >> 1;
  39214. v |= v >> 2;
  39215. v |= v >> 4;
  39216. v |= v >> 8;
  39217. v |= v >> 16;
  39218. return sp_521_tab32_21[(uint32_t)(v*0x07C4ACDD) >> 27];
  39219. }
  39220. static int sp_521_num_bits_21(const sp_digit* a)
  39221. {
  39222. int i;
  39223. int r = 0;
  39224. for (i = 20; i >= 0; i--) {
  39225. if (a[i] != 0) {
  39226. r = sp_521_num_bits_25_21(a[i]);
  39227. r += i * 25;
  39228. break;
  39229. }
  39230. }
  39231. return r;
  39232. }
  39233. /* Non-constant time modular inversion.
  39234. *
  39235. * @param [out] r Resulting number.
  39236. * @param [in] a Number to invert.
  39237. * @param [in] m Modulus.
  39238. * @return MP_OKAY on success.
  39239. * @return MEMEORY_E when dynamic memory allocation fails.
  39240. */
  39241. static int sp_521_mod_inv_21(sp_digit* r, const sp_digit* a, const sp_digit* m)
  39242. {
  39243. int err = MP_OKAY;
  39244. #ifdef WOLFSSL_SP_SMALL_STACK
  39245. sp_digit* u = NULL;
  39246. #else
  39247. sp_digit u[21 * 4];
  39248. #endif
  39249. sp_digit* v = NULL;
  39250. sp_digit* b = NULL;
  39251. sp_digit* d = NULL;
  39252. int ut;
  39253. int vt;
  39254. #ifdef WOLFSSL_SP_SMALL_STACK
  39255. u = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21 * 4, NULL,
  39256. DYNAMIC_TYPE_ECC);
  39257. if (u == NULL)
  39258. err = MEMORY_E;
  39259. #endif
  39260. if (err == MP_OKAY) {
  39261. v = u + 21;
  39262. b = u + 2 * 21;
  39263. d = u + 3 * 21;
  39264. XMEMCPY(u, m, sizeof(sp_digit) * 21);
  39265. XMEMCPY(v, a, sizeof(sp_digit) * 21);
  39266. ut = sp_521_num_bits_21(u);
  39267. vt = sp_521_num_bits_21(v);
  39268. XMEMSET(b, 0, sizeof(sp_digit) * 21);
  39269. if ((v[0] & 1) == 0) {
  39270. sp_521_rshift1_21(v, v);
  39271. XMEMCPY(d, m, sizeof(sp_digit) * 21);
  39272. d[0]++;
  39273. sp_521_rshift1_21(d, d);
  39274. vt--;
  39275. while ((v[0] & 1) == 0) {
  39276. sp_521_rshift1_21(v, v);
  39277. if (d[0] & 1)
  39278. sp_521_add_21(d, d, m);
  39279. sp_521_rshift1_21(d, d);
  39280. vt--;
  39281. }
  39282. }
  39283. else {
  39284. XMEMSET(d+1, 0, sizeof(sp_digit) * (21 - 1));
  39285. d[0] = 1;
  39286. }
  39287. while (ut > 1 && vt > 1) {
  39288. if ((ut > vt) || ((ut == vt) &&
  39289. (sp_521_cmp_21(u, v) >= 0))) {
  39290. sp_521_sub_21(u, u, v);
  39291. sp_521_norm_21(u);
  39292. sp_521_sub_21(b, b, d);
  39293. sp_521_norm_21(b);
  39294. if (b[20] < 0)
  39295. sp_521_add_21(b, b, m);
  39296. sp_521_norm_21(b);
  39297. ut = sp_521_num_bits_21(u);
  39298. do {
  39299. sp_521_rshift1_21(u, u);
  39300. if (b[0] & 1)
  39301. sp_521_add_21(b, b, m);
  39302. sp_521_rshift1_21(b, b);
  39303. ut--;
  39304. }
  39305. while (ut > 0 && (u[0] & 1) == 0);
  39306. }
  39307. else {
  39308. sp_521_sub_21(v, v, u);
  39309. sp_521_norm_21(v);
  39310. sp_521_sub_21(d, d, b);
  39311. sp_521_norm_21(d);
  39312. if (d[20] < 0)
  39313. sp_521_add_21(d, d, m);
  39314. sp_521_norm_21(d);
  39315. vt = sp_521_num_bits_21(v);
  39316. do {
  39317. sp_521_rshift1_21(v, v);
  39318. if (d[0] & 1)
  39319. sp_521_add_21(d, d, m);
  39320. sp_521_rshift1_21(d, d);
  39321. vt--;
  39322. }
  39323. while (vt > 0 && (v[0] & 1) == 0);
  39324. }
  39325. }
  39326. if (ut == 1)
  39327. XMEMCPY(r, b, sizeof(sp_digit) * 21);
  39328. else
  39329. XMEMCPY(r, d, sizeof(sp_digit) * 21);
  39330. }
  39331. #ifdef WOLFSSL_SP_SMALL_STACK
  39332. if (u != NULL)
  39333. XFREE(u, NULL, DYNAMIC_TYPE_ECC);
  39334. #endif
  39335. return err;
  39336. }
  39337. #endif /* WOLFSSL_SP_SMALL */
  39338. /* Add point p1 into point p2. Handles p1 == p2 and result at infinity.
  39339. *
  39340. * p1 First point to add and holds result.
  39341. * p2 Second point to add.
  39342. * tmp Temporary storage for intermediate numbers.
  39343. */
  39344. static void sp_521_add_points_21(sp_point_521* p1, const sp_point_521* p2,
  39345. sp_digit* tmp)
  39346. {
  39347. sp_521_proj_point_add_21(p1, p1, p2, tmp);
  39348. if (sp_521_iszero_21(p1->z)) {
  39349. if (sp_521_iszero_21(p1->x) && sp_521_iszero_21(p1->y)) {
  39350. sp_521_proj_point_dbl_21(p1, p2, tmp);
  39351. }
  39352. else {
  39353. /* Y ordinate is not used from here - don't set. */
  39354. p1->x[0] = 0;
  39355. p1->x[1] = 0;
  39356. p1->x[2] = 0;
  39357. p1->x[3] = 0;
  39358. p1->x[4] = 0;
  39359. p1->x[5] = 0;
  39360. p1->x[6] = 0;
  39361. p1->x[7] = 0;
  39362. p1->x[8] = 0;
  39363. p1->x[9] = 0;
  39364. p1->x[10] = 0;
  39365. p1->x[11] = 0;
  39366. p1->x[12] = 0;
  39367. p1->x[13] = 0;
  39368. p1->x[14] = 0;
  39369. p1->x[15] = 0;
  39370. p1->x[16] = 0;
  39371. p1->x[17] = 0;
  39372. p1->x[18] = 0;
  39373. p1->x[19] = 0;
  39374. p1->x[20] = 0;
  39375. XMEMCPY(p1->z, p521_norm_mod, sizeof(p521_norm_mod));
  39376. }
  39377. }
  39378. }
  39379. /* Calculate the verification point: [e/s]G + [r/s]Q
  39380. *
  39381. * p1 Calculated point.
  39382. * p2 Public point and temporary.
  39383. * s Second part of signature as a number.
  39384. * u1 Temporary number.
  39385. * u2 Temporary number.
  39386. * heap Heap to use for allocation.
  39387. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  39388. */
  39389. static int sp_521_calc_vfy_point_21(sp_point_521* p1, sp_point_521* p2,
  39390. sp_digit* s, sp_digit* u1, sp_digit* u2, sp_digit* tmp, void* heap)
  39391. {
  39392. int err;
  39393. #ifndef WOLFSSL_SP_SMALL
  39394. err = sp_521_mod_inv_21(s, s, p521_order);
  39395. if (err == MP_OKAY)
  39396. #endif /* !WOLFSSL_SP_SMALL */
  39397. {
  39398. sp_521_mul_21(s, s, p521_norm_order);
  39399. err = sp_521_mod_21(s, s, p521_order);
  39400. }
  39401. if (err == MP_OKAY) {
  39402. sp_521_norm_21(s);
  39403. #ifdef WOLFSSL_SP_SMALL
  39404. {
  39405. sp_521_mont_inv_order_21(s, s, tmp);
  39406. sp_521_mont_mul_order_21(u1, u1, s);
  39407. sp_521_mont_mul_order_21(u2, u2, s);
  39408. }
  39409. #else
  39410. {
  39411. sp_521_mont_mul_order_21(u1, u1, s);
  39412. sp_521_mont_mul_order_21(u2, u2, s);
  39413. }
  39414. #endif /* WOLFSSL_SP_SMALL */
  39415. {
  39416. err = sp_521_ecc_mulmod_base_21(p1, u1, 0, 0, heap);
  39417. }
  39418. }
  39419. if ((err == MP_OKAY) && sp_521_iszero_21(p1->z)) {
  39420. p1->infinity = 1;
  39421. }
  39422. if (err == MP_OKAY) {
  39423. err = sp_521_ecc_mulmod_21(p2, p2, u2, 0, 0, heap);
  39424. }
  39425. if ((err == MP_OKAY) && sp_521_iszero_21(p2->z)) {
  39426. p2->infinity = 1;
  39427. }
  39428. if (err == MP_OKAY) {
  39429. sp_521_add_points_21(p1, p2, tmp);
  39430. }
  39431. return err;
  39432. }
  39433. #ifdef HAVE_ECC_VERIFY
  39434. /* Verify the signature values with the hash and public key.
  39435. * e = Truncate(hash, 521)
  39436. * u1 = e/s mod order
  39437. * u2 = r/s mod order
  39438. * r == (u1.G + u2.Q)->x mod order
  39439. * Optimization: Leave point in projective form.
  39440. * (x, y, 1) == (x' / z'*z', y' / z'*z'*z', z' / z')
  39441. * (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x'
  39442. * The hash is truncated to the first 521 bits.
  39443. *
  39444. * hash Hash to sign.
  39445. * hashLen Length of the hash data.
  39446. * rng Random number generator.
  39447. * priv Private part of key - scalar.
  39448. * rm First part of result as an mp_int.
  39449. * sm Sirst part of result as an mp_int.
  39450. * heap Heap to use for allocation.
  39451. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  39452. */
  39453. int sp_ecc_verify_521(const byte* hash, word32 hashLen, const mp_int* pX,
  39454. const mp_int* pY, const mp_int* pZ, const mp_int* rm, const mp_int* sm,
  39455. int* res, void* heap)
  39456. {
  39457. #ifdef WOLFSSL_SP_SMALL_STACK
  39458. sp_digit* u1 = NULL;
  39459. sp_point_521* p1 = NULL;
  39460. #else
  39461. sp_digit u1[18 * 21];
  39462. sp_point_521 p1[2];
  39463. #endif
  39464. sp_digit* u2 = NULL;
  39465. sp_digit* s = NULL;
  39466. sp_digit* tmp = NULL;
  39467. sp_point_521* p2 = NULL;
  39468. sp_digit carry;
  39469. sp_int32 c = 0;
  39470. int err = MP_OKAY;
  39471. #ifdef WOLFSSL_SP_SMALL_STACK
  39472. if (err == MP_OKAY) {
  39473. p1 = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap,
  39474. DYNAMIC_TYPE_ECC);
  39475. if (p1 == NULL)
  39476. err = MEMORY_E;
  39477. }
  39478. if (err == MP_OKAY) {
  39479. u1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 18 * 21, heap,
  39480. DYNAMIC_TYPE_ECC);
  39481. if (u1 == NULL)
  39482. err = MEMORY_E;
  39483. }
  39484. #endif
  39485. if (err == MP_OKAY) {
  39486. u2 = u1 + 2 * 21;
  39487. s = u1 + 4 * 21;
  39488. tmp = u1 + 6 * 21;
  39489. p2 = p1 + 1;
  39490. if (hashLen > 66U) {
  39491. hashLen = 66U;
  39492. }
  39493. sp_521_from_bin(u1, 21, hash, (int)hashLen);
  39494. sp_521_from_mp(u2, 21, rm);
  39495. sp_521_from_mp(s, 21, sm);
  39496. sp_521_from_mp(p2->x, 21, pX);
  39497. sp_521_from_mp(p2->y, 21, pY);
  39498. sp_521_from_mp(p2->z, 21, pZ);
  39499. if (hashLen == 66U) {
  39500. sp_521_rshift_21(u1, u1, 7);
  39501. u1[20] |= ((sp_digit)hash[0]) << 13;
  39502. }
  39503. err = sp_521_calc_vfy_point_21(p1, p2, s, u1, u2, tmp, heap);
  39504. }
  39505. if (err == MP_OKAY) {
  39506. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  39507. /* Reload r and convert to Montgomery form. */
  39508. sp_521_from_mp(u2, 21, rm);
  39509. err = sp_521_mod_mul_norm_21(u2, u2, p521_mod);
  39510. }
  39511. if (err == MP_OKAY) {
  39512. /* u1 = r.z'.z' mod prime */
  39513. sp_521_mont_sqr_21(p1->z, p1->z, p521_mod, p521_mp_mod);
  39514. sp_521_mont_mul_21(u1, u2, p1->z, p521_mod, p521_mp_mod);
  39515. *res = (int)(sp_521_cmp_21(p1->x, u1) == 0);
  39516. if (*res == 0) {
  39517. /* Reload r and add order. */
  39518. sp_521_from_mp(u2, 21, rm);
  39519. carry = sp_521_add_21(u2, u2, p521_order);
  39520. /* Carry means result is greater than mod and is not valid. */
  39521. if (carry == 0) {
  39522. sp_521_norm_21(u2);
  39523. /* Compare with mod and if greater or equal then not valid. */
  39524. c = sp_521_cmp_21(u2, p521_mod);
  39525. }
  39526. }
  39527. if ((*res == 0) && (c < 0)) {
  39528. /* Convert to Montogomery form */
  39529. err = sp_521_mod_mul_norm_21(u2, u2, p521_mod);
  39530. if (err == MP_OKAY) {
  39531. /* u1 = (r + 1*order).z'.z' mod prime */
  39532. {
  39533. sp_521_mont_mul_21(u1, u2, p1->z, p521_mod, p521_mp_mod);
  39534. }
  39535. *res = (sp_521_cmp_21(p1->x, u1) == 0);
  39536. }
  39537. }
  39538. }
  39539. #ifdef WOLFSSL_SP_SMALL_STACK
  39540. if (u1 != NULL)
  39541. XFREE(u1, heap, DYNAMIC_TYPE_ECC);
  39542. if (p1 != NULL)
  39543. XFREE(p1, heap, DYNAMIC_TYPE_ECC);
  39544. #endif
  39545. return err;
  39546. }
  39547. #ifdef WOLFSSL_SP_NONBLOCK
  39548. typedef struct sp_ecc_verify_521_ctx {
  39549. int state;
  39550. union {
  39551. sp_521_ecc_mulmod_21_ctx mulmod_ctx;
  39552. sp_521_mont_inv_order_21_ctx mont_inv_order_ctx;
  39553. sp_521_proj_point_dbl_21_ctx dbl_ctx;
  39554. sp_521_proj_point_add_21_ctx add_ctx;
  39555. };
  39556. sp_digit u1[2*21];
  39557. sp_digit u2[2*21];
  39558. sp_digit s[2*21];
  39559. sp_digit tmp[2*21 * 6];
  39560. sp_point_521 p1;
  39561. sp_point_521 p2;
  39562. } sp_ecc_verify_521_ctx;
  39563. int sp_ecc_verify_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash,
  39564. word32 hashLen, const mp_int* pX, const mp_int* pY, const mp_int* pZ,
  39565. const mp_int* rm, const mp_int* sm, int* res, void* heap)
  39566. {
  39567. int err = FP_WOULDBLOCK;
  39568. sp_ecc_verify_521_ctx* ctx = (sp_ecc_verify_521_ctx*)sp_ctx->data;
  39569. typedef char ctx_size_test[sizeof(sp_ecc_verify_521_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  39570. (void)sizeof(ctx_size_test);
  39571. switch (ctx->state) {
  39572. case 0: /* INIT */
  39573. if (hashLen > 66U) {
  39574. hashLen = 66U;
  39575. }
  39576. sp_521_from_bin(ctx->u1, 21, hash, (int)hashLen);
  39577. sp_521_from_mp(ctx->u2, 21, rm);
  39578. sp_521_from_mp(ctx->s, 21, sm);
  39579. sp_521_from_mp(ctx->p2.x, 21, pX);
  39580. sp_521_from_mp(ctx->p2.y, 21, pY);
  39581. sp_521_from_mp(ctx->p2.z, 21, pZ);
  39582. if (hashLen == 66U) {
  39583. sp_521_rshift_21(ctx->u1, ctx->u1, 7);
  39584. ctx->u1[20] |= ((sp_digit)hash[0]) << 13;
  39585. }
  39586. ctx->state = 1;
  39587. break;
  39588. case 1: /* NORMS0 */
  39589. sp_521_mul_21(ctx->s, ctx->s, p521_norm_order);
  39590. err = sp_521_mod_21(ctx->s, ctx->s, p521_order);
  39591. if (err == MP_OKAY)
  39592. ctx->state = 2;
  39593. break;
  39594. case 2: /* NORMS1 */
  39595. sp_521_norm_21(ctx->s);
  39596. XMEMSET(&ctx->mont_inv_order_ctx, 0, sizeof(ctx->mont_inv_order_ctx));
  39597. ctx->state = 3;
  39598. break;
  39599. case 3: /* NORMS2 */
  39600. err = sp_521_mont_inv_order_21_nb((sp_ecc_ctx_t*)&ctx->mont_inv_order_ctx, ctx->s, ctx->s, ctx->tmp);
  39601. if (err == MP_OKAY) {
  39602. ctx->state = 4;
  39603. }
  39604. break;
  39605. case 4: /* NORMS3 */
  39606. sp_521_mont_mul_order_21(ctx->u1, ctx->u1, ctx->s);
  39607. ctx->state = 5;
  39608. break;
  39609. case 5: /* NORMS4 */
  39610. sp_521_mont_mul_order_21(ctx->u2, ctx->u2, ctx->s);
  39611. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  39612. ctx->state = 6;
  39613. break;
  39614. case 6: /* MULBASE */
  39615. err = sp_521_ecc_mulmod_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p1, &p521_base, ctx->u1, 0, 0, heap);
  39616. if (err == MP_OKAY) {
  39617. if (sp_521_iszero_21(ctx->p1.z)) {
  39618. ctx->p1.infinity = 1;
  39619. }
  39620. XMEMSET(&ctx->mulmod_ctx, 0, sizeof(ctx->mulmod_ctx));
  39621. ctx->state = 7;
  39622. }
  39623. break;
  39624. case 7: /* MULMOD */
  39625. err = sp_521_ecc_mulmod_21_nb((sp_ecc_ctx_t*)&ctx->mulmod_ctx, &ctx->p2, &ctx->p2, ctx->u2, 0, 0, heap);
  39626. if (err == MP_OKAY) {
  39627. if (sp_521_iszero_21(ctx->p2.z)) {
  39628. ctx->p2.infinity = 1;
  39629. }
  39630. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  39631. ctx->state = 8;
  39632. }
  39633. break;
  39634. case 8: /* ADD */
  39635. err = sp_521_proj_point_add_21_nb((sp_ecc_ctx_t*)&ctx->add_ctx, &ctx->p1, &ctx->p1, &ctx->p2, ctx->tmp);
  39636. if (err == MP_OKAY)
  39637. ctx->state = 9;
  39638. break;
  39639. case 9: /* MONT */
  39640. /* (r + n*order).z'.z' mod prime == (u1.G + u2.Q)->x' */
  39641. /* Reload r and convert to Montgomery form. */
  39642. sp_521_from_mp(ctx->u2, 21, rm);
  39643. err = sp_521_mod_mul_norm_21(ctx->u2, ctx->u2, p521_mod);
  39644. if (err == MP_OKAY)
  39645. ctx->state = 10;
  39646. break;
  39647. case 10: /* SQR */
  39648. /* u1 = r.z'.z' mod prime */
  39649. sp_521_mont_sqr_21(ctx->p1.z, ctx->p1.z, p521_mod, p521_mp_mod);
  39650. ctx->state = 11;
  39651. break;
  39652. case 11: /* MUL */
  39653. sp_521_mont_mul_21(ctx->u1, ctx->u2, ctx->p1.z, p521_mod, p521_mp_mod);
  39654. ctx->state = 12;
  39655. break;
  39656. case 12: /* RES */
  39657. {
  39658. sp_int32 c = 0;
  39659. err = MP_OKAY; /* math okay, now check result */
  39660. *res = (int)(sp_521_cmp_21(ctx->p1.x, ctx->u1) == 0);
  39661. if (*res == 0) {
  39662. sp_digit carry;
  39663. /* Reload r and add order. */
  39664. sp_521_from_mp(ctx->u2, 21, rm);
  39665. carry = sp_521_add_21(ctx->u2, ctx->u2, p521_order);
  39666. /* Carry means result is greater than mod and is not valid. */
  39667. if (carry == 0) {
  39668. sp_521_norm_21(ctx->u2);
  39669. /* Compare with mod and if greater or equal then not valid. */
  39670. c = sp_521_cmp_21(ctx->u2, p521_mod);
  39671. }
  39672. }
  39673. if ((*res == 0) && (c < 0)) {
  39674. /* Convert to Montogomery form */
  39675. err = sp_521_mod_mul_norm_21(ctx->u2, ctx->u2, p521_mod);
  39676. if (err == MP_OKAY) {
  39677. /* u1 = (r + 1*order).z'.z' mod prime */
  39678. sp_521_mont_mul_21(ctx->u1, ctx->u2, ctx->p1.z, p521_mod,
  39679. p521_mp_mod);
  39680. *res = (int)(sp_521_cmp_21(ctx->p1.x, ctx->u1) == 0);
  39681. }
  39682. }
  39683. break;
  39684. }
  39685. } /* switch */
  39686. if (err == MP_OKAY && ctx->state != 12) {
  39687. err = FP_WOULDBLOCK;
  39688. }
  39689. return err;
  39690. }
  39691. #endif /* WOLFSSL_SP_NONBLOCK */
  39692. #endif /* HAVE_ECC_VERIFY */
  39693. #ifdef HAVE_ECC_CHECK_KEY
  39694. /* Check that the x and y ordinates are a valid point on the curve.
  39695. *
  39696. * point EC point.
  39697. * heap Heap to use if dynamically allocating.
  39698. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  39699. * not on the curve and MP_OKAY otherwise.
  39700. */
  39701. static int sp_521_ecc_is_point_21(const sp_point_521* point,
  39702. void* heap)
  39703. {
  39704. #ifdef WOLFSSL_SP_SMALL_STACK
  39705. sp_digit* t1 = NULL;
  39706. #else
  39707. sp_digit t1[21 * 4];
  39708. #endif
  39709. sp_digit* t2 = NULL;
  39710. int err = MP_OKAY;
  39711. #ifdef WOLFSSL_SP_SMALL_STACK
  39712. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21 * 4, heap, DYNAMIC_TYPE_ECC);
  39713. if (t1 == NULL)
  39714. err = MEMORY_E;
  39715. #endif
  39716. (void)heap;
  39717. if (err == MP_OKAY) {
  39718. t2 = t1 + 2 * 21;
  39719. /* y^2 - x^3 - a.x = b */
  39720. sp_521_sqr_21(t1, point->y);
  39721. (void)sp_521_mod_21(t1, t1, p521_mod);
  39722. sp_521_sqr_21(t2, point->x);
  39723. (void)sp_521_mod_21(t2, t2, p521_mod);
  39724. sp_521_mul_21(t2, t2, point->x);
  39725. (void)sp_521_mod_21(t2, t2, p521_mod);
  39726. sp_521_mont_sub_21(t1, t1, t2, p521_mod);
  39727. /* y^2 - x^3 + 3.x = b, when a = -3 */
  39728. sp_521_mont_add_21(t1, t1, point->x, p521_mod);
  39729. sp_521_mont_add_21(t1, t1, point->x, p521_mod);
  39730. sp_521_mont_add_21(t1, t1, point->x, p521_mod);
  39731. if (sp_521_cmp_21(t1, p521_b) != 0) {
  39732. err = MP_VAL;
  39733. }
  39734. }
  39735. #ifdef WOLFSSL_SP_SMALL_STACK
  39736. if (t1 != NULL)
  39737. XFREE(t1, heap, DYNAMIC_TYPE_ECC);
  39738. #endif
  39739. return err;
  39740. }
  39741. /* Check that the x and y ordinates are a valid point on the curve.
  39742. *
  39743. * pX X ordinate of EC point.
  39744. * pY Y ordinate of EC point.
  39745. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  39746. * not on the curve and MP_OKAY otherwise.
  39747. */
  39748. int sp_ecc_is_point_521(const mp_int* pX, const mp_int* pY)
  39749. {
  39750. #ifdef WOLFSSL_SP_SMALL_STACK
  39751. sp_point_521* pub = NULL;
  39752. #else
  39753. sp_point_521 pub[1];
  39754. #endif
  39755. const byte one[1] = { 1 };
  39756. int err = MP_OKAY;
  39757. #ifdef WOLFSSL_SP_SMALL_STACK
  39758. pub = (sp_point_521*)XMALLOC(sizeof(sp_point_521), NULL,
  39759. DYNAMIC_TYPE_ECC);
  39760. if (pub == NULL)
  39761. err = MEMORY_E;
  39762. #endif
  39763. if (err == MP_OKAY) {
  39764. sp_521_from_mp(pub->x, 21, pX);
  39765. sp_521_from_mp(pub->y, 21, pY);
  39766. sp_521_from_bin(pub->z, 21, one, (int)sizeof(one));
  39767. err = sp_521_ecc_is_point_21(pub, NULL);
  39768. }
  39769. #ifdef WOLFSSL_SP_SMALL_STACK
  39770. if (pub != NULL)
  39771. XFREE(pub, NULL, DYNAMIC_TYPE_ECC);
  39772. #endif
  39773. return err;
  39774. }
  39775. /* Check that the private scalar generates the EC point (px, py), the point is
  39776. * on the curve and the point has the correct order.
  39777. *
  39778. * pX X ordinate of EC point.
  39779. * pY Y ordinate of EC point.
  39780. * privm Private scalar that generates EC point.
  39781. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  39782. * not on the curve, ECC_INF_E if the point does not have the correct order,
  39783. * ECC_PRIV_KEY_E when the private scalar doesn't generate the EC point and
  39784. * MP_OKAY otherwise.
  39785. */
  39786. int sp_ecc_check_key_521(const mp_int* pX, const mp_int* pY,
  39787. const mp_int* privm, void* heap)
  39788. {
  39789. #ifdef WOLFSSL_SP_SMALL_STACK
  39790. sp_digit* priv = NULL;
  39791. sp_point_521* pub = NULL;
  39792. #else
  39793. sp_digit priv[21];
  39794. sp_point_521 pub[2];
  39795. #endif
  39796. sp_point_521* p = NULL;
  39797. const byte one[1] = { 1 };
  39798. int err = MP_OKAY;
  39799. /* Quick check the lengs of public key ordinates and private key are in
  39800. * range. Proper check later.
  39801. */
  39802. if (((mp_count_bits(pX) > 521) ||
  39803. (mp_count_bits(pY) > 521) ||
  39804. ((privm != NULL) && (mp_count_bits(privm) > 521)))) {
  39805. err = ECC_OUT_OF_RANGE_E;
  39806. }
  39807. #ifdef WOLFSSL_SP_SMALL_STACK
  39808. if (err == MP_OKAY) {
  39809. pub = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, heap,
  39810. DYNAMIC_TYPE_ECC);
  39811. if (pub == NULL)
  39812. err = MEMORY_E;
  39813. }
  39814. if (err == MP_OKAY && privm) {
  39815. priv = (sp_digit*)XMALLOC(sizeof(sp_digit) * 21, heap,
  39816. DYNAMIC_TYPE_ECC);
  39817. if (priv == NULL)
  39818. err = MEMORY_E;
  39819. }
  39820. #endif
  39821. if (err == MP_OKAY) {
  39822. p = pub + 1;
  39823. sp_521_from_mp(pub->x, 21, pX);
  39824. sp_521_from_mp(pub->y, 21, pY);
  39825. sp_521_from_bin(pub->z, 21, one, (int)sizeof(one));
  39826. if (privm)
  39827. sp_521_from_mp(priv, 21, privm);
  39828. /* Check point at infinitiy. */
  39829. if ((sp_521_iszero_21(pub->x) != 0) &&
  39830. (sp_521_iszero_21(pub->y) != 0)) {
  39831. err = ECC_INF_E;
  39832. }
  39833. }
  39834. /* Check range of X and Y */
  39835. if ((err == MP_OKAY) &&
  39836. ((sp_521_cmp_21(pub->x, p521_mod) >= 0) ||
  39837. (sp_521_cmp_21(pub->y, p521_mod) >= 0))) {
  39838. err = ECC_OUT_OF_RANGE_E;
  39839. }
  39840. if (err == MP_OKAY) {
  39841. /* Check point is on curve */
  39842. err = sp_521_ecc_is_point_21(pub, heap);
  39843. }
  39844. if (err == MP_OKAY) {
  39845. /* Point * order = infinity */
  39846. err = sp_521_ecc_mulmod_21(p, pub, p521_order, 1, 1, heap);
  39847. }
  39848. /* Check result is infinity */
  39849. if ((err == MP_OKAY) && ((sp_521_iszero_21(p->x) == 0) ||
  39850. (sp_521_iszero_21(p->y) == 0))) {
  39851. err = ECC_INF_E;
  39852. }
  39853. if (privm) {
  39854. if (err == MP_OKAY) {
  39855. /* Base * private = point */
  39856. err = sp_521_ecc_mulmod_base_21(p, priv, 1, 1, heap);
  39857. }
  39858. /* Check result is public key */
  39859. if ((err == MP_OKAY) &&
  39860. ((sp_521_cmp_21(p->x, pub->x) != 0) ||
  39861. (sp_521_cmp_21(p->y, pub->y) != 0))) {
  39862. err = ECC_PRIV_KEY_E;
  39863. }
  39864. }
  39865. #ifdef WOLFSSL_SP_SMALL_STACK
  39866. if (pub != NULL)
  39867. XFREE(pub, heap, DYNAMIC_TYPE_ECC);
  39868. if (priv != NULL)
  39869. XFREE(priv, heap, DYNAMIC_TYPE_ECC);
  39870. #endif
  39871. return err;
  39872. }
  39873. #endif
  39874. #ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
  39875. /* Add two projective EC points together.
  39876. * (pX, pY, pZ) + (qX, qY, qZ) = (rX, rY, rZ)
  39877. *
  39878. * pX First EC point's X ordinate.
  39879. * pY First EC point's Y ordinate.
  39880. * pZ First EC point's Z ordinate.
  39881. * qX Second EC point's X ordinate.
  39882. * qY Second EC point's Y ordinate.
  39883. * qZ Second EC point's Z ordinate.
  39884. * rX Resultant EC point's X ordinate.
  39885. * rY Resultant EC point's Y ordinate.
  39886. * rZ Resultant EC point's Z ordinate.
  39887. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  39888. */
  39889. int sp_ecc_proj_add_point_521(mp_int* pX, mp_int* pY, mp_int* pZ,
  39890. mp_int* qX, mp_int* qY, mp_int* qZ,
  39891. mp_int* rX, mp_int* rY, mp_int* rZ)
  39892. {
  39893. #ifdef WOLFSSL_SP_SMALL_STACK
  39894. sp_digit* tmp = NULL;
  39895. sp_point_521* p = NULL;
  39896. #else
  39897. sp_digit tmp[2 * 21 * 6];
  39898. sp_point_521 p[2];
  39899. #endif
  39900. sp_point_521* q = NULL;
  39901. int err = MP_OKAY;
  39902. #ifdef WOLFSSL_SP_SMALL_STACK
  39903. if (err == MP_OKAY) {
  39904. p = (sp_point_521*)XMALLOC(sizeof(sp_point_521) * 2, NULL,
  39905. DYNAMIC_TYPE_ECC);
  39906. if (p == NULL)
  39907. err = MEMORY_E;
  39908. }
  39909. if (err == MP_OKAY) {
  39910. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 6, NULL,
  39911. DYNAMIC_TYPE_ECC);
  39912. if (tmp == NULL) {
  39913. err = MEMORY_E;
  39914. }
  39915. }
  39916. #endif
  39917. if (err == MP_OKAY) {
  39918. q = p + 1;
  39919. sp_521_from_mp(p->x, 21, pX);
  39920. sp_521_from_mp(p->y, 21, pY);
  39921. sp_521_from_mp(p->z, 21, pZ);
  39922. sp_521_from_mp(q->x, 21, qX);
  39923. sp_521_from_mp(q->y, 21, qY);
  39924. sp_521_from_mp(q->z, 21, qZ);
  39925. p->infinity = sp_521_iszero_21(p->x) &
  39926. sp_521_iszero_21(p->y);
  39927. q->infinity = sp_521_iszero_21(q->x) &
  39928. sp_521_iszero_21(q->y);
  39929. sp_521_proj_point_add_21(p, p, q, tmp);
  39930. }
  39931. if (err == MP_OKAY) {
  39932. err = sp_521_to_mp(p->x, rX);
  39933. }
  39934. if (err == MP_OKAY) {
  39935. err = sp_521_to_mp(p->y, rY);
  39936. }
  39937. if (err == MP_OKAY) {
  39938. err = sp_521_to_mp(p->z, rZ);
  39939. }
  39940. #ifdef WOLFSSL_SP_SMALL_STACK
  39941. if (tmp != NULL)
  39942. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  39943. if (p != NULL)
  39944. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  39945. #endif
  39946. return err;
  39947. }
  39948. /* Double a projective EC point.
  39949. * (pX, pY, pZ) + (pX, pY, pZ) = (rX, rY, rZ)
  39950. *
  39951. * pX EC point's X ordinate.
  39952. * pY EC point's Y ordinate.
  39953. * pZ EC point's Z ordinate.
  39954. * rX Resultant EC point's X ordinate.
  39955. * rY Resultant EC point's Y ordinate.
  39956. * rZ Resultant EC point's Z ordinate.
  39957. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  39958. */
  39959. int sp_ecc_proj_dbl_point_521(mp_int* pX, mp_int* pY, mp_int* pZ,
  39960. mp_int* rX, mp_int* rY, mp_int* rZ)
  39961. {
  39962. #ifdef WOLFSSL_SP_SMALL_STACK
  39963. sp_digit* tmp = NULL;
  39964. sp_point_521* p = NULL;
  39965. #else
  39966. sp_digit tmp[2 * 21 * 2];
  39967. sp_point_521 p[1];
  39968. #endif
  39969. int err = MP_OKAY;
  39970. #ifdef WOLFSSL_SP_SMALL_STACK
  39971. if (err == MP_OKAY) {
  39972. p = (sp_point_521*)XMALLOC(sizeof(sp_point_521), NULL,
  39973. DYNAMIC_TYPE_ECC);
  39974. if (p == NULL)
  39975. err = MEMORY_E;
  39976. }
  39977. if (err == MP_OKAY) {
  39978. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 2, NULL,
  39979. DYNAMIC_TYPE_ECC);
  39980. if (tmp == NULL)
  39981. err = MEMORY_E;
  39982. }
  39983. #endif
  39984. if (err == MP_OKAY) {
  39985. sp_521_from_mp(p->x, 21, pX);
  39986. sp_521_from_mp(p->y, 21, pY);
  39987. sp_521_from_mp(p->z, 21, pZ);
  39988. p->infinity = sp_521_iszero_21(p->x) &
  39989. sp_521_iszero_21(p->y);
  39990. sp_521_proj_point_dbl_21(p, p, tmp);
  39991. }
  39992. if (err == MP_OKAY) {
  39993. err = sp_521_to_mp(p->x, rX);
  39994. }
  39995. if (err == MP_OKAY) {
  39996. err = sp_521_to_mp(p->y, rY);
  39997. }
  39998. if (err == MP_OKAY) {
  39999. err = sp_521_to_mp(p->z, rZ);
  40000. }
  40001. #ifdef WOLFSSL_SP_SMALL_STACK
  40002. if (tmp != NULL)
  40003. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  40004. if (p != NULL)
  40005. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  40006. #endif
  40007. return err;
  40008. }
  40009. /* Map a projective EC point to affine in place.
  40010. * pZ will be one.
  40011. *
  40012. * pX EC point's X ordinate.
  40013. * pY EC point's Y ordinate.
  40014. * pZ EC point's Z ordinate.
  40015. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  40016. */
  40017. int sp_ecc_map_521(mp_int* pX, mp_int* pY, mp_int* pZ)
  40018. {
  40019. #ifdef WOLFSSL_SP_SMALL_STACK
  40020. sp_digit* tmp = NULL;
  40021. sp_point_521* p = NULL;
  40022. #else
  40023. sp_digit tmp[2 * 21 * 5];
  40024. sp_point_521 p[1];
  40025. #endif
  40026. int err = MP_OKAY;
  40027. #ifdef WOLFSSL_SP_SMALL_STACK
  40028. if (err == MP_OKAY) {
  40029. p = (sp_point_521*)XMALLOC(sizeof(sp_point_521), NULL,
  40030. DYNAMIC_TYPE_ECC);
  40031. if (p == NULL)
  40032. err = MEMORY_E;
  40033. }
  40034. if (err == MP_OKAY) {
  40035. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21 * 5, NULL,
  40036. DYNAMIC_TYPE_ECC);
  40037. if (tmp == NULL)
  40038. err = MEMORY_E;
  40039. }
  40040. #endif
  40041. if (err == MP_OKAY) {
  40042. sp_521_from_mp(p->x, 21, pX);
  40043. sp_521_from_mp(p->y, 21, pY);
  40044. sp_521_from_mp(p->z, 21, pZ);
  40045. p->infinity = sp_521_iszero_21(p->x) &
  40046. sp_521_iszero_21(p->y);
  40047. sp_521_map_21(p, p, tmp);
  40048. }
  40049. if (err == MP_OKAY) {
  40050. err = sp_521_to_mp(p->x, pX);
  40051. }
  40052. if (err == MP_OKAY) {
  40053. err = sp_521_to_mp(p->y, pY);
  40054. }
  40055. if (err == MP_OKAY) {
  40056. err = sp_521_to_mp(p->z, pZ);
  40057. }
  40058. #ifdef WOLFSSL_SP_SMALL_STACK
  40059. if (tmp != NULL)
  40060. XFREE(tmp, NULL, DYNAMIC_TYPE_ECC);
  40061. if (p != NULL)
  40062. XFREE(p, NULL, DYNAMIC_TYPE_ECC);
  40063. #endif
  40064. return err;
  40065. }
  40066. #endif /* WOLFSSL_PUBLIC_ECC_ADD_DBL */
  40067. #ifdef HAVE_COMP_KEY
  40068. /* Square root power for the P521 curve. */
  40069. static const uint32_t p521_sqrt_power[17] = {
  40070. 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  40071. 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
  40072. 0x00000000,0x00000000,0x00000080
  40073. };
  40074. /* Find the square root of a number mod the prime of the curve.
  40075. *
  40076. * y The number to operate on and the result.
  40077. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  40078. */
  40079. static int sp_521_mont_sqrt_21(sp_digit* y)
  40080. {
  40081. #ifdef WOLFSSL_SP_SMALL_STACK
  40082. sp_digit* t = NULL;
  40083. #else
  40084. sp_digit t[2 * 21];
  40085. #endif
  40086. int err = MP_OKAY;
  40087. #ifdef WOLFSSL_SP_SMALL_STACK
  40088. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 21, NULL, DYNAMIC_TYPE_ECC);
  40089. if (t == NULL)
  40090. err = MEMORY_E;
  40091. #endif
  40092. if (err == MP_OKAY) {
  40093. {
  40094. int i;
  40095. XMEMCPY(t, y, sizeof(sp_digit) * 21);
  40096. for (i=518; i>=0; i--) {
  40097. sp_521_mont_sqr_21(t, t, p521_mod, p521_mp_mod);
  40098. if (p521_sqrt_power[i / 32] & ((sp_digit)1 << (i % 32)))
  40099. sp_521_mont_mul_21(t, t, y, p521_mod, p521_mp_mod);
  40100. }
  40101. XMEMCPY(y, t, sizeof(sp_digit) * 21);
  40102. }
  40103. }
  40104. #ifdef WOLFSSL_SP_SMALL_STACK
  40105. if (t != NULL)
  40106. XFREE(t, NULL, DYNAMIC_TYPE_ECC);
  40107. #endif
  40108. return err;
  40109. }
  40110. /* Uncompress the point given the X ordinate.
  40111. *
  40112. * xm X ordinate.
  40113. * odd Whether the Y ordinate is odd.
  40114. * ym Calculated Y ordinate.
  40115. * returns MEMORY_E if dynamic memory allocation fails and MP_OKAY otherwise.
  40116. */
  40117. int sp_ecc_uncompress_521(mp_int* xm, int odd, mp_int* ym)
  40118. {
  40119. #ifdef WOLFSSL_SP_SMALL_STACK
  40120. sp_digit* x = NULL;
  40121. #else
  40122. sp_digit x[4 * 21];
  40123. #endif
  40124. sp_digit* y = NULL;
  40125. int err = MP_OKAY;
  40126. #ifdef WOLFSSL_SP_SMALL_STACK
  40127. x = (sp_digit*)XMALLOC(sizeof(sp_digit) * 4 * 21, NULL, DYNAMIC_TYPE_ECC);
  40128. if (x == NULL)
  40129. err = MEMORY_E;
  40130. #endif
  40131. if (err == MP_OKAY) {
  40132. y = x + 2 * 21;
  40133. sp_521_from_mp(x, 21, xm);
  40134. err = sp_521_mod_mul_norm_21(x, x, p521_mod);
  40135. }
  40136. if (err == MP_OKAY) {
  40137. /* y = x^3 */
  40138. {
  40139. sp_521_mont_sqr_21(y, x, p521_mod, p521_mp_mod);
  40140. sp_521_mont_mul_21(y, y, x, p521_mod, p521_mp_mod);
  40141. }
  40142. /* y = x^3 - 3x */
  40143. sp_521_mont_sub_21(y, y, x, p521_mod);
  40144. sp_521_mont_sub_21(y, y, x, p521_mod);
  40145. sp_521_mont_sub_21(y, y, x, p521_mod);
  40146. /* y = x^3 - 3x + b */
  40147. err = sp_521_mod_mul_norm_21(x, p521_b, p521_mod);
  40148. }
  40149. if (err == MP_OKAY) {
  40150. sp_521_mont_add_21(y, y, x, p521_mod);
  40151. /* y = sqrt(x^3 - 3x + b) */
  40152. err = sp_521_mont_sqrt_21(y);
  40153. }
  40154. if (err == MP_OKAY) {
  40155. XMEMSET(y + 21, 0, 21U * sizeof(sp_digit));
  40156. sp_521_mont_reduce_21(y, p521_mod, p521_mp_mod);
  40157. if ((((word32)y[0] ^ (word32)odd) & 1U) != 0U) {
  40158. sp_521_mont_sub_21(y, p521_mod, y, p521_mod);
  40159. }
  40160. err = sp_521_to_mp(y, ym);
  40161. }
  40162. #ifdef WOLFSSL_SP_SMALL_STACK
  40163. if (x != NULL)
  40164. XFREE(x, NULL, DYNAMIC_TYPE_ECC);
  40165. #endif
  40166. return err;
  40167. }
  40168. #endif
  40169. #endif /* WOLFSSL_SP_521 */
  40170. #ifdef WOLFCRYPT_HAVE_SAKKE
  40171. #ifdef WOLFSSL_SP_1024
  40172. /* Point structure to use. */
  40173. typedef struct sp_point_1024 {
  40174. /* X ordinate of point. */
  40175. sp_digit x[2 * 42];
  40176. /* Y ordinate of point. */
  40177. sp_digit y[2 * 42];
  40178. /* Z ordinate of point. */
  40179. sp_digit z[2 * 42];
  40180. /* Indicates point is at infinity. */
  40181. int infinity;
  40182. } sp_point_1024;
  40183. #ifndef WOLFSSL_SP_SMALL
  40184. /* Multiply a and b into r. (r = a * b)
  40185. *
  40186. * r A single precision integer.
  40187. * a A single precision integer.
  40188. * b A single precision integer.
  40189. */
  40190. SP_NOINLINE static void sp_1024_mul_7(sp_digit* r, const sp_digit* a,
  40191. const sp_digit* b)
  40192. {
  40193. sp_int64 t0 = ((sp_int64)a[ 0]) * b[ 0];
  40194. sp_int64 t1 = ((sp_int64)a[ 0]) * b[ 1]
  40195. + ((sp_int64)a[ 1]) * b[ 0];
  40196. sp_int64 t2 = ((sp_int64)a[ 0]) * b[ 2]
  40197. + ((sp_int64)a[ 1]) * b[ 1]
  40198. + ((sp_int64)a[ 2]) * b[ 0];
  40199. sp_int64 t3 = ((sp_int64)a[ 0]) * b[ 3]
  40200. + ((sp_int64)a[ 1]) * b[ 2]
  40201. + ((sp_int64)a[ 2]) * b[ 1]
  40202. + ((sp_int64)a[ 3]) * b[ 0];
  40203. sp_int64 t4 = ((sp_int64)a[ 0]) * b[ 4]
  40204. + ((sp_int64)a[ 1]) * b[ 3]
  40205. + ((sp_int64)a[ 2]) * b[ 2]
  40206. + ((sp_int64)a[ 3]) * b[ 1]
  40207. + ((sp_int64)a[ 4]) * b[ 0];
  40208. sp_int64 t5 = ((sp_int64)a[ 0]) * b[ 5]
  40209. + ((sp_int64)a[ 1]) * b[ 4]
  40210. + ((sp_int64)a[ 2]) * b[ 3]
  40211. + ((sp_int64)a[ 3]) * b[ 2]
  40212. + ((sp_int64)a[ 4]) * b[ 1]
  40213. + ((sp_int64)a[ 5]) * b[ 0];
  40214. sp_int64 t6 = ((sp_int64)a[ 0]) * b[ 6]
  40215. + ((sp_int64)a[ 1]) * b[ 5]
  40216. + ((sp_int64)a[ 2]) * b[ 4]
  40217. + ((sp_int64)a[ 3]) * b[ 3]
  40218. + ((sp_int64)a[ 4]) * b[ 2]
  40219. + ((sp_int64)a[ 5]) * b[ 1]
  40220. + ((sp_int64)a[ 6]) * b[ 0];
  40221. sp_int64 t7 = ((sp_int64)a[ 1]) * b[ 6]
  40222. + ((sp_int64)a[ 2]) * b[ 5]
  40223. + ((sp_int64)a[ 3]) * b[ 4]
  40224. + ((sp_int64)a[ 4]) * b[ 3]
  40225. + ((sp_int64)a[ 5]) * b[ 2]
  40226. + ((sp_int64)a[ 6]) * b[ 1];
  40227. sp_int64 t8 = ((sp_int64)a[ 2]) * b[ 6]
  40228. + ((sp_int64)a[ 3]) * b[ 5]
  40229. + ((sp_int64)a[ 4]) * b[ 4]
  40230. + ((sp_int64)a[ 5]) * b[ 3]
  40231. + ((sp_int64)a[ 6]) * b[ 2];
  40232. sp_int64 t9 = ((sp_int64)a[ 3]) * b[ 6]
  40233. + ((sp_int64)a[ 4]) * b[ 5]
  40234. + ((sp_int64)a[ 5]) * b[ 4]
  40235. + ((sp_int64)a[ 6]) * b[ 3];
  40236. sp_int64 t10 = ((sp_int64)a[ 4]) * b[ 6]
  40237. + ((sp_int64)a[ 5]) * b[ 5]
  40238. + ((sp_int64)a[ 6]) * b[ 4];
  40239. sp_int64 t11 = ((sp_int64)a[ 5]) * b[ 6]
  40240. + ((sp_int64)a[ 6]) * b[ 5];
  40241. sp_int64 t12 = ((sp_int64)a[ 6]) * b[ 6];
  40242. t1 += t0 >> 25; r[ 0] = t0 & 0x1ffffff;
  40243. t2 += t1 >> 25; r[ 1] = t1 & 0x1ffffff;
  40244. t3 += t2 >> 25; r[ 2] = t2 & 0x1ffffff;
  40245. t4 += t3 >> 25; r[ 3] = t3 & 0x1ffffff;
  40246. t5 += t4 >> 25; r[ 4] = t4 & 0x1ffffff;
  40247. t6 += t5 >> 25; r[ 5] = t5 & 0x1ffffff;
  40248. t7 += t6 >> 25; r[ 6] = t6 & 0x1ffffff;
  40249. t8 += t7 >> 25; r[ 7] = t7 & 0x1ffffff;
  40250. t9 += t8 >> 25; r[ 8] = t8 & 0x1ffffff;
  40251. t10 += t9 >> 25; r[ 9] = t9 & 0x1ffffff;
  40252. t11 += t10 >> 25; r[10] = t10 & 0x1ffffff;
  40253. t12 += t11 >> 25; r[11] = t11 & 0x1ffffff;
  40254. r[13] = (sp_digit)(t12 >> 25);
  40255. r[12] = t12 & 0x1ffffff;
  40256. }
  40257. /* Square a and put result in r. (r = a * a)
  40258. *
  40259. * r A single precision integer.
  40260. * a A single precision integer.
  40261. */
  40262. SP_NOINLINE static void sp_1024_sqr_7(sp_digit* r, const sp_digit* a)
  40263. {
  40264. sp_int64 t0 = ((sp_int64)a[ 0]) * a[ 0];
  40265. sp_int64 t1 = (((sp_int64)a[ 0]) * a[ 1]) * 2;
  40266. sp_int64 t2 = (((sp_int64)a[ 0]) * a[ 2]) * 2
  40267. + ((sp_int64)a[ 1]) * a[ 1];
  40268. sp_int64 t3 = (((sp_int64)a[ 0]) * a[ 3]
  40269. + ((sp_int64)a[ 1]) * a[ 2]) * 2;
  40270. sp_int64 t4 = (((sp_int64)a[ 0]) * a[ 4]
  40271. + ((sp_int64)a[ 1]) * a[ 3]) * 2
  40272. + ((sp_int64)a[ 2]) * a[ 2];
  40273. sp_int64 t5 = (((sp_int64)a[ 0]) * a[ 5]
  40274. + ((sp_int64)a[ 1]) * a[ 4]
  40275. + ((sp_int64)a[ 2]) * a[ 3]) * 2;
  40276. sp_int64 t6 = (((sp_int64)a[ 0]) * a[ 6]
  40277. + ((sp_int64)a[ 1]) * a[ 5]
  40278. + ((sp_int64)a[ 2]) * a[ 4]) * 2
  40279. + ((sp_int64)a[ 3]) * a[ 3];
  40280. sp_int64 t7 = (((sp_int64)a[ 1]) * a[ 6]
  40281. + ((sp_int64)a[ 2]) * a[ 5]
  40282. + ((sp_int64)a[ 3]) * a[ 4]) * 2;
  40283. sp_int64 t8 = (((sp_int64)a[ 2]) * a[ 6]
  40284. + ((sp_int64)a[ 3]) * a[ 5]) * 2
  40285. + ((sp_int64)a[ 4]) * a[ 4];
  40286. sp_int64 t9 = (((sp_int64)a[ 3]) * a[ 6]
  40287. + ((sp_int64)a[ 4]) * a[ 5]) * 2;
  40288. sp_int64 t10 = (((sp_int64)a[ 4]) * a[ 6]) * 2
  40289. + ((sp_int64)a[ 5]) * a[ 5];
  40290. sp_int64 t11 = (((sp_int64)a[ 5]) * a[ 6]) * 2;
  40291. sp_int64 t12 = ((sp_int64)a[ 6]) * a[ 6];
  40292. t1 += t0 >> 25; r[ 0] = t0 & 0x1ffffff;
  40293. t2 += t1 >> 25; r[ 1] = t1 & 0x1ffffff;
  40294. t3 += t2 >> 25; r[ 2] = t2 & 0x1ffffff;
  40295. t4 += t3 >> 25; r[ 3] = t3 & 0x1ffffff;
  40296. t5 += t4 >> 25; r[ 4] = t4 & 0x1ffffff;
  40297. t6 += t5 >> 25; r[ 5] = t5 & 0x1ffffff;
  40298. t7 += t6 >> 25; r[ 6] = t6 & 0x1ffffff;
  40299. t8 += t7 >> 25; r[ 7] = t7 & 0x1ffffff;
  40300. t9 += t8 >> 25; r[ 8] = t8 & 0x1ffffff;
  40301. t10 += t9 >> 25; r[ 9] = t9 & 0x1ffffff;
  40302. t11 += t10 >> 25; r[10] = t10 & 0x1ffffff;
  40303. t12 += t11 >> 25; r[11] = t11 & 0x1ffffff;
  40304. r[13] = (sp_digit)(t12 >> 25);
  40305. r[12] = t12 & 0x1ffffff;
  40306. }
  40307. /* Add b to a into r. (r = a + b)
  40308. *
  40309. * r A single precision integer.
  40310. * a A single precision integer.
  40311. * b A single precision integer.
  40312. */
  40313. SP_NOINLINE static int sp_1024_add_7(sp_digit* r, const sp_digit* a,
  40314. const sp_digit* b)
  40315. {
  40316. r[ 0] = a[ 0] + b[ 0];
  40317. r[ 1] = a[ 1] + b[ 1];
  40318. r[ 2] = a[ 2] + b[ 2];
  40319. r[ 3] = a[ 3] + b[ 3];
  40320. r[ 4] = a[ 4] + b[ 4];
  40321. r[ 5] = a[ 5] + b[ 5];
  40322. r[ 6] = a[ 6] + b[ 6];
  40323. return 0;
  40324. }
  40325. /* Sub b from a into r. (r = a - b)
  40326. *
  40327. * r A single precision integer.
  40328. * a A single precision integer.
  40329. * b A single precision integer.
  40330. */
  40331. SP_NOINLINE static int sp_1024_sub_14(sp_digit* r, const sp_digit* a,
  40332. const sp_digit* b)
  40333. {
  40334. r[ 0] = a[ 0] - b[ 0];
  40335. r[ 1] = a[ 1] - b[ 1];
  40336. r[ 2] = a[ 2] - b[ 2];
  40337. r[ 3] = a[ 3] - b[ 3];
  40338. r[ 4] = a[ 4] - b[ 4];
  40339. r[ 5] = a[ 5] - b[ 5];
  40340. r[ 6] = a[ 6] - b[ 6];
  40341. r[ 7] = a[ 7] - b[ 7];
  40342. r[ 8] = a[ 8] - b[ 8];
  40343. r[ 9] = a[ 9] - b[ 9];
  40344. r[10] = a[10] - b[10];
  40345. r[11] = a[11] - b[11];
  40346. r[12] = a[12] - b[12];
  40347. r[13] = a[13] - b[13];
  40348. return 0;
  40349. }
  40350. /* Add b to a into r. (r = a + b)
  40351. *
  40352. * r A single precision integer.
  40353. * a A single precision integer.
  40354. * b A single precision integer.
  40355. */
  40356. SP_NOINLINE static int sp_1024_add_14(sp_digit* r, const sp_digit* a,
  40357. const sp_digit* b)
  40358. {
  40359. r[ 0] = a[ 0] + b[ 0];
  40360. r[ 1] = a[ 1] + b[ 1];
  40361. r[ 2] = a[ 2] + b[ 2];
  40362. r[ 3] = a[ 3] + b[ 3];
  40363. r[ 4] = a[ 4] + b[ 4];
  40364. r[ 5] = a[ 5] + b[ 5];
  40365. r[ 6] = a[ 6] + b[ 6];
  40366. r[ 7] = a[ 7] + b[ 7];
  40367. r[ 8] = a[ 8] + b[ 8];
  40368. r[ 9] = a[ 9] + b[ 9];
  40369. r[10] = a[10] + b[10];
  40370. r[11] = a[11] + b[11];
  40371. r[12] = a[12] + b[12];
  40372. r[13] = a[13] + b[13];
  40373. return 0;
  40374. }
  40375. /* Multiply a and b into r. (r = a * b)
  40376. *
  40377. * r A single precision integer.
  40378. * a A single precision integer.
  40379. * b A single precision integer.
  40380. */
  40381. SP_NOINLINE static void sp_1024_mul_21(sp_digit* r, const sp_digit* a,
  40382. const sp_digit* b)
  40383. {
  40384. sp_digit p0[14];
  40385. sp_digit p1[14];
  40386. sp_digit p2[14];
  40387. sp_digit p3[14];
  40388. sp_digit p4[14];
  40389. sp_digit p5[14];
  40390. sp_digit t0[14];
  40391. sp_digit t1[14];
  40392. sp_digit t2[14];
  40393. sp_digit a0[7];
  40394. sp_digit a1[7];
  40395. sp_digit a2[7];
  40396. sp_digit b0[7];
  40397. sp_digit b1[7];
  40398. sp_digit b2[7];
  40399. (void)sp_1024_add_7(a0, a, &a[7]);
  40400. (void)sp_1024_add_7(b0, b, &b[7]);
  40401. (void)sp_1024_add_7(a1, &a[7], &a[14]);
  40402. (void)sp_1024_add_7(b1, &b[7], &b[14]);
  40403. (void)sp_1024_add_7(a2, a0, &a[14]);
  40404. (void)sp_1024_add_7(b2, b0, &b[14]);
  40405. sp_1024_mul_7(p0, a, b);
  40406. sp_1024_mul_7(p2, &a[7], &b[7]);
  40407. sp_1024_mul_7(p4, &a[14], &b[14]);
  40408. sp_1024_mul_7(p1, a0, b0);
  40409. sp_1024_mul_7(p3, a1, b1);
  40410. sp_1024_mul_7(p5, a2, b2);
  40411. XMEMSET(r, 0, sizeof(*r)*2U*21U);
  40412. (void)sp_1024_sub_14(t0, p3, p2);
  40413. (void)sp_1024_sub_14(t1, p1, p2);
  40414. (void)sp_1024_sub_14(t2, p5, t0);
  40415. (void)sp_1024_sub_14(t2, t2, t1);
  40416. (void)sp_1024_sub_14(t0, t0, p4);
  40417. (void)sp_1024_sub_14(t1, t1, p0);
  40418. (void)sp_1024_add_14(r, r, p0);
  40419. (void)sp_1024_add_14(&r[7], &r[7], t1);
  40420. (void)sp_1024_add_14(&r[14], &r[14], t2);
  40421. (void)sp_1024_add_14(&r[21], &r[21], t0);
  40422. (void)sp_1024_add_14(&r[28], &r[28], p4);
  40423. }
  40424. /* Square a into r. (r = a * a)
  40425. *
  40426. * r A single precision integer.
  40427. * a A single precision integer.
  40428. */
  40429. SP_NOINLINE static void sp_1024_sqr_21(sp_digit* r, const sp_digit* a)
  40430. {
  40431. sp_digit p0[14];
  40432. sp_digit p1[14];
  40433. sp_digit p2[14];
  40434. sp_digit p3[14];
  40435. sp_digit p4[14];
  40436. sp_digit p5[14];
  40437. sp_digit t0[14];
  40438. sp_digit t1[14];
  40439. sp_digit t2[14];
  40440. sp_digit a0[7];
  40441. sp_digit a1[7];
  40442. sp_digit a2[7];
  40443. (void)sp_1024_add_7(a0, a, &a[7]);
  40444. (void)sp_1024_add_7(a1, &a[7], &a[14]);
  40445. (void)sp_1024_add_7(a2, a0, &a[14]);
  40446. sp_1024_sqr_7(p0, a);
  40447. sp_1024_sqr_7(p2, &a[7]);
  40448. sp_1024_sqr_7(p4, &a[14]);
  40449. sp_1024_sqr_7(p1, a0);
  40450. sp_1024_sqr_7(p3, a1);
  40451. sp_1024_sqr_7(p5, a2);
  40452. XMEMSET(r, 0, sizeof(*r)*2U*21U);
  40453. (void)sp_1024_sub_14(t0, p3, p2);
  40454. (void)sp_1024_sub_14(t1, p1, p2);
  40455. (void)sp_1024_sub_14(t2, p5, t0);
  40456. (void)sp_1024_sub_14(t2, t2, t1);
  40457. (void)sp_1024_sub_14(t0, t0, p4);
  40458. (void)sp_1024_sub_14(t1, t1, p0);
  40459. (void)sp_1024_add_14(r, r, p0);
  40460. (void)sp_1024_add_14(&r[7], &r[7], t1);
  40461. (void)sp_1024_add_14(&r[14], &r[14], t2);
  40462. (void)sp_1024_add_14(&r[21], &r[21], t0);
  40463. (void)sp_1024_add_14(&r[28], &r[28], p4);
  40464. }
  40465. /* Add b to a into r. (r = a + b)
  40466. *
  40467. * r A single precision integer.
  40468. * a A single precision integer.
  40469. * b A single precision integer.
  40470. */
  40471. SP_NOINLINE static int sp_1024_add_21(sp_digit* r, const sp_digit* a,
  40472. const sp_digit* b)
  40473. {
  40474. int i;
  40475. for (i = 0; i < 16; i += 8) {
  40476. r[i + 0] = a[i + 0] + b[i + 0];
  40477. r[i + 1] = a[i + 1] + b[i + 1];
  40478. r[i + 2] = a[i + 2] + b[i + 2];
  40479. r[i + 3] = a[i + 3] + b[i + 3];
  40480. r[i + 4] = a[i + 4] + b[i + 4];
  40481. r[i + 5] = a[i + 5] + b[i + 5];
  40482. r[i + 6] = a[i + 6] + b[i + 6];
  40483. r[i + 7] = a[i + 7] + b[i + 7];
  40484. }
  40485. r[16] = a[16] + b[16];
  40486. r[17] = a[17] + b[17];
  40487. r[18] = a[18] + b[18];
  40488. r[19] = a[19] + b[19];
  40489. r[20] = a[20] + b[20];
  40490. return 0;
  40491. }
  40492. /* Add b to a into r. (r = a + b)
  40493. *
  40494. * r A single precision integer.
  40495. * a A single precision integer.
  40496. * b A single precision integer.
  40497. */
  40498. SP_NOINLINE static int sp_1024_add_42(sp_digit* r, const sp_digit* a,
  40499. const sp_digit* b)
  40500. {
  40501. int i;
  40502. for (i = 0; i < 40; i += 8) {
  40503. r[i + 0] = a[i + 0] + b[i + 0];
  40504. r[i + 1] = a[i + 1] + b[i + 1];
  40505. r[i + 2] = a[i + 2] + b[i + 2];
  40506. r[i + 3] = a[i + 3] + b[i + 3];
  40507. r[i + 4] = a[i + 4] + b[i + 4];
  40508. r[i + 5] = a[i + 5] + b[i + 5];
  40509. r[i + 6] = a[i + 6] + b[i + 6];
  40510. r[i + 7] = a[i + 7] + b[i + 7];
  40511. }
  40512. r[40] = a[40] + b[40];
  40513. r[41] = a[41] + b[41];
  40514. return 0;
  40515. }
  40516. /* Sub b from a into r. (r = a - b)
  40517. *
  40518. * r A single precision integer.
  40519. * a A single precision integer.
  40520. * b A single precision integer.
  40521. */
  40522. SP_NOINLINE static int sp_1024_sub_42(sp_digit* r, const sp_digit* a,
  40523. const sp_digit* b)
  40524. {
  40525. int i;
  40526. for (i = 0; i < 40; i += 8) {
  40527. r[i + 0] = a[i + 0] - b[i + 0];
  40528. r[i + 1] = a[i + 1] - b[i + 1];
  40529. r[i + 2] = a[i + 2] - b[i + 2];
  40530. r[i + 3] = a[i + 3] - b[i + 3];
  40531. r[i + 4] = a[i + 4] - b[i + 4];
  40532. r[i + 5] = a[i + 5] - b[i + 5];
  40533. r[i + 6] = a[i + 6] - b[i + 6];
  40534. r[i + 7] = a[i + 7] - b[i + 7];
  40535. }
  40536. r[40] = a[40] - b[40];
  40537. r[41] = a[41] - b[41];
  40538. return 0;
  40539. }
  40540. /* Multiply a and b into r. (r = a * b)
  40541. *
  40542. * r A single precision integer.
  40543. * a A single precision integer.
  40544. * b A single precision integer.
  40545. */
  40546. SP_NOINLINE static void sp_1024_mul_42(sp_digit* r, const sp_digit* a,
  40547. const sp_digit* b)
  40548. {
  40549. sp_digit* z0 = r;
  40550. sp_digit z1[42];
  40551. sp_digit* a1 = z1;
  40552. sp_digit b1[21];
  40553. sp_digit* z2 = r + 42;
  40554. (void)sp_1024_add_21(a1, a, &a[21]);
  40555. (void)sp_1024_add_21(b1, b, &b[21]);
  40556. sp_1024_mul_21(z2, &a[21], &b[21]);
  40557. sp_1024_mul_21(z0, a, b);
  40558. sp_1024_mul_21(z1, a1, b1);
  40559. (void)sp_1024_sub_42(z1, z1, z2);
  40560. (void)sp_1024_sub_42(z1, z1, z0);
  40561. (void)sp_1024_add_42(r + 21, r + 21, z1);
  40562. }
  40563. /* Square a and put result in r. (r = a * a)
  40564. *
  40565. * r A single precision integer.
  40566. * a A single precision integer.
  40567. */
  40568. SP_NOINLINE static void sp_1024_sqr_42(sp_digit* r, const sp_digit* a)
  40569. {
  40570. sp_digit* z0 = r;
  40571. sp_digit z1[42];
  40572. sp_digit* a1 = z1;
  40573. sp_digit* z2 = r + 42;
  40574. (void)sp_1024_add_21(a1, a, &a[21]);
  40575. sp_1024_sqr_21(z2, &a[21]);
  40576. sp_1024_sqr_21(z0, a);
  40577. sp_1024_sqr_21(z1, a1);
  40578. (void)sp_1024_sub_42(z1, z1, z2);
  40579. (void)sp_1024_sub_42(z1, z1, z0);
  40580. (void)sp_1024_add_42(r + 21, r + 21, z1);
  40581. }
  40582. #else
  40583. /* Multiply a and b into r. (r = a * b)
  40584. *
  40585. * r A single precision integer.
  40586. * a A single precision integer.
  40587. * b A single precision integer.
  40588. */
  40589. SP_NOINLINE static void sp_1024_mul_42(sp_digit* r, const sp_digit* a,
  40590. const sp_digit* b)
  40591. {
  40592. int i;
  40593. int imax;
  40594. int k;
  40595. sp_uint64 c;
  40596. sp_uint64 lo;
  40597. c = ((sp_uint64)a[41]) * b[41];
  40598. r[83] = (sp_digit)(c >> 25);
  40599. c &= 0x1ffffff;
  40600. for (k = 81; k >= 0; k--) {
  40601. if (k >= 42) {
  40602. i = k - 41;
  40603. imax = 41;
  40604. }
  40605. else {
  40606. i = 0;
  40607. imax = k;
  40608. }
  40609. lo = 0;
  40610. for (; i <= imax; i++) {
  40611. lo += ((sp_uint64)a[i]) * b[k - i];
  40612. }
  40613. c += lo >> 25;
  40614. r[k + 2] += (sp_digit)(c >> 25);
  40615. r[k + 1] = (sp_digit)(c & 0x1ffffff);
  40616. c = lo & 0x1ffffff;
  40617. }
  40618. r[0] = (sp_digit)c;
  40619. }
  40620. /* Square a and put result in r. (r = a * a)
  40621. *
  40622. * r A single precision integer.
  40623. * a A single precision integer.
  40624. */
  40625. SP_NOINLINE static void sp_1024_sqr_42(sp_digit* r, const sp_digit* a)
  40626. {
  40627. int i;
  40628. int imax;
  40629. int k;
  40630. sp_uint64 c;
  40631. sp_uint64 t;
  40632. c = ((sp_uint64)a[41]) * a[41];
  40633. r[83] = (sp_digit)(c >> 25);
  40634. c = (c & 0x1ffffff) << 25;
  40635. for (k = 81; k >= 0; k--) {
  40636. i = (k + 1) / 2;
  40637. if ((k & 1) == 0) {
  40638. c += ((sp_uint64)a[i]) * a[i];
  40639. i++;
  40640. }
  40641. if (k < 41) {
  40642. imax = k;
  40643. }
  40644. else {
  40645. imax = 41;
  40646. }
  40647. t = 0;
  40648. for (; i <= imax; i++) {
  40649. t += ((sp_uint64)a[i]) * a[k - i];
  40650. }
  40651. c += t * 2;
  40652. r[k + 2] += (sp_digit) (c >> 50);
  40653. r[k + 1] = (sp_digit)((c >> 25) & 0x1ffffff);
  40654. c = (c & 0x1ffffff) << 25;
  40655. }
  40656. r[0] = (sp_digit)(c >> 25);
  40657. }
  40658. #endif /* !WOLFSSL_SP_SMALL */
  40659. /* The modulus (prime) of the curve P1024. */
  40660. static const sp_digit p1024_mod[42] = {
  40661. 0x0a85feb,0x0c03d7f,0x1a1d99b,0x0158f59,0x00c5df1,0x02bed84,0x1a08e26,
  40662. 0x03ff9c7,0x156971f,0x1ca6b57,0x1026aa7,0x18a4387,0x02a7cf3,0x18c2954,
  40663. 0x0bfd2a0,0x039c36d,0x1cd6568,0x0289562,0x09ad335,0x18c90e6,0x06d0e26,
  40664. 0x1a53335,0x0d5b49f,0x1911432,0x1b39ff7,0x05873c8,0x14c6967,0x050e61a,
  40665. 0x1c0f1b2,0x1593f17,0x0bbd02a,0x167c034,0x09ae358,0x04130df,0x138672d,
  40666. 0x1482d81,0x1ad0657,0x0308cc6,0x0ff6997,0x03e14ac,0x0997abb,0x0000000
  40667. };
  40668. /* The Montgomery normalizer for modulus of the curve P1024. */
  40669. static const sp_digit p1024_norm_mod[42] = {
  40670. 0x157a015,0x13fc280,0x05e2664,0x1ea70a6,0x1f3a20e,0x1d4127b,0x05f71d9,
  40671. 0x1c00638,0x0a968e0,0x03594a8,0x0fd9558,0x075bc78,0x1d5830c,0x073d6ab,
  40672. 0x1402d5f,0x1c63c92,0x0329a97,0x1d76a9d,0x1652cca,0x0736f19,0x192f1d9,
  40673. 0x05accca,0x12a4b60,0x06eebcd,0x04c6008,0x1a78c37,0x0b39698,0x1af19e5,
  40674. 0x03f0e4d,0x0a6c0e8,0x1442fd5,0x0983fcb,0x1651ca7,0x1becf20,0x0c798d2,
  40675. 0x0b7d27e,0x052f9a8,0x1cf7339,0x1009668,0x1c1eb53,0x0668544,0x0000000
  40676. };
  40677. /* The Montgomery multiplier for modulus of the curve P1024. */
  40678. static sp_digit p1024_mp_mod = 0x8f2f3d;
  40679. #if defined(WOLFSSL_SP_SMALL) || defined(HAVE_ECC_CHECK_KEY)
  40680. /* The order of the curve P1024. */
  40681. static const sp_digit p1024_order[42] = {
  40682. 0x1aa17fb,0x1b00f5f,0x0e87666,0x08563d6,0x003177c,0x10afb61,0x1e82389,
  40683. 0x18ffe71,0x1d5a5c7,0x1f29ad5,0x1c09aa9,0x1e290e1,0x00a9f3c,0x0630a55,
  40684. 0x0aff4a8,0x00e70db,0x173595a,0x08a2558,0x126b4cd,0x1632439,0x09b4389,
  40685. 0x1e94ccd,0x1356d27,0x1e4450c,0x06ce7fd,0x1961cf2,0x1531a59,0x1143986,
  40686. 0x1f03c6c,0x1564fc5,0x02ef40a,0x059f00d,0x1a6b8d6,0x0904c37,0x0ce19cb,
  40687. 0x1d20b60,0x16b4195,0x18c2331,0x03fda65,0x18f852b,0x0265eae,0x0000000
  40688. };
  40689. #endif
  40690. /* The base point of curve P1024. */
  40691. static const sp_point_1024 p1024_base = {
  40692. /* X ordinate */
  40693. {
  40694. 0x0e63895,0x0e455f5,0x05e6203,0x092cfc1,0x00ec46c,0x1fb9f64,0x18e96d8,
  40695. 0x10fdd22,0x080728d,0x0e7da66,0x1a44375,0x029b74c,0x14a7c15,0x1d306f3,
  40696. 0x00b0ce5,0x1e5c34e,0x0548b72,0x199be43,0x1756f32,0x015eecb,0x0890976,
  40697. 0x13a0367,0x1c62f67,0x13bf4aa,0x1f22cdb,0x10821ea,0x00c2c27,0x1621b72,
  40698. 0x0e2308a,0x1b607b6,0x0fed7b6,0x16dfef9,0x0b2f204,0x034e34c,0x1f582bb,
  40699. 0x1456345,0x1ed9b52,0x1cc8029,0x0a6b429,0x1dc6658,0x053fc09,0x0000000,
  40700. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40701. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40702. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40703. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40704. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40705. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40706. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40707. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40708. (sp_digit)0, (sp_digit)0
  40709. },
  40710. /* Y ordinate */
  40711. {
  40712. 0x1ef16d7,0x19feb8d,0x1379d55,0x00d4cfb,0x0db9b57,0x1da31b5,0x0b56b56,
  40713. 0x153017b,0x1e9cb99,0x1a8ad6b,0x1357c84,0x0f3f8b4,0x09492d9,0x0b2554c,
  40714. 0x1bc7a00,0x05fc158,0x0b5b765,0x0656b4b,0x1551f1b,0x15c22f5,0x12b970d,
  40715. 0x0654f01,0x105b3fc,0x028165c,0x18ccf9a,0x0fb35ac,0x17c3795,0x0fefebc,
  40716. 0x0ec2b9e,0x14fa32a,0x1e3d7a9,0x03c2822,0x1778d82,0x0834b1e,0x00580a6,
  40717. 0x0ba7d04,0x1634a13,0x18f8299,0x027c7e7,0x00c7ec0,0x00a8249,0x0000000,
  40718. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40719. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40720. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40721. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40722. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40723. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40724. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40725. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40726. (sp_digit)0, (sp_digit)0
  40727. },
  40728. /* Z ordinate */
  40729. {
  40730. 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40731. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40732. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40733. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40734. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40735. 0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,
  40736. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40737. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40738. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40739. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40740. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40741. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40742. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40743. (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
  40744. (sp_digit)0, (sp_digit)0
  40745. },
  40746. /* infinity */
  40747. 0
  40748. };
  40749. /* Normalize the values in each word to 25 bits.
  40750. *
  40751. * a Array of sp_digit to normalize.
  40752. */
  40753. static void sp_1024_norm_41(sp_digit* a)
  40754. {
  40755. #ifdef WOLFSSL_SP_SMALL
  40756. int i;
  40757. for (i = 0; i < 40; i++) {
  40758. a[i+1] += a[i] >> 25;
  40759. a[i] &= 0x1ffffff;
  40760. }
  40761. #else
  40762. int i;
  40763. for (i = 0; i < 40; i += 8) {
  40764. a[i+1] += a[i+0] >> 25; a[i+0] &= 0x1ffffff;
  40765. a[i+2] += a[i+1] >> 25; a[i+1] &= 0x1ffffff;
  40766. a[i+3] += a[i+2] >> 25; a[i+2] &= 0x1ffffff;
  40767. a[i+4] += a[i+3] >> 25; a[i+3] &= 0x1ffffff;
  40768. a[i+5] += a[i+4] >> 25; a[i+4] &= 0x1ffffff;
  40769. a[i+6] += a[i+5] >> 25; a[i+5] &= 0x1ffffff;
  40770. a[i+7] += a[i+6] >> 25; a[i+6] &= 0x1ffffff;
  40771. a[i+8] += a[i+7] >> 25; a[i+7] &= 0x1ffffff;
  40772. }
  40773. #endif /* WOLFSSL_SP_SMALL */
  40774. }
  40775. /* Multiply a by scalar b into r. (r = a * b)
  40776. *
  40777. * r A single precision integer.
  40778. * a A single precision integer.
  40779. * b A scalar.
  40780. */
  40781. SP_NOINLINE static void sp_1024_mul_d_42(sp_digit* r, const sp_digit* a,
  40782. sp_digit b)
  40783. {
  40784. #ifdef WOLFSSL_SP_SMALL
  40785. sp_int64 tb = b;
  40786. sp_int64 t = 0;
  40787. int i;
  40788. for (i = 0; i < 42; i++) {
  40789. t += tb * a[i];
  40790. r[i] = (sp_digit)(t & 0x1ffffff);
  40791. t >>= 25;
  40792. }
  40793. r[42] = (sp_digit)t;
  40794. #else
  40795. sp_int64 tb = b;
  40796. sp_int64 t = 0;
  40797. sp_digit t2;
  40798. sp_int64 p[4];
  40799. int i;
  40800. for (i = 0; i < 40; i += 4) {
  40801. p[0] = tb * a[i + 0];
  40802. p[1] = tb * a[i + 1];
  40803. p[2] = tb * a[i + 2];
  40804. p[3] = tb * a[i + 3];
  40805. t += p[0];
  40806. t2 = (sp_digit)(t & 0x1ffffff);
  40807. t >>= 25;
  40808. r[i + 0] = (sp_digit)t2;
  40809. t += p[1];
  40810. t2 = (sp_digit)(t & 0x1ffffff);
  40811. t >>= 25;
  40812. r[i + 1] = (sp_digit)t2;
  40813. t += p[2];
  40814. t2 = (sp_digit)(t & 0x1ffffff);
  40815. t >>= 25;
  40816. r[i + 2] = (sp_digit)t2;
  40817. t += p[3];
  40818. t2 = (sp_digit)(t & 0x1ffffff);
  40819. t >>= 25;
  40820. r[i + 3] = (sp_digit)t2;
  40821. }
  40822. t += tb * a[40];
  40823. r[40] = (sp_digit)(t & 0x1ffffff);
  40824. t >>= 25;
  40825. t += tb * a[41];
  40826. r[41] = (sp_digit)(t & 0x1ffffff);
  40827. t >>= 25;
  40828. r[42] = (sp_digit)(t & 0x1ffffff);
  40829. #endif /* WOLFSSL_SP_SMALL */
  40830. }
  40831. /* Multiply a by scalar b into r. (r = a * b)
  40832. *
  40833. * r A single precision integer.
  40834. * a A single precision integer.
  40835. * b A scalar.
  40836. */
  40837. SP_NOINLINE static void sp_1024_mul_d_84(sp_digit* r, const sp_digit* a,
  40838. sp_digit b)
  40839. {
  40840. #ifdef WOLFSSL_SP_SMALL
  40841. sp_int64 tb = b;
  40842. sp_int64 t = 0;
  40843. int i;
  40844. for (i = 0; i < 84; i++) {
  40845. t += tb * a[i];
  40846. r[i] = (sp_digit)(t & 0x1ffffff);
  40847. t >>= 25;
  40848. }
  40849. r[84] = (sp_digit)t;
  40850. #else
  40851. sp_int64 tb = b;
  40852. sp_int64 t = 0;
  40853. sp_digit t2;
  40854. sp_int64 p[4];
  40855. int i;
  40856. for (i = 0; i < 84; i += 4) {
  40857. p[0] = tb * a[i + 0];
  40858. p[1] = tb * a[i + 1];
  40859. p[2] = tb * a[i + 2];
  40860. p[3] = tb * a[i + 3];
  40861. t += p[0];
  40862. t2 = (sp_digit)(t & 0x1ffffff);
  40863. t >>= 25;
  40864. r[i + 0] = (sp_digit)t2;
  40865. t += p[1];
  40866. t2 = (sp_digit)(t & 0x1ffffff);
  40867. t >>= 25;
  40868. r[i + 1] = (sp_digit)t2;
  40869. t += p[2];
  40870. t2 = (sp_digit)(t & 0x1ffffff);
  40871. t >>= 25;
  40872. r[i + 2] = (sp_digit)t2;
  40873. t += p[3];
  40874. t2 = (sp_digit)(t & 0x1ffffff);
  40875. t >>= 25;
  40876. r[i + 3] = (sp_digit)t2;
  40877. }
  40878. r[84] = (sp_digit)(t & 0x1ffffff);
  40879. #endif /* WOLFSSL_SP_SMALL */
  40880. }
  40881. #ifdef WOLFSSL_SP_SMALL
  40882. /* Conditionally add a and b using the mask m.
  40883. * m is -1 to add and 0 when not.
  40884. *
  40885. * r A single precision number representing conditional add result.
  40886. * a A single precision number to add with.
  40887. * b A single precision number to add.
  40888. * m Mask value to apply.
  40889. */
  40890. static void sp_1024_cond_add_42(sp_digit* r, const sp_digit* a,
  40891. const sp_digit* b, const sp_digit m)
  40892. {
  40893. int i;
  40894. for (i = 0; i < 42; i++) {
  40895. r[i] = a[i] + (b[i] & m);
  40896. }
  40897. }
  40898. #endif /* WOLFSSL_SP_SMALL */
  40899. #ifndef WOLFSSL_SP_SMALL
  40900. /* Conditionally add a and b using the mask m.
  40901. * m is -1 to add and 0 when not.
  40902. *
  40903. * r A single precision number representing conditional add result.
  40904. * a A single precision number to add with.
  40905. * b A single precision number to add.
  40906. * m Mask value to apply.
  40907. */
  40908. static void sp_1024_cond_add_42(sp_digit* r, const sp_digit* a,
  40909. const sp_digit* b, const sp_digit m)
  40910. {
  40911. int i;
  40912. for (i = 0; i < 40; i += 8) {
  40913. r[i + 0] = a[i + 0] + (b[i + 0] & m);
  40914. r[i + 1] = a[i + 1] + (b[i + 1] & m);
  40915. r[i + 2] = a[i + 2] + (b[i + 2] & m);
  40916. r[i + 3] = a[i + 3] + (b[i + 3] & m);
  40917. r[i + 4] = a[i + 4] + (b[i + 4] & m);
  40918. r[i + 5] = a[i + 5] + (b[i + 5] & m);
  40919. r[i + 6] = a[i + 6] + (b[i + 6] & m);
  40920. r[i + 7] = a[i + 7] + (b[i + 7] & m);
  40921. }
  40922. r[40] = a[40] + (b[40] & m);
  40923. r[41] = a[41] + (b[41] & m);
  40924. }
  40925. #endif /* !WOLFSSL_SP_SMALL */
  40926. #ifdef WOLFSSL_SP_SMALL
  40927. /* Sub b from a into r. (r = a - b)
  40928. *
  40929. * r A single precision integer.
  40930. * a A single precision integer.
  40931. * b A single precision integer.
  40932. */
  40933. SP_NOINLINE static int sp_1024_sub_42(sp_digit* r, const sp_digit* a,
  40934. const sp_digit* b)
  40935. {
  40936. int i;
  40937. for (i = 0; i < 42; i++) {
  40938. r[i] = a[i] - b[i];
  40939. }
  40940. return 0;
  40941. }
  40942. #endif
  40943. #ifdef WOLFSSL_SP_SMALL
  40944. /* Add b to a into r. (r = a + b)
  40945. *
  40946. * r A single precision integer.
  40947. * a A single precision integer.
  40948. * b A single precision integer.
  40949. */
  40950. SP_NOINLINE static int sp_1024_add_42(sp_digit* r, const sp_digit* a,
  40951. const sp_digit* b)
  40952. {
  40953. int i;
  40954. for (i = 0; i < 42; i++) {
  40955. r[i] = a[i] + b[i];
  40956. }
  40957. return 0;
  40958. }
  40959. #endif /* WOLFSSL_SP_SMALL */
  40960. SP_NOINLINE static void sp_1024_rshift_42(sp_digit* r, const sp_digit* a,
  40961. byte n)
  40962. {
  40963. int i;
  40964. #ifdef WOLFSSL_SP_SMALL
  40965. for (i=0; i<41; i++) {
  40966. r[i] = ((a[i] >> n) | (a[i + 1] << (25 - n))) & 0x1ffffff;
  40967. }
  40968. #else
  40969. for (i=0; i<40; i += 8) {
  40970. r[i+0] = (a[i+0] >> n) | ((a[i+1] << (25 - n)) & 0x1ffffff);
  40971. r[i+1] = (a[i+1] >> n) | ((a[i+2] << (25 - n)) & 0x1ffffff);
  40972. r[i+2] = (a[i+2] >> n) | ((a[i+3] << (25 - n)) & 0x1ffffff);
  40973. r[i+3] = (a[i+3] >> n) | ((a[i+4] << (25 - n)) & 0x1ffffff);
  40974. r[i+4] = (a[i+4] >> n) | ((a[i+5] << (25 - n)) & 0x1ffffff);
  40975. r[i+5] = (a[i+5] >> n) | ((a[i+6] << (25 - n)) & 0x1ffffff);
  40976. r[i+6] = (a[i+6] >> n) | ((a[i+7] << (25 - n)) & 0x1ffffff);
  40977. r[i+7] = (a[i+7] >> n) | ((a[i+8] << (25 - n)) & 0x1ffffff);
  40978. }
  40979. r[40] = (a[40] >> n) | ((a[41] << (25 - n)) & 0x1ffffff);
  40980. #endif /* WOLFSSL_SP_SMALL */
  40981. r[41] = a[41] >> n;
  40982. }
  40983. static WC_INLINE sp_digit sp_1024_div_word_42(sp_digit d1, sp_digit d0,
  40984. sp_digit div)
  40985. {
  40986. #ifdef SP_USE_DIVTI3
  40987. sp_int64 d = ((sp_int64)d1 << 25) + d0;
  40988. return d / div;
  40989. #elif defined(__x86_64__) || defined(__i386__)
  40990. sp_int64 d = ((sp_int64)d1 << 25) + d0;
  40991. sp_uint32 lo = (sp_uint32)d;
  40992. sp_digit hi = (sp_digit)(d >> 32);
  40993. __asm__ __volatile__ (
  40994. "idiv %2"
  40995. : "+a" (lo)
  40996. : "d" (hi), "r" (div)
  40997. : "cc"
  40998. );
  40999. return (sp_digit)lo;
  41000. #elif !defined(__aarch64__) && !defined(SP_DIV_WORD_USE_DIV)
  41001. sp_int64 d = ((sp_int64)d1 << 25) + d0;
  41002. sp_digit dv = (div >> 1) + 1;
  41003. sp_digit t1 = (sp_digit)(d >> 25);
  41004. sp_digit t0 = (sp_digit)(d & 0x1ffffff);
  41005. sp_digit t2;
  41006. sp_digit sign;
  41007. sp_digit r;
  41008. int i;
  41009. sp_int64 m;
  41010. r = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  41011. t1 -= dv & (0 - r);
  41012. for (i = 23; i >= 1; i--) {
  41013. t1 += t1 + (((sp_uint32)t0 >> 24) & 1);
  41014. t0 <<= 1;
  41015. t2 = (sp_digit)(((sp_uint32)(dv - t1)) >> 31);
  41016. r += r + t2;
  41017. t1 -= dv & (0 - t2);
  41018. t1 += t2;
  41019. }
  41020. r += r + 1;
  41021. m = d - ((sp_int64)r * div);
  41022. r += (sp_digit)(m >> 25);
  41023. m = d - ((sp_int64)r * div);
  41024. r += (sp_digit)(m >> 50) - (sp_digit)(d >> 50);
  41025. m = d - ((sp_int64)r * div);
  41026. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  41027. m *= sign;
  41028. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  41029. r += sign * t2;
  41030. m = d - ((sp_int64)r * div);
  41031. sign = (sp_digit)(0 - ((sp_uint32)m >> 31)) * 2 + 1;
  41032. m *= sign;
  41033. t2 = (sp_digit)(((sp_uint32)(div - m)) >> 31);
  41034. r += sign * t2;
  41035. return r;
  41036. #else
  41037. sp_int64 d = ((sp_int64)d1 << 25) + d0;
  41038. sp_digit r = 0;
  41039. sp_digit t;
  41040. sp_digit dv = (div >> 10) + 1;
  41041. t = (sp_digit)(d >> 20);
  41042. t = (t / dv) << 10;
  41043. r += t;
  41044. d -= (sp_int64)t * div;
  41045. t = (sp_digit)(d >> 5);
  41046. t = t / (dv << 5);
  41047. r += t;
  41048. d -= (sp_int64)t * div;
  41049. t = (sp_digit)d;
  41050. t = t / div;
  41051. r += t;
  41052. d -= (sp_int64)t * div;
  41053. return r;
  41054. #endif
  41055. }
  41056. static WC_INLINE sp_digit sp_1024_word_div_word_42(sp_digit d, sp_digit div)
  41057. {
  41058. #if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || \
  41059. defined(SP_DIV_WORD_USE_DIV)
  41060. return d / div;
  41061. #else
  41062. return (sp_digit)((sp_uint32)(div - d) >> 31);
  41063. #endif
  41064. }
  41065. /* Divide d in a and put remainder into r (m*d + r = a)
  41066. * m is not calculated as it is not needed at this time.
  41067. *
  41068. * Full implementation.
  41069. *
  41070. * a Number to be divided.
  41071. * d Number to divide with.
  41072. * m Multiplier result.
  41073. * r Remainder from the division.
  41074. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  41075. */
  41076. static int sp_1024_div_42(const sp_digit* a, const sp_digit* d,
  41077. const sp_digit* m, sp_digit* r)
  41078. {
  41079. int i;
  41080. #ifndef WOLFSSL_SP_DIV_32
  41081. #endif
  41082. sp_digit dv;
  41083. sp_digit r1;
  41084. #ifdef WOLFSSL_SP_SMALL_STACK
  41085. sp_digit* t1 = NULL;
  41086. #else
  41087. sp_digit t1[4 * 42 + 3];
  41088. #endif
  41089. sp_digit* t2 = NULL;
  41090. sp_digit* sd = NULL;
  41091. int err = MP_OKAY;
  41092. (void)m;
  41093. #ifdef WOLFSSL_SP_SMALL_STACK
  41094. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * (4 * 42 + 3), NULL,
  41095. DYNAMIC_TYPE_TMP_BUFFER);
  41096. if (t1 == NULL)
  41097. err = MEMORY_E;
  41098. #endif
  41099. (void)m;
  41100. if (err == MP_OKAY) {
  41101. t2 = t1 + 84 + 1;
  41102. sd = t2 + 42 + 1;
  41103. sp_1024_mul_d_42(sd, d, (sp_digit)1 << 1);
  41104. sp_1024_mul_d_84(t1, a, (sp_digit)1 << 1);
  41105. dv = sd[40];
  41106. t1[41 + 41] += t1[41 + 41 - 1] >> 25;
  41107. t1[41 + 41 - 1] &= 0x1ffffff;
  41108. for (i=41; i>=0; i--) {
  41109. r1 = sp_1024_div_word_42(t1[41 + i], t1[41 + i - 1], dv);
  41110. sp_1024_mul_d_42(t2, sd, r1);
  41111. (void)sp_1024_sub_42(&t1[i], &t1[i], t2);
  41112. sp_1024_norm_41(&t1[i]);
  41113. t1[41 + i] += t1[41 + i - 1] >> 25;
  41114. t1[41 + i - 1] &= 0x1ffffff;
  41115. r1 = sp_1024_div_word_42(-t1[41 + i], -t1[41 + i - 1], dv);
  41116. r1 -= t1[41 + i];
  41117. sp_1024_mul_d_42(t2, sd, r1);
  41118. (void)sp_1024_add_42(&t1[i], &t1[i], t2);
  41119. t1[41 + i] += t1[41 + i - 1] >> 25;
  41120. t1[41 + i - 1] &= 0x1ffffff;
  41121. }
  41122. t1[41 - 1] += t1[41 - 2] >> 25;
  41123. t1[41 - 2] &= 0x1ffffff;
  41124. r1 = sp_1024_word_div_word_42(t1[41 - 1], dv);
  41125. sp_1024_mul_d_42(t2, sd, r1);
  41126. sp_1024_sub_42(t1, t1, t2);
  41127. XMEMCPY(r, t1, sizeof(*r) * 84U);
  41128. for (i=0; i<40; i++) {
  41129. r[i+1] += r[i] >> 25;
  41130. r[i] &= 0x1ffffff;
  41131. }
  41132. sp_1024_cond_add_42(r, r, sd, r[40] >> 31);
  41133. sp_1024_norm_41(r);
  41134. sp_1024_rshift_42(r, r, 1);
  41135. r[41] = 0;
  41136. }
  41137. #ifdef WOLFSSL_SP_SMALL_STACK
  41138. if (t1 != NULL)
  41139. XFREE(t1, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  41140. #endif
  41141. return err;
  41142. }
  41143. /* Reduce a modulo m into r. (r = a mod m)
  41144. *
  41145. * r A single precision number that is the reduced result.
  41146. * a A single precision number that is to be reduced.
  41147. * m A single precision number that is the modulus to reduce with.
  41148. * returns MEMORY_E when unable to allocate memory and MP_OKAY otherwise.
  41149. */
  41150. static int sp_1024_mod_42(sp_digit* r, const sp_digit* a, const sp_digit* m)
  41151. {
  41152. return sp_1024_div_42(a, m, NULL, r);
  41153. }
  41154. /* Multiply a number by Montgomery normalizer mod modulus (prime).
  41155. *
  41156. * r The resulting Montgomery form number.
  41157. * a The number to convert.
  41158. * m The modulus (prime).
  41159. * returns MEMORY_E when memory allocation fails and MP_OKAY otherwise.
  41160. */
  41161. static int sp_1024_mod_mul_norm_42(sp_digit* r, const sp_digit* a,
  41162. const sp_digit* m)
  41163. {
  41164. sp_1024_mul_42(r, a, p1024_norm_mod);
  41165. return sp_1024_mod_42(r, r, m);
  41166. }
  41167. #ifdef WOLFCRYPT_HAVE_SAKKE
  41168. /* Create a new point.
  41169. *
  41170. * heap [in] Buffer to allocate dynamic memory from.
  41171. * sp [in] Data for point - only if not allocating.
  41172. * p [out] New point.
  41173. * returns MEMORY_E when dynamic memory allocation fails and 0 otherwise.
  41174. */
  41175. static int sp_1024_point_new_ex_42(void* heap, sp_point_1024* sp,
  41176. sp_point_1024** p)
  41177. {
  41178. int ret = MP_OKAY;
  41179. (void)heap;
  41180. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  41181. defined(WOLFSSL_SP_SMALL_STACK)
  41182. (void)sp;
  41183. *p = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), heap, DYNAMIC_TYPE_ECC);
  41184. #else
  41185. *p = sp;
  41186. #endif
  41187. if (*p == NULL) {
  41188. ret = MEMORY_E;
  41189. }
  41190. return ret;
  41191. }
  41192. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  41193. defined(WOLFSSL_SP_SMALL_STACK)
  41194. /* Allocate memory for point and return error. */
  41195. #define sp_1024_point_new_42(heap, sp, p) sp_1024_point_new_ex_42((heap), NULL, &(p))
  41196. #else
  41197. /* Set pointer to data and return no error. */
  41198. #define sp_1024_point_new_42(heap, sp, p) sp_1024_point_new_ex_42((heap), &(sp), &(p))
  41199. #endif
  41200. #endif /* WOLFCRYPT_HAVE_SAKKE */
  41201. #ifdef WOLFCRYPT_HAVE_SAKKE
  41202. /* Free the point.
  41203. *
  41204. * p [in,out] Point to free.
  41205. * clear [in] Indicates whether to zeroize point.
  41206. * heap [in] Buffer from which dynamic memory was allocate from.
  41207. */
  41208. static void sp_1024_point_free_42(sp_point_1024* p, int clear, void* heap)
  41209. {
  41210. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  41211. defined(WOLFSSL_SP_SMALL_STACK)
  41212. /* If valid pointer then clear point data if requested and free data. */
  41213. if (p != NULL) {
  41214. if (clear != 0) {
  41215. XMEMSET(p, 0, sizeof(*p));
  41216. }
  41217. XFREE(p, heap, DYNAMIC_TYPE_ECC);
  41218. }
  41219. #else
  41220. /* Clear point data if requested. */
  41221. if ((p != NULL) && (clear != 0)) {
  41222. XMEMSET(p, 0, sizeof(*p));
  41223. }
  41224. #endif
  41225. (void)heap;
  41226. }
  41227. #endif /* WOLFCRYPT_HAVE_SAKKE */
  41228. /* Convert an mp_int to an array of sp_digit.
  41229. *
  41230. * r A single precision integer.
  41231. * size Maximum number of bytes to convert
  41232. * a A multi-precision integer.
  41233. */
  41234. static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
  41235. {
  41236. #if DIGIT_BIT == 25
  41237. int i;
  41238. sp_digit j = (sp_digit)0 - (sp_digit)a->used;
  41239. int o = 0;
  41240. for (i = 0; i < size; i++) {
  41241. sp_digit mask = (sp_digit)0 - (j >> 24);
  41242. r[i] = a->dp[o] & mask;
  41243. j++;
  41244. o += (int)(j >> 24);
  41245. }
  41246. #elif DIGIT_BIT > 25
  41247. unsigned int i;
  41248. int j = 0;
  41249. word32 s = 0;
  41250. r[0] = 0;
  41251. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  41252. r[j] |= ((sp_digit)a->dp[i] << s);
  41253. r[j] &= 0x1ffffff;
  41254. s = 25U - s;
  41255. if (j + 1 >= size) {
  41256. break;
  41257. }
  41258. /* lint allow cast of mismatch word32 and mp_digit */
  41259. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  41260. while ((s + 25U) <= (word32)DIGIT_BIT) {
  41261. s += 25U;
  41262. r[j] &= 0x1ffffff;
  41263. if (j + 1 >= size) {
  41264. break;
  41265. }
  41266. if (s < (word32)DIGIT_BIT) {
  41267. /* lint allow cast of mismatch word32 and mp_digit */
  41268. r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
  41269. }
  41270. else {
  41271. r[++j] = (sp_digit)0;
  41272. }
  41273. }
  41274. s = (word32)DIGIT_BIT - s;
  41275. }
  41276. for (j++; j < size; j++) {
  41277. r[j] = 0;
  41278. }
  41279. #else
  41280. unsigned int i;
  41281. int j = 0;
  41282. int s = 0;
  41283. r[0] = 0;
  41284. for (i = 0; i < (unsigned int)a->used && j < size; i++) {
  41285. r[j] |= ((sp_digit)a->dp[i]) << s;
  41286. if (s + DIGIT_BIT >= 25) {
  41287. r[j] &= 0x1ffffff;
  41288. if (j + 1 >= size) {
  41289. break;
  41290. }
  41291. s = 25 - s;
  41292. if (s == DIGIT_BIT) {
  41293. r[++j] = 0;
  41294. s = 0;
  41295. }
  41296. else {
  41297. r[++j] = a->dp[i] >> s;
  41298. s = DIGIT_BIT - s;
  41299. }
  41300. }
  41301. else {
  41302. s += DIGIT_BIT;
  41303. }
  41304. }
  41305. for (j++; j < size; j++) {
  41306. r[j] = 0;
  41307. }
  41308. #endif
  41309. }
  41310. /* Convert a point of type ecc_point to type sp_point_1024.
  41311. *
  41312. * p Point of type sp_point_1024 (result).
  41313. * pm Point of type ecc_point.
  41314. */
  41315. static void sp_1024_point_from_ecc_point_42(sp_point_1024* p,
  41316. const ecc_point* pm)
  41317. {
  41318. XMEMSET(p->x, 0, sizeof(p->x));
  41319. XMEMSET(p->y, 0, sizeof(p->y));
  41320. XMEMSET(p->z, 0, sizeof(p->z));
  41321. sp_1024_from_mp(p->x, 42, pm->x);
  41322. sp_1024_from_mp(p->y, 42, pm->y);
  41323. sp_1024_from_mp(p->z, 42, pm->z);
  41324. p->infinity = 0;
  41325. }
  41326. /* Convert an array of sp_digit to an mp_int.
  41327. *
  41328. * a A single precision integer.
  41329. * r A multi-precision integer.
  41330. */
  41331. static int sp_1024_to_mp(const sp_digit* a, mp_int* r)
  41332. {
  41333. int err;
  41334. err = mp_grow(r, (1024 + DIGIT_BIT - 1) / DIGIT_BIT);
  41335. if (err == MP_OKAY) { /*lint !e774 case where err is always MP_OKAY*/
  41336. #if DIGIT_BIT == 25
  41337. XMEMCPY(r->dp, a, sizeof(sp_digit) * 41);
  41338. r->used = 41;
  41339. mp_clamp(r);
  41340. #elif DIGIT_BIT < 25
  41341. int i;
  41342. int j = 0;
  41343. int s = 0;
  41344. r->dp[0] = 0;
  41345. for (i = 0; i < 41; i++) {
  41346. r->dp[j] |= (mp_digit)(a[i] << s);
  41347. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  41348. s = DIGIT_BIT - s;
  41349. r->dp[++j] = (mp_digit)(a[i] >> s);
  41350. while (s + DIGIT_BIT <= 25) {
  41351. s += DIGIT_BIT;
  41352. r->dp[j++] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  41353. if (s == SP_WORD_SIZE) {
  41354. r->dp[j] = 0;
  41355. }
  41356. else {
  41357. r->dp[j] = (mp_digit)(a[i] >> s);
  41358. }
  41359. }
  41360. s = 25 - s;
  41361. }
  41362. r->used = (1024 + DIGIT_BIT - 1) / DIGIT_BIT;
  41363. mp_clamp(r);
  41364. #else
  41365. int i;
  41366. int j = 0;
  41367. int s = 0;
  41368. r->dp[0] = 0;
  41369. for (i = 0; i < 41; i++) {
  41370. r->dp[j] |= ((mp_digit)a[i]) << s;
  41371. if (s + 25 >= DIGIT_BIT) {
  41372. #if DIGIT_BIT != 32 && DIGIT_BIT != 64
  41373. r->dp[j] &= ((sp_digit)1 << DIGIT_BIT) - 1;
  41374. #endif
  41375. s = DIGIT_BIT - s;
  41376. r->dp[++j] = a[i] >> s;
  41377. s = 25 - s;
  41378. }
  41379. else {
  41380. s += 25;
  41381. }
  41382. }
  41383. r->used = (1024 + DIGIT_BIT - 1) / DIGIT_BIT;
  41384. mp_clamp(r);
  41385. #endif
  41386. }
  41387. return err;
  41388. }
  41389. /* Convert a point of type sp_point_1024 to type ecc_point.
  41390. *
  41391. * p Point of type sp_point_1024.
  41392. * pm Point of type ecc_point (result).
  41393. * returns MEMORY_E when allocation of memory in ecc_point fails otherwise
  41394. * MP_OKAY.
  41395. */
  41396. static int sp_1024_point_to_ecc_point_42(const sp_point_1024* p, ecc_point* pm)
  41397. {
  41398. int err;
  41399. err = sp_1024_to_mp(p->x, pm->x);
  41400. if (err == MP_OKAY) {
  41401. err = sp_1024_to_mp(p->y, pm->y);
  41402. }
  41403. if (err == MP_OKAY) {
  41404. err = sp_1024_to_mp(p->z, pm->z);
  41405. }
  41406. return err;
  41407. }
  41408. /* Compare a with b in constant time.
  41409. *
  41410. * a A single precision integer.
  41411. * b A single precision integer.
  41412. * return -ve, 0 or +ve if a is less than, equal to or greater than b
  41413. * respectively.
  41414. */
  41415. static sp_digit sp_1024_cmp_42(const sp_digit* a, const sp_digit* b)
  41416. {
  41417. sp_digit r = 0;
  41418. #ifdef WOLFSSL_SP_SMALL
  41419. int i;
  41420. for (i=41; i>=0; i--) {
  41421. r |= (a[i] - b[i]) & ~(((sp_digit)0 - r) >> 24);
  41422. }
  41423. #else
  41424. int i;
  41425. r |= (a[41] - b[41]) & (0 - (sp_digit)1);
  41426. r |= (a[40] - b[40]) & ~(((sp_digit)0 - r) >> 24);
  41427. for (i = 32; i >= 0; i -= 8) {
  41428. r |= (a[i + 7] - b[i + 7]) & ~(((sp_digit)0 - r) >> 24);
  41429. r |= (a[i + 6] - b[i + 6]) & ~(((sp_digit)0 - r) >> 24);
  41430. r |= (a[i + 5] - b[i + 5]) & ~(((sp_digit)0 - r) >> 24);
  41431. r |= (a[i + 4] - b[i + 4]) & ~(((sp_digit)0 - r) >> 24);
  41432. r |= (a[i + 3] - b[i + 3]) & ~(((sp_digit)0 - r) >> 24);
  41433. r |= (a[i + 2] - b[i + 2]) & ~(((sp_digit)0 - r) >> 24);
  41434. r |= (a[i + 1] - b[i + 1]) & ~(((sp_digit)0 - r) >> 24);
  41435. r |= (a[i + 0] - b[i + 0]) & ~(((sp_digit)0 - r) >> 24);
  41436. }
  41437. #endif /* WOLFSSL_SP_SMALL */
  41438. return r;
  41439. }
  41440. /* Conditionally subtract b from a using the mask m.
  41441. * m is -1 to subtract and 0 when not.
  41442. *
  41443. * r A single precision number representing condition subtract result.
  41444. * a A single precision number to subtract from.
  41445. * b A single precision number to subtract.
  41446. * m Mask value to apply.
  41447. */
  41448. static void sp_1024_cond_sub_42(sp_digit* r, const sp_digit* a,
  41449. const sp_digit* b, const sp_digit m)
  41450. {
  41451. #ifdef WOLFSSL_SP_SMALL
  41452. int i;
  41453. for (i = 0; i < 42; i++) {
  41454. r[i] = a[i] - (b[i] & m);
  41455. }
  41456. #else
  41457. int i;
  41458. for (i = 0; i < 40; i += 8) {
  41459. r[i + 0] = a[i + 0] - (b[i + 0] & m);
  41460. r[i + 1] = a[i + 1] - (b[i + 1] & m);
  41461. r[i + 2] = a[i + 2] - (b[i + 2] & m);
  41462. r[i + 3] = a[i + 3] - (b[i + 3] & m);
  41463. r[i + 4] = a[i + 4] - (b[i + 4] & m);
  41464. r[i + 5] = a[i + 5] - (b[i + 5] & m);
  41465. r[i + 6] = a[i + 6] - (b[i + 6] & m);
  41466. r[i + 7] = a[i + 7] - (b[i + 7] & m);
  41467. }
  41468. r[40] = a[40] - (b[40] & m);
  41469. r[41] = a[41] - (b[41] & m);
  41470. #endif /* WOLFSSL_SP_SMALL */
  41471. }
  41472. /* Mul a by scalar b and add into r. (r += a * b)
  41473. *
  41474. * r A single precision integer.
  41475. * a A single precision integer.
  41476. * b A scalar.
  41477. */
  41478. SP_NOINLINE static void sp_1024_mul_add_42(sp_digit* r, const sp_digit* a,
  41479. const sp_digit b)
  41480. {
  41481. #ifdef WOLFSSL_SP_SMALL
  41482. sp_int64 tb = b;
  41483. sp_int64 t[4];
  41484. int i;
  41485. t[0] = 0;
  41486. for (i = 0; i < 40; i += 4) {
  41487. t[0] += (tb * a[i+0]) + r[i+0];
  41488. t[1] = (tb * a[i+1]) + r[i+1];
  41489. t[2] = (tb * a[i+2]) + r[i+2];
  41490. t[3] = (tb * a[i+3]) + r[i+3];
  41491. r[i+0] = t[0] & 0x1ffffff;
  41492. t[1] += t[0] >> 25;
  41493. r[i+1] = t[1] & 0x1ffffff;
  41494. t[2] += t[1] >> 25;
  41495. r[i+2] = t[2] & 0x1ffffff;
  41496. t[3] += t[2] >> 25;
  41497. r[i+3] = t[3] & 0x1ffffff;
  41498. t[0] = t[3] >> 25;
  41499. }
  41500. t[0] += (tb * a[40]) + r[40];
  41501. t[1] = (tb * a[41]) + r[41];
  41502. r[40] = t[0] & 0x1ffffff;
  41503. t[1] += t[0] >> 25;
  41504. r[41] = t[1] & 0x1ffffff;
  41505. r[42] += (sp_digit)(t[1] >> 25);
  41506. #else
  41507. sp_int64 tb = b;
  41508. sp_int64 t[8];
  41509. int i;
  41510. t[0] = tb * a[0]; r[0] += (sp_digit)(t[0] & 0x1ffffff);
  41511. for (i = 0; i < 40; i += 8) {
  41512. t[1] = tb * a[i+1];
  41513. r[i+1] += (sp_digit)((t[0] >> 25) + (t[1] & 0x1ffffff));
  41514. t[2] = tb * a[i+2];
  41515. r[i+2] += (sp_digit)((t[1] >> 25) + (t[2] & 0x1ffffff));
  41516. t[3] = tb * a[i+3];
  41517. r[i+3] += (sp_digit)((t[2] >> 25) + (t[3] & 0x1ffffff));
  41518. t[4] = tb * a[i+4];
  41519. r[i+4] += (sp_digit)((t[3] >> 25) + (t[4] & 0x1ffffff));
  41520. t[5] = tb * a[i+5];
  41521. r[i+5] += (sp_digit)((t[4] >> 25) + (t[5] & 0x1ffffff));
  41522. t[6] = tb * a[i+6];
  41523. r[i+6] += (sp_digit)((t[5] >> 25) + (t[6] & 0x1ffffff));
  41524. t[7] = tb * a[i+7];
  41525. r[i+7] += (sp_digit)((t[6] >> 25) + (t[7] & 0x1ffffff));
  41526. t[0] = tb * a[i+8];
  41527. r[i+8] += (sp_digit)((t[7] >> 25) + (t[0] & 0x1ffffff));
  41528. }
  41529. t[1] = tb * a[41];
  41530. r[41] += (sp_digit)((t[0] >> 25) + (t[1] & 0x1ffffff));
  41531. r[42] += (sp_digit)(t[1] >> 25);
  41532. #endif /* WOLFSSL_SP_SMALL */
  41533. }
  41534. /* Normalize the values in each word to 25 bits.
  41535. *
  41536. * a Array of sp_digit to normalize.
  41537. */
  41538. static void sp_1024_norm_42(sp_digit* a)
  41539. {
  41540. #ifdef WOLFSSL_SP_SMALL
  41541. int i;
  41542. for (i = 0; i < 41; i++) {
  41543. a[i+1] += a[i] >> 25;
  41544. a[i] &= 0x1ffffff;
  41545. }
  41546. #else
  41547. int i;
  41548. for (i = 0; i < 40; i += 8) {
  41549. a[i+1] += a[i+0] >> 25; a[i+0] &= 0x1ffffff;
  41550. a[i+2] += a[i+1] >> 25; a[i+1] &= 0x1ffffff;
  41551. a[i+3] += a[i+2] >> 25; a[i+2] &= 0x1ffffff;
  41552. a[i+4] += a[i+3] >> 25; a[i+3] &= 0x1ffffff;
  41553. a[i+5] += a[i+4] >> 25; a[i+4] &= 0x1ffffff;
  41554. a[i+6] += a[i+5] >> 25; a[i+5] &= 0x1ffffff;
  41555. a[i+7] += a[i+6] >> 25; a[i+6] &= 0x1ffffff;
  41556. a[i+8] += a[i+7] >> 25; a[i+7] &= 0x1ffffff;
  41557. }
  41558. a[41] += a[40] >> 25; a[40] &= 0x1ffffff;
  41559. #endif /* WOLFSSL_SP_SMALL */
  41560. }
  41561. /* Shift the result in the high 1024 bits down to the bottom.
  41562. *
  41563. * r A single precision number.
  41564. * a A single precision number.
  41565. */
  41566. static void sp_1024_mont_shift_42(sp_digit* r, const sp_digit* a)
  41567. {
  41568. #ifdef WOLFSSL_SP_SMALL
  41569. int i;
  41570. sp_uint32 n;
  41571. n = a[40] >> 24;
  41572. for (i = 0; i < 40; i++) {
  41573. n += (sp_uint32)a[41 + i] << 1;
  41574. r[i] = n & 0x1ffffff;
  41575. n >>= 25;
  41576. }
  41577. n += (sp_uint32)a[81] << 1;
  41578. r[40] = n;
  41579. #else
  41580. sp_uint32 n;
  41581. int i;
  41582. n = (sp_uint32)a[40];
  41583. n = n >> 24U;
  41584. for (i = 0; i < 40; i += 8) {
  41585. n += (sp_uint32)a[i+41] << 1U; r[i+0] = n & 0x1ffffff; n >>= 25U;
  41586. n += (sp_uint32)a[i+42] << 1U; r[i+1] = n & 0x1ffffff; n >>= 25U;
  41587. n += (sp_uint32)a[i+43] << 1U; r[i+2] = n & 0x1ffffff; n >>= 25U;
  41588. n += (sp_uint32)a[i+44] << 1U; r[i+3] = n & 0x1ffffff; n >>= 25U;
  41589. n += (sp_uint32)a[i+45] << 1U; r[i+4] = n & 0x1ffffff; n >>= 25U;
  41590. n += (sp_uint32)a[i+46] << 1U; r[i+5] = n & 0x1ffffff; n >>= 25U;
  41591. n += (sp_uint32)a[i+47] << 1U; r[i+6] = n & 0x1ffffff; n >>= 25U;
  41592. n += (sp_uint32)a[i+48] << 1U; r[i+7] = n & 0x1ffffff; n >>= 25U;
  41593. }
  41594. n += (sp_uint32)a[81] << 1U; r[40] = n;
  41595. #endif /* WOLFSSL_SP_SMALL */
  41596. XMEMSET(&r[41], 0, sizeof(*r) * 41U);
  41597. }
  41598. /* Reduce the number back to 1024 bits using Montgomery reduction.
  41599. *
  41600. * a A single precision number to reduce in place.
  41601. * m The single precision number representing the modulus.
  41602. * mp The digit representing the negative inverse of m mod 2^n.
  41603. */
  41604. static void sp_1024_mont_reduce_42(sp_digit* a, const sp_digit* m, sp_digit mp)
  41605. {
  41606. int i;
  41607. sp_digit mu;
  41608. sp_digit over;
  41609. sp_1024_norm_42(a + 41);
  41610. if (mp != 1) {
  41611. for (i=0; i<40; i++) {
  41612. mu = (a[i] * mp) & 0x1ffffff;
  41613. sp_1024_mul_add_42(a+i, m, mu);
  41614. a[i+1] += a[i] >> 25;
  41615. }
  41616. mu = (a[i] * mp) & 0xffffffL;
  41617. sp_1024_mul_add_42(a+i, m, mu);
  41618. a[i+1] += a[i] >> 25;
  41619. a[i] &= 0x1ffffff;
  41620. }
  41621. else {
  41622. for (i=0; i<40; i++) {
  41623. mu = a[i] & 0x1ffffff;
  41624. sp_1024_mul_add_42(a+i, m, mu);
  41625. a[i+1] += a[i] >> 25;
  41626. }
  41627. mu = a[i] & 0xffffffL;
  41628. sp_1024_mul_add_42(a+i, m, mu);
  41629. a[i+1] += a[i] >> 25;
  41630. a[i] &= 0x1ffffff;
  41631. }
  41632. sp_1024_norm_42(a + 41);
  41633. sp_1024_mont_shift_42(a, a);
  41634. over = a[40] - m[40];
  41635. sp_1024_cond_sub_42(a, a, m, ~((over - 1) >> 31));
  41636. sp_1024_norm_42(a);
  41637. }
  41638. /* Multiply two Montgomery form numbers mod the modulus (prime).
  41639. * (r = a * b mod m)
  41640. *
  41641. * r Result of multiplication.
  41642. * a First number to multiply in Montgomery form.
  41643. * b Second number to multiply in Montgomery form.
  41644. * m Modulus (prime).
  41645. * mp Montgomery multiplier.
  41646. */
  41647. SP_NOINLINE static void sp_1024_mont_mul_42(sp_digit* r, const sp_digit* a,
  41648. const sp_digit* b, const sp_digit* m, sp_digit mp)
  41649. {
  41650. sp_1024_mul_42(r, a, b);
  41651. sp_1024_mont_reduce_42(r, m, mp);
  41652. }
  41653. /* Square the Montgomery form number. (r = a * a mod m)
  41654. *
  41655. * r Result of squaring.
  41656. * a Number to square in Montgomery form.
  41657. * m Modulus (prime).
  41658. * mp Montgomery multiplier.
  41659. */
  41660. SP_NOINLINE static void sp_1024_mont_sqr_42(sp_digit* r, const sp_digit* a,
  41661. const sp_digit* m, sp_digit mp)
  41662. {
  41663. sp_1024_sqr_42(r, a);
  41664. sp_1024_mont_reduce_42(r, m, mp);
  41665. }
  41666. /* Mod-2 for the P1024 curve. */
  41667. static const uint8_t p1024_mod_minus_2[] = {
  41668. 6,0x06, 7,0x0f, 7,0x0b, 6,0x0c, 7,0x1e, 9,0x09, 7,0x0c, 7,0x1f,
  41669. 6,0x16, 6,0x06, 7,0x0e, 8,0x10, 6,0x03, 8,0x11, 6,0x0d, 7,0x14,
  41670. 9,0x12, 6,0x0f, 7,0x04, 9,0x0d, 6,0x00, 7,0x13, 6,0x01, 6,0x07,
  41671. 8,0x0d, 8,0x00, 6,0x06, 9,0x17, 6,0x14, 6,0x15, 6,0x11, 6,0x0b,
  41672. 9,0x0c, 6,0x1e, 13,0x14, 7,0x0e, 6,0x1d, 12,0x0a, 6,0x0b, 8,0x07,
  41673. 6,0x18, 6,0x0f, 6,0x10, 8,0x1c, 7,0x16, 7,0x02, 6,0x01, 6,0x13,
  41674. 10,0x15, 7,0x06, 8,0x14, 6,0x0c, 6,0x19, 7,0x10, 6,0x19, 6,0x19,
  41675. 9,0x16, 7,0x19, 6,0x1f, 6,0x17, 6,0x12, 8,0x02, 6,0x01, 6,0x04,
  41676. 6,0x15, 7,0x16, 6,0x04, 6,0x1f, 6,0x09, 7,0x06, 7,0x13, 7,0x09,
  41677. 6,0x0d, 10,0x18, 6,0x06, 6,0x11, 6,0x04, 6,0x01, 6,0x13, 8,0x06,
  41678. 6,0x0d, 8,0x13, 7,0x08, 6,0x08, 6,0x05, 7,0x0c, 7,0x0e, 7,0x15,
  41679. 6,0x05, 7,0x14, 10,0x19, 6,0x10, 6,0x16, 6,0x15, 7,0x1f, 6,0x14,
  41680. 6,0x0a, 10,0x11, 6,0x01, 7,0x05, 7,0x08, 8,0x0a, 7,0x1e, 7,0x1c,
  41681. 6,0x1c, 7,0x09, 10,0x18, 7,0x1c, 10,0x06, 6,0x0a, 6,0x07, 6,0x19,
  41682. 7,0x06, 6,0x0d, 7,0x0f, 7,0x0b, 7,0x05, 6,0x11, 6,0x1c, 7,0x1f,
  41683. 6,0x1e, 7,0x18, 6,0x1e, 6,0x00, 6,0x03, 6,0x02, 7,0x10, 6,0x0b,
  41684. 6,0x1b, 7,0x10, 6,0x00, 8,0x11, 7,0x1b, 6,0x18, 6,0x01, 7,0x0c,
  41685. 7,0x1d, 7,0x13, 6,0x08, 7,0x1b, 8,0x13, 7,0x16, 13,0x1d, 7,0x1f,
  41686. 6,0x0a, 6,0x01, 7,0x1f, 6,0x14, 1,0x01
  41687. };
  41688. /* Invert the number, in Montgomery form, modulo the modulus (prime) of the
  41689. * P1024 curve. (r = 1 / a mod m)
  41690. *
  41691. * r Inverse result.
  41692. * a Number to invert.
  41693. * td Temporary data.
  41694. */
  41695. static void sp_1024_mont_inv_42(sp_digit* r, const sp_digit* a,
  41696. sp_digit* td)
  41697. {
  41698. sp_digit* t = &td[32 * 2 * 42];
  41699. int i;
  41700. int j;
  41701. sp_digit* table[32];
  41702. for (i = 0; i < 32; i++) {
  41703. table[i] = &td[2 * 42 * i];
  41704. }
  41705. XMEMCPY(table[0], a, sizeof(sp_digit) * 42);
  41706. for (i = 1; i < 6; i++) {
  41707. sp_1024_mont_sqr_42(table[0], table[0], p1024_mod, p1024_mp_mod);
  41708. }
  41709. for (i = 1; i < 32; i++) {
  41710. sp_1024_mont_mul_42(table[i], table[i-1], a, p1024_mod, p1024_mp_mod);
  41711. }
  41712. XMEMCPY(t, table[p1024_mod_minus_2[1]], sizeof(sp_digit) * 42);
  41713. for (i = 2; i < (int)sizeof(p1024_mod_minus_2) - 2; i += 2) {
  41714. for (j = 0; j < p1024_mod_minus_2[i]; j++) {
  41715. sp_1024_mont_sqr_42(t, t, p1024_mod, p1024_mp_mod);
  41716. }
  41717. sp_1024_mont_mul_42(t, t, table[p1024_mod_minus_2[i+1]], p1024_mod,
  41718. p1024_mp_mod);
  41719. }
  41720. sp_1024_mont_sqr_42(t, t, p1024_mod, p1024_mp_mod);
  41721. sp_1024_mont_mul_42(r, t, a, p1024_mod, p1024_mp_mod);
  41722. }
  41723. /* Map the Montgomery form projective coordinate point to an affine point.
  41724. *
  41725. * r Resulting affine coordinate point.
  41726. * p Montgomery form projective coordinate point.
  41727. * t Temporary ordinate data.
  41728. */
  41729. static void sp_1024_map_42(sp_point_1024* r, const sp_point_1024* p,
  41730. sp_digit* t)
  41731. {
  41732. sp_digit* t1 = t;
  41733. sp_digit* t2 = t + 2*42;
  41734. sp_int32 n;
  41735. sp_1024_mont_inv_42(t1, p->z, t + 2*42);
  41736. sp_1024_mont_sqr_42(t2, t1, p1024_mod, p1024_mp_mod);
  41737. sp_1024_mont_mul_42(t1, t2, t1, p1024_mod, p1024_mp_mod);
  41738. /* x /= z^2 */
  41739. sp_1024_mont_mul_42(r->x, p->x, t2, p1024_mod, p1024_mp_mod);
  41740. XMEMSET(r->x + 42, 0, sizeof(sp_digit) * 42U);
  41741. sp_1024_mont_reduce_42(r->x, p1024_mod, p1024_mp_mod);
  41742. /* Reduce x to less than modulus */
  41743. n = sp_1024_cmp_42(r->x, p1024_mod);
  41744. sp_1024_cond_sub_42(r->x, r->x, p1024_mod, ~(n >> 24));
  41745. sp_1024_norm_42(r->x);
  41746. /* y /= z^3 */
  41747. sp_1024_mont_mul_42(r->y, p->y, t1, p1024_mod, p1024_mp_mod);
  41748. XMEMSET(r->y + 42, 0, sizeof(sp_digit) * 42U);
  41749. sp_1024_mont_reduce_42(r->y, p1024_mod, p1024_mp_mod);
  41750. /* Reduce y to less than modulus */
  41751. n = sp_1024_cmp_42(r->y, p1024_mod);
  41752. sp_1024_cond_sub_42(r->y, r->y, p1024_mod, ~(n >> 24));
  41753. sp_1024_norm_42(r->y);
  41754. XMEMSET(r->z, 0, sizeof(r->z) / 2);
  41755. r->z[0] = 1;
  41756. }
  41757. /* Add two Montgomery form numbers (r = a + b % m).
  41758. *
  41759. * r Result of addition.
  41760. * a First number to add in Montgomery form.
  41761. * b Second number to add in Montgomery form.
  41762. * m Modulus (prime).
  41763. */
  41764. static void sp_1024_mont_add_42(sp_digit* r, const sp_digit* a, const sp_digit* b,
  41765. const sp_digit* m)
  41766. {
  41767. sp_digit over;
  41768. (void)sp_1024_add_42(r, a, b);
  41769. sp_1024_norm_42(r);
  41770. over = r[40] - m[40];
  41771. sp_1024_cond_sub_42(r, r, m, ~((over - 1) >> 31));
  41772. sp_1024_norm_42(r);
  41773. }
  41774. /* Double a Montgomery form number (r = a + a % m).
  41775. *
  41776. * r Result of doubling.
  41777. * a Number to double in Montgomery form.
  41778. * m Modulus (prime).
  41779. */
  41780. static void sp_1024_mont_dbl_42(sp_digit* r, const sp_digit* a, const sp_digit* m)
  41781. {
  41782. sp_digit over;
  41783. (void)sp_1024_add_42(r, a, a);
  41784. sp_1024_norm_42(r);
  41785. over = r[40] - m[40];
  41786. sp_1024_cond_sub_42(r, r, m, ~((over - 1) >> 31));
  41787. sp_1024_norm_42(r);
  41788. }
  41789. /* Triple a Montgomery form number (r = a + a + a % m).
  41790. *
  41791. * r Result of Tripling.
  41792. * a Number to triple in Montgomery form.
  41793. * m Modulus (prime).
  41794. */
  41795. static void sp_1024_mont_tpl_42(sp_digit* r, const sp_digit* a, const sp_digit* m)
  41796. {
  41797. sp_digit over;
  41798. (void)sp_1024_add_42(r, a, a);
  41799. sp_1024_norm_42(r);
  41800. over = r[40] - m[40];
  41801. sp_1024_cond_sub_42(r, r, m, ~((over - 1) >> 31));
  41802. sp_1024_norm_42(r);
  41803. (void)sp_1024_add_42(r, r, a);
  41804. sp_1024_norm_42(r);
  41805. over = r[40] - m[40];
  41806. sp_1024_cond_sub_42(r, r, m, ~((over - 1) >> 31));
  41807. sp_1024_norm_42(r);
  41808. }
  41809. /* Subtract two Montgomery form numbers (r = a - b % m).
  41810. *
  41811. * r Result of subtration.
  41812. * a Number to subtract from in Montgomery form.
  41813. * b Number to subtract with in Montgomery form.
  41814. * m Modulus (prime).
  41815. */
  41816. static void sp_1024_mont_sub_42(sp_digit* r, const sp_digit* a, const sp_digit* b,
  41817. const sp_digit* m)
  41818. {
  41819. (void)sp_1024_sub_42(r, a, b);
  41820. sp_1024_norm_42(r);
  41821. sp_1024_cond_add_42(r, r, m, r[41] >> 7);
  41822. sp_1024_norm_42(r);
  41823. }
  41824. /* Shift number left one bit.
  41825. * Bottom bit is lost.
  41826. *
  41827. * r Result of shift.
  41828. * a Number to shift.
  41829. */
  41830. SP_NOINLINE static void sp_1024_rshift1_42(sp_digit* r, const sp_digit* a)
  41831. {
  41832. #ifdef WOLFSSL_SP_SMALL
  41833. int i;
  41834. for (i=0; i<41; i++) {
  41835. r[i] = (a[i] >> 1) + ((a[i + 1] << 24) & 0x1ffffff);
  41836. }
  41837. #else
  41838. r[0] = (a[0] >> 1) + ((a[1] << 24) & 0x1ffffff);
  41839. r[1] = (a[1] >> 1) + ((a[2] << 24) & 0x1ffffff);
  41840. r[2] = (a[2] >> 1) + ((a[3] << 24) & 0x1ffffff);
  41841. r[3] = (a[3] >> 1) + ((a[4] << 24) & 0x1ffffff);
  41842. r[4] = (a[4] >> 1) + ((a[5] << 24) & 0x1ffffff);
  41843. r[5] = (a[5] >> 1) + ((a[6] << 24) & 0x1ffffff);
  41844. r[6] = (a[6] >> 1) + ((a[7] << 24) & 0x1ffffff);
  41845. r[7] = (a[7] >> 1) + ((a[8] << 24) & 0x1ffffff);
  41846. r[8] = (a[8] >> 1) + ((a[9] << 24) & 0x1ffffff);
  41847. r[9] = (a[9] >> 1) + ((a[10] << 24) & 0x1ffffff);
  41848. r[10] = (a[10] >> 1) + ((a[11] << 24) & 0x1ffffff);
  41849. r[11] = (a[11] >> 1) + ((a[12] << 24) & 0x1ffffff);
  41850. r[12] = (a[12] >> 1) + ((a[13] << 24) & 0x1ffffff);
  41851. r[13] = (a[13] >> 1) + ((a[14] << 24) & 0x1ffffff);
  41852. r[14] = (a[14] >> 1) + ((a[15] << 24) & 0x1ffffff);
  41853. r[15] = (a[15] >> 1) + ((a[16] << 24) & 0x1ffffff);
  41854. r[16] = (a[16] >> 1) + ((a[17] << 24) & 0x1ffffff);
  41855. r[17] = (a[17] >> 1) + ((a[18] << 24) & 0x1ffffff);
  41856. r[18] = (a[18] >> 1) + ((a[19] << 24) & 0x1ffffff);
  41857. r[19] = (a[19] >> 1) + ((a[20] << 24) & 0x1ffffff);
  41858. r[20] = (a[20] >> 1) + ((a[21] << 24) & 0x1ffffff);
  41859. r[21] = (a[21] >> 1) + ((a[22] << 24) & 0x1ffffff);
  41860. r[22] = (a[22] >> 1) + ((a[23] << 24) & 0x1ffffff);
  41861. r[23] = (a[23] >> 1) + ((a[24] << 24) & 0x1ffffff);
  41862. r[24] = (a[24] >> 1) + ((a[25] << 24) & 0x1ffffff);
  41863. r[25] = (a[25] >> 1) + ((a[26] << 24) & 0x1ffffff);
  41864. r[26] = (a[26] >> 1) + ((a[27] << 24) & 0x1ffffff);
  41865. r[27] = (a[27] >> 1) + ((a[28] << 24) & 0x1ffffff);
  41866. r[28] = (a[28] >> 1) + ((a[29] << 24) & 0x1ffffff);
  41867. r[29] = (a[29] >> 1) + ((a[30] << 24) & 0x1ffffff);
  41868. r[30] = (a[30] >> 1) + ((a[31] << 24) & 0x1ffffff);
  41869. r[31] = (a[31] >> 1) + ((a[32] << 24) & 0x1ffffff);
  41870. r[32] = (a[32] >> 1) + ((a[33] << 24) & 0x1ffffff);
  41871. r[33] = (a[33] >> 1) + ((a[34] << 24) & 0x1ffffff);
  41872. r[34] = (a[34] >> 1) + ((a[35] << 24) & 0x1ffffff);
  41873. r[35] = (a[35] >> 1) + ((a[36] << 24) & 0x1ffffff);
  41874. r[36] = (a[36] >> 1) + ((a[37] << 24) & 0x1ffffff);
  41875. r[37] = (a[37] >> 1) + ((a[38] << 24) & 0x1ffffff);
  41876. r[38] = (a[38] >> 1) + ((a[39] << 24) & 0x1ffffff);
  41877. r[39] = (a[39] >> 1) + ((a[40] << 24) & 0x1ffffff);
  41878. r[40] = (a[40] >> 1) + ((a[41] << 24) & 0x1ffffff);
  41879. #endif
  41880. r[41] = a[41] >> 1;
  41881. }
  41882. /* Divide the number by 2 mod the modulus (prime). (r = a / 2 % m)
  41883. *
  41884. * r Result of division by 2.
  41885. * a Number to divide.
  41886. * m Modulus (prime).
  41887. */
  41888. static void sp_1024_mont_div2_42(sp_digit* r, const sp_digit* a,
  41889. const sp_digit* m)
  41890. {
  41891. sp_1024_cond_add_42(r, a, m, 0 - (a[0] & 1));
  41892. sp_1024_norm_42(r);
  41893. sp_1024_rshift1_42(r, r);
  41894. }
  41895. /* Double the Montgomery form projective point p.
  41896. *
  41897. * r Result of doubling point.
  41898. * p Point to double.
  41899. * t Temporary ordinate data.
  41900. */
  41901. static void sp_1024_proj_point_dbl_42(sp_point_1024* r, const sp_point_1024* p,
  41902. sp_digit* t)
  41903. {
  41904. sp_digit* t1 = t;
  41905. sp_digit* t2 = t + 2*42;
  41906. sp_digit* x;
  41907. sp_digit* y;
  41908. sp_digit* z;
  41909. x = r->x;
  41910. y = r->y;
  41911. z = r->z;
  41912. /* Put infinity into result. */
  41913. if (r != p) {
  41914. r->infinity = p->infinity;
  41915. }
  41916. /* T1 = Z * Z */
  41917. sp_1024_mont_sqr_42(t1, p->z, p1024_mod, p1024_mp_mod);
  41918. /* Z = Y * Z */
  41919. sp_1024_mont_mul_42(z, p->y, p->z, p1024_mod, p1024_mp_mod);
  41920. /* Z = 2Z */
  41921. sp_1024_mont_dbl_42(z, z, p1024_mod);
  41922. /* T2 = X - T1 */
  41923. sp_1024_mont_sub_42(t2, p->x, t1, p1024_mod);
  41924. /* T1 = X + T1 */
  41925. sp_1024_mont_add_42(t1, p->x, t1, p1024_mod);
  41926. /* T2 = T1 * T2 */
  41927. sp_1024_mont_mul_42(t2, t1, t2, p1024_mod, p1024_mp_mod);
  41928. /* T1 = 3T2 */
  41929. sp_1024_mont_tpl_42(t1, t2, p1024_mod);
  41930. /* Y = 2Y */
  41931. sp_1024_mont_dbl_42(y, p->y, p1024_mod);
  41932. /* Y = Y * Y */
  41933. sp_1024_mont_sqr_42(y, y, p1024_mod, p1024_mp_mod);
  41934. /* T2 = Y * Y */
  41935. sp_1024_mont_sqr_42(t2, y, p1024_mod, p1024_mp_mod);
  41936. /* T2 = T2/2 */
  41937. sp_1024_mont_div2_42(t2, t2, p1024_mod);
  41938. /* Y = Y * X */
  41939. sp_1024_mont_mul_42(y, y, p->x, p1024_mod, p1024_mp_mod);
  41940. /* X = T1 * T1 */
  41941. sp_1024_mont_sqr_42(x, t1, p1024_mod, p1024_mp_mod);
  41942. /* X = X - Y */
  41943. sp_1024_mont_sub_42(x, x, y, p1024_mod);
  41944. /* X = X - Y */
  41945. sp_1024_mont_sub_42(x, x, y, p1024_mod);
  41946. /* Y = Y - X */
  41947. sp_1024_mont_sub_42(y, y, x, p1024_mod);
  41948. /* Y = Y * T1 */
  41949. sp_1024_mont_mul_42(y, y, t1, p1024_mod, p1024_mp_mod);
  41950. /* Y = Y - T2 */
  41951. sp_1024_mont_sub_42(y, y, t2, p1024_mod);
  41952. }
  41953. #ifdef WOLFSSL_SP_NONBLOCK
  41954. typedef struct sp_1024_proj_point_dbl_42_ctx {
  41955. int state;
  41956. sp_digit* t1;
  41957. sp_digit* t2;
  41958. sp_digit* x;
  41959. sp_digit* y;
  41960. sp_digit* z;
  41961. } sp_1024_proj_point_dbl_42_ctx;
  41962. /* Double the Montgomery form projective point p.
  41963. *
  41964. * r Result of doubling point.
  41965. * p Point to double.
  41966. * t Temporary ordinate data.
  41967. */
  41968. static int sp_1024_proj_point_dbl_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
  41969. const sp_point_1024* p, sp_digit* t)
  41970. {
  41971. int err = FP_WOULDBLOCK;
  41972. sp_1024_proj_point_dbl_42_ctx* ctx = (sp_1024_proj_point_dbl_42_ctx*)sp_ctx->data;
  41973. typedef char ctx_size_test[sizeof(sp_1024_proj_point_dbl_42_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  41974. (void)sizeof(ctx_size_test);
  41975. switch (ctx->state) {
  41976. case 0:
  41977. ctx->t1 = t;
  41978. ctx->t2 = t + 2*42;
  41979. ctx->x = r->x;
  41980. ctx->y = r->y;
  41981. ctx->z = r->z;
  41982. /* Put infinity into result. */
  41983. if (r != p) {
  41984. r->infinity = p->infinity;
  41985. }
  41986. ctx->state = 1;
  41987. break;
  41988. case 1:
  41989. /* T1 = Z * Z */
  41990. sp_1024_mont_sqr_42(ctx->t1, p->z, p1024_mod, p1024_mp_mod);
  41991. ctx->state = 2;
  41992. break;
  41993. case 2:
  41994. /* Z = Y * Z */
  41995. sp_1024_mont_mul_42(ctx->z, p->y, p->z, p1024_mod, p1024_mp_mod);
  41996. ctx->state = 3;
  41997. break;
  41998. case 3:
  41999. /* Z = 2Z */
  42000. sp_1024_mont_dbl_42(ctx->z, ctx->z, p1024_mod);
  42001. ctx->state = 4;
  42002. break;
  42003. case 4:
  42004. /* T2 = X - T1 */
  42005. sp_1024_mont_sub_42(ctx->t2, p->x, ctx->t1, p1024_mod);
  42006. ctx->state = 5;
  42007. break;
  42008. case 5:
  42009. /* T1 = X + T1 */
  42010. sp_1024_mont_add_42(ctx->t1, p->x, ctx->t1, p1024_mod);
  42011. ctx->state = 6;
  42012. break;
  42013. case 6:
  42014. /* T2 = T1 * T2 */
  42015. sp_1024_mont_mul_42(ctx->t2, ctx->t1, ctx->t2, p1024_mod, p1024_mp_mod);
  42016. ctx->state = 7;
  42017. break;
  42018. case 7:
  42019. /* T1 = 3T2 */
  42020. sp_1024_mont_tpl_42(ctx->t1, ctx->t2, p1024_mod);
  42021. ctx->state = 8;
  42022. break;
  42023. case 8:
  42024. /* Y = 2Y */
  42025. sp_1024_mont_dbl_42(ctx->y, p->y, p1024_mod);
  42026. ctx->state = 9;
  42027. break;
  42028. case 9:
  42029. /* Y = Y * Y */
  42030. sp_1024_mont_sqr_42(ctx->y, ctx->y, p1024_mod, p1024_mp_mod);
  42031. ctx->state = 10;
  42032. break;
  42033. case 10:
  42034. /* T2 = Y * Y */
  42035. sp_1024_mont_sqr_42(ctx->t2, ctx->y, p1024_mod, p1024_mp_mod);
  42036. ctx->state = 11;
  42037. break;
  42038. case 11:
  42039. /* T2 = T2/2 */
  42040. sp_1024_mont_div2_42(ctx->t2, ctx->t2, p1024_mod);
  42041. ctx->state = 12;
  42042. break;
  42043. case 12:
  42044. /* Y = Y * X */
  42045. sp_1024_mont_mul_42(ctx->y, ctx->y, p->x, p1024_mod, p1024_mp_mod);
  42046. ctx->state = 13;
  42047. break;
  42048. case 13:
  42049. /* X = T1 * T1 */
  42050. sp_1024_mont_sqr_42(ctx->x, ctx->t1, p1024_mod, p1024_mp_mod);
  42051. ctx->state = 14;
  42052. break;
  42053. case 14:
  42054. /* X = X - Y */
  42055. sp_1024_mont_sub_42(ctx->x, ctx->x, ctx->y, p1024_mod);
  42056. ctx->state = 15;
  42057. break;
  42058. case 15:
  42059. /* X = X - Y */
  42060. sp_1024_mont_sub_42(ctx->x, ctx->x, ctx->y, p1024_mod);
  42061. ctx->state = 16;
  42062. break;
  42063. case 16:
  42064. /* Y = Y - X */
  42065. sp_1024_mont_sub_42(ctx->y, ctx->y, ctx->x, p1024_mod);
  42066. ctx->state = 17;
  42067. break;
  42068. case 17:
  42069. /* Y = Y * T1 */
  42070. sp_1024_mont_mul_42(ctx->y, ctx->y, ctx->t1, p1024_mod, p1024_mp_mod);
  42071. ctx->state = 18;
  42072. break;
  42073. case 18:
  42074. /* Y = Y - T2 */
  42075. sp_1024_mont_sub_42(ctx->y, ctx->y, ctx->t2, p1024_mod);
  42076. ctx->state = 19;
  42077. /* fall-through */
  42078. case 19:
  42079. err = MP_OKAY;
  42080. break;
  42081. }
  42082. if (err == MP_OKAY && ctx->state != 19) {
  42083. err = FP_WOULDBLOCK;
  42084. }
  42085. return err;
  42086. }
  42087. #endif /* WOLFSSL_SP_NONBLOCK */
  42088. /* Compare two numbers to determine if they are equal.
  42089. * Constant time implementation.
  42090. *
  42091. * a First number to compare.
  42092. * b Second number to compare.
  42093. * returns 1 when equal and 0 otherwise.
  42094. */
  42095. static int sp_1024_cmp_equal_42(const sp_digit* a, const sp_digit* b)
  42096. {
  42097. return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
  42098. (a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
  42099. (a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
  42100. (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
  42101. (a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
  42102. (a[15] ^ b[15]) | (a[16] ^ b[16]) | (a[17] ^ b[17]) |
  42103. (a[18] ^ b[18]) | (a[19] ^ b[19]) | (a[20] ^ b[20]) |
  42104. (a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
  42105. (a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) |
  42106. (a[27] ^ b[27]) | (a[28] ^ b[28]) | (a[29] ^ b[29]) |
  42107. (a[30] ^ b[30]) | (a[31] ^ b[31]) | (a[32] ^ b[32]) |
  42108. (a[33] ^ b[33]) | (a[34] ^ b[34]) | (a[35] ^ b[35]) |
  42109. (a[36] ^ b[36]) | (a[37] ^ b[37]) | (a[38] ^ b[38]) |
  42110. (a[39] ^ b[39]) | (a[40] ^ b[40]) | (a[41] ^ b[41])) == 0;
  42111. }
  42112. /* Returns 1 if the number of zero.
  42113. * Implementation is constant time.
  42114. *
  42115. * a Number to check.
  42116. * returns 1 if the number is zero and 0 otherwise.
  42117. */
  42118. static int sp_1024_iszero_42(const sp_digit* a)
  42119. {
  42120. return (a[0] | a[1] | a[2] | a[3] | a[4] | a[5] | a[6] | a[7] |
  42121. a[8] | a[9] | a[10] | a[11] | a[12] | a[13] | a[14] | a[15] |
  42122. a[16] | a[17] | a[18] | a[19] | a[20] | a[21] | a[22] | a[23] |
  42123. a[24] | a[25] | a[26] | a[27] | a[28] | a[29] | a[30] | a[31] |
  42124. a[32] | a[33] | a[34] | a[35] | a[36] | a[37] | a[38] | a[39] |
  42125. a[40] | a[41]) == 0;
  42126. }
  42127. /* Add two Montgomery form projective points.
  42128. *
  42129. * r Result of addition.
  42130. * p First point to add.
  42131. * q Second point to add.
  42132. * t Temporary ordinate data.
  42133. */
  42134. static void sp_1024_proj_point_add_42(sp_point_1024* r,
  42135. const sp_point_1024* p, const sp_point_1024* q, sp_digit* t)
  42136. {
  42137. sp_digit* t6 = t;
  42138. sp_digit* t1 = t + 2*42;
  42139. sp_digit* t2 = t + 4*42;
  42140. sp_digit* t3 = t + 6*42;
  42141. sp_digit* t4 = t + 8*42;
  42142. sp_digit* t5 = t + 10*42;
  42143. /* U1 = X1*Z2^2 */
  42144. sp_1024_mont_sqr_42(t1, q->z, p1024_mod, p1024_mp_mod);
  42145. sp_1024_mont_mul_42(t3, t1, q->z, p1024_mod, p1024_mp_mod);
  42146. sp_1024_mont_mul_42(t1, t1, p->x, p1024_mod, p1024_mp_mod);
  42147. /* U2 = X2*Z1^2 */
  42148. sp_1024_mont_sqr_42(t2, p->z, p1024_mod, p1024_mp_mod);
  42149. sp_1024_mont_mul_42(t4, t2, p->z, p1024_mod, p1024_mp_mod);
  42150. sp_1024_mont_mul_42(t2, t2, q->x, p1024_mod, p1024_mp_mod);
  42151. /* S1 = Y1*Z2^3 */
  42152. sp_1024_mont_mul_42(t3, t3, p->y, p1024_mod, p1024_mp_mod);
  42153. /* S2 = Y2*Z1^3 */
  42154. sp_1024_mont_mul_42(t4, t4, q->y, p1024_mod, p1024_mp_mod);
  42155. /* Check double */
  42156. if ((~p->infinity) & (~q->infinity) &
  42157. sp_1024_cmp_equal_42(t2, t1) &
  42158. sp_1024_cmp_equal_42(t4, t3)) {
  42159. sp_1024_proj_point_dbl_42(r, p, t);
  42160. }
  42161. else {
  42162. sp_digit* x = t6;
  42163. sp_digit* y = t1;
  42164. sp_digit* z = t2;
  42165. /* H = U2 - U1 */
  42166. sp_1024_mont_sub_42(t2, t2, t1, p1024_mod);
  42167. /* R = S2 - S1 */
  42168. sp_1024_mont_sub_42(t4, t4, t3, p1024_mod);
  42169. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  42170. sp_1024_mont_sqr_42(t5, t2, p1024_mod, p1024_mp_mod);
  42171. sp_1024_mont_mul_42(y, t1, t5, p1024_mod, p1024_mp_mod);
  42172. sp_1024_mont_mul_42(t5, t5, t2, p1024_mod, p1024_mp_mod);
  42173. /* Z3 = H*Z1*Z2 */
  42174. sp_1024_mont_mul_42(z, p->z, t2, p1024_mod, p1024_mp_mod);
  42175. sp_1024_mont_mul_42(z, z, q->z, p1024_mod, p1024_mp_mod);
  42176. sp_1024_mont_sqr_42(x, t4, p1024_mod, p1024_mp_mod);
  42177. sp_1024_mont_sub_42(x, x, t5, p1024_mod);
  42178. sp_1024_mont_mul_42(t5, t5, t3, p1024_mod, p1024_mp_mod);
  42179. sp_1024_mont_dbl_42(t3, y, p1024_mod);
  42180. sp_1024_mont_sub_42(x, x, t3, p1024_mod);
  42181. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  42182. sp_1024_mont_sub_42(y, y, x, p1024_mod);
  42183. sp_1024_mont_mul_42(y, y, t4, p1024_mod, p1024_mp_mod);
  42184. sp_1024_mont_sub_42(y, y, t5, p1024_mod);
  42185. {
  42186. int i;
  42187. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  42188. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  42189. sp_digit maskt = ~(maskp | maskq);
  42190. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  42191. for (i = 0; i < 42; i++) {
  42192. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  42193. (x[i] & maskt);
  42194. }
  42195. for (i = 0; i < 42; i++) {
  42196. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  42197. (y[i] & maskt);
  42198. }
  42199. for (i = 0; i < 42; i++) {
  42200. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  42201. (z[i] & maskt);
  42202. }
  42203. r->z[0] |= inf;
  42204. r->infinity = (word32)inf;
  42205. }
  42206. }
  42207. }
  42208. #ifdef WOLFSSL_SP_NONBLOCK
  42209. typedef struct sp_1024_proj_point_add_42_ctx {
  42210. int state;
  42211. sp_1024_proj_point_dbl_42_ctx dbl_ctx;
  42212. const sp_point_1024* ap[2];
  42213. sp_point_1024* rp[2];
  42214. sp_digit* t1;
  42215. sp_digit* t2;
  42216. sp_digit* t3;
  42217. sp_digit* t4;
  42218. sp_digit* t5;
  42219. sp_digit* t6;
  42220. sp_digit* x;
  42221. sp_digit* y;
  42222. sp_digit* z;
  42223. } sp_1024_proj_point_add_42_ctx;
  42224. /* Add two Montgomery form projective points.
  42225. *
  42226. * r Result of addition.
  42227. * p First point to add.
  42228. * q Second point to add.
  42229. * t Temporary ordinate data.
  42230. */
  42231. static int sp_1024_proj_point_add_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
  42232. const sp_point_1024* p, const sp_point_1024* q, sp_digit* t)
  42233. {
  42234. int err = FP_WOULDBLOCK;
  42235. sp_1024_proj_point_add_42_ctx* ctx = (sp_1024_proj_point_add_42_ctx*)sp_ctx->data;
  42236. /* Ensure only the first point is the same as the result. */
  42237. if (q == r) {
  42238. const sp_point_1024* a = p;
  42239. p = q;
  42240. q = a;
  42241. }
  42242. typedef char ctx_size_test[sizeof(sp_1024_proj_point_add_42_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  42243. (void)sizeof(ctx_size_test);
  42244. switch (ctx->state) {
  42245. case 0: /* INIT */
  42246. ctx->t6 = t;
  42247. ctx->t1 = t + 2*42;
  42248. ctx->t2 = t + 4*42;
  42249. ctx->t3 = t + 6*42;
  42250. ctx->t4 = t + 8*42;
  42251. ctx->t5 = t + 10*42;
  42252. ctx->x = ctx->t6;
  42253. ctx->y = ctx->t1;
  42254. ctx->z = ctx->t2;
  42255. ctx->state = 1;
  42256. break;
  42257. case 1:
  42258. /* U1 = X1*Z2^2 */
  42259. sp_1024_mont_sqr_42(ctx->t1, q->z, p1024_mod, p1024_mp_mod);
  42260. ctx->state = 2;
  42261. break;
  42262. case 2:
  42263. sp_1024_mont_mul_42(ctx->t3, ctx->t1, q->z, p1024_mod, p1024_mp_mod);
  42264. ctx->state = 3;
  42265. break;
  42266. case 3:
  42267. sp_1024_mont_mul_42(ctx->t1, ctx->t1, p->x, p1024_mod, p1024_mp_mod);
  42268. ctx->state = 4;
  42269. break;
  42270. case 4:
  42271. /* U2 = X2*Z1^2 */
  42272. sp_1024_mont_sqr_42(ctx->t2, p->z, p1024_mod, p1024_mp_mod);
  42273. ctx->state = 5;
  42274. break;
  42275. case 5:
  42276. sp_1024_mont_mul_42(ctx->t4, ctx->t2, p->z, p1024_mod, p1024_mp_mod);
  42277. ctx->state = 6;
  42278. break;
  42279. case 6:
  42280. sp_1024_mont_mul_42(ctx->t2, ctx->t2, q->x, p1024_mod, p1024_mp_mod);
  42281. ctx->state = 7;
  42282. break;
  42283. case 7:
  42284. /* S1 = Y1*Z2^3 */
  42285. sp_1024_mont_mul_42(ctx->t3, ctx->t3, p->y, p1024_mod, p1024_mp_mod);
  42286. ctx->state = 8;
  42287. break;
  42288. case 8:
  42289. /* S2 = Y2*Z1^3 */
  42290. sp_1024_mont_mul_42(ctx->t4, ctx->t4, q->y, p1024_mod, p1024_mp_mod);
  42291. ctx->state = 9;
  42292. break;
  42293. case 9:
  42294. /* Check double */
  42295. if ((~p->infinity) & (~q->infinity) &
  42296. sp_1024_cmp_equal_42(ctx->t2, ctx->t1) &
  42297. sp_1024_cmp_equal_42(ctx->t4, ctx->t3)) {
  42298. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  42299. sp_1024_proj_point_dbl_42(r, p, t);
  42300. ctx->state = 25;
  42301. }
  42302. else {
  42303. ctx->state = 10;
  42304. }
  42305. break;
  42306. case 10:
  42307. /* H = U2 - U1 */
  42308. sp_1024_mont_sub_42(ctx->t2, ctx->t2, ctx->t1, p1024_mod);
  42309. ctx->state = 11;
  42310. break;
  42311. case 11:
  42312. /* R = S2 - S1 */
  42313. sp_1024_mont_sub_42(ctx->t4, ctx->t4, ctx->t3, p1024_mod);
  42314. ctx->state = 12;
  42315. break;
  42316. case 12:
  42317. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  42318. sp_1024_mont_sqr_42(ctx->t5, ctx->t2, p1024_mod, p1024_mp_mod);
  42319. ctx->state = 13;
  42320. break;
  42321. case 13:
  42322. sp_1024_mont_mul_42(ctx->y, ctx->t1, ctx->t5, p1024_mod, p1024_mp_mod);
  42323. ctx->state = 14;
  42324. break;
  42325. case 14:
  42326. sp_1024_mont_mul_42(ctx->t5, ctx->t5, ctx->t2, p1024_mod, p1024_mp_mod);
  42327. ctx->state = 15;
  42328. break;
  42329. case 15:
  42330. /* Z3 = H*Z1*Z2 */
  42331. sp_1024_mont_mul_42(ctx->z, p->z, ctx->t2, p1024_mod, p1024_mp_mod);
  42332. ctx->state = 16;
  42333. break;
  42334. case 16:
  42335. sp_1024_mont_mul_42(ctx->z, ctx->z, q->z, p1024_mod, p1024_mp_mod);
  42336. ctx->state = 17;
  42337. break;
  42338. case 17:
  42339. sp_1024_mont_sqr_42(ctx->x, ctx->t4, p1024_mod, p1024_mp_mod);
  42340. ctx->state = 18;
  42341. break;
  42342. case 18:
  42343. sp_1024_mont_sub_42(ctx->x, ctx->x, ctx->t5, p1024_mod);
  42344. ctx->state = 19;
  42345. break;
  42346. case 19:
  42347. sp_1024_mont_mul_42(ctx->t5, ctx->t5, ctx->t3, p1024_mod, p1024_mp_mod);
  42348. ctx->state = 20;
  42349. break;
  42350. case 20:
  42351. sp_1024_mont_dbl_42(ctx->t3, ctx->y, p1024_mod);
  42352. sp_1024_mont_sub_42(ctx->x, ctx->x, ctx->t3, p1024_mod);
  42353. ctx->state = 21;
  42354. break;
  42355. case 21:
  42356. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  42357. sp_1024_mont_sub_42(ctx->y, ctx->y, ctx->x, p1024_mod);
  42358. ctx->state = 22;
  42359. break;
  42360. case 22:
  42361. sp_1024_mont_mul_42(ctx->y, ctx->y, ctx->t4, p1024_mod, p1024_mp_mod);
  42362. ctx->state = 23;
  42363. break;
  42364. case 23:
  42365. sp_1024_mont_sub_42(ctx->y, ctx->y, ctx->t5, p1024_mod);
  42366. ctx->state = 24;
  42367. break;
  42368. case 24:
  42369. {
  42370. {
  42371. int i;
  42372. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  42373. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  42374. sp_digit maskt = ~(maskp | maskq);
  42375. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  42376. for (i = 0; i < 42; i++) {
  42377. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  42378. (ctx->x[i] & maskt);
  42379. }
  42380. for (i = 0; i < 42; i++) {
  42381. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  42382. (ctx->y[i] & maskt);
  42383. }
  42384. for (i = 0; i < 42; i++) {
  42385. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  42386. (ctx->z[i] & maskt);
  42387. }
  42388. r->z[0] |= inf;
  42389. r->infinity = (word32)inf;
  42390. }
  42391. ctx->state = 25;
  42392. break;
  42393. }
  42394. case 25:
  42395. err = MP_OKAY;
  42396. break;
  42397. }
  42398. if (err == MP_OKAY && ctx->state != 25) {
  42399. err = FP_WOULDBLOCK;
  42400. }
  42401. return err;
  42402. }
  42403. #endif /* WOLFSSL_SP_NONBLOCK */
  42404. #ifdef WOLFSSL_SP_SMALL
  42405. /* Multiply the point by the scalar and return the result.
  42406. * If map is true then convert result to affine coordinates.
  42407. *
  42408. * Small implementation using add and double that is cache attack resistant but
  42409. * allocates memory rather than use large stacks.
  42410. * 1024 adds and doubles.
  42411. *
  42412. * r Resulting point.
  42413. * g Point to multiply.
  42414. * k Scalar to multiply by.
  42415. * map Indicates whether to convert result to affine.
  42416. * ct Constant time required.
  42417. * heap Heap to use for allocation.
  42418. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  42419. */
  42420. static int sp_1024_ecc_mulmod_42(sp_point_1024* r, const sp_point_1024* g,
  42421. const sp_digit* k, int map, int ct, void* heap)
  42422. {
  42423. #ifdef WOLFSSL_SP_SMALL_STACK
  42424. sp_point_1024* t = NULL;
  42425. sp_digit* tmp = NULL;
  42426. #else
  42427. sp_point_1024 t[3];
  42428. sp_digit tmp[2 * 42 * 37];
  42429. #endif
  42430. sp_digit n;
  42431. int i;
  42432. int c;
  42433. int y;
  42434. int err = MP_OKAY;
  42435. /* Implementation is constant time. */
  42436. (void)ct;
  42437. (void)heap;
  42438. #ifdef WOLFSSL_SP_SMALL_STACK
  42439. t = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) * 3, heap,
  42440. DYNAMIC_TYPE_ECC);
  42441. if (t == NULL)
  42442. err = MEMORY_E;
  42443. if (err == MP_OKAY) {
  42444. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 42 * 37, heap,
  42445. DYNAMIC_TYPE_ECC);
  42446. if (tmp == NULL)
  42447. err = MEMORY_E;
  42448. }
  42449. #endif
  42450. if (err == MP_OKAY) {
  42451. XMEMSET(t, 0, sizeof(sp_point_1024) * 3);
  42452. /* t[0] = {0, 0, 1} * norm */
  42453. t[0].infinity = 1;
  42454. /* t[1] = {g->x, g->y, g->z} * norm */
  42455. err = sp_1024_mod_mul_norm_42(t[1].x, g->x, p1024_mod);
  42456. }
  42457. if (err == MP_OKAY)
  42458. err = sp_1024_mod_mul_norm_42(t[1].y, g->y, p1024_mod);
  42459. if (err == MP_OKAY)
  42460. err = sp_1024_mod_mul_norm_42(t[1].z, g->z, p1024_mod);
  42461. if (err == MP_OKAY) {
  42462. i = 40;
  42463. c = 24;
  42464. n = k[i--] << (25 - c);
  42465. for (; ; c--) {
  42466. if (c == 0) {
  42467. if (i == -1)
  42468. break;
  42469. n = k[i--];
  42470. c = 25;
  42471. }
  42472. y = (n >> 24) & 1;
  42473. n <<= 1;
  42474. sp_1024_proj_point_add_42(&t[y^1], &t[0], &t[1], tmp);
  42475. XMEMCPY(&t[2], (void*)(((size_t)&t[0] & addr_mask[y^1]) +
  42476. ((size_t)&t[1] & addr_mask[y])),
  42477. sizeof(sp_point_1024));
  42478. sp_1024_proj_point_dbl_42(&t[2], &t[2], tmp);
  42479. XMEMCPY((void*)(((size_t)&t[0] & addr_mask[y^1]) +
  42480. ((size_t)&t[1] & addr_mask[y])), &t[2],
  42481. sizeof(sp_point_1024));
  42482. }
  42483. if (map != 0) {
  42484. sp_1024_map_42(r, &t[0], tmp);
  42485. }
  42486. else {
  42487. XMEMCPY(r, &t[0], sizeof(sp_point_1024));
  42488. }
  42489. }
  42490. #ifdef WOLFSSL_SP_SMALL_STACK
  42491. if (tmp != NULL)
  42492. #endif
  42493. {
  42494. ForceZero(tmp, sizeof(sp_digit) * 2 * 42 * 37);
  42495. #ifdef WOLFSSL_SP_SMALL_STACK
  42496. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  42497. #endif
  42498. }
  42499. #ifdef WOLFSSL_SP_SMALL_STACK
  42500. if (t != NULL)
  42501. #endif
  42502. {
  42503. ForceZero(t, sizeof(sp_point_1024) * 3);
  42504. #ifdef WOLFSSL_SP_SMALL_STACK
  42505. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  42506. #endif
  42507. }
  42508. return err;
  42509. }
  42510. #ifdef WOLFSSL_SP_NONBLOCK
  42511. typedef struct sp_1024_ecc_mulmod_42_ctx {
  42512. int state;
  42513. union {
  42514. sp_1024_proj_point_dbl_42_ctx dbl_ctx;
  42515. sp_1024_proj_point_add_42_ctx add_ctx;
  42516. };
  42517. sp_point_1024 t[3];
  42518. sp_digit tmp[2 * 42 * 37];
  42519. sp_digit n;
  42520. int i;
  42521. int c;
  42522. int y;
  42523. } sp_1024_ecc_mulmod_42_ctx;
  42524. static int sp_1024_ecc_mulmod_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
  42525. const sp_point_1024* g, const sp_digit* k, int map, int ct, void* heap)
  42526. {
  42527. int err = FP_WOULDBLOCK;
  42528. sp_1024_ecc_mulmod_42_ctx* ctx = (sp_1024_ecc_mulmod_42_ctx*)sp_ctx->data;
  42529. typedef char ctx_size_test[sizeof(sp_1024_ecc_mulmod_42_ctx) >= sizeof(*sp_ctx) ? -1 : 1];
  42530. (void)sizeof(ctx_size_test);
  42531. /* Implementation is constant time. */
  42532. (void)ct;
  42533. switch (ctx->state) {
  42534. case 0: /* INIT */
  42535. XMEMSET(ctx->t, 0, sizeof(sp_point_1024) * 3);
  42536. ctx->i = 40;
  42537. ctx->c = 24;
  42538. ctx->n = k[ctx->i--] << (25 - ctx->c);
  42539. /* t[0] = {0, 0, 1} * norm */
  42540. ctx->t[0].infinity = 1;
  42541. ctx->state = 1;
  42542. break;
  42543. case 1: /* T1X */
  42544. /* t[1] = {g->x, g->y, g->z} * norm */
  42545. err = sp_1024_mod_mul_norm_42(ctx->t[1].x, g->x, p1024_mod);
  42546. ctx->state = 2;
  42547. break;
  42548. case 2: /* T1Y */
  42549. err = sp_1024_mod_mul_norm_42(ctx->t[1].y, g->y, p1024_mod);
  42550. ctx->state = 3;
  42551. break;
  42552. case 3: /* T1Z */
  42553. err = sp_1024_mod_mul_norm_42(ctx->t[1].z, g->z, p1024_mod);
  42554. ctx->state = 4;
  42555. break;
  42556. case 4: /* ADDPREP */
  42557. if (ctx->c == 0) {
  42558. if (ctx->i == -1) {
  42559. ctx->state = 7;
  42560. break;
  42561. }
  42562. ctx->n = k[ctx->i--];
  42563. ctx->c = 25;
  42564. }
  42565. ctx->y = (ctx->n >> 24) & 1;
  42566. ctx->n <<= 1;
  42567. XMEMSET(&ctx->add_ctx, 0, sizeof(ctx->add_ctx));
  42568. ctx->state = 5;
  42569. break;
  42570. case 5: /* ADD */
  42571. err = sp_1024_proj_point_add_42_nb((sp_ecc_ctx_t*)&ctx->add_ctx,
  42572. &ctx->t[ctx->y^1], &ctx->t[0], &ctx->t[1], ctx->tmp);
  42573. if (err == MP_OKAY) {
  42574. XMEMCPY(&ctx->t[2], (void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  42575. ((size_t)&ctx->t[1] & addr_mask[ctx->y])),
  42576. sizeof(sp_point_1024));
  42577. XMEMSET(&ctx->dbl_ctx, 0, sizeof(ctx->dbl_ctx));
  42578. ctx->state = 6;
  42579. }
  42580. break;
  42581. case 6: /* DBL */
  42582. err = sp_1024_proj_point_dbl_42_nb((sp_ecc_ctx_t*)&ctx->dbl_ctx, &ctx->t[2],
  42583. &ctx->t[2], ctx->tmp);
  42584. if (err == MP_OKAY) {
  42585. XMEMCPY((void*)(((size_t)&ctx->t[0] & addr_mask[ctx->y^1]) +
  42586. ((size_t)&ctx->t[1] & addr_mask[ctx->y])), &ctx->t[2],
  42587. sizeof(sp_point_1024));
  42588. ctx->state = 4;
  42589. ctx->c--;
  42590. }
  42591. break;
  42592. case 7: /* MAP */
  42593. if (map != 0) {
  42594. sp_1024_map_42(r, &ctx->t[0], ctx->tmp);
  42595. }
  42596. else {
  42597. XMEMCPY(r, &ctx->t[0], sizeof(sp_point_1024));
  42598. }
  42599. err = MP_OKAY;
  42600. break;
  42601. }
  42602. if (err == MP_OKAY && ctx->state != 7) {
  42603. err = FP_WOULDBLOCK;
  42604. }
  42605. if (err != FP_WOULDBLOCK) {
  42606. ForceZero(ctx->tmp, sizeof(ctx->tmp));
  42607. ForceZero(ctx->t, sizeof(ctx->t));
  42608. }
  42609. (void)heap;
  42610. return err;
  42611. }
  42612. #endif /* WOLFSSL_SP_NONBLOCK */
  42613. #else
  42614. /* A table entry for pre-computed points. */
  42615. typedef struct sp_table_entry_1024 {
  42616. sp_digit x[42];
  42617. sp_digit y[42];
  42618. } sp_table_entry_1024;
  42619. /* Conditionally copy a into r using the mask m.
  42620. * m is -1 to copy and 0 when not.
  42621. *
  42622. * r A single precision number to copy over.
  42623. * a A single precision number to copy.
  42624. * m Mask value to apply.
  42625. */
  42626. static void sp_1024_cond_copy_42(sp_digit* r, const sp_digit* a, const sp_digit m)
  42627. {
  42628. sp_digit t[42];
  42629. #ifdef WOLFSSL_SP_SMALL
  42630. int i;
  42631. for (i = 0; i < 42; i++) {
  42632. t[i] = r[i] ^ a[i];
  42633. }
  42634. for (i = 0; i < 42; i++) {
  42635. r[i] ^= t[i] & m;
  42636. }
  42637. #else
  42638. t[ 0] = r[ 0] ^ a[ 0];
  42639. t[ 1] = r[ 1] ^ a[ 1];
  42640. t[ 2] = r[ 2] ^ a[ 2];
  42641. t[ 3] = r[ 3] ^ a[ 3];
  42642. t[ 4] = r[ 4] ^ a[ 4];
  42643. t[ 5] = r[ 5] ^ a[ 5];
  42644. t[ 6] = r[ 6] ^ a[ 6];
  42645. t[ 7] = r[ 7] ^ a[ 7];
  42646. t[ 8] = r[ 8] ^ a[ 8];
  42647. t[ 9] = r[ 9] ^ a[ 9];
  42648. t[10] = r[10] ^ a[10];
  42649. t[11] = r[11] ^ a[11];
  42650. t[12] = r[12] ^ a[12];
  42651. t[13] = r[13] ^ a[13];
  42652. t[14] = r[14] ^ a[14];
  42653. t[15] = r[15] ^ a[15];
  42654. t[16] = r[16] ^ a[16];
  42655. t[17] = r[17] ^ a[17];
  42656. t[18] = r[18] ^ a[18];
  42657. t[19] = r[19] ^ a[19];
  42658. t[20] = r[20] ^ a[20];
  42659. t[21] = r[21] ^ a[21];
  42660. t[22] = r[22] ^ a[22];
  42661. t[23] = r[23] ^ a[23];
  42662. t[24] = r[24] ^ a[24];
  42663. t[25] = r[25] ^ a[25];
  42664. t[26] = r[26] ^ a[26];
  42665. t[27] = r[27] ^ a[27];
  42666. t[28] = r[28] ^ a[28];
  42667. t[29] = r[29] ^ a[29];
  42668. t[30] = r[30] ^ a[30];
  42669. t[31] = r[31] ^ a[31];
  42670. t[32] = r[32] ^ a[32];
  42671. t[33] = r[33] ^ a[33];
  42672. t[34] = r[34] ^ a[34];
  42673. t[35] = r[35] ^ a[35];
  42674. t[36] = r[36] ^ a[36];
  42675. t[37] = r[37] ^ a[37];
  42676. t[38] = r[38] ^ a[38];
  42677. t[39] = r[39] ^ a[39];
  42678. t[40] = r[40] ^ a[40];
  42679. t[41] = r[41] ^ a[41];
  42680. r[ 0] ^= t[ 0] & m;
  42681. r[ 1] ^= t[ 1] & m;
  42682. r[ 2] ^= t[ 2] & m;
  42683. r[ 3] ^= t[ 3] & m;
  42684. r[ 4] ^= t[ 4] & m;
  42685. r[ 5] ^= t[ 5] & m;
  42686. r[ 6] ^= t[ 6] & m;
  42687. r[ 7] ^= t[ 7] & m;
  42688. r[ 8] ^= t[ 8] & m;
  42689. r[ 9] ^= t[ 9] & m;
  42690. r[10] ^= t[10] & m;
  42691. r[11] ^= t[11] & m;
  42692. r[12] ^= t[12] & m;
  42693. r[13] ^= t[13] & m;
  42694. r[14] ^= t[14] & m;
  42695. r[15] ^= t[15] & m;
  42696. r[16] ^= t[16] & m;
  42697. r[17] ^= t[17] & m;
  42698. r[18] ^= t[18] & m;
  42699. r[19] ^= t[19] & m;
  42700. r[20] ^= t[20] & m;
  42701. r[21] ^= t[21] & m;
  42702. r[22] ^= t[22] & m;
  42703. r[23] ^= t[23] & m;
  42704. r[24] ^= t[24] & m;
  42705. r[25] ^= t[25] & m;
  42706. r[26] ^= t[26] & m;
  42707. r[27] ^= t[27] & m;
  42708. r[28] ^= t[28] & m;
  42709. r[29] ^= t[29] & m;
  42710. r[30] ^= t[30] & m;
  42711. r[31] ^= t[31] & m;
  42712. r[32] ^= t[32] & m;
  42713. r[33] ^= t[33] & m;
  42714. r[34] ^= t[34] & m;
  42715. r[35] ^= t[35] & m;
  42716. r[36] ^= t[36] & m;
  42717. r[37] ^= t[37] & m;
  42718. r[38] ^= t[38] & m;
  42719. r[39] ^= t[39] & m;
  42720. r[40] ^= t[40] & m;
  42721. r[41] ^= t[41] & m;
  42722. #endif /* WOLFSSL_SP_SMALL */
  42723. }
  42724. /* Double the Montgomery form projective point p a number of times.
  42725. *
  42726. * r Result of repeated doubling of point.
  42727. * p Point to double.
  42728. * n Number of times to double
  42729. * t Temporary ordinate data.
  42730. */
  42731. static void sp_1024_proj_point_dbl_n_42(sp_point_1024* p, int i,
  42732. sp_digit* t)
  42733. {
  42734. sp_digit* w = t;
  42735. sp_digit* a = t + 2*42;
  42736. sp_digit* b = t + 4*42;
  42737. sp_digit* t1 = t + 6*42;
  42738. sp_digit* t2 = t + 8*42;
  42739. sp_digit* x;
  42740. sp_digit* y;
  42741. sp_digit* z;
  42742. volatile int n = i;
  42743. x = p->x;
  42744. y = p->y;
  42745. z = p->z;
  42746. /* Y = 2*Y */
  42747. sp_1024_mont_dbl_42(y, y, p1024_mod);
  42748. /* W = Z^4 */
  42749. sp_1024_mont_sqr_42(w, z, p1024_mod, p1024_mp_mod);
  42750. sp_1024_mont_sqr_42(w, w, p1024_mod, p1024_mp_mod);
  42751. #ifndef WOLFSSL_SP_SMALL
  42752. while (--n > 0)
  42753. #else
  42754. while (--n >= 0)
  42755. #endif
  42756. {
  42757. /* A = 3*(X^2 - W) */
  42758. sp_1024_mont_sqr_42(t1, x, p1024_mod, p1024_mp_mod);
  42759. sp_1024_mont_sub_42(t1, t1, w, p1024_mod);
  42760. sp_1024_mont_tpl_42(a, t1, p1024_mod);
  42761. /* B = X*Y^2 */
  42762. sp_1024_mont_sqr_42(t1, y, p1024_mod, p1024_mp_mod);
  42763. sp_1024_mont_mul_42(b, t1, x, p1024_mod, p1024_mp_mod);
  42764. /* X = A^2 - 2B */
  42765. sp_1024_mont_sqr_42(x, a, p1024_mod, p1024_mp_mod);
  42766. sp_1024_mont_dbl_42(t2, b, p1024_mod);
  42767. sp_1024_mont_sub_42(x, x, t2, p1024_mod);
  42768. /* B = 2.(B - X) */
  42769. sp_1024_mont_sub_42(t2, b, x, p1024_mod);
  42770. sp_1024_mont_dbl_42(b, t2, p1024_mod);
  42771. /* Z = Z*Y */
  42772. sp_1024_mont_mul_42(z, z, y, p1024_mod, p1024_mp_mod);
  42773. /* t1 = Y^4 */
  42774. sp_1024_mont_sqr_42(t1, t1, p1024_mod, p1024_mp_mod);
  42775. #ifdef WOLFSSL_SP_SMALL
  42776. if (n != 0)
  42777. #endif
  42778. {
  42779. /* W = W*Y^4 */
  42780. sp_1024_mont_mul_42(w, w, t1, p1024_mod, p1024_mp_mod);
  42781. }
  42782. /* y = 2*A*(B - X) - Y^4 */
  42783. sp_1024_mont_mul_42(y, b, a, p1024_mod, p1024_mp_mod);
  42784. sp_1024_mont_sub_42(y, y, t1, p1024_mod);
  42785. }
  42786. #ifndef WOLFSSL_SP_SMALL
  42787. /* A = 3*(X^2 - W) */
  42788. sp_1024_mont_sqr_42(t1, x, p1024_mod, p1024_mp_mod);
  42789. sp_1024_mont_sub_42(t1, t1, w, p1024_mod);
  42790. sp_1024_mont_tpl_42(a, t1, p1024_mod);
  42791. /* B = X*Y^2 */
  42792. sp_1024_mont_sqr_42(t1, y, p1024_mod, p1024_mp_mod);
  42793. sp_1024_mont_mul_42(b, t1, x, p1024_mod, p1024_mp_mod);
  42794. /* X = A^2 - 2B */
  42795. sp_1024_mont_sqr_42(x, a, p1024_mod, p1024_mp_mod);
  42796. sp_1024_mont_dbl_42(t2, b, p1024_mod);
  42797. sp_1024_mont_sub_42(x, x, t2, p1024_mod);
  42798. /* B = 2.(B - X) */
  42799. sp_1024_mont_sub_42(t2, b, x, p1024_mod);
  42800. sp_1024_mont_dbl_42(b, t2, p1024_mod);
  42801. /* Z = Z*Y */
  42802. sp_1024_mont_mul_42(z, z, y, p1024_mod, p1024_mp_mod);
  42803. /* t1 = Y^4 */
  42804. sp_1024_mont_sqr_42(t1, t1, p1024_mod, p1024_mp_mod);
  42805. /* y = 2*A*(B - X) - Y^4 */
  42806. sp_1024_mont_mul_42(y, b, a, p1024_mod, p1024_mp_mod);
  42807. sp_1024_mont_sub_42(y, y, t1, p1024_mod);
  42808. #endif /* WOLFSSL_SP_SMALL */
  42809. /* Y = Y/2 */
  42810. sp_1024_mont_div2_42(y, y, p1024_mod);
  42811. }
  42812. /* Double the Montgomery form projective point p a number of times.
  42813. *
  42814. * r Result of repeated doubling of point.
  42815. * p Point to double.
  42816. * n Number of times to double
  42817. * t Temporary ordinate data.
  42818. */
  42819. static void sp_1024_proj_point_dbl_n_store_42(sp_point_1024* r,
  42820. const sp_point_1024* p, int n, int m, sp_digit* t)
  42821. {
  42822. sp_digit* w = t;
  42823. sp_digit* a = t + 2*42;
  42824. sp_digit* b = t + 4*42;
  42825. sp_digit* t1 = t + 6*42;
  42826. sp_digit* t2 = t + 8*42;
  42827. sp_digit* x = r[2*m].x;
  42828. sp_digit* y = r[(1<<n)*m].y;
  42829. sp_digit* z = r[2*m].z;
  42830. int i;
  42831. int j;
  42832. for (i=0; i<42; i++) {
  42833. x[i] = p->x[i];
  42834. }
  42835. for (i=0; i<42; i++) {
  42836. y[i] = p->y[i];
  42837. }
  42838. for (i=0; i<42; i++) {
  42839. z[i] = p->z[i];
  42840. }
  42841. /* Y = 2*Y */
  42842. sp_1024_mont_dbl_42(y, y, p1024_mod);
  42843. /* W = Z^4 */
  42844. sp_1024_mont_sqr_42(w, z, p1024_mod, p1024_mp_mod);
  42845. sp_1024_mont_sqr_42(w, w, p1024_mod, p1024_mp_mod);
  42846. j = m;
  42847. for (i=1; i<=n; i++) {
  42848. j *= 2;
  42849. /* A = 3*(X^2 - W) */
  42850. sp_1024_mont_sqr_42(t1, x, p1024_mod, p1024_mp_mod);
  42851. sp_1024_mont_sub_42(t1, t1, w, p1024_mod);
  42852. sp_1024_mont_tpl_42(a, t1, p1024_mod);
  42853. /* B = X*Y^2 */
  42854. sp_1024_mont_sqr_42(t1, y, p1024_mod, p1024_mp_mod);
  42855. sp_1024_mont_mul_42(b, t1, x, p1024_mod, p1024_mp_mod);
  42856. x = r[j].x;
  42857. /* X = A^2 - 2B */
  42858. sp_1024_mont_sqr_42(x, a, p1024_mod, p1024_mp_mod);
  42859. sp_1024_mont_dbl_42(t2, b, p1024_mod);
  42860. sp_1024_mont_sub_42(x, x, t2, p1024_mod);
  42861. /* B = 2.(B - X) */
  42862. sp_1024_mont_sub_42(t2, b, x, p1024_mod);
  42863. sp_1024_mont_dbl_42(b, t2, p1024_mod);
  42864. /* Z = Z*Y */
  42865. sp_1024_mont_mul_42(r[j].z, z, y, p1024_mod, p1024_mp_mod);
  42866. z = r[j].z;
  42867. /* t1 = Y^4 */
  42868. sp_1024_mont_sqr_42(t1, t1, p1024_mod, p1024_mp_mod);
  42869. if (i != n) {
  42870. /* W = W*Y^4 */
  42871. sp_1024_mont_mul_42(w, w, t1, p1024_mod, p1024_mp_mod);
  42872. }
  42873. /* y = 2*A*(B - X) - Y^4 */
  42874. sp_1024_mont_mul_42(y, b, a, p1024_mod, p1024_mp_mod);
  42875. sp_1024_mont_sub_42(y, y, t1, p1024_mod);
  42876. /* Y = Y/2 */
  42877. sp_1024_mont_div2_42(r[j].y, y, p1024_mod);
  42878. r[j].infinity = 0;
  42879. }
  42880. }
  42881. /* Add two Montgomery form projective points.
  42882. *
  42883. * ra Result of addition.
  42884. * rs Result of subtraction.
  42885. * p First point to add.
  42886. * q Second point to add.
  42887. * t Temporary ordinate data.
  42888. */
  42889. static void sp_1024_proj_point_add_sub_42(sp_point_1024* ra,
  42890. sp_point_1024* rs, const sp_point_1024* p, const sp_point_1024* q,
  42891. sp_digit* t)
  42892. {
  42893. sp_digit* t1 = t;
  42894. sp_digit* t2 = t + 2*42;
  42895. sp_digit* t3 = t + 4*42;
  42896. sp_digit* t4 = t + 6*42;
  42897. sp_digit* t5 = t + 8*42;
  42898. sp_digit* t6 = t + 10*42;
  42899. sp_digit* xa = ra->x;
  42900. sp_digit* ya = ra->y;
  42901. sp_digit* za = ra->z;
  42902. sp_digit* xs = rs->x;
  42903. sp_digit* ys = rs->y;
  42904. sp_digit* zs = rs->z;
  42905. XMEMCPY(xa, p->x, sizeof(p->x) / 2);
  42906. XMEMCPY(ya, p->y, sizeof(p->y) / 2);
  42907. XMEMCPY(za, p->z, sizeof(p->z) / 2);
  42908. ra->infinity = 0;
  42909. rs->infinity = 0;
  42910. /* U1 = X1*Z2^2 */
  42911. sp_1024_mont_sqr_42(t1, q->z, p1024_mod, p1024_mp_mod);
  42912. sp_1024_mont_mul_42(t3, t1, q->z, p1024_mod, p1024_mp_mod);
  42913. sp_1024_mont_mul_42(t1, t1, xa, p1024_mod, p1024_mp_mod);
  42914. /* U2 = X2*Z1^2 */
  42915. sp_1024_mont_sqr_42(t2, za, p1024_mod, p1024_mp_mod);
  42916. sp_1024_mont_mul_42(t4, t2, za, p1024_mod, p1024_mp_mod);
  42917. sp_1024_mont_mul_42(t2, t2, q->x, p1024_mod, p1024_mp_mod);
  42918. /* S1 = Y1*Z2^3 */
  42919. sp_1024_mont_mul_42(t3, t3, ya, p1024_mod, p1024_mp_mod);
  42920. /* S2 = Y2*Z1^3 */
  42921. sp_1024_mont_mul_42(t4, t4, q->y, p1024_mod, p1024_mp_mod);
  42922. /* H = U2 - U1 */
  42923. sp_1024_mont_sub_42(t2, t2, t1, p1024_mod);
  42924. /* RS = S2 + S1 */
  42925. sp_1024_mont_add_42(t6, t4, t3, p1024_mod);
  42926. /* R = S2 - S1 */
  42927. sp_1024_mont_sub_42(t4, t4, t3, p1024_mod);
  42928. /* Z3 = H*Z1*Z2 */
  42929. /* ZS = H*Z1*Z2 */
  42930. sp_1024_mont_mul_42(za, za, q->z, p1024_mod, p1024_mp_mod);
  42931. sp_1024_mont_mul_42(za, za, t2, p1024_mod, p1024_mp_mod);
  42932. XMEMCPY(zs, za, sizeof(p->z)/2);
  42933. /* X3 = R^2 - H^3 - 2*U1*H^2 */
  42934. /* XS = RS^2 - H^3 - 2*U1*H^2 */
  42935. sp_1024_mont_sqr_42(xa, t4, p1024_mod, p1024_mp_mod);
  42936. sp_1024_mont_sqr_42(xs, t6, p1024_mod, p1024_mp_mod);
  42937. sp_1024_mont_sqr_42(t5, t2, p1024_mod, p1024_mp_mod);
  42938. sp_1024_mont_mul_42(ya, t1, t5, p1024_mod, p1024_mp_mod);
  42939. sp_1024_mont_mul_42(t5, t5, t2, p1024_mod, p1024_mp_mod);
  42940. sp_1024_mont_sub_42(xa, xa, t5, p1024_mod);
  42941. sp_1024_mont_sub_42(xs, xs, t5, p1024_mod);
  42942. sp_1024_mont_dbl_42(t1, ya, p1024_mod);
  42943. sp_1024_mont_sub_42(xa, xa, t1, p1024_mod);
  42944. sp_1024_mont_sub_42(xs, xs, t1, p1024_mod);
  42945. /* Y3 = R*(U1*H^2 - X3) - S1*H^3 */
  42946. /* YS = -RS*(U1*H^2 - XS) - S1*H^3 */
  42947. sp_1024_mont_sub_42(ys, ya, xs, p1024_mod);
  42948. sp_1024_mont_sub_42(ya, ya, xa, p1024_mod);
  42949. sp_1024_mont_mul_42(ya, ya, t4, p1024_mod, p1024_mp_mod);
  42950. sp_1024_mont_sub_42(t6, p1024_mod, t6, p1024_mod);
  42951. sp_1024_mont_mul_42(ys, ys, t6, p1024_mod, p1024_mp_mod);
  42952. sp_1024_mont_mul_42(t5, t5, t3, p1024_mod, p1024_mp_mod);
  42953. sp_1024_mont_sub_42(ya, ya, t5, p1024_mod);
  42954. sp_1024_mont_sub_42(ys, ys, t5, p1024_mod);
  42955. }
  42956. /* Structure used to describe recoding of scalar multiplication. */
  42957. typedef struct ecc_recode_1024 {
  42958. /* Index into pre-computation table. */
  42959. uint8_t i;
  42960. /* Use the negative of the point. */
  42961. uint8_t neg;
  42962. } ecc_recode_1024;
  42963. /* The index into pre-computation table to use. */
  42964. static const uint8_t recode_index_42_7[130] = {
  42965. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  42966. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  42967. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  42968. 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  42969. 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49,
  42970. 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33,
  42971. 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
  42972. 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
  42973. 0, 1,
  42974. };
  42975. /* Whether to negate y-ordinate. */
  42976. static const uint8_t recode_neg_42_7[130] = {
  42977. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42978. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42979. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42980. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  42981. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  42982. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  42983. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  42984. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  42985. 0, 0,
  42986. };
  42987. /* Recode the scalar for multiplication using pre-computed values and
  42988. * subtraction.
  42989. *
  42990. * k Scalar to multiply by.
  42991. * v Vector of operations to perform.
  42992. */
  42993. static void sp_1024_ecc_recode_7_42(const sp_digit* k, ecc_recode_1024* v)
  42994. {
  42995. int i;
  42996. int j;
  42997. uint8_t y;
  42998. int carry = 0;
  42999. int o;
  43000. sp_digit n;
  43001. j = 0;
  43002. n = k[j];
  43003. o = 0;
  43004. for (i=0; i<147; i++) {
  43005. y = (int8_t)n;
  43006. if (o + 7 < 25) {
  43007. y &= 0x7f;
  43008. n >>= 7;
  43009. o += 7;
  43010. }
  43011. else if (o + 7 == 25) {
  43012. n >>= 7;
  43013. if (++j < 42)
  43014. n = k[j];
  43015. o = 0;
  43016. }
  43017. else if (++j < 42) {
  43018. n = k[j];
  43019. y |= (uint8_t)((n << (25 - o)) & 0x7f);
  43020. o -= 18;
  43021. n >>= o;
  43022. }
  43023. y += (uint8_t)carry;
  43024. v[i].i = recode_index_42_7[y];
  43025. v[i].neg = recode_neg_42_7[y];
  43026. carry = (y >> 7) + v[i].neg;
  43027. }
  43028. }
  43029. /* Multiply the point by the scalar and return the result.
  43030. * If map is true then convert result to affine coordinates.
  43031. *
  43032. * Window technique of 7 bits. (Add-Sub variation.)
  43033. * Calculate 0..64 times the point. Use function that adds and
  43034. * subtracts the same two points.
  43035. * Recode to add or subtract one of the computed points.
  43036. * Double to push up.
  43037. * NOT a sliding window.
  43038. *
  43039. * r Resulting point.
  43040. * g Point to multiply.
  43041. * k Scalar to multiply by.
  43042. * map Indicates whether to convert result to affine.
  43043. * ct Constant time required.
  43044. * heap Heap to use for allocation.
  43045. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  43046. */
  43047. static int sp_1024_ecc_mulmod_win_add_sub_42(sp_point_1024* r, const sp_point_1024* g,
  43048. const sp_digit* k, int map, int ct, void* heap)
  43049. {
  43050. #ifdef WOLFSSL_SP_SMALL_STACK
  43051. sp_point_1024* t = NULL;
  43052. sp_digit* tmp = NULL;
  43053. #else
  43054. sp_point_1024 t[65+2];
  43055. sp_digit tmp[2 * 42 * 37];
  43056. #endif
  43057. sp_point_1024* rt = NULL;
  43058. sp_point_1024* p = NULL;
  43059. sp_digit* negy;
  43060. int i;
  43061. ecc_recode_1024 v[147];
  43062. int err = MP_OKAY;
  43063. /* Constant time used for cache attack resistance implementation. */
  43064. (void)ct;
  43065. (void)heap;
  43066. #ifdef WOLFSSL_SP_SMALL_STACK
  43067. t = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) *
  43068. (65+2), heap, DYNAMIC_TYPE_ECC);
  43069. if (t == NULL)
  43070. err = MEMORY_E;
  43071. if (err == MP_OKAY) {
  43072. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 42 * 37,
  43073. heap, DYNAMIC_TYPE_ECC);
  43074. if (tmp == NULL)
  43075. err = MEMORY_E;
  43076. }
  43077. #endif
  43078. if (err == MP_OKAY) {
  43079. rt = t + 65;
  43080. p = t + 65+1;
  43081. /* t[0] = {0, 0, 1} * norm */
  43082. XMEMSET(&t[0], 0, sizeof(t[0]));
  43083. t[0].infinity = 1;
  43084. /* t[1] = {g->x, g->y, g->z} * norm */
  43085. err = sp_1024_mod_mul_norm_42(t[1].x, g->x, p1024_mod);
  43086. }
  43087. if (err == MP_OKAY) {
  43088. err = sp_1024_mod_mul_norm_42(t[1].y, g->y, p1024_mod);
  43089. }
  43090. if (err == MP_OKAY) {
  43091. err = sp_1024_mod_mul_norm_42(t[1].z, g->z, p1024_mod);
  43092. }
  43093. if (err == MP_OKAY) {
  43094. t[1].infinity = 0;
  43095. /* t[2] ... t[64] */
  43096. sp_1024_proj_point_dbl_n_store_42(t, &t[ 1], 6, 1, tmp);
  43097. sp_1024_proj_point_add_42(&t[ 3], &t[ 2], &t[ 1], tmp);
  43098. sp_1024_proj_point_dbl_42(&t[ 6], &t[ 3], tmp);
  43099. sp_1024_proj_point_add_sub_42(&t[ 7], &t[ 5], &t[ 6], &t[ 1], tmp);
  43100. sp_1024_proj_point_dbl_42(&t[10], &t[ 5], tmp);
  43101. sp_1024_proj_point_add_sub_42(&t[11], &t[ 9], &t[10], &t[ 1], tmp);
  43102. sp_1024_proj_point_dbl_42(&t[12], &t[ 6], tmp);
  43103. sp_1024_proj_point_dbl_42(&t[14], &t[ 7], tmp);
  43104. sp_1024_proj_point_add_sub_42(&t[15], &t[13], &t[14], &t[ 1], tmp);
  43105. sp_1024_proj_point_dbl_42(&t[18], &t[ 9], tmp);
  43106. sp_1024_proj_point_add_sub_42(&t[19], &t[17], &t[18], &t[ 1], tmp);
  43107. sp_1024_proj_point_dbl_42(&t[20], &t[10], tmp);
  43108. sp_1024_proj_point_dbl_42(&t[22], &t[11], tmp);
  43109. sp_1024_proj_point_add_sub_42(&t[23], &t[21], &t[22], &t[ 1], tmp);
  43110. sp_1024_proj_point_dbl_42(&t[24], &t[12], tmp);
  43111. sp_1024_proj_point_dbl_42(&t[26], &t[13], tmp);
  43112. sp_1024_proj_point_add_sub_42(&t[27], &t[25], &t[26], &t[ 1], tmp);
  43113. sp_1024_proj_point_dbl_42(&t[28], &t[14], tmp);
  43114. sp_1024_proj_point_dbl_42(&t[30], &t[15], tmp);
  43115. sp_1024_proj_point_add_sub_42(&t[31], &t[29], &t[30], &t[ 1], tmp);
  43116. sp_1024_proj_point_dbl_42(&t[34], &t[17], tmp);
  43117. sp_1024_proj_point_add_sub_42(&t[35], &t[33], &t[34], &t[ 1], tmp);
  43118. sp_1024_proj_point_dbl_42(&t[36], &t[18], tmp);
  43119. sp_1024_proj_point_dbl_42(&t[38], &t[19], tmp);
  43120. sp_1024_proj_point_add_sub_42(&t[39], &t[37], &t[38], &t[ 1], tmp);
  43121. sp_1024_proj_point_dbl_42(&t[40], &t[20], tmp);
  43122. sp_1024_proj_point_dbl_42(&t[42], &t[21], tmp);
  43123. sp_1024_proj_point_add_sub_42(&t[43], &t[41], &t[42], &t[ 1], tmp);
  43124. sp_1024_proj_point_dbl_42(&t[44], &t[22], tmp);
  43125. sp_1024_proj_point_dbl_42(&t[46], &t[23], tmp);
  43126. sp_1024_proj_point_add_sub_42(&t[47], &t[45], &t[46], &t[ 1], tmp);
  43127. sp_1024_proj_point_dbl_42(&t[48], &t[24], tmp);
  43128. sp_1024_proj_point_dbl_42(&t[50], &t[25], tmp);
  43129. sp_1024_proj_point_add_sub_42(&t[51], &t[49], &t[50], &t[ 1], tmp);
  43130. sp_1024_proj_point_dbl_42(&t[52], &t[26], tmp);
  43131. sp_1024_proj_point_dbl_42(&t[54], &t[27], tmp);
  43132. sp_1024_proj_point_add_sub_42(&t[55], &t[53], &t[54], &t[ 1], tmp);
  43133. sp_1024_proj_point_dbl_42(&t[56], &t[28], tmp);
  43134. sp_1024_proj_point_dbl_42(&t[58], &t[29], tmp);
  43135. sp_1024_proj_point_add_sub_42(&t[59], &t[57], &t[58], &t[ 1], tmp);
  43136. sp_1024_proj_point_dbl_42(&t[60], &t[30], tmp);
  43137. sp_1024_proj_point_dbl_42(&t[62], &t[31], tmp);
  43138. sp_1024_proj_point_add_sub_42(&t[63], &t[61], &t[62], &t[ 1], tmp);
  43139. negy = t[0].y;
  43140. sp_1024_ecc_recode_7_42(k, v);
  43141. i = 146;
  43142. XMEMCPY(rt, &t[v[i].i], sizeof(sp_point_1024));
  43143. for (--i; i>=0; i--) {
  43144. sp_1024_proj_point_dbl_n_42(rt, 7, tmp);
  43145. XMEMCPY(p, &t[v[i].i], sizeof(sp_point_1024));
  43146. sp_1024_mont_sub_42(negy, p1024_mod, p->y, p1024_mod);
  43147. sp_1024_norm_42(negy);
  43148. sp_1024_cond_copy_42(p->y, negy, (sp_digit)0 - v[i].neg);
  43149. sp_1024_proj_point_add_42(rt, rt, p, tmp);
  43150. }
  43151. if (map != 0) {
  43152. sp_1024_map_42(r, rt, tmp);
  43153. }
  43154. else {
  43155. XMEMCPY(r, rt, sizeof(sp_point_1024));
  43156. }
  43157. }
  43158. #ifdef WOLFSSL_SP_SMALL_STACK
  43159. if (t != NULL)
  43160. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  43161. if (tmp != NULL)
  43162. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  43163. #endif
  43164. return err;
  43165. }
  43166. #ifdef FP_ECC
  43167. #endif /* FP_ECC */
  43168. /* Add two Montgomery form projective points. The second point has a q value of
  43169. * one.
  43170. * Only the first point can be the same pointer as the result point.
  43171. *
  43172. * r Result of addition.
  43173. * p First point to add.
  43174. * q Second point to add.
  43175. * t Temporary ordinate data.
  43176. */
  43177. static void sp_1024_proj_point_add_qz1_42(sp_point_1024* r,
  43178. const sp_point_1024* p, const sp_point_1024* q, sp_digit* t)
  43179. {
  43180. sp_digit* t2 = t;
  43181. sp_digit* t3 = t + 2*42;
  43182. sp_digit* t6 = t + 4*42;
  43183. sp_digit* t1 = t + 6*42;
  43184. sp_digit* t4 = t + 8*42;
  43185. sp_digit* t5 = t + 10*42;
  43186. /* Calculate values to subtract from P->x and P->y. */
  43187. /* U2 = X2*Z1^2 */
  43188. sp_1024_mont_sqr_42(t2, p->z, p1024_mod, p1024_mp_mod);
  43189. sp_1024_mont_mul_42(t4, t2, p->z, p1024_mod, p1024_mp_mod);
  43190. sp_1024_mont_mul_42(t2, t2, q->x, p1024_mod, p1024_mp_mod);
  43191. /* S2 = Y2*Z1^3 */
  43192. sp_1024_mont_mul_42(t4, t4, q->y, p1024_mod, p1024_mp_mod);
  43193. if ((~p->infinity) & (~q->infinity) &
  43194. sp_1024_cmp_equal_42(p->x, t2) &
  43195. sp_1024_cmp_equal_42(p->y, t4)) {
  43196. sp_1024_proj_point_dbl_42(r, p, t);
  43197. }
  43198. else {
  43199. sp_digit* x = t2;
  43200. sp_digit* y = t3;
  43201. sp_digit* z = t6;
  43202. /* H = U2 - X1 */
  43203. sp_1024_mont_sub_42(t2, t2, p->x, p1024_mod);
  43204. /* R = S2 - Y1 */
  43205. sp_1024_mont_sub_42(t4, t4, p->y, p1024_mod);
  43206. /* Z3 = H*Z1 */
  43207. sp_1024_mont_mul_42(z, p->z, t2, p1024_mod, p1024_mp_mod);
  43208. /* X3 = R^2 - H^3 - 2*X1*H^2 */
  43209. sp_1024_mont_sqr_42(t1, t2, p1024_mod, p1024_mp_mod);
  43210. sp_1024_mont_mul_42(t3, p->x, t1, p1024_mod, p1024_mp_mod);
  43211. sp_1024_mont_mul_42(t1, t1, t2, p1024_mod, p1024_mp_mod);
  43212. sp_1024_mont_sqr_42(t2, t4, p1024_mod, p1024_mp_mod);
  43213. sp_1024_mont_sub_42(t2, t2, t1, p1024_mod);
  43214. sp_1024_mont_dbl_42(t5, t3, p1024_mod);
  43215. sp_1024_mont_sub_42(x, t2, t5, p1024_mod);
  43216. /* Y3 = R*(X1*H^2 - X3) - Y1*H^3 */
  43217. sp_1024_mont_sub_42(t3, t3, x, p1024_mod);
  43218. sp_1024_mont_mul_42(t3, t3, t4, p1024_mod, p1024_mp_mod);
  43219. sp_1024_mont_mul_42(t1, t1, p->y, p1024_mod, p1024_mp_mod);
  43220. sp_1024_mont_sub_42(y, t3, t1, p1024_mod);
  43221. {
  43222. int i;
  43223. sp_digit maskp = 0 - (q->infinity & (!p->infinity));
  43224. sp_digit maskq = 0 - (p->infinity & (!q->infinity));
  43225. sp_digit maskt = ~(maskp | maskq);
  43226. sp_digit inf = (sp_digit)(p->infinity & q->infinity);
  43227. for (i = 0; i < 42; i++) {
  43228. r->x[i] = (p->x[i] & maskp) | (q->x[i] & maskq) |
  43229. (x[i] & maskt);
  43230. }
  43231. for (i = 0; i < 42; i++) {
  43232. r->y[i] = (p->y[i] & maskp) | (q->y[i] & maskq) |
  43233. (y[i] & maskt);
  43234. }
  43235. for (i = 0; i < 42; i++) {
  43236. r->z[i] = (p->z[i] & maskp) | (q->z[i] & maskq) |
  43237. (z[i] & maskt);
  43238. }
  43239. r->z[0] |= inf;
  43240. r->infinity = (word32)inf;
  43241. }
  43242. }
  43243. }
  43244. #if defined(FP_ECC) || !defined(WOLFSSL_SP_SMALL)
  43245. /* Convert the projective point to affine.
  43246. * Ordinates are in Montgomery form.
  43247. *
  43248. * a Point to convert.
  43249. * t Temporary data.
  43250. */
  43251. static void sp_1024_proj_to_affine_42(sp_point_1024* a, sp_digit* t)
  43252. {
  43253. sp_digit* t1 = t;
  43254. sp_digit* t2 = t + 2 * 42;
  43255. sp_digit* tmp = t + 4 * 42;
  43256. sp_1024_mont_inv_42(t1, a->z, tmp);
  43257. sp_1024_mont_sqr_42(t2, t1, p1024_mod, p1024_mp_mod);
  43258. sp_1024_mont_mul_42(t1, t2, t1, p1024_mod, p1024_mp_mod);
  43259. sp_1024_mont_mul_42(a->x, a->x, t2, p1024_mod, p1024_mp_mod);
  43260. sp_1024_mont_mul_42(a->y, a->y, t1, p1024_mod, p1024_mp_mod);
  43261. XMEMCPY(a->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  43262. }
  43263. /* Generate the pre-computed table of points for the base point.
  43264. *
  43265. * width = 8
  43266. * 256 entries
  43267. * 128 bits between
  43268. *
  43269. * a The base point.
  43270. * table Place to store generated point data.
  43271. * tmp Temporary data.
  43272. * heap Heap to use for allocation.
  43273. */
  43274. static int sp_1024_gen_stripe_table_42(const sp_point_1024* a,
  43275. sp_table_entry_1024* table, sp_digit* tmp, void* heap)
  43276. {
  43277. #ifdef WOLFSSL_SP_SMALL_STACK
  43278. sp_point_1024* t = NULL;
  43279. #else
  43280. sp_point_1024 t[3];
  43281. #endif
  43282. sp_point_1024* s1 = NULL;
  43283. sp_point_1024* s2 = NULL;
  43284. int i;
  43285. int j;
  43286. int err = MP_OKAY;
  43287. (void)heap;
  43288. #ifdef WOLFSSL_SP_SMALL_STACK
  43289. t = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) * 3, heap,
  43290. DYNAMIC_TYPE_ECC);
  43291. if (t == NULL)
  43292. err = MEMORY_E;
  43293. #endif
  43294. if (err == MP_OKAY) {
  43295. s1 = t + 1;
  43296. s2 = t + 2;
  43297. err = sp_1024_mod_mul_norm_42(t->x, a->x, p1024_mod);
  43298. }
  43299. if (err == MP_OKAY) {
  43300. err = sp_1024_mod_mul_norm_42(t->y, a->y, p1024_mod);
  43301. }
  43302. if (err == MP_OKAY) {
  43303. err = sp_1024_mod_mul_norm_42(t->z, a->z, p1024_mod);
  43304. }
  43305. if (err == MP_OKAY) {
  43306. t->infinity = 0;
  43307. sp_1024_proj_to_affine_42(t, tmp);
  43308. XMEMCPY(s1->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  43309. s1->infinity = 0;
  43310. XMEMCPY(s2->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  43311. s2->infinity = 0;
  43312. /* table[0] = {0, 0, infinity} */
  43313. XMEMSET(&table[0], 0, sizeof(sp_table_entry_1024));
  43314. /* table[1] = Affine version of 'a' in Montgomery form */
  43315. XMEMCPY(table[1].x, t->x, sizeof(table->x));
  43316. XMEMCPY(table[1].y, t->y, sizeof(table->y));
  43317. for (i=1; i<8; i++) {
  43318. sp_1024_proj_point_dbl_n_42(t, 128, tmp);
  43319. sp_1024_proj_to_affine_42(t, tmp);
  43320. XMEMCPY(table[1<<i].x, t->x, sizeof(table->x));
  43321. XMEMCPY(table[1<<i].y, t->y, sizeof(table->y));
  43322. }
  43323. for (i=1; i<8; i++) {
  43324. XMEMCPY(s1->x, table[1<<i].x, sizeof(table->x));
  43325. XMEMCPY(s1->y, table[1<<i].y, sizeof(table->y));
  43326. for (j=(1<<i)+1; j<(1<<(i+1)); j++) {
  43327. XMEMCPY(s2->x, table[j-(1<<i)].x, sizeof(table->x));
  43328. XMEMCPY(s2->y, table[j-(1<<i)].y, sizeof(table->y));
  43329. sp_1024_proj_point_add_qz1_42(t, s1, s2, tmp);
  43330. sp_1024_proj_to_affine_42(t, tmp);
  43331. XMEMCPY(table[j].x, t->x, sizeof(table->x));
  43332. XMEMCPY(table[j].y, t->y, sizeof(table->y));
  43333. }
  43334. }
  43335. }
  43336. #ifdef WOLFSSL_SP_SMALL_STACK
  43337. if (t != NULL)
  43338. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  43339. #endif
  43340. return err;
  43341. }
  43342. #endif /* FP_ECC | !WOLFSSL_SP_SMALL */
  43343. /* Multiply the point by the scalar and return the result.
  43344. * If map is true then convert result to affine coordinates.
  43345. *
  43346. * Stripe implementation.
  43347. * Pre-generated: 2^0, 2^128, ...
  43348. * Pre-generated: products of all combinations of above.
  43349. * 8 doubles and adds (with qz=1)
  43350. *
  43351. * r Resulting point.
  43352. * k Scalar to multiply by.
  43353. * table Pre-computed table.
  43354. * map Indicates whether to convert result to affine.
  43355. * ct Constant time required.
  43356. * heap Heap to use for allocation.
  43357. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  43358. */
  43359. static int sp_1024_ecc_mulmod_stripe_42(sp_point_1024* r, const sp_point_1024* g,
  43360. const sp_table_entry_1024* table, const sp_digit* k, int map,
  43361. int ct, void* heap)
  43362. {
  43363. #ifdef WOLFSSL_SP_SMALL_STACK
  43364. sp_point_1024* rt = NULL;
  43365. sp_digit* t = NULL;
  43366. #else
  43367. sp_point_1024 rt[2];
  43368. sp_digit t[2 * 42 * 37];
  43369. #endif
  43370. sp_point_1024* p = NULL;
  43371. int i;
  43372. int j;
  43373. int y;
  43374. int x;
  43375. int err = MP_OKAY;
  43376. (void)g;
  43377. /* Constant time used for cache attack resistance implementation. */
  43378. (void)ct;
  43379. (void)heap;
  43380. #ifdef WOLFSSL_SP_SMALL_STACK
  43381. rt = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) * 2, heap,
  43382. DYNAMIC_TYPE_ECC);
  43383. if (rt == NULL)
  43384. err = MEMORY_E;
  43385. if (err == MP_OKAY) {
  43386. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 42 * 37, heap,
  43387. DYNAMIC_TYPE_ECC);
  43388. if (t == NULL)
  43389. err = MEMORY_E;
  43390. }
  43391. #endif
  43392. if (err == MP_OKAY) {
  43393. p = rt + 1;
  43394. XMEMCPY(p->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  43395. XMEMCPY(rt->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  43396. y = 0;
  43397. x = 127;
  43398. for (j=0; j<8; j++) {
  43399. y |= (int)(((k[x / 25] >> (x % 25)) & 1) << j);
  43400. x += 128;
  43401. }
  43402. XMEMCPY(rt->x, table[y].x, sizeof(table[y].x));
  43403. XMEMCPY(rt->y, table[y].y, sizeof(table[y].y));
  43404. rt->infinity = !y;
  43405. for (i=126; i>=0; i--) {
  43406. y = 0;
  43407. x = i;
  43408. for (j=0; j<8; j++) {
  43409. y |= (int)(((k[x / 25] >> (x % 25)) & 1) << j);
  43410. x += 128;
  43411. }
  43412. sp_1024_proj_point_dbl_42(rt, rt, t);
  43413. XMEMCPY(p->x, table[y].x, sizeof(table[y].x));
  43414. XMEMCPY(p->y, table[y].y, sizeof(table[y].y));
  43415. p->infinity = !y;
  43416. sp_1024_proj_point_add_qz1_42(rt, rt, p, t);
  43417. }
  43418. if (map != 0) {
  43419. sp_1024_map_42(r, rt, t);
  43420. }
  43421. else {
  43422. XMEMCPY(r, rt, sizeof(sp_point_1024));
  43423. }
  43424. }
  43425. #ifdef WOLFSSL_SP_SMALL_STACK
  43426. if (t != NULL)
  43427. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  43428. if (rt != NULL)
  43429. XFREE(rt, heap, DYNAMIC_TYPE_ECC);
  43430. #endif
  43431. return err;
  43432. }
  43433. #ifdef FP_ECC
  43434. #ifndef FP_ENTRIES
  43435. #define FP_ENTRIES 16
  43436. #endif
  43437. /* Cache entry - holds precomputation tables for a point. */
  43438. typedef struct sp_cache_1024_t {
  43439. /* X ordinate of point that table was generated from. */
  43440. sp_digit x[42];
  43441. /* Y ordinate of point that table was generated from. */
  43442. sp_digit y[42];
  43443. /* Precomputation table for point. */
  43444. sp_table_entry_1024 table[256];
  43445. /* Count of entries in table. */
  43446. uint32_t cnt;
  43447. /* Point and table set in entry. */
  43448. int set;
  43449. } sp_cache_1024_t;
  43450. /* Cache of tables. */
  43451. static THREAD_LS_T sp_cache_1024_t sp_cache_1024[FP_ENTRIES];
  43452. /* Index of last entry in cache. */
  43453. static THREAD_LS_T int sp_cache_1024_last = -1;
  43454. /* Cache has been initialized. */
  43455. static THREAD_LS_T int sp_cache_1024_inited = 0;
  43456. #ifndef HAVE_THREAD_LS
  43457. static volatile int initCacheMutex_1024 = 0;
  43458. static wolfSSL_Mutex sp_cache_1024_lock;
  43459. #endif
  43460. /* Get the cache entry for the point.
  43461. *
  43462. * g [in] Point scalar multiplying.
  43463. * cache [out] Cache table to use.
  43464. */
  43465. static void sp_ecc_get_cache_1024(const sp_point_1024* g, sp_cache_1024_t** cache)
  43466. {
  43467. int i;
  43468. int j;
  43469. uint32_t least;
  43470. if (sp_cache_1024_inited == 0) {
  43471. for (i=0; i<FP_ENTRIES; i++) {
  43472. sp_cache_1024[i].set = 0;
  43473. }
  43474. sp_cache_1024_inited = 1;
  43475. }
  43476. /* Compare point with those in cache. */
  43477. for (i=0; i<FP_ENTRIES; i++) {
  43478. if (!sp_cache_1024[i].set)
  43479. continue;
  43480. if (sp_1024_cmp_equal_42(g->x, sp_cache_1024[i].x) &
  43481. sp_1024_cmp_equal_42(g->y, sp_cache_1024[i].y)) {
  43482. sp_cache_1024[i].cnt++;
  43483. break;
  43484. }
  43485. }
  43486. /* No match. */
  43487. if (i == FP_ENTRIES) {
  43488. /* Find empty entry. */
  43489. i = (sp_cache_1024_last + 1) % FP_ENTRIES;
  43490. for (; i != sp_cache_1024_last; i=(i+1)%FP_ENTRIES) {
  43491. if (!sp_cache_1024[i].set) {
  43492. break;
  43493. }
  43494. }
  43495. /* Evict least used. */
  43496. if (i == sp_cache_1024_last) {
  43497. least = sp_cache_1024[0].cnt;
  43498. for (j=1; j<FP_ENTRIES; j++) {
  43499. if (sp_cache_1024[j].cnt < least) {
  43500. i = j;
  43501. least = sp_cache_1024[i].cnt;
  43502. }
  43503. }
  43504. }
  43505. XMEMCPY(sp_cache_1024[i].x, g->x, sizeof(sp_cache_1024[i].x));
  43506. XMEMCPY(sp_cache_1024[i].y, g->y, sizeof(sp_cache_1024[i].y));
  43507. sp_cache_1024[i].set = 1;
  43508. sp_cache_1024[i].cnt = 1;
  43509. }
  43510. *cache = &sp_cache_1024[i];
  43511. sp_cache_1024_last = i;
  43512. }
  43513. #endif /* FP_ECC */
  43514. /* Multiply the base point of P1024 by the scalar and return the result.
  43515. * If map is true then convert result to affine coordinates.
  43516. *
  43517. * r Resulting point.
  43518. * g Point to multiply.
  43519. * k Scalar to multiply by.
  43520. * map Indicates whether to convert result to affine.
  43521. * ct Constant time required.
  43522. * heap Heap to use for allocation.
  43523. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  43524. */
  43525. static int sp_1024_ecc_mulmod_42(sp_point_1024* r, const sp_point_1024* g,
  43526. const sp_digit* k, int map, int ct, void* heap)
  43527. {
  43528. #ifndef FP_ECC
  43529. return sp_1024_ecc_mulmod_win_add_sub_42(r, g, k, map, ct, heap);
  43530. #else
  43531. #ifdef WOLFSSL_SP_SMALL_STACK
  43532. sp_digit* tmp;
  43533. #else
  43534. sp_digit tmp[2 * 42 * 38];
  43535. #endif
  43536. sp_cache_1024_t* cache;
  43537. int err = MP_OKAY;
  43538. #ifdef WOLFSSL_SP_SMALL_STACK
  43539. tmp = (sp_digit*)XMALLOC(sizeof(sp_digit) * 2 * 42 * 38, heap, DYNAMIC_TYPE_ECC);
  43540. if (tmp == NULL) {
  43541. err = MEMORY_E;
  43542. }
  43543. #endif
  43544. #ifndef HAVE_THREAD_LS
  43545. if (err == MP_OKAY) {
  43546. if (initCacheMutex_1024 == 0) {
  43547. wc_InitMutex(&sp_cache_1024_lock);
  43548. initCacheMutex_1024 = 1;
  43549. }
  43550. if (wc_LockMutex(&sp_cache_1024_lock) != 0) {
  43551. err = BAD_MUTEX_E;
  43552. }
  43553. }
  43554. #endif /* HAVE_THREAD_LS */
  43555. if (err == MP_OKAY) {
  43556. sp_ecc_get_cache_1024(g, &cache);
  43557. if (cache->cnt == 2)
  43558. sp_1024_gen_stripe_table_42(g, cache->table, tmp, heap);
  43559. #ifndef HAVE_THREAD_LS
  43560. wc_UnLockMutex(&sp_cache_1024_lock);
  43561. #endif /* HAVE_THREAD_LS */
  43562. if (cache->cnt < 2) {
  43563. err = sp_1024_ecc_mulmod_win_add_sub_42(r, g, k, map, ct, heap);
  43564. }
  43565. else {
  43566. err = sp_1024_ecc_mulmod_stripe_42(r, g, cache->table, k,
  43567. map, ct, heap);
  43568. }
  43569. }
  43570. #ifdef WOLFSSL_SP_SMALL_STACK
  43571. XFREE(tmp, heap, DYNAMIC_TYPE_ECC);
  43572. #endif
  43573. return err;
  43574. #endif
  43575. }
  43576. #endif
  43577. /* Multiply the point by the scalar and return the result.
  43578. * If map is true then convert result to affine coordinates.
  43579. *
  43580. * km Scalar to multiply by.
  43581. * p Point to multiply.
  43582. * r Resulting point.
  43583. * map Indicates whether to convert result to affine.
  43584. * heap Heap to use for allocation.
  43585. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  43586. */
  43587. int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
  43588. int map, void* heap)
  43589. {
  43590. #ifdef WOLFSSL_SP_SMALL_STACK
  43591. sp_point_1024* point = NULL;
  43592. sp_digit* k = NULL;
  43593. #else
  43594. sp_point_1024 point[1];
  43595. sp_digit k[42];
  43596. #endif
  43597. int err = MP_OKAY;
  43598. #ifdef WOLFSSL_SP_SMALL_STACK
  43599. point = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), heap,
  43600. DYNAMIC_TYPE_ECC);
  43601. if (point == NULL)
  43602. err = MEMORY_E;
  43603. if (err == MP_OKAY) {
  43604. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 42, heap,
  43605. DYNAMIC_TYPE_ECC);
  43606. if (k == NULL)
  43607. err = MEMORY_E;
  43608. }
  43609. #endif
  43610. if (err == MP_OKAY) {
  43611. sp_1024_from_mp(k, 42, km);
  43612. sp_1024_point_from_ecc_point_42(point, gm);
  43613. err = sp_1024_ecc_mulmod_42(point, point, k, map, 1, heap);
  43614. }
  43615. if (err == MP_OKAY) {
  43616. err = sp_1024_point_to_ecc_point_42(point, r);
  43617. }
  43618. #ifdef WOLFSSL_SP_SMALL_STACK
  43619. if (k != NULL)
  43620. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  43621. if (point != NULL)
  43622. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  43623. #endif
  43624. return err;
  43625. }
  43626. #ifdef WOLFSSL_SP_SMALL
  43627. /* Multiply the base point of P1024 by the scalar and return the result.
  43628. * If map is true then convert result to affine coordinates.
  43629. *
  43630. * r Resulting point.
  43631. * k Scalar to multiply by.
  43632. * map Indicates whether to convert result to affine.
  43633. * heap Heap to use for allocation.
  43634. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  43635. */
  43636. static int sp_1024_ecc_mulmod_base_42(sp_point_1024* r, const sp_digit* k,
  43637. int map, int ct, void* heap)
  43638. {
  43639. /* No pre-computed values. */
  43640. return sp_1024_ecc_mulmod_42(r, &p1024_base, k, map, ct, heap);
  43641. }
  43642. #ifdef WOLFSSL_SP_NONBLOCK
  43643. static int sp_1024_ecc_mulmod_base_42_nb(sp_ecc_ctx_t* sp_ctx, sp_point_1024* r,
  43644. const sp_digit* k, int map, int ct, void* heap)
  43645. {
  43646. /* No pre-computed values. */
  43647. return sp_1024_ecc_mulmod_42_nb(sp_ctx, r, &p1024_base, k, map, ct, heap);
  43648. }
  43649. #endif /* WOLFSSL_SP_NONBLOCK */
  43650. #else
  43651. /* Striping precomputation table.
  43652. * 8 points combined into a table of 256 points.
  43653. * Distance of 128 between points.
  43654. */
  43655. static const sp_table_entry_1024 p1024_table[256] = {
  43656. /* 0 */
  43657. { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43658. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43659. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43660. 0x00, 0x00, 0x00, 0x00, 0x00 },
  43661. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43662. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43663. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43664. 0x00, 0x00, 0x00, 0x00, 0x00 } },
  43665. /* 1 */
  43666. { { 0x0162bc2,0x03f6370,0x0a26fe7,0x0621512,0x1decc6e,0x04cec0e,
  43667. 0x077c279,0x030bab3,0x06d3582,0x14b7514,0x17e36e6,0x0fa6e18,
  43668. 0x0601aec,0x067ae83,0x0b92656,0x1aff1ce,0x17d3e91,0x1617394,
  43669. 0x0a7cbd6,0x03b725b,0x19ed862,0x13ad2b3,0x12c9b21,0x0ad5582,
  43670. 0x185df2c,0x1cc9199,0x131a84f,0x111ce9a,0x08ec11b,0x18b9ffd,
  43671. 0x1bc4852,0x03e7f3f,0x0386a27,0x1da2750,0x0d3b039,0x0d7b363,
  43672. 0x0ecd349,0x12946e7,0x1e02ebf,0x0d43893,0x08dfff9 },
  43673. { 0x03c0c83,0x03a9d60,0x15d6d29,0x11579b9,0x08e69d1,0x1adb24b,
  43674. 0x06e23dd,0x0a5c707,0x0bf58f3,0x01fca4d,0x0f05720,0x0cf37a1,
  43675. 0x025f702,0x07f94c6,0x0fd745a,0x12edd0b,0x198c6c7,0x01fb75e,
  43676. 0x178f86d,0x0315e88,0x0093206,0x072a732,0x19f5566,0x09fdb3c,
  43677. 0x1283b50,0x08bd823,0x15c361d,0x0a1957f,0x1addbe4,0x145f9fa,
  43678. 0x1291f58,0x0f19699,0x037ef30,0x0248400,0x14f1ac7,0x0e9c291,
  43679. 0x0fcfd83,0x0b6994a,0x007cf89,0x0f7bc78,0x02aa120 } },
  43680. /* 2 */
  43681. { { 0x1900955,0x1b6d700,0x15b6a56,0x039d68c,0x05dc9cc,0x17f4add,
  43682. 0x0241f9c,0x068a18f,0x1a040c3,0x0d72a23,0x0ba9ba8,0x06e0f2a,
  43683. 0x0591191,0x1684b98,0x1fdcd0d,0x1a21ea9,0x074bda4,0x0526d80,
  43684. 0x059101c,0x060de32,0x122cfd5,0x19c5922,0x052e7f9,0x093eec4,
  43685. 0x0dad678,0x1720a34,0x02c3734,0x0f65343,0x1ad4928,0x18d0af0,
  43686. 0x06ab75f,0x1b77454,0x0c63a81,0x119bccd,0x116e048,0x10026f3,
  43687. 0x10e53bc,0x0159785,0x0ed87d0,0x0fe17e2,0x08c3eb2 },
  43688. { 0x113696f,0x169f0f2,0x1fea692,0x1831903,0x0350ba5,0x019e898,
  43689. 0x104d8f0,0x1783c5f,0x117a531,0x1ed3738,0x1584354,0x092035d,
  43690. 0x0742ec6,0x14cffab,0x0fa37df,0x1a255a6,0x13e3dee,0x1f2556b,
  43691. 0x003d37a,0x0768ca3,0x10b4d98,0x14a8179,0x064d949,0x1231aff,
  43692. 0x199aba8,0x1cd3f13,0x19c03f1,0x1ffd096,0x1fd8c20,0x006b205,
  43693. 0x0f5ed10,0x0ba4c83,0x1a21d21,0x110e5e1,0x110b0c9,0x06f3072,
  43694. 0x11401e8,0x132805d,0x10c42b3,0x07c4a38,0x07bf416 } },
  43695. /* 3 */
  43696. { { 0x1fd589e,0x1a7c471,0x080c705,0x01bf2e9,0x1b50179,0x182a4fe,
  43697. 0x08f8cf9,0x069a12c,0x115924f,0x0848f7f,0x196b163,0x195bf36,
  43698. 0x0feef79,0x1fb4e16,0x1310988,0x10579a5,0x03252cd,0x0c0bec8,
  43699. 0x17c7777,0x09e9b34,0x16bdacf,0x1aa808d,0x1418498,0x1a28193,
  43700. 0x0490d2e,0x1694fba,0x1136da1,0x08125d1,0x0b0fcc6,0x178b3bb,
  43701. 0x0d8897b,0x1be2d5d,0x08c01e9,0x1ec1507,0x1d0612e,0x0ec506c,
  43702. 0x0956e33,0x1aba714,0x1fc1dd5,0x18ce0b4,0x09871ed },
  43703. { 0x16535f7,0x1bb6abb,0x0ee2f42,0x044c6b6,0x1214d60,0x10b7b22,
  43704. 0x16b6674,0x0eb8184,0x15515bf,0x0a6f9d3,0x1c59d7f,0x0b78bd3,
  43705. 0x0724a62,0x003439f,0x0d7bedd,0x0b89478,0x033bb2e,0x177ae4d,
  43706. 0x01ac662,0x0366bd0,0x10eda97,0x12d1e34,0x07d7032,0x03c4683,
  43707. 0x1dd898e,0x0f2546a,0x1a556b6,0x19d9799,0x0d34164,0x0203924,
  43708. 0x1b8bb3d,0x08b815e,0x0bb3811,0x007ff8d,0x1a0871e,0x0e7e97d,
  43709. 0x0272ed5,0x06fbb46,0x0deb745,0x0146e2c,0x0397ed1 } },
  43710. /* 4 */
  43711. { { 0x15c2a27,0x105d93a,0x11133cf,0x12b2b0b,0x138e42f,0x142f306,
  43712. 0x0f83c64,0x01e8d62,0x076273d,0x1f66860,0x115a6b0,0x010a327,
  43713. 0x0a7800f,0x01a8c0c,0x139d2ad,0x06c77e0,0x0388496,0x1492c55,
  43714. 0x032253f,0x0cc2f97,0x09a0845,0x15157cb,0x02f18aa,0x08cd1b3,
  43715. 0x0280b5a,0x07d3361,0x1aa64bd,0x193beb1,0x001e99b,0x1bec9fa,
  43716. 0x03976c2,0x1898718,0x0614fe1,0x0fb59f0,0x1470b33,0x11aa622,
  43717. 0x0143b61,0x1abaf67,0x0629071,0x10bbf27,0x0402479 },
  43718. { 0x1055746,0x128bc47,0x1b83ee8,0x001563c,0x05ba004,0x14934be,
  43719. 0x053eeb0,0x081c363,0x15b4f47,0x18a908c,0x1ee951d,0x03a1376,
  43720. 0x0425009,0x1cd09cd,0x19d2186,0x154fcf4,0x1b3f353,0x15d4209,
  43721. 0x110f3bb,0x0ee3244,0x1bd0afe,0x1b1c23d,0x0511a34,0x149285a,
  43722. 0x19ff63d,0x02b30fb,0x075096d,0x0ac7438,0x1f46301,0x07e6baf,
  43723. 0x124f09c,0x1d65005,0x0072090,0x0380221,0x172f217,0x08d1e19,
  43724. 0x1a032e7,0x01b97df,0x0760329,0x1cd916f,0x01a6fd1 } },
  43725. /* 5 */
  43726. { { 0x15116a3,0x1480d46,0x11fe59e,0x0965ebe,0x0b84439,0x15d79d8,
  43727. 0x1514983,0x019c735,0x160ccfc,0x10df30b,0x1d4fc87,0x07a5987,
  43728. 0x16ac07e,0x0f688dd,0x00e3838,0x16185bb,0x1071c15,0x022a3a9,
  43729. 0x083f96e,0x1a8e912,0x096d70d,0x16f238c,0x06882f8,0x04ed8f8,
  43730. 0x1ad8a59,0x1039e1f,0x0f221bb,0x04d4398,0x031ac40,0x179bb74,
  43731. 0x1967f6d,0x158a03a,0x0a35d1a,0x142ba13,0x0415036,0x0a15d31,
  43732. 0x0bd734e,0x0ef0525,0x11d4197,0x1b82ac2,0x029b7d4 },
  43733. { 0x1f4e20b,0x1e165e5,0x131512c,0x1eb1988,0x1c3f548,0x06560f8,
  43734. 0x06d516c,0x0427301,0x100f806,0x007815a,0x0417803,0x11200cd,
  43735. 0x0ce612b,0x01a80c4,0x0563b5e,0x0ed651e,0x0583f55,0x0600ee2,
  43736. 0x11524b8,0x0064e54,0x0443298,0x1d07fc9,0x1de9588,0x1a1b882,
  43737. 0x02b0029,0x03d6895,0x049e03a,0x0824a8b,0x13f272b,0x1c8186a,
  43738. 0x0347af3,0x048603d,0x0e6ea40,0x083cc5d,0x1cbe8df,0x183cbe7,
  43739. 0x02b4126,0x0161881,0x125fa4d,0x004a704,0x05d0928 } },
  43740. /* 6 */
  43741. { { 0x12f780d,0x115bf7f,0x0c7560e,0x01afaed,0x14d2682,0x1ba5761,
  43742. 0x0a11e1b,0x1d7c786,0x010823f,0x1ea1109,0x19efd03,0x02fdf6b,
  43743. 0x0d227e4,0x12b47c6,0x03526da,0x177d8a2,0x1d61781,0x1a9de73,
  43744. 0x1cdc62d,0x1c7e445,0x0c1f9cf,0x0fecef3,0x1fd13a2,0x15936aa,
  43745. 0x0553f3f,0x05e78e6,0x1b9bcc0,0x1a5a108,0x0ae6b19,0x01514f8,
  43746. 0x1825db2,0x0497177,0x03dbf5e,0x12d53f3,0x1d165ce,0x0e9958f,
  43747. 0x04dd33c,0x15b11bc,0x1b9771b,0x068285f,0x00a26e4 },
  43748. { 0x0aa9a08,0x099cfd6,0x1386020,0x0aa48dd,0x00f3110,0x1c9ba3a,
  43749. 0x005c184,0x1c31259,0x1242f02,0x0c6a081,0x17a62a3,0x1a4076b,
  43750. 0x12482bf,0x0d5df4a,0x1be51ad,0x1049313,0x0b93769,0x15c690c,
  43751. 0x1985f1e,0x0d1d12c,0x0b91d52,0x08c5be9,0x058b9d5,0x11acf87,
  43752. 0x07973fe,0x028962e,0x08ac05f,0x05c62a1,0x0294694,0x0f5e60d,
  43753. 0x00dbd39,0x0a638e1,0x19910ce,0x1cf2851,0x1ad2dde,0x015e9ed,
  43754. 0x1a120ad,0x05d8bae,0x0dbb1a3,0x0c3724c,0x019497c } },
  43755. /* 7 */
  43756. { { 0x17659a8,0x0586320,0x03fda48,0x0f25965,0x077ab9c,0x03bcbfe,
  43757. 0x1c602da,0x0c6ab6c,0x1e77593,0x057ac60,0x06c6193,0x1b6caac,
  43758. 0x065155b,0x1c07a4a,0x1938d55,0x116405c,0x1b7229a,0x0758564,
  43759. 0x15c6f58,0x129af04,0x18f9885,0x1cf1fd3,0x1773024,0x185a6f2,
  43760. 0x148302a,0x0223dc5,0x02e43c5,0x00bf7ec,0x04b3c15,0x07409e7,
  43761. 0x062b184,0x1ab36b8,0x1a4f27a,0x101111c,0x05cdf3a,0x16bf467,
  43762. 0x0dff1c7,0x1c3985c,0x1de9b95,0x116a2f7,0x096b91b },
  43763. { 0x0ac087c,0x0c8fa4d,0x0a3706a,0x1cd9fb6,0x0e62f74,0x1b006b6,
  43764. 0x1fe697d,0x19211ad,0x0f917f9,0x1c0e682,0x14b6ff5,0x0bec7bc,
  43765. 0x007796f,0x176b90c,0x16d9380,0x026fbcf,0x0f66fa4,0x107843b,
  43766. 0x1287dc5,0x03dcc87,0x18a3327,0x0c3e255,0x12e6c81,0x090208f,
  43767. 0x1710739,0x01be5d0,0x1566317,0x1f34321,0x00e125d,0x1395379,
  43768. 0x0b432db,0x1e9e520,0x1142204,0x16e7dd1,0x12e5f38,0x0285a51,
  43769. 0x03d3c35,0x130dc55,0x092777c,0x02b9ff8,0x073f3d3 } },
  43770. /* 8 */
  43771. { { 0x0fd3673,0x142adf3,0x0ded761,0x1f3a429,0x109b70a,0x0236699,
  43772. 0x0be4373,0x1bd1a66,0x1595510,0x0a9e00a,0x0494739,0x012c718,
  43773. 0x095746a,0x02e60de,0x1f3a96e,0x1751f9a,0x068002e,0x027fd0a,
  43774. 0x0bf35df,0x0796e04,0x05e310a,0x1de2750,0x0da6677,0x1f4eadd,
  43775. 0x1a0d04e,0x1ec19ba,0x1b73b57,0x1b204f3,0x1fd56e4,0x1201928,
  43776. 0x1c52064,0x105498b,0x07633a4,0x0082df4,0x04c06cd,0x1062e1a,
  43777. 0x1247e57,0x0cc587b,0x087ea4e,0x0c886d7,0x088934f },
  43778. { 0x113eabc,0x1a1d823,0x145fc27,0x03599b8,0x0ca7dd9,0x09e53e2,
  43779. 0x098efbc,0x0964fb5,0x0258818,0x1972d3d,0x1709a62,0x0c25b2b,
  43780. 0x0c0a8cb,0x10f978a,0x1a5d68b,0x126b868,0x0ede172,0x18f94dc,
  43781. 0x102f078,0x17fadda,0x03dac3c,0x1f89931,0x14fd1ac,0x016ed03,
  43782. 0x1be6dfb,0x1a2608a,0x155b690,0x1c63868,0x043d985,0x1f8c547,
  43783. 0x1aa9f18,0x097bb69,0x1cb2083,0x07ac62a,0x10e1295,0x1362d41,
  43784. 0x06fd69d,0x1566512,0x12385d3,0x1762a6a,0x00d1898 } },
  43785. /* 9 */
  43786. { { 0x15ef043,0x19a30f1,0x15913a9,0x12692d6,0x107b67d,0x1c1d1e0,
  43787. 0x05cef43,0x06bac58,0x051d29c,0x16a581c,0x070693e,0x1054e36,
  43788. 0x1e3f428,0x0a5a1dc,0x0af3d99,0x1ea86ba,0x1aa2abd,0x0e3bd8a,
  43789. 0x0af8f70,0x071501b,0x073b5cb,0x175240b,0x057f682,0x1721d7c,
  43790. 0x16b4de7,0x1ec434c,0x14af23c,0x09f0fc4,0x04e4248,0x01eb1be,
  43791. 0x162b7b4,0x1af4f5f,0x1ede666,0x05c9d72,0x168a873,0x0301bb2,
  43792. 0x06fba39,0x0e7e92a,0x0b98295,0x1b88df0,0x02bdab1 },
  43793. { 0x06fed61,0x0f115fd,0x0539e93,0x0b991bb,0x0a458aa,0x09117ae,
  43794. 0x0b7c41c,0x0ee7c6e,0x1e5aff3,0x1525a27,0x0e39b41,0x174e94e,
  43795. 0x16bc2d0,0x0f98f89,0x11c3875,0x1522234,0x13ae102,0x0bbffc9,
  43796. 0x0431e21,0x1014a06,0x05ac8b3,0x143c1fe,0x07cf008,0x0e4ba0d,
  43797. 0x0892544,0x110f633,0x196b210,0x0f1e1c2,0x1a6e8a8,0x18d7e7e,
  43798. 0x0ea68eb,0x0f19a55,0x183ed37,0x0875700,0x158209b,0x0a659b7,
  43799. 0x0bee641,0x11a330e,0x00482cc,0x1257382,0x0353eb8 } },
  43800. /* 10 */
  43801. { { 0x0b5521e,0x0e56b08,0x0bc323f,0x00a5ce0,0x1a11b44,0x1ed24e0,
  43802. 0x1a0363f,0x15ac604,0x0cbf36b,0x0dcb2a5,0x028b5f3,0x1c22982,
  43803. 0x007b58c,0x131873f,0x1747df7,0x150263c,0x17d6760,0x1c65f1e,
  43804. 0x12035df,0x0b0cd6c,0x0219eb3,0x19bf81b,0x161ca33,0x1514eae,
  43805. 0x065ed42,0x0386eac,0x1641a8a,0x107e3e3,0x1f906b2,0x1fd2528,
  43806. 0x0a1e788,0x0a87641,0x0ac6e83,0x13baa79,0x0de6e07,0x1c9e16c,
  43807. 0x040016e,0x1de06a4,0x0d9f55f,0x0e3cc43,0x08da207 },
  43808. { 0x0ce65ec,0x0a80276,0x0178f21,0x1f6e903,0x16d10d1,0x1cbd693,
  43809. 0x1ef29e1,0x15ac97c,0x077e54a,0x1a226d8,0x17c3fd0,0x01937c1,
  43810. 0x0417b6b,0x02a8435,0x11095b0,0x1ab471f,0x03bfd74,0x07ca962,
  43811. 0x0713b6e,0x1c00b40,0x0328501,0x1e252bf,0x1545cb7,0x0baddc7,
  43812. 0x0ce4e53,0x08c6da0,0x1031942,0x15de3cb,0x1561fcb,0x02f3c2b,
  43813. 0x11ba145,0x0694449,0x068536a,0x0705172,0x089c3b0,0x18d351c,
  43814. 0x042b03f,0x1a91239,0x0f57ecf,0x1c5877d,0x0862f55 } },
  43815. /* 11 */
  43816. { { 0x06049fe,0x11c8791,0x07ecb5a,0x11b9779,0x0c92a57,0x11a7dbe,
  43817. 0x1b2925d,0x1274a5f,0x03dea58,0x19a065b,0x07a458a,0x0714549,
  43818. 0x13a39f3,0x0a4f20f,0x0cb7cf6,0x0fc804d,0x0db065a,0x1638e3e,
  43819. 0x1a0a068,0x1709408,0x0eca4a9,0x01b98f7,0x18fbad4,0x1976e4a,
  43820. 0x0913476,0x1c67368,0x06e5299,0x19f2f35,0x0fd9f10,0x061dc04,
  43821. 0x0e6d136,0x1c15f8b,0x00da613,0x0df34f3,0x1f78fa9,0x1ea5b9c,
  43822. 0x1c1ee74,0x0eb4326,0x01e40e9,0x1227790,0x071ab28 },
  43823. { 0x15b60ad,0x0c7e21d,0x06133d8,0x0094186,0x0afb5e3,0x0019810,
  43824. 0x00732f1,0x0cda447,0x1db1c0c,0x1e7c4a9,0x04aa34c,0x1c9b4c2,
  43825. 0x069c994,0x08cb3d4,0x0ab8b0f,0x19a53af,0x0935b7a,0x1e146aa,
  43826. 0x12695fe,0x0b7a26d,0x07f9807,0x1f4e421,0x12700dc,0x0644beb,
  43827. 0x0a18d19,0x0c6165e,0x0d10b00,0x06eefa2,0x13a7277,0x16a3fdd,
  43828. 0x063af97,0x032c5b8,0x0437d49,0x0440338,0x1824b70,0x19e7383,
  43829. 0x15fff35,0x14e37b8,0x029940f,0x16cbc6c,0x08d087b } },
  43830. /* 12 */
  43831. { { 0x1dc1844,0x091811f,0x115af88,0x1e20bd5,0x0eca27e,0x1451a43,
  43832. 0x0981bc5,0x1964307,0x1e1d7a4,0x0afc03e,0x1750f8a,0x0c64fde,
  43833. 0x077246a,0x03b812e,0x050c817,0x09c7d5c,0x1caf348,0x0a5efe3,
  43834. 0x1d4b01d,0x07312bb,0x0ac0ec9,0x1b6bd4e,0x00b9957,0x15dbb61,
  43835. 0x1fe208b,0x198cc2e,0x1149f79,0x13902fc,0x1de1ea7,0x07de189,
  43836. 0x0ecc338,0x1989ed9,0x1f95b89,0x19066ce,0x1c7bd6e,0x03e55db,
  43837. 0x1a8cfb0,0x0f05448,0x0dfb3f0,0x094c7db,0x0225ed3 },
  43838. { 0x0bb1a85,0x18aa6dd,0x1968f84,0x0e3cd4a,0x13d8dae,0x058807e,
  43839. 0x1f55aad,0x035a642,0x0ebc78e,0x026c9a7,0x1cf4df5,0x043691c,
  43840. 0x0b02153,0x100f21e,0x1242fe8,0x0120b77,0x1d02750,0x09e11f8,
  43841. 0x019a468,0x1ca0019,0x041c2a2,0x093032c,0x022caeb,0x004d6c0,
  43842. 0x01caf30,0x1308aea,0x1149db3,0x0e2585e,0x132ffb1,0x01f38ac,
  43843. 0x1c80713,0x0d4e995,0x094e13d,0x09bd23c,0x177c301,0x1c05ade,
  43844. 0x02b1c97,0x1dbb016,0x1f1eea3,0x1cba110,0x0612b60 } },
  43845. /* 13 */
  43846. { { 0x0245d6b,0x04ae7dd,0x1fdbbf5,0x0f459c7,0x1cf0cbb,0x1aff772,
  43847. 0x0ab037f,0x14649b4,0x0cf28c6,0x0648a7c,0x0295ae4,0x0a1a861,
  43848. 0x1472fdb,0x09eb901,0x16fdde4,0x193d207,0x091822a,0x0e7d2f6,
  43849. 0x0ba8fa0,0x1ce7907,0x11390dd,0x1133144,0x1516ea5,0x0d597a6,
  43850. 0x1648bca,0x01d5297,0x1a6281a,0x1ede4ed,0x18ed52f,0x09d651b,
  43851. 0x16494db,0x110b583,0x13c2c54,0x042539a,0x0b6802f,0x0f95fea,
  43852. 0x1768416,0x18fc0e1,0x061b8e5,0x1c3a5af,0x00f7334 },
  43853. { 0x196067e,0x1ae41b2,0x001abee,0x1271833,0x13e54e1,0x0586e61,
  43854. 0x1659ce7,0x1f3050b,0x1424035,0x1a9fa1e,0x1e4254a,0x03f1bfd,
  43855. 0x1a38c53,0x0d87ab8,0x1efa393,0x14f0f21,0x0d2a39c,0x04d060f,
  43856. 0x01bc988,0x1983acc,0x0b4a2fe,0x18b95be,0x0772242,0x176f0d1,
  43857. 0x0a6fbcc,0x124e19e,0x0bf9cfb,0x0362210,0x166c48d,0x1e8bfe5,
  43858. 0x1cd642d,0x10dc28a,0x156b0a6,0x156c2c9,0x0b1014f,0x16ebad0,
  43859. 0x054d30f,0x172afd6,0x1a526ca,0x0e5f15d,0x067636a } },
  43860. /* 14 */
  43861. { { 0x11d6bea,0x031de5c,0x0e598e0,0x1d247d9,0x0e263a2,0x13d6535,
  43862. 0x0264b18,0x0fd3af6,0x077af9e,0x176800d,0x0bfaef1,0x199e495,
  43863. 0x109214a,0x1c02ad4,0x1592e59,0x0933b46,0x11ce027,0x0804ccd,
  43864. 0x11a81a9,0x0749c3c,0x0fe7e41,0x1b1728f,0x081744f,0x150877d,
  43865. 0x07d349b,0x0cf1af4,0x14c60c5,0x14c6704,0x0019230,0x145d2a3,
  43866. 0x1c9808f,0x16ffa39,0x1107721,0x17ea9cd,0x10aff7c,0x108d6aa,
  43867. 0x1c18af3,0x0a7a7c0,0x02596cc,0x0ecc159,0x0086f98 },
  43868. { 0x0bb9850,0x00caa46,0x1231d9c,0x01441a5,0x0210b73,0x1ab3863,
  43869. 0x1415d4c,0x1d48109,0x10324ba,0x166e2ca,0x1ba6d0f,0x0be58ed,
  43870. 0x04607fc,0x0207fd3,0x04f403d,0x08c79e7,0x1962dc1,0x1f0088b,
  43871. 0x11dc979,0x1704a33,0x1186f00,0x1b2de8e,0x0d7981c,0x1ee5558,
  43872. 0x0554c2c,0x0bef9ec,0x1bbe8d2,0x09ba1fb,0x06ad11b,0x13467b2,
  43873. 0x0b75c48,0x13ef71d,0x1c20afb,0x16ff283,0x0753f01,0x14c612d,
  43874. 0x1245549,0x1bef8e3,0x1a041da,0x007cc35,0x0681f94 } },
  43875. /* 15 */
  43876. { { 0x1a0623b,0x0a8b1e4,0x0351f2b,0x0ecff57,0x1bf8295,0x17be3e6,
  43877. 0x0c3b206,0x1845995,0x0e966d5,0x14f1c64,0x1390711,0x1aa5e1a,
  43878. 0x1c34430,0x12959ac,0x181d68a,0x0024e84,0x1e333bd,0x09216e9,
  43879. 0x1fb48d0,0x07ec6b3,0x0ffacda,0x186bea9,0x137ccdc,0x08187de,
  43880. 0x156f076,0x0be2fff,0x106ef79,0x0f07843,0x0bb3364,0x051575c,
  43881. 0x01761e1,0x1d5a108,0x0c7c533,0x115ea0f,0x108fe6d,0x1e96fe2,
  43882. 0x1075d4a,0x018a2e3,0x1642955,0x09574c0,0x00c9de9 },
  43883. { 0x1d5682b,0x1939aca,0x1bb63b5,0x065d84e,0x111c428,0x1b50693,
  43884. 0x0bb562c,0x11fa3e9,0x08498a8,0x155a062,0x03d1458,0x18c4890,
  43885. 0x0258c8f,0x1bce7ff,0x123292e,0x06b3b17,0x03c701a,0x0c855ac,
  43886. 0x1f57457,0x0634e67,0x133caee,0x1de4891,0x00a9565,0x187c784,
  43887. 0x1cae4b6,0x044080c,0x10a64e0,0x0a26085,0x1c8199e,0x141efa3,
  43888. 0x0483800,0x1e5401d,0x0d68e58,0x0d71dc8,0x1d069dd,0x04d3c5b,
  43889. 0x071c30b,0x097652c,0x18e5ae3,0x01d763b,0x0733dca } },
  43890. /* 16 */
  43891. { { 0x159213a,0x04ae825,0x003bd6d,0x131ae04,0x0a67203,0x13b8e0e,
  43892. 0x02698ad,0x1969796,0x02b9eb0,0x156f76a,0x0e88489,0x0ea919b,
  43893. 0x11eb544,0x1844486,0x06aff37,0x08d681c,0x163698e,0x029284c,
  43894. 0x0ba704e,0x1fe1610,0x1a71e1b,0x06a884c,0x0862793,0x172398f,
  43895. 0x0c9bcc9,0x05f11b0,0x104dfb1,0x17a9afb,0x119f6e9,0x1290e8a,
  43896. 0x00f40d5,0x19f064a,0x15f6d78,0x1515a5f,0x00c637b,0x19c8602,
  43897. 0x0f4c319,0x09924a7,0x09f5f0c,0x08e1e3f,0x02ab3bd },
  43898. { 0x02c9fbb,0x1db4049,0x1b455d4,0x101e2d8,0x069e7dc,0x00b77e4,
  43899. 0x144d6eb,0x1370688,0x0846d1d,0x19351da,0x18b0850,0x1dc765a,
  43900. 0x15b517f,0x0594956,0x016be88,0x15826d2,0x11a2cad,0x0952b89,
  43901. 0x0f6f2a3,0x009b1fd,0x1fb2cd9,0x179f9b2,0x17fb6a1,0x0fd5439,
  43902. 0x1b208dc,0x1e0384b,0x129179d,0x1346b50,0x1d118e8,0x031667a,
  43903. 0x1a105e8,0x03edd33,0x00c04a8,0x1043e9e,0x12c2e9e,0x05888e0,
  43904. 0x1ea22ad,0x0513e89,0x148a5be,0x02c984f,0x093a4b4 } },
  43905. /* 17 */
  43906. { { 0x11efb7a,0x18de08f,0x1037509,0x0c67f99,0x0e4e68e,0x0fa8545,
  43907. 0x123c6c4,0x1133b37,0x1af0760,0x0181cc7,0x14380d5,0x05f6887,
  43908. 0x0145e24,0x1b71ea6,0x1b09467,0x15a12e7,0x190ba9b,0x1d5b87b,
  43909. 0x06b7443,0x0255abf,0x02b4de6,0x070a74a,0x0e0df95,0x1716d15,
  43910. 0x056d3dd,0x0040bad,0x106b0a9,0x10b6467,0x080f94e,0x1618786,
  43911. 0x1e7e3fd,0x1131b69,0x17f3fb7,0x1ee6ea5,0x113d169,0x0b458c0,
  43912. 0x1e3d389,0x15d97b7,0x1dd8fce,0x1ae65dc,0x0342ce0 },
  43913. { 0x1491b1f,0x109ca67,0x0e57ac9,0x0e3213c,0x1caaeed,0x126df56,
  43914. 0x0156a7f,0x09bb988,0x1493d60,0x1d3308e,0x17afbc5,0x147439c,
  43915. 0x15ba445,0x11cc4e5,0x0b8a163,0x1080dd0,0x08283f5,0x0dcb7a1,
  43916. 0x055b3d5,0x0ef7334,0x0a0e998,0x13270b3,0x0be41a9,0x12eda27,
  43917. 0x1d353b2,0x100e750,0x1cdb186,0x1f82de4,0x155d86e,0x0219d87,
  43918. 0x0076c13,0x11d6698,0x0b4b269,0x101401e,0x1de0ab9,0x0a71a0f,
  43919. 0x03be3ec,0x161de5a,0x1f4810e,0x1e7c2ad,0x0455f4a } },
  43920. /* 18 */
  43921. { { 0x14ec21c,0x1f9313a,0x08e3015,0x13c7437,0x1eacd4c,0x160ff49,
  43922. 0x0434445,0x16c7404,0x0eacc8a,0x075274a,0x1ccb2b9,0x1935d4d,
  43923. 0x0e31c00,0x035cbae,0x0d88e76,0x143d2b9,0x18ca14e,0x1b2a6ae,
  43924. 0x019ff22,0x1a63e8a,0x1ecb230,0x05b1aaf,0x122ee43,0x02e5d1c,
  43925. 0x01ecedc,0x19bbc7c,0x032c019,0x1107015,0x02d0122,0x1700f0b,
  43926. 0x17066c0,0x18b5e28,0x0087a06,0x0e1aa07,0x02dedcb,0x0de09b9,
  43927. 0x0de3c06,0x07790a4,0x07edfdc,0x0862601,0x04f1482 },
  43928. { 0x02055e2,0x027e737,0x019d780,0x150d864,0x09e247e,0x0ed5514,
  43929. 0x0f6557e,0x0769d79,0x1ceb7f6,0x0af9097,0x1e12834,0x183f0c6,
  43930. 0x115ecc5,0x1abb012,0x0ce002d,0x052a8a7,0x1c38a6a,0x0f5c980,
  43931. 0x04f3746,0x0d74314,0x0d240f1,0x08c43e1,0x00c4f49,0x12827ed,
  43932. 0x035859a,0x1e2fcc9,0x1bf8ff5,0x04680bc,0x00ee054,0x159a0b7,
  43933. 0x0c19e2b,0x07f5b55,0x13be7bb,0x022388f,0x08b20a2,0x0cf203f,
  43934. 0x0d662ff,0x086d982,0x05c2f25,0x1a87802,0x074d5d2 } },
  43935. /* 19 */
  43936. { { 0x15bfe11,0x016e015,0x079e8c0,0x1aa5a64,0x0733410,0x1cdd448,
  43937. 0x03d9659,0x0dc2b24,0x0685b23,0x112460a,0x1d81003,0x0b2868d,
  43938. 0x108cfab,0x00638bf,0x15ebedd,0x08aed3e,0x08c6604,0x186dd59,
  43939. 0x1370c91,0x0132d13,0x0d050fa,0x1161187,0x10780ab,0x0b7dee8,
  43940. 0x01554e4,0x1b786cb,0x0b3935e,0x0d11530,0x02d22e9,0x1d63af3,
  43941. 0x0a3eb7b,0x17a5974,0x11512a6,0x03a4fd7,0x198af9f,0x16f10d1,
  43942. 0x0e9f5a6,0x0246c0d,0x1e8a620,0x0858b0a,0x06b1a54 },
  43943. { 0x1242066,0x15cd6a1,0x0aba7d6,0x0a59994,0x0afef1b,0x076e270,
  43944. 0x0fb1e62,0x1ab6368,0x10341b0,0x0860078,0x0aacdc3,0x11ef6a1,
  43945. 0x194d68b,0x19d3254,0x03939bf,0x0d09d35,0x0fb7f1a,0x00cc19c,
  43946. 0x14683d7,0x01ce906,0x05158bc,0x06ed622,0x0b2b3cb,0x13feed6,
  43947. 0x139995e,0x02ae0a6,0x1c58e4c,0x0940367,0x0d83765,0x1752c44,
  43948. 0x0c5ab0f,0x0e464ef,0x04d9a9a,0x0dddfdc,0x1a47847,0x1132264,
  43949. 0x0bb6717,0x1b8bd75,0x12b2165,0x04d1762,0x04c2135 } },
  43950. /* 20 */
  43951. { { 0x1532833,0x1f0534a,0x019cb9b,0x1dac4da,0x0bca228,0x0f39ded,
  43952. 0x1cf6592,0x018455d,0x0f03c4c,0x041d43d,0x1a6d148,0x0eba6a2,
  43953. 0x09e954e,0x1a28354,0x1d427b9,0x19f20ae,0x16e2aea,0x0a4e593,
  43954. 0x09027e4,0x0ebaeff,0x16b9082,0x1ef85de,0x187adbc,0x0264e08,
  43955. 0x002cbe4,0x058ca41,0x06c7126,0x0be7f84,0x1fee593,0x05d41b0,
  43956. 0x1cddb1a,0x0a1c0a3,0x18cbbd9,0x1382150,0x01e4c63,0x1647095,
  43957. 0x00dd1e8,0x155f56c,0x10cd0a4,0x052b86f,0x065713c },
  43958. { 0x0b77b9a,0x05474e7,0x11a7733,0x0e476d2,0x0f97e72,0x0eb5941,
  43959. 0x0fb9a80,0x1fd8ed5,0x15abecd,0x092901e,0x0435c0e,0x0104525,
  43960. 0x1889448,0x1818a21,0x04c5092,0x08f87f3,0x1f17cd4,0x182104e,
  43961. 0x0157209,0x1e40b39,0x00697c6,0x112b607,0x165f5e1,0x05b2989,
  43962. 0x1b6fe41,0x0eead4e,0x0665310,0x134c8b2,0x1e21a31,0x0550e44,
  43963. 0x03848d2,0x18d407e,0x0904b50,0x17f566b,0x055a985,0x16ab82a,
  43964. 0x1cc7693,0x1b68dab,0x0f0e138,0x0d8775c,0x06b0e99 } },
  43965. /* 21 */
  43966. { { 0x0eced00,0x04fd5e6,0x0998c9e,0x15cb6f5,0x1237e71,0x0f5e6f9,
  43967. 0x189a4b7,0x11f0f65,0x0b61dad,0x1922890,0x1e00f2d,0x1c91a6b,
  43968. 0x0de11e5,0x0c72878,0x137d75e,0x15725f6,0x0b4bcd2,0x0b07734,
  43969. 0x138cd8f,0x165eb83,0x064798a,0x0d3e6a1,0x056e8e7,0x1e9f67e,
  43970. 0x172eb83,0x06d8d32,0x0395bc2,0x1eefbd1,0x0562c20,0x1b0f0b9,
  43971. 0x1d05d0d,0x114b1e1,0x0349ff8,0x0eb715f,0x1c6e134,0x09c09b4,
  43972. 0x1e9ff3b,0x0781a14,0x08fe0da,0x00acf04,0x04022a2 },
  43973. { 0x1847375,0x1de82c1,0x0bc149e,0x047e8a3,0x1ae56b6,0x163f8c1,
  43974. 0x1c9352c,0x11ac331,0x14525b9,0x1191fad,0x0212d7b,0x07341c1,
  43975. 0x16a9d8d,0x1d8963b,0x0175fdb,0x182a9a0,0x03e708b,0x06b8e24,
  43976. 0x109506f,0x0dfa50e,0x1ddb8ca,0x06fc1cb,0x02bcf73,0x199e486,
  43977. 0x131253e,0x1c6dc06,0x0163606,0x0e87421,0x191f68c,0x1590b89,
  43978. 0x1fcfd23,0x06776ca,0x13aff88,0x03f18a4,0x15981f9,0x0c3a2bd,
  43979. 0x008279f,0x0acd88f,0x0a55840,0x196494d,0x0312179 } },
  43980. /* 22 */
  43981. { { 0x1615ac2,0x061e503,0x1606a53,0x082435a,0x05865e6,0x0c35bcc,
  43982. 0x185be9e,0x03b5c8e,0x19d5e0f,0x0ad2075,0x115fa8e,0x04c87b2,
  43983. 0x19a9143,0x1d1432e,0x19b5a8f,0x15d191b,0x1961014,0x183b8ed,
  43984. 0x1daa1f2,0x0f99cd2,0x0f6077a,0x108a1d0,0x09f790b,0x127b269,
  43985. 0x1cc09d9,0x01ef101,0x0e63b13,0x04030d2,0x05df4b9,0x036c1d1,
  43986. 0x1af5dd5,0x0c5605a,0x0d9eb47,0x138c485,0x0823416,0x17f555e,
  43987. 0x031221b,0x1c0c0fa,0x047a948,0x0f0e66a,0x0417d6c },
  43988. { 0x091e9a8,0x0c0db87,0x1accf2f,0x1186e1a,0x1334041,0x1511b9b,
  43989. 0x0c42a3a,0x0ad04bb,0x06c7d67,0x19584f2,0x0cf7b63,0x1d37298,
  43990. 0x1be288e,0x0b4af1f,0x0109aec,0x1d1119b,0x086dce9,0x1530bb6,
  43991. 0x05978d8,0x191244c,0x1b093f4,0x0fb031f,0x1453904,0x1f3c098,
  43992. 0x1ac20c8,0x0b0b483,0x137f4ab,0x1dee8d3,0x12199ac,0x1d72422,
  43993. 0x18ae8c2,0x0255868,0x0681293,0x0a41698,0x01cf24b,0x0a0237d,
  43994. 0x0833099,0x065fc4f,0x0282bfd,0x0a5a28e,0x002189d } },
  43995. /* 23 */
  43996. { { 0x0599c69,0x00ceec9,0x0b29cf9,0x16ffd86,0x1b94221,0x1dfdfea,
  43997. 0x06f4826,0x0b7657f,0x063ed89,0x0f54bd2,0x01bde58,0x08d67e9,
  43998. 0x1966091,0x1e8a0d1,0x071e817,0x0826b7a,0x0cf83d6,0x1e3cf64,
  43999. 0x020d41e,0x1fa85f3,0x10277f8,0x1b8bd9e,0x0bf2d4e,0x194b443,
  44000. 0x18dcd67,0x1c34332,0x1334525,0x0d4d815,0x195067a,0x0b871a5,
  44001. 0x0305bcf,0x1be892b,0x11208e3,0x001091b,0x139bb0a,0x03a5bac,
  44002. 0x10782c7,0x1962559,0x1dbe8ce,0x17aa422,0x07bbf8a },
  44003. { 0x18b981a,0x12557d3,0x00a2fa7,0x0c609d9,0x188b4e3,0x0cef51b,
  44004. 0x13ce4e5,0x18e188b,0x1240b39,0x054dee9,0x00edf5c,0x0fba507,
  44005. 0x06499cd,0x183d081,0x1a42cb8,0x1e36660,0x198ee92,0x011316a,
  44006. 0x11c9692,0x1aefbd6,0x0a0ec62,0x1e3de1d,0x085bc96,0x0bdeff5,
  44007. 0x18b65d1,0x147b16e,0x142e5b5,0x12f2443,0x0f1906d,0x02e1d00,
  44008. 0x102e4a2,0x1d6e98e,0x0476b9b,0x1b1117d,0x0ed71d5,0x1e42fbb,
  44009. 0x1788504,0x1c16182,0x1c5af09,0x0d9f024,0x0860d09 } },
  44010. /* 24 */
  44011. { { 0x179bbf9,0x019bea6,0x1e03faf,0x10d3ee9,0x1d53eab,0x0826a9a,
  44012. 0x08254cc,0x12ffe6d,0x0196f8b,0x15c106d,0x19a424a,0x1a3eeb9,
  44013. 0x14961d3,0x02341ba,0x05fb010,0x1973763,0x1bf93a6,0x1d34670,
  44014. 0x17c0868,0x08adff8,0x1fdb503,0x18c4a07,0x0d428b6,0x0008413,
  44015. 0x10f8fef,0x03abbe2,0x1c12596,0x0c6ba2e,0x18770ad,0x136cc5d,
  44016. 0x0f9c95d,0x140f1ca,0x019b028,0x041bc47,0x132be7f,0x006c9a9,
  44017. 0x10dd39a,0x1efa08f,0x1e48068,0x084075b,0x07e80e4 },
  44018. { 0x19a1ddf,0x1c52ba9,0x15892d7,0x1ddc90c,0x1248e7a,0x1010f0e,
  44019. 0x1247605,0x18838f6,0x1fd36d2,0x13dc38d,0x100364b,0x0a0815d,
  44020. 0x13da38b,0x10c9f8d,0x009d849,0x0f1ade5,0x086fb1f,0x1b4e1ff,
  44021. 0x009eb0c,0x116f0dd,0x08f756c,0x039a43e,0x05a1fdb,0x1bdcb78,
  44022. 0x1221719,0x00c55c7,0x1ffce65,0x09d08e7,0x027c800,0x000a548,
  44023. 0x0a3ce13,0x1543a5c,0x167be9a,0x0f778cc,0x1b4f819,0x190d2d0,
  44024. 0x07bd837,0x1e35846,0x1618dcd,0x1a33d17,0x05dcab5 } },
  44025. /* 25 */
  44026. { { 0x07d772b,0x0141d4d,0x166c1e1,0x0bca812,0x0b49e52,0x00a55ab,
  44027. 0x0c02219,0x152a8d7,0x09d74b2,0x02240b1,0x0c2c6f5,0x015a407,
  44028. 0x0b26789,0x0469fc3,0x1ea0af3,0x1078e3c,0x1b5d85a,0x189a95f,
  44029. 0x0b41f33,0x1e2dc7f,0x043ff29,0x1c20f06,0x100a98e,0x06f3fdf,
  44030. 0x122c56b,0x1934827,0x0ec4913,0x13b14ca,0x08bdea1,0x1b6f9d1,
  44031. 0x13998d6,0x1eda8ab,0x0b68851,0x19b9a8c,0x006273f,0x16e9585,
  44032. 0x0b2cbda,0x007cefc,0x15262b5,0x13d5b93,0x008cc2d },
  44033. { 0x170c84b,0x1343360,0x1210b9a,0x16b4934,0x1b989e8,0x0644c95,
  44034. 0x0038341,0x046f61c,0x061b3a4,0x0d69a3c,0x0062655,0x08a161a,
  44035. 0x133c952,0x1188065,0x0488557,0x0eda1c7,0x16ef032,0x18c932d,
  44036. 0x1b50ad4,0x10b2b4e,0x13b60fe,0x107e31a,0x02a5b7b,0x0df127c,
  44037. 0x00dc824,0x05d3b0f,0x1bc29d3,0x1d92057,0x1fad9b4,0x03421fe,
  44038. 0x1d58402,0x09fb6d2,0x16a60e4,0x1ac852e,0x0b21fbd,0x0e7ea75,
  44039. 0x12870a3,0x0f35f00,0x156c34a,0x182ab54,0x0991fad } },
  44040. /* 26 */
  44041. { { 0x0844ffe,0x02587da,0x01c60af,0x08c1f17,0x1392271,0x11f8f9b,
  44042. 0x0038933,0x1d91580,0x0163519,0x06aa45a,0x022d7fc,0x0857105,
  44043. 0x107aaf8,0x15ee4d3,0x02c3130,0x1facf3d,0x1524ba5,0x1d036a8,
  44044. 0x04f37b0,0x035f41f,0x18f0d0b,0x1d6fc4f,0x0a02556,0x1465924,
  44045. 0x1e92dee,0x1f24365,0x04ff816,0x195c7f3,0x0919aa0,0x184afd3,
  44046. 0x02fc981,0x0dc1e37,0x154741e,0x07cc407,0x1dd0c3b,0x0e55da3,
  44047. 0x134991d,0x0b7bb5b,0x03fa64a,0x0504b3e,0x066cf8d },
  44048. { 0x06f5868,0x0c82d91,0x1a7a6c0,0x182d213,0x0102e88,0x1bf5aa6,
  44049. 0x0245928,0x04657a1,0x0c98163,0x19129f4,0x0b14f3d,0x1d3b0d7,
  44050. 0x1737f84,0x17f5557,0x0d49152,0x008dc5c,0x1772ca0,0x133e437,
  44051. 0x198cdcb,0x19ca1cc,0x0a0486b,0x105b4a8,0x1da8ea5,0x0357527,
  44052. 0x194d7fc,0x13730fc,0x0f04c9b,0x12af825,0x16b0051,0x07f2172,
  44053. 0x0326d96,0x10b24e8,0x0d297fc,0x19352ce,0x1a6c5df,0x16eca99,
  44054. 0x079d2eb,0x134cedd,0x19122aa,0x0b41d96,0x05fca0c } },
  44055. /* 27 */
  44056. { { 0x09a6663,0x112f9ab,0x129f89b,0x0fcd549,0x09597ee,0x0c5c060,
  44057. 0x1369a34,0x0604b49,0x1229267,0x083015a,0x01c8251,0x0ca00e7,
  44058. 0x139af5f,0x13399d2,0x1bb6cd0,0x052a3fd,0x1688657,0x107ae73,
  44059. 0x0e62ba6,0x146c170,0x16c3872,0x0015987,0x180d1ea,0x02c42b0,
  44060. 0x13b231a,0x0f66908,0x0bb9b1b,0x1fb39f2,0x1cf9e66,0x12d42e5,
  44061. 0x01217c2,0x05747fd,0x1a5a6e4,0x06b93eb,0x1c8147b,0x0155fcc,
  44062. 0x02081a1,0x0e35d95,0x0c2d382,0x1e172e7,0x0657acb },
  44063. { 0x074c8d4,0x02337e1,0x1344c4c,0x0c61532,0x0276517,0x1ca1afa,
  44064. 0x16329c1,0x00c42e4,0x0eb897a,0x0428203,0x1b84c11,0x1ddcac3,
  44065. 0x1bf38df,0x150bbc5,0x1d3eb3e,0x173d223,0x017b9ab,0x13b2e33,
  44066. 0x03c424c,0x0a9337b,0x1159b13,0x1bd39dc,0x103ad8c,0x0fd16d5,
  44067. 0x1ccf16f,0x1a9f960,0x0861f7b,0x1665807,0x0b9c625,0x0ea4c18,
  44068. 0x0e226b4,0x05e21ca,0x135eae3,0x1aade0b,0x070a757,0x1b6397b,
  44069. 0x0539db0,0x014623f,0x0ceed09,0x02590a5,0x03d2da4 } },
  44070. /* 28 */
  44071. { { 0x11f2865,0x015b743,0x035a5dc,0x1e28524,0x16cb639,0x1ac308a,
  44072. 0x08a8116,0x024650a,0x1f3b138,0x1ca1d68,0x081ba3c,0x0014e24,
  44073. 0x0ae6c22,0x11a6acf,0x024396a,0x1eeb385,0x140f6b7,0x1d5a97e,
  44074. 0x002fd59,0x0591bc3,0x0396f52,0x1956677,0x0607a5e,0x1d4b976,
  44075. 0x15819c4,0x1f7f01b,0x02ad474,0x1b330bd,0x150fd80,0x0b655e5,
  44076. 0x03789b2,0x12fc390,0x19d6b13,0x11abefd,0x0053de5,0x16b0563,
  44077. 0x07f4c7f,0x13c1108,0x1f98626,0x05b806a,0x002aeef },
  44078. { 0x07ec9be,0x1c93796,0x0804ae9,0x1ce4b16,0x092f307,0x1d35a51,
  44079. 0x0a8431b,0x156e9cc,0x1e2bcc5,0x06042a4,0x0301ce0,0x1b70f77,
  44080. 0x0db4160,0x194f8ca,0x1bc14a4,0x09539ab,0x0146dda,0x0875c6d,
  44081. 0x17a88f4,0x1a87a42,0x1fae0b5,0x017e1a5,0x1b3afbc,0x10eaf4e,
  44082. 0x164d084,0x051d669,0x00b4d33,0x028026d,0x0d95e2c,0x13a10e9,
  44083. 0x0a02729,0x0f0dd54,0x1fd1d6e,0x12ff661,0x0db68a5,0x073d622,
  44084. 0x0077920,0x038dd56,0x0bac122,0x002962b,0x06b446c } },
  44085. /* 29 */
  44086. { { 0x1e8fe80,0x0f59712,0x085f206,0x0d30471,0x0b5f790,0x120c249,
  44087. 0x1a65a07,0x08bade3,0x098ea6d,0x056c56b,0x00b9016,0x15a97fa,
  44088. 0x0d5bae5,0x140920b,0x1b70c9e,0x0f94202,0x185a334,0x0c598d4,
  44089. 0x0a994e4,0x1b4c210,0x15fb0b4,0x16da461,0x072e46c,0x155f188,
  44090. 0x0817cd2,0x0e04f4b,0x0f37f73,0x14c6090,0x1692541,0x09b0895,
  44091. 0x05dc156,0x1f14541,0x1dcd712,0x02940af,0x08e8d73,0x0ab356c,
  44092. 0x132b609,0x0475f04,0x014bcc3,0x097611c,0x0861342 },
  44093. { 0x0231d8a,0x01031d9,0x199ca24,0x13b34c2,0x10f6232,0x0d4f93d,
  44094. 0x03f9c1c,0x0fd55f4,0x0603f04,0x1e6c4b0,0x0a870da,0x14edfb2,
  44095. 0x16118cc,0x18ea41d,0x05398ad,0x0a4c468,0x0ddba70,0x15091e6,
  44096. 0x166d716,0x0ec86ff,0x0fa31a5,0x0126468,0x094c06f,0x0484f9b,
  44097. 0x0ad4410,0x0014b78,0x034ea9b,0x1cdf6bc,0x0a39960,0x0440039,
  44098. 0x0b73631,0x1081a7f,0x1afca12,0x0eaa0a6,0x08f77a4,0x1a53e99,
  44099. 0x0441734,0x1be2cc4,0x195f000,0x133399f,0x086333a } },
  44100. /* 30 */
  44101. { { 0x0f53b40,0x1d3a8f6,0x150b484,0x045ef14,0x0ff2c6f,0x1d72b6e,
  44102. 0x1c38bc4,0x11c1eb3,0x10e6174,0x0fc665f,0x1105164,0x1973ae5,
  44103. 0x170aade,0x064e6e5,0x0bb6149,0x1f8e0d6,0x12c1eaf,0x147005b,
  44104. 0x09ca040,0x04850b5,0x0afa89b,0x105b3ce,0x0a9fa9f,0x014dedf,
  44105. 0x18c264f,0x1cbae95,0x0c3a010,0x1daf62e,0x1730497,0x15a2e42,
  44106. 0x0f96a4f,0x0130dd2,0x12bf5d4,0x06057e4,0x0a71a88,0x1ea4d6b,
  44107. 0x199dc3a,0x0fa3e4d,0x0b3242b,0x1c57440,0x012b25f },
  44108. { 0x1eea395,0x06bc519,0x117026e,0x11ec67f,0x07a9361,0x076777e,
  44109. 0x058a49c,0x018fd04,0x0c628ed,0x123bcdc,0x1a24e54,0x194343a,
  44110. 0x1091db5,0x0c376e4,0x09b8639,0x1e77f0c,0x08bfeb3,0x07f011f,
  44111. 0x09405c7,0x13fbc20,0x12de627,0x0e2af0b,0x194bb1f,0x1a9948b,
  44112. 0x08695c6,0x078a22f,0x02f6f04,0x05bc70f,0x03835e4,0x06f437e,
  44113. 0x148ac45,0x0fc216c,0x1aba456,0x13c7f4f,0x00a8e43,0x148223b,
  44114. 0x0edf0ac,0x15b0e15,0x12dd15d,0x152e959,0x0216279 } },
  44115. /* 31 */
  44116. { { 0x047f747,0x06d5fa0,0x087b053,0x1b8262b,0x03ca233,0x12e8538,
  44117. 0x12f4d03,0x0d2b3cf,0x1bb4138,0x1e86274,0x07ef607,0x11621e0,
  44118. 0x1d189d0,0x13b5c11,0x112710a,0x00142a0,0x0a1398b,0x040e112,
  44119. 0x1a05e79,0x109c9f1,0x01e9080,0x0a34c72,0x1f62be6,0x0217e5d,
  44120. 0x0e37c56,0x0878f18,0x1e9f49e,0x1cd4087,0x1953884,0x1306598,
  44121. 0x1f6765b,0x006f33b,0x15f986d,0x1c817f3,0x1c47e3f,0x1c76951,
  44122. 0x1588416,0x0a29bc3,0x14d7bea,0x07f304e,0x020683e },
  44123. { 0x0378878,0x0171368,0x1e1f2d6,0x074f28a,0x1e214c2,0x134459c,
  44124. 0x002fe3d,0x0e027a0,0x1405152,0x0a46a7a,0x047d75d,0x02ba802,
  44125. 0x027113c,0x145ffc8,0x1d6949a,0x08b9877,0x0109b49,0x0ded358,
  44126. 0x10bce81,0x198e9d7,0x1fa183d,0x0221f7e,0x0abbd8a,0x0b8b7e8,
  44127. 0x00ee956,0x01d6973,0x1564bc9,0x1e1f421,0x03bf514,0x05990de,
  44128. 0x1d1ab96,0x0c0aed4,0x13b0868,0x1840d40,0x0fe135c,0x1217804,
  44129. 0x12dcee5,0x081d501,0x11e567f,0x1ea4fad,0x05e416b } },
  44130. /* 32 */
  44131. { { 0x06cc23c,0x09bb001,0x016090c,0x1d6b652,0x1819aae,0x09770bf,
  44132. 0x1cbe317,0x0055244,0x1ee5cc4,0x02473e5,0x1bc1f60,0x0ddcefb,
  44133. 0x1edbc7d,0x1b57c10,0x15a4913,0x17712c3,0x0ed996c,0x02fbcb3,
  44134. 0x1a85569,0x162fd52,0x0d56f81,0x1801f9f,0x0cb67bd,0x1054b65,
  44135. 0x05906e8,0x0c02f37,0x0aba51c,0x0df420e,0x0c76f48,0x1e28b2c,
  44136. 0x080d367,0x19606b5,0x1603dc0,0x13240cf,0x1fadd6f,0x1f6f673,
  44137. 0x0f04a9e,0x03aaa56,0x1f78f2a,0x1d90f69,0x04ff682 },
  44138. { 0x0a10ad5,0x0b13fe8,0x1d14c49,0x052d1cd,0x1fd45c7,0x1508b1b,
  44139. 0x0f5ae01,0x1c65303,0x1de5033,0x096f0e6,0x1e2622e,0x08bd7e9,
  44140. 0x1c3b44b,0x0d73f0e,0x06e625b,0x1b0f194,0x05a0778,0x1a90b37,
  44141. 0x1445a11,0x08e57d4,0x144582d,0x157944a,0x1ef74e0,0x0dd8993,
  44142. 0x116025d,0x1811176,0x12d954a,0x0c29d63,0x06210f3,0x0fb9d0f,
  44143. 0x09d8f17,0x00434e9,0x1160285,0x05ea6f4,0x1003197,0x1348994,
  44144. 0x0f15e29,0x058c3f0,0x141f123,0x11c6804,0x051eb81 } },
  44145. /* 33 */
  44146. { { 0x12100ab,0x0e8bc5c,0x00e47f0,0x012c0b7,0x1f2e3d6,0x0f2ce86,
  44147. 0x10956dc,0x008254f,0x114fcbe,0x1c5b33a,0x141abcf,0x126ab3f,
  44148. 0x070e8a3,0x0901068,0x0c99408,0x0f7caac,0x0d1528e,0x0334b7e,
  44149. 0x11edd95,0x10a2961,0x05b5658,0x062c895,0x033603e,0x04996fe,
  44150. 0x1ef04f3,0x0bac5d7,0x1f1b68f,0x16a7dd9,0x11df2f6,0x046c18e,
  44151. 0x1b7b7bd,0x0e70256,0x136b965,0x13018f9,0x192bb98,0x17905d5,
  44152. 0x1244f09,0x055e996,0x191fcc0,0x0aa63b2,0x08b0af9 },
  44153. { 0x0603544,0x00c0517,0x167addc,0x0644359,0x0b573ac,0x0038191,
  44154. 0x1d99589,0x07a742f,0x1b89abc,0x09f3a56,0x0c896ab,0x1c75af2,
  44155. 0x0b8a3d2,0x17812b2,0x1eee813,0x1a56a8a,0x12ffc2d,0x0443ab2,
  44156. 0x19c50fa,0x00ba2bc,0x0d70d29,0x0101724,0x1b6212d,0x0c6d4ae,
  44157. 0x19219c7,0x06f837c,0x04d78de,0x11b8684,0x064a02a,0x0b9e886,
  44158. 0x19a5707,0x1982af4,0x16a4ece,0x051aa66,0x0722389,0x1b75b98,
  44159. 0x1839329,0x1278d94,0x02b4200,0x0929b49,0x05363e5 } },
  44160. /* 34 */
  44161. { { 0x03fc641,0x091dbf1,0x018c7d5,0x1f0ccce,0x1e54e72,0x004e97f,
  44162. 0x057d638,0x1c25294,0x18c57f5,0x101ccbf,0x159373c,0x049962d,
  44163. 0x1ba2297,0x05d517f,0x1ef93f5,0x11dacd2,0x0460a6e,0x11fa83f,
  44164. 0x014214d,0x1c74baf,0x02080af,0x0ecaa04,0x1bbbdb3,0x18846f9,
  44165. 0x1d889f2,0x129b80f,0x0970e14,0x12db107,0x0212f14,0x13f6b95,
  44166. 0x1378971,0x03fef1f,0x1416783,0x1a0a325,0x001305b,0x0fd32ce,
  44167. 0x045b069,0x02e1d0e,0x0c30fe9,0x0307f7a,0x0633340 },
  44168. { 0x0fbbbce,0x0d06651,0x1d10e72,0x1954196,0x076f6e5,0x1c7671c,
  44169. 0x00438d0,0x10539cc,0x013802d,0x1568a47,0x11686c2,0x18c139a,
  44170. 0x009c3e5,0x1de7e0f,0x172e165,0x09ba10e,0x190d858,0x1d8cffb,
  44171. 0x0070a8a,0x11703db,0x07e3259,0x17815f0,0x0462f7c,0x0ecb9d2,
  44172. 0x1c8eeb9,0x0d703a7,0x02c93e5,0x04bd3b1,0x18f09d1,0x166e064,
  44173. 0x09ceec4,0x1416e96,0x06aee07,0x03be725,0x0be7020,0x1e8e47a,
  44174. 0x1ea8026,0x0a23eb5,0x02dce56,0x0b82c50,0x093a707 } },
  44175. /* 35 */
  44176. { { 0x15b27f9,0x1f7f138,0x048c9ae,0x0454501,0x0935a5e,0x0c51355,
  44177. 0x08ebff5,0x128bbbe,0x07c1386,0x0641f0b,0x08854d5,0x1793125,
  44178. 0x1544799,0x0dc684f,0x1b91c42,0x1d4d09c,0x016d588,0x1631d7b,
  44179. 0x00eac6d,0x12ce0d1,0x13365e8,0x101e904,0x0f04e4e,0x1847bb4,
  44180. 0x1292192,0x121e817,0x0b73dba,0x16e196f,0x1559e1a,0x07543c8,
  44181. 0x02c490d,0x0dae1fe,0x00680db,0x15d2282,0x1948a0c,0x1e3421f,
  44182. 0x05f0cb8,0x0fce047,0x107f75a,0x1588962,0x01a7422 },
  44183. { 0x140b675,0x0ee974f,0x1ce70ea,0x07f98e3,0x0a7c660,0x0471a11,
  44184. 0x0698465,0x1083127,0x0ed0ab4,0x19db0ac,0x0729ae3,0x1b2fdc6,
  44185. 0x03a3aa7,0x1bd46db,0x07a197b,0x0c5c978,0x0092c7c,0x198afc6,
  44186. 0x1d71b43,0x00f11f3,0x1ec5a26,0x14a5b79,0x0c60cc4,0x169b093,
  44187. 0x1bcd636,0x14db9d6,0x02f1a66,0x0dc2912,0x1175e76,0x086c150,
  44188. 0x13efcde,0x1f8a794,0x143605a,0x1b048bf,0x111e1ff,0x0caefed,
  44189. 0x000c82b,0x1e3aa93,0x1667209,0x0613a4a,0x00944d6 } },
  44190. /* 36 */
  44191. { { 0x0ab9620,0x15b1f73,0x00233f7,0x1af0d9b,0x1ff4fa6,0x119059e,
  44192. 0x1760915,0x02a28bd,0x0c49439,0x172fc31,0x0cfe1ca,0x10276e7,
  44193. 0x099508e,0x1297cbd,0x16017cf,0x136c477,0x028c982,0x07b8dae,
  44194. 0x1b833bf,0x098e1d0,0x136eb39,0x1491ded,0x14d3ec6,0x1c4fcb4,
  44195. 0x15862db,0x0b4eb27,0x0e0ead8,0x15c47be,0x0828cbb,0x18d893e,
  44196. 0x02b75b7,0x07460f5,0x101899f,0x0efb30c,0x1966047,0x0e6d990,
  44197. 0x19943b7,0x05bbba3,0x195da8f,0x106dfb0,0x07d89f3 },
  44198. { 0x1f92b2b,0x1212164,0x0af7e15,0x0b88dc6,0x100c6a7,0x0cd2e2b,
  44199. 0x1a2ddfe,0x0d127ce,0x0031495,0x177f42c,0x199c26d,0x1433859,
  44200. 0x13bbfe8,0x1737624,0x068ec6f,0x1851ae4,0x0a9c371,0x0937777,
  44201. 0x145df87,0x1022bc2,0x05a5d79,0x0758345,0x15efcef,0x1a56965,
  44202. 0x1a22046,0x0fe6fc6,0x0d66fa7,0x1be132b,0x040b793,0x0bde3bb,
  44203. 0x11725a2,0x0b457a7,0x00cf4c2,0x1f3a267,0x15ba26b,0x162de8b,
  44204. 0x1a8509b,0x1f9d659,0x09b9ad4,0x03ec7e5,0x0449af8 } },
  44205. /* 37 */
  44206. { { 0x16d9377,0x0789950,0x1e7b0bf,0x06fc345,0x1ab377b,0x08cd72c,
  44207. 0x084ba1b,0x162e5c3,0x0d013bb,0x1589733,0x1d9aeb4,0x00ab96b,
  44208. 0x100972e,0x1ccf55a,0x0778700,0x0bd85a2,0x0fdc65f,0x1e0f98a,
  44209. 0x0a7fd64,0x0230831,0x06e6fc3,0x1670292,0x17dcf07,0x04a0adb,
  44210. 0x1136316,0x10ce146,0x1dbec97,0x0153b7a,0x1cd2d73,0x0922422,
  44211. 0x0b4127b,0x1a6dd0a,0x179b83f,0x04541e3,0x1f1fda3,0x070b46b,
  44212. 0x095e803,0x0df8f0e,0x06bd4a6,0x1864112,0x00e8617 },
  44213. { 0x1c81b5c,0x1030133,0x1cf14dc,0x1bce6f0,0x0fa89dc,0x0a27e81,
  44214. 0x0c2c2a0,0x10654e8,0x126208c,0x00362d3,0x0903d4c,0x0cc1b1d,
  44215. 0x044e066,0x04b209d,0x14097e6,0x0293f3b,0x0cc46b9,0x15ef9c0,
  44216. 0x0849730,0x0acc321,0x1c37801,0x1ba93c9,0x0135a8e,0x0f4c5e4,
  44217. 0x013746b,0x0bc5b00,0x0161756,0x139fc4d,0x15fe66a,0x065c41c,
  44218. 0x1db72b4,0x08d64c3,0x0b468fc,0x0c90c5d,0x17be767,0x05941de,
  44219. 0x1e45240,0x03ea542,0x1da1f14,0x1e264d9,0x06f4404 } },
  44220. /* 38 */
  44221. { { 0x1ebd3ff,0x0c905a7,0x0eea8f8,0x11fbfa5,0x0a6234d,0x0d4c14e,
  44222. 0x0bcab86,0x0416fa3,0x0c6f5bc,0x1ef0b08,0x0e72a48,0x17e7b54,
  44223. 0x0be204d,0x16c6385,0x0b7a6e1,0x06e1654,0x0377c9d,0x1139706,
  44224. 0x1595443,0x02980dc,0x16b0809,0x142be5d,0x0d8479e,0x04cd4dd,
  44225. 0x1c6efd8,0x00e03b7,0x18c2560,0x1f5869d,0x024063d,0x00515cf,
  44226. 0x115a7fd,0x0f0f54b,0x1ba31a9,0x1866953,0x1f7ccf1,0x081c9a3,
  44227. 0x0895f07,0x1f18993,0x1c78a40,0x1f0ff6c,0x0905771 },
  44228. { 0x0062bee,0x0dd06d2,0x07e5466,0x1929afb,0x18e7238,0x0491600,
  44229. 0x0a6f078,0x0bfea7e,0x1b12d85,0x14d9540,0x0328a77,0x1ddadad,
  44230. 0x1f649f3,0x028604b,0x0b7f0d3,0x13140c9,0x0b99db3,0x040cb25,
  44231. 0x0961c89,0x0b388ef,0x103a00d,0x0b3a62c,0x027fa8e,0x0087ba0,
  44232. 0x1d8ee15,0x0103557,0x197c7b3,0x0ae434d,0x19b7b4c,0x124186d,
  44233. 0x0aadb5a,0x0cd91aa,0x0ffc617,0x0151383,0x075ab32,0x107bc48,
  44234. 0x07f2f7a,0x02f8291,0x17b3018,0x076c809,0x06a2295 } },
  44235. /* 39 */
  44236. { { 0x0fce389,0x096c7ba,0x1592491,0x0055f4a,0x059634c,0x16bc128,
  44237. 0x132efc3,0x01b26ef,0x137718e,0x0fa022d,0x1a69362,0x1cfb3f4,
  44238. 0x1a11074,0x194ad85,0x1c2ec1d,0x1dbccba,0x0adf107,0x1d916aa,
  44239. 0x068a71e,0x1347b14,0x03ab5c3,0x016bcaf,0x0dc8db0,0x0b132a2,
  44240. 0x02d002b,0x1717b94,0x195e42f,0x1c44cb7,0x065ea25,0x1508d47,
  44241. 0x0f64783,0x0c0039d,0x071a708,0x02a0107,0x1d68b07,0x022d201,
  44242. 0x157f698,0x196ae01,0x0d09f0e,0x140c33c,0x0528c9e },
  44243. { 0x126c577,0x0435a2f,0x15147b7,0x1128717,0x1807470,0x12c153f,
  44244. 0x0404de4,0x13e5bfc,0x0de1e56,0x0475650,0x168d5b8,0x1df534a,
  44245. 0x165f952,0x124bb10,0x1602d4f,0x0e3e549,0x055cd5d,0x0695b2c,
  44246. 0x1b3a8fc,0x0e097ec,0x03ca246,0x0fa4919,0x064fd90,0x1b6264a,
  44247. 0x1855c9a,0x1295340,0x18b4675,0x0daa459,0x02ed7b8,0x0f882dc,
  44248. 0x0a54d82,0x11c2a1a,0x10f0094,0x1f4489d,0x0fec2c4,0x12475b1,
  44249. 0x1794b44,0x18aab67,0x13d5f2e,0x126e717,0x0200f90 } },
  44250. /* 40 */
  44251. { { 0x188387f,0x117e2c1,0x0f17e6c,0x0051d10,0x0f26f17,0x1bcb9e6,
  44252. 0x0ae4346,0x0e288f9,0x0f6ec91,0x0aea751,0x136f023,0x0931861,
  44253. 0x0b2e16f,0x04311e1,0x04a4431,0x18a8bb9,0x1b030db,0x0758a48,
  44254. 0x137886c,0x1bd65c2,0x10f4631,0x1317f41,0x0128841,0x1383e7e,
  44255. 0x0979c37,0x1cad263,0x03ec1a9,0x14e656d,0x19dfa98,0x193d0b0,
  44256. 0x06ce910,0x11b7c59,0x1a307d3,0x04ff548,0x03480e6,0x1f27379,
  44257. 0x0f4a331,0x155d790,0x15770f6,0x131ba1e,0x05c307e },
  44258. { 0x1b233da,0x070621a,0x0616ef1,0x0a45edf,0x03d2908,0x1812347,
  44259. 0x0b486a2,0x1cf33ba,0x1a96916,0x1c7a074,0x0f33b65,0x10d8c29,
  44260. 0x0c0327d,0x19483b1,0x1a5540a,0x1e5db2b,0x197a879,0x187fe90,
  44261. 0x0382f4c,0x0ca26ea,0x04c4c43,0x050413e,0x09b0c52,0x19f8164,
  44262. 0x012a83f,0x0c4e3cc,0x18c64a1,0x07b1a2f,0x10f42dc,0x167f441,
  44263. 0x0fe2d5c,0x0960ff0,0x0d9ff92,0x08a47be,0x0540294,0x1866395,
  44264. 0x0c59f9a,0x029cb42,0x11e1743,0x1f58286,0x01df16d } },
  44265. /* 41 */
  44266. { { 0x0bcacc3,0x1da5634,0x033f31e,0x1e861eb,0x06ded34,0x10c2ad0,
  44267. 0x07d3f51,0x1798b3f,0x045c9f0,0x0a48cca,0x17224bd,0x1d8c86e,
  44268. 0x1adc5f7,0x1e42cc1,0x01c23c4,0x1a10e37,0x0c482fc,0x1d9952e,
  44269. 0x15ad303,0x19b86a5,0x1b2defd,0x0245637,0x12ec93c,0x120c8e2,
  44270. 0x0d4f533,0x1622cc1,0x1ee0e8e,0x0c5d6a5,0x17a2231,0x0f94119,
  44271. 0x14dc4c3,0x19787b7,0x0e7b802,0x1d6076e,0x0564919,0x1d1672b,
  44272. 0x1b56717,0x09e9740,0x0985c87,0x0a08ca2,0x0729a7f },
  44273. { 0x020f90a,0x168d542,0x01561d3,0x1c1fc99,0x0368e19,0x1f3a57b,
  44274. 0x12aaac2,0x1536c5a,0x08ca60c,0x17e6240,0x16a19dd,0x0b4aec8,
  44275. 0x0cf310b,0x0ed8d92,0x06eb26f,0x0b68826,0x11d2dea,0x177bbeb,
  44276. 0x0bf3193,0x0da420e,0x17f0470,0x08b39eb,0x0a6e49a,0x13c0cc6,
  44277. 0x00bf3e8,0x0a01170,0x0dd01df,0x0e5a19a,0x1232e24,0x0206c14,
  44278. 0x0ccf884,0x071b90a,0x1916dfb,0x07b3397,0x166c52e,0x1a91776,
  44279. 0x144be19,0x0f4fa56,0x0757067,0x092465b,0x07f6d36 } },
  44280. /* 42 */
  44281. { { 0x0794819,0x0326f37,0x1684ef4,0x1df05d7,0x1a6b694,0x0f14022,
  44282. 0x1ff82e4,0x1a43e02,0x107a43c,0x08698f9,0x10cfa46,0x044cc60,
  44283. 0x146c26f,0x055fee5,0x1222a9c,0x0238174,0x085a464,0x020c6c8,
  44284. 0x1fed620,0x069fcd7,0x18491b9,0x1bf1007,0x1d74788,0x0a827b6,
  44285. 0x0d63fa5,0x1bbef82,0x1788ecf,0x042ddae,0x11bd30e,0x136587c,
  44286. 0x0268161,0x0ee538a,0x0c395d9,0x1596bc2,0x062114a,0x0dd92fc,
  44287. 0x0093d68,0x1be0fc8,0x021b232,0x12ac51e,0x02d0323 },
  44288. { 0x044b4c5,0x04a03a5,0x1262a07,0x1398e05,0x1984687,0x186e4bd,
  44289. 0x08a1f3a,0x04396a0,0x06e3aa3,0x0180893,0x095b08c,0x0ec7c98,
  44290. 0x05c0ac8,0x12ada42,0x00d3483,0x1e6b6ca,0x040f240,0x0554b50,
  44291. 0x13dfbb7,0x1a4da6f,0x0656046,0x109dc08,0x18a96a3,0x1ae1856,
  44292. 0x04b9783,0x147c302,0x0167936,0x1f75ff1,0x17f5d12,0x080d2a2,
  44293. 0x15e4a76,0x16a636e,0x09e1eb2,0x14b9ce9,0x0f72793,0x12429b5,
  44294. 0x0eaa9bd,0x0b927e2,0x0ee6d6f,0x1663df3,0x0734c12 } },
  44295. /* 43 */
  44296. { { 0x0f9b086,0x11e1749,0x151263f,0x1d67fa8,0x0641b93,0x01632e2,
  44297. 0x0822d70,0x0848f9c,0x1c4f032,0x1296e50,0x14a7da2,0x0fb2cf3,
  44298. 0x14b5ec1,0x0a037af,0x14bfb42,0x1502223,0x1dc0d9b,0x19307b1,
  44299. 0x151ca8f,0x160ade2,0x10e6de2,0x0f80394,0x06c5c36,0x16b91f2,
  44300. 0x03e8db6,0x1f75171,0x073cd30,0x08b4507,0x173ee23,0x0a308dc,
  44301. 0x1166f71,0x17649a3,0x1bda6c2,0x0a0d0b2,0x0e8cf18,0x032faa5,
  44302. 0x1d2eb20,0x1d8b094,0x1927d1e,0x10e43f7,0x07c558a },
  44303. { 0x1350fec,0x02d291f,0x1302e52,0x0ad471a,0x016678c,0x0d53268,
  44304. 0x11a8835,0x1c91de6,0x0d96da2,0x02ed501,0x11ecf2e,0x09d49ec,
  44305. 0x0c845ec,0x06af4a3,0x1469b28,0x1e95781,0x1c14fa9,0x1a0ec68,
  44306. 0x122c4c0,0x0e598b3,0x1bfb439,0x06a1a7f,0x19f87d2,0x13a4630,
  44307. 0x0e93a81,0x11f9a86,0x01b77bc,0x13ea612,0x0cf12c4,0x167c900,
  44308. 0x1f0f0b9,0x0c80865,0x0691cc1,0x0b5a921,0x12d1c92,0x1d7ffee,
  44309. 0x020a97b,0x093e4f8,0x10d2111,0x194f678,0x034cd7d } },
  44310. /* 44 */
  44311. { { 0x1e7fe87,0x0bb0d2c,0x15cbc0c,0x14008f9,0x11eae31,0x1187b15,
  44312. 0x0b9a3eb,0x0864f20,0x1b71db1,0x1337a46,0x00e3d29,0x0cf01c0,
  44313. 0x0d75ee6,0x015eebb,0x116b19c,0x19ab876,0x028a0d6,0x08697dc,
  44314. 0x16316c4,0x1cfe3b3,0x1e9627c,0x120905a,0x0507f83,0x04cf86e,
  44315. 0x1b984b9,0x166cad0,0x07580c4,0x040dcb1,0x1493565,0x1a176d2,
  44316. 0x0b0619c,0x00e18e9,0x14520b9,0x1d8599b,0x0ed6555,0x084e079,
  44317. 0x06ed8c1,0x10face5,0x0e21fd8,0x18557ef,0x07ceb1c },
  44318. { 0x17fd65b,0x1d2dded,0x15f0191,0x006d928,0x18d45cc,0x0938c56,
  44319. 0x0676e78,0x1638db5,0x0e93a7f,0x08eddfa,0x159a87b,0x12b97a2,
  44320. 0x194512c,0x0de0648,0x186e803,0x0a4d290,0x0989e7f,0x11e3661,
  44321. 0x0506aab,0x12c2a01,0x18e3671,0x07e4629,0x0ff3d74,0x0b4aa3f,
  44322. 0x09929a2,0x19356b7,0x145f283,0x00e2130,0x09ef7e9,0x1c757d4,
  44323. 0x125d0ed,0x0e3568a,0x1d5ea31,0x0e1b69c,0x0fcf9b4,0x1ae885e,
  44324. 0x059d568,0x1341f00,0x1b57096,0x13244f9,0x01f629a } },
  44325. /* 45 */
  44326. { { 0x05a1c3e,0x0eed672,0x117e249,0x0a83eea,0x12d2936,0x13fc143,
  44327. 0x0bf2cdf,0x1a48ac4,0x13e4c79,0x011a289,0x19175a2,0x1f09384,
  44328. 0x195dffa,0x0ca4015,0x1e3d376,0x13f4060,0x1f09d33,0x02b3493,
  44329. 0x1f64773,0x00143d3,0x0bd79a5,0x0005585,0x1380206,0x129cbbf,
  44330. 0x135a381,0x0446cb8,0x1e62b7c,0x1d0ec60,0x05a2a79,0x00dc4d2,
  44331. 0x064eebc,0x0f11687,0x1ed6154,0x14cbeb7,0x1c8b9de,0x1b301ca,
  44332. 0x0a378ee,0x0487fd1,0x0168aab,0x14517b0,0x04a75fd },
  44333. { 0x1e74cbc,0x147ddaa,0x1c97426,0x1df5631,0x137738c,0x12761d3,
  44334. 0x0eb5a5d,0x0621f84,0x1e7e0ad,0x0d3e9ad,0x07326f1,0x0d1dc90,
  44335. 0x14e75e0,0x1ea5761,0x10baa64,0x0c789e1,0x1e80d4a,0x0789927,
  44336. 0x06c164b,0x16f82d3,0x146b5db,0x06d3f07,0x110b59d,0x001f5d4,
  44337. 0x166c7a3,0x041ad2e,0x04ccceb,0x107b904,0x008496e,0x0097462,
  44338. 0x105c3be,0x133debf,0x0e1dcb6,0x074314b,0x1c6c5cd,0x10dc56e,
  44339. 0x183507d,0x114e6e2,0x05e6811,0x15c47b0,0x05819f9 } },
  44340. /* 46 */
  44341. { { 0x0a78811,0x14890b5,0x1f0f665,0x084207c,0x164ee8f,0x1cf34c7,
  44342. 0x041c08a,0x1bdbbe0,0x04f582c,0x1000fcf,0x1eb06b9,0x115e5d9,
  44343. 0x0924a60,0x031c980,0x1d31e10,0x05222dd,0x0e6ebf7,0x0293175,
  44344. 0x113b968,0x1a15eb1,0x1bc7ddb,0x08766c3,0x01d6bfe,0x049e229,
  44345. 0x1b34c6f,0x0b917ee,0x07a197c,0x1020850,0x0c1b9a4,0x1213443,
  44346. 0x07e55a4,0x13de846,0x15f3208,0x1f41737,0x0b3f429,0x115eb0f,
  44347. 0x1ac395c,0x0b8c8bc,0x09d4359,0x07826c9,0x0745960 },
  44348. { 0x01ae519,0x03adffa,0x0944709,0x0295f1e,0x14401fb,0x1d961e9,
  44349. 0x1f34abb,0x010e1bb,0x151cdaf,0x1969c2d,0x02ec666,0x04ad041,
  44350. 0x168531c,0x0619f9f,0x12277d9,0x02ed22d,0x0992457,0x1611e7d,
  44351. 0x1b4042e,0x136a3d0,0x0313233,0x069131c,0x0236c3a,0x1fdbd6e,
  44352. 0x1e17900,0x178fbb4,0x0e8da1f,0x1fb2db9,0x0764753,0x1591c8a,
  44353. 0x1773411,0x0188b91,0x1ff2064,0x01ebc79,0x1ef6e0d,0x01dfa2c,
  44354. 0x0b77ee9,0x1e65b6a,0x1ed1524,0x027679e,0x0330255 } },
  44355. /* 47 */
  44356. { { 0x1eaaca1,0x002349a,0x0408dbc,0x0b12232,0x0c384b7,0x094aa60,
  44357. 0x159979b,0x1af966e,0x1b1e9d6,0x1c8ccdc,0x109d5f2,0x0693853,
  44358. 0x1075852,0x1c739c6,0x12f46ea,0x1484f13,0x0905923,0x0cdc6df,
  44359. 0x03f8622,0x0ef27c3,0x0083a23,0x0bd3a17,0x0909c5d,0x1d7ac27,
  44360. 0x179d24e,0x1bbc624,0x1353cb3,0x0064a0a,0x0705de4,0x1048cac,
  44361. 0x0ea8ee2,0x067b333,0x1191bd9,0x1f70f0d,0x0e90ec3,0x0975fdf,
  44362. 0x1facdf1,0x1d68c21,0x15872ce,0x160870e,0x09328ad },
  44363. { 0x106b872,0x027407c,0x1996afa,0x00f04c4,0x105523a,0x0c667bb,
  44364. 0x1a9f8ce,0x047b138,0x1f55b53,0x1d5aa8e,0x137aa0b,0x1d940aa,
  44365. 0x0da0578,0x1baac4e,0x09948f4,0x1aea1de,0x042864a,0x16c7eb1,
  44366. 0x1e3f87f,0x04ff8a2,0x142293f,0x184efc3,0x1ecf9bc,0x0a1a0a8,
  44367. 0x0e49e37,0x0509431,0x097700e,0x1b218d6,0x1b682b7,0x1711426,
  44368. 0x02b0686,0x1310326,0x1f3dab7,0x1f05223,0x154aebc,0x0a61cd7,
  44369. 0x162d25c,0x00012df,0x1579c1a,0x19f5ba1,0x00aa1f3 } },
  44370. /* 48 */
  44371. { { 0x0a10453,0x110c811,0x042ea60,0x1854074,0x1d1eb91,0x12379de,
  44372. 0x1765659,0x18d5f76,0x0f38b6f,0x0c6f1a2,0x1f28769,0x07cb719,
  44373. 0x04ce47c,0x07b86d0,0x16385b4,0x05dadf9,0x09bda26,0x156221a,
  44374. 0x15b8be3,0x01b0f78,0x0e58932,0x040c89c,0x0738fa8,0x1646d81,
  44375. 0x02dffa2,0x186d2c3,0x1239fbe,0x161f34b,0x0c78eb6,0x01958b5,
  44376. 0x0bd2d4d,0x0e136a3,0x1f43105,0x0cb1437,0x1be23d4,0x1a11c46,
  44377. 0x0ed403a,0x09f8bb7,0x151787e,0x1c12c6c,0x0559337 },
  44378. { 0x0fd807a,0x0fb9c6c,0x0888c37,0x1b56262,0x14e0ec9,0x0d7de1f,
  44379. 0x1d36d89,0x12a2945,0x09f12f8,0x0db8302,0x0113f75,0x1847586,
  44380. 0x0fb46f3,0x1aa00a4,0x08cb47f,0x1caa836,0x0f539b4,0x0b0da2c,
  44381. 0x175c2dd,0x0964941,0x01d9f69,0x0c944ac,0x03f190a,0x0bfc45a,
  44382. 0x149beee,0x1b1e02e,0x1da862f,0x15e688f,0x1929d67,0x0ee13f8,
  44383. 0x033a5a8,0x182aa3d,0x0fe6028,0x0a7d135,0x0bccad7,0x084fb59,
  44384. 0x145c2cb,0x0b18de2,0x0534d28,0x1f36192,0x0930070 } },
  44385. /* 49 */
  44386. { { 0x1a9bc05,0x1962f34,0x0dcf4bc,0x0cb1389,0x0a5c19c,0x132fce0,
  44387. 0x0797a51,0x07212b9,0x1bcfb4c,0x1587949,0x0df0c62,0x10ee3bb,
  44388. 0x08b9070,0x1359c02,0x13a5961,0x1b37b12,0x0cf606b,0x0f8cd48,
  44389. 0x1bf4b5a,0x1ab1bf6,0x0a69cc1,0x07230ec,0x021b731,0x19c9063,
  44390. 0x1c277f9,0x141622a,0x19d97e2,0x0934b32,0x1adc8d7,0x134661d,
  44391. 0x0acbff1,0x122259b,0x0018396,0x1e3e59c,0x170ec90,0x09530f2,
  44392. 0x010a222,0x1af9880,0x178521d,0x082b0f6,0x0043a21 },
  44393. { 0x0873752,0x14ede1d,0x1fb9eef,0x085e885,0x0e1493f,0x0610c0f,
  44394. 0x08b2306,0x1cf3039,0x0e29769,0x0671848,0x1a317c0,0x1591bce,
  44395. 0x1eb4626,0x1a6bb3b,0x1a73918,0x129cc67,0x0ade0fa,0x1fc4e16,
  44396. 0x07d6d6f,0x0b98228,0x012c04f,0x1b11146,0x09597dc,0x00b99ca,
  44397. 0x1706a0c,0x027f8df,0x1ef921f,0x1a0ffff,0x19f1a45,0x1e04d24,
  44398. 0x000fb10,0x131b290,0x14e79bb,0x1897c27,0x08581cf,0x1b1466b,
  44399. 0x0f970d6,0x1af57b8,0x02ba12e,0x0f7e49a,0x018d074 } },
  44400. /* 50 */
  44401. { { 0x0601faf,0x1e3be42,0x1dc9634,0x055e383,0x09465be,0x0b6c036,
  44402. 0x19e6344,0x079fec4,0x0d5b0d9,0x0cb6063,0x19c8e8e,0x1aeabd8,
  44403. 0x092fa1a,0x01dd29a,0x1aa0510,0x09b152c,0x0222ac3,0x0ee264a,
  44404. 0x159d619,0x08e3bdd,0x128fddf,0x0bca9ea,0x162b296,0x1d7ecfb,
  44405. 0x063b524,0x069d972,0x05f896d,0x0b0490e,0x159daa2,0x16dd218,
  44406. 0x1008f16,0x1066aea,0x058f9c6,0x058d32a,0x169fe4e,0x039ed0b,
  44407. 0x0efed23,0x0d27ed6,0x1796660,0x1da1176,0x0711093 },
  44408. { 0x01f161a,0x11fe320,0x1a1c4aa,0x012e98b,0x1735856,0x1aefc17,
  44409. 0x14bec5e,0x1329544,0x1a48e62,0x05c1583,0x1611f6c,0x02ae53b,
  44410. 0x0600234,0x0294e2d,0x1953401,0x1ea71e3,0x19e6d98,0x1e60e29,
  44411. 0x034eaf2,0x0c56a65,0x10cd361,0x1c15427,0x1d68de4,0x1dce908,
  44412. 0x1a81b4d,0x18dfb8b,0x0d308ef,0x0d9e6bf,0x1e8b3e1,0x014fbc3,
  44413. 0x0c1ff47,0x0b36f35,0x1da7e68,0x16305db,0x028217d,0x0a0e420,
  44414. 0x07ed48b,0x0200acf,0x05f50c6,0x1b49b39,0x017898b } },
  44415. /* 51 */
  44416. { { 0x01b8cf8,0x041ec57,0x015b361,0x05d3451,0x123d4b4,0x0525e11,
  44417. 0x1613c81,0x1f4ec66,0x0ca7a69,0x1059114,0x1eeac93,0x1517eea,
  44418. 0x0a8afbd,0x1662fce,0x0c90221,0x12b870b,0x013d41a,0x1a3fda4,
  44419. 0x0aaaf9a,0x178a798,0x199d3f1,0x1f8d68a,0x1c8b368,0x03d5363,
  44420. 0x0c081c3,0x1608d97,0x0c05852,0x091e609,0x0fa7ab0,0x0774e35,
  44421. 0x0f738c7,0x08281b8,0x1af7633,0x055dd2a,0x0cdf73a,0x1d096f5,
  44422. 0x07cf3ef,0x0f3b246,0x1aac943,0x19e2a6a,0x073a88d },
  44423. { 0x0e83b39,0x1414403,0x0df4fe1,0x073e880,0x077a441,0x0de420a,
  44424. 0x02c3c5f,0x093f20b,0x154d175,0x0db27a7,0x01fff8b,0x14d5e46,
  44425. 0x01a23ce,0x0789313,0x0fbf555,0x0fe4c72,0x18a10f3,0x097a732,
  44426. 0x13b878d,0x06f9c7e,0x1e8ba44,0x13d49e6,0x193bd0a,0x1355202,
  44427. 0x1c9f493,0x06a0ef5,0x08f5ed7,0x08447ad,0x0a3acc4,0x1508fc4,
  44428. 0x0b5e269,0x058c114,0x0fb9df8,0x0b6032b,0x038eefd,0x01cf3b7,
  44429. 0x068fa30,0x02b5793,0x1a879cf,0x02f5c72,0x052f32b } },
  44430. /* 52 */
  44431. { { 0x114f71a,0x09260f3,0x14655bd,0x0535bb0,0x01be126,0x056df1e,
  44432. 0x0276197,0x0935b23,0x05a0fb6,0x045fae4,0x064b676,0x152443a,
  44433. 0x0f9efa6,0x17b925b,0x1fa0e25,0x02339c7,0x024b250,0x0761fd7,
  44434. 0x0b834f0,0x15f3ec5,0x024d4b6,0x05eb0cb,0x03f3ae8,0x1b6dc75,
  44435. 0x1092b2f,0x094bee1,0x18c98f3,0x123b46e,0x1c43bdc,0x1b0f7ca,
  44436. 0x164c301,0x19bd689,0x1136400,0x0698ec4,0x1a110f0,0x1ffafb9,
  44437. 0x1871899,0x1f61d8c,0x16305e3,0x051dfbe,0x079e14d },
  44438. { 0x1b40c55,0x1111acd,0x090b8e0,0x1a1da0f,0x0a27202,0x1c60fa0,
  44439. 0x106a520,0x11c91cd,0x1d864a7,0x1af9253,0x115724a,0x081418d,
  44440. 0x087e7f1,0x07096a8,0x0b0412b,0x03c21cc,0x07ec11b,0x0cd850d,
  44441. 0x1eecf75,0x144ebf5,0x0b30fd8,0x1f4d1db,0x17fcd53,0x0c05403,
  44442. 0x05d9e46,0x0fbad08,0x164eed9,0x1a6e369,0x02fdeb3,0x1f8587c,
  44443. 0x1176972,0x1bc8d0a,0x001229b,0x0a8bf23,0x02e71cf,0x04a0bc2,
  44444. 0x072ff49,0x07d2a0b,0x1b389df,0x11532ac,0x00d8ec2 } },
  44445. /* 53 */
  44446. { { 0x1eee995,0x07b9f65,0x0030053,0x19a923d,0x12eb88b,0x15d2ea5,
  44447. 0x1b2b766,0x09ac2b4,0x19304c8,0x1bea319,0x00f268b,0x03a5156,
  44448. 0x14ba050,0x08dd5dc,0x1dc8f7a,0x0aee591,0x1775040,0x06442fc,
  44449. 0x1ff2c25,0x03a5678,0x071ab5e,0x0aefcb6,0x187b9e6,0x0c8933c,
  44450. 0x0daab34,0x0995c64,0x157d81e,0x1684bbb,0x043587d,0x0e50d89,
  44451. 0x101c094,0x13f8e86,0x0d7d3be,0x1564493,0x0c43240,0x1f182f2,
  44452. 0x0559a74,0x09160aa,0x12bf1c9,0x04f86e6,0x086001e },
  44453. { 0x1693947,0x005d2f3,0x18ac4ec,0x1c02580,0x0478641,0x0a48543,
  44454. 0x0e383a1,0x0bdc348,0x1d9574d,0x0b9eddf,0x0ee9854,0x171937a,
  44455. 0x159532e,0x0f9f503,0x106f2e1,0x125723e,0x0478cbb,0x0560e61,
  44456. 0x1be406d,0x08c91c3,0x12ee0f3,0x0f6959d,0x1764a74,0x1aeb7f9,
  44457. 0x11eabc3,0x0692387,0x1c4e73d,0x19b78de,0x0249535,0x02a6f82,
  44458. 0x00f3619,0x08ff967,0x0079812,0x1c9860f,0x06d05f7,0x0173e41,
  44459. 0x114ebc0,0x12fe188,0x11b0508,0x19668f2,0x0020591 } },
  44460. /* 54 */
  44461. { { 0x15e0af4,0x01b9093,0x092f8c0,0x1fcf149,0x121141e,0x1aba42b,
  44462. 0x1f3db45,0x13cccd9,0x1168e65,0x1d0eb9b,0x010bb97,0x1ca81c5,
  44463. 0x16263e3,0x0a45eaf,0x1b30f52,0x020955b,0x03d246b,0x000cef0,
  44464. 0x0d0f606,0x13d207e,0x0d31f8a,0x052d860,0x12d5ee9,0x1c4ecbf,
  44465. 0x0c50651,0x1b3c123,0x1d9466f,0x018aea3,0x119a018,0x0100790,
  44466. 0x1d17c17,0x0f043a9,0x06487b8,0x01d033f,0x12a8987,0x044c5f2,
  44467. 0x1214605,0x07f244b,0x017bd5b,0x0bf43be,0x0511998 },
  44468. { 0x18586c0,0x0a4bed8,0x0989606,0x0d8ddd5,0x004415d,0x06d1458,
  44469. 0x11ada5f,0x128f8d4,0x07c1945,0x10a4d94,0x0e941a6,0x13f49da,
  44470. 0x14b5636,0x01e4a65,0x04aa999,0x1ddc4e1,0x13aa9e9,0x0aade73,
  44471. 0x1e24d42,0x1650e0e,0x132634b,0x180375a,0x02be57e,0x071e90b,
  44472. 0x1032396,0x1fc43e6,0x016e9d6,0x126ec4d,0x02d5812,0x179ecea,
  44473. 0x137ccb5,0x0cb8dac,0x0cad574,0x0f6a0d2,0x03eecb3,0x0f30bea,
  44474. 0x1006a06,0x1a67074,0x1fe6b3c,0x0cab14a,0x059eaf2 } },
  44475. /* 55 */
  44476. { { 0x0c3876f,0x03f7db7,0x1921ed0,0x07e1e90,0x180c612,0x04981cb,
  44477. 0x15bfefe,0x1605576,0x045a91a,0x0c97550,0x046e0a5,0x09aef10,
  44478. 0x09ce5b8,0x0fcf9fe,0x09c68d0,0x1c2770d,0x186f0e7,0x060bfee,
  44479. 0x1568220,0x1b052ec,0x066688e,0x1a40eaf,0x1d75b71,0x02e2f2e,
  44480. 0x09df61d,0x10ff7fe,0x178fde7,0x0d5a991,0x06192e3,0x18be902,
  44481. 0x18b6c54,0x04e9fb4,0x0c9fa7a,0x0cc8a3c,0x093e0b7,0x1809d92,
  44482. 0x1a64971,0x0e8f1c1,0x0efec16,0x1d44c41,0x03b4450 },
  44483. { 0x176dcdb,0x1d4aae3,0x091cf6d,0x1903917,0x15c4a57,0x0bb07d9,
  44484. 0x1400d41,0x0a75c50,0x1b3aec3,0x1f40348,0x05ef978,0x0b7c8e2,
  44485. 0x0138033,0x02b667b,0x111f8e8,0x0f22dc3,0x1eb3397,0x0929e7e,
  44486. 0x172dfb8,0x19bf75e,0x17043de,0x07be7a5,0x1cf25e5,0x1f028c5,
  44487. 0x1680c9f,0x14f9200,0x06f8f6a,0x1c881c2,0x191d8a4,0x01bbb4f,
  44488. 0x1771741,0x196bd38,0x106c7a8,0x1e926a0,0x0684ced,0x0432321,
  44489. 0x1764b4a,0x09e41c1,0x0d853a2,0x0198853,0x04a7fe3 } },
  44490. /* 56 */
  44491. { { 0x055c7c5,0x19d3812,0x1d539e3,0x10e02ae,0x1b7636e,0x1193162,
  44492. 0x11491d8,0x18fe658,0x01bc780,0x04c588f,0x1b61dcb,0x1d5922b,
  44493. 0x14d48ea,0x0cc932f,0x0134f00,0x0401f76,0x19bcfa5,0x035a958,
  44494. 0x0fa8ffa,0x1413032,0x0059c46,0x1edd3ac,0x160b1cc,0x12d5599,
  44495. 0x0bbd618,0x0a8e992,0x133a3b3,0x181345f,0x1c44b3a,0x0c7e817,
  44496. 0x12d4a64,0x15542f0,0x0c45e4a,0x1042e78,0x0d03f88,0x026ac4c,
  44497. 0x050c7d6,0x05db3b6,0x1ac8d4f,0x146ca24,0x083fa1e },
  44498. { 0x0ccc646,0x0436d08,0x07a582b,0x1ef608a,0x0ce0637,0x0443081,
  44499. 0x1d8c228,0x1057779,0x1203499,0x1e0c80c,0x0f36808,0x0739f81,
  44500. 0x1d707fc,0x0dea7eb,0x1347c54,0x07776fe,0x0744471,0x06b5327,
  44501. 0x16b2798,0x1b8ced8,0x116957b,0x019bdb0,0x115b14c,0x1e8143a,
  44502. 0x11396dc,0x163e9a2,0x15265f4,0x07dbd84,0x04a739f,0x14d2616,
  44503. 0x1894d2b,0x0d4d5a5,0x001397e,0x0afc08a,0x15348fa,0x1e40ed3,
  44504. 0x1e98fab,0x1003e36,0x147833b,0x0f32638,0x0614097 } },
  44505. /* 57 */
  44506. { { 0x1156623,0x1996d8a,0x1f08f76,0x1956f4c,0x08137fb,0x0cf1e13,
  44507. 0x07d41bc,0x0c24c02,0x089924c,0x010c581,0x013070d,0x161f8d0,
  44508. 0x07492a0,0x17d5735,0x16f9c1a,0x17cc3ac,0x03e0d01,0x09d89e9,
  44509. 0x01fd31a,0x08b68ff,0x1aa3445,0x11026e0,0x15088db,0x0a2c3d9,
  44510. 0x1261d3c,0x003b09a,0x0ef622f,0x1d68d4c,0x19d7201,0x0c1b0ac,
  44511. 0x1cde31b,0x0d375e1,0x0955fe1,0x194107b,0x0f585c1,0x148cfdd,
  44512. 0x1e3a340,0x0dc5151,0x17e20bc,0x0ec5a16,0x0636dac },
  44513. { 0x0c80af3,0x006dcda,0x0aae50a,0x029c712,0x1a189cd,0x03beee4,
  44514. 0x00b8345,0x09e4dce,0x068f9f1,0x08d771c,0x0a82cba,0x0c75017,
  44515. 0x092864f,0x05b8a51,0x1607dce,0x0f96d59,0x070c5fe,0x09870dc,
  44516. 0x0420dff,0x1d43876,0x089f883,0x09b5902,0x0b689e5,0x145b4be,
  44517. 0x12a6858,0x10a1d75,0x080ea3e,0x046617e,0x10b1c4e,0x045aee3,
  44518. 0x1d2d712,0x0532cf1,0x078c4d9,0x1b3ae05,0x0260977,0x104677a,
  44519. 0x1b67d36,0x1ae03b3,0x1bcfcde,0x1fc9a17,0x02f6dbd } },
  44520. /* 58 */
  44521. { { 0x04da7c7,0x0397e97,0x04c8be1,0x035ccef,0x108cfc9,0x0134713,
  44522. 0x1c228f7,0x0486c95,0x0799a24,0x1886ff0,0x162ffc3,0x1ab0e3a,
  44523. 0x06ef912,0x0c44b17,0x1cd77f2,0x1d414d7,0x1a95f47,0x0945cb7,
  44524. 0x0b4c230,0x14f3d55,0x1bba734,0x1bcfa1b,0x055cc0c,0x1ea9eeb,
  44525. 0x0bd8e6c,0x1760016,0x1f9d8cb,0x0ec0db9,0x1931044,0x0f65a98,
  44526. 0x075012d,0x0159ee5,0x0e0897c,0x0f8ef05,0x0e18ef7,0x1112c51,
  44527. 0x187d744,0x168aa77,0x1753bb3,0x12e8b1a,0x05cb6e1 },
  44528. { 0x08c75ed,0x178cb80,0x0be2633,0x1deddd5,0x1cf49d3,0x1af4b6b,
  44529. 0x0780861,0x1143adf,0x0dd9b0d,0x076167f,0x1db6abf,0x19fd72a,
  44530. 0x1838a61,0x1b53edd,0x000fce4,0x029e820,0x06823b8,0x1d9be1c,
  44531. 0x0038c54,0x0cdb977,0x07a89fb,0x1d02cc2,0x079f8ba,0x14e4ee1,
  44532. 0x063fd35,0x1685276,0x07f2783,0x023e7b2,0x15baa43,0x004a6a8,
  44533. 0x18cf077,0x14119a9,0x1a06ebc,0x0f7553a,0x08e0bb5,0x1f56c2e,
  44534. 0x01f52c1,0x015dd87,0x15b94ba,0x060a2eb,0x02149d6 } },
  44535. /* 59 */
  44536. { { 0x19311f6,0x14737af,0x1e17b86,0x1f75783,0x097e3c9,0x0a104d6,
  44537. 0x114bad2,0x1c29f4f,0x019774f,0x0617a8e,0x16113c1,0x02450aa,
  44538. 0x135cefd,0x1ac39d5,0x0e18a8e,0x033f96a,0x1d6cbed,0x13b477e,
  44539. 0x19611a6,0x0248f3d,0x009ccdc,0x189ec06,0x0448df8,0x0898518,
  44540. 0x0a290c0,0x143eeba,0x0af51f8,0x1dcca2f,0x0ffeef9,0x0914568,
  44541. 0x07f0908,0x1031a50,0x073088f,0x006f0a1,0x12f10fb,0x07d78e8,
  44542. 0x1415bd7,0x137667d,0x109b16c,0x0a1960f,0x014e2f3 },
  44543. { 0x016946b,0x0950821,0x04b5523,0x0ef497b,0x0e801f0,0x14a8b03,
  44544. 0x1428d0d,0x192b32d,0x163a197,0x18dae17,0x1ddf243,0x189e0c3,
  44545. 0x0279da3,0x09ffbd9,0x07358d2,0x0247e38,0x050a234,0x02f30db,
  44546. 0x0a100cf,0x16698be,0x0214826,0x146179a,0x1c62e43,0x100dd8a,
  44547. 0x15620ae,0x0da52f9,0x178c92a,0x05f5c68,0x13cb51a,0x1caf45a,
  44548. 0x1e2302e,0x1f32cae,0x14f6ac2,0x0f79964,0x01f5ae7,0x0e0fd8c,
  44549. 0x10ed8f2,0x1f8edd6,0x0793d8e,0x005b96c,0x058537e } },
  44550. /* 60 */
  44551. { { 0x0f80ba2,0x0583232,0x116c7d9,0x0e0ab34,0x08e055e,0x1a5b1a7,
  44552. 0x0acd3c7,0x105864c,0x1de8c84,0x1a7beaf,0x11e02bb,0x1d41861,
  44553. 0x139d55d,0x07d0f34,0x102bee7,0x186962e,0x0667460,0x1167f35,
  44554. 0x061f07b,0x12b2822,0x0d94f66,0x1bafcba,0x04e0bc9,0x08a93d6,
  44555. 0x0ace400,0x0810e50,0x1eeaf7b,0x1048967,0x1653eaf,0x0683271,
  44556. 0x00f0dbd,0x18ab8bf,0x0b9f0dc,0x1e74875,0x13beb3a,0x0bb2773,
  44557. 0x1906142,0x12c7390,0x05c3459,0x0bf05af,0x0485783 },
  44558. { 0x0576210,0x092de69,0x110f735,0x0faa36a,0x1f378aa,0x0c1cca4,
  44559. 0x0fc5c6f,0x043fd2f,0x1f38ac6,0x18687b1,0x1023324,0x182f030,
  44560. 0x16af8f2,0x1307a9f,0x04b21f8,0x0ebc84d,0x007db0a,0x187722a,
  44561. 0x1f6c6cd,0x08f5cbf,0x044b0ec,0x0e3d535,0x1da44a7,0x0816eba,
  44562. 0x132b22e,0x1bbdb7c,0x0257bce,0x00cec9a,0x1c63e8e,0x03fab45,
  44563. 0x100a3f5,0x1380029,0x1810494,0x0aec768,0x0ff75e6,0x1f21c5a,
  44564. 0x0c2a85a,0x1cd02eb,0x0c4a3ac,0x17b443e,0x06c0277 } },
  44565. /* 61 */
  44566. { { 0x109e7ef,0x1b8435a,0x1e47906,0x167aff3,0x0842ec7,0x135c45c,
  44567. 0x17e5154,0x1579a50,0x0051dd0,0x1227032,0x1c73adb,0x1820ee9,
  44568. 0x1b90198,0x091f330,0x12afa60,0x08fb2dd,0x13632f6,0x1224088,
  44569. 0x1b14abb,0x10568a4,0x09d51dd,0x1fc9cee,0x1594241,0x1a8ab7f,
  44570. 0x0eef2fc,0x0be5eaf,0x1634b97,0x102b49b,0x1c9f2a7,0x1649445,
  44571. 0x0896b53,0x0af4766,0x0f10d0b,0x0e5ede3,0x079c82e,0x11d1a18,
  44572. 0x1b774ee,0x05838d4,0x13e3d68,0x135e45f,0x03067bc },
  44573. { 0x1ca9326,0x0c4f95b,0x1d8f839,0x1b62449,0x17a106f,0x1d2bde8,
  44574. 0x11485d1,0x05d646a,0x162b088,0x10a4c16,0x07ff3c9,0x0a88872,
  44575. 0x0d7f3af,0x1427220,0x0a8cdee,0x160e235,0x1b0941b,0x014751b,
  44576. 0x1929fd5,0x0fb9685,0x15fba95,0x160d356,0x19ead98,0x186d441,
  44577. 0x1e381f7,0x1b5e89a,0x126ea82,0x05cf301,0x04671f4,0x01864a7,
  44578. 0x18d08dc,0x1161245,0x0cc63ff,0x12c4f92,0x09e5116,0x19a21aa,
  44579. 0x0870ff6,0x0ce98b5,0x10656ee,0x195532d,0x0390c83 } },
  44580. /* 62 */
  44581. { { 0x1c4a73f,0x1fd417f,0x0c0d434,0x0a77aa6,0x0665d63,0x05dbbe9,
  44582. 0x1be2899,0x1090140,0x022d73d,0x0e02537,0x0ee2aa0,0x1fea064,
  44583. 0x1a2409c,0x062626a,0x173885e,0x1383263,0x00e0c0f,0x01ba554,
  44584. 0x0061aee,0x0b470e0,0x087f0b2,0x085578a,0x142dde8,0x0931bc3,
  44585. 0x19ad5ab,0x08b0af9,0x186a830,0x05c65b4,0x025ce89,0x1edecb7,
  44586. 0x1448a38,0x0bd0c8d,0x17c88dc,0x18e345a,0x059099e,0x0ace562,
  44587. 0x000bdec,0x06c03fb,0x15ce974,0x0fa447c,0x03ea400 },
  44588. { 0x195d0a3,0x0f5e852,0x0ed35db,0x175fe16,0x06bd76c,0x0dedcbd,
  44589. 0x0553e6c,0x0e37e58,0x04c714c,0x158cd5a,0x0bd98d8,0x0772443,
  44590. 0x16c9bf3,0x064a0f7,0x161f126,0x01eda47,0x0c3d79f,0x092ac02,
  44591. 0x09eb2f0,0x14200a5,0x08af6f1,0x0caa829,0x176ade7,0x1a2c426,
  44592. 0x1a6f0c8,0x014febb,0x1779784,0x00a116d,0x1da12b4,0x00797ca,
  44593. 0x087656b,0x0eb1517,0x060af71,0x0647dc4,0x120dc58,0x0816329,
  44594. 0x0e004d3,0x0736406,0x0aa8290,0x02ed629,0x009f82a } },
  44595. /* 63 */
  44596. { { 0x01366dc,0x1f2c461,0x0be582a,0x1f5eebb,0x129c0a4,0x1c9f6a3,
  44597. 0x07f66b2,0x0e0e0a0,0x087a16d,0x0bf3a27,0x1cd86ee,0x14f531c,
  44598. 0x13a42e0,0x145aa67,0x136bfc8,0x120f035,0x0bbb7bd,0x1f843e6,
  44599. 0x18c9439,0x1e7306c,0x1c09da6,0x175d783,0x19b5a4f,0x175e2ae,
  44600. 0x0f4c38c,0x0e83cdd,0x1f7f2a6,0x15309c0,0x0d8dab5,0x1923f93,
  44601. 0x1e6ad34,0x0fd746d,0x10be701,0x0e90b26,0x19943a3,0x066f773,
  44602. 0x131c4f0,0x1527122,0x16169ca,0x1096ea7,0x077d1e9 },
  44603. { 0x0e62367,0x1991cec,0x13c764d,0x1773041,0x1361848,0x0e4be21,
  44604. 0x18d116a,0x1f8018f,0x014f960,0x10764d7,0x11d2d66,0x019ee80,
  44605. 0x15cf41f,0x167032e,0x1bb7a3f,0x10c214b,0x04e9e80,0x0d8ef2d,
  44606. 0x1833dd7,0x0895c95,0x0d0b17c,0x11b58a4,0x0be958c,0x13fe5b8,
  44607. 0x0740fd2,0x097327d,0x0a232c8,0x0c0bd71,0x063016c,0x18d6b54,
  44608. 0x05fcb1d,0x0c0f698,0x16112e7,0x04bc2b6,0x101d035,0x0bfd21d,
  44609. 0x0256e0e,0x0df0c5f,0x0b6c166,0x1d994a9,0x04e6eab } },
  44610. /* 64 */
  44611. { { 0x199cfe6,0x191e9fd,0x05e2540,0x0d92668,0x1b09bc2,0x1efdb7b,
  44612. 0x07905f2,0x0c0c822,0x089a757,0x08a0ba2,0x0672c24,0x1bf2212,
  44613. 0x0f4c633,0x1cb5fe9,0x17f1f1c,0x0c5b6e2,0x1128cab,0x04650ca,
  44614. 0x16e06ab,0x0e48e69,0x054a306,0x15da626,0x199e891,0x0452c8d,
  44615. 0x0a0fabf,0x0b86bbf,0x07e96d7,0x17da2be,0x1192f35,0x16d2e17,
  44616. 0x0b695a1,0x0fecd21,0x0cac72a,0x085beef,0x0a8b2a9,0x1e1895e,
  44617. 0x0049ad2,0x0318e0b,0x1c15bd1,0x12c09d9,0x0325d27 },
  44618. { 0x048c144,0x0fdaaa4,0x1ccbb84,0x0b6d4f5,0x0e06292,0x0f07cd2,
  44619. 0x1a384da,0x03c24b6,0x0ca53b2,0x0cded73,0x03a86eb,0x00b85d3,
  44620. 0x15f50d6,0x0f97d1c,0x0e7854e,0x065eb7b,0x12de915,0x1a2b871,
  44621. 0x1a89435,0x0d315c8,0x1145810,0x1656cec,0x1ff6551,0x1d2f4bc,
  44622. 0x0772111,0x174d5fb,0x14927e0,0x1453efa,0x11df63c,0x1cd4cc2,
  44623. 0x196a714,0x0e3a1c7,0x184d54b,0x095ab7e,0x1670107,0x15a3c08,
  44624. 0x1d80096,0x19f5b77,0x1e74f3a,0x08dc654,0x019d485 } },
  44625. /* 65 */
  44626. { { 0x140f5e5,0x0f747da,0x145ff86,0x1e09cd1,0x06d2a52,0x1ee438c,
  44627. 0x036c2b6,0x191a464,0x0d03a7f,0x01d6ad4,0x12e45aa,0x078e117,
  44628. 0x0054bf8,0x1728f42,0x084cfa8,0x1bbbe12,0x024cb52,0x1de71c2,
  44629. 0x0418d60,0x0f7c806,0x1176d5c,0x0fa2c71,0x107aee7,0x09b577f,
  44630. 0x19639bc,0x0d457d8,0x13015c9,0x0c6a1fc,0x01cd243,0x031a427,
  44631. 0x17ab128,0x1828b71,0x1f73154,0x0191bd6,0x167acd2,0x00154db,
  44632. 0x0bff272,0x1a2e1ee,0x14ec28c,0x0d969c8,0x01b3ace },
  44633. { 0x0a8bdc5,0x1f2f4c8,0x02240d0,0x1ac60d4,0x0203bf9,0x0429075,
  44634. 0x068d639,0x00d3091,0x0de7d1d,0x08bef5f,0x0574fef,0x0daebef,
  44635. 0x1f8fafa,0x1c3d851,0x13ad8c0,0x1d5f549,0x132ffdd,0x1700b35,
  44636. 0x19d9380,0x1c40a8f,0x1304a2f,0x127438f,0x156ae60,0x05d88bc,
  44637. 0x136bb95,0x065515e,0x12a4348,0x1698290,0x1cfb537,0x19c3bad,
  44638. 0x1954c67,0x0d30589,0x0238a4a,0x1490e9a,0x071e840,0x1d4576c,
  44639. 0x1b3ab17,0x030db26,0x0285078,0x07c325e,0x0538ec3 } },
  44640. /* 66 */
  44641. { { 0x19b56cf,0x04b7f50,0x0b3464d,0x08f7733,0x063d77f,0x085440b,
  44642. 0x0bea15f,0x1fb1e09,0x0082835,0x0769ed1,0x0b3b1f3,0x15dabb0,
  44643. 0x057e21f,0x1c004e4,0x05d6e67,0x1460edc,0x11b2d05,0x16ce371,
  44644. 0x0521f60,0x091a950,0x0655969,0x196a37b,0x01baf4f,0x0799893,
  44645. 0x11aa877,0x0534342,0x0a2c590,0x1c441e4,0x020b753,0x11d420d,
  44646. 0x1be7c1b,0x1215814,0x0fffe5e,0x159fd96,0x076a3af,0x13eb536,
  44647. 0x0e08e2c,0x03eccbb,0x1d00496,0x13007d3,0x06fd602 },
  44648. { 0x0b7516a,0x04fc6c7,0x02ad51c,0x097b8b3,0x03058a7,0x1400e74,
  44649. 0x176621f,0x12da469,0x0d17b8a,0x087cec8,0x03daaff,0x093edd2,
  44650. 0x1baa1e5,0x0d3f6aa,0x05bfe01,0x0983249,0x17a6c25,0x086cfb2,
  44651. 0x025895d,0x1d49397,0x07de3cd,0x1816ff9,0x0da168f,0x1178097,
  44652. 0x0e7fddb,0x1581e28,0x1e61c8d,0x009fe1f,0x0d50559,0x0c7edd8,
  44653. 0x141250a,0x1c297d1,0x0b3386d,0x0986b1a,0x1a71f0f,0x12f5a69,
  44654. 0x0159fdd,0x15995ef,0x197007c,0x0798ec3,0x084cfa2 } },
  44655. /* 67 */
  44656. { { 0x199b964,0x008f5c5,0x111c4ef,0x14b1c5f,0x0e280c0,0x04d2a5c,
  44657. 0x0f12753,0x1f50e1f,0x0bf6e20,0x1d19a51,0x0233e8d,0x1a1baf9,
  44658. 0x1aee583,0x17a578e,0x180a6a3,0x1f14c0b,0x0340c2e,0x136aaf1,
  44659. 0x027a6d8,0x0dfbfc4,0x080f61b,0x135dc70,0x0ec76b4,0x125f834,
  44660. 0x1c16293,0x1a72d6d,0x182ab8f,0x05581fc,0x1f4d5b0,0x000d615,
  44661. 0x14a3666,0x18505fd,0x133f93f,0x0d99f91,0x0432d4b,0x0e2db96,
  44662. 0x055752e,0x1c87c26,0x0363827,0x0a39094,0x0287d4c },
  44663. { 0x09867da,0x0c10087,0x13697e9,0x06350e9,0x014589b,0x0f71173,
  44664. 0x09f17ef,0x15000bc,0x1e612bd,0x1abff7a,0x18d7e78,0x1dbe5a6,
  44665. 0x064e0db,0x17892d4,0x0f9c391,0x145cac5,0x0840d94,0x0d04dcc,
  44666. 0x02d7974,0x13342a5,0x08b57eb,0x173a881,0x086e505,0x0da5988,
  44667. 0x17fd7e0,0x0228d89,0x1ffa826,0x1f43ea2,0x0ecbd76,0x14b37fe,
  44668. 0x0f8ee87,0x1065e8a,0x0c89a4a,0x147d0ea,0x0abfb29,0x060f63c,
  44669. 0x0bd395a,0x1da229a,0x0784f43,0x1b9b1df,0x00132a3 } },
  44670. /* 68 */
  44671. { { 0x16374c2,0x03bc2ab,0x010394f,0x0308e4e,0x060526d,0x0650227,
  44672. 0x1b7208a,0x027140c,0x0f1ce13,0x1f0e0d9,0x0c31747,0x10659bd,
  44673. 0x0f2aeec,0x0e5fc13,0x1659a66,0x14b134e,0x081de77,0x0668c47,
  44674. 0x0634495,0x1c1fc02,0x186ae5c,0x0203c85,0x0850aa6,0x158519d,
  44675. 0x1043f39,0x0027147,0x021f796,0x1ddf052,0x19a8c54,0x0d997b1,
  44676. 0x13e0f0c,0x0b10ef2,0x10454a7,0x0d9c8eb,0x154062c,0x0b94c6b,
  44677. 0x11d9c79,0x1f503b1,0x0a8973b,0x0ed6df1,0x013cbee },
  44678. { 0x13f34f3,0x15f07c6,0x1f8de72,0x1946c2f,0x1da9c31,0x0a1350d,
  44679. 0x1b88f76,0x00964db,0x1f29c91,0x0eecb13,0x1b34efa,0x02d3c58,
  44680. 0x16033eb,0x1e5d10c,0x1cfd24b,0x1907914,0x00bb858,0x1c971bf,
  44681. 0x0ecfeed,0x05594c4,0x00a2e4f,0x0f325f0,0x00407ec,0x11ec891,
  44682. 0x1826a94,0x073c8d3,0x1241c98,0x0280cf6,0x0bb8354,0x1528718,
  44683. 0x1bbddd2,0x1933380,0x122ca80,0x04288fc,0x16e42e8,0x00d70c6,
  44684. 0x05fa04f,0x09b5ae1,0x0259efe,0x1b5c05d,0x04e0a1a } },
  44685. /* 69 */
  44686. { { 0x1a29c4d,0x1333845,0x0250032,0x1c45310,0x008240c,0x0ed3a96,
  44687. 0x1299c5b,0x068438b,0x1abbbfa,0x04e0722,0x0a2dc9a,0x0bfa7da,
  44688. 0x141d754,0x0be2b55,0x0884663,0x13acabe,0x1743875,0x0a59ec7,
  44689. 0x1f942e2,0x121bf71,0x1a16934,0x0bf4075,0x0d907d7,0x1596a6f,
  44690. 0x1a5eb79,0x12f3d86,0x1c30757,0x16d6292,0x1a429aa,0x1346d2e,
  44691. 0x0948ce3,0x05eda5e,0x010c437,0x079d3f0,0x1b4994c,0x1844de2,
  44692. 0x0bef08b,0x187bdb6,0x12667be,0x1b33f33,0x0733e30 },
  44693. { 0x02a38f9,0x10ac152,0x1403b3f,0x1c8e616,0x0ec2d58,0x0bb5965,
  44694. 0x1ca9f7a,0x1765dc5,0x1a969c1,0x029ceda,0x136d2bc,0x02d1f9d,
  44695. 0x0231954,0x13d4748,0x1dcd22b,0x0a83fe5,0x1cc3121,0x10eac6b,
  44696. 0x080ab94,0x0b6eb84,0x15a75d2,0x0d7a041,0x17aa659,0x1369c8d,
  44697. 0x16a4152,0x0cd9ff5,0x1ef49eb,0x192ff6d,0x1f900b5,0x0a60130,
  44698. 0x07b61d5,0x009ab63,0x03031d9,0x0cdce5a,0x06e32c8,0x1e67abd,
  44699. 0x1ee00bc,0x01ea491,0x17031e9,0x0736f34,0x056facb } },
  44700. /* 70 */
  44701. { { 0x1018bfa,0x0b2d151,0x0610064,0x093ff5b,0x100c6b2,0x1a0d4d8,
  44702. 0x0c7d954,0x19377e3,0x125dc4c,0x15e8ecb,0x1ff9839,0x1daa57f,
  44703. 0x0b52850,0x1f2a84d,0x1a64b31,0x0b3e249,0x02e4ceb,0x07fb628,
  44704. 0x0a9f452,0x166ae63,0x0a462f0,0x0ef3f1d,0x1a43077,0x0285101,
  44705. 0x09f45d1,0x0eadd76,0x1996f97,0x0eb9fa4,0x0bce134,0x18a70ff,
  44706. 0x0c20eae,0x101285a,0x0ba4829,0x1416435,0x0d74a5f,0x1a3c364,
  44707. 0x10d8218,0x18e6df2,0x1b2eedd,0x0cdb29a,0x0885992 },
  44708. { 0x15ccaf2,0x039480a,0x1cf8221,0x0ef8b6e,0x0679ebc,0x0e8476c,
  44709. 0x0b746cb,0x1b75116,0x087d475,0x1050c07,0x1340aa5,0x0d6ecd2,
  44710. 0x1680fdb,0x1f9fcf4,0x01d6324,0x06d887d,0x0fa4ad8,0x0ded1fb,
  44711. 0x0bece1f,0x018b026,0x000f940,0x0112a81,0x0969e15,0x0dd9e30,
  44712. 0x1c35177,0x0cd154b,0x1959b6d,0x07d7e8d,0x145eda0,0x1140132,
  44713. 0x1111d0e,0x19ee956,0x1169d84,0x19fb4f6,0x0c76232,0x0d75572,
  44714. 0x1825719,0x1749966,0x05c65c2,0x14d4181,0x0797224 } },
  44715. /* 71 */
  44716. { { 0x01f3567,0x091fc22,0x1c758ca,0x105c497,0x011c316,0x138fffe,
  44717. 0x1c9aedd,0x044972e,0x17a5e1a,0x00ba353,0x16d05d8,0x1d4075b,
  44718. 0x0653ddd,0x1facdc2,0x019e8f1,0x0ffeeaf,0x18756cd,0x0580954,
  44719. 0x066ea6a,0x0bfd93e,0x07481bd,0x117c183,0x1d40de6,0x1180ba2,
  44720. 0x1445dab,0x0153bb1,0x0de40fd,0x1afe883,0x03e46d5,0x13a6d48,
  44721. 0x1070045,0x15ba24d,0x11d3c4d,0x0ada00d,0x0ab1851,0x1d44ea5,
  44722. 0x155c356,0x1215342,0x014b136,0x02bb041,0x03ff09c },
  44723. { 0x1cb7784,0x10de77c,0x0c15302,0x184845e,0x0ec539b,0x00a553d,
  44724. 0x1e7f431,0x188be81,0x0ffd42b,0x1d518b6,0x1638574,0x09865e6,
  44725. 0x0242f5a,0x0b713b4,0x0f7367b,0x1d9dc01,0x09ff8a5,0x0834fbc,
  44726. 0x17853d7,0x10031c0,0x0741807,0x09c5a06,0x0aecf92,0x02fee5a,
  44727. 0x08c1d79,0x0862ede,0x13315c5,0x01dd4cc,0x1a8920e,0x062d61f,
  44728. 0x192897b,0x038f2e2,0x021b0f5,0x168b59e,0x0bc98d2,0x151e134,
  44729. 0x18391d9,0x1987e2a,0x0b93239,0x00a9fbf,0x047ef18 } },
  44730. /* 72 */
  44731. { { 0x1a285e4,0x0f9e89e,0x0fd2659,0x147403c,0x1a7d4db,0x10a5685,
  44732. 0x104e984,0x0928e70,0x1223975,0x1dbea9a,0x0c2e4b4,0x1b9eb4e,
  44733. 0x1da53db,0x19968b2,0x0c364ac,0x0fde862,0x14182f9,0x1225142,
  44734. 0x137386d,0x0444388,0x0ec9bf6,0x0c3f150,0x0ee84e1,0x1f5b331,
  44735. 0x12c8dcb,0x02599f9,0x1ed7fb5,0x013cbe7,0x0217bb4,0x0632e33,
  44736. 0x0a570ca,0x1f9bee3,0x00db69f,0x103c458,0x0886e24,0x1744785,
  44737. 0x1ae6464,0x1594731,0x02187e2,0x13971bc,0x01a6b6e },
  44738. { 0x0af77aa,0x1615b03,0x0196bdb,0x1b510fe,0x0e60f5c,0x04c62b1,
  44739. 0x050027d,0x0970fa4,0x1fcbaaf,0x1acadac,0x0ae1576,0x05424e3,
  44740. 0x0c0fb59,0x0a1a4d8,0x1384397,0x1193941,0x1d8887d,0x1ceb0c3,
  44741. 0x152f5b6,0x1d2bf22,0x099903e,0x09ae836,0x03f94c8,0x0d4c9a1,
  44742. 0x1bc30fb,0x1b07a53,0x159a932,0x1a455e1,0x17367c3,0x1677ae9,
  44743. 0x1545a54,0x132fb1c,0x10ea734,0x1996837,0x1c3dcc5,0x05688f8,
  44744. 0x09cb394,0x15981a5,0x03f4002,0x10050a2,0x079dd01 } },
  44745. /* 73 */
  44746. { { 0x0c7424e,0x0019d1d,0x1340138,0x10c1fb4,0x1b06b68,0x1bb97de,
  44747. 0x05d9af2,0x14846d5,0x1f297cd,0x0a54715,0x04f1b8a,0x170bb60,
  44748. 0x0d4b0aa,0x0391d1d,0x0abb262,0x094d67a,0x0cd13c8,0x1065719,
  44749. 0x03b05a7,0x111ebce,0x0262218,0x1ea1544,0x1ce58ce,0x0c1b370,
  44750. 0x0792e7b,0x1f0b456,0x0841da7,0x13e56e4,0x0bed348,0x07f3692,
  44751. 0x0aa3cff,0x147d649,0x15efb88,0x03835e9,0x08fd213,0x1bbbd9f,
  44752. 0x129ece0,0x008cd4c,0x150d9f3,0x08b1a80,0x087e5ad },
  44753. { 0x11000a7,0x0d54ebe,0x00ceea6,0x195d047,0x0b94aff,0x1c1ee2c,
  44754. 0x058a37e,0x11b9045,0x1845a41,0x1acff08,0x05c150b,0x01f0ba8,
  44755. 0x01a8b97,0x195b8ac,0x0630995,0x1ba2f12,0x17dc0d1,0x07277a3,
  44756. 0x0beb5f0,0x1699e67,0x0a5bb50,0x1c80c38,0x086eba9,0x07450d0,
  44757. 0x087f9bb,0x0e6e3b8,0x1849296,0x10aea63,0x1432397,0x0137abf,
  44758. 0x12bb5d3,0x002c992,0x1f5ae25,0x05fba6a,0x1f8bc25,0x04cc116,
  44759. 0x1dceea3,0x06dadd7,0x10117d3,0x0333219,0x00b7125 } },
  44760. /* 74 */
  44761. { { 0x0d5c64d,0x08650c4,0x14d168a,0x134e924,0x0596d74,0x0074928,
  44762. 0x034f4a8,0x0d74096,0x0caf7b6,0x0166816,0x17b60c2,0x0185d9b,
  44763. 0x0e912b5,0x1f98b23,0x0f3a77b,0x1ff2b02,0x0c7c75f,0x0b15738,
  44764. 0x18a9185,0x10a5c0f,0x0fd16f6,0x0801c02,0x0c83f5f,0x031d1b2,
  44765. 0x0a4dd82,0x0ebd8d1,0x0ebf191,0x12314df,0x19fdbe4,0x07d0f46,
  44766. 0x1bbec20,0x088e16d,0x1d4d08a,0x1a77b99,0x01ddb65,0x05a5744,
  44767. 0x09dae5d,0x05cad3b,0x165b63b,0x074fad2,0x07a3f42 },
  44768. { 0x0929387,0x096534d,0x1ffcd8b,0x0396383,0x0bdb758,0x08db65d,
  44769. 0x1b27df9,0x03fb125,0x03a4e13,0x146c319,0x01d587b,0x07e2b7b,
  44770. 0x124680e,0x0a73f39,0x0965f87,0x1fdfdc7,0x17c5581,0x19e6395,
  44771. 0x0a32b82,0x0eff159,0x14aff3e,0x0e2f17e,0x1f31f5f,0x06ab6f3,
  44772. 0x0455221,0x0bbee9d,0x0a8b01c,0x08d649e,0x09621f5,0x0996834,
  44773. 0x0f9056d,0x07ef02c,0x1e9af51,0x1f69095,0x0e6ccf5,0x064fac7,
  44774. 0x1680294,0x00cf794,0x1ebd2ac,0x0aa2c47,0x02da5fc } },
  44775. /* 75 */
  44776. { { 0x0a5c600,0x14e79e4,0x19f1890,0x047fc67,0x07a80c2,0x0beee5d,
  44777. 0x09d0029,0x0e93ffb,0x1925b0c,0x0d70ab6,0x003ac34,0x07f2d62,
  44778. 0x01097a4,0x17ca1e4,0x07a5173,0x19e482d,0x0e51128,0x1d0fb9a,
  44779. 0x067c04c,0x10f8948,0x0024043,0x0580822,0x1001e1a,0x06b39e5,
  44780. 0x16abf90,0x071f2a0,0x191e355,0x138edfd,0x02173ef,0x0ed3215,
  44781. 0x1059886,0x13fc602,0x1e03156,0x1923f30,0x138e4fb,0x0541feb,
  44782. 0x072b659,0x0bc95d0,0x1534e04,0x032e190,0x0855f02 },
  44783. { 0x07314c4,0x1fdb642,0x05a987e,0x0bd68b7,0x1790615,0x1157d64,
  44784. 0x18519ae,0x102e205,0x1ab9497,0x0a8fcba,0x0313fbb,0x162f822,
  44785. 0x079d2f5,0x17fabb3,0x12339c2,0x089cef5,0x0216eb2,0x1f39b35,
  44786. 0x1471971,0x1779d8a,0x19dedd1,0x0570d42,0x0d49418,0x14fa5cf,
  44787. 0x081748b,0x0623d02,0x06ae3aa,0x03458a8,0x1ff078e,0x1261b7e,
  44788. 0x011b9e0,0x0290e96,0x1b49fc7,0x0fb99bc,0x0dfc1ac,0x1e455c6,
  44789. 0x0f8fe6c,0x1a90c93,0x01e5c70,0x19ea4ba,0x0292236 } },
  44790. /* 76 */
  44791. { { 0x18b29dc,0x06c053e,0x122b36e,0x0811d4c,0x117a202,0x095f48e,
  44792. 0x0b17aba,0x178fb62,0x0fda72f,0x19a3e8c,0x1831bc7,0x16813ce,
  44793. 0x1111374,0x0c71c6c,0x187a3c7,0x183e8e6,0x09d739a,0x13b8a5f,
  44794. 0x137d713,0x12e0396,0x0ae1c1f,0x0c37b96,0x1644e3b,0x1a30189,
  44795. 0x1e1f76a,0x1ce0e3f,0x1a78b6f,0x11830b7,0x10c44df,0x1934be3,
  44796. 0x17e0d76,0x161a2b6,0x197cfea,0x12a2f7c,0x1169879,0x1ca2028,
  44797. 0x05184e5,0x1834421,0x19ea85a,0x0b2ea43,0x07cfac3 },
  44798. { 0x00bc53a,0x010b39e,0x0d9e046,0x06fcea2,0x04b5ede,0x12bd0c4,
  44799. 0x157f68d,0x1307944,0x0ba1fdd,0x0b55dfa,0x09df602,0x0d3f8bb,
  44800. 0x059ce83,0x1559a16,0x1ee6b9e,0x0b3e3e4,0x1d69720,0x083648d,
  44801. 0x053b3fa,0x1b56612,0x1f12ee0,0x1dc9fa9,0x0ed91fe,0x14afc1d,
  44802. 0x18a7aff,0x1039861,0x1e7cab5,0x02fa0dd,0x19dcc95,0x06c3ddc,
  44803. 0x08525ca,0x088c101,0x0034af1,0x0e0bed8,0x10fc4ae,0x0199021,
  44804. 0x172a22a,0x12f8a7b,0x00af5c8,0x0fe3bbf,0x06ce3dc } },
  44805. /* 77 */
  44806. { { 0x0397830,0x06c1ad2,0x0c1b01f,0x19e8e66,0x0dd9290,0x0c4f462,
  44807. 0x14ea0a6,0x0a5ba6b,0x1563d81,0x0c812ac,0x17986de,0x1223d0f,
  44808. 0x1cf278d,0x081271a,0x1cd031c,0x01cb338,0x0614a0d,0x096a222,
  44809. 0x0c989a8,0x0ec11fe,0x1aa963e,0x14e264d,0x189e8df,0x1fffa4a,
  44810. 0x0dc5176,0x0e6862b,0x033bca8,0x16dbdf9,0x0559d9c,0x06ab77e,
  44811. 0x04b2f30,0x008396d,0x05f3fc5,0x10f04f2,0x08e7945,0x199a0b8,
  44812. 0x1c3b559,0x198f74a,0x085b4a9,0x04547a1,0x0851511 },
  44813. { 0x0ff19e2,0x0819ac3,0x180de0b,0x143b450,0x02c60da,0x1e3f76e,
  44814. 0x033f955,0x16165cf,0x01bc4e8,0x07b7cc2,0x0d719ea,0x16967be,
  44815. 0x0acc1f9,0x03b2231,0x184d80d,0x1c1612d,0x1977c7a,0x15fc885,
  44816. 0x050d655,0x0fe60aa,0x0ae527c,0x0e7b18f,0x10536c5,0x0d36699,
  44817. 0x161427e,0x1f9528e,0x057f04b,0x1d9050a,0x087162d,0x1709fdc,
  44818. 0x0f7f33a,0x1bc2911,0x0332ac1,0x1f3a66d,0x1388bb8,0x194406e,
  44819. 0x10ae069,0x1f50d0f,0x1b01165,0x1e4ef7b,0x08b1159 } },
  44820. /* 78 */
  44821. { { 0x1961d30,0x18d2217,0x123d2bd,0x10f58e4,0x1df968a,0x148366d,
  44822. 0x1e1f2c6,0x04ba65b,0x004abf9,0x0608713,0x0135300,0x0eb373e,
  44823. 0x1ab8711,0x09cb82e,0x1553982,0x0109201,0x033c9f8,0x0fbac3a,
  44824. 0x09e88dd,0x1575bcd,0x17ac2e9,0x1c4a560,0x159db51,0x005b338,
  44825. 0x0525bc2,0x19ea650,0x16afeb9,0x0b71795,0x05991b9,0x169c1a0,
  44826. 0x10c8dc7,0x08b1533,0x169e47a,0x0643315,0x0c60ade,0x18f9581,
  44827. 0x00232c7,0x1553cdf,0x1d165b3,0x066b11e,0x00bd864 },
  44828. { 0x0734189,0x0d45a3f,0x085f7a8,0x119fcbf,0x12c5ac8,0x01bb322,
  44829. 0x1353845,0x0a08894,0x0af9e97,0x1291184,0x11acef0,0x0187a61,
  44830. 0x1778b1d,0x0636fa3,0x16b97c1,0x11bae5d,0x19a2ee8,0x029898e,
  44831. 0x1324f8d,0x0701dd5,0x0e8ec4e,0x16546d8,0x15266c6,0x0ba93af,
  44832. 0x08c167f,0x06bbb9a,0x1c555b3,0x12cc64a,0x11d13dc,0x0746130,
  44833. 0x1319738,0x16b45fb,0x095fe66,0x07d5096,0x00ca196,0x104cd31,
  44834. 0x11c32c9,0x03e8fa1,0x0641f6a,0x131f9b2,0x0466505 } },
  44835. /* 79 */
  44836. { { 0x14a5efa,0x009e635,0x099531b,0x163a0f6,0x0481989,0x0e34e06,
  44837. 0x19b3a2f,0x1a82172,0x02c2531,0x0a67d51,0x028403d,0x101195a,
  44838. 0x09cb5f1,0x172ed22,0x0d494e3,0x107997d,0x085bedd,0x0531200,
  44839. 0x189571e,0x05b59fa,0x058fe79,0x0310310,0x020dc64,0x02cb183,
  44840. 0x15e83ed,0x0a14b30,0x1df4a35,0x16a9364,0x175df34,0x13edc1d,
  44841. 0x10babc4,0x02ff772,0x160df6d,0x1e49827,0x076fdbd,0x1fa10c6,
  44842. 0x0018789,0x01c7cc3,0x0a0305f,0x0957352,0x00c4357 },
  44843. { 0x120cad0,0x199260e,0x0229dba,0x1318c22,0x10decb0,0x0369b6c,
  44844. 0x14e71bc,0x12f4dd3,0x0bc0da1,0x06cbc5d,0x0b1739b,0x0380a0f,
  44845. 0x155948b,0x02a4bf5,0x151c593,0x029c657,0x00f4d59,0x0154e26,
  44846. 0x1d67c0f,0x18a08d4,0x047e772,0x0534d64,0x19f5cca,0x0916661,
  44847. 0x17d0c30,0x167546a,0x0103dee,0x0c0069c,0x1f1790e,0x08c9d42,
  44848. 0x0da08f6,0x0b90b2e,0x0e9b66c,0x1081153,0x11e99e7,0x0845945,
  44849. 0x09023fa,0x13d0ce0,0x156e403,0x1e24e4d,0x0324999 } },
  44850. /* 80 */
  44851. { { 0x0834915,0x1576b3e,0x193599f,0x1578bd6,0x1f77aa6,0x0b1008c,
  44852. 0x0f2d897,0x184e53d,0x0699fd9,0x1771279,0x153db02,0x10e8571,
  44853. 0x16e1eb5,0x0a64bb6,0x049c430,0x1d4cafe,0x135f6d9,0x0489c81,
  44854. 0x1ad4019,0x16e0920,0x0e4f668,0x07043b7,0x1965a68,0x13b26c0,
  44855. 0x1bf3f2f,0x1e77c80,0x06d2678,0x16350ca,0x1bcaaaf,0x09fdf96,
  44856. 0x0da02e5,0x12e760d,0x12cc566,0x1b63218,0x070cebc,0x0a6a69b,
  44857. 0x10ffd81,0x031d290,0x0ae4791,0x097e318,0x057ea2b },
  44858. { 0x0a0f2f2,0x0f0b145,0x12a803d,0x0a1c8d7,0x0c7e75c,0x116216c,
  44859. 0x11e6a92,0x0052f56,0x014baa2,0x0798475,0x0f30bad,0x1a28d28,
  44860. 0x04a901b,0x176ac40,0x0497fbb,0x01ef976,0x0f99d18,0x0328164,
  44861. 0x1603187,0x0a72322,0x1ee3e53,0x1493880,0x1f89e01,0x14e4e2e,
  44862. 0x040a1fa,0x0a9bd05,0x0931d6c,0x05db9c0,0x0f1c223,0x1305a9c,
  44863. 0x0bb688d,0x17c60fa,0x1511e98,0x1705a26,0x19026eb,0x0e484ed,
  44864. 0x1ff1f30,0x061c93b,0x0d7269e,0x08dd4f2,0x060480b } },
  44865. /* 81 */
  44866. { { 0x072ece3,0x03eb31c,0x03e0c42,0x1b2ab6e,0x1f29be7,0x1caddc2,
  44867. 0x13f1e73,0x0436a16,0x1dbffa6,0x171dac6,0x0ae976e,0x0501c04,
  44868. 0x1c0e61d,0x00c0a24,0x0b9445d,0x0a90af1,0x040cf55,0x1058994,
  44869. 0x03382c3,0x1da36d7,0x1e3d800,0x0abc6ae,0x0d77ff7,0x14ad68e,
  44870. 0x0237469,0x173fbf2,0x0636442,0x0bc646d,0x13c7c7d,0x0950318,
  44871. 0x196dbfd,0x1525bd3,0x02fe20d,0x0885dad,0x1f4f448,0x0683668,
  44872. 0x00c16f2,0x082f6da,0x0233316,0x1a7351f,0x00774a0 },
  44873. { 0x1b6c106,0x0c0d5f1,0x02dceb8,0x1f1bc2a,0x0ebe163,0x1aa41b2,
  44874. 0x0e0bdbc,0x02d9eeb,0x13ac7ac,0x1069031,0x1c8abea,0x0cd0522,
  44875. 0x135c680,0x08aa2aa,0x0507984,0x1c7eee7,0x038bf5d,0x10b893f,
  44876. 0x0bed076,0x1fbe063,0x066332c,0x08c3de4,0x11a24f2,0x0593933,
  44877. 0x06744a6,0x0a3ba82,0x1658b06,0x0d0cdc5,0x0cdf4c9,0x046f9bc,
  44878. 0x0c9227b,0x0680ff4,0x060709b,0x148689d,0x0565544,0x07a6fa4,
  44879. 0x1ab9227,0x11e981d,0x0052e58,0x0a84864,0x0081519 } },
  44880. /* 82 */
  44881. { { 0x17b2108,0x1b6c4fd,0x06abe48,0x195aebf,0x1ecc83c,0x10ed089,
  44882. 0x0ac56d3,0x0c5ef8e,0x10315c3,0x0957577,0x0bf8fd5,0x01dbe4e,
  44883. 0x0811e14,0x03c21f7,0x15e6fda,0x164b733,0x0fd1d9b,0x06735aa,
  44884. 0x0c6eb5d,0x161c42b,0x090db20,0x07adc26,0x1528085,0x14d9d92,
  44885. 0x1bf52fc,0x1b7a2cd,0x167937d,0x06c7891,0x0cf17ee,0x1c276b2,
  44886. 0x120c117,0x1ec55b4,0x002a167,0x06500c2,0x0fcda9d,0x1a593c3,
  44887. 0x1691c42,0x07cea0f,0x0e1d3a3,0x0f18589,0x05abf21 },
  44888. { 0x1b3bccd,0x1cb35f9,0x12a91dd,0x017c7c1,0x0047e0f,0x1ea8218,
  44889. 0x00ece31,0x1f99707,0x1946fd5,0x1bf1dd7,0x103a1f9,0x0f0bd3d,
  44890. 0x0579baa,0x0450c69,0x0f155f3,0x1f9fdb0,0x1af25be,0x0cdcb72,
  44891. 0x031c6d8,0x0ba2bd3,0x0da14f0,0x0d3bf31,0x0207e64,0x1547042,
  44892. 0x0c781cb,0x1fd8e37,0x1795366,0x0a45ecb,0x0d14307,0x0ab9a27,
  44893. 0x16bd741,0x12b95fb,0x035b31f,0x07adf98,0x1d0d8de,0x128fccf,
  44894. 0x1270b9d,0x0fbe56a,0x1a9200a,0x10e9b22,0x015ad15 } },
  44895. /* 83 */
  44896. { { 0x0588ae4,0x1176755,0x08c8037,0x1146e34,0x152ebc5,0x1182222,
  44897. 0x0a4d1c4,0x05ba01d,0x1e4b183,0x1dfd33e,0x07a10eb,0x06836d1,
  44898. 0x0829216,0x10fa717,0x05aeef5,0x13b8a3f,0x08404c2,0x0caa103,
  44899. 0x08c5ff4,0x1c704e8,0x1162c7f,0x0331a41,0x18282bb,0x000309f,
  44900. 0x194d107,0x0c2fe15,0x0ff87ef,0x0e4332e,0x0743520,0x1558fd8,
  44901. 0x049922d,0x188dca7,0x1bbdaad,0x12b7f91,0x147c03e,0x0c1b71b,
  44902. 0x066725f,0x040af5c,0x0658c41,0x194a5d0,0x03f9c4c },
  44903. { 0x0ce637e,0x1594b99,0x1377fcd,0x1beba4b,0x01a15f2,0x0156cbc,
  44904. 0x014b62c,0x1d2343a,0x0cfbab3,0x12f9dde,0x1badd4b,0x17aec29,
  44905. 0x1a60d2c,0x06ad3c9,0x124610f,0x04289a8,0x175cdba,0x1112167,
  44906. 0x02e65d9,0x0e0bcf1,0x0132a20,0x00763bf,0x19384b3,0x035360a,
  44907. 0x14df6b6,0x1ad58e0,0x11d2096,0x1fb2fe0,0x0312238,0x04109ed,
  44908. 0x0365581,0x09a618e,0x0486727,0x17734ef,0x1c54704,0x1b79571,
  44909. 0x068d893,0x031c5a3,0x15d2d77,0x1ac447e,0x06479da } },
  44910. /* 84 */
  44911. { { 0x05f2b26,0x02279d8,0x1db15a4,0x150173e,0x135a294,0x087b575,
  44912. 0x1f8a10a,0x0ef1073,0x1026a58,0x10e7d91,0x1fe70dd,0x0d6c5cb,
  44913. 0x1676892,0x0588e2b,0x19b3480,0x07dfd75,0x15672a0,0x16e42bb,
  44914. 0x06eb58e,0x1c0e95c,0x199c0ca,0x10eb84e,0x0ff9246,0x003b382,
  44915. 0x1ded665,0x1fbbb62,0x070cabb,0x1b4dd94,0x1683e81,0x0eaae2b,
  44916. 0x11d4212,0x1bf31b0,0x0392e9c,0x0d2b24f,0x00bd936,0x05f5af3,
  44917. 0x037b98b,0x01dedbd,0x0125fdf,0x129e10c,0x01fe09f },
  44918. { 0x048cc63,0x1f5573b,0x1c51269,0x02cf9f4,0x13ea251,0x1fa2ac8,
  44919. 0x048f194,0x10df917,0x181a16e,0x0abb0cd,0x1919d36,0x0096790,
  44920. 0x1a0c7e8,0x0b0b2cc,0x0204d28,0x04651f9,0x1690a65,0x11b3754,
  44921. 0x0f240a7,0x0652c09,0x0d2b415,0x0a57155,0x1be7866,0x0217deb,
  44922. 0x08c527f,0x0304f15,0x1b19efe,0x07b96b0,0x0cc25d7,0x01fd422,
  44923. 0x14fd869,0x0e9d66c,0x14e7eea,0x007816b,0x1c1b749,0x09e66ac,
  44924. 0x1d83bcb,0x03b4a67,0x149abbb,0x10db6c4,0x04de957 } },
  44925. /* 85 */
  44926. { { 0x1eac2f7,0x1e98a9e,0x0a39219,0x156c3b3,0x0084778,0x1bd96ad,
  44927. 0x1be582a,0x0f3e76e,0x0cfdf4f,0x059802b,0x0e3d2c0,0x1c2a635,
  44928. 0x01d0701,0x0e3bce8,0x1e52356,0x0a6e20f,0x0bc8267,0x03e4ca7,
  44929. 0x02eb530,0x09a9dc9,0x1058110,0x1adfe4e,0x1e63382,0x13f5016,
  44930. 0x0898d30,0x157e3e5,0x16b2ccf,0x0489e44,0x0f31750,0x06fe2d9,
  44931. 0x0d3547a,0x149af7c,0x049ba6b,0x015a19f,0x131ef68,0x142ec1e,
  44932. 0x0435275,0x11b53f2,0x06030df,0x117cc6d,0x01c9441 },
  44933. { 0x1dc1414,0x1098984,0x14dd0e8,0x1887926,0x060765f,0x0fbce70,
  44934. 0x081eb7d,0x194dfe6,0x085d4cf,0x18c58fd,0x0656adb,0x0e5cc7d,
  44935. 0x02f5c42,0x1415980,0x0682792,0x0fe2c24,0x11b9714,0x1415b2e,
  44936. 0x029ff89,0x0784184,0x0726499,0x0c7338b,0x067272e,0x1688141,
  44937. 0x0d673fe,0x1e2ad01,0x04946d2,0x1e7f53c,0x1338ea3,0x023a502,
  44938. 0x12dd76f,0x0f613ed,0x0b4044b,0x1a3049e,0x0862010,0x04cecfb,
  44939. 0x098ceac,0x028a110,0x0d6ea5e,0x1656aa4,0x0611bfb } },
  44940. /* 86 */
  44941. { { 0x00ad2a1,0x152af78,0x035ef6e,0x1c29452,0x09efa85,0x158b4a1,
  44942. 0x11da3a4,0x0607694,0x111ec81,0x1888de6,0x149ec99,0x0e05117,
  44943. 0x060e425,0x0cd01e0,0x033ca8f,0x11095e5,0x12df318,0x05dbe46,
  44944. 0x0eabac8,0x1428c5c,0x1d77e2e,0x0221dc2,0x0cd4d60,0x09dd37a,
  44945. 0x0448255,0x0c7c0f7,0x1b9aa86,0x165ddd3,0x0c5944e,0x1402613,
  44946. 0x1f1e96a,0x105562c,0x0ef2da5,0x110d2d0,0x11d80bf,0x1cb4556,
  44947. 0x1370298,0x0e59dc1,0x0aa345a,0x0881d67,0x086e6c5 },
  44948. { 0x1793d9b,0x0199085,0x1b3bb78,0x023bb6b,0x179fade,0x0985b27,
  44949. 0x16a49a2,0x165ee7f,0x1fe4fd1,0x1556cbe,0x1372201,0x163b254,
  44950. 0x15073a5,0x1e4bb6b,0x1e32f62,0x04d8115,0x1b163ce,0x1305a55,
  44951. 0x12c7ec1,0x060153b,0x13d39c8,0x066d4ad,0x0cd6965,0x0fd590e,
  44952. 0x1d7d4b3,0x1558fcb,0x0883bbe,0x07a5d74,0x0828c8a,0x048379f,
  44953. 0x004c963,0x10b56ef,0x032616f,0x05b0be4,0x064a30a,0x1ae4b2e,
  44954. 0x1233b82,0x18cb5e1,0x049b735,0x17233f4,0x083867e } },
  44955. /* 87 */
  44956. { { 0x0474edb,0x1f39f11,0x06b9dd3,0x083509c,0x0a76639,0x16eb719,
  44957. 0x0a6b671,0x0ba4e06,0x114f8bf,0x062520a,0x19ee400,0x146fa44,
  44958. 0x0e3ce2e,0x08e927d,0x1d4c054,0x036f024,0x054263a,0x13e0a6c,
  44959. 0x0b82c81,0x1080363,0x09fc20c,0x0d840fa,0x1cca804,0x138dbf1,
  44960. 0x123fb95,0x0830f40,0x1200387,0x0651b8f,0x059a9aa,0x11bc121,
  44961. 0x0dd61da,0x16fded8,0x1ada8b5,0x0a64f91,0x0dbaa4f,0x1e047ed,
  44962. 0x1fb6389,0x1aa0a6f,0x0ce7a27,0x145cc51,0x04b26bb },
  44963. { 0x1318454,0x18e5a2e,0x12db4c2,0x1fae86d,0x123b749,0x053a308,
  44964. 0x11c995a,0x03c6221,0x11c84fd,0x02ef091,0x00f5572,0x0dcc108,
  44965. 0x18a5f8d,0x0d8fd5f,0x16db84e,0x1b9c072,0x0c33cfe,0x07f36b4,
  44966. 0x12e4444,0x00703f2,0x0eb71d9,0x0096e63,0x1c2a3aa,0x1219457,
  44967. 0x004137e,0x02d2cf4,0x1f22897,0x1d6bf80,0x04663cb,0x129d2ec,
  44968. 0x1f00270,0x12216d4,0x0b15073,0x07c6a80,0x0931042,0x0b0c0fb,
  44969. 0x0b901e6,0x01ece1e,0x057180b,0x18a592c,0x04d697b } },
  44970. /* 88 */
  44971. { { 0x1a8fb40,0x18f7877,0x0273836,0x16b7473,0x09021c5,0x0e8cef9,
  44972. 0x1ec5602,0x1c351ad,0x14c1219,0x1bc3db9,0x1c1789a,0x02d029d,
  44973. 0x026417e,0x07cbcb7,0x04d0b6e,0x0843689,0x05ebf84,0x117c3c5,
  44974. 0x052914d,0x122dafd,0x1693e71,0x11d708c,0x06062ee,0x0d1009d,
  44975. 0x14be957,0x1c57633,0x13e1093,0x144c0e9,0x0ce6ab0,0x1dcea33,
  44976. 0x02f6f24,0x192400f,0x1f15a98,0x078d1d9,0x1434e1c,0x0f3a21f,
  44977. 0x04e785a,0x0920ecf,0x1360298,0x143cd91,0x076ca87 },
  44978. { 0x02e48b7,0x1fdab70,0x07190d5,0x079813d,0x1bd14b1,0x034e787,
  44979. 0x090d490,0x153b6be,0x02c3b01,0x03c0b2e,0x15b6b7e,0x0f89cd2,
  44980. 0x08e549e,0x1deb05b,0x1fa54e2,0x18ca7e5,0x16b059d,0x1ca97c2,
  44981. 0x0ddffa6,0x0c044b6,0x08c4d3f,0x145ff48,0x1a831cc,0x11ebe5a,
  44982. 0x0a2d3bc,0x0286735,0x0c91094,0x0e42688,0x1b3ce5f,0x13351e9,
  44983. 0x0485f84,0x182ceea,0x1b5e43f,0x1c4a53a,0x0188dfe,0x0a2b24e,
  44984. 0x0be3e37,0x1303a99,0x0def854,0x18cdb47,0x027e7f2 } },
  44985. /* 89 */
  44986. { { 0x0a15883,0x1b2d6f3,0x0ccd8e3,0x18cd5fb,0x14a7e68,0x1896f2e,
  44987. 0x0daaf4f,0x020c40f,0x037b878,0x037fca8,0x13db4c7,0x1964c95,
  44988. 0x02c0d44,0x195f3c6,0x0eb1807,0x1301c2c,0x05a1636,0x18e31e6,
  44989. 0x1724d26,0x059fd12,0x12203e9,0x0c20f63,0x1dce383,0x0bf52c2,
  44990. 0x1d7642d,0x074b0b4,0x070f80a,0x154eed8,0x0d54092,0x0b2358b,
  44991. 0x1664f71,0x0e0dbe9,0x0b27fb5,0x035cbd0,0x05c33a7,0x013d322,
  44992. 0x13c85f4,0x07215f2,0x194a3aa,0x06f0648,0x002e964 },
  44993. { 0x078ea1f,0x0056ed7,0x1a5a455,0x1af6ce1,0x11a1b74,0x0034132,
  44994. 0x19107dc,0x18ff326,0x07d7520,0x1cbeb75,0x184b863,0x1404d39,
  44995. 0x020faa6,0x1c9041a,0x042b2a1,0x0886c4b,0x0637561,0x1bd241c,
  44996. 0x0e05023,0x0c293de,0x140607c,0x026bc29,0x1ccefd6,0x1776dee,
  44997. 0x1b0109a,0x04d43b0,0x1fd4a28,0x09d6493,0x00ae3ce,0x0f6c170,
  44998. 0x1e821e0,0x042f1df,0x04c1b25,0x09d3f43,0x0a8a754,0x1f983cc,
  44999. 0x1919062,0x1c5ca70,0x149f7b6,0x1b49e2c,0x0739f53 } },
  45000. /* 90 */
  45001. { { 0x04adc5f,0x1a54449,0x15b5e97,0x0d5031e,0x15646c1,0x0afcaa4,
  45002. 0x044a5de,0x0001d89,0x1d19c54,0x1a43a9e,0x044ad0a,0x06d640b,
  45003. 0x0616fa2,0x143d24a,0x0f597cf,0x1a0ccd6,0x001045f,0x0538ba5,
  45004. 0x0a97850,0x0a06262,0x0623b63,0x0254b5c,0x09e712d,0x16007ab,
  45005. 0x19d659a,0x18d3d19,0x18e09bc,0x0e5e618,0x1090cdc,0x1c8637b,
  45006. 0x092d39c,0x120dd7c,0x1ac6c36,0x0282d2c,0x01b6ee9,0x14734fe,
  45007. 0x058c413,0x0cc8f0e,0x03a120e,0x1ff441c,0x0020c23 },
  45008. { 0x1c74661,0x1256d57,0x0194483,0x064eff8,0x17bbcf6,0x0e73cc9,
  45009. 0x073dadb,0x1428209,0x17b161b,0x1c6b5a9,0x043ec96,0x086352c,
  45010. 0x0922218,0x0feef3b,0x07b2747,0x00c61bd,0x04d42d8,0x1e995fd,
  45011. 0x09137d2,0x0ae054c,0x0dfb388,0x16a2ac9,0x137b747,0x09c0371,
  45012. 0x1f45bfb,0x0d8070e,0x0a1b885,0x1e97bda,0x137e6a8,0x0a43b54,
  45013. 0x08e024d,0x10261ee,0x15278ba,0x010fc20,0x1a48e2a,0x158db88,
  45014. 0x1d8b4f8,0x03d88cf,0x073bc88,0x0a7f24d,0x076e7bf } },
  45015. /* 91 */
  45016. { { 0x1ebd187,0x1421413,0x16ed7c4,0x176cb55,0x0d3320a,0x12c34ac,
  45017. 0x1d969c8,0x1576084,0x18f0986,0x11f99fc,0x1fd40f6,0x0f4f5d7,
  45018. 0x0541180,0x012fb8d,0x11ddb2a,0x1e4964b,0x1edff7d,0x0606f3d,
  45019. 0x197c7ed,0x161e842,0x1ae3da8,0x1bb98f9,0x17cffdc,0x07c14a4,
  45020. 0x1d7e719,0x1232668,0x0edacee,0x1bf0954,0x1f37828,0x1c4bd50,
  45021. 0x11eea12,0x1cee675,0x07960cc,0x00d10b7,0x1aad426,0x1a9a8da,
  45022. 0x1cbb80e,0x009612b,0x1bc247b,0x04e572d,0x079e7ad },
  45023. { 0x130caae,0x0b86e47,0x1bd0f36,0x0214dd7,0x05cabcf,0x0a30b6c,
  45024. 0x018fb1c,0x130c783,0x1519e3a,0x0286d85,0x0c4f587,0x12c6c99,
  45025. 0x09f39b8,0x112a3db,0x19f607c,0x16199be,0x1b9d67d,0x1b8abd5,
  45026. 0x025246d,0x144b751,0x00dcccc,0x1e3d13f,0x1da2481,0x1a86503,
  45027. 0x08fbe0f,0x0049a57,0x0d5c83b,0x0bb23ee,0x1d7beda,0x0c84e6f,
  45028. 0x0cacbd8,0x094073c,0x0c10232,0x0c7ee0f,0x197b6c3,0x1ba787a,
  45029. 0x0fe5005,0x048b642,0x1aa50cb,0x1589817,0x07f8c37 } },
  45030. /* 92 */
  45031. { { 0x1ac05e5,0x00f2a21,0x0094cfb,0x099b1a7,0x1a4a4da,0x1fcf15e,
  45032. 0x0302e22,0x1b90db1,0x0b53811,0x06b8ee8,0x0eae90d,0x01a5478,
  45033. 0x1e65504,0x1b0b08d,0x1102526,0x09f4057,0x06e279a,0x18e16a1,
  45034. 0x0c196b0,0x14b5447,0x0890535,0x17e2975,0x16aa28c,0x1bb5a45,
  45035. 0x1eca79f,0x137ad2e,0x14aacec,0x023e0bf,0x1cd81e9,0x13edf9b,
  45036. 0x03176b3,0x121a2d7,0x00e44e7,0x0c4a707,0x0bb793d,0x1e2bcd1,
  45037. 0x1c92a74,0x1024ccf,0x1f0bebf,0x1552e1c,0x01d7703 },
  45038. { 0x10062a9,0x0640e9f,0x02eaa29,0x11b2d44,0x031eb2b,0x05e880f,
  45039. 0x0637e19,0x028cdbb,0x04413b6,0x102fac9,0x1557e2e,0x141bd34,
  45040. 0x1151a67,0x1725a96,0x10bc25c,0x1564759,0x0ec7184,0x1d5aed5,
  45041. 0x11fda46,0x11687cf,0x07f4ce0,0x05bb621,0x148394c,0x047d7b8,
  45042. 0x12069e4,0x0673e9a,0x00d37c5,0x16bc73d,0x0305ac6,0x194aa23,
  45043. 0x104f72f,0x1fc699b,0x02cb2e1,0x1ad7db4,0x1744447,0x13a9588,
  45044. 0x07f296f,0x17b1e6a,0x021c717,0x1d92784,0x00a2c40 } },
  45045. /* 93 */
  45046. { { 0x15747db,0x01c27d7,0x01ac26f,0x0d80d57,0x1bad608,0x1e0aa39,
  45047. 0x020ba79,0x17f480d,0x155977a,0x0a99368,0x077ac0b,0x140bb50,
  45048. 0x11063a9,0x0925b08,0x01b929d,0x1d72135,0x07a4ab2,0x10a017c,
  45049. 0x171802e,0x0e43a9a,0x1dbf7d0,0x14f944f,0x068bf66,0x1bcde0e,
  45050. 0x0e66dec,0x139faee,0x1f6ae7e,0x042e24e,0x074bab6,0x024fb62,
  45051. 0x0cdb4b7,0x0eddda0,0x0017e1f,0x012e9ee,0x170136a,0x0772e2e,
  45052. 0x14b05e4,0x14bf1ea,0x121f9b0,0x08cad93,0x02efb45 },
  45053. { 0x121c064,0x0958045,0x0a7a91c,0x0494e0c,0x1186fe4,0x1a7857e,
  45054. 0x0cd026d,0x052c86b,0x17ec9e6,0x0b2d521,0x183421a,0x0ce7898,
  45055. 0x0adda14,0x1f982bd,0x19599c2,0x0dec016,0x0403ce8,0x13f82f4,
  45056. 0x1100685,0x00e7520,0x007ec05,0x1c14a73,0x05ac798,0x19ee08c,
  45057. 0x0325269,0x09d103c,0x0fa339f,0x1282283,0x17053d2,0x0c69bab,
  45058. 0x0374e2b,0x1954cc6,0x1a68fb3,0x021a86d,0x1fc7a54,0x17d97d5,
  45059. 0x1d2d760,0x08b36a8,0x047927d,0x19c8c51,0x0337532 } },
  45060. /* 94 */
  45061. { { 0x000bb9b,0x08c299d,0x1a14fc4,0x1c8becc,0x0d2ffba,0x1771269,
  45062. 0x06a1752,0x0dd35c2,0x1034185,0x05d0f0d,0x04d27c6,0x02f04e6,
  45063. 0x15a9ac8,0x0a2b8ad,0x0f7f529,0x1a5d582,0x03c5daa,0x1d2fba1,
  45064. 0x0d6dda9,0x090772a,0x1e9b30a,0x127fc39,0x04ba6b6,0x07420ab,
  45065. 0x02d8472,0x0700ab3,0x0e3b6b1,0x126a92f,0x18fa70b,0x020d1ce,
  45066. 0x07d86d9,0x081a2b1,0x141d756,0x02f850a,0x08dfc28,0x10c5328,
  45067. 0x0bb2890,0x05801a3,0x0cafff6,0x0bba99a,0x0192a2b },
  45068. { 0x05ced07,0x1b3141b,0x147d8d5,0x160bbc3,0x029f32f,0x0053d50,
  45069. 0x0e6f2fd,0x08eda2f,0x09bb50a,0x18d9504,0x0989e06,0x1776f2b,
  45070. 0x1b9389a,0x19a7e0c,0x13fd83e,0x10e72a5,0x092387d,0x179d5ca,
  45071. 0x0483335,0x00a7ccd,0x14f0a8f,0x05b1d4d,0x0fbcb75,0x1d04252,
  45072. 0x0ede151,0x1d0cd58,0x0c20e2f,0x1f74181,0x1c11bea,0x13d64ff,
  45073. 0x1e0af56,0x12b9810,0x18bfd95,0x1786302,0x028fe30,0x14d0da9,
  45074. 0x1d9b31b,0x1d5d578,0x109a30c,0x1127781,0x0632e22 } },
  45075. /* 95 */
  45076. { { 0x1a1ccca,0x08e900a,0x0f0c721,0x18fca45,0x0efe290,0x155829a,
  45077. 0x0755463,0x02e16e8,0x1bc85e2,0x132b0cb,0x1e2ca6b,0x083c039,
  45078. 0x18ae131,0x134a423,0x0b2d64d,0x1b15c5c,0x10fc31b,0x075abdd,
  45079. 0x09939e2,0x1debad8,0x0d86dec,0x064e5cb,0x1bea15b,0x12307b4,
  45080. 0x1681327,0x0b516d8,0x00e0f5e,0x007e704,0x0c6fedf,0x0b7f8e8,
  45081. 0x06d6291,0x114d57b,0x1589805,0x0b78c92,0x0b160fe,0x0e673ea,
  45082. 0x1a7e9ea,0x16f6c7e,0x135173d,0x182ba39,0x068c3d9 },
  45083. { 0x0b392b7,0x13132f3,0x14259f8,0x1eeebb2,0x0ec1d9b,0x128a7be,
  45084. 0x0f3535d,0x039c2d5,0x00de72e,0x037acd9,0x1ec0cf6,0x079a35b,
  45085. 0x0ca66e4,0x02f22be,0x0d10d00,0x1b545b6,0x1165681,0x0db3d3c,
  45086. 0x00451cc,0x1cf757e,0x0961c32,0x1769d8f,0x019bf85,0x07a4dcc,
  45087. 0x0298ef6,0x0b6c927,0x01506b7,0x17d41bb,0x02f9719,0x006fccc,
  45088. 0x0b3be54,0x18be0ed,0x0876e63,0x09cb5ae,0x0b96c8f,0x14abc25,
  45089. 0x0ec6747,0x17dd9b1,0x01a9427,0x1dc4665,0x08f2055 } },
  45090. /* 96 */
  45091. { { 0x02c1af0,0x15cf1dc,0x0991292,0x0fe595c,0x1c65e9e,0x0c3ea37,
  45092. 0x0b02980,0x0c69fd5,0x1e393b3,0x1e9f99a,0x0eb3389,0x1801033,
  45093. 0x119c9f7,0x1c55330,0x1d062d6,0x15d2a7e,0x157372a,0x0ffd4a2,
  45094. 0x16ce162,0x1af0091,0x1c1c937,0x0fb78fd,0x144321b,0x1e1419d,
  45095. 0x0bd89a2,0x0f5a457,0x08d9d0e,0x1cbabf4,0x17d2d8a,0x15059f8,
  45096. 0x05040e9,0x0823b31,0x033f68a,0x1b3d179,0x02cc862,0x0cffd9d,
  45097. 0x0319bf0,0x112a079,0x0c8b810,0x192681a,0x01292c8 },
  45098. { 0x186463d,0x1aac381,0x05ffd7a,0x0406e3b,0x14bbc2b,0x00ce2d6,
  45099. 0x115c42e,0x082366c,0x0cf04ad,0x05da16b,0x0e7b043,0x18eccd2,
  45100. 0x075d819,0x100c23f,0x116b04e,0x065c90e,0x1021c72,0x027b825,
  45101. 0x12c15e0,0x1cb1415,0x02952c9,0x19dab0f,0x0548ee2,0x1f3746b,
  45102. 0x0df0079,0x11419c2,0x087aaa5,0x10463f8,0x0a2b907,0x02a7c57,
  45103. 0x18e8bab,0x061a384,0x075ed77,0x1c80040,0x1b57ecc,0x1559689,
  45104. 0x1011293,0x0a35617,0x05d9249,0x057d704,0x07c7876 } },
  45105. /* 97 */
  45106. { { 0x07902b6,0x1eb7d83,0x0602e3d,0x07a2e6b,0x12823a4,0x1a0eeed,
  45107. 0x1ec4965,0x0b80c59,0x14033f9,0x11c8d83,0x026e31b,0x0146d0b,
  45108. 0x123831d,0x0911487,0x11d3525,0x03e75c6,0x0d6222e,0x0a6d58a,
  45109. 0x0fc234e,0x01f9bca,0x08f58f0,0x17383f9,0x156645e,0x11cc0f8,
  45110. 0x0a0ba06,0x0120b35,0x1f5f87e,0x004e27c,0x0a328f6,0x0aa026b,
  45111. 0x0a9f095,0x131219a,0x12e3264,0x0590506,0x0513b28,0x19e440f,
  45112. 0x12f4e09,0x0c6e03a,0x1a07572,0x009b09b,0x0694035 },
  45113. { 0x1407206,0x1d9b372,0x0a33e2d,0x1e1b11f,0x1ecf54c,0x1397378,
  45114. 0x19523dc,0x0d0dfdf,0x081ab44,0x12989b9,0x1d10235,0x1e1c9c8,
  45115. 0x1f52cb5,0x124839b,0x109ace9,0x1a0e33c,0x19b4980,0x192bb60,
  45116. 0x1c9cb2b,0x068c501,0x11c991f,0x07a3479,0x1e39829,0x1089b12,
  45117. 0x0a32990,0x015c3bb,0x12e5456,0x14aae01,0x11adbf8,0x19b28a5,
  45118. 0x1beac6b,0x1f7a687,0x0ebff92,0x00f9a11,0x0c06df6,0x0265f3f,
  45119. 0x1a6b30e,0x0287035,0x0551ab6,0x04f78bf,0x06da9e0 } },
  45120. /* 98 */
  45121. { { 0x09490ce,0x172612e,0x0e0487b,0x061bed0,0x096ec4a,0x149b475,
  45122. 0x01f8292,0x1e7cd8c,0x04bc262,0x0582495,0x10d3ff6,0x04208c1,
  45123. 0x0d0846a,0x146f99e,0x1fde990,0x0ec25ef,0x0442182,0x08862a8,
  45124. 0x126f340,0x0bf9d22,0x13dc9d2,0x06e7e30,0x1c95847,0x1ea39ca,
  45125. 0x17e8897,0x05a8acf,0x053a302,0x1f477e6,0x07538f3,0x108abaf,
  45126. 0x083a855,0x1239080,0x1e0a951,0x1568568,0x02eb3c0,0x1e1a44d,
  45127. 0x058b8e5,0x0635620,0x1644a81,0x17366a2,0x0773b40 },
  45128. { 0x031cfd2,0x1966e1b,0x1ef003f,0x0700ee6,0x14c4c2d,0x0529380,
  45129. 0x185a8ce,0x1bdac00,0x1b32cab,0x0719836,0x0c5f2b4,0x11d54e1,
  45130. 0x0e33673,0x1cf9a9f,0x1d2aa35,0x075a7e5,0x0d9576f,0x03897b5,
  45131. 0x06caf38,0x0f30a51,0x0a30e42,0x06ed496,0x01763e5,0x0925bb2,
  45132. 0x1d475d8,0x05ecc48,0x0934579,0x1c0d4b9,0x0eabbd3,0x0a7592a,
  45133. 0x0f11c97,0x181daa2,0x1394ace,0x1573618,0x0166efe,0x0efc1f3,
  45134. 0x033fd13,0x092aa34,0x13dd770,0x10b8ad8,0x012b463 } },
  45135. /* 99 */
  45136. { { 0x12951de,0x0df5ec9,0x1252043,0x04b54d3,0x16959d4,0x197846c,
  45137. 0x07013b2,0x058bf89,0x02250b8,0x03a7866,0x113876b,0x134a75d,
  45138. 0x0d96a43,0x0824cd6,0x0f2ae6a,0x1675f86,0x06654d9,0x197e66f,
  45139. 0x018eba2,0x1e50b87,0x1f88f4a,0x1f237f5,0x08dccdc,0x1356fda,
  45140. 0x1672c3c,0x1063a8e,0x03f8480,0x038a226,0x13e56ec,0x0017a97,
  45141. 0x006b609,0x1494c95,0x089ab7a,0x0b1f91a,0x198767c,0x0e143f6,
  45142. 0x0e55331,0x034df08,0x1505c5f,0x0bcfb11,0x061c193 },
  45143. { 0x092ae43,0x116cd9a,0x0168b9c,0x0a0a71e,0x1ef89d9,0x0555b18,
  45144. 0x1962080,0x02f5cef,0x0eba4b1,0x0396090,0x1872e0a,0x0590748,
  45145. 0x065c243,0x05c9c79,0x16cd0d3,0x0fb8062,0x0c58c4c,0x082df95,
  45146. 0x05acde3,0x0a03bab,0x0c30d2e,0x0fe5c48,0x0a141b2,0x06c3e19,
  45147. 0x0f4617c,0x1d71e85,0x0168d72,0x03ef6e3,0x1c01382,0x1af8f9f,
  45148. 0x17ef440,0x116491d,0x0628af5,0x0e5703a,0x0741232,0x071ac84,
  45149. 0x0ca1877,0x11ed1c9,0x16e51d7,0x1e4e3a7,0x027ad0d } },
  45150. /* 100 */
  45151. { { 0x05b5aed,0x1ed3c98,0x1a9e78e,0x08b331a,0x0c67d4a,0x1f5b801,
  45152. 0x1874c3d,0x08990ab,0x0147d1c,0x0c53f4f,0x1503b70,0x0c31912,
  45153. 0x003ea99,0x1f35fe9,0x0ef8829,0x0886f4a,0x064ecc1,0x164a43f,
  45154. 0x13be171,0x0f240e6,0x0bd5729,0x18eaf0f,0x1e83539,0x091ad6d,
  45155. 0x0b1e64d,0x06a7ed1,0x159b880,0x10543c0,0x1366a17,0x186d2d2,
  45156. 0x0e0a8f1,0x0348e6e,0x03fbd2b,0x010747f,0x1019ff8,0x0bafdf1,
  45157. 0x0acfb66,0x1437ef7,0x150bfb1,0x04edba2,0x05d9b5e },
  45158. { 0x13e472e,0x1e2d2e5,0x0178d8d,0x0e61428,0x0153d92,0x04c2ac1,
  45159. 0x04b96d1,0x0a20133,0x1f39a08,0x0780666,0x1b15806,0x18236b8,
  45160. 0x0e26237,0x09a1aa0,0x03b5020,0x0630883,0x1f07e7f,0x1ff7be5,
  45161. 0x1d215da,0x1246cd7,0x091aecd,0x0d5e4a6,0x06dd6f8,0x02c44ec,
  45162. 0x178de4a,0x05c470b,0x0f171af,0x0a5cafa,0x171858c,0x0163ad5,
  45163. 0x1e5730e,0x07edc73,0x12c2c28,0x19afe70,0x1bcb589,0x0c98fc1,
  45164. 0x035a599,0x18ef58c,0x11d9b81,0x19b9771,0x024f891 } },
  45165. /* 101 */
  45166. { { 0x178c1e2,0x1b05fb3,0x197093b,0x1a01ab7,0x1f49c03,0x00d04ff,
  45167. 0x061b8bc,0x0b1d823,0x0ae096e,0x0d39452,0x1e61316,0x1db6e0e,
  45168. 0x05aabbc,0x038652d,0x11cef4a,0x01c7bf6,0x0614de3,0x1464946,
  45169. 0x1d9eaf2,0x1cff349,0x09cf3fa,0x15f610d,0x00f0acb,0x1b36bbd,
  45170. 0x10d629c,0x06fd7d3,0x07182c6,0x1bd5d4b,0x09b54ca,0x1bdf202,
  45171. 0x18f57fb,0x0dba621,0x0eebc76,0x190e67e,0x1f8e3d8,0x0aee91d,
  45172. 0x18ee8af,0x0e19588,0x1d84bfa,0x19fa85b,0x0863ac3 },
  45173. { 0x05a2fe2,0x17e53dc,0x171828d,0x11dc853,0x13e70d0,0x0e1ca27,
  45174. 0x0882450,0x0151937,0x067272a,0x0354083,0x02f418c,0x0aabf2d,
  45175. 0x1de69a1,0x0a9e301,0x1bdf91c,0x1c9f570,0x14aef56,0x04b8330,
  45176. 0x01e02d3,0x186d713,0x1263c0d,0x111d0e9,0x10d95ff,0x0aa4592,
  45177. 0x17a8643,0x13c80fc,0x1bb7fbd,0x12312fe,0x0a17a0d,0x18ea36d,
  45178. 0x0f7aef8,0x10b599f,0x1179100,0x1e0ef37,0x18ca3e7,0x19c1b4d,
  45179. 0x01e7142,0x0ea9edf,0x1c96872,0x03d170c,0x03e3f1b } },
  45180. /* 102 */
  45181. { { 0x17fbf05,0x10ae03d,0x020adfa,0x0c3e347,0x192f11b,0x0e68de4,
  45182. 0x1656b47,0x11793bb,0x0ad0f7e,0x0fadbfd,0x1eade4c,0x0bd7f94,
  45183. 0x062936e,0x0cd2adf,0x1d05f70,0x1caa861,0x04343cd,0x18fb7a7,
  45184. 0x0bc112f,0x1ebccb0,0x0408971,0x1221446,0x1cf0ee3,0x00feaea,
  45185. 0x0c59fb8,0x07830d5,0x16062d6,0x0c9dc5b,0x03b0d3a,0x05304bd,
  45186. 0x161bde8,0x0072960,0x185ecc8,0x1a8bec5,0x11d2fec,0x0d340b2,
  45187. 0x079c3f0,0x16acbbd,0x0009626,0x1b0e015,0x081208e },
  45188. { 0x0c4ce37,0x1a84c8a,0x0298424,0x0743549,0x134bb84,0x06ac747,
  45189. 0x1c09160,0x1750c00,0x1b375b8,0x0da1624,0x0f7a0db,0x0a49da7,
  45190. 0x16ac365,0x124919d,0x08786d1,0x128deaa,0x1d564dd,0x15e3e62,
  45191. 0x1ed6dab,0x09606b7,0x01a39c1,0x0c00a36,0x1fc8ae8,0x04429ea,
  45192. 0x0fbbc87,0x1b205b1,0x1ed2485,0x159fafe,0x0d6df13,0x06d0e5a,
  45193. 0x0457fc4,0x0c4c015,0x00e2620,0x08b3fb3,0x0a76076,0x12f58fb,
  45194. 0x16e7a19,0x0713065,0x0cf09ba,0x17101bd,0x044383f } },
  45195. /* 103 */
  45196. { { 0x04f9af6,0x1f80ef2,0x0873841,0x1b1963f,0x16381a4,0x1eea499,
  45197. 0x18fb3ed,0x13fccb7,0x026a883,0x05c21ad,0x1e27634,0x122a7d8,
  45198. 0x1fee60f,0x15e62f0,0x17fa940,0x15039c4,0x0c57e44,0x0023be0,
  45199. 0x0c2e96e,0x1d3f064,0x0dd9349,0x17ef0c0,0x1750bcc,0x147a239,
  45200. 0x19eaf64,0x01d4581,0x1afadc2,0x01df109,0x0742cb8,0x1062789,
  45201. 0x188a239,0x0e41404,0x0156cc5,0x1dbbfa2,0x1799c94,0x139aa8f,
  45202. 0x06013a5,0x14d3765,0x0111660,0x11e1aa9,0x08aee70 },
  45203. { 0x0c54409,0x116ce19,0x0b1063c,0x0cebd75,0x09ebfa4,0x1424c0d,
  45204. 0x1a4a218,0x01921c5,0x16b3a8e,0x0100fb7,0x1d907b4,0x02d97ae,
  45205. 0x15c9730,0x180b82b,0x09bcbc1,0x19c03f2,0x08ffec0,0x024c202,
  45206. 0x0c674c1,0x12c423e,0x08c4bf6,0x02648d4,0x1d2d721,0x0061504,
  45207. 0x0fbcee0,0x090a620,0x1793db5,0x1dacea4,0x167d1eb,0x03e614e,
  45208. 0x0dabdf9,0x1843a6a,0x0307db8,0x14a02fd,0x11aaeec,0x1ead6d8,
  45209. 0x033e805,0x0cd3f18,0x09683c1,0x1fcc12d,0x0970f61 } },
  45210. /* 104 */
  45211. { { 0x1ec8e4a,0x09e918d,0x0d306f1,0x086b4c0,0x0809ac1,0x0f2326c,
  45212. 0x0076942,0x06a9dc1,0x18a4882,0x0b570fe,0x0192d92,0x10c664b,
  45213. 0x1fa1ae9,0x1a66834,0x1284fa5,0x14d6975,0x058b1d8,0x01b9c66,
  45214. 0x1dae769,0x0e3eb1c,0x16fb5fa,0x0463f58,0x12466fa,0x09c853b,
  45215. 0x0f13fad,0x0f6fae4,0x049267e,0x0b076ce,0x0d8bd74,0x008ad08,
  45216. 0x1faf388,0x0af2176,0x06d7605,0x1bc6efb,0x1b7920a,0x15262d5,
  45217. 0x15f855f,0x0c7d96b,0x1329f83,0x128b4fb,0x0404b5b },
  45218. { 0x17a15c7,0x1341528,0x080be7b,0x19df100,0x0ae4cfb,0x0351aa5,
  45219. 0x104e544,0x1cf9dc5,0x0170feb,0x0f300c9,0x03152d7,0x13fae7a,
  45220. 0x17589e3,0x0648495,0x171c4d6,0x1fcbe32,0x13f0a7b,0x0e5bf6a,
  45221. 0x187325e,0x124855e,0x17d92bd,0x1629caf,0x034bbc5,0x1665e13,
  45222. 0x0c1ca70,0x0e086a5,0x154b461,0x0b0ea4d,0x0d6195a,0x18254a1,
  45223. 0x0b0a4ca,0x14a0161,0x025a979,0x1e9187f,0x12b958b,0x18bf43e,
  45224. 0x00da253,0x1aad791,0x1800983,0x16b0628,0x07faa11 } },
  45225. /* 105 */
  45226. { { 0x0402149,0x1278637,0x0466c2e,0x1b2c798,0x1584cc1,0x093a3b1,
  45227. 0x1706a99,0x1e4ee81,0x1c95715,0x1bbffba,0x07ec38f,0x095a7f1,
  45228. 0x1fb2f23,0x17cdf1f,0x05640cb,0x0fd04aa,0x01d0423,0x1fe4fd9,
  45229. 0x054fb64,0x1dfe714,0x1d13eb2,0x1008020,0x02754eb,0x037b051,
  45230. 0x0545b7f,0x152e797,0x190e54f,0x1a944f9,0x1e75c8d,0x12ea6c2,
  45231. 0x10c034b,0x04837c3,0x193ed62,0x10196f5,0x097c090,0x023ca7e,
  45232. 0x03a4e70,0x0abb1b6,0x1fafee6,0x0a5db31,0x014b63a },
  45233. { 0x1c43336,0x05aa9b8,0x092dd84,0x0c47490,0x19dfd4a,0x03028d8,
  45234. 0x08b800a,0x1b6f72f,0x08f5f1e,0x155ddce,0x1f6ab61,0x1aef36c,
  45235. 0x1b67a57,0x06affd7,0x13941b7,0x078c715,0x19589ac,0x042ed4f,
  45236. 0x168f454,0x197550e,0x0ed2081,0x07f49a3,0x00cd4f6,0x1f3405a,
  45237. 0x161f1a1,0x038d955,0x1ce9967,0x0196126,0x1df8a1b,0x1185a7a,
  45238. 0x076df83,0x1d6fab4,0x1c4c741,0x12e783b,0x1271ca3,0x191e08d,
  45239. 0x17c171a,0x0e85e3f,0x09954cb,0x0e706da,0x0024858 } },
  45240. /* 106 */
  45241. { { 0x1a4cd8d,0x06e91ba,0x09e3350,0x072f797,0x132ca43,0x06b0fa8,
  45242. 0x1361096,0x0d0618b,0x1da1e8e,0x13f602c,0x1750282,0x02e23ac,
  45243. 0x1607a8f,0x1a1a86b,0x079957b,0x15c850d,0x0f05983,0x05cc673,
  45244. 0x162faf4,0x02723b3,0x1d497b6,0x12d8dd2,0x0e94a78,0x0d659ec,
  45245. 0x132e91f,0x114a37b,0x08fe8ed,0x1acdd8d,0x0f0ed2b,0x087661f,
  45246. 0x1d8e5e5,0x0be1168,0x09008cb,0x1071777,0x1096596,0x0ffad7c,
  45247. 0x1177bc8,0x16a89e0,0x0b6b9e3,0x1bffca2,0x06798ce },
  45248. { 0x197c5c6,0x1fc7e8d,0x0cfd278,0x1cf1876,0x19fbab3,0x1acadd1,
  45249. 0x1104903,0x0ec884e,0x15d7d43,0x1a112dc,0x111ddc5,0x1f98f38,
  45250. 0x05880b3,0x194b592,0x0eb2a0c,0x1c309b8,0x1f71734,0x12ac89e,
  45251. 0x124d11c,0x1647a73,0x0a11a4d,0x19e8a10,0x13aecdc,0x0c117b9,
  45252. 0x00cf9f3,0x09fdce9,0x18c33f8,0x0c3159e,0x10874ca,0x1598af9,
  45253. 0x095d7c1,0x13e000b,0x06efe7f,0x1e4eda8,0x1e3006f,0x03155d4,
  45254. 0x178e7c4,0x0bc92af,0x18e57e4,0x1a4a5d2,0x03ea7ae } },
  45255. /* 107 */
  45256. { { 0x106ae25,0x0bf022d,0x03be618,0x1b96aea,0x1cac148,0x0615d15,
  45257. 0x0bc3981,0x0eb23d4,0x176b789,0x060cfb5,0x1686040,0x0da0ca3,
  45258. 0x1b79b9b,0x04a2b82,0x0896faf,0x0b7e3e6,0x1f35c00,0x0985a1a,
  45259. 0x109361b,0x1689057,0x1777440,0x0b6b1b9,0x0ae3c26,0x08969b8,
  45260. 0x16c561c,0x0ccb2fe,0x18c241a,0x1280bdc,0x0a1ec1e,0x0492045,
  45261. 0x05467fc,0x07a5e51,0x0f3246a,0x033cbf7,0x1d96f1d,0x1c02d86,
  45262. 0x10705f7,0x092b4fe,0x001118b,0x1380a4a,0x06a8ad3 },
  45263. { 0x0be7282,0x18106a3,0x1c4b917,0x1a42701,0x1405afe,0x0d35684,
  45264. 0x096f757,0x03c99b9,0x07f8be6,0x16b78c2,0x0e05e30,0x12a6b2d,
  45265. 0x1420132,0x1d46fca,0x0ec79ed,0x0569b1a,0x1bb3957,0x13abe30,
  45266. 0x0330ed5,0x136af70,0x1fecd74,0x099bd9f,0x05643fe,0x0bb929b,
  45267. 0x1b65314,0x0b99cdd,0x188cd79,0x01838c0,0x03feba7,0x196bfbb,
  45268. 0x0ca70b9,0x198c36e,0x168e424,0x1f96523,0x1e9aa9c,0x1aeefa5,
  45269. 0x05cb58c,0x126dd56,0x186ab7b,0x0f339f5,0x01a1811 } },
  45270. /* 108 */
  45271. { { 0x1575ed0,0x1fb17bb,0x066dbdb,0x12fa3b5,0x18f14fa,0x17ebfb0,
  45272. 0x0bbeda7,0x0665ce5,0x1ddc286,0x02d5a65,0x1160d31,0x1a90b0d,
  45273. 0x18b0e20,0x1cbbaee,0x05c0468,0x08931a7,0x008f413,0x0009864,
  45274. 0x14457b6,0x011d75e,0x1ed92d4,0x0e01306,0x1141a81,0x1957223,
  45275. 0x1736219,0x1434f2d,0x1ba1a4e,0x19ea118,0x1736174,0x122fe63,
  45276. 0x08d39c4,0x12bb139,0x171aa1f,0x1de4c17,0x11a981e,0x049774f,
  45277. 0x012b7fd,0x128af39,0x1d6a3ce,0x0eb2461,0x07d2ddc },
  45278. { 0x0d2cae8,0x0c0b6a7,0x0ddcf41,0x1b73800,0x0cf6bc7,0x15846a2,
  45279. 0x0639991,0x101847d,0x14b9c01,0x0f73630,0x05e707e,0x1427df2,
  45280. 0x0ae11c9,0x076cb44,0x0d851fa,0x0e14f4b,0x048d066,0x0bd7f5b,
  45281. 0x1da149d,0x0066782,0x08f2d67,0x14bafcf,0x0a27765,0x14d15bd,
  45282. 0x1228d37,0x0c35dab,0x191532c,0x0340bab,0x1dd5502,0x0ac7831,
  45283. 0x1cd2040,0x0996d95,0x0dd4f08,0x055f3c9,0x0149e15,0x0ce189b,
  45284. 0x0e729d7,0x0cb4ee3,0x102ea11,0x0f5637e,0x05a52f8 } },
  45285. /* 109 */
  45286. { { 0x1ecacbd,0x0cf4884,0x17abb40,0x1af7137,0x0544023,0x039b8f3,
  45287. 0x07c2d5c,0x02ef98a,0x016c8e2,0x0419582,0x166ad45,0x0d05024,
  45288. 0x14b1aa6,0x11f1b0e,0x0403e48,0x0b854dc,0x0e9e3a9,0x172c9f7,
  45289. 0x1b04389,0x16d77a2,0x013f699,0x19ca39d,0x0b521e1,0x0e930f9,
  45290. 0x14dc5b2,0x174f8e0,0x1495678,0x0fb800e,0x147ad25,0x024ee1e,
  45291. 0x04e1126,0x1baa4ef,0x1df278a,0x0adccc1,0x1b23bbf,0x00ee1c7,
  45292. 0x16bd02a,0x12c2233,0x17ff8ab,0x0c87ce0,0x017f027 },
  45293. { 0x1abea1f,0x0008694,0x1133769,0x0a480f5,0x036b969,0x1990c5b,
  45294. 0x004a410,0x0952d4c,0x1163d53,0x110fe1d,0x081597c,0x0b7d998,
  45295. 0x1705ba1,0x0b142ab,0x0e39536,0x009a624,0x0578788,0x00d8a21,
  45296. 0x026a7f9,0x17e6095,0x02b196f,0x1625f32,0x1229fc1,0x05610bd,
  45297. 0x020e86e,0x08eee8d,0x0bfd296,0x1efe4f8,0x0343b88,0x03a9d25,
  45298. 0x13705ec,0x1762e7a,0x04b1e88,0x03ddf34,0x0910f70,0x0e7599d,
  45299. 0x0c441d7,0x0ae446a,0x055fb6c,0x134a7cb,0x00ef030 } },
  45300. /* 110 */
  45301. { { 0x08e5b60,0x12b90fd,0x0ec93f0,0x1ad2381,0x046938a,0x0511243,
  45302. 0x12dd82c,0x0efc8da,0x07de168,0x11fcd61,0x0718c21,0x0dde4e4,
  45303. 0x02503bb,0x05b3fd8,0x106677c,0x17a73f1,0x172e07a,0x13c60f6,
  45304. 0x0cbc376,0x1bd6f76,0x09f3cf9,0x18361e4,0x0bfdc9b,0x0e444b5,
  45305. 0x08b2d19,0x1ae5b80,0x1d3c517,0x1eb4c22,0x1c4f378,0x17c622b,
  45306. 0x1913839,0x0388a78,0x1bdaa44,0x0964045,0x09b69ba,0x02af7c6,
  45307. 0x1d77356,0x1e1feca,0x0dcaaa6,0x18d766f,0x03d3b6c },
  45308. { 0x122c880,0x189664b,0x0225b9b,0x0e50d6d,0x1a1b6ae,0x17d7f61,
  45309. 0x1026eb4,0x1df7439,0x043bb8b,0x0b256bd,0x0fd30eb,0x14012f8,
  45310. 0x1ba5af6,0x01a9d48,0x1f2c367,0x17ed655,0x0ab69cc,0x06509fe,
  45311. 0x0aaf064,0x142723e,0x07e5699,0x0111d12,0x0b6f555,0x0911b34,
  45312. 0x0180f95,0x01e7103,0x1c49133,0x153cf7f,0x13a365b,0x1d5f43e,
  45313. 0x188a4a5,0x1f4994b,0x054fa38,0x10db620,0x08f59ef,0x096720c,
  45314. 0x18f41a4,0x133e2bb,0x1139c7e,0x0878f6a,0x02e946e } },
  45315. /* 111 */
  45316. { { 0x00934ae,0x07eefe3,0x1b44a60,0x1e2c840,0x0c3e7ef,0x176bad1,
  45317. 0x1fe5905,0x1b9eebc,0x15cd0b2,0x1630679,0x0b61efe,0x1d9c3f5,
  45318. 0x1dddc4b,0x0c24f2e,0x0fea1f2,0x1e35cea,0x0a32c1b,0x1e2ea8b,
  45319. 0x11ccad2,0x1b7d502,0x096b565,0x1d67243,0x001faf8,0x172ed28,
  45320. 0x074d6cd,0x1df2065,0x0197939,0x1eb9a4e,0x0c4ebc3,0x1e009d5,
  45321. 0x085d211,0x087ad87,0x162e034,0x103b533,0x125519e,0x1ad21b1,
  45322. 0x1eda677,0x06bc6b0,0x16309da,0x0aa0303,0x00997ce },
  45323. { 0x05a0b81,0x1ba364b,0x17ea4a5,0x0dcbc25,0x08b58be,0x0fa1bfa,
  45324. 0x0cf11c5,0x0b2aae7,0x1b565c4,0x012f483,0x09e5f39,0x0a242b0,
  45325. 0x0f4f43f,0x0752a3a,0x16be9be,0x00959cb,0x1be13de,0x19575c7,
  45326. 0x0281f20,0x1f2be1d,0x09feed7,0x1733160,0x0f804a9,0x0859e2e,
  45327. 0x0e9b8c7,0x022dfcb,0x0b8a287,0x1d4aeb3,0x14e2f38,0x00da2e7,
  45328. 0x0651d65,0x1f20340,0x1d3c02d,0x0b5973e,0x1ba9c24,0x11cf49b,
  45329. 0x0fa9b98,0x19395a9,0x1ff9942,0x13fa122,0x096f9f0 } },
  45330. /* 112 */
  45331. { { 0x0310a96,0x0556216,0x1cd1e3a,0x07ef454,0x12a9830,0x0b11039,
  45332. 0x0a0f48e,0x10188d9,0x0d95412,0x0898f37,0x0fa446b,0x18bc595,
  45333. 0x085791f,0x020db63,0x12ddfae,0x110f0a1,0x1ea3d3c,0x157fc9e,
  45334. 0x0401ef3,0x083e3be,0x11fd065,0x012ae6f,0x13b9ca7,0x07c72e4,
  45335. 0x1131732,0x060f07b,0x06b5342,0x05bcf48,0x1e22bfa,0x155fd1a,
  45336. 0x096a644,0x1136066,0x050122b,0x0a6a750,0x07d0194,0x17173ca,
  45337. 0x19d3e0a,0x1e3d56b,0x1fa9508,0x04c8171,0x071998e },
  45338. { 0x0b6ed78,0x007e6e7,0x1459005,0x0e30a68,0x053cf37,0x0b06e63,
  45339. 0x0d96ba3,0x1f008a1,0x09dac55,0x1360d3b,0x15a1b33,0x125b5c0,
  45340. 0x028a96a,0x093892b,0x1911d88,0x1284a5f,0x150a4f3,0x13a3de5,
  45341. 0x114c7f0,0x18dfe5f,0x1ff0f0e,0x03887f4,0x125f0d1,0x0f259ff,
  45342. 0x087839c,0x00cfda4,0x0009bec,0x0a58a49,0x04c2905,0x114e6c0,
  45343. 0x1cd0006,0x06b9194,0x02b5ad8,0x0efd03a,0x1c5dbb9,0x0386f03,
  45344. 0x1dfa4ab,0x15c2f81,0x0cab329,0x034161a,0x0838994 } },
  45345. /* 113 */
  45346. { { 0x0067dff,0x031516f,0x058b03c,0x0179700,0x14f3269,0x03d15ee,
  45347. 0x064341c,0x123319b,0x0fae4a3,0x17e31dc,0x0b60516,0x16f7665,
  45348. 0x11684f1,0x18ccefd,0x08b738b,0x0b09161,0x17f48f2,0x1113070,
  45349. 0x0b57a18,0x07b6018,0x1171739,0x0a19c67,0x07a23e1,0x159ea45,
  45350. 0x1942902,0x19e8033,0x01a0d6b,0x122af97,0x02614c1,0x17c95c5,
  45351. 0x1b0bea9,0x0269d88,0x0ff95f5,0x1409a82,0x09bbede,0x099e00c,
  45352. 0x137a470,0x059e82d,0x1b09515,0x0624d29,0x01fbfda },
  45353. { 0x0f69c77,0x1db2be4,0x03ebf7a,0x1747bf1,0x12a8278,0x1dbc5a4,
  45354. 0x155c707,0x0668c76,0x011c71a,0x103350d,0x0562c34,0x0286113,
  45355. 0x0610c88,0x07ceb3d,0x1d71f83,0x0f71f72,0x0087303,0x0ed52e9,
  45356. 0x02fd618,0x0a00ba8,0x09a95ee,0x13bedd3,0x0c039b3,0x0c598e8,
  45357. 0x03cb3c9,0x02ac49e,0x0533e10,0x15930c5,0x1c9d700,0x1b1d112,
  45358. 0x1a029fb,0x1723c8f,0x0184869,0x1c25f7f,0x17ae30b,0x1e373af,
  45359. 0x00e278b,0x1c448ae,0x1c6799d,0x195884d,0x04f9488 } },
  45360. /* 114 */
  45361. { { 0x151b8ce,0x0fe6a6e,0x1a01843,0x106c461,0x0857927,0x0ccab10,
  45362. 0x1fc70d9,0x0efdb8f,0x1e2cae8,0x02f56a5,0x19d8224,0x0bb3cf2,
  45363. 0x0ca1c32,0x1e9c493,0x0e7b776,0x0149c7c,0x0685f6f,0x06d4964,
  45364. 0x11e83e9,0x1f0015e,0x0aabe16,0x0df2fb0,0x142d36d,0x070a7a6,
  45365. 0x1412f98,0x04e1b32,0x026de5e,0x096c44a,0x0e72b26,0x002c270,
  45366. 0x0efa958,0x1caab85,0x1bd4901,0x09708d5,0x069c5ca,0x1e6f083,
  45367. 0x0174218,0x05ad557,0x1ae49b8,0x1091ef2,0x0688e06 },
  45368. { 0x13b8f64,0x17b2098,0x118b37f,0x172858e,0x0ef11b7,0x06c55ed,
  45369. 0x1eddd70,0x1520cf9,0x0af4041,0x04752f8,0x14843d8,0x1b04d26,
  45370. 0x0823d5b,0x13c8bd0,0x0e413f0,0x05a42b5,0x1fe45d2,0x1c2edd8,
  45371. 0x14d8567,0x0bca129,0x18f2c3d,0x070e9cd,0x0baed4a,0x0959de1,
  45372. 0x0a828f4,0x12a6eae,0x1c8315e,0x084135b,0x195f442,0x1a19bc7,
  45373. 0x0dd5d0a,0x15266fa,0x11fa7d9,0x07edbe8,0x1027193,0x19acd41,
  45374. 0x1bb817e,0x12adc7c,0x049955b,0x1c7c988,0x01723c7 } },
  45375. /* 115 */
  45376. { { 0x08b43f3,0x0436c6e,0x19a2699,0x024c813,0x1c3e0e6,0x1a3001f,
  45377. 0x110df66,0x0f63113,0x16284ec,0x142819a,0x16eba8e,0x0b88d53,
  45378. 0x1c5a366,0x14bc499,0x1da5077,0x02920f7,0x1106934,0x08f6ad2,
  45379. 0x12e000b,0x14f6f51,0x0a59664,0x1230768,0x180fddb,0x09d7e4e,
  45380. 0x06ba31f,0x13fe1f0,0x07cb0e2,0x12d9da8,0x1db08a2,0x07bce78,
  45381. 0x0d8ab06,0x19bcf47,0x119e882,0x1458364,0x14a76fd,0x0a2bcef,
  45382. 0x0e947cb,0x0bc5d52,0x064e886,0x056ec61,0x084bf54 },
  45383. { 0x164f21e,0x166d4f1,0x15fb077,0x0a025ca,0x0d6cf34,0x07c8708,
  45384. 0x1a12162,0x1717448,0x1e3b104,0x1b6ed25,0x1bd5ea7,0x068dc75,
  45385. 0x096bf7a,0x14193f5,0x00a67fb,0x1cd8e42,0x087da95,0x0d54cfa,
  45386. 0x0b37d91,0x1f027da,0x14b824f,0x0945ea0,0x1476ecb,0x1f434c3,
  45387. 0x101afca,0x0d20328,0x0a737af,0x1b3e973,0x1039e47,0x19caf20,
  45388. 0x10abd06,0x18a15be,0x1e9e6ba,0x14f24f1,0x0eb8d07,0x069e426,
  45389. 0x0b157f2,0x146079e,0x0054d25,0x0f7b40d,0x0383f82 } },
  45390. /* 116 */
  45391. { { 0x183ff4c,0x03510b2,0x079cbb1,0x1295ae1,0x0e645a2,0x0650952,
  45392. 0x1a73f01,0x1cbb8cd,0x09160a7,0x178947a,0x11d8ba0,0x0f62ad3,
  45393. 0x07bfb22,0x0176dc7,0x031e58f,0x1ed11f0,0x00649a0,0x053ed7f,
  45394. 0x1452e33,0x082ea85,0x00beb7e,0x09c36f2,0x0e83171,0x16f2662,
  45395. 0x052861d,0x18df868,0x07eff81,0x12059cd,0x0e9903b,0x14ab108,
  45396. 0x0e18791,0x1ee07d7,0x0ef874e,0x1bc5b7d,0x11fb757,0x15ecd12,
  45397. 0x1af5ea3,0x1432a3a,0x11895bf,0x02a87f2,0x03b121f },
  45398. { 0x19275e9,0x17423b2,0x19416c9,0x1ada1f9,0x07581cf,0x11f8f7a,
  45399. 0x12ff62a,0x01cabeb,0x1e484e6,0x13df18a,0x1a63907,0x041ffd2,
  45400. 0x04d8f1a,0x1d5823c,0x151b6a5,0x1b67c4b,0x175834c,0x0d2936d,
  45401. 0x1422802,0x0811b31,0x08161fd,0x102dae5,0x1f0012c,0x1c977d1,
  45402. 0x03bb365,0x177ad9f,0x15d66ed,0x0a19824,0x1ac737f,0x140be17,
  45403. 0x06bc17e,0x1a4e72a,0x0e102d2,0x199b3cf,0x102ffb2,0x1e551ca,
  45404. 0x0a6a515,0x1a237d9,0x0320d9c,0x1a26e52,0x05505e1 } },
  45405. /* 117 */
  45406. { { 0x15e68a6,0x00a50e8,0x179430c,0x0cc9ba6,0x0f9f0b2,0x16b3fcb,
  45407. 0x1d0b40e,0x1083186,0x0d2c144,0x040c607,0x068f2dd,0x02d21a8,
  45408. 0x1ec5181,0x024f9f4,0x12320ff,0x1270ccb,0x0612c27,0x04d9306,
  45409. 0x1b413a7,0x10df5d9,0x0758f60,0x15febe2,0x09ecb33,0x052ffb1,
  45410. 0x0313390,0x164259e,0x0025c06,0x1504c9d,0x0b3762c,0x1543a84,
  45411. 0x1fa7e5d,0x130751b,0x1582714,0x0cc74ae,0x19a7675,0x106a1a4,
  45412. 0x0f6fd34,0x05c4e58,0x0c5f217,0x1a94ae8,0x0617d80 },
  45413. { 0x0022b67,0x1933f38,0x052933b,0x0a6ed17,0x00536bb,0x1c22314,
  45414. 0x0959b49,0x03262a7,0x0382439,0x082a6a2,0x1e31292,0x02e4bbe,
  45415. 0x1a8d11e,0x0ad0f1a,0x094a9c7,0x1c63b36,0x0808171,0x103c336,
  45416. 0x0ce2803,0x0a03b63,0x02360a8,0x1c673b8,0x0bb64ca,0x1b5efa0,
  45417. 0x176098e,0x174d16b,0x0ee4c01,0x15dcbb5,0x1eb0363,0x04625df,
  45418. 0x02febff,0x09c4367,0x17b9678,0x0703483,0x167f72a,0x02923f8,
  45419. 0x0e93847,0x1127aa8,0x1e02cfd,0x010f9a2,0x05156f5 } },
  45420. /* 118 */
  45421. { { 0x006e8d0,0x1a71101,0x1cc9608,0x08fe2b5,0x15f6f5d,0x1c4a87f,
  45422. 0x1ca2758,0x1e95f56,0x17d4495,0x1762684,0x0a02a59,0x18bad1b,
  45423. 0x0bad890,0x127c51b,0x0a82481,0x0b8bfc9,0x17e0f4d,0x0bccf12,
  45424. 0x112578c,0x0cef5c4,0x035244c,0x19d2dc7,0x1c80e1e,0x1450f72,
  45425. 0x190f475,0x17bb81b,0x170f07c,0x0912b98,0x07fa415,0x07cda0d,
  45426. 0x02ee1a0,0x1601601,0x0d47458,0x039e5fe,0x00e2e99,0x1429399,
  45427. 0x0c9be19,0x16afbd5,0x196e9e3,0x139666e,0x0525459 },
  45428. { 0x01b54c4,0x1cb3cd1,0x167421c,0x156c92f,0x029ece2,0x0443200,
  45429. 0x06a4b21,0x1b3e29e,0x1e9fa79,0x1246e7f,0x08236eb,0x03848d8,
  45430. 0x1e14b91,0x0d71fb4,0x0c3efcb,0x17070b5,0x07ed1ed,0x18c0564,
  45431. 0x02161ae,0x1fae303,0x0bd0146,0x0a2a33e,0x0843ad9,0x0cf9fdc,
  45432. 0x1940816,0x1305511,0x0adcf46,0x1624b83,0x1c1cbed,0x0980440,
  45433. 0x0cb79a1,0x06f8604,0x034c713,0x0468c7f,0x1c39bcf,0x078d8c0,
  45434. 0x14af4e8,0x11b2dd5,0x0ad141f,0x1dbb9f0,0x022f0a7 } },
  45435. /* 119 */
  45436. { { 0x07f1b7f,0x13c8ff5,0x0753898,0x1bb9fe1,0x1c3d8c5,0x03ee2c4,
  45437. 0x0a70ce7,0x1810d85,0x14276e8,0x0d6a00b,0x1875593,0x1eb3d3f,
  45438. 0x090a918,0x1554086,0x15e59c0,0x19b8971,0x0364aa5,0x175bd44,
  45439. 0x1ebe9cb,0x184777c,0x0908fc4,0x0f25643,0x136ed72,0x018fcde,
  45440. 0x190136a,0x0691bf1,0x0527086,0x0abae00,0x1324a28,0x1e33ca5,
  45441. 0x1c791d6,0x0c50f40,0x18a8dc6,0x0191e64,0x066d7ed,0x1272b45,
  45442. 0x0c0389e,0x0361f70,0x1311b86,0x0de2ce6,0x079f81e },
  45443. { 0x04f3c4e,0x160f99b,0x052e0fc,0x0a26cfc,0x136b2ac,0x19f21ea,
  45444. 0x173f164,0x1fc894d,0x110d961,0x072ca3a,0x1caab8d,0x1d9cfc7,
  45445. 0x0508234,0x1ef53f9,0x04b802a,0x1424997,0x0f0a791,0x10f7dd2,
  45446. 0x064b54e,0x10dfa42,0x0af6c20,0x1e5a8e4,0x1fb0343,0x01e36bf,
  45447. 0x1b2cadc,0x10ca468,0x1e04b6f,0x00f4711,0x1bdd45b,0x1d356f6,
  45448. 0x069021c,0x1ae04b1,0x02a1268,0x13db25e,0x0ea05f8,0x0b77edc,
  45449. 0x0d386e8,0x172b31b,0x10001cf,0x06f3bcf,0x0442ecd } },
  45450. /* 120 */
  45451. { { 0x02f90a6,0x08d7345,0x0332d33,0x1adeb5a,0x1277d41,0x0ea5c77,
  45452. 0x0a31100,0x062d470,0x0d83766,0x00bd09a,0x04492fa,0x0b1bebc,
  45453. 0x04142b7,0x1eb5caf,0x1ef1a77,0x13c7c4b,0x15fd74a,0x151864f,
  45454. 0x02598f3,0x01e2c7b,0x186d5ac,0x1b86731,0x0caa7bb,0x1daaa88,
  45455. 0x10ea5d8,0x13d3d34,0x0262250,0x1bc47fe,0x0ced585,0x1b52f55,
  45456. 0x195d6b4,0x1a7c308,0x114a6c1,0x09c881a,0x0b0dfc2,0x107b22c,
  45457. 0x033d56e,0x0856ecf,0x1a47970,0x0e60d54,0x085176b },
  45458. { 0x0a21e38,0x0887d14,0x14e28c8,0x1aaee7a,0x17b6379,0x0106e24,
  45459. 0x1eefcb4,0x19ba6d2,0x1961833,0x08bbac9,0x0a14596,0x0bf5cbf,
  45460. 0x126d704,0x1c355ae,0x043ca69,0x0b6e067,0x030dc4f,0x15605ed,
  45461. 0x1318571,0x004815b,0x0d91cca,0x01628a3,0x0387c5c,0x059df0f,
  45462. 0x072d0a7,0x1d0e75a,0x002d9a6,0x09080e1,0x01aa0a8,0x07cebf3,
  45463. 0x02de6c2,0x08cd2ac,0x08160be,0x15b8f1c,0x10b6523,0x184726b,
  45464. 0x1431590,0x1ec1e04,0x1a2cf5f,0x176dcae,0x08ab154 } },
  45465. /* 121 */
  45466. { { 0x13c4a96,0x030019a,0x00d4a1a,0x1120b9b,0x0e5c60e,0x137c662,
  45467. 0x04d923d,0x13d7ab2,0x09faccf,0x15c05cc,0x18e796d,0x1f5dc64,
  45468. 0x0bbc1c1,0x13c556f,0x18e5b48,0x0405a5e,0x0d01898,0x08053cb,
  45469. 0x091d20d,0x16a91e7,0x0e3e18a,0x01d98d8,0x0b3415b,0x0c8a25b,
  45470. 0x068dd01,0x1de0add,0x052c0fc,0x00706db,0x1206c52,0x0535ec7,
  45471. 0x0db593b,0x13e2ef3,0x11a361e,0x19a5449,0x03f14aa,0x05b04d2,
  45472. 0x12922e2,0x15dc704,0x00aa4d0,0x109c016,0x01bfcdd },
  45473. { 0x1a365d9,0x1cd21ba,0x0c0cc42,0x1c11b1f,0x14ade15,0x016fc1e,
  45474. 0x14f5f5d,0x085392e,0x0de3187,0x1b984ea,0x02b3833,0x042466c,
  45475. 0x031228e,0x1bb34b2,0x10f48e3,0x0b4a620,0x1edf90f,0x1fe156d,
  45476. 0x0d7e4e5,0x0c996ef,0x101041d,0x0562236,0x14802cc,0x02e41fc,
  45477. 0x0642d23,0x03ae1e4,0x16e6a88,0x1980245,0x1eae47f,0x1d89020,
  45478. 0x09215b8,0x0d190ed,0x1864455,0x10358a2,0x01088cd,0x1e3438f,
  45479. 0x027757b,0x1b368f9,0x153c66d,0x077ef73,0x025b78a } },
  45480. /* 122 */
  45481. { { 0x16707ce,0x1ab8c0a,0x042a420,0x108629f,0x1bdc239,0x12bedec,
  45482. 0x0216a2f,0x17002f9,0x1ad63a4,0x05dd112,0x0b3ff75,0x170c2b5,
  45483. 0x025ce71,0x194aa39,0x09991d5,0x1a7babe,0x1f74f0a,0x1854078,
  45484. 0x10d4bb5,0x0a7147f,0x06ca010,0x02a101e,0x1e29901,0x018e769,
  45485. 0x07a8833,0x00d9596,0x180b72b,0x06867dc,0x0b17c7b,0x0ce7f69,
  45486. 0x11cb812,0x17ac653,0x18681a4,0x16e1bcf,0x0518dbe,0x16712f3,
  45487. 0x12b7895,0x0b28644,0x073c371,0x0e0cb4a,0x070ab95 },
  45488. { 0x1585d93,0x1c7623d,0x193919d,0x014c67f,0x0a6d361,0x10188d6,
  45489. 0x055393a,0x05e43b4,0x1bd6400,0x1910c85,0x12dea6b,0x158fb23,
  45490. 0x179e633,0x17341be,0x04f0c7f,0x1dd15da,0x1d71616,0x16d2503,
  45491. 0x0bf3585,0x144e647,0x1694d78,0x12dd0a6,0x1019a5b,0x1eb0841,
  45492. 0x154d74d,0x1e4b99b,0x189de38,0x10bca09,0x15a5c2e,0x15062ad,
  45493. 0x170c156,0x1147596,0x13df538,0x0476d18,0x12d4a82,0x1cb12d5,
  45494. 0x04c85dd,0x0421504,0x19afbf2,0x0f2a3bb,0x05fec9f } },
  45495. /* 123 */
  45496. { { 0x0519f99,0x0163e7f,0x0d4d7af,0x01ca820,0x0396bd8,0x1cc479f,
  45497. 0x0500a28,0x1435bdb,0x1d601bd,0x001db9a,0x1992b07,0x006c299,
  45498. 0x10fd302,0x0092014,0x0dfafa4,0x012fab0,0x1a3a554,0x0e55750,
  45499. 0x02e204e,0x0e7a4b6,0x10b9dce,0x15f6584,0x0d7b504,0x07b5678,
  45500. 0x09ff7d6,0x038cc81,0x0418b6c,0x0aa86fb,0x04c11d5,0x17ab215,
  45501. 0x0249df4,0x049f922,0x17fa645,0x092a6a3,0x06dc9e6,0x18f625d,
  45502. 0x184c618,0x0957116,0x14655eb,0x0c79d1d,0x00a8d56 },
  45503. { 0x021fde1,0x028b185,0x01250eb,0x0cd207b,0x0fcf5dd,0x0eb140e,
  45504. 0x067b97f,0x068da49,0x077a49a,0x0f6e378,0x1701bd3,0x058050e,
  45505. 0x0646bda,0x1a3dc02,0x18383d8,0x106dfa1,0x09b5e67,0x1082c0b,
  45506. 0x1a2a010,0x032255b,0x1d32c96,0x05549d9,0x17cffa8,0x0aed78b,
  45507. 0x18edb0c,0x123cf89,0x1b634df,0x12e35ad,0x05e7cb7,0x0b9ce67,
  45508. 0x103aae1,0x03a4056,0x0a4b434,0x0fe9344,0x155f8e8,0x02bb084,
  45509. 0x13a86f9,0x17d5ead,0x18a7e1c,0x126d548,0x095b934 } },
  45510. /* 124 */
  45511. { { 0x1f951de,0x05380cc,0x0d16666,0x0de0b1b,0x0fade59,0x081ee9c,
  45512. 0x0707bcf,0x1a69a8f,0x133b141,0x14946ae,0x1a2901b,0x100159f,
  45513. 0x1d9a465,0x00e77d1,0x022b4bf,0x0e4dda2,0x121e013,0x1b25cb4,
  45514. 0x1a0eee7,0x0d4d6d1,0x0544b9b,0x0e09217,0x0a7c79b,0x0cb2cd6,
  45515. 0x0f6762f,0x1a0e9fc,0x1978416,0x069ba12,0x011e1ca,0x09cd0b0,
  45516. 0x06f53a4,0x04a2aa8,0x0a4dc68,0x10b36f7,0x02b3208,0x08df006,
  45517. 0x11d1612,0x03d70e9,0x1e9f6f7,0x0a2c435,0x02e25ef },
  45518. { 0x18e7357,0x1e7c7ee,0x16e094c,0x11d59db,0x133ba21,0x0269561,
  45519. 0x18c741e,0x1c4d1c7,0x0f2804a,0x0493f9b,0x1eb5f87,0x1a44efc,
  45520. 0x0001433,0x0c3fbc5,0x10073c1,0x04f5c16,0x036aa00,0x0cefe78,
  45521. 0x16691ad,0x08d9163,0x0d32c9e,0x030f944,0x0a9b792,0x114087b,
  45522. 0x0da2f1b,0x1ab6eab,0x17cb42e,0x08c461c,0x1efb563,0x1b720ce,
  45523. 0x1d067c2,0x043a590,0x1ec37cd,0x122d9aa,0x0e5edc3,0x047b7e0,
  45524. 0x0c7ce85,0x031546d,0x1cf5bc2,0x14fc283,0x087979e } },
  45525. /* 125 */
  45526. { { 0x11c747f,0x13d9fbf,0x0da66df,0x1b8dcc6,0x151a4c1,0x196dd00,
  45527. 0x1fdc2cd,0x1fc84e7,0x0d3ee54,0x136911a,0x12b83f2,0x1c19a67,
  45528. 0x0c12fc8,0x0eeb788,0x0ca14e1,0x139f24e,0x1bdf01a,0x0e4379f,
  45529. 0x0db2ba4,0x04ceffc,0x0a44532,0x1997f7f,0x0e69c00,0x115e42e,
  45530. 0x0a328ce,0x0fa164e,0x1bda9cc,0x004acee,0x096813c,0x19efb35,
  45531. 0x0a31a1e,0x11b65db,0x14aab12,0x07f5e8c,0x116bbb1,0x05bc61b,
  45532. 0x179241b,0x0911b54,0x1305b01,0x005847a,0x03ec988 },
  45533. { 0x072f74d,0x13b0620,0x01643e7,0x1d56b28,0x078eb0d,0x1804e17,
  45534. 0x1a90326,0x1cbb67b,0x038b59a,0x1f43af8,0x16a8191,0x086c569,
  45535. 0x08f40eb,0x04879bc,0x1a93e48,0x15f1734,0x1afedbf,0x177f5f4,
  45536. 0x019f895,0x1f2d4b3,0x0aebf87,0x11bad5b,0x079bfb4,0x1b62796,
  45537. 0x0782a3f,0x1108bf9,0x19c3e89,0x02058e3,0x0c0dbe5,0x03767ea,
  45538. 0x05d74ac,0x06068e5,0x17cc268,0x1f3c029,0x18acad9,0x051b7eb,
  45539. 0x1a25da3,0x119f9d5,0x12450bd,0x1d1df5d,0x03e9315 } },
  45540. /* 126 */
  45541. { { 0x19a9ea9,0x0e7d291,0x098a495,0x0017c67,0x00f3c69,0x1b215e9,
  45542. 0x1ad2e72,0x030eb3d,0x000bae7,0x18b62a3,0x043e10c,0x0dabe68,
  45543. 0x16874a7,0x087894d,0x0ed40ba,0x03e3824,0x1a81285,0x056e47c,
  45544. 0x0d89023,0x16ec943,0x177bf57,0x0f8d403,0x045bb00,0x01bb8b8,
  45545. 0x0cef21f,0x0d3ba37,0x13969a9,0x1893a8f,0x0955ba3,0x0df3837,
  45546. 0x0c07857,0x168baf3,0x09c0c79,0x08843b1,0x0c21de3,0x0e224f0,
  45547. 0x0c6a22d,0x0c2ee3c,0x09e4489,0x01a14d0,0x02ed02a },
  45548. { 0x1aa2682,0x01a0b26,0x18954c1,0x16026b2,0x0e26d32,0x03384b8,
  45549. 0x00d2af6,0x05c8939,0x1ee77ae,0x0d0ce95,0x1b05a44,0x053475e,
  45550. 0x1439bd5,0x0e6b082,0x1329701,0x01fc26d,0x19bdc6c,0x0b1b852,
  45551. 0x04f544d,0x041a4f7,0x051aca4,0x02aaa62,0x161cc35,0x19bd7e5,
  45552. 0x058c996,0x102f5e9,0x02943e6,0x1963732,0x0f01510,0x04bd3d8,
  45553. 0x185a6a3,0x023a42f,0x0c36d34,0x1baf416,0x0229d4b,0x03e22ed,
  45554. 0x009b2a6,0x1809ca5,0x15f7476,0x08953df,0x0146278 } },
  45555. /* 127 */
  45556. { { 0x12803cf,0x11d7691,0x1cd1af2,0x17352df,0x01e4398,0x15bc45e,
  45557. 0x1d5fdd2,0x09b95ec,0x07e68c0,0x1d29f00,0x1f34830,0x1832b96,
  45558. 0x0a5f969,0x0e0345e,0x02d969b,0x06065e5,0x1d31d86,0x071e500,
  45559. 0x1e02385,0x0677030,0x18be9b7,0x0cf7f30,0x0d75c13,0x03728db,
  45560. 0x13542b0,0x0df93b7,0x1befb77,0x00afc33,0x1275cee,0x1795c81,
  45561. 0x119f460,0x1101ef7,0x0dc5f77,0x1b60a1e,0x14fde11,0x05ade07,
  45562. 0x09ba507,0x0faaabd,0x058a00d,0x16d6805,0x07acb57 },
  45563. { 0x0e6b07c,0x09ab4a2,0x1177490,0x13c38e6,0x051c4cc,0x19dcfda,
  45564. 0x1136389,0x1f880e8,0x1b88e34,0x124b03c,0x09ddb7f,0x099fe2a,
  45565. 0x1c77d18,0x03a114c,0x040cee7,0x0512eda,0x08477bf,0x014d053,
  45566. 0x1a3c108,0x1fbe21d,0x16d659f,0x16225da,0x1385c51,0x135d0aa,
  45567. 0x106c2fb,0x06ac18e,0x0f64f9f,0x059705b,0x16b607b,0x0e231e4,
  45568. 0x0a20ce0,0x0ea93c5,0x0aed251,0x110ea03,0x0471dd2,0x1bdf2f1,
  45569. 0x0675fbd,0x0c03e3c,0x145b2ba,0x172c6c6,0x06a5a05 } },
  45570. /* 128 */
  45571. { { 0x08f4f33,0x18f5335,0x1d2a4b9,0x0c9bd51,0x12fc6fc,0x144230f,
  45572. 0x094b3fb,0x011a6ac,0x008954d,0x0d8541f,0x0add996,0x18468d1,
  45573. 0x045bd68,0x0807c68,0x0a04d5e,0x0cf5c80,0x1c052b8,0x08c0e0c,
  45574. 0x01d9310,0x14a2d23,0x1d24986,0x1709aba,0x12c077e,0x06cef6f,
  45575. 0x09ae559,0x18c8b93,0x151b726,0x0da2e04,0x0097c8f,0x024ce20,
  45576. 0x1ee379a,0x04b3880,0x0df0032,0x14ec5bb,0x0b645f4,0x0c81235,
  45577. 0x0a7ab5f,0x1a3690a,0x192329f,0x168e1d9,0x0688054 },
  45578. { 0x1a5b86c,0x0b45528,0x091fc34,0x112aeee,0x0437e4d,0x1901949,
  45579. 0x101dbc5,0x09d5d08,0x19647a5,0x13d643e,0x1588b02,0x1496080,
  45580. 0x0f1e597,0x1853cf9,0x1bf971b,0x02adbdb,0x0c24d55,0x1579f78,
  45581. 0x1c11f3d,0x1f609dd,0x0137917,0x0faa5b1,0x0de49e6,0x097c170,
  45582. 0x0a32f31,0x18643af,0x0c3119a,0x02af8cb,0x018978e,0x08673f1,
  45583. 0x0bf4a32,0x19bcb0f,0x10fc3ba,0x1bdf6dc,0x1c722e1,0x1bba65a,
  45584. 0x0a8e10c,0x0191006,0x1b94ced,0x033b29e,0x00021f4 } },
  45585. /* 129 */
  45586. { { 0x1519d26,0x0891621,0x0114864,0x1a814a3,0x1dafac1,0x05dc4fd,
  45587. 0x1c7a552,0x1f398de,0x016844b,0x1799bae,0x1a35567,0x1ef22f1,
  45588. 0x05e7789,0x0fc5f0e,0x1d666d8,0x1bc8009,0x19a2cbb,0x0c04464,
  45589. 0x04c81b2,0x1344c11,0x0851893,0x1ffe698,0x086b92f,0x11fd5fd,
  45590. 0x0b3fee0,0x15e3326,0x07fc52a,0x03e7013,0x041ef96,0x0a66154,
  45591. 0x0d8360e,0x02fe03b,0x1fad8ad,0x1dbb9ba,0x15d9b7a,0x04df868,
  45592. 0x0425251,0x18b582d,0x1b67c79,0x10053c3,0x0798558 },
  45593. { 0x1106473,0x19d554a,0x08128b2,0x02b4c3b,0x15fafa4,0x0ab1e04,
  45594. 0x04d894e,0x10ffa79,0x195312b,0x1524048,0x0171dae,0x0b057f1,
  45595. 0x156c7e7,0x11863c6,0x1db6ad8,0x0881ae1,0x11c7747,0x1467182,
  45596. 0x1f6d861,0x1d7a29f,0x00966db,0x1d0c872,0x0c38107,0x1cc5c55,
  45597. 0x0c4666e,0x1eb5d08,0x09d3ccc,0x07aafc5,0x1b9b669,0x16e27f3,
  45598. 0x1f401aa,0x00da506,0x0f72f6c,0x1a0f57d,0x179a441,0x0e63198,
  45599. 0x0569247,0x081304b,0x0c23671,0x1863a1f,0x095d823 } },
  45600. /* 130 */
  45601. { { 0x00528a5,0x15ec30a,0x0f21abb,0x14a72f3,0x1268c2b,0x00a255f,
  45602. 0x06e293b,0x1db6379,0x182a7d7,0x17d5d86,0x0463607,0x01a29c0,
  45603. 0x0ef12c7,0x10e0aac,0x181c5a2,0x1ce7c62,0x0b7e4b7,0x099f214,
  45604. 0x0ebb277,0x0ecc6f0,0x035c631,0x1f70956,0x145cbfe,0x02f6548,
  45605. 0x10bfbbc,0x0951bef,0x01d07e0,0x0425f0e,0x088f9c4,0x05edf14,
  45606. 0x174f73b,0x0ead94a,0x1dc15aa,0x14720d4,0x03b2e40,0x07e6323,
  45607. 0x0aeadb0,0x0f0142b,0x13d51fb,0x1aaf0ca,0x00e2708 },
  45608. { 0x1e20f88,0x06629e6,0x00e489c,0x18beb62,0x1338272,0x058edfc,
  45609. 0x1867977,0x182a085,0x1b72d74,0x19ef10c,0x0aa9552,0x1516555,
  45610. 0x0616c49,0x1dd435d,0x0110f96,0x02d2a01,0x17220cf,0x0f735e6,
  45611. 0x026af44,0x1f58d75,0x039d59f,0x1df88ab,0x0a0c485,0x09974a4,
  45612. 0x08af2f3,0x0837269,0x1c1c9ea,0x04fe07c,0x017766f,0x03cfb48,
  45613. 0x0f9a10b,0x0f50224,0x13469bd,0x0b9dc65,0x0d1a90a,0x1a9181e,
  45614. 0x03990db,0x0bc2531,0x059e3f1,0x077f653,0x00d3dab } },
  45615. /* 131 */
  45616. { { 0x029c3cc,0x1bb7367,0x0f1a3e0,0x19e02d9,0x0b0507e,0x1ca670e,
  45617. 0x1e65978,0x083bd7f,0x173c50d,0x07e2937,0x1b38f49,0x14a85a2,
  45618. 0x014edd5,0x08e098a,0x0def766,0x10c0d76,0x0f2e33a,0x071a217,
  45619. 0x018a76a,0x12066f8,0x13312ae,0x122c955,0x15febb1,0x0570af6,
  45620. 0x18997d8,0x0bb0d49,0x068cdcc,0x1ad9197,0x06751fa,0x0ef1484,
  45621. 0x05a0965,0x03182e3,0x01e97fb,0x0b9abd4,0x084efda,0x13c9e91,
  45622. 0x1cb89f6,0x1c3e172,0x0d09a84,0x1d6b0e9,0x0530b4e },
  45623. { 0x0b7b5ae,0x13ad0dd,0x0fd3a7c,0x1a074af,0x1b69dc4,0x0e282dd,
  45624. 0x1712a91,0x00592e9,0x1416ac4,0x131b4f9,0x061771c,0x1cf15db,
  45625. 0x01735e4,0x06ea235,0x12361e7,0x160540a,0x0699e16,0x1426758,
  45626. 0x026c469,0x1edf48f,0x0784f73,0x0fd9527,0x1aa8310,0x1536d2e,
  45627. 0x1690293,0x15958fb,0x03c0ea2,0x02999c0,0x0d66c18,0x12adc22,
  45628. 0x005932c,0x0612a44,0x194e7d6,0x19138db,0x1390f68,0x13c0a5a,
  45629. 0x08b6a4d,0x1c59738,0x15dfd49,0x0a5018c,0x0909425 } },
  45630. /* 132 */
  45631. { { 0x15b4c2f,0x0d0a686,0x127349a,0x16b914c,0x0b8fc59,0x11bea51,
  45632. 0x12ceac3,0x0fd2b7d,0x0911103,0x0d0d3b4,0x0d4c8bf,0x00b529c,
  45633. 0x1c5810e,0x10bc7d7,0x137304a,0x19cc544,0x1b28e3d,0x02e1631,
  45634. 0x114b111,0x187e2f2,0x1161995,0x01a16a2,0x0d4cc3b,0x1df0252,
  45635. 0x1a60ab4,0x009d012,0x0a2eba7,0x0a9264a,0x03caf88,0x1303717,
  45636. 0x11c9746,0x06c937e,0x04091ab,0x162f8ea,0x1efdc13,0x078fa15,
  45637. 0x1d8b333,0x1e8eb15,0x05bd49e,0x0239fcc,0x0505701 },
  45638. { 0x134356b,0x025677a,0x1ef3402,0x0a96961,0x1df1de0,0x1026e0c,
  45639. 0x1f8173b,0x1c20435,0x0361b78,0x05ef344,0x034e2d9,0x198fdef,
  45640. 0x0ea324f,0x15852f2,0x0cdcb3b,0x0332dfd,0x0b36581,0x177827e,
  45641. 0x1ac2ad3,0x1cbaa0b,0x186e7dc,0x0411c62,0x078a6d6,0x1b0006e,
  45642. 0x03197bc,0x0e7ef2f,0x05201ae,0x17ebc8a,0x0e67ab8,0x0b45e8c,
  45643. 0x0b50cc2,0x1f3ec7f,0x0a7d04e,0x0c5da13,0x048ed70,0x19438fe,
  45644. 0x05dce22,0x0dc2411,0x19e7d21,0x0dfaa81,0x08ff0b3 } },
  45645. /* 133 */
  45646. { { 0x1f42cff,0x1717a1f,0x05f267c,0x1a386a6,0x03c19f9,0x10daa2d,
  45647. 0x04e4aae,0x065b6e9,0x14afa9a,0x0119582,0x1350da1,0x1a8dafb,
  45648. 0x150b855,0x02e7cc8,0x10d7881,0x1443115,0x0c7f001,0x0ebe791,
  45649. 0x15020c1,0x1a6b5dd,0x0fcd057,0x0caa9e6,0x0969294,0x1c57272,
  45650. 0x0579393,0x013af2b,0x00d08bb,0x0406656,0x053958a,0x002f1d6,
  45651. 0x18e6c24,0x0f3d362,0x08051a3,0x10c6b31,0x1027f19,0x1f6941b,
  45652. 0x0748e7a,0x0742bfb,0x158fa78,0x1dd8aef,0x071b28e },
  45653. { 0x1726bf8,0x15866cc,0x1cf1250,0x1238411,0x1290a3b,0x0cc7550,
  45654. 0x0439ec1,0x051fae5,0x1a25a91,0x153bc8f,0x1f5f6b1,0x1649806,
  45655. 0x1b2d33d,0x187141b,0x07bfac1,0x1c54184,0x16ee3da,0x1dfb86c,
  45656. 0x141d809,0x1b03230,0x17e343e,0x1426a56,0x12bac2a,0x18b6e98,
  45657. 0x1101fe8,0x1eede3a,0x1ab49ba,0x17f654d,0x18aa4ed,0x103435b,
  45658. 0x122ea04,0x1c22b30,0x14aa8f2,0x12e2764,0x076cfae,0x141a21b,
  45659. 0x0318295,0x1ff623b,0x0496b39,0x034661b,0x0729471 } },
  45660. /* 134 */
  45661. { { 0x0bbd495,0x02c8219,0x1cfff39,0x037ca92,0x130f4dd,0x0e1fa71,
  45662. 0x1b87576,0x00800d7,0x059ba72,0x077303c,0x0b1da10,0x1a7e858,
  45663. 0x1ec194f,0x14ff445,0x19dac4b,0x0042141,0x1dbec2b,0x18be6ee,
  45664. 0x02047b1,0x1a86d60,0x09e4689,0x1b9425f,0x09a9ae8,0x0fa8229,
  45665. 0x195b200,0x1a255e1,0x0c3c479,0x119bf3e,0x196402f,0x1f64749,
  45666. 0x01717fa,0x1dd68c5,0x0751743,0x0689bc5,0x1e0b1b8,0x07337f0,
  45667. 0x1eb292e,0x12f0b85,0x1f57ce5,0x1b0b003,0x0001c39 },
  45668. { 0x04a0912,0x02e5ced,0x1293d20,0x1488217,0x127cb76,0x18eb2de,
  45669. 0x12e3bb1,0x135de7b,0x1481684,0x007dd95,0x0918d5e,0x004d516,
  45670. 0x08ef6a7,0x0962273,0x1897220,0x0e9502a,0x12c4d7a,0x0312611,
  45671. 0x0c58c79,0x0ee06e9,0x1c2e81a,0x18edc8b,0x01393df,0x0c3db2a,
  45672. 0x065fd1f,0x11e8e82,0x072f79b,0x0209009,0x131fcfb,0x1060eb8,
  45673. 0x0558df3,0x115b48e,0x0e4dbc2,0x0cb9311,0x1172b3a,0x01eea61,
  45674. 0x0e28745,0x0b06e67,0x0bc4e80,0x0e17723,0x09132e6 } },
  45675. /* 135 */
  45676. { { 0x196099d,0x1f7f13c,0x0232015,0x1740dcc,0x172344d,0x0ac2c45,
  45677. 0x01d0342,0x1d3d695,0x079e5ae,0x09ed783,0x08beb79,0x1535211,
  45678. 0x0ac9560,0x083f383,0x12f84c4,0x048d4fe,0x19b2830,0x136af9e,
  45679. 0x1f328f9,0x11d1b44,0x1292a5f,0x1326147,0x1ad4772,0x03bfaf1,
  45680. 0x0310ef3,0x1f2a67d,0x08b281c,0x05c18f8,0x0da6839,0x0b4a520,
  45681. 0x1f040bc,0x0ea1a71,0x0bb07cc,0x1701a8b,0x0f8aeb6,0x1ae07d0,
  45682. 0x14d3c9d,0x09e0335,0x03b47aa,0x1caf328,0x07d0b03 },
  45683. { 0x1d94c63,0x1f51826,0x0ce97f9,0x0ae7161,0x17ef01c,0x0735a5a,
  45684. 0x09e3285,0x0ed2a69,0x0a53532,0x1b1166f,0x0b40181,0x140ef84,
  45685. 0x09af696,0x1ea3590,0x0f06219,0x05694e6,0x0bb626c,0x04b2a66,
  45686. 0x013cf13,0x11a7435,0x0b74a09,0x1696b9a,0x0d65be7,0x0aa3920,
  45687. 0x1021a5d,0x11fefe9,0x1c7b144,0x0574fa5,0x01aa39e,0x1492d96,
  45688. 0x09fe5c9,0x1f1d652,0x0e75d0e,0x09537e9,0x04b8646,0x1df574e,
  45689. 0x1b83e50,0x035a1d4,0x1798298,0x05fb56b,0x031b178 } },
  45690. /* 136 */
  45691. { { 0x034db92,0x0dd22a0,0x11361e3,0x031e69b,0x0397790,0x1aa619d,
  45692. 0x13cbb7d,0x1111a00,0x0cd563a,0x152caa5,0x1feb47a,0x191376b,
  45693. 0x18a29d6,0x186c5ed,0x0b7d956,0x1b68f51,0x02d8cdb,0x1fbfdc2,
  45694. 0x034c816,0x1c74070,0x1ca9b72,0x193e563,0x10cd6c2,0x14a8ebb,
  45695. 0x00bcbd8,0x12fffe3,0x07ae934,0x06deee3,0x10fca67,0x0e1c062,
  45696. 0x000f640,0x1018032,0x1dacf7b,0x0fc268f,0x163d5a0,0x02eb9ec,
  45697. 0x1cefbbc,0x13f31a2,0x1b47d5e,0x1ca7c0f,0x06fc0fb },
  45698. { 0x01b0e5f,0x088b5dc,0x0ee125b,0x0a5590a,0x182dd2a,0x19c3f86,
  45699. 0x08b50c9,0x0b26afc,0x0ba912c,0x1199542,0x177304f,0x0c8693a,
  45700. 0x138b71c,0x01c6c2e,0x060bba5,0x19a9c19,0x13cbf7f,0x1c85caa,
  45701. 0x03fb578,0x0737787,0x09032cb,0x0e2d621,0x08b19f2,0x00fb4ab,
  45702. 0x01217bf,0x07775f9,0x1682e79,0x0b580b5,0x09e0c65,0x0961477,
  45703. 0x0fc42ec,0x09176dc,0x0f3aee5,0x03748ae,0x1a722c1,0x1e95ce4,
  45704. 0x0a0e553,0x1330095,0x03f232c,0x1435299,0x0701935 } },
  45705. /* 137 */
  45706. { { 0x0626dea,0x06a0ed2,0x0e7f796,0x142b720,0x05ef66c,0x12732d9,
  45707. 0x04290c5,0x19f3350,0x1748cfc,0x1f36d56,0x10bea67,0x0d7a5e2,
  45708. 0x167ab9a,0x0ea38bc,0x12e85a1,0x1473749,0x1366bc3,0x1096985,
  45709. 0x0fd141d,0x0d4bb91,0x0c0e1f4,0x148a10d,0x0e1a394,0x1774389,
  45710. 0x0620659,0x1c83d34,0x1b69a62,0x1696aa5,0x0537072,0x0e6a72a,
  45711. 0x17d40e7,0x13d202c,0x0a07a9e,0x02efe21,0x1fcf5f5,0x015071f,
  45712. 0x1b5ceb3,0x0c8f2d1,0x0980106,0x1912d39,0x06c961e },
  45713. { 0x0e7eb46,0x1ee0de2,0x0d21c0e,0x0eb2d8f,0x16bac55,0x17eba6e,
  45714. 0x05f359a,0x1e69f32,0x1656ce6,0x11aa882,0x05c5d55,0x0a18649,
  45715. 0x0d3d1fb,0x11f7fd9,0x099e0f9,0x1457bfb,0x1f3eefa,0x1debcf8,
  45716. 0x1ebe7bd,0x1f7ca82,0x17a4a4e,0x112d2ad,0x1b3bd91,0x0e26608,
  45717. 0x132381a,0x0d188b7,0x1ee5589,0x165454f,0x027e96d,0x121d058,
  45718. 0x0f1a82a,0x0906567,0x18fe5d2,0x1d56022,0x037d6b7,0x14a4683,
  45719. 0x049e7f9,0x0d44e5e,0x12d4f01,0x1b0d3c4,0x0830883 } },
  45720. /* 138 */
  45721. { { 0x0557389,0x18e3101,0x02f2566,0x0f5bdf8,0x1fe5ce9,0x1879c1a,
  45722. 0x0f9fe0c,0x03d1277,0x116cfb8,0x1f06357,0x10a3f49,0x0cb7a08,
  45723. 0x026f64e,0x1bcf30c,0x17a4916,0x02394a7,0x1c1487e,0x1845189,
  45724. 0x116f3a4,0x1d87728,0x149e65c,0x0a6b3f6,0x0cef00c,0x0f046a4,
  45725. 0x16b2430,0x0e934f9,0x1e4eb4c,0x0f1cbb5,0x00890cd,0x15b863c,
  45726. 0x1a7c9a0,0x13c8bdf,0x015c34f,0x1d7f538,0x0e939b2,0x1826ba9,
  45727. 0x1e3fcc6,0x11bc523,0x03e310e,0x0ff2cc7,0x02376f9 },
  45728. { 0x0575b99,0x10f6057,0x037029b,0x1f0372e,0x1e14cb4,0x139ca3b,
  45729. 0x0e0934e,0x13be014,0x1fb235a,0x1a5ce40,0x18a5102,0x02beb7e,
  45730. 0x1a8d151,0x0f0b2eb,0x14d6d0c,0x07c779f,0x0a2b2ee,0x1ae897f,
  45731. 0x1460b9e,0x13094de,0x108e629,0x19e1b2e,0x1390f8b,0x1e6dce4,
  45732. 0x0709130,0x000cc99,0x03f4d15,0x1316940,0x196dce6,0x1e875d7,
  45733. 0x1508f13,0x046ceaa,0x00ba0ae,0x12bc253,0x10b6c0c,0x02a37b5,
  45734. 0x015464a,0x1a0c851,0x00a5a2a,0x0c2d7e2,0x08c4616 } },
  45735. /* 139 */
  45736. { { 0x11f36a5,0x0512c16,0x1cb7bff,0x051298b,0x0eded2b,0x076c278,
  45737. 0x136e10f,0x1366b4b,0x0db0e3b,0x087c4c1,0x068448a,0x15e00e3,
  45738. 0x16cce0e,0x1cd1b16,0x1995f90,0x0fc8fa1,0x15d6269,0x02a8b52,
  45739. 0x198d945,0x1c3eef1,0x09bc269,0x05ea813,0x178f7b7,0x038af8a,
  45740. 0x0230044,0x1c6f676,0x131c155,0x1707e63,0x089eabd,0x1db98f2,
  45741. 0x0d06f7b,0x072bf9b,0x0b678cf,0x0d80090,0x0473fe7,0x112119f,
  45742. 0x15f52cc,0x15e37a2,0x0458b2f,0x045698c,0x0155ea6 },
  45743. { 0x16fa42e,0x1178fc3,0x1b9e52f,0x12ff5bd,0x0b5e874,0x0432d7d,
  45744. 0x1c3d4e3,0x160d25c,0x0df8059,0x174cdc2,0x09eb245,0x00dd16b,
  45745. 0x0b0ceb6,0x16a31e9,0x148cd5c,0x013419d,0x0232a9a,0x1968793,
  45746. 0x0187ef7,0x1333187,0x110b252,0x13e0df1,0x1c46222,0x1155bc6,
  45747. 0x029c50d,0x19ecd89,0x00ec4d4,0x179f36f,0x029708d,0x037c7f8,
  45748. 0x020f29d,0x1b507df,0x1a013a1,0x1422252,0x14612ac,0x151d209,
  45749. 0x1cbd4ab,0x14259ed,0x1630cbf,0x0484b20,0x08f570f } },
  45750. /* 140 */
  45751. { { 0x0a9c508,0x1364516,0x1e037ad,0x04d3ad6,0x0dc5bec,0x156b001,
  45752. 0x0499a23,0x0282dac,0x149d726,0x0c20dcb,0x1cb9bd8,0x1cd99c8,
  45753. 0x1641e40,0x0fd3d43,0x0890990,0x12f415b,0x133cc39,0x022dcfe,
  45754. 0x105773d,0x1d1f52f,0x029db25,0x190974b,0x004933a,0x167b2ac,
  45755. 0x072c67d,0x0221d46,0x0df069e,0x1c5bda5,0x1027ff8,0x04e336e,
  45756. 0x11a52ac,0x0fcf457,0x09a057d,0x063b1fc,0x089b3dc,0x055b17e,
  45757. 0x08a2621,0x193473e,0x1307532,0x10f6588,0x03d171e },
  45758. { 0x0e49820,0x160b746,0x1724e0a,0x0581889,0x04ee45e,0x142c621,
  45759. 0x1e449cf,0x1f21d8c,0x046327c,0x0c6592e,0x16707e4,0x0ed78c2,
  45760. 0x1343e38,0x1baa2e5,0x0db8380,0x068fd6d,0x1ab5d12,0x0b25c1c,
  45761. 0x0c03550,0x0124e94,0x116972e,0x13440e0,0x09aaca3,0x0eb5086,
  45762. 0x00fffeb,0x06fa52c,0x08d6448,0x14b0059,0x09f4a30,0x0168190,
  45763. 0x001ffba,0x11cd527,0x118016b,0x108e55a,0x11c30bb,0x0f7338d,
  45764. 0x0b9d4ec,0x082d78d,0x0401058,0x1f0699b,0x0234e98 } },
  45765. /* 141 */
  45766. { { 0x0db9cda,0x1a9040a,0x1243fd0,0x0f2d5bd,0x19cfdc4,0x02c5b6c,
  45767. 0x0a9bebd,0x0630875,0x1743eaa,0x18fba0a,0x0d7604f,0x125cc2e,
  45768. 0x15915e1,0x0562cae,0x10688b4,0x1791a68,0x167c044,0x13825df,
  45769. 0x188e88d,0x0c08e37,0x15572f9,0x040ae8e,0x130c98e,0x163bb29,
  45770. 0x0230b76,0x133ca08,0x1c30722,0x05ca873,0x1c910df,0x00d6419,
  45771. 0x17d5ac5,0x10cb709,0x07c999f,0x015bda3,0x07e887c,0x003604a,
  45772. 0x1621695,0x0da9304,0x07a4f79,0x1c79c74,0x06a2130 },
  45773. { 0x13ca1a7,0x1b3d025,0x1a03486,0x0601819,0x0f42ed5,0x16783d5,
  45774. 0x14da24c,0x0b44599,0x15c25c3,0x1291d40,0x013418d,0x12b11ba,
  45775. 0x1becdd3,0x197c9d1,0x168d40a,0x16a60e7,0x03cd5e5,0x1a62f06,
  45776. 0x0c9a1dd,0x1ea90c2,0x0292ef9,0x1e0f3a1,0x1b61ffb,0x09cbdbd,
  45777. 0x0c29ea2,0x18d36cd,0x00ce127,0x115793e,0x1239050,0x1149207,
  45778. 0x14ec26c,0x0ff2686,0x191072c,0x15aa833,0x0e079ab,0x002054c,
  45779. 0x16feb87,0x103a04c,0x0a0c0fb,0x155389a,0x034f06f } },
  45780. /* 142 */
  45781. { { 0x148f005,0x0e3cf91,0x02c61a7,0x03be924,0x1b5c5d7,0x1732524,
  45782. 0x15f29b7,0x169fa36,0x0e82a4f,0x0dbfb9a,0x1e0d988,0x106972a,
  45783. 0x16637cb,0x1e943ec,0x0d0406d,0x1d95792,0x0ac0392,0x18ac87c,
  45784. 0x1dd7d38,0x1b86e6f,0x0c62280,0x07b530d,0x02cdbd4,0x0aad1b5,
  45785. 0x18304a6,0x1853a7a,0x0764c21,0x01af255,0x0895cc8,0x18c97e4,
  45786. 0x07db45e,0x0922927,0x18392fa,0x0adcf24,0x09f7507,0x0b5e6c0,
  45787. 0x1caa82b,0x16bcf12,0x1746914,0x163e822,0x0764d47 },
  45788. { 0x0ee8b9c,0x11181d1,0x152177c,0x070bbf9,0x1b9f72d,0x009d1b8,
  45789. 0x0e60c42,0x1ead685,0x13de741,0x146291d,0x0eed6f8,0x04b5e60,
  45790. 0x0f08576,0x164dfcd,0x1bca66a,0x0b66924,0x0080d44,0x110df56,
  45791. 0x1ae8b03,0x047405a,0x08646a5,0x18bfe71,0x18c0a86,0x00183d5,
  45792. 0x0a235e3,0x188a28b,0x09ed2a4,0x0a86e6d,0x0c89f74,0x1cf4606,
  45793. 0x17b4f02,0x081db11,0x081904f,0x1fe3802,0x0d58f2d,0x109e4d3,
  45794. 0x121b973,0x10ea9d1,0x0e04026,0x1864614,0x01c0dd9 } },
  45795. /* 143 */
  45796. { { 0x06a7d9a,0x10fb3e2,0x0733fea,0x097dbf2,0x0474333,0x1217973,
  45797. 0x0e9d11e,0x1528b06,0x1241ffa,0x1cc0028,0x1bf9ad9,0x150866b,
  45798. 0x0370979,0x1845920,0x0184fd7,0x023b8be,0x1cd64f2,0x035d917,
  45799. 0x015cb3f,0x1165474,0x014ae1b,0x00bca85,0x06783ad,0x16d9a98,
  45800. 0x0bb293e,0x0fff31a,0x151c289,0x0340964,0x115a0a3,0x1d64d1e,
  45801. 0x1a6907d,0x17e5fdb,0x1ed85ec,0x0a50077,0x1d7e06e,0x183eb03,
  45802. 0x1ef4a15,0x1ccb584,0x106f2a8,0x07360c0,0x052d8be },
  45803. { 0x1631a2f,0x09b7b7e,0x0372f45,0x0166a35,0x11fae7f,0x0931094,
  45804. 0x0431e6c,0x06ba34b,0x12bd0f4,0x16a43af,0x03a9c14,0x0da7256,
  45805. 0x1e9aedb,0x1c1d5c4,0x142af72,0x0325817,0x06289fe,0x1413d08,
  45806. 0x00a82f6,0x0d52c02,0x0814656,0x1be701b,0x16820c0,0x0c7280b,
  45807. 0x0d79f58,0x0fc985f,0x1b6f2a3,0x0e40336,0x1aa3f59,0x094377e,
  45808. 0x04a2480,0x0a46d71,0x137b996,0x01739d9,0x0e38a3f,0x0623a7c,
  45809. 0x080e8da,0x1c3fa0c,0x09175c1,0x0cfb5c9,0x06cff63 } },
  45810. /* 144 */
  45811. { { 0x09a8bb4,0x08219fc,0x1dc6f4f,0x0727731,0x02144c3,0x038516a,
  45812. 0x05b200d,0x13d056c,0x1e5da08,0x07e63ab,0x17f69a6,0x09def7e,
  45813. 0x0c54235,0x0f5e9a6,0x017094e,0x1ba1a31,0x085bec5,0x1171059,
  45814. 0x00a86f2,0x1777c2f,0x0ef0e71,0x184dc2a,0x05677b4,0x12ff4d5,
  45815. 0x0997989,0x0228b92,0x03607cf,0x019f1f5,0x0111525,0x1a8bb06,
  45816. 0x1aaa68e,0x1d9f08b,0x1b0ef7d,0x1688de4,0x188ee7f,0x0192673,
  45817. 0x0825608,0x1f4e2e1,0x1079f24,0x02ec27d,0x01d2c82 },
  45818. { 0x07cfc93,0x09a3ecc,0x0041ce0,0x17e30ff,0x047603b,0x0865188,
  45819. 0x0f27449,0x1e67f4d,0x0bb055b,0x00048f0,0x0be1f12,0x1e34747,
  45820. 0x0bbdf95,0x0a02a05,0x1a1ddc0,0x008b7c4,0x130d7fe,0x0ccc6fb,
  45821. 0x1c8ef0b,0x1026bf6,0x0c46b39,0x060af5f,0x0b08c3e,0x0aac381,
  45822. 0x018305f,0x03ff047,0x1369829,0x181f7e9,0x0d4bfc7,0x0e1270b,
  45823. 0x0481ba5,0x0e8c2fd,0x0163495,0x061073a,0x01a52b8,0x0c72e33,
  45824. 0x0131e2b,0x1349891,0x1dc8bf8,0x06c14a6,0x025486e } },
  45825. /* 145 */
  45826. { { 0x1572806,0x1cae529,0x0385861,0x12cad2d,0x12c8944,0x1991d75,
  45827. 0x0b25cfe,0x1ac2938,0x0409bc7,0x18aef13,0x0486cfe,0x14e58f2,
  45828. 0x1ba90cd,0x102655d,0x0be8538,0x0824ada,0x0f79160,0x1e5e6d3,
  45829. 0x10d7e51,0x10c4c36,0x0b10250,0x1c61417,0x16da1b0,0x14f2397,
  45830. 0x16d62f1,0x1362880,0x0586889,0x1638fda,0x1d74a66,0x0333138,
  45831. 0x09099e0,0x104850f,0x1ffeda1,0x07879da,0x0ffeef9,0x0997ca0,
  45832. 0x19482a7,0x1bf85f5,0x04fc75f,0x0b01109,0x0751b23 },
  45833. { 0x1c9be68,0x1dceb74,0x11b3565,0x08cfa21,0x1794b5c,0x11597a0,
  45834. 0x170f5dd,0x0235119,0x0a1b44e,0x0ca531d,0x03b2a1b,0x1773555,
  45835. 0x1ffb0bb,0x04b1ec3,0x0c3cb43,0x00ebbe9,0x02c5dc7,0x0dba983,
  45836. 0x064ce62,0x0e4d589,0x0cdefed,0x1c2bfce,0x1769818,0x1f18ecc,
  45837. 0x0392a75,0x165110e,0x157719c,0x1a4c9b2,0x0ecc8dc,0x1f915b3,
  45838. 0x0e9c013,0x03148b1,0x11aa9ae,0x1eb29fd,0x137e2ea,0x19d52c8,
  45839. 0x0ba0de7,0x1bc7401,0x1b1d6a4,0x05b9458,0x0144cc1 } },
  45840. /* 146 */
  45841. { { 0x189aa3a,0x1050e94,0x193564e,0x06b3cdc,0x183f228,0x1739976,
  45842. 0x0c32f4c,0x093d271,0x13c3cb2,0x0623262,0x1a9ab3d,0x0bf1f13,
  45843. 0x129750a,0x1a367e1,0x1f96efc,0x170128c,0x19d37b2,0x0e4dfd5,
  45844. 0x0cce71b,0x16e8a67,0x0deef8e,0x1f1dbb3,0x0ff807e,0x0d5d44e,
  45845. 0x14254ef,0x188598a,0x09ef986,0x0ab87be,0x0184885,0x16c0eec,
  45846. 0x1e5c3ed,0x177ce29,0x01af3a4,0x07b49ed,0x005e746,0x12aebe4,
  45847. 0x0465b83,0x047e359,0x0a54770,0x066d709,0x0874ecf },
  45848. { 0x1b3f6be,0x17c1f5d,0x08f5892,0x1211768,0x1578fbb,0x039a93f,
  45849. 0x0c2eb5e,0x084ac47,0x0a62e04,0x1b2cdec,0x0dbde70,0x02cffc4,
  45850. 0x062903b,0x129f935,0x090c31b,0x0259eab,0x1ae3ad7,0x19112a3,
  45851. 0x1bac9ca,0x1121aee,0x0df9b73,0x059eb14,0x056d3dc,0x1d5c959,
  45852. 0x013b053,0x1a74f87,0x039fc85,0x169ea27,0x1bae175,0x167ccc6,
  45853. 0x001d520,0x088a309,0x169bbde,0x178ae15,0x194b2bf,0x129e4f2,
  45854. 0x16bcaf1,0x11f795d,0x18d3e82,0x1039c98,0x031fb85 } },
  45855. /* 147 */
  45856. { { 0x15cd607,0x18368b0,0x0e98e60,0x1554658,0x080c9fa,0x1c898eb,
  45857. 0x1c16ddd,0x001d0f4,0x036708b,0x018809d,0x14a5fc4,0x01c3288,
  45858. 0x16814fa,0x1353cda,0x11560ea,0x17da8e1,0x0bf4b16,0x18181ce,
  45859. 0x0aabe34,0x0f951b5,0x08a518a,0x13ae6db,0x1ccc567,0x07029f5,
  45860. 0x0e738d2,0x1cfef50,0x02343d3,0x166a4e3,0x1ff032e,0x1304ee6,
  45861. 0x02ec2dd,0x07a9067,0x1ba8ea9,0x0a83d32,0x1609577,0x0830089,
  45862. 0x0a4a50b,0x05111f2,0x0795211,0x00031c3,0x0983230 },
  45863. { 0x1f3d5a6,0x10813ab,0x1734a28,0x10dd195,0x1fce564,0x0a8f9df,
  45864. 0x0e06c09,0x1e32b20,0x1935ebd,0x1366327,0x0ea9bac,0x0523810,
  45865. 0x0160611,0x047267a,0x062299a,0x1636b9b,0x173dd53,0x0ac0e1f,
  45866. 0x1ff1887,0x100952e,0x02fa78c,0x187d6e5,0x0c61d0c,0x0799e04,
  45867. 0x08da4c8,0x183fb80,0x169e691,0x0824543,0x115eb5c,0x069fa54,
  45868. 0x1826a38,0x1a0246c,0x0de157d,0x1695051,0x0ec997a,0x0a8bde8,
  45869. 0x188db28,0x11156f0,0x032ab42,0x13d245c,0x08abbe3 } },
  45870. /* 148 */
  45871. { { 0x02d2f01,0x034829d,0x0172d11,0x06bb8cd,0x127c319,0x1a5013e,
  45872. 0x02efc75,0x03ad521,0x15b50ec,0x0ed1a87,0x10b8980,0x08bc7e7,
  45873. 0x121d3dd,0x1c1b774,0x1b84742,0x12f39ec,0x08f474b,0x03f01c8,
  45874. 0x02e1e0d,0x0f8b733,0x1de919e,0x1f5e9e8,0x09d074f,0x1ec0b37,
  45875. 0x08e8d1e,0x123b1e3,0x04d9d38,0x173ff27,0x1e67f69,0x09f39f3,
  45876. 0x12075f5,0x15dd3c4,0x18dc326,0x0cc2634,0x1b6acef,0x0ea5e47,
  45877. 0x0f8fe8a,0x0f18d83,0x0ea57e5,0x1a187a1,0x00f15b4 },
  45878. { 0x10a8d85,0x1b31abc,0x0bc63cb,0x1dc4b2b,0x11bffba,0x1a8943a,
  45879. 0x1fb1892,0x0bba2b6,0x1323471,0x11cdb55,0x151075d,0x0532578,
  45880. 0x130cdd5,0x1b682c1,0x0003a93,0x1c6c0a9,0x152f6d6,0x190f7eb,
  45881. 0x04a4184,0x0fffca3,0x18cdc0b,0x12f7544,0x0da2960,0x13044cd,
  45882. 0x1ba9222,0x1d97676,0x02ef41a,0x0f15236,0x16b0cb6,0x16e025d,
  45883. 0x062c90d,0x195f1d5,0x17a99e7,0x102dde7,0x19b9c6a,0x03725a1,
  45884. 0x15993eb,0x068238f,0x1776efe,0x0f04070,0x0515db3 } },
  45885. /* 149 */
  45886. { { 0x15bef22,0x1f55537,0x1c4bb90,0x1040690,0x152d269,0x1d7b634,
  45887. 0x12139e8,0x0063c98,0x09a8c94,0x06a1a63,0x0626686,0x0e82a00,
  45888. 0x0c63e5d,0x1f47520,0x0e36ef3,0x10e42a4,0x0d29679,0x0653664,
  45889. 0x12b2f7a,0x16d5dc0,0x13ce73d,0x06dbfcc,0x0fda4ca,0x08bc669,
  45890. 0x19bbfad,0x11851fb,0x0df07c5,0x18a3d92,0x00a6de8,0x192fcd8,
  45891. 0x10d241c,0x025b057,0x1e6acb4,0x0cfe4a4,0x0db43b1,0x16b2036,
  45892. 0x1cf34e3,0x04db884,0x1300b2c,0x0fc357e,0x02de048 },
  45893. { 0x1d9d484,0x19179c6,0x0b3062d,0x06f8ef7,0x0334939,0x0c95c54,
  45894. 0x0e3c64f,0x04ab1b7,0x08e3fac,0x06bc6a8,0x1d29f60,0x1302e8b,
  45895. 0x1df0500,0x03be614,0x1caffb6,0x113f1a0,0x0f2c30a,0x1b3d5fc,
  45896. 0x0820835,0x0acfd53,0x173892c,0x17451d2,0x1096ac4,0x0aaa436,
  45897. 0x0faebf0,0x0f4e0b1,0x1ae53a9,0x1c389e4,0x11e546e,0x04ca1eb,
  45898. 0x0747905,0x087d17c,0x18183b8,0x1570592,0x120bbe7,0x008922f,
  45899. 0x13874a3,0x09d22bb,0x1e1b9a0,0x0e39885,0x06f6ac0 } },
  45900. /* 150 */
  45901. { { 0x1d6e3b1,0x01156a6,0x01a74e2,0x195ac41,0x1c78e1c,0x166f407,
  45902. 0x0e114b2,0x1c7cf08,0x0a8469f,0x10e60a5,0x1a3bc84,0x1b4fccf,
  45903. 0x088e8f3,0x069a3a2,0x00f45b9,0x063e9b7,0x1987986,0x19dd0ee,
  45904. 0x0931305,0x16b2ee1,0x101fdfa,0x031f6e3,0x07c284c,0x1b1fe50,
  45905. 0x1d6016c,0x1e4a324,0x0ef3156,0x04ce461,0x00412a2,0x0e302bb,
  45906. 0x1d80a86,0x0651f5d,0x119d5f1,0x1556ce3,0x1a7bd9f,0x0a4f972,
  45907. 0x119bafb,0x0129873,0x00b2fcd,0x199feb5,0x06e2c24 },
  45908. { 0x1af8793,0x18125d6,0x12398c4,0x0206b92,0x144bccf,0x1a805fc,
  45909. 0x19ade54,0x0cbd340,0x01d1167,0x0c8d4a3,0x04f1e1e,0x165d3fb,
  45910. 0x1595add,0x14972a4,0x14b00df,0x1cb9e0b,0x1189f03,0x1658a2d,
  45911. 0x16a87dc,0x1c91952,0x0e4f81a,0x0109ad3,0x080fc9c,0x1654faa,
  45912. 0x0f5a249,0x15195e7,0x000b5fc,0x0d0f520,0x0745b00,0x1914363,
  45913. 0x014bdf4,0x10ca0e6,0x1a8a875,0x0e2c79e,0x0210ba3,0x0b7c717,
  45914. 0x1bf1118,0x045f9a6,0x03e45ad,0x01b2f81,0x05af7fd } },
  45915. /* 151 */
  45916. { { 0x0a224a5,0x0dca87a,0x1ce957e,0x0998a04,0x0190457,0x1f8feaa,
  45917. 0x04cc190,0x10669f0,0x10e50f7,0x0b400dd,0x005c4a6,0x080712b,
  45918. 0x16866d7,0x12048e9,0x0690176,0x0dfcfb7,0x1df16a4,0x078f1bc,
  45919. 0x0efe45a,0x09527f0,0x0bca8d0,0x1a99590,0x0b9320c,0x0543821,
  45920. 0x134b1f7,0x0da4ce9,0x1f60657,0x1f7932e,0x014b5d8,0x1efffdd,
  45921. 0x1db2bac,0x0edb5e8,0x0fef022,0x1b97a30,0x17fb6d6,0x0497291,
  45922. 0x16dfb06,0x02e492d,0x152b946,0x1032c13,0x027a9c3 },
  45923. { 0x12a93af,0x1b9a378,0x0d35cf0,0x18aa6cc,0x028b707,0x00c9e88,
  45924. 0x1635526,0x13b1df4,0x0ef21b6,0x1c1d2e6,0x0283893,0x01474f1,
  45925. 0x1805cbb,0x12d89e4,0x00c5e05,0x0f09802,0x0582b73,0x17f5107,
  45926. 0x140d87c,0x0e2741c,0x02d9df9,0x07e8661,0x0c51268,0x0bc5c36,
  45927. 0x152e77c,0x0678c1b,0x16d9c11,0x1c89ad7,0x1e177a6,0x0f4ab99,
  45928. 0x08c04b7,0x011dc58,0x0b49669,0x18ca4b4,0x15047d7,0x1fb3760,
  45929. 0x0acd886,0x0c1638b,0x0491254,0x129f7bd,0x01c6906 } },
  45930. /* 152 */
  45931. { { 0x0880026,0x13e8b9d,0x17c976d,0x0024bb2,0x09c4f0a,0x165bd24,
  45932. 0x01544fd,0x14a520a,0x15cbbdc,0x15918e8,0x0f2f4cf,0x19332e5,
  45933. 0x1af8cff,0x16aad01,0x13bd352,0x0f85f96,0x1ca2286,0x0ca26a3,
  45934. 0x1ab46a9,0x110a901,0x104596d,0x1c65e45,0x1da95f3,0x0bcab40,
  45935. 0x1844b00,0x04beff2,0x0474628,0x1d3cfc3,0x123c745,0x1374294,
  45936. 0x0e655e8,0x0febb66,0x0867b79,0x1686468,0x02398ef,0x184aa68,
  45937. 0x089ad23,0x0b72eab,0x10ce456,0x1ad4a09,0x07b8c13 },
  45938. { 0x0fb6901,0x01d56a9,0x14ecbf1,0x122d944,0x1c0313f,0x0d56e30,
  45939. 0x00c2945,0x18428eb,0x07f577d,0x09e8c93,0x0f03772,0x1d1dee4,
  45940. 0x1a26e52,0x1f5cfb6,0x0783ae0,0x06eda5e,0x082f180,0x0ccbcef,
  45941. 0x020d24e,0x051d976,0x18e743e,0x0e51ce1,0x068b547,0x1c7ed6b,
  45942. 0x063a9a8,0x1383730,0x092e6cc,0x19e3b47,0x18915d4,0x0451697,
  45943. 0x049b94d,0x0a0a0f2,0x075e3e0,0x1c1fd2f,0x195c834,0x135dff9,
  45944. 0x0fd2fb2,0x16a9e64,0x1334075,0x1ecd2de,0x00e3c3e } },
  45945. /* 153 */
  45946. { { 0x1ee1d83,0x19be090,0x1e20ef0,0x1af0f6e,0x17e08f6,0x07d2674,
  45947. 0x07f304e,0x0b17ee1,0x1a0348e,0x17bbb23,0x199cb6e,0x15794ab,
  45948. 0x1d04f8b,0x1eaf62e,0x14a4675,0x124301d,0x1ff33e9,0x1c67325,
  45949. 0x12c166b,0x13f8ae4,0x12baac0,0x1cee2f1,0x141a0c7,0x0b5ed52,
  45950. 0x0267746,0x1fc1351,0x1b25fc7,0x18bdfcc,0x0087fd3,0x106b5e3,
  45951. 0x1ac5457,0x1551db8,0x1a39c5e,0x0f694d8,0x1aec39e,0x107bb02,
  45952. 0x1c3788b,0x009bb4d,0x09471b3,0x1c78125,0x0463098 },
  45953. { 0x0bd0fa7,0x00463e4,0x1924e99,0x039cd7b,0x1176431,0x1f7bdf6,
  45954. 0x18420a0,0x071c62b,0x199b5d9,0x109e63b,0x1269ae0,0x0b028b4,
  45955. 0x11af7f1,0x1294f26,0x03f6c3f,0x193ada0,0x177ce66,0x12ae9c7,
  45956. 0x0f52e54,0x0f99803,0x1986b4f,0x04d7b8f,0x0365d6d,0x0c9a015,
  45957. 0x19fcbcd,0x16b895a,0x12968ee,0x10c1ca0,0x1c89f11,0x102215a,
  45958. 0x07db65d,0x0f47c46,0x0d0c659,0x05d497f,0x10cc5e3,0x1cb0229,
  45959. 0x0698e11,0x13a6033,0x0e16b8b,0x1274691,0x07f8fd0 } },
  45960. /* 154 */
  45961. { { 0x19428af,0x0c96560,0x1997c91,0x0274610,0x192a1c8,0x05debf8,
  45962. 0x0604b8c,0x17284b1,0x1836c6b,0x06d8391,0x19261c4,0x03d2b31,
  45963. 0x0b9c7a4,0x1756b7a,0x1fc5e79,0x0588915,0x1b97586,0x1387c7c,
  45964. 0x1c8660f,0x16046ed,0x11526b3,0x0dcc732,0x09760fa,0x0a24314,
  45965. 0x126a8d7,0x0d31d96,0x0a75bc7,0x0a10503,0x081f749,0x0682d2d,
  45966. 0x1c637de,0x1c8d0e8,0x19ee559,0x1ec666b,0x095d9e1,0x0a40c19,
  45967. 0x08476c9,0x1d427fd,0x144c509,0x0a3cc86,0x087b64c },
  45968. { 0x130d3c4,0x037b2a5,0x1c521fd,0x184769d,0x0dec4c5,0x0526b46,
  45969. 0x11d998f,0x0db676e,0x1cf3fb5,0x0f9a134,0x1f51a87,0x13881fa,
  45970. 0x1dd4f13,0x1534d45,0x0df1f1d,0x1afa547,0x0c9cbad,0x0772b5a,
  45971. 0x12508cd,0x1fe6855,0x1da3b28,0x1d3c378,0x0011bf7,0x001905c,
  45972. 0x1149cb7,0x0cbe72e,0x0542599,0x1461df0,0x1f4bddc,0x0304fe7,
  45973. 0x1a11288,0x08924a4,0x12f65e7,0x10f9c07,0x14b3500,0x01cb6ca,
  45974. 0x042dbbd,0x154e150,0x18bd5df,0x0f9b380,0x08c9526 } },
  45975. /* 155 */
  45976. { { 0x1c1abb1,0x081972f,0x1d0d995,0x0825fc8,0x0215af5,0x182f7a9,
  45977. 0x1d580a7,0x1d3faca,0x1dc191b,0x0739992,0x18e6c2c,0x0cbd810,
  45978. 0x137ab3c,0x0e1f333,0x141fd44,0x0aaaace,0x1c3c861,0x0b1c5f7,
  45979. 0x0bc312b,0x03119e8,0x186d5d0,0x0e6c4b0,0x010e8c0,0x18ce83d,
  45980. 0x003f7b2,0x0e8022b,0x13e8f34,0x0ea8b81,0x00672ef,0x17fea52,
  45981. 0x177d84a,0x08b73d1,0x0197c9f,0x116ba2b,0x0df61e4,0x1f68a64,
  45982. 0x0b2d59b,0x09971d2,0x1a85afc,0x0e77094,0x08afa1b },
  45983. { 0x193ac70,0x0cb7573,0x1441acd,0x1dddedb,0x0c94ef8,0x0117202,
  45984. 0x13e89c1,0x0c724d6,0x0e9e5d7,0x0638ee7,0x0aab7f2,0x16e1ea2,
  45985. 0x1f352fc,0x1441cba,0x1ee84e2,0x0762636,0x190058c,0x0abcc89,
  45986. 0x1dd03f4,0x0412552,0x0697969,0x0d8b058,0x066b651,0x106f564,
  45987. 0x1438810,0x1b8de31,0x13c5d2e,0x0ddc238,0x1b80eb7,0x1fe0d58,
  45988. 0x0298446,0x0e1d88b,0x082bac8,0x09992de,0x049cc4b,0x11ddcc0,
  45989. 0x1240adc,0x08c58d5,0x024f2d0,0x12256b4,0x0672111 } },
  45990. /* 156 */
  45991. { { 0x15cf9bf,0x0c9837a,0x1b6647a,0x1148d72,0x1b04530,0x1d32efc,
  45992. 0x0787679,0x1775c78,0x1c731bc,0x09e58a8,0x1629851,0x044f49a,
  45993. 0x0214be5,0x0be3a66,0x16b248a,0x001ac73,0x045822e,0x1a687bd,
  45994. 0x18ac0f7,0x163aa38,0x0b2dafe,0x125d50c,0x0ec770e,0x056e9e1,
  45995. 0x07178df,0x119bf9e,0x1a25ada,0x19a6514,0x0e055ff,0x0a2a0ee,
  45996. 0x01fa57b,0x0d49c57,0x1fbc76b,0x0ee74cb,0x1fc7e96,0x03cbd8c,
  45997. 0x0c0367c,0x11b4566,0x08ff814,0x02ca9c9,0x07c8639 },
  45998. { 0x07388cf,0x0a5af65,0x14e157a,0x018066b,0x17cc0a6,0x17c2dd0,
  45999. 0x0de2d85,0x10136d3,0x1101229,0x02e8177,0x1429e5c,0x1d0039f,
  46000. 0x12565a6,0x1e8f71a,0x1d2a5b5,0x13b5bd6,0x0ed427b,0x1ae4419,
  46001. 0x1b54cc3,0x150a51c,0x0ee896e,0x158c692,0x0c36218,0x1f273ee,
  46002. 0x18ed59f,0x1294e69,0x0804180,0x121f934,0x03b3ff6,0x045c118,
  46003. 0x1a718b6,0x1baa568,0x042d7a4,0x096c9fe,0x1e8a32b,0x100df1b,
  46004. 0x0092043,0x11b0483,0x156b540,0x0b1f9d0,0x0325827 } },
  46005. /* 157 */
  46006. { { 0x19e8c60,0x0722f9a,0x061bac8,0x0a6c994,0x071bb8a,0x1c70886,
  46007. 0x141c77f,0x0f00562,0x14c93e5,0x1a748e9,0x0743601,0x1c01705,
  46008. 0x1ac0326,0x113541f,0x0648961,0x1413c78,0x0d5fb29,0x11c3d32,
  46009. 0x16b1720,0x147a69c,0x1a29caa,0x12d6d16,0x03b5a17,0x052ca1d,
  46010. 0x00267eb,0x179c939,0x05d8e00,0x0e30963,0x0b1aeaf,0x0e876fb,
  46011. 0x1748fd7,0x04bcc24,0x01fa347,0x1950d5f,0x1e74321,0x1fac50f,
  46012. 0x0c57c3a,0x1549e95,0x1d95926,0x0e2b7b4,0x01a4e6a },
  46013. { 0x14d1267,0x1376f2a,0x0d20684,0x0639a05,0x17f9453,0x18fd8e9,
  46014. 0x1c13338,0x025ae15,0x1097dc0,0x1a08585,0x1edb173,0x1a2e6d8,
  46015. 0x05930e1,0x0344884,0x0bfb907,0x0c71f20,0x0a779fb,0x19a4dd2,
  46016. 0x135be37,0x18b0435,0x0acea16,0x009703b,0x1ecee0f,0x003a29b,
  46017. 0x1033be5,0x16d35c6,0x0883cb4,0x0b27a8a,0x1f18800,0x0936cce,
  46018. 0x098dd49,0x13fd667,0x032351c,0x17a2b65,0x0ef07db,0x15b2268,
  46019. 0x15b9dc8,0x042bed9,0x1a0cb1d,0x1270b69,0x0856a7c } },
  46020. /* 158 */
  46021. { { 0x10a5583,0x1e80106,0x162a801,0x1bdb48c,0x0f1301d,0x0c9cdf1,
  46022. 0x1e590d3,0x06d2380,0x0a70c08,0x065b3c0,0x0795028,0x1f2b7d0,
  46023. 0x18c0b4d,0x0ea5645,0x0ef34d1,0x0c472d9,0x0d05475,0x12be297,
  46024. 0x00173ad,0x05b9483,0x0255cac,0x15bc9a2,0x0457b9a,0x193454d,
  46025. 0x1ef3124,0x13a1b36,0x1e304b1,0x1a772c5,0x1b7c3bb,0x078dbed,
  46026. 0x16eaad9,0x1c45772,0x00e4553,0x11dba1e,0x1aeb131,0x024811f,
  46027. 0x0a4da63,0x13b9891,0x16900f2,0x1098c6d,0x0628890 },
  46028. { 0x0b8d208,0x1fea9c6,0x1b52915,0x12a87e0,0x1a8f800,0x17f955b,
  46029. 0x18553cb,0x1cf6cdb,0x1f72517,0x0ed9475,0x0274b3f,0x1ccdf27,
  46030. 0x0e0149f,0x0c2dc46,0x1a1dcff,0x087eef3,0x10b0ba5,0x0229704,
  46031. 0x02c0ff0,0x136b9f6,0x177bdeb,0x05362f6,0x0c44d12,0x1f806e4,
  46032. 0x1f3cf8f,0x0251b04,0x15706d3,0x179388d,0x059be92,0x1df9c7d,
  46033. 0x04799bc,0x19b604d,0x196bf5f,0x1c47c89,0x0750027,0x07e3d8b,
  46034. 0x0ad9dfe,0x081a2b1,0x135630a,0x058b5b4,0x079d812 } },
  46035. /* 159 */
  46036. { { 0x0529507,0x0726755,0x1400535,0x08e8cab,0x056a081,0x07e23a0,
  46037. 0x028e13c,0x11d81a6,0x03443cb,0x14101f5,0x05ca362,0x1f612fe,
  46038. 0x1233c62,0x1a9077a,0x0e373f6,0x13a7d14,0x15d7cac,0x0507c86,
  46039. 0x1cf3a94,0x0f617f0,0x01cb28a,0x1d36362,0x14456b8,0x0702583,
  46040. 0x171daa1,0x03f51a8,0x1589354,0x0ba9774,0x18f42f2,0x0944bf4,
  46041. 0x1c6476b,0x12d4826,0x1d6b1e9,0x12dbbff,0x0496da7,0x0fa8d84,
  46042. 0x00c4f70,0x095a121,0x155eb1f,0x12b0284,0x02ab3af },
  46043. { 0x05372a6,0x103a635,0x0e9e1b2,0x1cac525,0x128fb83,0x1a0e7ab,
  46044. 0x05b71dd,0x13ae8ab,0x1520ef4,0x05a6750,0x1191c9c,0x1c68c3c,
  46045. 0x1d1472f,0x1fdc562,0x15af598,0x180e3e9,0x0c9c10b,0x0a37296,
  46046. 0x1c68d18,0x129dfc6,0x0877287,0x0c13b7f,0x092141c,0x1deb569,
  46047. 0x157739b,0x00af6d6,0x1cfc572,0x0985b3f,0x0395c32,0x0872c7c,
  46048. 0x1546225,0x1016d50,0x0e40996,0x001f0dd,0x08b22a2,0x1c9ea7c,
  46049. 0x039d25e,0x119fb08,0x0272abc,0x06a4a08,0x007db2c } },
  46050. /* 160 */
  46051. { { 0x17d4703,0x1dc6d81,0x02e71fc,0x1f8be91,0x083708d,0x18ea017,
  46052. 0x00c3e11,0x1d23f75,0x05a2faa,0x0af7469,0x13f07a9,0x1e20a80,
  46053. 0x11c2e5b,0x1516ab2,0x1f5409e,0x1ebf2c8,0x00c7eba,0x19bd29e,
  46054. 0x16cc2af,0x1e17652,0x13ba7ad,0x1f6b264,0x1698b87,0x1de94f0,
  46055. 0x018c0e2,0x027bffe,0x0534b34,0x073bb3b,0x00af021,0x1d5baf5,
  46056. 0x13c94fe,0x01fdf35,0x08100ea,0x0ad53be,0x0137218,0x12e98a7,
  46057. 0x1fe5206,0x143416c,0x15d672c,0x11f9efb,0x008b6ca },
  46058. { 0x16c3b5a,0x12df501,0x0d2f813,0x04ff3e5,0x1872610,0x1cbe079,
  46059. 0x095c0a5,0x14753f9,0x182879e,0x12b0c05,0x1c377c5,0x1376c0f,
  46060. 0x0715338,0x13d8704,0x08488f1,0x0ff8f33,0x0ec9d89,0x0868c04,
  46061. 0x05bb7c6,0x00e2352,0x1118947,0x158390b,0x1e3d4bc,0x111116d,
  46062. 0x129ffd1,0x0802ec5,0x15331be,0x1e3c458,0x04877fe,0x10b2f59,
  46063. 0x097100d,0x06a8f2a,0x1a95233,0x0a3457e,0x1085a18,0x11ac454,
  46064. 0x14faba0,0x021d83b,0x09f4974,0x0041a63,0x02c337b } },
  46065. /* 161 */
  46066. { { 0x022fa65,0x182de75,0x18e9ec8,0x09a2b3e,0x1e183ef,0x1ac91fd,
  46067. 0x161f4fc,0x0a668e7,0x0c11d77,0x13fd983,0x1533fec,0x1cd6540,
  46068. 0x19702e7,0x178c2b0,0x1a7e5f2,0x0a38a79,0x0434e7d,0x1c1aa81,
  46069. 0x0d5ab16,0x1c7b05e,0x1131a63,0x156bb22,0x019edf2,0x0e3f93b,
  46070. 0x1e6afa6,0x0bbf742,0x18ac1f3,0x1730bdb,0x1a51933,0x0c587fe,
  46071. 0x0d81f56,0x15285b8,0x10eca39,0x10c54d8,0x13b9418,0x142fe7b,
  46072. 0x06b7d5c,0x0a74688,0x0c724f6,0x069db10,0x0509b26 },
  46073. { 0x0caed54,0x0a0a724,0x1a5ec6e,0x1997ea3,0x17a78c6,0x14d92c3,
  46074. 0x0323537,0x0f148d1,0x091ee3d,0x01209be,0x1b99300,0x0469c61,
  46075. 0x18a68f9,0x040c86b,0x0c956f2,0x0d216ae,0x05fba80,0x020f470,
  46076. 0x10d53d3,0x071b09d,0x0816500,0x0b6fd29,0x0c63c0b,0x16c7fb5,
  46077. 0x19007cc,0x02ae23f,0x0fa62b9,0x13a901f,0x0e319d2,0x0e912e8,
  46078. 0x0652b11,0x004db6e,0x06f3575,0x0c3dce8,0x1880b0d,0x0ee6773,
  46079. 0x0c31772,0x041cc91,0x01d4889,0x14ea977,0x01592d5 } },
  46080. /* 162 */
  46081. { { 0x17453f0,0x06cd167,0x07c15de,0x15db078,0x0ffb899,0x1415d3d,
  46082. 0x01b4f82,0x1035cca,0x0ea3d50,0x164270d,0x0a8e2cc,0x1181021,
  46083. 0x019ad52,0x1e9be82,0x1f6c082,0x1c83f63,0x1e1d06c,0x13c6b65,
  46084. 0x19d2dfd,0x0fe1e05,0x1022d28,0x1ae21dd,0x1d73495,0x034e367,
  46085. 0x0f2f3f8,0x1fa3694,0x1718cf9,0x0cb763e,0x1c580ee,0x1e0e627,
  46086. 0x094cb97,0x176f60f,0x155539f,0x1579d66,0x11c70f2,0x1b6b528,
  46087. 0x0cc22d2,0x0c5efa2,0x1ddf2e5,0x17aef44,0x01614bd },
  46088. { 0x10ab04d,0x1811876,0x0ba9307,0x00dc410,0x0e347b0,0x162dafd,
  46089. 0x0f18f10,0x06b3e21,0x1de0199,0x029cf37,0x142096c,0x09cecbb,
  46090. 0x16d89bd,0x1de76d0,0x0983fbe,0x1946524,0x15ce62a,0x1c5553a,
  46091. 0x1b20b17,0x0c5f52b,0x0768ed7,0x008c328,0x0679930,0x05c6919,
  46092. 0x16245c9,0x0b42bee,0x1cc7a9b,0x1b7114e,0x1447360,0x095583d,
  46093. 0x1fbbc00,0x02e3ae1,0x1356b94,0x048d85c,0x18a00fe,0x05cd160,
  46094. 0x179c20a,0x0a529d5,0x01ca0e9,0x18f6016,0x0489656 } },
  46095. /* 163 */
  46096. { { 0x1353c25,0x124dd38,0x189390d,0x0227ecf,0x117f27a,0x0f5cf1a,
  46097. 0x0cce870,0x1f2217a,0x078e29b,0x070e02e,0x0fc5765,0x1b2e8e8,
  46098. 0x1084fe7,0x086d16f,0x01d2422,0x077c339,0x1a75367,0x0c1201f,
  46099. 0x0eba86c,0x1ebb683,0x0ead7eb,0x1a920c0,0x13f82b8,0x1ea187f,
  46100. 0x1873fc2,0x06c8e8a,0x19c1987,0x0d0a35a,0x1e8c2c1,0x146cd28,
  46101. 0x06600a5,0x1c02c21,0x1d1a9cd,0x1f52b73,0x1226a29,0x10562a7,
  46102. 0x06e3c49,0x00dbc48,0x0772db5,0x1d3aced,0x0082bb2 },
  46103. { 0x0d6615f,0x077a362,0x0a71860,0x0203730,0x1c629dc,0x1932657,
  46104. 0x0bb003e,0x189bc44,0x010ecc2,0x0a2bf03,0x08b1371,0x133e3dd,
  46105. 0x0c95ce5,0x07ce2d9,0x0cfe9ca,0x021f208,0x062cd63,0x1f701aa,
  46106. 0x18b8894,0x0af8779,0x1e4484c,0x0d4b6c3,0x1b23b0c,0x0a58b4e,
  46107. 0x1e393a4,0x11a985f,0x02811ec,0x0b25628,0x18545ec,0x1f0c600,
  46108. 0x119ef62,0x0b82f18,0x14e0107,0x1802dbc,0x0518b88,0x06908e3,
  46109. 0x022a54f,0x12f11bb,0x0410899,0x08d2039,0x036451a } },
  46110. /* 164 */
  46111. { { 0x1893e71,0x0168c0c,0x02085e0,0x16a7344,0x01765d8,0x01767e5,
  46112. 0x1a8048c,0x13bf8d5,0x1365bf5,0x0a67a8d,0x0caa023,0x1ae41a4,
  46113. 0x0787741,0x0c74021,0x0d0facc,0x073d958,0x12fe747,0x12a9f65,
  46114. 0x0a2c1f2,0x14f3503,0x0b3aaec,0x112b7a5,0x0227fcc,0x143a3ee,
  46115. 0x1d7293f,0x10b2f4a,0x1bd8aa6,0x0c0ad35,0x08ddc22,0x1119550,
  46116. 0x12979dd,0x036f76a,0x1fabec3,0x0ab73c9,0x0559d0f,0x1e91441,
  46117. 0x0b0ebef,0x0e6d897,0x1f3c5d2,0x148d371,0x0705307 },
  46118. { 0x088310b,0x1260272,0x15edea3,0x04a64b9,0x12726e3,0x01f7d60,
  46119. 0x162c126,0x026ba1f,0x002ddb9,0x0b72a96,0x05a171e,0x07eeef7,
  46120. 0x030eeca,0x18af925,0x1d9ba26,0x192f336,0x0d648ef,0x03e139b,
  46121. 0x000871b,0x032d0b5,0x11ea3d6,0x1c50597,0x1f8cf89,0x0edad61,
  46122. 0x09879b6,0x05f4ae3,0x046bd38,0x00e8e63,0x04ee55a,0x1af89b6,
  46123. 0x0e68bea,0x0b3cbe7,0x138b8ff,0x17f3734,0x1690e72,0x003c229,
  46124. 0x0a6ad12,0x0caf61b,0x0abb325,0x1a0afcc,0x080f79b } },
  46125. /* 165 */
  46126. { { 0x0af09b3,0x1a153b0,0x1850f3b,0x1b267bf,0x1c016eb,0x02f5541,
  46127. 0x1c783b6,0x192e419,0x1ceaa3b,0x07af4cf,0x01be5f5,0x13a56e2,
  46128. 0x127216b,0x04b3456,0x1cd30db,0x0ca3ecb,0x0bc5b0c,0x1547dc1,
  46129. 0x0bf6937,0x085e39e,0x059e20f,0x16690fb,0x1acc6ac,0x07a2c31,
  46130. 0x176c7a1,0x1f2dbd3,0x08e198a,0x1888204,0x108e0be,0x0d38656,
  46131. 0x0032097,0x0045803,0x1299079,0x1cffecc,0x1680abb,0x00ec477,
  46132. 0x15c58b5,0x027a79f,0x1fc677a,0x149b049,0x05f5a5d },
  46133. { 0x08311dc,0x192bf3f,0x04d95cd,0x028cd9e,0x1ef94f5,0x0e510d6,
  46134. 0x05916c1,0x06f4e7c,0x002e4ab,0x0754d9e,0x04596ce,0x15930af,
  46135. 0x047760e,0x012580d,0x1f7411f,0x0ab09bf,0x1d13fb9,0x10c46a7,
  46136. 0x15522f6,0x1871704,0x1cacfaa,0x182cf4e,0x069e69b,0x144e01e,
  46137. 0x1720f09,0x1244c1f,0x13ee29f,0x19774aa,0x01fad58,0x0cb423d,
  46138. 0x178e286,0x0b57ad6,0x1856547,0x0b76108,0x14c7cdc,0x16ea227,
  46139. 0x0212907,0x08f3c0a,0x162244e,0x0021b82,0x05319c8 } },
  46140. /* 166 */
  46141. { { 0x161c3af,0x009b735,0x0da08c8,0x1c0f697,0x1d40f2d,0x064bf80,
  46142. 0x1b9fce0,0x074ca3b,0x06a8c31,0x0bc5d38,0x072842a,0x0fac402,
  46143. 0x1b22c58,0x158fa22,0x0ee8862,0x089cc91,0x107e504,0x0c62f57,
  46144. 0x10bf33e,0x13e0548,0x093d554,0x179ec02,0x09591d1,0x1808b22,
  46145. 0x04f6179,0x043a169,0x02af722,0x0c01f43,0x138f8f1,0x10056f6,
  46146. 0x11972e1,0x12475d6,0x0bf9b90,0x02bc552,0x18d4787,0x09ac7fd,
  46147. 0x0bb9ea1,0x04e2d67,0x13fc3cf,0x09be234,0x03d1331 },
  46148. { 0x0513d1e,0x03316da,0x0af7973,0x0baab2a,0x1e78a8c,0x1c36856,
  46149. 0x1e8ff9f,0x18bd146,0x07a04f0,0x1168952,0x1741b32,0x0dc85c4,
  46150. 0x114c669,0x1909b03,0x1851a62,0x1c396a4,0x01b89f6,0x17a6938,
  46151. 0x03bf657,0x1ac2ef0,0x0907aaf,0x0262ddb,0x19b5ceb,0x01b66b5,
  46152. 0x074ac42,0x1d024f4,0x13c9d47,0x02c63bc,0x1a2edd1,0x199b50f,
  46153. 0x136ca7d,0x16ffaf2,0x0406864,0x1c95326,0x074f88b,0x0ce7964,
  46154. 0x0043cc7,0x1482731,0x11ab7ab,0x13f6645,0x067f28a } },
  46155. /* 167 */
  46156. { { 0x0148ab5,0x1d92c65,0x0145f05,0x1f678c0,0x19a1976,0x1946fcd,
  46157. 0x01a6323,0x02fd44c,0x0e8d450,0x1d9663a,0x02908a1,0x06520af,
  46158. 0x1237257,0x0bdf639,0x157b894,0x1778903,0x1cf1d48,0x16ba08f,
  46159. 0x01fd73f,0x02fcd69,0x0e1b462,0x02a0f5c,0x12c01eb,0x0b40191,
  46160. 0x057a6e0,0x14ce20e,0x0f4be7e,0x1f2a9a5,0x141cad1,0x0aeda04,
  46161. 0x074dc2f,0x07052a1,0x087879c,0x052f772,0x154973b,0x1c9826e,
  46162. 0x1d3efb9,0x17bfd27,0x0f6cba3,0x0e837a3,0x05ff091 },
  46163. { 0x19c6632,0x089522b,0x0055e46,0x1f71441,0x1b19a44,0x0b1ce9d,
  46164. 0x1ee114d,0x19de9f2,0x1bc3c9b,0x0bf15e5,0x1990439,0x1e57e33,
  46165. 0x0d122b3,0x09abecd,0x0062768,0x1fecc3e,0x1bb79e5,0x033aab9,
  46166. 0x1cbcf13,0x1cb931d,0x0731444,0x1002688,0x15bd878,0x0ebac6b,
  46167. 0x0366fac,0x19186fd,0x18b2153,0x1f88f90,0x10850b9,0x121f056,
  46168. 0x0cb012b,0x05ee418,0x0e94f64,0x1de4eae,0x19969d4,0x06cfdf5,
  46169. 0x10373a6,0x1e9869d,0x0591b09,0x07452e4,0x0668101 } },
  46170. /* 168 */
  46171. { { 0x04509df,0x0ec89f4,0x0dd84e1,0x1b9e672,0x0978bed,0x11d0a47,
  46172. 0x0974cd0,0x0f25be8,0x1ee8cb5,0x1fd0571,0x1154f10,0x0d3a638,
  46173. 0x08f0153,0x0fdf8ea,0x13c22ef,0x048940b,0x1e69444,0x1d6ffa5,
  46174. 0x0d7768c,0x06bf034,0x0b7c016,0x04f3b7d,0x0217225,0x0e6ef06,
  46175. 0x1fcde16,0x06925eb,0x128953e,0x1b196a5,0x1ec985f,0x0533209,
  46176. 0x131885a,0x0f5204d,0x0db9741,0x0f0dbf9,0x1959438,0x1c72c5d,
  46177. 0x13beffd,0x1051a36,0x0ac7efb,0x05e17bf,0x03b35b7 },
  46178. { 0x15c3749,0x06f4fa9,0x1122ffe,0x1f15bb3,0x03c1f20,0x1c7b319,
  46179. 0x0cdef23,0x09352eb,0x1e8f3ae,0x094f23a,0x1898a09,0x01aa3ab,
  46180. 0x1dc32f1,0x13c3178,0x1034a5d,0x17c6cb5,0x138854c,0x109e3c9,
  46181. 0x0d9f918,0x0009de9,0x0ee148f,0x0872e88,0x1e8de85,0x1051141,
  46182. 0x0778dd2,0x1a6a4ba,0x1b3edcf,0x0d0614c,0x0049529,0x000983c,
  46183. 0x0527d11,0x12ec16d,0x033c709,0x1ae4cc1,0x129496d,0x1906819,
  46184. 0x0771f99,0x117205e,0x11a14fd,0x1d79b2b,0x047d0a1 } },
  46185. /* 169 */
  46186. { { 0x12811f1,0x1a7ffb2,0x000899b,0x06c5de6,0x0aacaa9,0x05d0657,
  46187. 0x1e95543,0x0ced870,0x0007f54,0x1a80a15,0x1c99ce8,0x0054405,
  46188. 0x05c7fd1,0x19ee373,0x0bb95c0,0x0c7b2bb,0x0c3064a,0x1303417,
  46189. 0x18ac947,0x1e17608,0x16e746c,0x12aed49,0x0380c32,0x084cb6a,
  46190. 0x060f243,0x07ae43d,0x0da6d3a,0x0c6f657,0x17770a9,0x1ac63d6,
  46191. 0x099807e,0x1da742b,0x12147f6,0x0f4b08f,0x1578a65,0x0c0b68f,
  46192. 0x03213a1,0x0654d9c,0x0a1732c,0x094932b,0x08f4b61 },
  46193. { 0x14eb3c1,0x0760ca5,0x09c16aa,0x0840647,0x0c549ac,0x1663554,
  46194. 0x04c893d,0x14601a9,0x145f9a5,0x129dcdd,0x1eaeec3,0x0220112,
  46195. 0x10e46ef,0x0bd66be,0x01cf95f,0x16b11fd,0x1e50f7c,0x0be7e67,
  46196. 0x01555f4,0x0a7acb9,0x12e20ea,0x0239447,0x1f767ad,0x1d6d151,
  46197. 0x1edfac0,0x1065596,0x002180e,0x104428e,0x1eb06c5,0x0344807,
  46198. 0x0b1a519,0x04bcb95,0x04cf5bf,0x08d74c0,0x01627f2,0x1db0ab3,
  46199. 0x13c45ea,0x09bc58b,0x06007b6,0x004a499,0x08f942d } },
  46200. /* 170 */
  46201. { { 0x0845808,0x1618147,0x1f147c7,0x156ef57,0x0302bff,0x0cbee3e,
  46202. 0x152e7e3,0x0964d5f,0x03aac59,0x09d41e2,0x165370f,0x17a2ce9,
  46203. 0x1ce3b74,0x0552c88,0x192dcdf,0x059a488,0x173871c,0x131492b,
  46204. 0x0d1103f,0x1e490a7,0x0d7d419,0x19f0295,0x1769a83,0x0d90d81,
  46205. 0x080d684,0x1a13229,0x0be0c93,0x04ad13f,0x0f117aa,0x08f403e,
  46206. 0x0df1d2b,0x11bb93b,0x026dea0,0x1e42eab,0x0dce59b,0x06a4c40,
  46207. 0x13b1eb5,0x16abe1f,0x06b2f82,0x0a52938,0x0383002 },
  46208. { 0x0744723,0x1ad202f,0x120683b,0x0a35c10,0x1b5bcf7,0x00fbb7e,
  46209. 0x16333fb,0x18d57f5,0x1fab37f,0x1d2ec18,0x1b6de3e,0x049191f,
  46210. 0x10be39e,0x16c9f98,0x13eb57e,0x0b8494b,0x11e913d,0x0ba3fed,
  46211. 0x1462dfd,0x148f928,0x0327052,0x163e7da,0x0788235,0x1ca717d,
  46212. 0x1cb9c70,0x08b589a,0x056ec5e,0x0c6a4eb,0x1106c73,0x1c402d9,
  46213. 0x01a8b01,0x1841376,0x0d42a06,0x08256e9,0x11c74f1,0x096a4b6,
  46214. 0x022ce03,0x1a59b44,0x0169727,0x12dd683,0x015f187 } },
  46215. /* 171 */
  46216. { { 0x0ee4684,0x0f50305,0x0f20253,0x0cf9b7b,0x02b21f0,0x09898ca,
  46217. 0x18526c6,0x14d4873,0x181a7db,0x125eea0,0x0ba03fa,0x0e0c785,
  46218. 0x02c6213,0x09411ee,0x02c259c,0x023636b,0x1158326,0x03a21ea,
  46219. 0x0f080e1,0x0df0622,0x12d22e1,0x0b15ecc,0x0338813,0x0327116,
  46220. 0x1bcd6f4,0x063a4ce,0x1474dde,0x125bda3,0x1dae734,0x0ba7e2e,
  46221. 0x166756f,0x13296c4,0x0813d52,0x165346a,0x13d83a1,0x18323b3,
  46222. 0x13e9c2a,0x10bcf57,0x048e158,0x1e73fdc,0x06146f1 },
  46223. { 0x18e2aa6,0x1699f03,0x0996f41,0x0f3bdd2,0x093af7f,0x1207423,
  46224. 0x03e076a,0x0fdaadc,0x09b9a40,0x0fdddc4,0x0654641,0x15b9dbd,
  46225. 0x19dcf44,0x0496dd1,0x1c7e34c,0x0ee96fe,0x1a54231,0x1b3adae,
  46226. 0x17d817a,0x0d44a34,0x1a9e745,0x17c3d1c,0x040c752,0x168e97b,
  46227. 0x1000605,0x148eda1,0x0ad996a,0x1b4bb7e,0x11eeb4b,0x1efab31,
  46228. 0x1617468,0x0c46ef8,0x08149ef,0x085ff81,0x13a5a17,0x1c5c35e,
  46229. 0x02a465d,0x15043ac,0x0014383,0x13c0d7a,0x095543f } },
  46230. /* 172 */
  46231. { { 0x1d7c6ef,0x1e37a42,0x1093df2,0x1ac7637,0x0ad8084,0x065d316,
  46232. 0x13a22fe,0x125bf21,0x0b455c1,0x0725b43,0x1f1bb66,0x11aaee9,
  46233. 0x176146b,0x1d71003,0x188e279,0x04a52e1,0x07961c2,0x0a920e2,
  46234. 0x021397d,0x042a207,0x02737d2,0x110bf14,0x15b4833,0x04ce9f1,
  46235. 0x19f514f,0x0edf188,0x15c3004,0x0a8b20a,0x1b760e8,0x1aecfe7,
  46236. 0x0677ead,0x13d1854,0x146362a,0x0a593ca,0x1e2929f,0x1896da7,
  46237. 0x0e5d698,0x0438827,0x05bfe97,0x0f05745,0x06db434 },
  46238. { 0x03f0d95,0x03249ae,0x0254192,0x049ce91,0x0917db8,0x179f224,
  46239. 0x17d89ac,0x097ee7f,0x02b7f57,0x1076e2a,0x0c9c8f1,0x13455ee,
  46240. 0x0cbe1c0,0x1e5688a,0x0d19a75,0x15ff2fa,0x00a321a,0x04b2330,
  46241. 0x1433587,0x1c5775d,0x150eb94,0x00ef623,0x019b869,0x1513eb1,
  46242. 0x0990db1,0x149d0df,0x13c9d65,0x073c9ad,0x00dddfc,0x1bc0607,
  46243. 0x104473e,0x1b33914,0x0afcd7f,0x0182878,0x0b6db87,0x099d7ff,
  46244. 0x16d2c6e,0x1cc0d84,0x1ea513c,0x1ce55c4,0x007a791 } },
  46245. /* 173 */
  46246. { { 0x09f0300,0x148238f,0x04139c3,0x13799bf,0x00253ad,0x02983c7,
  46247. 0x0a277fc,0x0c4a380,0x0ae8934,0x0f78497,0x11a117c,0x1235490,
  46248. 0x142c90a,0x18ed6a5,0x11bb683,0x0cf6432,0x0f333df,0x0783b28,
  46249. 0x0c56805,0x1311b61,0x10f9c6e,0x175aa17,0x1cb8319,0x1806f1e,
  46250. 0x16311e0,0x086aea5,0x0aba1a5,0x09175b5,0x1f1c8f5,0x11c6d9a,
  46251. 0x151a005,0x1289a35,0x09e3216,0x18e9909,0x0b21011,0x1d32a37,
  46252. 0x05e94dd,0x0614f9c,0x1b2b00f,0x05c8a87,0x06d6acc },
  46253. { 0x1b2d299,0x0cf4aab,0x0737ae6,0x17c7ae4,0x1a2bcd9,0x065a221,
  46254. 0x0e13eed,0x1545cc0,0x1dc060f,0x10bbb84,0x01f37ab,0x0da7193,
  46255. 0x0d74f0e,0x083b7df,0x08df3e0,0x1f7ff34,0x1137983,0x034d78a,
  46256. 0x08fe561,0x1ef43a6,0x03986c3,0x07b6db2,0x0f8872b,0x0e07b24,
  46257. 0x0134f96,0x1bb3e6c,0x1ee0e4f,0x0eab131,0x0252220,0x145e174,
  46258. 0x1f06d6c,0x0f24954,0x18799c1,0x13d455b,0x03ca050,0x043b66f,
  46259. 0x1f28949,0x1228d8f,0x11bbb56,0x0247a78,0x079d182 } },
  46260. /* 174 */
  46261. { { 0x09d5589,0x16ffc88,0x126468f,0x0805368,0x1ed52eb,0x1aa56fe,
  46262. 0x074c2d2,0x0ce27d7,0x1a27bff,0x1c90a60,0x03d1813,0x1dcecfe,
  46263. 0x084c817,0x01d2871,0x17e360f,0x0c46f75,0x1c99402,0x0e2ee01,
  46264. 0x19991f0,0x12b0372,0x07f35f2,0x04c5034,0x042da82,0x0c68a2e,
  46265. 0x07cec31,0x0c4573c,0x158b9d4,0x0003b74,0x02c3fb2,0x10d3a2f,
  46266. 0x0555753,0x16cfa67,0x1cacdeb,0x021775f,0x1e72f1a,0x1743415,
  46267. 0x1e88580,0x0c85159,0x1372141,0x1234f09,0x0731044 },
  46268. { 0x048d676,0x1166f93,0x0ac5132,0x0a9e362,0x1a85eca,0x0070f5c,
  46269. 0x0b250a6,0x112373b,0x11ac8aa,0x1869b84,0x078657c,0x156f8e3,
  46270. 0x1773072,0x17b81bc,0x1463208,0x0cfed74,0x014ac00,0x1d60487,
  46271. 0x1734a49,0x19f8e11,0x1a630e6,0x1110f3e,0x13d6227,0x0e38f8c,
  46272. 0x0a40b83,0x064da55,0x0a3de1e,0x1f3b57c,0x0caf3f1,0x16b5ec2,
  46273. 0x04bde2b,0x13c1c3b,0x039dd07,0x0126e1e,0x17ec489,0x12d017c,
  46274. 0x0bdc009,0x0d90a68,0x1153fd0,0x192a301,0x06a8f8f } },
  46275. /* 175 */
  46276. { { 0x1235132,0x0f6b1a9,0x022d8a8,0x02b3b75,0x1db233f,0x0f7eec0,
  46277. 0x15148a4,0x15d0ac4,0x1b25111,0x1a8294b,0x006f631,0x15f23ae,
  46278. 0x1db5921,0x0bba7a2,0x14175ca,0x0e7ff69,0x05ef18e,0x0371ea6,
  46279. 0x066cc0e,0x1b30bf1,0x1558897,0x1de44d8,0x02a70c3,0x0263039,
  46280. 0x0d1a34d,0x1071e49,0x08888cc,0x125d0d7,0x0eed022,0x0a6100e,
  46281. 0x07f3c91,0x0b07e61,0x1a45f74,0x1e8d193,0x00b2b43,0x10eb4c2,
  46282. 0x0b9c753,0x07a2e96,0x0ff5f6d,0x183b650,0x04752d8 },
  46283. { 0x1dff4d5,0x0b6756a,0x1fd1453,0x168b504,0x14cd5fd,0x0389af3,
  46284. 0x098313f,0x11c20e1,0x01be577,0x1605dbc,0x11ac237,0x059ab1b,
  46285. 0x16271e1,0x0a5e124,0x194226d,0x131596e,0x0636190,0x136ef96,
  46286. 0x1d4a20c,0x1d758cc,0x0af1fd6,0x12e1284,0x1aa8b40,0x19f83e1,
  46287. 0x0cda84d,0x1f009e1,0x0115442,0x18f06d5,0x0868011,0x14468d4,
  46288. 0x114e411,0x15f5e4a,0x03132aa,0x05446b2,0x15dca0c,0x0092d0a,
  46289. 0x0744b47,0x0a48e54,0x015495a,0x1e6ebf7,0x03a6518 } },
  46290. /* 176 */
  46291. { { 0x04042a0,0x076a811,0x079aaaa,0x0048a5e,0x0cb4e3b,0x0108ec3,
  46292. 0x17d31da,0x07fdb94,0x1ef4d5d,0x107f1fc,0x151b953,0x0548a45,
  46293. 0x1533a8e,0x18a233b,0x063887f,0x1a036b3,0x10ef592,0x08a4b62,
  46294. 0x0e99dce,0x00985f0,0x1f00691,0x05a395d,0x0a19c2f,0x062ef7a,
  46295. 0x083b250,0x1514754,0x15f49c4,0x0bb1780,0x19c994c,0x098bda1,
  46296. 0x1fd07be,0x1b9b435,0x001d3a8,0x07b7dcc,0x1ad5c0e,0x01ad0dd,
  46297. 0x1bfbf82,0x062e687,0x1605fa0,0x0c7db84,0x0540ac3 },
  46298. { 0x07f43df,0x0b4d4ff,0x19329c6,0x1058373,0x0665380,0x0e148bf,
  46299. 0x1df6216,0x0095b2c,0x196aa44,0x1654aa2,0x0a5f6ae,0x0abffe2,
  46300. 0x1e0e9d8,0x115753e,0x18625ec,0x07f1c3e,0x0fd36f1,0x1cb76e6,
  46301. 0x1b88037,0x1a60e02,0x08a4627,0x1b64c4c,0x1ca7c1c,0x1e463a4,
  46302. 0x05e6097,0x1a94af1,0x0fd8121,0x1efe443,0x19b299a,0x1304a00,
  46303. 0x16759a0,0x04d6963,0x199de09,0x0ebd18e,0x1d986b3,0x13d88f9,
  46304. 0x0ebe15e,0x14f959b,0x05d3d37,0x1d9f42d,0x017db32 } },
  46305. /* 177 */
  46306. { { 0x0f40599,0x1b48cb6,0x03a9d7b,0x1601804,0x1ea10df,0x157b3cb,
  46307. 0x0b9eff2,0x0f07b4b,0x188ddd6,0x0b31e51,0x0f3f343,0x11fc4ab,
  46308. 0x1e5a21f,0x11a25e3,0x10fd4e3,0x00c65d3,0x11d548e,0x09afb15,
  46309. 0x0f1b993,0x1e484a8,0x1627654,0x13134c9,0x11d569e,0x1e82649,
  46310. 0x1c5f7b0,0x079d1db,0x04e8860,0x0ad2fef,0x01675b0,0x0fd88f4,
  46311. 0x1d5b3e1,0x1ca6851,0x13cdb35,0x1458136,0x16454b4,0x11c7542,
  46312. 0x17a3fb7,0x03812af,0x11176a1,0x0374328,0x0460bd0 },
  46313. { 0x04d8077,0x06e11e1,0x14b2f0d,0x0098e41,0x02f4b58,0x0e8fff4,
  46314. 0x0a445bd,0x1c5453b,0x092783c,0x1c57a90,0x012bcd5,0x03576b2,
  46315. 0x10e29f5,0x1bd508c,0x115c35f,0x1bbe08d,0x1ba571b,0x0a52917,
  46316. 0x1a26ed4,0x1c540d5,0x044dbf4,0x062cf9a,0x1e66cd7,0x1984aae,
  46317. 0x0836726,0x0bbe181,0x16bf3b0,0x0949d30,0x16cbd09,0x1ee5be1,
  46318. 0x1deb6bd,0x0eba720,0x131b787,0x1125e76,0x013cb4f,0x16a5ad2,
  46319. 0x1f95421,0x0513348,0x01e3717,0x0782e69,0x07d342c } },
  46320. /* 178 */
  46321. { { 0x1fd127f,0x1960508,0x117b973,0x10233c9,0x06d36bb,0x1ab561b,
  46322. 0x0c949bb,0x0eac435,0x0e54306,0x067f577,0x1a5864c,0x0fa5587,
  46323. 0x112ede2,0x1c7e733,0x04d44eb,0x0987ac8,0x01b075f,0x030ace3,
  46324. 0x041a766,0x0fdfd2b,0x0ea9d44,0x14753b5,0x0be35bd,0x0b7a2c9,
  46325. 0x1c61b0f,0x1cc562e,0x187a22e,0x175688d,0x092320d,0x058b0dd,
  46326. 0x195862e,0x0f13130,0x0eafb3c,0x1bf4150,0x130b022,0x1618f57,
  46327. 0x00d160b,0x184db71,0x18e9c43,0x14d1c98,0x05be0af },
  46328. { 0x1bbf49c,0x1b69c0d,0x0ffa0aa,0x13180e0,0x1e09ce4,0x07a1319,
  46329. 0x02d7784,0x065d94b,0x1da5a45,0x0e632c0,0x03dedf6,0x10edec3,
  46330. 0x0707e18,0x1287bff,0x066978c,0x10d7c08,0x090de6b,0x0dd8d4f,
  46331. 0x1cd645a,0x14fbd66,0x1b2c584,0x04a8a4e,0x0e3acd2,0x1d75770,
  46332. 0x06a33b0,0x1490a2a,0x030be22,0x00cfe16,0x0db0190,0x0ff3851,
  46333. 0x0faf783,0x18c7cde,0x051b06c,0x037d6dd,0x1ee7a48,0x1543224,
  46334. 0x1e80dc0,0x15af43f,0x0c2bb93,0x1eba9bc,0x01e6fcc } },
  46335. /* 179 */
  46336. { { 0x08ac924,0x0ffb355,0x0fa2d5f,0x0385316,0x06e9ad3,0x1d84060,
  46337. 0x18ca597,0x07fa281,0x11d95c9,0x0d5908e,0x0032a9f,0x1085143,
  46338. 0x096d68d,0x1106f6b,0x04a5022,0x08c3e35,0x15338df,0x1540a8b,
  46339. 0x03aba4c,0x0c095cc,0x0c0bff5,0x04bed72,0x0406e79,0x04c5d13,
  46340. 0x1a97fde,0x0c1a2b9,0x13c4212,0x1ad3b34,0x124f1de,0x0117b23,
  46341. 0x17e3fe8,0x1d50b42,0x1f1c2e4,0x09bca6a,0x13a4051,0x1a98c4d,
  46342. 0x1f0907d,0x02066b5,0x0a0de01,0x0c2bbb5,0x04522d4 },
  46343. { 0x1fbe7c5,0x0f83cf5,0x111a225,0x1b09de6,0x10ea1de,0x10d5cb1,
  46344. 0x07adb52,0x0d0e2d5,0x050a30c,0x1252e91,0x0eeea86,0x0638008,
  46345. 0x155a166,0x080872f,0x041d409,0x00aad7a,0x09d3d8c,0x0dfff1f,
  46346. 0x1ddc906,0x0616300,0x029731b,0x18425c1,0x043fdfb,0x0343187,
  46347. 0x17d75f2,0x07c0061,0x15596ee,0x11a14c6,0x03bceb1,0x0d1522f,
  46348. 0x036eb07,0x047e161,0x038e90c,0x02d628e,0x0a897ef,0x0de3743,
  46349. 0x1da71fc,0x0a92b5e,0x102e827,0x152dafc,0x0346501 } },
  46350. /* 180 */
  46351. { { 0x02b0f1d,0x1224666,0x1c0e1af,0x1358986,0x03eb45c,0x04b5dff,
  46352. 0x1d9767f,0x1b4a70f,0x15ae27f,0x179e274,0x0602273,0x0eec378,
  46353. 0x01a008f,0x11650c5,0x1d28210,0x066e3e6,0x04253b7,0x0774414,
  46354. 0x13024d5,0x1f8db0f,0x0d6bcb6,0x0db0a4b,0x01227b0,0x1c64b89,
  46355. 0x029b949,0x0b35496,0x09ef7b0,0x0b8d94a,0x0a28131,0x07776e7,
  46356. 0x13e5511,0x074422a,0x0683eb3,0x030e79a,0x1e634e4,0x171f64d,
  46357. 0x06c940b,0x1845540,0x125b70e,0x19fcaa9,0x07c1d42 },
  46358. { 0x0110aa7,0x1381fee,0x0de1d9b,0x0fe6c5c,0x0b7b79d,0x16e51e5,
  46359. 0x11d756a,0x0e7a4b3,0x160be33,0x137653c,0x13a3fca,0x14960d8,
  46360. 0x1ff4744,0x19db82d,0x010b33b,0x096a765,0x1aaae30,0x00d1d7a,
  46361. 0x0cb4c6e,0x1f44023,0x08d97bb,0x1d25f74,0x112e9ba,0x0b97073,
  46362. 0x165ce56,0x074169a,0x1b6bdfb,0x09010d2,0x1597452,0x0673f34,
  46363. 0x0dcb1f3,0x1d29f30,0x1d6eb3c,0x0d19377,0x133ce04,0x0c14676,
  46364. 0x1ffa93a,0x101fa1f,0x0764050,0x050e786,0x0031e98 } },
  46365. /* 181 */
  46366. { { 0x05a17ff,0x1f67e3b,0x09953fb,0x11a2521,0x009f388,0x06d01c5,
  46367. 0x1711a4e,0x08d7e4c,0x1a169ad,0x1db0a2e,0x18bfa12,0x0428474,
  46368. 0x0533cf8,0x15e4305,0x0b7d5c6,0x07188ac,0x0fa815c,0x0df9548,
  46369. 0x1fb6a1d,0x143adc2,0x05e145b,0x0d4a37d,0x1e67620,0x01eb476,
  46370. 0x1e784b9,0x095360d,0x12c43fd,0x122146f,0x14fd360,0x0ff2527,
  46371. 0x0830e30,0x11c5a77,0x1180fc5,0x130c3e1,0x0142c5e,0x047c5fe,
  46372. 0x143a35c,0x0002cdc,0x11470e8,0x08b4519,0x0494d36 },
  46373. { 0x1a021f8,0x0135b25,0x0db0e61,0x06f2dbd,0x114c908,0x1b63b16,
  46374. 0x14e55f8,0x02cda5c,0x0751cf2,0x1aab765,0x0928663,0x1c00336,
  46375. 0x0edaca1,0x0590615,0x021f691,0x14e668f,0x0cdff41,0x1c9f6a6,
  46376. 0x11f0335,0x02f888b,0x10098d7,0x0548dfb,0x131218d,0x0b3775f,
  46377. 0x146f93b,0x18ad0f8,0x0795893,0x1a71767,0x1f8443d,0x0d56981,
  46378. 0x1f25b50,0x097e209,0x1670f03,0x032c135,0x07b4a5c,0x0a0a07f,
  46379. 0x134200f,0x070fa3d,0x11bcdda,0x0bd77a9,0x03cfdcc } },
  46380. /* 182 */
  46381. { { 0x123e13d,0x015435a,0x02814db,0x105241a,0x1014a45,0x0b894b0,
  46382. 0x0d1e39d,0x1d47aa5,0x07eb51b,0x0ba3033,0x03a4641,0x10c30f6,
  46383. 0x08709f7,0x1434447,0x02bb621,0x1f9a805,0x1d7d94a,0x1bcd404,
  46384. 0x084a6bc,0x0c065fc,0x008250c,0x194c1e2,0x1d792f9,0x1677d1c,
  46385. 0x11bbb7a,0x1944c19,0x12d8631,0x0634065,0x19c4a4d,0x02d09fa,
  46386. 0x188db76,0x1da9ec3,0x1ece345,0x18b8aed,0x1334795,0x0f74f55,
  46387. 0x04a1ebd,0x062c6d3,0x1ba844e,0x01e7a35,0x089296d },
  46388. { 0x0a82c97,0x09447e6,0x0372c59,0x1a284fd,0x06c6c12,0x1f6ed49,
  46389. 0x13c1d30,0x17ccd52,0x0eaa01e,0x030070f,0x17a1b65,0x1cf861e,
  46390. 0x1114abc,0x05a2b51,0x075c083,0x08584e8,0x013279f,0x05582d5,
  46391. 0x108e11a,0x0c1f5fa,0x19e670b,0x0098c69,0x0863bfb,0x0416631,
  46392. 0x1f1ac89,0x101f583,0x0360e67,0x03c7975,0x01a3010,0x09971e4,
  46393. 0x16197e2,0x1998ccf,0x08bca7d,0x0303e57,0x19e689a,0x199dc35,
  46394. 0x0ac0a12,0x0173266,0x13150c6,0x1ee5634,0x09233a2 } },
  46395. /* 183 */
  46396. { { 0x0cbee17,0x146fb05,0x1371c5f,0x04b849f,0x0f0959c,0x07fe580,
  46397. 0x0621f95,0x0d68de1,0x0d28511,0x0c9ef65,0x07e946e,0x09f1774,
  46398. 0x1e0bfaa,0x08790c1,0x04927bf,0x0eef339,0x1589684,0x0fc9e59,
  46399. 0x0c8b508,0x17f6fe4,0x1009284,0x0d6a157,0x10331c2,0x163ac2a,
  46400. 0x122749b,0x035634f,0x09c5f0f,0x0dea167,0x1c5eeb7,0x14c2ddc,
  46401. 0x17e2c87,0x148f076,0x0fb19ae,0x0e1f3ac,0x0e6d4b8,0x100990d,
  46402. 0x12971ac,0x12c8497,0x00a46b2,0x0d243db,0x02bb26a },
  46403. { 0x1f81416,0x1a21a8a,0x0ed2628,0x0f55feb,0x086e72e,0x0b930e0,
  46404. 0x193780c,0x1fc7a3e,0x05c0a1c,0x0e03c36,0x00d004c,0x09b166d,
  46405. 0x0d542ea,0x0d1cda6,0x1dc9ce8,0x04fe25e,0x0e1cbef,0x00a7f3f,
  46406. 0x1aec9f7,0x1f813c2,0x1dc7ee7,0x0ba0872,0x1037330,0x08767bb,
  46407. 0x0674219,0x0dbd1a3,0x00fcc70,0x052696c,0x0c10709,0x0f6ce11,
  46408. 0x1ac061b,0x0f33f2c,0x17ee8ba,0x18449d1,0x12d0926,0x1c1e77f,
  46409. 0x0e92d4d,0x130a239,0x1ac22eb,0x1f1c32d,0x0937cb3 } },
  46410. /* 184 */
  46411. { { 0x0fbfdce,0x073be0b,0x13015f0,0x13931a9,0x0a034cc,0x0b96907,
  46412. 0x1b5c909,0x079cec0,0x00019a8,0x030daae,0x05c58a6,0x1007e2b,
  46413. 0x1b80ba2,0x02d07eb,0x1050774,0x155441e,0x13b4b0d,0x04432c8,
  46414. 0x08e123b,0x10ae8d5,0x05d2e66,0x0d1f024,0x05b4569,0x0d20bba,
  46415. 0x0c7743b,0x15d40e0,0x16062bc,0x1d8636f,0x174b78c,0x18ca695,
  46416. 0x0a20363,0x0a87c5e,0x0659db2,0x03e0e65,0x09f67ec,0x0063707,
  46417. 0x1f1048c,0x09bfee0,0x1a84619,0x00ef0b0,0x04d57bb },
  46418. { 0x1b396b6,0x1bb4529,0x16b2f12,0x09276a3,0x1c8b24c,0x0570d9d,
  46419. 0x047ae8c,0x18a67ca,0x1945147,0x09ddeca,0x1f8f3a2,0x00622f3,
  46420. 0x146cc86,0x1fc905e,0x0c2859c,0x0c2c069,0x0eb6b25,0x1d99489,
  46421. 0x145a360,0x1345493,0x1128bc6,0x1d7786e,0x0d25279,0x04d33c3,
  46422. 0x1419a87,0x1b59309,0x1efc84d,0x0d8b08e,0x1971470,0x0c84d27,
  46423. 0x17f956c,0x0f736e8,0x1d6eb75,0x19e42b1,0x0ca4237,0x076a6cb,
  46424. 0x15fcfae,0x12bf21a,0x0aaa038,0x0312f3e,0x01067c1 } },
  46425. /* 185 */
  46426. { { 0x0bf8883,0x0a84219,0x199f211,0x14dfa0c,0x0755286,0x0119aea,
  46427. 0x03e3ddf,0x129ae16,0x02f4a2c,0x1c7306d,0x02b3d59,0x1159a23,
  46428. 0x19a468d,0x1fadc86,0x04e0c2e,0x122099d,0x074ed4e,0x075258e,
  46429. 0x1dddba9,0x0e62da4,0x0b12ac6,0x0e1b0dd,0x0e62b5d,0x02448a3,
  46430. 0x1d48299,0x1d76191,0x014c290,0x0c88044,0x12d5a52,0x0997194,
  46431. 0x0f0e911,0x0bfd9e3,0x148694b,0x1dc5c6d,0x05bb199,0x1dc9c0a,
  46432. 0x04306ad,0x152cafd,0x05c96ce,0x123e69d,0x07e4f70 },
  46433. { 0x1f70919,0x00b74db,0x0fd4fce,0x1a2d600,0x165216e,0x064cf2b,
  46434. 0x13fd1de,0x0208d8d,0x030a518,0x152d5f4,0x1ca36f9,0x13cc8bc,
  46435. 0x16ef6f4,0x056677e,0x175cfab,0x1e7eedf,0x06f8c37,0x1f61ca7,
  46436. 0x1901ff0,0x0410056,0x1cbd733,0x1d4b312,0x0623a3d,0x157f601,
  46437. 0x123637c,0x0cd4194,0x1d01fcd,0x0b1753b,0x1fae502,0x1772e65,
  46438. 0x04ffc06,0x1fc4a30,0x1eaeace,0x0e5d0fd,0x05860fc,0x0b38d3e,
  46439. 0x1eadcdb,0x162c56c,0x1a2f544,0x1a8d999,0x02ae49c } },
  46440. /* 186 */
  46441. { { 0x00849f2,0x0d871e2,0x063048e,0x1b48821,0x1136a4c,0x03fb24a,
  46442. 0x16a6795,0x18cc2a6,0x07a9bba,0x1725ee2,0x11ebda4,0x0c8ca6a,
  46443. 0x0a195a1,0x05a3d3a,0x1b2cc66,0x145650b,0x1fc9de6,0x093c2a9,
  46444. 0x18ae94b,0x1807141,0x1a93471,0x041ade5,0x04ae86e,0x063d944,
  46445. 0x150da6f,0x1636a5f,0x1a00acc,0x028dc7e,0x04c8c4d,0x00989e3,
  46446. 0x05c3270,0x1dda425,0x130f12d,0x02987d6,0x1fee71a,0x0336eb7,
  46447. 0x0918de5,0x00569f4,0x1c6dc8f,0x0a54e6e,0x0180e9d },
  46448. { 0x1ab77b0,0x12a1794,0x18a30c5,0x19ef5dc,0x1d411d9,0x1e17a06,
  46449. 0x01a14d4,0x19e0898,0x04b0ae4,0x1c6e3f2,0x1099bd8,0x030b2bf,
  46450. 0x1da0924,0x1e97f5b,0x07699c7,0x12f30c7,0x0d55ea3,0x12b42c7,
  46451. 0x03ce0ca,0x129e62b,0x18317a6,0x03698b6,0x0a508cf,0x146b4f7,
  46452. 0x0cb2630,0x09d97e5,0x17c7fdc,0x1df1efb,0x0ee2f3f,0x0292acf,
  46453. 0x12a2e6d,0x02ada0c,0x1b4f91b,0x07e7e68,0x1b08bd7,0x022ef0c,
  46454. 0x1777eb4,0x1e12b31,0x016d04a,0x079b157,0x021ca6f } },
  46455. /* 187 */
  46456. { { 0x1e66635,0x11589d1,0x1abc385,0x16553ee,0x1ef20a2,0x0d99ab0,
  46457. 0x0e8c11b,0x11b568e,0x17802bb,0x0205ebb,0x06d1302,0x1ebd4d3,
  46458. 0x115b6ba,0x0d9103f,0x1846400,0x0020b8d,0x0a9790b,0x072ef0b,
  46459. 0x0d9fc01,0x025e2bb,0x1d2522b,0x02c5012,0x0617eb5,0x0142284,
  46460. 0x16953df,0x0605e67,0x0fd140d,0x1884253,0x077bff4,0x02000e1,
  46461. 0x0603dd0,0x050153c,0x0440b4c,0x1515a37,0x03d610a,0x1eecfbd,
  46462. 0x05e8d94,0x11055c0,0x1d8d4f7,0x0b24044,0x05aff58 },
  46463. { 0x0458e40,0x1669054,0x0af6016,0x10292e6,0x1a5557d,0x0e5396a,
  46464. 0x104c57c,0x0478e0e,0x0952b53,0x197134e,0x13eb7df,0x0aacc92,
  46465. 0x065c592,0x0d3e933,0x0edeb34,0x050ca2a,0x03d86fe,0x1d36f83,
  46466. 0x1f54eda,0x03b626a,0x0d011e9,0x04f49f5,0x04656ee,0x0c77fcd,
  46467. 0x1e1af29,0x0431eb8,0x0a209e2,0x1565738,0x059b6ff,0x13491dc,
  46468. 0x145de0d,0x1ee053b,0x0695174,0x022b0b7,0x01d9ee6,0x138f30f,
  46469. 0x1907d84,0x1da78ea,0x0a5dd93,0x03911b1,0x03eab7e } },
  46470. /* 188 */
  46471. { { 0x0e5718b,0x14a5b29,0x07a71ce,0x09e99dc,0x03aefa5,0x1f76f57,
  46472. 0x0798d54,0x034ca9d,0x15f3aca,0x12a0f0d,0x00cc5bc,0x09121a1,
  46473. 0x0ed7129,0x1dbfca8,0x196bd8f,0x07c94f2,0x00dc74e,0x06c7e4f,
  46474. 0x0bde7af,0x1c91a5d,0x07e6b4e,0x1545bbc,0x09162a1,0x199d5e1,
  46475. 0x1621ff7,0x006ec63,0x1f7d9e6,0x0451ddf,0x1067278,0x03a17c8,
  46476. 0x0a48435,0x160fc6c,0x1f63501,0x0f14ec8,0x0719e5c,0x0a882ec,
  46477. 0x03a3b8a,0x06632f8,0x0551303,0x09e71c1,0x03491da },
  46478. { 0x1062eae,0x1682365,0x1db59c1,0x0aba10e,0x0e7db73,0x118ae97,
  46479. 0x00148a4,0x1b701bd,0x0c402bb,0x03c2b31,0x14ccdd0,0x04b84dd,
  46480. 0x135f935,0x1eab476,0x1a85359,0x1163cd9,0x1896688,0x0c8b508,
  46481. 0x171c59d,0x1aa40ab,0x1df20fb,0x1bf22ba,0x00cf441,0x012466b,
  46482. 0x1100aec,0x1c4a749,0x05b3614,0x1f3c3a0,0x0263682,0x1b92a19,
  46483. 0x15fbaf4,0x037499f,0x01d172b,0x02c1c20,0x0e755d3,0x1c6efb5,
  46484. 0x00d517d,0x1534ac4,0x16862ba,0x1fad5a2,0x00c843d } },
  46485. /* 189 */
  46486. { { 0x1373300,0x008ffe4,0x0c01156,0x1533fb8,0x1c39332,0x1e5b2a8,
  46487. 0x0e070d4,0x04fc337,0x096a83d,0x1a5c925,0x18fc69d,0x1f9765d,
  46488. 0x07cbfc8,0x0086ab6,0x09e3b10,0x15ef35e,0x02fe0ab,0x1b7ef34,
  46489. 0x0ce6baf,0x0da0e4e,0x1db6756,0x0eb8902,0x0f4d6b5,0x0a393a1,
  46490. 0x1e69470,0x13e5add,0x034e8c1,0x0efb690,0x0d75305,0x1faa2b9,
  46491. 0x0f4b1c3,0x1c0db0a,0x0615aec,0x1fdaef4,0x132c16a,0x0ee3333,
  46492. 0x0a0a8ed,0x17e4b5f,0x17da7bb,0x13a6bed,0x02dcc46 },
  46493. { 0x05f0e77,0x1668363,0x052b329,0x017ae36,0x1dcc798,0x09e6006,
  46494. 0x07e2cf2,0x0af6c44,0x1ae8cbf,0x0fe6ad9,0x0398ff7,0x0e7eedf,
  46495. 0x17bc929,0x0370995,0x01228d0,0x193c5d3,0x003d51e,0x12662cd,
  46496. 0x08cc206,0x1a65767,0x066b9c9,0x0940742,0x0004841,0x17ce52a,
  46497. 0x0032a1b,0x0246158,0x08924e1,0x17f8cae,0x1ba0ffd,0x10675b5,
  46498. 0x00ba5ca,0x1815290,0x00c0a4f,0x0c5e3fb,0x0731667,0x11ec588,
  46499. 0x112da0b,0x064b771,0x1e7f208,0x1b79b7b,0x05a1a65 } },
  46500. /* 190 */
  46501. { { 0x0485684,0x1348d21,0x0326fee,0x125388e,0x013116b,0x15028cb,
  46502. 0x065c798,0x1b56960,0x05ff499,0x1922d53,0x0e3bffc,0x0fe94a4,
  46503. 0x15c2ef8,0x064eaa8,0x1b71aeb,0x1595982,0x07e2dbd,0x1ad3f91,
  46504. 0x06eebb2,0x1b55895,0x18858de,0x16973e4,0x1fcc229,0x112ab27,
  46505. 0x12fc2e6,0x108a637,0x145df81,0x0cabe50,0x0b1bee3,0x0683180,
  46506. 0x15298fa,0x02782f6,0x0d0ce79,0x1a1315f,0x18d7125,0x0f94957,
  46507. 0x1c4e403,0x1a250bd,0x1ef67d2,0x133dfcb,0x05ae950 },
  46508. { 0x04f7455,0x12f73c0,0x1a0848b,0x0e440cc,0x141a499,0x0af1999,
  46509. 0x130c5de,0x1db2fa4,0x0e48efc,0x17a091e,0x0f08704,0x1b2433f,
  46510. 0x0ee8738,0x0331d1d,0x0ef7184,0x14db776,0x0c28593,0x09b01ec,
  46511. 0x0f06b1d,0x044fe5c,0x0519926,0x002f557,0x1faa4ab,0x0d02559,
  46512. 0x16f0bfd,0x16e2dac,0x13f0aa0,0x19cfd08,0x122b273,0x040d31a,
  46513. 0x054e101,0x0a50cf1,0x16088b1,0x0434441,0x1f30996,0x1843ff6,
  46514. 0x0f4a7ca,0x1198b09,0x14a6032,0x0fd47db,0x0411066 } },
  46515. /* 191 */
  46516. { { 0x0d04b63,0x181abe1,0x0862060,0x1be9253,0x1fc5a34,0x08caef9,
  46517. 0x1db688b,0x0e78e77,0x1cb4324,0x06f97c4,0x1fc4e05,0x1cb9d32,
  46518. 0x14345af,0x05cb027,0x18fd7e6,0x015cbb1,0x0e950c1,0x1d6bca1,
  46519. 0x1b497fc,0x1aa88fd,0x00cccef,0x0f0739e,0x0fda394,0x0a9f499,
  46520. 0x0d591ab,0x0462d8d,0x144ad87,0x1778220,0x0bf7608,0x1489dad,
  46521. 0x126ee4c,0x003cf2c,0x11231be,0x065f3ed,0x1a44103,0x13a1507,
  46522. 0x10a96db,0x0f2137c,0x047a8f7,0x08a69be,0x01cceb6 },
  46523. { 0x06d0f55,0x0862786,0x1274b48,0x1738ce7,0x0cadf61,0x071fddb,
  46524. 0x06466a7,0x1c9baff,0x093b063,0x1afa4a6,0x0a4ef84,0x167828b,
  46525. 0x1c580bd,0x07a977b,0x01c8cc8,0x176d49b,0x0e88814,0x13a6c3b,
  46526. 0x1ea5f7b,0x1ee4758,0x18334f6,0x181f1e6,0x1f78ae3,0x0e404e0,
  46527. 0x0f082ae,0x03730b1,0x1377e92,0x111d85a,0x1a17c6e,0x042cc69,
  46528. 0x06b6597,0x073002e,0x0e59e54,0x1b59131,0x0176efb,0x06156c5,
  46529. 0x0d48b20,0x1a28caa,0x17a8cf3,0x0669d44,0x01f1752 } },
  46530. /* 192 */
  46531. { { 0x067ea91,0x13b2d9a,0x1116022,0x1dfa5b3,0x1f4632e,0x195e379,
  46532. 0x171b673,0x15cf6eb,0x0359813,0x1e46920,0x12f637b,0x0413c89,
  46533. 0x0223ecb,0x10a92b1,0x0e8438c,0x1c334b3,0x1343f1e,0x1fd0a6c,
  46534. 0x0c3123d,0x0f8437f,0x1437df9,0x0875186,0x11398a2,0x028eb85,
  46535. 0x0e2a465,0x152d943,0x104999c,0x123e03c,0x0ab3b82,0x0d2e18d,
  46536. 0x1b271bf,0x1c2fa45,0x1277a5a,0x185d6db,0x160e453,0x037b11d,
  46537. 0x0a2392e,0x182e8db,0x0f0af42,0x120cb12,0x04cb8af },
  46538. { 0x14b1953,0x0102bdd,0x1bba8ac,0x09eb2fe,0x0ce08b4,0x1209642,
  46539. 0x1766d79,0x0330a9e,0x1b3cd49,0x0899316,0x0aed746,0x05c8dc8,
  46540. 0x0090276,0x0bc73fb,0x157239b,0x182d906,0x02438b6,0x0477d54,
  46541. 0x1543d86,0x0e6f21c,0x178ed01,0x1172beb,0x0462bd1,0x0b68e28,
  46542. 0x0d5e871,0x07cd0b5,0x0d077a9,0x000b2d8,0x0ca6109,0x1e19140,
  46543. 0x084aa55,0x06e98cb,0x1aee800,0x0020a17,0x049d402,0x03b620a,
  46544. 0x1f080fa,0x0edc98f,0x1e3f230,0x04baf30,0x0486a5c } },
  46545. /* 193 */
  46546. { { 0x01b4f36,0x0f109ca,0x13e4148,0x09f0076,0x1aacfb1,0x12a5d45,
  46547. 0x188b94a,0x0d9fbe3,0x08fe479,0x07d5ddd,0x0eb2dab,0x11b6b1b,
  46548. 0x11ae078,0x00cefd2,0x0635cdb,0x02dddbf,0x06a35a7,0x18aae14,
  46549. 0x1219186,0x1a8ced3,0x0a5ebe7,0x07b1d32,0x142d8e0,0x0c124c4,
  46550. 0x019149f,0x0d98a5a,0x028b7f1,0x12334fa,0x1466ac0,0x0d2ae77,
  46551. 0x1b31153,0x0d30d55,0x1fa4a24,0x04e76c9,0x05c5c69,0x1aa1216,
  46552. 0x01fa75a,0x178eb66,0x1015180,0x112f1c9,0x05d269f },
  46553. { 0x0920419,0x001860a,0x1ce4e9d,0x11212d0,0x0845d86,0x1b87d30,
  46554. 0x05313ba,0x1970373,0x1d9fc5b,0x1e55036,0x1e3cb6a,0x084feb1,
  46555. 0x0a06539,0x18ee295,0x1217d9e,0x037546b,0x1722c91,0x02d3ec6,
  46556. 0x1b0b60d,0x0200b95,0x1347404,0x023d472,0x0d61a29,0x1ca2587,
  46557. 0x0180b8d,0x0758277,0x148445a,0x1b54cdc,0x17cd8a4,0x0ed5918,
  46558. 0x1db02f5,0x0c22c9b,0x1d4185d,0x16be4d0,0x089876e,0x0759db9,
  46559. 0x09b0268,0x125ad60,0x1543c3f,0x0b44db2,0x08ac999 } },
  46560. /* 194 */
  46561. { { 0x040a39d,0x06e4d93,0x07e6cb2,0x11dbc19,0x01ff0b3,0x165d051,
  46562. 0x1a6f687,0x02ee9e8,0x1080d04,0x1481666,0x0518122,0x1465e93,
  46563. 0x15e956f,0x0bbb558,0x03e173e,0x1e92469,0x0ee0066,0x1e10fe3,
  46564. 0x1bbbcd9,0x03d7fdf,0x05ed35b,0x0e2309f,0x1e01160,0x0d740e2,
  46565. 0x1e8e6ea,0x1f6e5ef,0x0a5435c,0x1bf9546,0x048889d,0x1c9b0ed,
  46566. 0x14725d1,0x1b75ff7,0x0867c8c,0x17573e7,0x0c7c72e,0x11a4ce8,
  46567. 0x097912c,0x12a822c,0x07935a0,0x1b9afd4,0x00c7c1d },
  46568. { 0x0e963a7,0x118660e,0x0b794ea,0x19898bf,0x1352f64,0x1457dfb,
  46569. 0x08be0a0,0x00e5735,0x0ca2121,0x0139e2b,0x15db719,0x0ca90b4,
  46570. 0x1caadd7,0x085ae3b,0x05ab0fa,0x1e736c3,0x09fd1aa,0x0106a1f,
  46571. 0x14172f1,0x1240c59,0x12fdfc3,0x192607f,0x05058e1,0x1d043cc,
  46572. 0x0b8d82a,0x1f86799,0x0cfe9e8,0x1eb1f28,0x04ca925,0x0e96fb2,
  46573. 0x17ebafc,0x032314e,0x0061563,0x1b08c06,0x17b5ae1,0x02f3136,
  46574. 0x0d41244,0x1a1222d,0x0ceaefc,0x15c3bec,0x024ffc9 } },
  46575. /* 195 */
  46576. { { 0x1c7cb2b,0x06e02c9,0x0fee27f,0x0ab200a,0x01243b9,0x011a1e6,
  46577. 0x1af3d86,0x0c6c03b,0x166c18a,0x122a377,0x04ca1cd,0x0e03d92,
  46578. 0x11a5290,0x1cbc461,0x16e009b,0x1efaf86,0x02a92d1,0x04295c3,
  46579. 0x0a9e5ca,0x13960a1,0x0005180,0x1e51e59,0x025f519,0x1eb728d,
  46580. 0x077c09e,0x0c27906,0x0bc8906,0x066e588,0x1bb206c,0x1f06f9a,
  46581. 0x0d76814,0x1538281,0x026c6d0,0x17d99de,0x10332d5,0x10c39f9,
  46582. 0x099b396,0x1e7cf79,0x06e9070,0x1a280c4,0x089e4d3 },
  46583. { 0x05a9be3,0x14073d2,0x1ef74d7,0x100e6ad,0x04daa57,0x13de17e,
  46584. 0x158bae5,0x1c6030d,0x047cd16,0x18133cf,0x033a6e9,0x1804be6,
  46585. 0x10ca2f1,0x0fc327a,0x0816d18,0x03acde2,0x1978506,0x13feb6b,
  46586. 0x0822027,0x1b89ed1,0x1ae247e,0x04cd269,0x176b011,0x03f3b50,
  46587. 0x0664a6d,0x138fc22,0x135ea0e,0x1e619d0,0x0c33f19,0x15d6755,
  46588. 0x0afa4e0,0x1290c45,0x1033831,0x00f590f,0x12ebdda,0x0f606f4,
  46589. 0x19a1b5c,0x0b54844,0x143ef45,0x0dfcde3,0x0675d3e } },
  46590. /* 196 */
  46591. { { 0x07193e5,0x13ffeb8,0x039765d,0x030206b,0x0478aa9,0x06c77bf,
  46592. 0x1e7fcca,0x14eac69,0x06dbbd9,0x09d0774,0x055a1a4,0x12d0fc4,
  46593. 0x18379b2,0x04eced1,0x0fd042a,0x069a520,0x1b91b13,0x0ecfc6b,
  46594. 0x160bbed,0x0e84537,0x07789fe,0x111c01e,0x16d5a2d,0x1a4a689,
  46595. 0x1a350d3,0x1f449f4,0x01c9125,0x0b386b6,0x09e23b5,0x0a1b50b,
  46596. 0x1a711cb,0x198b698,0x1864632,0x1fa9884,0x16760f1,0x113edae,
  46597. 0x1e49788,0x0e78ed8,0x0692ea4,0x1fcc15e,0x05f7f92 },
  46598. { 0x145167e,0x10e6302,0x0383c62,0x055ff51,0x15ee2e0,0x153de7a,
  46599. 0x1fd450c,0x0cc499b,0x0a75108,0x1c16d21,0x046bddc,0x023e80a,
  46600. 0x03e894c,0x15578a1,0x13938c4,0x1a55d54,0x0f0f63d,0x0c61e9b,
  46601. 0x1d9818d,0x192aa1a,0x1eabfc5,0x189bf53,0x00494dc,0x172a1ec,
  46602. 0x0d59839,0x021152e,0x050398d,0x0b41ec0,0x0c70459,0x11c7795,
  46603. 0x1ce4178,0x088d61e,0x0bacc0e,0x02bc522,0x01bb112,0x0699a84,
  46604. 0x05bd780,0x1d8d555,0x11634d9,0x1b21456,0x025bece } },
  46605. /* 197 */
  46606. { { 0x033a8fb,0x139c106,0x10741e6,0x021e4bb,0x0fbf6cd,0x0a415b6,
  46607. 0x1cfe31b,0x0949ff8,0x007bf84,0x128f8c6,0x058bc0f,0x046cb32,
  46608. 0x11a7651,0x0a009c0,0x1669d38,0x0314158,0x065e550,0x0cabd34,
  46609. 0x0f2826c,0x18a37bc,0x053fe1e,0x19d4b01,0x0f031fa,0x1c07f09,
  46610. 0x1fd147d,0x184f41d,0x054bef6,0x00a81da,0x015ec1c,0x176ee75,
  46611. 0x01dae94,0x0964c26,0x1d30ed5,0x0b90379,0x0ba3a0e,0x1537af7,
  46612. 0x096373a,0x06c3490,0x0fd8fc8,0x0978761,0x00a616a },
  46613. { 0x01339c9,0x0f9f6b7,0x029881d,0x057f160,0x1afaa07,0x06cda3b,
  46614. 0x1b20af3,0x18fbf5f,0x100ca54,0x1898ac7,0x10c6b91,0x05e2717,
  46615. 0x0a44910,0x1886fe4,0x063c560,0x0a9a95f,0x07559e9,0x064f790,
  46616. 0x149e831,0x0435f38,0x0023e80,0x1bbd0c9,0x1ba0049,0x16046ee,
  46617. 0x1538c7f,0x0a8b1af,0x1fa327a,0x1be32e9,0x0c90975,0x1d768ae,
  46618. 0x1700a1f,0x1ef4a22,0x00728f0,0x0311efd,0x0f983eb,0x1321b7f,
  46619. 0x0311ba0,0x0a07ea0,0x11932a3,0x09c0f8c,0x0876d15 } },
  46620. /* 198 */
  46621. { { 0x0d3ea8a,0x06b6961,0x003b4e9,0x175084c,0x16be681,0x0383391,
  46622. 0x0403790,0x0f78a7e,0x06a7d7a,0x1f2db7f,0x186a0f8,0x09f2bab,
  46623. 0x0a6e699,0x1b04be1,0x12b3489,0x020220f,0x1baa679,0x0096cc6,
  46624. 0x00b8389,0x1888c22,0x072addf,0x016a499,0x120576f,0x086cd2c,
  46625. 0x0e64ba9,0x1c83f1c,0x08cacaf,0x12c1d63,0x08e28b4,0x1a92ec9,
  46626. 0x07b6915,0x0540ef9,0x0f75b39,0x10e8039,0x12edff5,0x0c4eec1,
  46627. 0x0f4b145,0x11ae8d8,0x05c02bc,0x077ceda,0x03040c2 },
  46628. { 0x0fa9a70,0x0e2ada7,0x1842c43,0x1ea7d0c,0x14de414,0x1c513fe,
  46629. 0x1044c27,0x0787b2b,0x106661d,0x02884d2,0x0d44f94,0x1294c1d,
  46630. 0x0bcaa29,0x0f3e99c,0x19054dc,0x1ce3e7d,0x1fc4651,0x027e8a2,
  46631. 0x0f0c4ed,0x17f0719,0x015051b,0x1c0f5c9,0x0c0e781,0x17eb58f,
  46632. 0x16b4414,0x0467434,0x022f835,0x1acce31,0x0f2b6f2,0x197aeec,
  46633. 0x02afa4e,0x1d714ff,0x1dfd1e7,0x1a8e2e0,0x176643d,0x1d0c567,
  46634. 0x032a74b,0x18d6ac5,0x126887a,0x1343d77,0x05486d7 } },
  46635. /* 199 */
  46636. { { 0x1359e13,0x11a7fd0,0x01472cb,0x1e5032c,0x002d8db,0x0b25af1,
  46637. 0x008f48d,0x025d2bc,0x042f6ac,0x189a05b,0x0dc977e,0x10a56ca,
  46638. 0x0d543ba,0x0692335,0x0bb735a,0x0e51703,0x024547c,0x0dfbc01,
  46639. 0x15a7ed9,0x1f14232,0x0ec9559,0x116fd91,0x1416de9,0x1dabca4,
  46640. 0x075409e,0x1888388,0x00a67db,0x1913251,0x16f8c79,0x09309ed,
  46641. 0x0a69f5a,0x16794f3,0x0eb7fb3,0x0b05818,0x0ee3ec8,0x1595733,
  46642. 0x128b409,0x0092b46,0x17e2f48,0x01eb588,0x0380f1b },
  46643. { 0x0a0068f,0x0cf35f3,0x1d4f02e,0x15914e6,0x0b67cf2,0x1d75be2,
  46644. 0x09522cb,0x1874d93,0x1340260,0x1a0bfcc,0x1dce79f,0x10ab981,
  46645. 0x1a8ee56,0x1c04a4e,0x02d443d,0x0ddffe1,0x1c28d5c,0x1d8bb87,
  46646. 0x165a9ee,0x0b57ddf,0x1a2ab4f,0x1b79332,0x081ec44,0x003b9f3,
  46647. 0x180a4b6,0x06317d9,0x1058afb,0x19006c2,0x0b83b3c,0x1dcb773,
  46648. 0x1acd263,0x15182fd,0x09b0fd6,0x1f7e175,0x16ea85d,0x1cb0696,
  46649. 0x1b110b3,0x08227aa,0x0a17a4a,0x1dbd7ae,0x04abedd } },
  46650. /* 200 */
  46651. { { 0x00ef376,0x0f0dcb8,0x0ffccd5,0x14cd9b5,0x156e5d9,0x143b236,
  46652. 0x095d51f,0x0d367b8,0x000f793,0x07a25c5,0x14b8a4a,0x163d418,
  46653. 0x1208c32,0x1b94d9c,0x1e37848,0x0473ab4,0x19ab26d,0x1a0c228,
  46654. 0x033929a,0x0d696fc,0x09f923f,0x0556595,0x08d7dbe,0x00c94b2,
  46655. 0x1c454e2,0x1175dc5,0x106fcc1,0x0fdfa06,0x1ff6f93,0x141dca6,
  46656. 0x019aeb1,0x1154ff4,0x1364b1e,0x19ba2e1,0x1cab382,0x1e0c2ce,
  46657. 0x11e3fb0,0x1846846,0x0cb4d1b,0x16631c2,0x06a20ab },
  46658. { 0x085cbc7,0x1880b35,0x0a9faa0,0x0d269f3,0x1099094,0x1c78d9e,
  46659. 0x042239d,0x1338442,0x12247b7,0x1527fc7,0x121339f,0x1ae28a8,
  46660. 0x04b3171,0x07cc61b,0x100e525,0x028b052,0x1f397df,0x12ed488,
  46661. 0x050e445,0x0b01261,0x18bca6b,0x0d0ba11,0x1d7e542,0x012eb1a,
  46662. 0x1182182,0x0e87f5a,0x0691e49,0x1c18c04,0x0a315ea,0x134a57c,
  46663. 0x0dc3a51,0x0d75a09,0x07af8a3,0x1223ed7,0x19ffc1c,0x1c8982b,
  46664. 0x05456ff,0x0233455,0x0e5dd46,0x14f7e6d,0x045e353 } },
  46665. /* 201 */
  46666. { { 0x1092f71,0x0b3b249,0x15c5d81,0x05eb725,0x0b66b6c,0x045b62f,
  46667. 0x0526f8b,0x07d3b66,0x020c036,0x117ac1d,0x15c25fd,0x1a66079,
  46668. 0x0c688ac,0x15dc8b5,0x14303e3,0x1361d0b,0x02c84c1,0x08dfba3,
  46669. 0x1129ab4,0x1dabf2f,0x1369c76,0x1d688cf,0x1b22e22,0x1ca1707,
  46670. 0x0371beb,0x1532cdc,0x02199c1,0x198d2a1,0x173d2c0,0x1ad1fc1,
  46671. 0x1ed4c71,0x054b405,0x01cd3a3,0x0d0e827,0x1de368e,0x1dd04e8,
  46672. 0x15da333,0x1e2dddb,0x0f4dbb7,0x04994f3,0x015941f },
  46673. { 0x17dd512,0x0607c53,0x17d90ba,0x0e3b86c,0x091b59a,0x1a9c315,
  46674. 0x0533421,0x195d01a,0x1d272fa,0x1121186,0x1f2d685,0x182c804,
  46675. 0x03eea3e,0x00f7cf8,0x1c02d67,0x0291b82,0x1270da3,0x0ea08e0,
  46676. 0x10606bc,0x1dc8918,0x100b801,0x0ccf1d4,0x1b7ca15,0x0135ffb,
  46677. 0x1b0bd0d,0x0122eb3,0x1a2cdc0,0x1073bf2,0x1836b8d,0x03f0737,
  46678. 0x124ed8c,0x17a6403,0x182e588,0x0815da9,0x09ade87,0x12c6db1,
  46679. 0x168641e,0x1bedbb4,0x0b40dc2,0x094231f,0x06d17c3 } },
  46680. /* 202 */
  46681. { { 0x181c99b,0x04420e0,0x12bf3d8,0x0390f7b,0x165dc90,0x106d5f5,
  46682. 0x0d11cdc,0x0b768c1,0x0537751,0x03ce1cb,0x1b09dd3,0x045c152,
  46683. 0x00d447f,0x15607a2,0x05484c0,0x1075a1b,0x06bc905,0x0419859,
  46684. 0x0a24128,0x1d2ef52,0x0b18e25,0x0cc2e28,0x077abff,0x15abed4,
  46685. 0x1bcb7a5,0x16ae7a6,0x07228df,0x179a003,0x1850b6c,0x0ec80f4,
  46686. 0x015e11b,0x16171cc,0x0c8194a,0x197c80d,0x15c4d04,0x1772e50,
  46687. 0x156ee28,0x14f8a4f,0x0753933,0x1487d3c,0x01ab9b5 },
  46688. { 0x14fa7a3,0x0d5c918,0x058c81b,0x008f1ff,0x0c4af0f,0x06cfede,
  46689. 0x05c4e41,0x1fc999c,0x112c045,0x0105175,0x1db5f6b,0x08f1fb1,
  46690. 0x1a44fc5,0x053db7f,0x1b9cb17,0x1eeb110,0x09b6fd6,0x0bfd229,
  46691. 0x0aa0835,0x03a3632,0x11494df,0x0f93c4f,0x0f604be,0x176a7a4,
  46692. 0x0f083aa,0x1994c21,0x0ca80ea,0x0c90a73,0x1125022,0x104858a,
  46693. 0x1558c73,0x0e63ed7,0x1294d15,0x1731a70,0x187650d,0x1f64526,
  46694. 0x1ca966a,0x0140e21,0x0cfb631,0x0ad8435,0x024b349 } },
  46695. /* 203 */
  46696. { { 0x19824e2,0x0e5c332,0x1d3126f,0x109c27c,0x0dc4ce4,0x1f0f753,
  46697. 0x06899ae,0x0af4980,0x11e3ec4,0x1d95c73,0x0a392d1,0x0bc05eb,
  46698. 0x0d7e8b1,0x1199a98,0x07adb9b,0x0a405d0,0x09e17a4,0x1d65d1b,
  46699. 0x1c39327,0x082863a,0x1eb8812,0x059f095,0x10642bd,0x1e90dfb,
  46700. 0x1052311,0x1e72993,0x04a7eca,0x1ed883c,0x0f6c089,0x03f5db8,
  46701. 0x1def98a,0x07fd688,0x079850a,0x18c5d8a,0x0c466f3,0x01f9fbf,
  46702. 0x1a80d04,0x0e1497e,0x16fe649,0x1cafc78,0x0212d65 },
  46703. { 0x015cf08,0x0d9c365,0x0bac8eb,0x0903c2e,0x0dfa4ac,0x0168602,
  46704. 0x0fe4d35,0x18f3a3b,0x174404d,0x0e7b039,0x0aff376,0x0883d26,
  46705. 0x1860508,0x0e34154,0x1a44328,0x0398135,0x01841ac,0x04a947e,
  46706. 0x0efb58c,0x02415db,0x1250e6a,0x1618667,0x0538387,0x1177e5f,
  46707. 0x0ba54e5,0x00aff42,0x1e7ea91,0x0cda169,0x0e7ce5c,0x18f3f67,
  46708. 0x0e83163,0x0df4d0e,0x01d43eb,0x189a43d,0x1680e67,0x0f2d8d8,
  46709. 0x06727ab,0x17cd557,0x0911f9b,0x0a934b8,0x066afa5 } },
  46710. /* 204 */
  46711. { { 0x180e91d,0x155d464,0x1beb696,0x12d5931,0x093cf50,0x1193315,
  46712. 0x0382a36,0x07d6132,0x0008145,0x0e90a98,0x077a100,0x067c7ae,
  46713. 0x122bb0d,0x1f0cd00,0x17db600,0x071ce8c,0x14c78a8,0x02c817f,
  46714. 0x04c4d23,0x055f6e3,0x057b74e,0x0bce7d8,0x0924c9d,0x1a07f1f,
  46715. 0x0a6423a,0x0053b0f,0x1563fe9,0x0fa9848,0x087e30b,0x006cbbd,
  46716. 0x09ad7a7,0x193909a,0x1c5edba,0x0b1d068,0x0e68f46,0x1bd9510,
  46717. 0x0bf6bf0,0x17979af,0x0af7ef1,0x0621ab1,0x001ef06 },
  46718. { 0x0cdcbb0,0x0818b1f,0x0554afe,0x104f839,0x19e2d72,0x1ae4980,
  46719. 0x1c0c255,0x0613ca4,0x1969839,0x0e0e2d4,0x020b7c3,0x01fef9a,
  46720. 0x11ef9f8,0x0fcbf02,0x04541d7,0x036ab9b,0x1fe9cc6,0x079437f,
  46721. 0x03c9331,0x1b671f0,0x1ae3352,0x161b291,0x1b66e67,0x1620953,
  46722. 0x08ca810,0x1d6884d,0x1cc1480,0x04e01fc,0x1400f5c,0x11273b4,
  46723. 0x0b0a8bb,0x1dc188a,0x195d399,0x01520ea,0x15abdfc,0x0e156eb,
  46724. 0x0db730b,0x08404c8,0x04808d0,0x1fabd1a,0x00e4f5f } },
  46725. /* 205 */
  46726. { { 0x1f14c38,0x0322207,0x07caf47,0x155d9c2,0x1a5b59f,0x17b1984,
  46727. 0x0169c8a,0x1dd548c,0x082af24,0x0e4fb2d,0x0845677,0x17fdd73,
  46728. 0x0ff4ee4,0x1a74275,0x18f41d9,0x1559c48,0x1e00e0b,0x1c465f0,
  46729. 0x17eaf72,0x0ad1d5a,0x199d7ca,0x1262bf5,0x0f60354,0x17d30e7,
  46730. 0x0572ce9,0x02f4e23,0x15cc02e,0x03143b9,0x1541769,0x0989207,
  46731. 0x0d92488,0x16b6284,0x1e324ff,0x078b57b,0x140490d,0x1881bb4,
  46732. 0x0133d97,0x019a10d,0x1c08022,0x0c210ed,0x033d411 },
  46733. { 0x078e5ec,0x0d1b5cc,0x08c9d4c,0x028d230,0x1de3e32,0x1182322,
  46734. 0x068cf42,0x0b3a2bf,0x1aa1736,0x1a60dc3,0x1753f9c,0x0945f24,
  46735. 0x14ac209,0x0131587,0x1259687,0x0b97887,0x03e447d,0x03ace48,
  46736. 0x148e4c0,0x1e42bc0,0x1f3492a,0x0f8fac9,0x1ffedb5,0x19bb6bf,
  46737. 0x03b4bc3,0x00432ca,0x12ff755,0x1a07453,0x0d76c09,0x0d358cc,
  46738. 0x1663df3,0x181e4f6,0x0790a22,0x0c667e0,0x0a1232d,0x1974aaf,
  46739. 0x16c54fd,0x110296b,0x0d19964,0x1548f6d,0x02d3de7 } },
  46740. /* 206 */
  46741. { { 0x1add3b7,0x13a3132,0x10aaab7,0x0b57e49,0x05888f3,0x12bec9f,
  46742. 0x1272b86,0x17fa82a,0x02c76f7,0x11170c7,0x080acc3,0x11d57c6,
  46743. 0x0a67f28,0x0e8e878,0x0699ae8,0x15a316f,0x1492881,0x087055b,
  46744. 0x1eb6c3a,0x04810d8,0x132f7d4,0x0294210,0x01c30cb,0x1f3413d,
  46745. 0x077f158,0x0c4c2c2,0x0bb0095,0x045526e,0x0987774,0x062e528,
  46746. 0x162f90a,0x0aecc00,0x1b79564,0x19be7a2,0x18c655f,0x12d8ff8,
  46747. 0x1631628,0x1811eee,0x04a9a2d,0x16cb638,0x047003b },
  46748. { 0x11c1c96,0x000e0e4,0x05c3665,0x124f425,0x0a5dcdf,0x014883d,
  46749. 0x0b85f0f,0x0207572,0x1a3fe47,0x17e747b,0x0663b89,0x1abc9dd,
  46750. 0x18b0d09,0x071d20f,0x0988812,0x14a0d5f,0x0a5a26c,0x158e009,
  46751. 0x06d5c94,0x1ee6993,0x1fe12c6,0x0fa897b,0x0424f5e,0x1dc334c,
  46752. 0x0906eac,0x1531798,0x0415b47,0x17ff070,0x135f216,0x0c2b77f,
  46753. 0x091871d,0x1835a44,0x007e978,0x07ef437,0x1285ac8,0x165994d,
  46754. 0x033fe81,0x06b696b,0x0b39aad,0x00960d4,0x073dff5 } },
  46755. /* 207 */
  46756. { { 0x0e20fb8,0x0ac02ec,0x0fc22d8,0x09056a6,0x1c6873e,0x142a653,
  46757. 0x1c0055a,0x022a40b,0x0cb3692,0x1ff6356,0x024ade1,0x01d98fe,
  46758. 0x0c1fa3c,0x1422ff2,0x0d991fb,0x1e224b6,0x085f8b1,0x1ea3c0f,
  46759. 0x0c3c69b,0x04d0731,0x0b92c65,0x166e5c7,0x13bae31,0x0bedaa5,
  46760. 0x10ead8e,0x06e099f,0x0f2364d,0x03107c4,0x0ac45a3,0x0adea14,
  46761. 0x014853b,0x1b77f95,0x17ca492,0x0d709fb,0x0ff81f9,0x17be822,
  46762. 0x12ab05f,0x1250693,0x1d4d58f,0x16ee291,0x07544d0 },
  46763. { 0x0797ace,0x0689a40,0x05f93fa,0x015f0db,0x016d6aa,0x0d347e1,
  46764. 0x09a23bd,0x109b7e1,0x19f9b26,0x05937a2,0x074bf06,0x19f5133,
  46765. 0x1552fef,0x11211ca,0x0be3609,0x06f01ab,0x069f63a,0x1c7891a,
  46766. 0x1353fab,0x068a9fb,0x1d09293,0x1bd39da,0x0ea0062,0x0aa5831,
  46767. 0x1f276e5,0x18e4d78,0x17fc9ae,0x0ba8ee7,0x1d4f44c,0x0a08036,
  46768. 0x1267bd2,0x0be7374,0x18f12f9,0x0527956,0x1b73d9b,0x14aecfe,
  46769. 0x1922f59,0x03b9f8b,0x0b526ea,0x1d583c8,0x0220081 } },
  46770. /* 208 */
  46771. { { 0x037a0ba,0x1eab9dd,0x17d8c10,0x19ba2ed,0x05a431b,0x10387b8,
  46772. 0x0b3f310,0x0120664,0x067c2d1,0x055e987,0x02f3e97,0x0bbd97f,
  46773. 0x0b362c9,0x1bc3d88,0x19f49dd,0x0bcc9ae,0x15e6ec0,0x1309648,
  46774. 0x19a70c3,0x0d2c639,0x06359e6,0x07b4171,0x09f2776,0x1ff9870,
  46775. 0x01f1295,0x0513c81,0x0628ab7,0x0d51dcf,0x1d500a0,0x13c225a,
  46776. 0x1163803,0x11b01ad,0x1746fc7,0x1886643,0x0efa457,0x1048c0a,
  46777. 0x019f6fd,0x0719459,0x0dcce11,0x158237a,0x0620541 },
  46778. { 0x09e5a29,0x1e9c128,0x0c783df,0x016864a,0x0748d7d,0x1c41dcc,
  46779. 0x04d5334,0x0f51ee9,0x08bfbb1,0x15c563a,0x0b4b171,0x14cc0be,
  46780. 0x03a4616,0x0de58dc,0x1659894,0x04cb567,0x1042fee,0x067ba98,
  46781. 0x0c89416,0x1ae7f7b,0x1556c70,0x1a78616,0x0484750,0x164b366,
  46782. 0x061d854,0x1bec310,0x1710acf,0x1fc8c0d,0x0a4949f,0x02c2f43,
  46783. 0x0b13172,0x02c1ddb,0x0ddcc8b,0x1121002,0x199d5a3,0x0c30099,
  46784. 0x0214165,0x19c2ad2,0x0fa5e47,0x131f265,0x07f3781 } },
  46785. /* 209 */
  46786. { { 0x1a6639a,0x1a5ed6f,0x0e4668d,0x080556e,0x0cbd48d,0x018f168,
  46787. 0x1c8d91c,0x03eb8bd,0x0d0599d,0x04f715e,0x0e110ed,0x16c1c1a,
  46788. 0x08d285e,0x1349c97,0x0faa4bc,0x0a71fb7,0x1bfb8bc,0x048a2af,
  46789. 0x11a6dda,0x0b3fe3c,0x1682ae2,0x0fa0ef2,0x1073b2c,0x0a5a35d,
  46790. 0x0f07199,0x023643b,0x079efdd,0x19c4a30,0x0ad2f11,0x16c3141,
  46791. 0x19f2e4e,0x0d749de,0x1a3cd31,0x1d51f47,0x0813941,0x11f9cd1,
  46792. 0x061bb60,0x0ba0b85,0x043433b,0x167ed58,0x06de716 },
  46793. { 0x12d6dc5,0x0c6820b,0x1973539,0x0cc72f8,0x1ed2cde,0x0f5a745,
  46794. 0x1f86032,0x1b6f5ce,0x075fa2e,0x113aa34,0x199ce15,0x049d523,
  46795. 0x0e4b303,0x11ae459,0x08ea158,0x0510ec0,0x0c2a8f9,0x0cefb6b,
  46796. 0x1bd7a2d,0x1830bfe,0x148aec2,0x159d6ab,0x1e24b84,0x095df78,
  46797. 0x1b4f2d5,0x010bd75,0x03ba1a2,0x0922a89,0x19bd5b1,0x0fb8d8e,
  46798. 0x1de89b1,0x05fe01b,0x1ccd166,0x18ef772,0x1c5ee56,0x09d7933,
  46799. 0x1fe1f77,0x0c1b0b1,0x096c242,0x061767a,0x051f908 } },
  46800. /* 210 */
  46801. { { 0x0922461,0x1b7d0f9,0x034524d,0x062ca1a,0x1bb1b1c,0x0c3046e,
  46802. 0x070cc37,0x00d2572,0x136b899,0x1309625,0x180148f,0x1617bea,
  46803. 0x05e1977,0x11b512a,0x0bffdc1,0x07b1df1,0x0781172,0x166d3e9,
  46804. 0x06f79ee,0x1789770,0x178e0b0,0x1976952,0x0f2c202,0x0365c04,
  46805. 0x00d0d17,0x0d72ded,0x1e506ee,0x0dbe719,0x0a65c5f,0x00ede0a,
  46806. 0x03a1776,0x1833bb3,0x198c82d,0x037c9bf,0x11fd488,0x118c26e,
  46807. 0x1f5bbe7,0x09d1612,0x12f9e78,0x11c1546,0x05eed21 },
  46808. { 0x1d4dc0b,0x12baa00,0x0c1f855,0x0feacd7,0x01ae5f2,0x1112ead,
  46809. 0x1afaee0,0x0d7d30b,0x01189ec,0x19d690e,0x1936757,0x0319d99,
  46810. 0x1917da5,0x0b5b2da,0x128b4fb,0x0ee3990,0x1758ffa,0x13fcc40,
  46811. 0x0b1a69e,0x0d5c245,0x046d50d,0x18e3734,0x12dfcc2,0x1a17627,
  46812. 0x03a605b,0x003c601,0x175cfc9,0x1421fd9,0x10a9969,0x0c6672f,
  46813. 0x01a3145,0x17b1eb0,0x06bf615,0x12370e9,0x0a1e456,0x115e65d,
  46814. 0x0287d30,0x1ba7408,0x10953ab,0x00d4c4c,0x08c14ba } },
  46815. /* 211 */
  46816. { { 0x17ee201,0x1bc4ad8,0x09dc321,0x0311caf,0x005aa47,0x01122b6,
  46817. 0x19d8e5e,0x03a3387,0x0c9c3ba,0x1f37c60,0x027af82,0x09ff687,
  46818. 0x16fe85f,0x0673fdd,0x02f3338,0x0d8c8a7,0x12a6526,0x143b755,
  46819. 0x1e68e10,0x158d219,0x19815c9,0x18e6647,0x07d73ce,0x1ed0fbd,
  46820. 0x1be6a9c,0x00afd0b,0x120e0d7,0x19f821f,0x0ef2ebf,0x07ed8a8,
  46821. 0x19821ac,0x11094a5,0x197ecd9,0x08f5c4f,0x1e8ac33,0x1482dcd,
  46822. 0x1ecc03b,0x1e8acc9,0x0597b8a,0x0bbd576,0x0645c0a },
  46823. { 0x0aa7e31,0x02102a8,0x1697653,0x185f0a3,0x0ec8df0,0x1937355,
  46824. 0x1a424f1,0x13532c8,0x02619bf,0x16dee1b,0x0fef55c,0x01c1c4a,
  46825. 0x061b426,0x06384f0,0x10967ee,0x1d8b72f,0x0bbcdda,0x0fd5fbe,
  46826. 0x12dc0fa,0x0bd163c,0x0fddb4d,0x17039a7,0x06c1b95,0x0abf14a,
  46827. 0x0a4f91f,0x046816a,0x08fd597,0x1f0c117,0x0d1d947,0x03e940b,
  46828. 0x0da08bd,0x0b9cf62,0x0c36156,0x0212106,0x17bcc74,0x0dc8ddc,
  46829. 0x083567f,0x132fb83,0x1b246ca,0x081a5f4,0x027e9ff } },
  46830. /* 212 */
  46831. { { 0x1e952e7,0x08c49eb,0x1c61d49,0x078e6b7,0x15b3058,0x1f02488,
  46832. 0x1664a5b,0x194e656,0x0806d2f,0x1a28c2c,0x017b649,0x0d40371,
  46833. 0x0c71ab7,0x16cfaaf,0x13a765d,0x175397b,0x12048f2,0x19ed305,
  46834. 0x04ac4ca,0x0f810cb,0x11d7697,0x0584c82,0x0db72a7,0x1115c4b,
  46835. 0x0ab23d1,0x19eece1,0x1f882ab,0x1e8d3e7,0x0d74d09,0x1be7ad5,
  46836. 0x0ef6f47,0x04553d6,0x15efe5c,0x008621e,0x1e884dc,0x0118bdb,
  46837. 0x1787026,0x1110bda,0x05ddab6,0x0ce7b59,0x04feee5 },
  46838. { 0x1d3d780,0x0c6a95a,0x1d10c38,0x060e2cc,0x0dadb5d,0x1a10ab2,
  46839. 0x0e1b969,0x10c641a,0x08d6bbb,0x0c61487,0x18f7457,0x06465a4,
  46840. 0x16981a4,0x0c4c231,0x1439f2a,0x1596267,0x04da519,0x1a89c3c,
  46841. 0x177207f,0x1c7f57b,0x043a832,0x0a18ccd,0x1f09e16,0x0e862c7,
  46842. 0x0abcf32,0x1d3ada6,0x15d3e53,0x1f40217,0x14a6279,0x1a1eab4,
  46843. 0x0930a29,0x196caf4,0x1d2a888,0x112f560,0x140fa1a,0x1efdde4,
  46844. 0x04c561f,0x08d2e98,0x1783bb4,0x1cf393d,0x04fe818 } },
  46845. /* 213 */
  46846. { { 0x1c1c7ff,0x0964ebf,0x0b44009,0x1b3f513,0x09bd419,0x1274e65,
  46847. 0x0492901,0x1999274,0x043942e,0x0265e5c,0x05a56ce,0x03fb0e9,
  46848. 0x1f004c2,0x0108b2d,0x120767d,0x02204d3,0x028dde0,0x0f1192b,
  46849. 0x0a6c013,0x06e8aeb,0x1c21ec9,0x1ffb6e7,0x1eccd1a,0x06e58fb,
  46850. 0x1a64b4d,0x0715626,0x0fc8125,0x1d96f5a,0x07c150c,0x00daf43,
  46851. 0x16158b1,0x1856e47,0x19395ce,0x0991894,0x1f15fb9,0x0f9235b,
  46852. 0x110b659,0x1788b0f,0x0fff381,0x0536e9a,0x0819155 },
  46853. { 0x0d9d4ee,0x09218b7,0x1c063b0,0x08d135f,0x1dffa15,0x04d1fa1,
  46854. 0x0d27caa,0x1649574,0x0d467ef,0x0d8f471,0x040b88b,0x06a8072,
  46855. 0x0b18dea,0x1297841,0x0aae14f,0x1ba8e84,0x0c1ed36,0x1389851,
  46856. 0x0a5747b,0x01d0da0,0x1ad3ca6,0x043e3fa,0x19ab1a0,0x10c8cb1,
  46857. 0x1cecfde,0x13287c1,0x0518744,0x05ccd84,0x1850997,0x00a85e9,
  46858. 0x027fbbd,0x14cc645,0x1183f3a,0x0e3ca87,0x12f9e4b,0x044ea8a,
  46859. 0x1136770,0x02608d8,0x1bbcc9d,0x18fd1d4,0x07d06bc } },
  46860. /* 214 */
  46861. { { 0x090212f,0x02ca138,0x011224a,0x18aa43d,0x091b7d4,0x16ddc93,
  46862. 0x0108af8,0x1009807,0x1bd81f8,0x0bb90f6,0x06f0d8c,0x17dd591,
  46863. 0x0dc136c,0x1dc7802,0x1c6d82d,0x115709e,0x0d04e21,0x0934899,
  46864. 0x1b32053,0x0492ddc,0x1c15b0e,0x0bbafd6,0x02cb38c,0x1a4478a,
  46865. 0x1c08466,0x1c5c171,0x193184b,0x0e43954,0x1653559,0x08f5d25,
  46866. 0x145669d,0x18fa7b3,0x033aad5,0x0a1231a,0x074ba03,0x143cc37,
  46867. 0x1c673ca,0x0fb2aff,0x12e4852,0x133a1f3,0x048b52b },
  46868. { 0x1dc05be,0x0a9ccf7,0x17a68e4,0x1027c12,0x1e70db1,0x0d9fed6,
  46869. 0x18ba737,0x0a288f0,0x01a0094,0x15818b1,0x083a8e8,0x1018472,
  46870. 0x0b4b279,0x111dc7f,0x14e53c6,0x02da958,0x0563e56,0x10b1fb9,
  46871. 0x1c50866,0x1ff27f6,0x0474aa0,0x0949eb1,0x149be5b,0x19fc4ed,
  46872. 0x12ea87d,0x08aee90,0x1d1c0e3,0x164f7e5,0x18168ea,0x0192fa0,
  46873. 0x06b9632,0x1665531,0x1704222,0x0f89df1,0x0e42ff2,0x1b46d28,
  46874. 0x0d0684a,0x1713030,0x1dbb3c5,0x10f3b18,0x017c0de } },
  46875. /* 215 */
  46876. { { 0x0c01958,0x0fa29ee,0x0e4ef29,0x0839d10,0x1d94595,0x0fadb6b,
  46877. 0x1428558,0x178bcc6,0x07e2d36,0x08e1e43,0x10e9b0a,0x1b094b5,
  46878. 0x0df6c7e,0x0cc0036,0x04f102f,0x1d876f2,0x0875671,0x0fbc5d8,
  46879. 0x10fa26a,0x051edd6,0x01ed1c9,0x19d70f5,0x1f7ca37,0x049656b,
  46880. 0x1a5b1b9,0x102b15d,0x146845b,0x123a4e0,0x1ed3e34,0x015b8b3,
  46881. 0x11823b0,0x0b78160,0x091cf7b,0x0bfacf1,0x05a6317,0x0e61ca0,
  46882. 0x15c799b,0x1e1a86f,0x1875c31,0x1c4158d,0x06862b9 },
  46883. { 0x1fa1f64,0x17a73cf,0x0d255b1,0x1543c48,0x1ed6a91,0x1ba9197,
  46884. 0x1b83336,0x00fd341,0x10322d6,0x1e4859b,0x1fbe1ef,0x15a48c5,
  46885. 0x1429480,0x015fe79,0x08525a7,0x1c71ff8,0x1e0a539,0x0372908,
  46886. 0x0a94527,0x13d84c2,0x15322a5,0x096b835,0x0657f88,0x1390852,
  46887. 0x1b108e9,0x0417bbf,0x0d77201,0x099d5d4,0x12d2987,0x0185dec,
  46888. 0x1ba9698,0x155d42b,0x142dca5,0x1884e56,0x0f1d261,0x13ad587,
  46889. 0x090af64,0x070e201,0x179b319,0x05aa3f1,0x05093fa } },
  46890. /* 216 */
  46891. { { 0x02d553b,0x1994026,0x10a7133,0x04772cd,0x1c1abe2,0x0b48a56,
  46892. 0x152708a,0x192aad4,0x1999976,0x064fc5a,0x1a0fcf6,0x0f7aeed,
  46893. 0x17c22c5,0x1e42f62,0x0a50aad,0x0c3ea9e,0x1e56e2c,0x0779a03,
  46894. 0x084f6d2,0x0bd195e,0x18c7f00,0x1ef9934,0x11c3214,0x1814a96,
  46895. 0x088d7ca,0x00f737a,0x1582dd4,0x0d7ad7d,0x0a4bd9b,0x188338a,
  46896. 0x053c040,0x0dc1311,0x085bc3b,0x0950029,0x106bd7e,0x15d80ce,
  46897. 0x0f7ef24,0x18b2137,0x090e0cb,0x09ad8ef,0x012f9c4 },
  46898. { 0x1313a1c,0x0f4b241,0x0cdc654,0x14678b1,0x18edd3d,0x1620224,
  46899. 0x0fd4b1e,0x1d09db7,0x10dcb5e,0x136537b,0x108be21,0x11eadba,
  46900. 0x0eec0ae,0x0330f61,0x1def150,0x0a47820,0x13ad422,0x1369cc8,
  46901. 0x039f2cf,0x0bc3d0b,0x1b45d10,0x1fe4bcd,0x11f24e5,0x12f6b24,
  46902. 0x1d4a909,0x1f39910,0x0fa254b,0x1dec514,0x1462410,0x0c13a74,
  46903. 0x1034235,0x0b2f01e,0x0cbed0f,0x0887632,0x089c238,0x0627af8,
  46904. 0x1679b1a,0x036c333,0x0746346,0x09c4d5c,0x002f75e } },
  46905. /* 217 */
  46906. { { 0x1f307d7,0x1bf5fa3,0x11dc6d8,0x15a0282,0x0b644a6,0x02d4063,
  46907. 0x0f594b8,0x0630546,0x1fed07b,0x078d079,0x1b965f2,0x0ff26d2,
  46908. 0x1ec09ee,0x03ffe00,0x0a9fb0f,0x0e7739b,0x0fef8f3,0x0aa4fc4,
  46909. 0x0eee262,0x1a32c38,0x07b7c88,0x14efe55,0x164a93f,0x1c95641,
  46910. 0x19ee23a,0x0d2897f,0x07d7b2c,0x0b5d4c8,0x0fb47df,0x11bff19,
  46911. 0x1039da4,0x04ba10b,0x0a5c420,0x1aad14b,0x15609b1,0x07b9224,
  46912. 0x1bce972,0x05cc2fc,0x0650560,0x0ccc72c,0x072b1b5 },
  46913. { 0x10e5558,0x045043c,0x1e0275c,0x020d135,0x1853604,0x189dafc,
  46914. 0x1ee2908,0x035d0bc,0x055a49d,0x15d0949,0x1c6c2f9,0x0961586,
  46915. 0x195e76c,0x09c7370,0x1413ce6,0x13442b0,0x02260ae,0x146ea0a,
  46916. 0x1a12173,0x009d372,0x1e43d8b,0x12c43f7,0x1e5312e,0x038bce7,
  46917. 0x08e67f1,0x0e20893,0x033dae6,0x04c47c5,0x0a96629,0x15543d0,
  46918. 0x14fcb42,0x099405d,0x066772a,0x1daa8d9,0x1938b58,0x0ad1dd1,
  46919. 0x0e78b5b,0x15d94c9,0x096b737,0x02dc2e4,0x05df192 } },
  46920. /* 218 */
  46921. { { 0x1f2e7e3,0x13f0f46,0x1f78800,0x11b1b40,0x1183cc6,0x05734a5,
  46922. 0x0e9a52d,0x1119c6b,0x13ca62e,0x0b6cbef,0x1fb4b22,0x0276a5d,
  46923. 0x0f3de47,0x135e842,0x01b1038,0x12477a0,0x1bbfc81,0x00f4db8,
  46924. 0x0ab31ac,0x038f6c3,0x0840999,0x1247b2b,0x194324d,0x1e8ea48,
  46925. 0x161d187,0x05109c2,0x06fff4f,0x021e562,0x1914186,0x0fd7fd0,
  46926. 0x0265a45,0x12abca6,0x11236de,0x196bcc7,0x1baa861,0x16c2797,
  46927. 0x06a2a48,0x1da2753,0x070c9fd,0x185c151,0x0452265 },
  46928. { 0x1430010,0x0f63c92,0x03012b5,0x1fd7a12,0x0ac786f,0x14e9fae,
  46929. 0x1d3fc82,0x0bf4bf3,0x0a3edc6,0x05fa089,0x0fac47f,0x073819e,
  46930. 0x0088248,0x0552db8,0x175b53a,0x1157171,0x1fdb756,0x171138e,
  46931. 0x1d11583,0x1d86e76,0x1296e43,0x130e7ba,0x1e3abe4,0x152db36,
  46932. 0x1ae0e3f,0x1ea8c04,0x1770977,0x16625a5,0x0b77110,0x1c5a35d,
  46933. 0x191ae3d,0x16bd9e3,0x09efc8d,0x1f65503,0x0eb9827,0x03832a5,
  46934. 0x1f4dbde,0x118176a,0x015550f,0x1f23c0f,0x014b02b } },
  46935. /* 219 */
  46936. { { 0x07e5b57,0x0e3b45c,0x155cb1c,0x0fea634,0x0bcc78f,0x0cbee40,
  46937. 0x0fe2fdd,0x0be9ff2,0x1139e17,0x1470136,0x1329b2c,0x0e4f972,
  46938. 0x1c6b83b,0x003cfbf,0x0bf8ec8,0x1a2e05d,0x0decf3b,0x015652a,
  46939. 0x0bc371b,0x082678d,0x035e17c,0x12e67af,0x0fa8799,0x0aa0b8d,
  46940. 0x11a4834,0x1c4d334,0x0398402,0x0c6757a,0x1d03882,0x138360b,
  46941. 0x03259b1,0x03419f2,0x0efffbe,0x0eb263d,0x0f9f42b,0x0c9b08f,
  46942. 0x0ea2aa4,0x0de6fdd,0x1429752,0x0e8598f,0x085e07e },
  46943. { 0x1c25bca,0x1705305,0x13b08ea,0x03c89ec,0x0e8e55f,0x03dbb9b,
  46944. 0x05b62d8,0x013c3cd,0x0d30059,0x14853a3,0x112642a,0x199a597,
  46945. 0x1d072b1,0x034717a,0x03f9b1b,0x11d921a,0x1f053e2,0x0c90762,
  46946. 0x0010330,0x043f69e,0x02c779b,0x09fe625,0x09cdd6f,0x1758fbb,
  46947. 0x1def9e1,0x069fafa,0x04d703e,0x1862baf,0x0cd318d,0x00b8165,
  46948. 0x071c45f,0x1d24dee,0x12823c4,0x179cd37,0x02efb40,0x0671b6b,
  46949. 0x1db6932,0x1a4918b,0x1d0c396,0x13f1a93,0x0096403 } },
  46950. /* 220 */
  46951. { { 0x0999eba,0x1a78b2b,0x0c1485d,0x0f63bcc,0x1d8ee28,0x0593349,
  46952. 0x1dc9b78,0x143b035,0x13f8942,0x1a2349c,0x0f84f0d,0x0c2bd40,
  46953. 0x0fbcf6b,0x0a7139e,0x03030d6,0x0b8ada6,0x056c672,0x127e99d,
  46954. 0x02fa5e8,0x0a695b5,0x0251a57,0x133e115,0x1e6490a,0x018b892,
  46955. 0x1bdb59d,0x1b42728,0x131a909,0x0f9aed9,0x06bf59d,0x0bd66a1,
  46956. 0x0ca4502,0x0cdd37d,0x1404a2c,0x171f4ac,0x1a61725,0x008e71f,
  46957. 0x0ad666d,0x1d9f075,0x1795af2,0x1a4c778,0x0626b0f },
  46958. { 0x1a1ec42,0x0bedd70,0x11411c8,0x1756b59,0x0a6ae7d,0x0998e8d,
  46959. 0x0ac7a19,0x0df6fc3,0x03d3012,0x0229838,0x186146e,0x13c1bdc,
  46960. 0x0428064,0x15344aa,0x01bd28f,0x1ec6510,0x1adcb56,0x1a5df21,
  46961. 0x12bfe53,0x1737b57,0x17be036,0x12de831,0x0365079,0x0de7576,
  46962. 0x19d4468,0x1eb410b,0x12ab5ab,0x090d225,0x1e15341,0x048f7fb,
  46963. 0x05a68ee,0x1d70dfb,0x0c426ce,0x09461c4,0x0a0445e,0x016adcd,
  46964. 0x16399e0,0x1f389ac,0x1ab064c,0x1b342f6,0x009bbdd } },
  46965. /* 221 */
  46966. { { 0x0fd3673,0x1ce0ef2,0x181dd78,0x034cb91,0x1880d9d,0x04e3ff7,
  46967. 0x10771ca,0x0008e4b,0x03529d2,0x1b39af7,0x11ebcd6,0x05da78e,
  46968. 0x15c1f8f,0x08977ef,0x1ce663e,0x13872b9,0x0184985,0x0f6b913,
  46969. 0x19a5e57,0x12745e1,0x12a7237,0x0b4358e,0x029aae3,0x15105c9,
  46970. 0x015de22,0x0bf0064,0x13e76e3,0x1cefadf,0x067547b,0x1d99011,
  46971. 0x170221b,0x093821d,0x02687d4,0x1f6a65b,0x185df20,0x153e387,
  46972. 0x1af366e,0x0aebf82,0x0b4939b,0x171a3df,0x02eaa01 },
  46973. { 0x1357c74,0x1fdb80f,0x1e51791,0x1553c76,0x13085c4,0x02d482c,
  46974. 0x01ccdba,0x1929e13,0x1be0244,0x09c047f,0x159837d,0x1f27476,
  46975. 0x1691ddd,0x19dcaf6,0x1d8ddef,0x041a916,0x1b7bb39,0x1c8dc88,
  46976. 0x1a84f3c,0x1e117f0,0x0e587cc,0x0bf500c,0x14fb63e,0x18aa328,
  46977. 0x0434378,0x0d358f5,0x07834b5,0x1cd5bbd,0x16259a8,0x1247cdc,
  46978. 0x177f0ac,0x1dde2fb,0x0ebceae,0x1ce42cb,0x110d55f,0x11ed296,
  46979. 0x07d5bba,0x068a878,0x061ad23,0x1d36983,0x002d31d } },
  46980. /* 222 */
  46981. { { 0x079499d,0x1cf0f6f,0x0ab69ae,0x11fa1f8,0x16ca8ff,0x1ec9ab7,
  46982. 0x1e3a069,0x04f7d81,0x1e8f063,0x01e8e4f,0x002faef,0x042e766,
  46983. 0x1b805c7,0x009e0c0,0x1082821,0x13a0200,0x07ef0ca,0x14f4d0b,
  46984. 0x0bbb775,0x19213a3,0x0a72076,0x1fc71d4,0x1928665,0x0f6853c,
  46985. 0x1f7a7a7,0x1f49e73,0x1172534,0x1581f7e,0x148407a,0x0a53f36,
  46986. 0x19fcdda,0x1523243,0x16679e2,0x0ddeb7a,0x03cfb87,0x13e47fc,
  46987. 0x0bf9fa9,0x08bab36,0x15d971e,0x1e5c1e9,0x0965860 },
  46988. { 0x1a5f79c,0x03815bf,0x09b79cd,0x0cb5e5a,0x130bd42,0x19f0674,
  46989. 0x02e61b1,0x05a8b7b,0x14ee44a,0x0df3df6,0x122869f,0x00492ad,
  46990. 0x0ec129e,0x1be6fc0,0x17016b1,0x14b36df,0x02b589c,0x1b8535d,
  46991. 0x066096b,0x1080433,0x10b6fc4,0x0a3d11f,0x074a12d,0x141515e,
  46992. 0x010a428,0x16c58ed,0x04acabd,0x03d6366,0x135ee3b,0x021d19c,
  46993. 0x1b3c145,0x11dff4d,0x007eb26,0x132a63d,0x021b598,0x182ddc8,
  46994. 0x0549ee4,0x1de280a,0x02949e9,0x0643f53,0x0650810 } },
  46995. /* 223 */
  46996. { { 0x07ed9b2,0x072305b,0x0f4927c,0x0186db2,0x0cda0fd,0x03af0e0,
  46997. 0x18fa623,0x19376b2,0x1614bc0,0x0bddf49,0x1a1815d,0x100334e,
  46998. 0x049a9b8,0x0476e2a,0x0df8abd,0x0b30b51,0x19eb51a,0x04f3bf6,
  46999. 0x0efc093,0x04a4e9d,0x0636dd0,0x040aa2e,0x1662d8a,0x001b740,
  47000. 0x1aed048,0x11d1cde,0x06078a8,0x1f84027,0x0cb4f27,0x1eae2a8,
  47001. 0x11f719b,0x16a40d1,0x127032f,0x0fd0ad6,0x12ba05a,0x0593417,
  47002. 0x1a7ca8a,0x1037909,0x194bd81,0x08d30c4,0x0982950 },
  47003. { 0x011c128,0x1a30017,0x09f8f8d,0x1a1cdb9,0x00dfae5,0x0a91324,
  47004. 0x05b8b65,0x087c880,0x0880b71,0x12fc479,0x0e2073d,0x11a8a4d,
  47005. 0x1eca3d2,0x0fdc357,0x1167747,0x1f2b1f3,0x0c24c74,0x1aa4430,
  47006. 0x12da7d3,0x1d48793,0x0cecd06,0x17399a7,0x14d0f26,0x0652e26,
  47007. 0x0ccd635,0x0062e61,0x0d7ce9b,0x12bfe80,0x12653ba,0x10e659b,
  47008. 0x0f4b806,0x144a0a4,0x1510fdf,0x13f5918,0x038a988,0x01ddca7,
  47009. 0x0a23cd1,0x0fe4506,0x1d52fab,0x0367cf1,0x04b7e6e } },
  47010. /* 224 */
  47011. { { 0x15f928b,0x083b7ed,0x13b1e72,0x0d6e68f,0x06250bb,0x007620f,
  47012. 0x1de62b0,0x18ea96c,0x09d9619,0x006905d,0x10d0fe4,0x01a0b3c,
  47013. 0x17ed42c,0x028c9ae,0x1ce7a15,0x0039c7b,0x18264f7,0x0131c88,
  47014. 0x07e1eab,0x1e4aa9c,0x1aaace8,0x04b2fc8,0x1f7759e,0x048a73f,
  47015. 0x1163fa3,0x0cacb66,0x112eb3a,0x1902be5,0x0f9ea55,0x061554a,
  47016. 0x1575e32,0x1de49c8,0x0b2aff4,0x0e1353d,0x1024737,0x05e1dac,
  47017. 0x00ca282,0x0521058,0x1d96255,0x18ba652,0x00611c4 },
  47018. { 0x1e81829,0x1000e54,0x0b33c64,0x0011450,0x1ed3332,0x0ef6cde,
  47019. 0x1f7863e,0x00617fa,0x1b78890,0x1c9d606,0x1e97759,0x123a6ae,
  47020. 0x0bbb00d,0x00169e1,0x1e88e9e,0x12029c2,0x08cfb54,0x1ffcafc,
  47021. 0x1c6db81,0x037e978,0x0c8b7cd,0x1011ac4,0x0b8ec92,0x02240ec,
  47022. 0x135b8a4,0x0984da9,0x1b1015b,0x090380b,0x16a1b52,0x0086748,
  47023. 0x1d1571d,0x10a02f3,0x1e03271,0x089045d,0x05decf3,0x002bcd8,
  47024. 0x10cbfe5,0x0d12604,0x0159942,0x0523821,0x0820795 } },
  47025. /* 225 */
  47026. { { 0x07d353e,0x09e7f8e,0x18ed74b,0x1afbc19,0x15e7ecc,0x143b1ae,
  47027. 0x01d7db2,0x07d6962,0x025f9ad,0x1420270,0x12d6bb6,0x1d1240b,
  47028. 0x016b963,0x04f910d,0x17b8360,0x159493c,0x1d9ea41,0x06b2642,
  47029. 0x1110a8d,0x0d89d26,0x15a46a4,0x1f1e7b2,0x0b1bfe5,0x082faf9,
  47030. 0x05c1ee5,0x0263b2b,0x07bafe7,0x1020135,0x1a63886,0x0e9cc46,
  47031. 0x11a56d8,0x1ed68e5,0x002b46a,0x188b8b2,0x05942df,0x063fbca,
  47032. 0x1e0c05e,0x1c7939d,0x1129e53,0x06d5106,0x07487b0 },
  47033. { 0x03e2370,0x072bace,0x1c66a18,0x07f0090,0x19d5819,0x117cd50,
  47034. 0x0fcf29b,0x136741b,0x1614471,0x163f4ac,0x1fb086d,0x18e9bdf,
  47035. 0x1fa9049,0x1fa8675,0x08192c8,0x1bc2b17,0x0c049a1,0x1589411,
  47036. 0x07549fc,0x096fb36,0x0430b65,0x0e87fe8,0x111c216,0x00a88d7,
  47037. 0x14a674f,0x0ca9be3,0x0e8eb76,0x0aa64a3,0x1533b5e,0x0b65f19,
  47038. 0x13928fb,0x04fc833,0x12f44d0,0x0dcbc97,0x1a0a974,0x1e5b09d,
  47039. 0x1b6fa69,0x1b5891e,0x0ef7731,0x18a43f4,0x0834f85 } },
  47040. /* 226 */
  47041. { { 0x0e9b31a,0x1a3e096,0x0edcca4,0x15fc7f6,0x1d88522,0x1fc87e8,
  47042. 0x1ed354b,0x03a979d,0x02b1a08,0x1d8b9c3,0x047c214,0x0374548,
  47043. 0x1a538c1,0x0a0db01,0x056e4f0,0x1ae82f1,0x1aab10b,0x114c9dc,
  47044. 0x0644a61,0x17a08c1,0x0ba5ccb,0x1877505,0x19a7ebe,0x0cc312e,
  47045. 0x0462235,0x12a6a42,0x10d9ffe,0x14c7713,0x1478da4,0x0e8e8e1,
  47046. 0x1df2eb5,0x154c069,0x1339227,0x189c8e2,0x017f986,0x0a1cdae,
  47047. 0x174ff51,0x0a5b307,0x0d53374,0x014a665,0x0639d8b },
  47048. { 0x02217cd,0x118b10b,0x039be90,0x1502385,0x0e0e4a2,0x1b36e01,
  47049. 0x1386085,0x1ded1b3,0x1046a06,0x0931b9c,0x0484054,0x0463bbd,
  47050. 0x1344eea,0x08a14c6,0x01f23c8,0x0afd20c,0x0ba63d9,0x093f939,
  47051. 0x17a32b8,0x1d01994,0x063fe7c,0x11127bd,0x1605baf,0x0ce7c68,
  47052. 0x0e5a789,0x1ea26f6,0x094daea,0x06ead44,0x1f77af1,0x10d771d,
  47053. 0x0f19135,0x0579f31,0x0b2bf6e,0x14b1630,0x07cca7e,0x067616b,
  47054. 0x0bb5002,0x1b4d0d5,0x100b2c1,0x06c18ea,0x0409031 } },
  47055. /* 227 */
  47056. { { 0x070433f,0x1439d0b,0x17f2134,0x0c4a927,0x09394df,0x1e7c4f6,
  47057. 0x0866a03,0x02dd60b,0x0db2976,0x1cf2188,0x18c11b8,0x1b93b3c,
  47058. 0x1e50742,0x0ef4e54,0x06b6320,0x03a1be6,0x194fb7b,0x0c3555f,
  47059. 0x0cf20b4,0x1b44f43,0x0d8436c,0x1a1cb81,0x1ec68bb,0x0102533,
  47060. 0x1fddc46,0x11c1405,0x1748e58,0x0965691,0x1c9353e,0x0179bd9,
  47061. 0x1a4b6cb,0x025f714,0x1b5b317,0x0023a6a,0x08ec206,0x11f370f,
  47062. 0x1e95257,0x0c84c30,0x0af2361,0x1dbe6f4,0x080668e },
  47063. { 0x19a0249,0x0e69ad9,0x1abb8bb,0x0965f15,0x0f230cd,0x11ef82d,
  47064. 0x05791c8,0x1e852b6,0x0e0e937,0x1b34c15,0x12458ae,0x16e5197,
  47065. 0x01019d2,0x07a4ee5,0x144aba7,0x00f68b8,0x1a7630f,0x088da48,
  47066. 0x00e1d3a,0x09e6994,0x143348d,0x132265b,0x107f43a,0x0b66187,
  47067. 0x19ae1f9,0x05609fb,0x17b62d8,0x006c5a9,0x0ad81c4,0x0a7fb0f,
  47068. 0x0a27a0c,0x093187a,0x1600dd4,0x10b8176,0x1067094,0x06bf963,
  47069. 0x1a9c1f3,0x1194fe1,0x1b3a564,0x09037bc,0x0046775 } },
  47070. /* 228 */
  47071. { { 0x1233c96,0x0f2b71c,0x1abfb8f,0x1900e6f,0x068c409,0x0d5e344,
  47072. 0x046f480,0x00b595c,0x12b4862,0x196754d,0x0415b03,0x0fc2de3,
  47073. 0x01e3238,0x12ee152,0x1d4d96a,0x17d0dd4,0x0cc12b4,0x0bb614d,
  47074. 0x158ca53,0x1f956f1,0x1f24a01,0x058655c,0x0076fa2,0x02980a9,
  47075. 0x06e5bf4,0x1d53b32,0x0f2e5ad,0x1c22312,0x04e097f,0x1ad8bb3,
  47076. 0x0a6d927,0x0a7f9eb,0x196422e,0x1fb1a50,0x06f42df,0x0ab2f19,
  47077. 0x1c22989,0x1f59c71,0x1115ad7,0x1f61067,0x0038a49 },
  47078. { 0x1e93257,0x1c0c609,0x106cd78,0x1b4c24e,0x14cebc9,0x1560358,
  47079. 0x04925f2,0x02c9edd,0x13daa11,0x113c719,0x080d2a0,0x0cbc9bc,
  47080. 0x10e7cc5,0x050dd31,0x1f7257c,0x0df7b76,0x1236695,0x140eecf,
  47081. 0x0c4cb75,0x1cc6337,0x1337c63,0x117e120,0x1b88ac0,0x117d638,
  47082. 0x081937e,0x05611c2,0x176324e,0x0763329,0x1b56448,0x1d65535,
  47083. 0x01ed533,0x00df230,0x07cd44e,0x06cf98d,0x06eea3e,0x0c3ba87,
  47084. 0x1f74a8e,0x06153c3,0x1598198,0x0442436,0x04bb76e } },
  47085. /* 229 */
  47086. { { 0x0354817,0x08f4573,0x10e1e85,0x15e0716,0x13d494e,0x0ac4c31,
  47087. 0x11a2216,0x024990d,0x11dcbac,0x10a9c13,0x16b419c,0x1f1981d,
  47088. 0x16f487a,0x128072e,0x0cc147f,0x0feab5a,0x11bd6e4,0x085388d,
  47089. 0x11d1ab5,0x0e134f1,0x135ea68,0x1132017,0x09fc5c9,0x0618260,
  47090. 0x08efafb,0x04be368,0x0701b1d,0x1de3808,0x03e2da9,0x07676e6,
  47091. 0x1cf431d,0x0125c20,0x0c5f96e,0x095ba18,0x0f3caa8,0x041e272,
  47092. 0x0107eb0,0x0c200b1,0x1e62c91,0x0bef6ed,0x08843d2 },
  47093. { 0x1b2a83e,0x080ee76,0x1c91385,0x005771a,0x1cfe8fb,0x12efb15,
  47094. 0x0196764,0x1861204,0x142ab6f,0x038aee7,0x0277f4f,0x00ab41e,
  47095. 0x0a73c05,0x11ac857,0x19d1763,0x0e93c24,0x0d876ff,0x1a9c17a,
  47096. 0x0483198,0x13fddf5,0x11cafc6,0x08cfeb8,0x1785808,0x0eb89ab,
  47097. 0x1c3bd90,0x1f9210c,0x04f7b5a,0x100197a,0x03a1163,0x1075b13,
  47098. 0x0de31fa,0x0fa4c98,0x1bd7958,0x0e4c61a,0x1915c56,0x0aadc45,
  47099. 0x1a7373b,0x1f9516f,0x12525c6,0x073126b,0x00503f9 } },
  47100. /* 230 */
  47101. { { 0x1dad4f6,0x0ee3338,0x086d96b,0x120497d,0x038e488,0x02e9ee9,
  47102. 0x1238bd8,0x113f6ed,0x0b0d96b,0x1eafaef,0x06cb2c4,0x146acc0,
  47103. 0x14e0b5b,0x01f1e92,0x1f52476,0x11d4fc6,0x023240c,0x1744302,
  47104. 0x047266e,0x0305e7d,0x1919374,0x1cd43d6,0x09b0b2b,0x0e9e52a,
  47105. 0x1040af5,0x051a589,0x0651000,0x17379da,0x1f42e75,0x0bdf036,
  47106. 0x0753331,0x097a211,0x0e8ec50,0x1da8011,0x1deb776,0x1618a62,
  47107. 0x1ecfead,0x0698e94,0x1a3e5a4,0x1fc2ecc,0x0735778 },
  47108. { 0x03c1137,0x1771f42,0x0f343e1,0x147e16e,0x1c1c42f,0x19071d1,
  47109. 0x19e762a,0x15c1cea,0x016242f,0x1caf8fa,0x024b91b,0x0238736,
  47110. 0x007b88e,0x0611b56,0x0a500f9,0x005cc2c,0x1412dac,0x133082f,
  47111. 0x18b818c,0x18514f0,0x1c8d74d,0x1979d91,0x08463fe,0x08bff7e,
  47112. 0x0417c07,0x08f08c1,0x113015c,0x136ab40,0x1be4de4,0x0dba677,
  47113. 0x01cb199,0x12f7ee2,0x0c4c01d,0x1833b0e,0x1b6b153,0x1165940,
  47114. 0x1450d0f,0x0cced53,0x00a87f1,0x14c3463,0x052e637 } },
  47115. /* 231 */
  47116. { { 0x1ebc6db,0x18078b5,0x1649205,0x17f2a07,0x0a6b45d,0x0a9c8ca,
  47117. 0x134f174,0x1798e2b,0x1e5ad2a,0x0150e02,0x0d19be5,0x086756f,
  47118. 0x0b36a82,0x1d09c8c,0x104efb6,0x1cd9d74,0x02490f4,0x134c52b,
  47119. 0x0fc7cf2,0x041b4de,0x1ab3bb7,0x0eb1a38,0x0845b50,0x07a6c12,
  47120. 0x1222730,0x14f7006,0x0118ee9,0x1fa9980,0x045fd17,0x0f26b14,
  47121. 0x11eb182,0x1015b93,0x1603b2c,0x17de531,0x126917e,0x177e2df,
  47122. 0x04bc94a,0x003fbfe,0x05a6104,0x09f4e96,0x07c916b },
  47123. { 0x0bac2d4,0x137c8bc,0x01d7040,0x104c035,0x0a2e809,0x19eb204,
  47124. 0x09db801,0x1115a5e,0x0fcc1fb,0x01b0862,0x0ca47d1,0x104594d,
  47125. 0x1c5727b,0x0476307,0x1154cb2,0x1a9160c,0x099ed9a,0x1a8f244,
  47126. 0x150fc40,0x16916be,0x0eeb841,0x1f6ac8e,0x09b32c6,0x19eb517,
  47127. 0x0df0f9d,0x0da7e25,0x02cd1f7,0x14f9404,0x04c5213,0x066165a,
  47128. 0x112a86b,0x00a4f81,0x13b6828,0x1e7a83b,0x1041c08,0x0d546e9,
  47129. 0x0b74c92,0x1e88003,0x141f1cc,0x0deef51,0x01ff391 } },
  47130. /* 232 */
  47131. { { 0x197939d,0x0c7f27c,0x0ecea88,0x16f22b0,0x1d4dfbb,0x1bab059,
  47132. 0x0d76a1f,0x131674f,0x15da92c,0x0e01400,0x19bd2aa,0x155a8cc,
  47133. 0x17e1eb4,0x0a674ee,0x0c5e944,0x060ec5d,0x0a4ef8f,0x17a3533,
  47134. 0x043951b,0x168b8d0,0x04dd900,0x0c25d78,0x1debc89,0x109a85f,
  47135. 0x1c8725c,0x1ef1e60,0x1639320,0x0127e44,0x0d88b23,0x0f208b8,
  47136. 0x1118beb,0x1580edc,0x19612e4,0x08a0df0,0x0d18cb7,0x15e91ae,
  47137. 0x125e34d,0x18fbacc,0x0432706,0x0ac0e57,0x019ed1a },
  47138. { 0x0735473,0x1fe6f36,0x10fa73d,0x0ec0077,0x0ab88e6,0x0ccddc5,
  47139. 0x1f2f3ec,0x17a2430,0x19acccc,0x1b98220,0x195166e,0x1e7961e,
  47140. 0x02214af,0x17c9314,0x1b2068d,0x04170d5,0x1329f9d,0x0554165,
  47141. 0x1dcf324,0x07f21ea,0x17e182f,0x15fb112,0x12bd839,0x08ec5be,
  47142. 0x144bfbd,0x1a9f8c5,0x076e5c1,0x1291625,0x02c18e3,0x1074be1,
  47143. 0x0b71ba4,0x0af7d2f,0x13d6208,0x11bfc9c,0x00b11ad,0x0bd1ae7,
  47144. 0x11fed1d,0x112e65f,0x05667d9,0x1f2d0d0,0x06f31e0 } },
  47145. /* 233 */
  47146. { { 0x0b8f204,0x17f2ac1,0x152b116,0x0da6b16,0x0c0441b,0x0afaf6d,
  47147. 0x19efeb3,0x126e427,0x1139bcd,0x08a6385,0x0f2ec06,0x0b032db,
  47148. 0x01714b4,0x0f69ae9,0x0a5f4d4,0x03e41d2,0x0376a3e,0x0c7b204,
  47149. 0x1cf35c1,0x15153a5,0x1f6d150,0x00ee6ec,0x1ecdba0,0x1eadb05,
  47150. 0x0eb655c,0x110ad2a,0x124aa96,0x0c20a01,0x089f037,0x05711d8,
  47151. 0x1a34434,0x18856cd,0x11b2079,0x146a424,0x18f43bb,0x0a95e35,
  47152. 0x01556f4,0x1f26142,0x09f984d,0x010c7b1,0x0875e33 },
  47153. { 0x16c0acc,0x07eee57,0x1023720,0x0d763cf,0x15ad1e6,0x02c2d6e,
  47154. 0x1eb860a,0x14db8e2,0x0275c7d,0x0e2a1a0,0x0e7856f,0x10a5a4d,
  47155. 0x10f4b4c,0x1502fd2,0x0287efd,0x19664be,0x047817b,0x0e37c0f,
  47156. 0x03fcb87,0x1a8650e,0x17fc2cb,0x0b33e3f,0x0289240,0x10b4d89,
  47157. 0x1acb7b5,0x02be822,0x11199b0,0x1d2e55a,0x17d63d2,0x03e7f36,
  47158. 0x1131d36,0x01c4e82,0x1067d87,0x0c2577b,0x15ea2c9,0x1765942,
  47159. 0x15f0fde,0x0e2dfdb,0x1802525,0x103e70d,0x05abb05 } },
  47160. /* 234 */
  47161. { { 0x0c97f57,0x11695f8,0x031e2f9,0x032c5e5,0x0fe0487,0x1a855d8,
  47162. 0x0919d1e,0x1db8a91,0x144fa09,0x1593701,0x16a5bbd,0x0dc7560,
  47163. 0x02fd44c,0x1873574,0x0c00cb1,0x1133bdb,0x02bd7e4,0x1145ea0,
  47164. 0x0df0470,0x05d2c73,0x171643f,0x0767489,0x03b0ff0,0x1fa1f18,
  47165. 0x18bc902,0x1d63b4d,0x09f2af0,0x1b39675,0x124cc99,0x0449034,
  47166. 0x053a22a,0x084c120,0x11461aa,0x13cf052,0x0a2e58b,0x018fe95,
  47167. 0x0b1b3e8,0x1810854,0x192f13b,0x10037fd,0x0705446 },
  47168. { 0x01901c1,0x1eb8989,0x12abeac,0x0ffd5aa,0x090a262,0x045d11f,
  47169. 0x14a16f0,0x0fcc9ed,0x136ec22,0x0cc980a,0x0646ae3,0x15720d8,
  47170. 0x0c99a16,0x1b24e71,0x0c73d6f,0x075010d,0x15966be,0x02c9033,
  47171. 0x12e8b3c,0x06c4f39,0x1486188,0x03f7fa9,0x0b055ee,0x04475e4,
  47172. 0x098964b,0x12bdfd6,0x002ab9e,0x1a1fa9e,0x018a80c,0x1ca0319,
  47173. 0x13b6b76,0x1bf11e2,0x044bb79,0x16cfe9c,0x0f52dc7,0x0d8367c,
  47174. 0x1620503,0x11a509e,0x029adb1,0x19f70d0,0x06f56ae } },
  47175. /* 235 */
  47176. { { 0x1205c5d,0x0e401ec,0x04a6c07,0x1ace247,0x08955f7,0x0db2b2b,
  47177. 0x0fff676,0x1fc7bd7,0x0d3b1ac,0x0221caf,0x13bbfee,0x1642c12,
  47178. 0x0b04328,0x114c8ff,0x0c7fea0,0x1a0eacc,0x0e6190d,0x086ef33,
  47179. 0x015df01,0x0078abd,0x040775b,0x0fc8b91,0x1b24739,0x176747e,
  47180. 0x08a408e,0x1cb4d14,0x0816284,0x1a6edf1,0x0e06761,0x0a2bcd3,
  47181. 0x023ce96,0x0f6e3a5,0x03029c5,0x0186008,0x10a2d13,0x181087e,
  47182. 0x130e0b9,0x1357fc3,0x112b763,0x0229dac,0x07b6be8 },
  47183. { 0x13aa54e,0x1c7251e,0x0268fb0,0x07b07aa,0x1023394,0x1caaf10,
  47184. 0x0988490,0x089f095,0x1f51d3d,0x088238b,0x0938dca,0x0858fd9,
  47185. 0x1e62d24,0x02fd2ae,0x16948f6,0x1436b18,0x0da851d,0x0637ae6,
  47186. 0x000051a,0x1795504,0x02e0044,0x14700b8,0x1dd4079,0x14159d9,
  47187. 0x19359e6,0x0597840,0x16b03bc,0x07bb4d5,0x164f013,0x16e47ec,
  47188. 0x1625ebb,0x0a61721,0x0dacd0e,0x09175a4,0x15bee10,0x1c98bf5,
  47189. 0x1700a1d,0x02760f6,0x151d08a,0x06bb794,0x086f9a8 } },
  47190. /* 236 */
  47191. { { 0x10cc69f,0x0c82aa2,0x063c387,0x1993dbf,0x10eb14b,0x1f5d00a,
  47192. 0x139dfb9,0x0a63772,0x1998f8e,0x1bd339b,0x1bbbc17,0x09c6362,
  47193. 0x1558838,0x0c2e2f0,0x04a1c8f,0x0a55577,0x145cbd9,0x07f28f1,
  47194. 0x189059d,0x01dc50f,0x02f0c5d,0x178800c,0x1f7051b,0x1eb7c59,
  47195. 0x19e92e7,0x09f07b9,0x1ed95af,0x0035675,0x08e2895,0x16ef28b,
  47196. 0x12ac554,0x171dc20,0x00dfe31,0x0223aca,0x180f10c,0x0685246,
  47197. 0x0460a91,0x03788a6,0x07e1a4c,0x15e076a,0x05bfa9f },
  47198. { 0x07b258e,0x1fa9608,0x0770a88,0x17acc68,0x189e82b,0x1e7f8d4,
  47199. 0x13b6208,0x03ea947,0x0719b49,0x02dbbca,0x0f7ee3d,0x0430486,
  47200. 0x0e898c2,0x0249287,0x0776473,0x0ecaa1f,0x0ae4fa1,0x0a86151,
  47201. 0x10c9fd1,0x1439c85,0x1e41f7a,0x0b2c1d8,0x04e856b,0x17f5b3c,
  47202. 0x0d5a5a1,0x0e6cd50,0x02387ef,0x1639545,0x1f7f879,0x01db48a,
  47203. 0x07abe4a,0x10fd034,0x10e4e0c,0x0694b60,0x0958420,0x1009fb9,
  47204. 0x12755bd,0x064b0b0,0x1bb69ab,0x155051f,0x01b1266 } },
  47205. /* 237 */
  47206. { { 0x14ee49c,0x005003b,0x1f5d3af,0x0596c46,0x176f685,0x1c9c51b,
  47207. 0x112b177,0x17bf80a,0x0b6fbfb,0x19c4764,0x1cbabb0,0x179ae8b,
  47208. 0x1784ac8,0x18f6749,0x1159826,0x1f42753,0x0ac7de8,0x0b2b7db,
  47209. 0x14cae1c,0x1bdae94,0x1f095f8,0x05d5444,0x0ac350a,0x16f5d85,
  47210. 0x07f2810,0x1a621d9,0x1bfbb2c,0x0c84dc3,0x09c2db2,0x0db5cf4,
  47211. 0x041110c,0x0724221,0x0c4bc5d,0x0082c55,0x0da13f6,0x1d24dee,
  47212. 0x071ef60,0x17d348a,0x1e88d14,0x1b6431a,0x033517f },
  47213. { 0x13c4a36,0x19fa32c,0x07baa70,0x106d635,0x0c69d71,0x1bdf765,
  47214. 0x0307509,0x138ab44,0x07e4f17,0x1465127,0x162288f,0x06d3a8d,
  47215. 0x1857373,0x1983817,0x13ac731,0x1aae8e3,0x19735ee,0x1458c26,
  47216. 0x1c133b0,0x0a2f440,0x0a537f4,0x0c6b831,0x1fc4a74,0x1aefc38,
  47217. 0x0571bb1,0x05903d2,0x060d436,0x0e95861,0x1ab8ef7,0x08cfb0f,
  47218. 0x06c9eca,0x16bbb00,0x1c4cc13,0x02c8fd3,0x156c50d,0x07cfcc4,
  47219. 0x1a3592b,0x0c9bdc2,0x1d524d2,0x07a618e,0x031fac6 } },
  47220. /* 238 */
  47221. { { 0x0913fb6,0x0678d82,0x1accbba,0x002ed34,0x1e40135,0x1f30f83,
  47222. 0x0edc5e0,0x1fcf21d,0x1e27f2f,0x12883fc,0x1e26fc7,0x0cffdb5,
  47223. 0x0d124ba,0x12c6f34,0x0480387,0x157dc31,0x0a36df5,0x14b1399,
  47224. 0x12fad2a,0x186f9f5,0x1a7672c,0x0b749e2,0x0c317ea,0x0c67277,
  47225. 0x0317cde,0x0b62615,0x1e0c2cb,0x0fecbcc,0x05b96a9,0x1a820df,
  47226. 0x1b52bf0,0x0e619cc,0x1f40a60,0x06c2785,0x09e64d0,0x112d437,
  47227. 0x07626b0,0x10c12a0,0x12fd4fb,0x1b6f561,0x001db35 },
  47228. { 0x00efee2,0x1de16d6,0x0d15b83,0x1bae3b7,0x0406ebc,0x1b4d5f4,
  47229. 0x178f866,0x045ce57,0x137e018,0x0e5bf30,0x162d312,0x0038228,
  47230. 0x03cbb8c,0x143e2eb,0x02d211d,0x0ceec84,0x1a1454c,0x00c23ef,
  47231. 0x060e746,0x1d223ba,0x1046bed,0x0493c6f,0x06e7727,0x03466d8,
  47232. 0x1d62b88,0x16e14a5,0x064f9de,0x1e12d0f,0x0e3ba77,0x0332a1e,
  47233. 0x1f1eb24,0x0eec9dd,0x08695fd,0x032e78a,0x1c2e6b1,0x03c1841,
  47234. 0x06e2cdb,0x1746945,0x0d0758d,0x119aeaa,0x07b6ba9 } },
  47235. /* 239 */
  47236. { { 0x1881ab4,0x0cf01e0,0x12232c7,0x0b662d1,0x19c25d5,0x11b2670,
  47237. 0x0f51ca0,0x049505a,0x0f161aa,0x0cca1c8,0x0ecb265,0x1801c3d,
  47238. 0x157838b,0x1ef63d3,0x1577f32,0x044151f,0x1c24ff7,0x026e901,
  47239. 0x1bfbfd2,0x02e7661,0x0b355ec,0x198b214,0x067c74a,0x0dd027f,
  47240. 0x1d9e505,0x0f8e035,0x0b02cc6,0x0522e57,0x023b159,0x11c27e9,
  47241. 0x1b5ab83,0x131a123,0x101059e,0x032475e,0x0392995,0x10d662d,
  47242. 0x1375e79,0x08a23f9,0x1142088,0x032e3d6,0x047e810 },
  47243. { 0x08c290d,0x0ea2d5e,0x0ce9c11,0x0b021f6,0x033d135,0x1ddf97d,
  47244. 0x002491b,0x1b2575e,0x1385c7c,0x07f9f8d,0x066172b,0x01d9c2c,
  47245. 0x08c5b15,0x154443a,0x1b829fc,0x1b9918d,0x08e5e88,0x1cec446,
  47246. 0x12e1910,0x0e6be59,0x16f24dd,0x1b9e207,0x130784e,0x1fdad23,
  47247. 0x025fff3,0x0e3fe1d,0x1c95fb9,0x1968762,0x0db1354,0x07c9f99,
  47248. 0x14ea995,0x005bfe5,0x0f58d0a,0x131ca22,0x0622a32,0x0ef1c7e,
  47249. 0x13e8669,0x1236677,0x1a1ece5,0x005c1b9,0x0785b19 } },
  47250. /* 240 */
  47251. { { 0x12f9a20,0x111b0d4,0x103bf33,0x0f3ac8a,0x17bdca8,0x006be2d,
  47252. 0x06a1474,0x04da8e7,0x02e97c9,0x13d646e,0x09aa2c1,0x1ffcf1b,
  47253. 0x092aea3,0x11e28db,0x0a2fd51,0x02834d0,0x0797155,0x03b78e2,
  47254. 0x05df604,0x197dec7,0x0e7af4b,0x04aa0de,0x1d6f125,0x0e0834a,
  47255. 0x14066d1,0x157f00f,0x161dd57,0x0505ab7,0x07ae80d,0x03eeacf,
  47256. 0x1bdb884,0x0705566,0x056e166,0x0eb1a55,0x1bdae74,0x08cbdd1,
  47257. 0x0e4ed84,0x110b056,0x0b09e66,0x0cf6ee2,0x06557c3 },
  47258. { 0x15b6e52,0x181346b,0x1a25586,0x00231a1,0x1081364,0x1758d75,
  47259. 0x0ccc1a8,0x1299fea,0x06d0908,0x1231113,0x1075213,0x044f6bf,
  47260. 0x0dbb351,0x0bd1831,0x197a81d,0x05b8b26,0x17bd66e,0x1a65651,
  47261. 0x0425621,0x1afa477,0x13bf220,0x09c6223,0x0703f4e,0x10fb49f,
  47262. 0x1370a67,0x05c56ff,0x13415fd,0x1e15d79,0x13f33ae,0x1a2608b,
  47263. 0x0d08179,0x124b44d,0x0d1f0a5,0x1ddfedc,0x1d25c8b,0x09526c9,
  47264. 0x0227d28,0x08d73bc,0x02ad322,0x00941c1,0x015c40d } },
  47265. /* 241 */
  47266. { { 0x00e18d1,0x18b4d15,0x1f0a6eb,0x0e98064,0x1971c01,0x0131674,
  47267. 0x0c8fdef,0x0f3b034,0x1818ff3,0x04cedc6,0x0f0cc08,0x0c7a99a,
  47268. 0x13663f6,0x008d02a,0x14c970c,0x148e1de,0x1dcf980,0x04e6b85,
  47269. 0x127b41c,0x08a5a23,0x0e13e64,0x1a5633b,0x0befd0f,0x10b854b,
  47270. 0x0c0a6ae,0x0624bdf,0x011c124,0x1f55caa,0x1e6ba92,0x1d43a48,
  47271. 0x0502ae5,0x155f532,0x055f537,0x132aba0,0x16ecd9c,0x1ff92b5,
  47272. 0x1119d6b,0x11a1dce,0x078dd91,0x1413a68,0x0788e94 },
  47273. { 0x053461a,0x137f2ce,0x1bb414e,0x1c11c76,0x15ec897,0x146c9cb,
  47274. 0x14bcc1d,0x09f51eb,0x0cc213d,0x1eb5ffb,0x0051f26,0x16820b6,
  47275. 0x09590c7,0x1e3dc0b,0x08d8a2d,0x0f1d241,0x06e5bce,0x1e33504,
  47276. 0x17b0763,0x09a5049,0x0ce93dd,0x0260cee,0x0242b3d,0x086b4fd,
  47277. 0x0d875d8,0x0d93319,0x07a98e0,0x1202cf8,0x1cc1285,0x0bcbf86,
  47278. 0x18ec896,0x08df1a8,0x1a612b4,0x17d1cc8,0x15e3057,0x108430b,
  47279. 0x119f678,0x0af61b8,0x1aa4f7d,0x18cf01b,0x091b19c } },
  47280. /* 242 */
  47281. { { 0x15d8b80,0x1384ee5,0x183bafc,0x05f86ac,0x03b9618,0x0f7cb48,
  47282. 0x1664415,0x08570e7,0x1e47c43,0x0f525a6,0x1e219f4,0x0489aa9,
  47283. 0x0fcc4b9,0x1ec6bbf,0x0c68b2b,0x1eac727,0x0e7e8c1,0x1034692,
  47284. 0x065cc15,0x1f576c9,0x174f5f5,0x0802a11,0x00c9231,0x071d227,
  47285. 0x1e2b53f,0x05f61b6,0x0deeda0,0x1a0fd1d,0x1313b5e,0x09ebec7,
  47286. 0x04a5920,0x15fa5a7,0x1b6a069,0x0518d3d,0x1238212,0x0b80db0,
  47287. 0x04f0c32,0x13fd97f,0x10ebda1,0x0680ce6,0x03c2ba8 },
  47288. { 0x13ad63b,0x16bbace,0x0c7ead8,0x0eb3c1d,0x1f9cab9,0x02f08b9,
  47289. 0x0a98ce2,0x13ce066,0x0e20b2f,0x11657e7,0x12a51fc,0x14fc93d,
  47290. 0x0db529b,0x11146c4,0x0550859,0x12ac249,0x1ec3923,0x0407511,
  47291. 0x10dc191,0x120fcfa,0x0e441b8,0x0aab1f2,0x12dfe91,0x14961f4,
  47292. 0x1829eb2,0x1c96654,0x1120181,0x014e414,0x0991ced,0x0d06123,
  47293. 0x1ae3337,0x0691a10,0x1a2325b,0x177099b,0x1427d82,0x1eacdda,
  47294. 0x147f253,0x1870488,0x0ef60f4,0x14b820e,0x01fa627 } },
  47295. /* 243 */
  47296. { { 0x0478fd4,0x1115121,0x0002844,0x02ce164,0x0cf4c6f,0x0ce36f5,
  47297. 0x0c13e0d,0x179ee37,0x17b93cd,0x0c71414,0x16d82d8,0x15c6461,
  47298. 0x0996e1b,0x0b2d9d9,0x1ff4ed2,0x0abbbe2,0x1c6bc70,0x1d2c31c,
  47299. 0x0e05f5f,0x1525da9,0x08a4c3e,0x13691d8,0x0420aca,0x02e021d,
  47300. 0x1228adc,0x0cbc238,0x1883a27,0x0a773c8,0x1f77c97,0x07cb81f,
  47301. 0x1973df9,0x0577cc1,0x03f8245,0x100beb6,0x12f2e03,0x173c865,
  47302. 0x00a45ed,0x052d66e,0x1d0f854,0x00a8f30,0x067b8bd },
  47303. { 0x0797cf7,0x03cda7a,0x180b998,0x15a07fb,0x031c998,0x055778f,
  47304. 0x1d8e953,0x022b546,0x0f76497,0x06cd0ff,0x06c69d9,0x18e75e5,
  47305. 0x137ce0d,0x1db3654,0x186c20f,0x0d4f0cc,0x0fe32fb,0x0dfa6ba,
  47306. 0x1c02958,0x0dde13b,0x115925f,0x1fc18e8,0x0af10e0,0x0d7bc6e,
  47307. 0x0c10c53,0x12db6ae,0x1e20b31,0x0928bf3,0x1a99b8d,0x0789a28,
  47308. 0x09207d2,0x0d75823,0x00161cd,0x125050a,0x13b7c62,0x093b29a,
  47309. 0x0467a82,0x1b18b2d,0x0bb7d94,0x1534993,0x074297a } },
  47310. /* 244 */
  47311. { { 0x01124ba,0x1ac5271,0x0f4b125,0x1150fff,0x19bd819,0x131c544,
  47312. 0x13744f5,0x0ec8bf7,0x015f7bf,0x0322ffc,0x1b55fa5,0x06df89c,
  47313. 0x195fa67,0x09730ed,0x0b991d6,0x128943d,0x00ccbdf,0x03cabae,
  47314. 0x16cc75d,0x02608e4,0x1ae6a3d,0x112655a,0x1e2077c,0x0510fe4,
  47315. 0x1d2991a,0x02cc6df,0x0289ab1,0x07a0eb2,0x061d4a2,0x0c296c3,
  47316. 0x1dcb962,0x1140281,0x1b5c13b,0x1bc151b,0x0678fec,0x001f283,
  47317. 0x1bc14e9,0x15502c8,0x0ec49c8,0x175aab7,0x089aab7 },
  47318. { 0x056bdc7,0x02d4b6b,0x14ee2cd,0x1fc2ed9,0x03bdc8a,0x0b2621a,
  47319. 0x062d8cb,0x083ad2a,0x179b82b,0x079b253,0x033e0bf,0x089dff6,
  47320. 0x1b907b3,0x0880943,0x14320f1,0x121dfe7,0x05934cd,0x074f935,
  47321. 0x1c20ad7,0x0b55e40,0x0165e5f,0x1af673e,0x13adcb1,0x130d9ac,
  47322. 0x10a81be,0x15574ac,0x1ffc54d,0x1dde931,0x063d5ef,0x0121d41,
  47323. 0x0ac1158,0x0a95d0e,0x00be14f,0x03b434a,0x13278c8,0x157dcf7,
  47324. 0x01bc4d7,0x0b513ee,0x0ad1b52,0x12eb281,0x0002dc2 } },
  47325. /* 245 */
  47326. { { 0x09d60c3,0x19c9bdb,0x1d57b94,0x05fd2e4,0x060be55,0x0392d31,
  47327. 0x0de3703,0x185623f,0x0cab2e7,0x0c1613f,0x0c8b2da,0x1bb3dc4,
  47328. 0x174bcee,0x0913827,0x0ac67b4,0x0c2cb2a,0x085854a,0x096fa61,
  47329. 0x0c64921,0x016b7ef,0x152aba4,0x08008cf,0x1f2f2a5,0x15bb0df,
  47330. 0x1d1cbe5,0x160ba33,0x0f6743c,0x17ea6df,0x14ebc99,0x171a5c6,
  47331. 0x05cf0a5,0x00b5026,0x095f8f4,0x1afbb02,0x0359ccc,0x0518b3d,
  47332. 0x0054212,0x09e9927,0x169cc2d,0x06a7877,0x04d5645 },
  47333. { 0x05c0877,0x17c003f,0x1d91cc8,0x0c19534,0x081b43e,0x00938b2,
  47334. 0x13d2e8b,0x184463e,0x1ed3136,0x0acb42b,0x0cc3782,0x064471b,
  47335. 0x1cae826,0x0cc8475,0x0beb502,0x0463cca,0x014af0d,0x085c68c,
  47336. 0x072f0d2,0x018a961,0x1f8e268,0x19a5f9d,0x1f5158b,0x056b2bf,
  47337. 0x1090b09,0x01a14c2,0x117857f,0x0de7394,0x178168e,0x08c8de1,
  47338. 0x01dc05d,0x108b495,0x06944b3,0x0aa0d48,0x1d2a0a8,0x09598da,
  47339. 0x1155c8b,0x04dd59d,0x1b18ab7,0x19cee60,0x01f2f89 } },
  47340. /* 246 */
  47341. { { 0x0ffefdf,0x1f7a0cd,0x15ae094,0x0a99f24,0x05d7ece,0x0272418,
  47342. 0x00bcad1,0x03e6ee0,0x1cba547,0x0c4baaf,0x0f8056c,0x0797ab9,
  47343. 0x09c8848,0x1505c21,0x13df1a5,0x1ec3a4a,0x1d461f3,0x18c4285,
  47344. 0x0891c55,0x0421121,0x0b0d7ba,0x176c977,0x0d6aef0,0x0bbd912,
  47345. 0x0cabe96,0x0257dab,0x12f155a,0x1b446e4,0x1a74929,0x1cb7b53,
  47346. 0x11b62e8,0x05de974,0x0b90db7,0x0d93d7e,0x1f82642,0x1dba469,
  47347. 0x16f4366,0x19e0b23,0x0351ef7,0x0fe2fca,0x009c809 },
  47348. { 0x0050c07,0x058a030,0x0df9a81,0x108751c,0x029e831,0x0af20fe,
  47349. 0x0a6caed,0x0759728,0x02ce60e,0x097f52d,0x160bd3b,0x1fe7b73,
  47350. 0x1adc7b1,0x143e9bf,0x1afb30d,0x0ea7291,0x032ecb0,0x13c8a9f,
  47351. 0x1c1d5a4,0x000a9ea,0x19ba6a6,0x064003a,0x0e1c734,0x1245be2,
  47352. 0x1386f30,0x1be0bd3,0x1a0cd5e,0x1d3f8b3,0x0151864,0x19d49ca,
  47353. 0x024749a,0x1a69b71,0x12a0222,0x06db8c8,0x13d167f,0x0ccce5f,
  47354. 0x04ff303,0x1f9346a,0x185b168,0x1a6d223,0x06f113e } },
  47355. /* 247 */
  47356. { { 0x036f1c9,0x0efac8c,0x01f54aa,0x0a84646,0x1a6519f,0x16942d7,
  47357. 0x11c0577,0x0eb080d,0x0af627f,0x10aa2e5,0x0105f42,0x03dd59c,
  47358. 0x03ae111,0x13089a2,0x0a2f7da,0x19797f6,0x0ab52db,0x06f4f78,
  47359. 0x004f996,0x183036f,0x1225e9d,0x0dcc893,0x02c76af,0x10298b2,
  47360. 0x198e322,0x13f2f82,0x1b64d3b,0x18772cd,0x1ba4bf5,0x076d5cc,
  47361. 0x19d3ae1,0x07836ab,0x0919a34,0x14307d9,0x0d2652a,0x0d535bb,
  47362. 0x16811ff,0x19106ff,0x00f886d,0x077a343,0x06636a2 },
  47363. { 0x0587283,0x0ad1690,0x11777d7,0x13de0ff,0x0b3822c,0x1b6f1c0,
  47364. 0x0f5543b,0x03a2f0d,0x125d167,0x11e7c83,0x0c77bc5,0x0e3e39b,
  47365. 0x0a74bf9,0x04217e2,0x127a0c0,0x0a9eeae,0x1c727f8,0x187176d,
  47366. 0x13892b2,0x0f77b57,0x108dbb2,0x1602df6,0x106c673,0x1920979,
  47367. 0x0123ef7,0x16dd56d,0x0f62660,0x04853e3,0x16e6320,0x10b732f,
  47368. 0x0c9274d,0x1dcb3fa,0x1789fa8,0x194fad1,0x0eebfa7,0x002c174,
  47369. 0x0f5378a,0x169db0d,0x09be03c,0x0ece785,0x07aeecc } },
  47370. /* 248 */
  47371. { { 0x043b0db,0x03abe6e,0x12b7ce9,0x0b30233,0x1d8a4e8,0x0b60ab1,
  47372. 0x16fd918,0x12ff012,0x04f533e,0x11503de,0x1f16b4f,0x06ce739,
  47373. 0x0ca9824,0x06b4029,0x09ae8eb,0x1d8cc31,0x1908a1c,0x0deb072,
  47374. 0x0ac6da5,0x10834a0,0x195bae3,0x090c850,0x061b7fc,0x063fb37,
  47375. 0x0beacad,0x1bd96f9,0x1331ca3,0x1b12644,0x10a9927,0x139c067,
  47376. 0x1ab0e3a,0x0b0d489,0x0439a80,0x0f81e54,0x1fc0585,0x0bdbcfe,
  47377. 0x07a1f88,0x124c841,0x1d91520,0x00d6f14,0x028ec40 },
  47378. { 0x0fe0009,0x1061751,0x13a7860,0x05e270e,0x011ba5d,0x126da97,
  47379. 0x0915314,0x0532ea4,0x07fede5,0x0a3ba13,0x1403513,0x0335364,
  47380. 0x0b01d34,0x0c34922,0x0229248,0x1c3739c,0x023dd1b,0x05d0b48,
  47381. 0x0a8c078,0x187ca86,0x0788242,0x1d38483,0x06d5bde,0x0951989,
  47382. 0x12a09c7,0x01cf856,0x075dbe5,0x139a308,0x1fb60e9,0x1f05b10,
  47383. 0x0d3b76b,0x17872ec,0x16bee54,0x1854202,0x0183fdf,0x1e8ca7f,
  47384. 0x0011c0a,0x0a43b79,0x0970daf,0x18e192a,0x0134f4c } },
  47385. /* 249 */
  47386. { { 0x138dff4,0x0d1f674,0x068e588,0x1690d4f,0x1d101a7,0x0a829bb,
  47387. 0x1be5f7a,0x1b7e589,0x1e65d87,0x18c204c,0x0e33ebc,0x1ff66e7,
  47388. 0x0eb89c7,0x142148b,0x0ea9417,0x14ec8d1,0x1094ebe,0x1d3c87e,
  47389. 0x164a24a,0x1beda9c,0x1741679,0x0e7e7f6,0x0808ccc,0x101fe42,
  47390. 0x0efd298,0x08085fa,0x1740d11,0x194f1bb,0x0858c87,0x0f659a1,
  47391. 0x1e8b2c2,0x04aea90,0x05eb6dc,0x18248cf,0x0857af2,0x02a0ceb,
  47392. 0x1381d47,0x0973a7b,0x15bd027,0x05307a7,0x06ea378 },
  47393. { 0x05cc40a,0x004a5a7,0x17ef197,0x1435e6f,0x1a2e3f6,0x0137223,
  47394. 0x1fa77e4,0x0a7dece,0x193880f,0x1c3c64a,0x112aa6d,0x160efec,
  47395. 0x1c4aa30,0x1790461,0x1145a0c,0x0cc7741,0x1ae658d,0x03e013b,
  47396. 0x187644c,0x1678715,0x1ea4ef0,0x13b4ae1,0x0c0bcde,0x018bc1a,
  47397. 0x0c1c56a,0x1cff002,0x10832f3,0x1fa92b8,0x0a0e7c9,0x0dceab4,
  47398. 0x151c1b5,0x0b250c8,0x1225dff,0x1384e45,0x1196366,0x10a4fa8,
  47399. 0x07c08d6,0x02ac6d4,0x1c1f51f,0x1cd769d,0x0606ee6 } },
  47400. /* 250 */
  47401. { { 0x1c621f6,0x0cfe3ab,0x15200b6,0x02ffd07,0x092e40c,0x18ccd81,
  47402. 0x11e867b,0x0cc37bf,0x0e62c76,0x0502081,0x0e1d4de,0x06e1cce,
  47403. 0x0f16cda,0x0f1d32d,0x0065d34,0x1c41379,0x048f78f,0x10cba10,
  47404. 0x1d66071,0x140b157,0x102dc83,0x1a4e44b,0x1c9ac90,0x034cf15,
  47405. 0x12f1e9d,0x114cc45,0x03fca6b,0x0e57f36,0x1cf5ec4,0x11cc0eb,
  47406. 0x162850f,0x164d1bb,0x09d7e45,0x07fbb4e,0x09557f1,0x062cd9b,
  47407. 0x04aa767,0x0266f85,0x01c1d81,0x1efd229,0x049dba6 },
  47408. { 0x158e37a,0x03fd953,0x1d98839,0x0e5b1d5,0x0f6b31d,0x0e11085,
  47409. 0x157e5be,0x0566a55,0x190efc3,0x049fb93,0x12c9900,0x13b883c,
  47410. 0x15435c9,0x02d8abc,0x0a1e380,0x06aeb7f,0x0a40e67,0x0cce290,
  47411. 0x1fba9d6,0x104b290,0x148bca6,0x00f8951,0x00a7dee,0x1459c6a,
  47412. 0x1cc182a,0x162d2a3,0x0fab578,0x023b0e9,0x082cdfa,0x1a4daab,
  47413. 0x19a6bc0,0x1177d1c,0x06ebfea,0x1ca55fc,0x1e0bd54,0x1e7b570,
  47414. 0x0bc8eb8,0x05fbcbf,0x19e3116,0x14936fb,0x04890a7 } },
  47415. /* 251 */
  47416. { { 0x1a995f6,0x0cb44c6,0x1bbf5ca,0x0fd8c2a,0x139eaae,0x15416ae,
  47417. 0x01030d5,0x1fcd2b2,0x1c135bc,0x1023590,0x0571e2c,0x16c81eb,
  47418. 0x00ea720,0x13e2fda,0x0093beb,0x077f805,0x14c0edb,0x14bec7e,
  47419. 0x07c93af,0x00520af,0x06b912f,0x078c3f5,0x05bf11f,0x13ab846,
  47420. 0x1fd2778,0x166610c,0x122498f,0x0674d6d,0x0d30a62,0x1a5945b,
  47421. 0x00208d8,0x193666d,0x0352e25,0x1ba2b65,0x1b29031,0x172711a,
  47422. 0x1c92065,0x12ad859,0x069dbe3,0x0960487,0x05c1747 },
  47423. { 0x0accab5,0x073e145,0x016f622,0x0d559da,0x1802783,0x1607b28,
  47424. 0x01df733,0x10430b7,0x0125c28,0x1e56e0e,0x1715324,0x0814cff,
  47425. 0x1345df5,0x013c451,0x0f21b8b,0x1f4589e,0x069e3a0,0x19f43a2,
  47426. 0x1ce60f3,0x1b548e4,0x18a5c59,0x05a54b6,0x0c18f12,0x1cb122a,
  47427. 0x12bcfc2,0x061e1c6,0x1e1390a,0x01cf170,0x04fd539,0x1496786,
  47428. 0x0164028,0x1283cc0,0x1f92db7,0x09d0e5b,0x0905b29,0x0f2acf2,
  47429. 0x11ab0fa,0x1b798ed,0x10230d7,0x168f6b0,0x05d675e } },
  47430. /* 252 */
  47431. { { 0x10c6025,0x10d3bc3,0x1f2abbb,0x0f2345b,0x1c4a23b,0x15b2627,
  47432. 0x18310e1,0x162f61c,0x1e5ae72,0x0ead8be,0x1e884b5,0x11593dd,
  47433. 0x166dfc8,0x0a01c5c,0x1abbefb,0x05d989f,0x1568e2d,0x184cd61,
  47434. 0x04abc81,0x1d4c240,0x1218548,0x0dc4e18,0x13ffb67,0x1cce662,
  47435. 0x091c4e0,0x0700e0f,0x1ebe0c0,0x01376c9,0x13c3be0,0x080e33b,
  47436. 0x1ea1e01,0x1810433,0x0cd6ede,0x1837ff0,0x181fe06,0x1ef80ab,
  47437. 0x0080b36,0x1b1fce7,0x1b28e0a,0x15e153f,0x002fccb },
  47438. { 0x07cac61,0x0ea68da,0x04b2664,0x0f570dc,0x0e9d168,0x0a78211,
  47439. 0x157b0ae,0x1cb18d0,0x148e648,0x120028c,0x06b15f2,0x1f65df1,
  47440. 0x0d9ba91,0x0df3c96,0x1064818,0x03c2a9e,0x1cbbd0f,0x0c16910,
  47441. 0x1111006,0x1d6277f,0x0fdc062,0x194cbc8,0x1cea5f0,0x0cf4c97,
  47442. 0x16d9460,0x1ad273c,0x01b48dd,0x08dba60,0x1f0f23c,0x026af6b,
  47443. 0x15e19cb,0x0769ec7,0x01851dc,0x139f941,0x1833498,0x1ea1475,
  47444. 0x0ac60f6,0x072c7e7,0x1551600,0x0ac2708,0x056f1e4 } },
  47445. /* 253 */
  47446. { { 0x0c24f3b,0x059fb19,0x1f98073,0x1e0db02,0x19eb1c7,0x1133bb4,
  47447. 0x102edaa,0x1c11b8c,0x00845d5,0x01c57ff,0x09e6a1e,0x1963f03,
  47448. 0x10f34fe,0x1f340cd,0x0b8a0b4,0x14970d4,0x1ce8237,0x0e25cbb,
  47449. 0x1d8d90e,0x0d67b70,0x04970f4,0x004bcb8,0x09197d5,0x1237c87,
  47450. 0x0876287,0x1636bf0,0x10d0663,0x004416d,0x1d94bb0,0x031b849,
  47451. 0x0c95ece,0x053ad21,0x0012e16,0x168d242,0x16d482a,0x0605d93,
  47452. 0x05dc34e,0x1717e34,0x033e2bf,0x06c4aa0,0x0911d19 },
  47453. { 0x1e5af5b,0x0deac7a,0x0a9c4ec,0x16f6d44,0x07ca263,0x17956e5,
  47454. 0x1b137ce,0x17b56d7,0x1a04420,0x1328f2c,0x0db0445,0x1676974,
  47455. 0x103b448,0x1fa1218,0x18aff37,0x0d97678,0x0a5f1a9,0x06f0ae2,
  47456. 0x1347e60,0x15b143c,0x1a3abe0,0x071b339,0x004af45,0x02559bb,
  47457. 0x03af692,0x0e72018,0x115d825,0x1edb573,0x1f5ca58,0x0415083,
  47458. 0x0c1f7c6,0x1112d47,0x103e63c,0x1d9f85c,0x1513618,0x1dea090,
  47459. 0x009887d,0x080cdce,0x0e19579,0x1fd41ea,0x02be744 } },
  47460. /* 254 */
  47461. { { 0x150f324,0x0682fad,0x1e88153,0x083d478,0x19b1eb2,0x1c735bd,
  47462. 0x02971ff,0x104950b,0x0ec0408,0x01c817f,0x0ea6f76,0x0929a19,
  47463. 0x1e72b26,0x194e4f0,0x05dbe42,0x1b703a0,0x102ceba,0x002ea75,
  47464. 0x1cae2ff,0x080b626,0x1190874,0x00bcf56,0x17104a2,0x056919a,
  47465. 0x03dd3ec,0x019ea25,0x1cfd354,0x089334e,0x0c3a098,0x1c66ab2,
  47466. 0x0eecdec,0x1e85d00,0x0e99497,0x08c5940,0x1e82e3d,0x0980f68,
  47467. 0x1568fde,0x0871e29,0x039eb1c,0x05f9d5a,0x0735f54 },
  47468. { 0x0380039,0x0d0b89c,0x07232aa,0x0fee9a3,0x0dfafe1,0x1e0d45d,
  47469. 0x0e4fb32,0x00b25a8,0x1fe0297,0x02edf9c,0x1a6cd8f,0x0b57261,
  47470. 0x0a4552b,0x157ea4a,0x198c0c8,0x15886fd,0x0d73f02,0x041354d,
  47471. 0x04d58a6,0x0a6ac53,0x1b3998c,0x03b9a15,0x0321a7e,0x1f36f34,
  47472. 0x10020e4,0x0d4eba8,0x134d1e2,0x06c3a34,0x0856376,0x0add67d,
  47473. 0x193c37b,0x111580f,0x07ee73f,0x18e5ea0,0x00fc27b,0x1bf58fa,
  47474. 0x0d475ba,0x0b4be5a,0x0e67897,0x13a297a,0x01e984c } },
  47475. /* 255 */
  47476. { { 0x050c817,0x082b0a4,0x04b71db,0x1269130,0x108a5b1,0x0c65df5,
  47477. 0x1455179,0x0b4e4e7,0x04be61e,0x0805afd,0x1ae3862,0x0d23af5,
  47478. 0x0baa088,0x09ad1ea,0x1999abf,0x0fa7bcc,0x19957ec,0x01c5160,
  47479. 0x1a35bd7,0x091d1ec,0x1746a06,0x163d6e0,0x07e7f24,0x060cb86,
  47480. 0x116c084,0x13491d0,0x01879ab,0x0c6e144,0x047e733,0x1b9b155,
  47481. 0x01189b0,0x1bdfedb,0x00c25f2,0x1696a2a,0x093336f,0x0530090,
  47482. 0x039a949,0x0dfe700,0x0b8052d,0x0aced28,0x06c474a },
  47483. { 0x188e3a1,0x1cd20be,0x10a8eba,0x118908e,0x105d3c8,0x1308988,
  47484. 0x1a344ff,0x117cb3b,0x11a869e,0x047adb5,0x1764285,0x18b354e,
  47485. 0x137a8ab,0x110a300,0x0326f1d,0x099b25e,0x147c382,0x121fd53,
  47486. 0x09742e4,0x0c7430d,0x0ebc817,0x1e4de5d,0x0ef0d06,0x08ba3bb,
  47487. 0x13160f7,0x0fa70c0,0x16dd739,0x0a79ca5,0x0de4c2a,0x13366a8,
  47488. 0x1b457ab,0x0ebaeca,0x0d8996c,0x12a952f,0x1c47132,0x09c9fea,
  47489. 0x1c5305b,0x0f4c2d1,0x08b3885,0x0a9f437,0x06b2589 } },
  47490. };
  47491. /* Multiply the base point of P1024 by the scalar and return the result.
  47492. * If map is true then convert result to affine coordinates.
  47493. *
  47494. * Stripe implementation.
  47495. * Pre-generated: 2^0, 2^128, ...
  47496. * Pre-generated: products of all combinations of above.
  47497. * 8 doubles and adds (with qz=1)
  47498. *
  47499. * r Resulting point.
  47500. * k Scalar to multiply by.
  47501. * map Indicates whether to convert result to affine.
  47502. * ct Constant time required.
  47503. * heap Heap to use for allocation.
  47504. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  47505. */
  47506. static int sp_1024_ecc_mulmod_base_42(sp_point_1024* r, const sp_digit* k,
  47507. int map, int ct, void* heap)
  47508. {
  47509. return sp_1024_ecc_mulmod_stripe_42(r, &p1024_base, p1024_table,
  47510. k, map, ct, heap);
  47511. }
  47512. #endif
  47513. /* Multiply the base point of P1024 by the scalar and return the result.
  47514. * If map is true then convert result to affine coordinates.
  47515. *
  47516. * km Scalar to multiply by.
  47517. * r Resulting point.
  47518. * map Indicates whether to convert result to affine.
  47519. * heap Heap to use for allocation.
  47520. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  47521. */
  47522. int sp_ecc_mulmod_base_1024(const mp_int* km, ecc_point* r, int map, void* heap)
  47523. {
  47524. #ifdef WOLFSSL_SP_SMALL_STACK
  47525. sp_point_1024* point = NULL;
  47526. sp_digit* k = NULL;
  47527. #else
  47528. sp_point_1024 point[1];
  47529. sp_digit k[42];
  47530. #endif
  47531. int err = MP_OKAY;
  47532. #ifdef WOLFSSL_SP_SMALL_STACK
  47533. point = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), heap,
  47534. DYNAMIC_TYPE_ECC);
  47535. if (point == NULL)
  47536. err = MEMORY_E;
  47537. if (err == MP_OKAY) {
  47538. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 42, heap,
  47539. DYNAMIC_TYPE_ECC);
  47540. if (k == NULL)
  47541. err = MEMORY_E;
  47542. }
  47543. #endif
  47544. if (err == MP_OKAY) {
  47545. sp_1024_from_mp(k, 42, km);
  47546. err = sp_1024_ecc_mulmod_base_42(point, k, map, 1, heap);
  47547. }
  47548. if (err == MP_OKAY) {
  47549. err = sp_1024_point_to_ecc_point_42(point, r);
  47550. }
  47551. #ifdef WOLFSSL_SP_SMALL_STACK
  47552. if (k != NULL)
  47553. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  47554. if (point != NULL)
  47555. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  47556. #endif
  47557. return err;
  47558. }
  47559. /* Multiply the base point of P1024 by the scalar, add point a and return
  47560. * the result. If map is true then convert result to affine coordinates.
  47561. *
  47562. * km Scalar to multiply by.
  47563. * am Point to add to scalar multiply result.
  47564. * inMont Point to add is in montgomery form.
  47565. * r Resulting point.
  47566. * map Indicates whether to convert result to affine.
  47567. * heap Heap to use for allocation.
  47568. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  47569. */
  47570. int sp_ecc_mulmod_base_add_1024(const mp_int* km, const ecc_point* am,
  47571. int inMont, ecc_point* r, int map, void* heap)
  47572. {
  47573. #ifdef WOLFSSL_SP_SMALL_STACK
  47574. sp_point_1024* point = NULL;
  47575. sp_digit* k = NULL;
  47576. #else
  47577. sp_point_1024 point[2];
  47578. sp_digit k[42 + 42 * 2 * 37];
  47579. #endif
  47580. sp_point_1024* addP = NULL;
  47581. sp_digit* tmp = NULL;
  47582. int err = MP_OKAY;
  47583. #ifdef WOLFSSL_SP_SMALL_STACK
  47584. point = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) * 2, heap,
  47585. DYNAMIC_TYPE_ECC);
  47586. if (point == NULL)
  47587. err = MEMORY_E;
  47588. if (err == MP_OKAY) {
  47589. k = (sp_digit*)XMALLOC(
  47590. sizeof(sp_digit) * (42 + 42 * 2 * 37),
  47591. heap, DYNAMIC_TYPE_ECC);
  47592. if (k == NULL)
  47593. err = MEMORY_E;
  47594. }
  47595. #endif
  47596. if (err == MP_OKAY) {
  47597. addP = point + 1;
  47598. tmp = k + 42;
  47599. sp_1024_from_mp(k, 42, km);
  47600. sp_1024_point_from_ecc_point_42(addP, am);
  47601. }
  47602. if ((err == MP_OKAY) && (!inMont)) {
  47603. err = sp_1024_mod_mul_norm_42(addP->x, addP->x, p1024_mod);
  47604. }
  47605. if ((err == MP_OKAY) && (!inMont)) {
  47606. err = sp_1024_mod_mul_norm_42(addP->y, addP->y, p1024_mod);
  47607. }
  47608. if ((err == MP_OKAY) && (!inMont)) {
  47609. err = sp_1024_mod_mul_norm_42(addP->z, addP->z, p1024_mod);
  47610. }
  47611. if (err == MP_OKAY) {
  47612. err = sp_1024_ecc_mulmod_base_42(point, k, 0, 0, heap);
  47613. }
  47614. if (err == MP_OKAY) {
  47615. sp_1024_proj_point_add_42(point, point, addP, tmp);
  47616. if (map) {
  47617. sp_1024_map_42(point, point, tmp);
  47618. }
  47619. err = sp_1024_point_to_ecc_point_42(point, r);
  47620. }
  47621. #ifdef WOLFSSL_SP_SMALL_STACK
  47622. if (k != NULL)
  47623. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  47624. if (point)
  47625. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  47626. #endif
  47627. return err;
  47628. }
  47629. #ifndef WOLFSSL_SP_SMALL
  47630. /* Generate a pre-computation table for the point.
  47631. *
  47632. * gm Point to generate table for.
  47633. * table Buffer to hold pre-computed points table.
  47634. * len Length of table.
  47635. * heap Heap to use for allocation.
  47636. * returns BAD_FUNC_ARG when gm or len is NULL, LENGTH_ONLY_E when table is
  47637. * NULL and length is returned, BUFFER_E if length is too small and 0 otherwise.
  47638. */
  47639. int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len,
  47640. void* heap)
  47641. {
  47642. #ifdef WOLFSSL_SP_SMALL_STACK
  47643. sp_point_1024* point = NULL;
  47644. sp_digit* t = NULL;
  47645. #else
  47646. sp_point_1024 point[1];
  47647. sp_digit t[38 * 2 * 42];
  47648. #endif
  47649. int err = MP_OKAY;
  47650. if ((gm == NULL) || (len == NULL)) {
  47651. err = BAD_FUNC_ARG;
  47652. }
  47653. if ((err == MP_OKAY) && (table == NULL)) {
  47654. *len = sizeof(sp_table_entry_1024) * 256;
  47655. err = LENGTH_ONLY_E;
  47656. }
  47657. if ((err == MP_OKAY) && (*len < (int)(sizeof(sp_table_entry_1024) * 256))) {
  47658. err = BUFFER_E;
  47659. }
  47660. #ifdef WOLFSSL_SP_SMALL_STACK
  47661. if (err == MP_OKAY) {
  47662. point = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), heap,
  47663. DYNAMIC_TYPE_ECC);
  47664. if (point == NULL)
  47665. err = MEMORY_E;
  47666. }
  47667. if (err == MP_OKAY) {
  47668. t = (sp_digit*)XMALLOC(sizeof(sp_digit) * 38 * 2 * 42, heap,
  47669. DYNAMIC_TYPE_ECC);
  47670. if (t == NULL)
  47671. err = MEMORY_E;
  47672. }
  47673. #endif
  47674. if (err == MP_OKAY) {
  47675. sp_1024_point_from_ecc_point_42(point, gm);
  47676. err = sp_1024_gen_stripe_table_42(point,
  47677. (sp_table_entry_1024*)table, t, heap);
  47678. }
  47679. if (err == 0) {
  47680. *len = sizeof(sp_table_entry_1024) * 256;
  47681. }
  47682. #ifdef WOLFSSL_SP_SMALL_STACK
  47683. if (t != NULL)
  47684. XFREE(t, heap, DYNAMIC_TYPE_ECC);
  47685. if (point != NULL)
  47686. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  47687. #endif
  47688. return err;
  47689. }
  47690. #else
  47691. /* Generate a pre-computation table for the point.
  47692. *
  47693. * gm Point to generate table for.
  47694. * table Buffer to hold pre-computed points table.
  47695. * len Length of table.
  47696. * heap Heap to use for allocation.
  47697. * returns BAD_FUNC_ARG when gm or len is NULL, LENGTH_ONLY_E when table is
  47698. * NULL and length is returned, BUFFER_E if length is too small and 0 otherwise.
  47699. */
  47700. int sp_ecc_gen_table_1024(const ecc_point* gm, byte* table, word32* len,
  47701. void* heap)
  47702. {
  47703. int err = 0;
  47704. if ((gm == NULL) || (len == NULL)) {
  47705. err = BAD_FUNC_ARG;
  47706. }
  47707. if ((err == 0) && (table == NULL)) {
  47708. *len = 0;
  47709. err = LENGTH_ONLY_E;
  47710. }
  47711. if ((err == 0) && (*len != 0)) {
  47712. err = BUFFER_E;
  47713. }
  47714. if (err == 0) {
  47715. *len = 0;
  47716. }
  47717. (void)heap;
  47718. return err;
  47719. }
  47720. #endif
  47721. /* Multiply the point by the scalar and return the result.
  47722. * If map is true then convert result to affine coordinates.
  47723. *
  47724. * km Scalar to multiply by.
  47725. * gm Point to multiply.
  47726. * table Pre-computed points.
  47727. * r Resulting point.
  47728. * map Indicates whether to convert result to affine.
  47729. * heap Heap to use for allocation.
  47730. * returns MEMORY_E when memory allocation fails and MP_OKAY on success.
  47731. */
  47732. int sp_ecc_mulmod_table_1024(const mp_int* km, const ecc_point* gm, byte* table,
  47733. ecc_point* r, int map, void* heap)
  47734. {
  47735. #ifdef WOLFSSL_SP_SMALL_STACK
  47736. sp_point_1024* point = NULL;
  47737. sp_digit* k = NULL;
  47738. #else
  47739. sp_point_1024 point[1];
  47740. sp_digit k[42];
  47741. #endif
  47742. int err = MP_OKAY;
  47743. #ifdef WOLFSSL_SP_SMALL_STACK
  47744. point = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), heap,
  47745. DYNAMIC_TYPE_ECC);
  47746. if (point == NULL) {
  47747. err = MEMORY_E;
  47748. }
  47749. if (err == MP_OKAY) {
  47750. k = (sp_digit*)XMALLOC(sizeof(sp_digit) * 42, heap, DYNAMIC_TYPE_ECC);
  47751. if (k == NULL)
  47752. err = MEMORY_E;
  47753. }
  47754. #endif
  47755. if (err == MP_OKAY) {
  47756. sp_1024_from_mp(k, 42, km);
  47757. sp_1024_point_from_ecc_point_42(point, gm);
  47758. #ifndef WOLFSSL_SP_SMALL
  47759. err = sp_1024_ecc_mulmod_stripe_42(point, point,
  47760. (const sp_table_entry_1024*)table, k, map, 0, heap);
  47761. #else
  47762. (void)table;
  47763. err = sp_1024_ecc_mulmod_42(point, point, k, map, 0, heap);
  47764. #endif
  47765. }
  47766. if (err == MP_OKAY) {
  47767. err = sp_1024_point_to_ecc_point_42(point, r);
  47768. }
  47769. #ifdef WOLFSSL_SP_SMALL_STACK
  47770. if (k != NULL)
  47771. XFREE(k, heap, DYNAMIC_TYPE_ECC);
  47772. if (point != NULL)
  47773. XFREE(point, heap, DYNAMIC_TYPE_ECC);
  47774. #endif
  47775. return err;
  47776. }
  47777. /* Multiply p* in projective coordinates by q*.
  47778. *
  47779. * r.x = p.x - (p.y * q.y)
  47780. * r.y = (p.x * q.y) + p.y
  47781. *
  47782. * px [in,out] A single precision integer - X ordinate of number to multiply.
  47783. * py [in,out] A single precision integer - Y ordinate of number to multiply.
  47784. * q [in] A single precision integer - multiplier.
  47785. * t [in] Two single precision integers - temps.
  47786. */
  47787. static void sp_1024_proj_mul_qx1_42(sp_digit* px, sp_digit* py,
  47788. const sp_digit* q, sp_digit* t)
  47789. {
  47790. sp_digit* t1 = t;
  47791. sp_digit* t2 = t + 2 * 42;
  47792. /* t1 = p.x * q.y */
  47793. sp_1024_mont_mul_42(t1, px, q, p1024_mod, p1024_mp_mod);
  47794. /* t2 = p.y * q.y */
  47795. sp_1024_mont_mul_42(t2, py, q, p1024_mod, p1024_mp_mod);
  47796. /* r.x = p.x - (p.y * q.y) */
  47797. sp_1024_mont_sub_42(px, px, t2, p1024_mod);
  47798. /* r.y = (p.x * q.y) + p.y */
  47799. sp_1024_mont_add_42(py, t1, py, p1024_mod);
  47800. }
  47801. /* Square p* in projective coordinates.
  47802. *
  47803. * px' = (p.x + p.y) * (p.x - p.y) = p.x^2 - p.y^2
  47804. * py' = 2 * p.x * p.y
  47805. *
  47806. * px [in,out] A single precision integer - X ordinate of number to square.
  47807. * py [in,out] A single precision integer - Y ordinate of number to square.
  47808. * t [in] Two single precision integers - temps.
  47809. */
  47810. static void sp_1024_proj_sqr_42(sp_digit* px, sp_digit* py, sp_digit* t)
  47811. {
  47812. sp_digit* t1 = t;
  47813. sp_digit* t2 = t + 2 * 42;
  47814. /* t1 = p.x + p.y */
  47815. sp_1024_mont_add_42(t1, px, py, p1024_mod);
  47816. /* t2 = p.x - p.y */
  47817. sp_1024_mont_sub_42(t2, px, py, p1024_mod);
  47818. /* r.y = p.x * p.y */
  47819. sp_1024_mont_mul_42(py, px, py, p1024_mod, p1024_mp_mod);
  47820. /* r.x = (p.x + p.y) * (p.x - p.y) */
  47821. sp_1024_mont_mul_42(px, t1, t2, p1024_mod, p1024_mp_mod);
  47822. /* r.y = (p.x * p.y) * 2 */
  47823. sp_1024_mont_dbl_42(py, py, p1024_mod);
  47824. }
  47825. #ifdef WOLFSSL_SP_SMALL
  47826. /* Perform the modular exponentiation in Fp* for SAKKE.
  47827. *
  47828. * Simple square and multiply when expontent bit is one algorithm.
  47829. * Square and multiply performed in Fp*.
  47830. *
  47831. * base [in] Base. MP integer.
  47832. * exp [in] Exponent. MP integer.
  47833. * res [out] Result. MP integer.
  47834. * returns 0 on success and MEMORY_E if memory allocation fails.
  47835. */
  47836. int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
  47837. {
  47838. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  47839. defined(WOLFSSL_SP_SMALL_STACK)
  47840. sp_digit* td;
  47841. sp_digit* t;
  47842. sp_digit* tx;
  47843. sp_digit* ty;
  47844. sp_digit* b;
  47845. sp_digit* e;
  47846. #else
  47847. sp_digit t[36 * 2 * 42];
  47848. sp_digit tx[2 * 42];
  47849. sp_digit ty[2 * 42];
  47850. sp_digit b[2 * 42];
  47851. sp_digit e[2 * 42];
  47852. #endif
  47853. sp_digit* r;
  47854. int err = MP_OKAY;
  47855. int bits;
  47856. int i;
  47857. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  47858. defined(WOLFSSL_SP_SMALL_STACK)
  47859. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 40 * 42 * 2, NULL,
  47860. DYNAMIC_TYPE_TMP_BUFFER);
  47861. if (td == NULL) {
  47862. err = MEMORY_E;
  47863. }
  47864. #endif
  47865. if (err == MP_OKAY) {
  47866. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  47867. defined(WOLFSSL_SP_SMALL_STACK)
  47868. t = td;
  47869. tx = td + 36 * 42 * 2;
  47870. ty = td + 37 * 42 * 2;
  47871. b = td + 38 * 42 * 2;
  47872. e = td + 39 * 42 * 2;
  47873. #endif
  47874. r = ty;
  47875. bits = mp_count_bits(exp);
  47876. sp_1024_from_mp(b, 42, base);
  47877. sp_1024_from_mp(e, 42, exp);
  47878. XMEMCPY(tx, p1024_norm_mod, sizeof(sp_digit) * 42);
  47879. sp_1024_mul_42(b, b, p1024_norm_mod);
  47880. err = sp_1024_mod_42(b, b, p1024_mod);
  47881. }
  47882. if (err == MP_OKAY) {
  47883. XMEMCPY(ty, b, sizeof(sp_digit) * 42);
  47884. for (i = bits - 2; i >= 0; i--) {
  47885. sp_1024_proj_sqr_42(tx, ty, t);
  47886. if ((e[i / 25] >> (i % 25)) & 1) {
  47887. sp_1024_proj_mul_qx1_42(tx, ty, b, t);
  47888. }
  47889. }
  47890. }
  47891. if (err == MP_OKAY) {
  47892. sp_1024_mont_inv_42(tx, tx, t);
  47893. XMEMSET(tx + 42, 0, sizeof(sp_digit) * 42);
  47894. sp_1024_mont_reduce_42(tx, p1024_mod, p1024_mp_mod);
  47895. XMEMSET(ty + 42, 0, sizeof(sp_digit) * 42);
  47896. sp_1024_mont_reduce_42(ty, p1024_mod, p1024_mp_mod);
  47897. sp_1024_mul_42(r, tx, ty);
  47898. err = sp_1024_mod_42(r, r, p1024_mod);
  47899. }
  47900. if (err == MP_OKAY) {
  47901. err = sp_1024_to_mp(r, res);
  47902. }
  47903. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  47904. defined(WOLFSSL_SP_SMALL_STACK)
  47905. if (td != NULL) {
  47906. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  47907. }
  47908. #endif
  47909. return err;
  47910. }
  47911. #else
  47912. /* Pre-computed table for exponentiating g.
  47913. * Striping: 8 points at a distance of (128 combined for
  47914. * a total of 256 points.
  47915. */
  47916. static const sp_digit sp_1024_g_table[256][42] = {
  47917. { 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47918. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47919. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47920. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47921. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47922. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000,
  47923. 0x0000000, 0x0000000, 0x0000000, 0x0000000, 0x0000000 },
  47924. { 0x15c1685, 0x1236919, 0x09605c2, 0x03c200f, 0x0ac9e97, 0x052539f,
  47925. 0x1cf7d0f, 0x0ea81d1, 0x1826424, 0x1237c0a, 0x15db449, 0x176966c,
  47926. 0x1b3af49, 0x195f8d7, 0x078b451, 0x0a3cdb1, 0x02c2fd1, 0x013df44,
  47927. 0x1e21c5f, 0x1db90b1, 0x0c6fadd, 0x1f8b563, 0x15b6166, 0x11d5cb1,
  47928. 0x01a1b2d, 0x186873a, 0x018707c, 0x1f5ef40, 0x07e0966, 0x084d4db,
  47929. 0x1f59b6f, 0x0fa769e, 0x1f11c06, 0x1e4c710, 0x080b1c9, 0x02c2a57,
  47930. 0x086cb22, 0x0ac448f, 0x0ebd2bf, 0x0d4d7a7, 0x059e93c },
  47931. { 0x1dd4594, 0x0e9b7b8, 0x079b953, 0x1e015de, 0x1bc9cc9, 0x0fb2985,
  47932. 0x0913a86, 0x0513d4b, 0x13f5209, 0x0c4554c, 0x1050621, 0x12991eb,
  47933. 0x1a97537, 0x0089ccf, 0x02f5e4b, 0x0d56a23, 0x0fdf5cb, 0x15cde9d,
  47934. 0x1b2e594, 0x1a39645, 0x1813813, 0x13a01c4, 0x1f51589, 0x1908639,
  47935. 0x1119b4a, 0x15b28fb, 0x0428603, 0x1b3ed52, 0x1bfa2ed, 0x168bcfb,
  47936. 0x1644e51, 0x0a153a1, 0x0f18631, 0x1b9e98b, 0x0835be0, 0x12be338,
  47937. 0x1b6a52b, 0x02d6354, 0x0b80efa, 0x0f6e9ec, 0x063ef18 },
  47938. { 0x16f45e7, 0x1b5bf80, 0x0be1f0d, 0x0e57d90, 0x1c1bdb5, 0x014db00,
  47939. 0x1dd0739, 0x03ae725, 0x0c7afd8, 0x1edf851, 0x04262db, 0x163ee48,
  47940. 0x0fbda41, 0x1db07c6, 0x101d1d2, 0x1789ab6, 0x141b330, 0x1499f06,
  47941. 0x0cfe8ef, 0x105060e, 0x0cd1ae1, 0x0d87ae3, 0x083b4a6, 0x130c191,
  47942. 0x1354e3f, 0x020bff9, 0x1855567, 0x026c130, 0x1f85cbb, 0x1b1e094,
  47943. 0x0faac32, 0x08ed0bf, 0x02ecc49, 0x0cb19b4, 0x1b0bac6, 0x14a0bd1,
  47944. 0x1dac2cd, 0x0e63ca6, 0x1688e43, 0x039e325, 0x04fe679 },
  47945. { 0x1e8733c, 0x011ea82, 0x1f06529, 0x0a3aae2, 0x0c845e6, 0x10d9916,
  47946. 0x1fa23a5, 0x19846f8, 0x0db4181, 0x02238e3, 0x0f5c843, 0x0bc4e27,
  47947. 0x0900c87, 0x1960bd8, 0x1f7a7b6, 0x1d5ed3b, 0x1e5e88c, 0x1218536,
  47948. 0x0e073a9, 0x0f4c34f, 0x18d5aaa, 0x13119fc, 0x1a94b40, 0x0d13535,
  47949. 0x0fdd060, 0x155daaf, 0x1972b12, 0x019f4f9, 0x1507613, 0x188a474,
  47950. 0x14be936, 0x09d343c, 0x09570c4, 0x000b818, 0x1d84681, 0x0431843,
  47951. 0x1e78d9d, 0x0e8fff5, 0x0ca5d55, 0x030ac3b, 0x004482a },
  47952. { 0x1d486d8, 0x0c56139, 0x079f9dd, 0x0cc39b8, 0x0169f94, 0x0455a7c,
  47953. 0x067f086, 0x060e479, 0x0f33736, 0x072a781, 0x1089828, 0x1c4b7b1,
  47954. 0x00560be, 0x0298de3, 0x1f0c1f1, 0x1fd6a51, 0x11a7e44, 0x1eb790f,
  47955. 0x1c4a34d, 0x089338a, 0x0a45c8e, 0x1f6bd97, 0x058ec14, 0x147a445,
  47956. 0x07a0432, 0x1342061, 0x14d5165, 0x16a30a9, 0x1557e95, 0x124feb9,
  47957. 0x1e99b86, 0x10d240e, 0x1267fd9, 0x0138106, 0x034f9cd, 0x09f426a,
  47958. 0x08ccdb4, 0x0e1f92b, 0x1e27c6a, 0x1f1bdb7, 0x0833a0f },
  47959. { 0x1376b76, 0x00ce3d5, 0x0332a31, 0x064fa1e, 0x1b7294f, 0x0628a69,
  47960. 0x0e78aa4, 0x14dcad7, 0x0a62575, 0x18dd28f, 0x102a224, 0x00f6131,
  47961. 0x0a56fee, 0x1a60b51, 0x0f96bba, 0x04c1609, 0x10be6eb, 0x072899a,
  47962. 0x075709c, 0x1db5ad4, 0x0dd1339, 0x0cf4edd, 0x1cd9bb5, 0x1a0dd81,
  47963. 0x1be882d, 0x1eda109, 0x032c461, 0x05ac739, 0x01058a2, 0x0af0ec5,
  47964. 0x1c47fb2, 0x1456e89, 0x1f73ea6, 0x02e0601, 0x146bd3c, 0x00e83fa,
  47965. 0x05f811a, 0x16fcad4, 0x0597cb8, 0x1c7d649, 0x0692b3c },
  47966. { 0x0a127b4, 0x165b969, 0x05bc339, 0x0b1f250, 0x06a46ea, 0x11bb0b3,
  47967. 0x1d18d1e, 0x1dc87d9, 0x1e0ab96, 0x11ecd00, 0x16fa305, 0x18db65d,
  47968. 0x05c8145, 0x06f2733, 0x109b2b9, 0x0a5f25e, 0x14074e2, 0x08ba685,
  47969. 0x14abe0c, 0x0481aef, 0x093654c, 0x0b9eb29, 0x1607e8e, 0x13a8d2a,
  47970. 0x1491ca0, 0x01e02dc, 0x0d51499, 0x189d0a6, 0x1283278, 0x0198ea0,
  47971. 0x094cb59, 0x0e06c3e, 0x0479038, 0x184f932, 0x06c627b, 0x00ee832,
  47972. 0x01de5fe, 0x078557c, 0x10b5b03, 0x015e800, 0x0333e43 },
  47973. { 0x126d3b7, 0x026f267, 0x06f977c, 0x0d6a7ef, 0x17a7730, 0x045b322,
  47974. 0x0f17c60, 0x0c14802, 0x0850373, 0x1948f52, 0x1840dfb, 0x1afa160,
  47975. 0x1b1ffc9, 0x12e489d, 0x1413765, 0x10b0fb3, 0x1aff13b, 0x0ca451b,
  47976. 0x18fb9d5, 0x086907f, 0x1386b54, 0x1a02318, 0x0ff0879, 0x1bd6b18,
  47977. 0x104e5cd, 0x0a959d0, 0x0995cb3, 0x09fc30c, 0x0aa4089, 0x18d08ad,
  47978. 0x18bae69, 0x08b3d48, 0x0dc6fe5, 0x18151c5, 0x05d52ba, 0x037631a,
  47979. 0x0f7791d, 0x093b1b1, 0x15c22b8, 0x03bad77, 0x010e8b3 },
  47980. { 0x0d9f1af, 0x181f29f, 0x059ae1f, 0x0eaccec, 0x03ad247, 0x070adc0,
  47981. 0x158c1d3, 0x0b671b9, 0x026b1e8, 0x03bf158, 0x0670546, 0x1a2e35f,
  47982. 0x1ab1654, 0x09c12a3, 0x00ba792, 0x0bdeb2f, 0x07c26d5, 0x036e3fe,
  47983. 0x1efad53, 0x11f2ba5, 0x0357903, 0x1f01b60, 0x1f96437, 0x1b87eff,
  47984. 0x16eae4f, 0x14467e5, 0x13cd786, 0x163f78a, 0x0a5568c, 0x0ed96d0,
  47985. 0x15cf238, 0x0b6deaa, 0x087393f, 0x005034d, 0x0ccb9eb, 0x1670c8d,
  47986. 0x0a8495a, 0x130e419, 0x112f3f4, 0x09819b9, 0x0648552 },
  47987. { 0x0a6ff2a, 0x1d9f162, 0x0a286af, 0x146b4c8, 0x0aa03fb, 0x17fba11,
  47988. 0x09fc226, 0x1271084, 0x0ba5dbd, 0x19bc41d, 0x060b2c8, 0x15d3a54,
  47989. 0x0538186, 0x04d00f8, 0x1c1d935, 0x03cf573, 0x1eb917b, 0x1c9208f,
  47990. 0x1c32ed6, 0x163206a, 0x1e7c700, 0x0adc8a5, 0x1754607, 0x102305a,
  47991. 0x0443719, 0x0cb89ae, 0x115d2e6, 0x04eb1a4, 0x0d28b23, 0x147ab19,
  47992. 0x0269942, 0x1f4707e, 0x0078bac, 0x19ec012, 0x1830028, 0x12ca8d4,
  47993. 0x0df8b44, 0x030e3d1, 0x158f290, 0x1e5e468, 0x01f76f3 },
  47994. { 0x0c436b0, 0x160a1a2, 0x01ea6a8, 0x0c3ed39, 0x1907055, 0x16d96fb,
  47995. 0x045ed7d, 0x1046be6, 0x1ed56ba, 0x0bb0fa0, 0x0be9221, 0x0c9efa1,
  47996. 0x1ef8314, 0x1d6e738, 0x07ca454, 0x0e91153, 0x093116b, 0x1593dfb,
  47997. 0x0ee510e, 0x14b5193, 0x1de8a98, 0x131772f, 0x1fe1e00, 0x025596e,
  47998. 0x193dd18, 0x0491d37, 0x137212f, 0x1f25499, 0x14995aa, 0x1157f8e,
  47999. 0x074f095, 0x009db13, 0x19fc33c, 0x1529c7e, 0x0a513b4, 0x0d80519,
  48000. 0x049ea72, 0x19b3dd8, 0x0381743, 0x1f67a21, 0x004924f },
  48001. { 0x073562f, 0x0471ee3, 0x1230195, 0x0bc5d5c, 0x13b3302, 0x0e34bbe,
  48002. 0x14cad78, 0x0f7cc3f, 0x06ebe55, 0x1271032, 0x1b86390, 0x038083a,
  48003. 0x1b76739, 0x0a6bf4a, 0x03aee38, 0x0371897, 0x1d42099, 0x1a5745b,
  48004. 0x004a434, 0x01becdc, 0x1f4ef8a, 0x11c92f2, 0x125f892, 0x0104e55,
  48005. 0x1b2cb15, 0x130bcd3, 0x18941c9, 0x08160e5, 0x02fa49b, 0x10c1483,
  48006. 0x13b6b67, 0x1e78a77, 0x180a784, 0x013ccc3, 0x0dda7c5, 0x0cb1505,
  48007. 0x0146842, 0x06c24e6, 0x0b8d423, 0x0138701, 0x04dfce8 },
  48008. { 0x127b780, 0x14e596a, 0x0375141, 0x0b2ef26, 0x152da01, 0x1e8131e,
  48009. 0x1802f89, 0x0562198, 0x0bb2d1b, 0x0081613, 0x0b7cf0d, 0x0c46aa9,
  48010. 0x074c652, 0x02f87fa, 0x0244e09, 0x0dcf9ad, 0x0c5ca91, 0x141fd46,
  48011. 0x0572362, 0x01e273a, 0x16b31e1, 0x1740ee2, 0x1c5cf70, 0x09db375,
  48012. 0x0cb045c, 0x1143fe7, 0x011f404, 0x00ffafb, 0x1a532f3, 0x18a9cf9,
  48013. 0x0889295, 0x1c42a78, 0x1e9e81d, 0x052042c, 0x057790a, 0x078ac4b,
  48014. 0x1339bd2, 0x1ed7fc4, 0x1a00b71, 0x0117140, 0x00d0759 },
  48015. { 0x0085f2a, 0x17953ef, 0x0b961c2, 0x1f7d336, 0x08fcd24, 0x05209dc,
  48016. 0x1498567, 0x0a31181, 0x08559f8, 0x1815172, 0x0b68347, 0x0043ec4,
  48017. 0x1583b96, 0x16e51b0, 0x0170bd5, 0x18d04b8, 0x11c7910, 0x100a467,
  48018. 0x1c9a56f, 0x1e512c4, 0x0ef6392, 0x1ad46b2, 0x020f42e, 0x1f978a5,
  48019. 0x122441c, 0x1f2f786, 0x1149845, 0x0bb5f9d, 0x0928e9f, 0x095cf82,
  48020. 0x0aada18, 0x0727e5c, 0x03f744d, 0x008a894, 0x1fb5c03, 0x1df7dda,
  48021. 0x04360df, 0x06f10ad, 0x14d6bcb, 0x0385e10, 0x024fa96 },
  48022. { 0x16df7f6, 0x1ed9fb0, 0x0c981d9, 0x11f7b20, 0x043057d, 0x016aa23,
  48023. 0x0aa41ba, 0x1b62e9b, 0x1689643, 0x14279a2, 0x0681808, 0x03bf991,
  48024. 0x1218b19, 0x0b613e8, 0x0d1abd3, 0x0a28b75, 0x086c989, 0x12d2bfa,
  48025. 0x1250be7, 0x0429d39, 0x0158c03, 0x07a0ca8, 0x09cf872, 0x15a8756,
  48026. 0x1759f39, 0x0b9c675, 0x1f943b8, 0x1c3716f, 0x0d7d4e5, 0x18fe47a,
  48027. 0x1cfd8d6, 0x0eaac07, 0x0ff77e3, 0x17d3047, 0x0745dd4, 0x02403ec,
  48028. 0x0a6fb6e, 0x0bd01ea, 0x0045253, 0x07bf89e, 0x0371cc2 },
  48029. { 0x090c351, 0x188aeed, 0x1018a26, 0x1e6c9b3, 0x0d196eb, 0x08598db,
  48030. 0x0480bd9, 0x05eef51, 0x06f5764, 0x01460b2, 0x00049f3, 0x1c6c102,
  48031. 0x1bdc4f7, 0x0e26403, 0x0db3423, 0x081e510, 0x156e002, 0x1894078,
  48032. 0x072ce54, 0x14daf13, 0x00383f9, 0x099d401, 0x1029253, 0x0fa68e8,
  48033. 0x17e91e8, 0x12522b4, 0x1c9b778, 0x01b2fa0, 0x00c30e7, 0x12c6bb2,
  48034. 0x1181bda, 0x0b74dcd, 0x1c2c0e8, 0x009f401, 0x09ebc6f, 0x1e661ed,
  48035. 0x09f4d78, 0x101727e, 0x1edfcf9, 0x1401901, 0x092b6bc },
  48036. { 0x100822e, 0x0ae41af, 0x1c48b8f, 0x057162d, 0x0e82571, 0x1851980,
  48037. 0x0a7124a, 0x0a90386, 0x1a7cc19, 0x1a71956, 0x0504fda, 0x19dc376,
  48038. 0x070bee9, 0x0549651, 0x1edeea9, 0x122a7db, 0x0faea3b, 0x0e6a395,
  48039. 0x03c303e, 0x013cfc0, 0x1b70e8f, 0x192e6f5, 0x0938761, 0x136c76d,
  48040. 0x1ae084a, 0x1b2ff15, 0x00ff563, 0x0802837, 0x162759f, 0x0f6d51d,
  48041. 0x0235fb1, 0x0f21c61, 0x0af6e67, 0x1bf18cd, 0x00c07c9, 0x1842b5b,
  48042. 0x0f33871, 0x0da5cc6, 0x1e2779f, 0x1929e05, 0x071ff62 },
  48043. { 0x04a84d9, 0x0388115, 0x079aa93, 0x1abd78e, 0x02ee4ac, 0x06b2bc7,
  48044. 0x0a297c7, 0x14a7623, 0x1fff120, 0x1faf7cf, 0x1940ce0, 0x11c213c,
  48045. 0x00a4c59, 0x050220c, 0x1a7e643, 0x05183c3, 0x146f598, 0x1c5c196,
  48046. 0x0ebd4da, 0x1e51406, 0x168a753, 0x18db6a7, 0x04bb712, 0x199a3e1,
  48047. 0x0692a72, 0x01976ef, 0x1748899, 0x07541ef, 0x12661cd, 0x1b1f51e,
  48048. 0x168e36e, 0x1fb86fb, 0x1e19fc6, 0x1b5a678, 0x0d4213b, 0x12d8316,
  48049. 0x1f1bba6, 0x141ff4e, 0x009cf9a, 0x1cebf2b, 0x040fd47 },
  48050. { 0x07140a4, 0x05ba313, 0x0bed6e2, 0x1dd56de, 0x0dbbfc1, 0x0312a43,
  48051. 0x12239a6, 0x185bb3d, 0x12eb6ef, 0x0df75d0, 0x03fe21a, 0x0295159,
  48052. 0x10cfc22, 0x1ad10ca, 0x15725ba, 0x1f6d32b, 0x0054171, 0x1c99c4e,
  48053. 0x0d1a0cd, 0x0ba8a43, 0x025c2d8, 0x042089a, 0x0535a28, 0x0d842e8,
  48054. 0x00139ec, 0x026f296, 0x1fdcc02, 0x019e172, 0x178aa32, 0x15130fa,
  48055. 0x10c6b05, 0x1f36d5c, 0x0b9fab3, 0x0534a8c, 0x0447615, 0x0cd1b04,
  48056. 0x1ffbe28, 0x19a6cc6, 0x0ce302c, 0x0afcc72, 0x05b1c11 },
  48057. { 0x0b6bb8f, 0x0d558b9, 0x0b0a43b, 0x0405f92, 0x0dc64ed, 0x14a639c,
  48058. 0x08f17f9, 0x1c9e857, 0x1cb54dc, 0x0b6e32f, 0x108370c, 0x0d46c64,
  48059. 0x14cb2d6, 0x02b6e7c, 0x19c1b9c, 0x0593a2d, 0x164a4f3, 0x01404e3,
  48060. 0x09bb72a, 0x11b061d, 0x1f57ab1, 0x1340e32, 0x13f46b3, 0x1425820,
  48061. 0x1651c7d, 0x1240fc8, 0x1b1de46, 0x15877ac, 0x1e67a30, 0x0e7a3c2,
  48062. 0x046dab4, 0x1b41fab, 0x0d3fc44, 0x031a272, 0x0005b87, 0x079c2c9,
  48063. 0x13e50ab, 0x0f4e5c1, 0x1bbd213, 0x0754ead, 0x0963ab8 },
  48064. { 0x14ea5a3, 0x1a3ec6f, 0x17fa512, 0x0ab9fc8, 0x1656881, 0x1e1ab24,
  48065. 0x1f56228, 0x02ba2dc, 0x0e7c99e, 0x072ad9f, 0x01c6f21, 0x009beaa,
  48066. 0x0e3fee2, 0x0202bee, 0x001bca4, 0x0aae0e2, 0x10dbba7, 0x07f461c,
  48067. 0x0c66b6b, 0x0b796c6, 0x1fd8364, 0x183e105, 0x00627a2, 0x0fb2af1,
  48068. 0x109697d, 0x11dc72a, 0x06e67d3, 0x06fa264, 0x0cfb6a0, 0x1290d30,
  48069. 0x168046c, 0x106e705, 0x0594aaa, 0x0ee03b3, 0x07f60f0, 0x0991372,
  48070. 0x076b988, 0x015c4c8, 0x11561ae, 0x1f97c8b, 0x0443480 },
  48071. { 0x114221a, 0x1ffda48, 0x09ebe3f, 0x1c7d0af, 0x0aec4f2, 0x12a3c3a,
  48072. 0x143903e, 0x0a485c5, 0x1d6f961, 0x19f3598, 0x1a6ddfb, 0x0a6ff7f,
  48073. 0x0ab2296, 0x1da1d43, 0x0a743cb, 0x0558d85, 0x0ed2457, 0x1920942,
  48074. 0x1c86e9e, 0x0d122fc, 0x078da38, 0x00608bd, 0x16fbdf0, 0x02c0b59,
  48075. 0x09071d3, 0x1749c0a, 0x18196a3, 0x05b5b53, 0x02be82c, 0x1c6c622,
  48076. 0x16356c4, 0x1edae56, 0x16c224b, 0x01f36cd, 0x173e3ac, 0x0373a6a,
  48077. 0x0170037, 0x168f585, 0x09faead, 0x1119ff5, 0x097118a },
  48078. { 0x1ecb5d8, 0x02cd166, 0x019afe7, 0x175274d, 0x0083c81, 0x1ba7dfc,
  48079. 0x1760411, 0x16849c1, 0x0a02070, 0x1bcd1e5, 0x1ede079, 0x1f761f7,
  48080. 0x049d352, 0x1f7950e, 0x0c36080, 0x1ca0351, 0x17b14b3, 0x15c2c31,
  48081. 0x0a20bfc, 0x0e14931, 0x0fa55ba, 0x019d837, 0x089cc02, 0x05fdc55,
  48082. 0x002f410, 0x1d2d216, 0x0628088, 0x09cec53, 0x03fc72e, 0x1d1342e,
  48083. 0x19f6e8a, 0x1fca5d5, 0x14fe763, 0x1a2fb2a, 0x01689c3, 0x18616a8,
  48084. 0x0573387, 0x150bbd5, 0x1ea0b55, 0x11a96e3, 0x017c077 },
  48085. { 0x135e37b, 0x0ff8e93, 0x15c839b, 0x0ccadd8, 0x09884e5, 0x1dd4bc6,
  48086. 0x0b2767a, 0x18945eb, 0x0ba09f3, 0x07d228c, 0x010ddd0, 0x02efeb6,
  48087. 0x0a8c3fa, 0x0b3d176, 0x0877b36, 0x17a8143, 0x0700528, 0x13b45e5,
  48088. 0x01a4712, 0x092a563, 0x1fd5f22, 0x02f436a, 0x05b84b1, 0x10b34d4,
  48089. 0x1915737, 0x1073d06, 0x0683ff3, 0x047e861, 0x0cc9a37, 0x1bcdd4b,
  48090. 0x0e16a36, 0x035a474, 0x1d12ae0, 0x1aec236, 0x0e878af, 0x0d3ffd8,
  48091. 0x0452ed6, 0x074270d, 0x1931b5b, 0x190ae3f, 0x01219d5 },
  48092. { 0x02969eb, 0x1533f93, 0x1dcd0fa, 0x1a5e07c, 0x1a3ab39, 0x1d84849,
  48093. 0x1f9455e, 0x0e9cc24, 0x18d1502, 0x1c15876, 0x02f6f43, 0x15b1cb0,
  48094. 0x0bffffc, 0x14ba1f3, 0x14f41d6, 0x023aca3, 0x1b18bac, 0x00a425e,
  48095. 0x0c930e2, 0x1b3321d, 0x07c695c, 0x083fd63, 0x085a987, 0x09cd70e,
  48096. 0x0f762a0, 0x0642184, 0x072e95f, 0x10cbbac, 0x14a07a2, 0x1586e91,
  48097. 0x1e4f0a5, 0x0740f27, 0x0f92839, 0x14f673b, 0x187c2f8, 0x04e16af,
  48098. 0x1e626f4, 0x0a5417b, 0x1c8c04c, 0x165acaf, 0x02c8d7a },
  48099. { 0x025e4d6, 0x1ac4904, 0x0d119f3, 0x0addf07, 0x1f51eaa, 0x080846e,
  48100. 0x197604c, 0x07ec7cc, 0x18dd096, 0x14fc4fa, 0x190da88, 0x09bb3be,
  48101. 0x078c4b1, 0x0a2f5dd, 0x16b91a7, 0x1e70333, 0x1775a4d, 0x188c555,
  48102. 0x078dffa, 0x12f17a5, 0x17efda8, 0x1556516, 0x1a73b56, 0x0fad514,
  48103. 0x0d05dc6, 0x11a364c, 0x15dfe12, 0x08e97e1, 0x0cd59a7, 0x059776c,
  48104. 0x1ef510a, 0x1a3a731, 0x0fd1cd5, 0x10588d8, 0x0f6e528, 0x08b2c02,
  48105. 0x1b404c4, 0x15b82d0, 0x165625b, 0x0ee9613, 0x02299d2 },
  48106. { 0x04397e6, 0x06ac6e3, 0x0c796e7, 0x1d7edba, 0x0c198f1, 0x0f8ed95,
  48107. 0x16384fa, 0x118b0cd, 0x18fcdc6, 0x02d7143, 0x1007f50, 0x019bca7,
  48108. 0x16a4b28, 0x008edaf, 0x058fcb5, 0x1f141b9, 0x189bec4, 0x1f6aea8,
  48109. 0x05bba62, 0x1fa27b2, 0x148e336, 0x198216f, 0x1a496c6, 0x1c00e9c,
  48110. 0x16291ac, 0x14a867a, 0x0094c5f, 0x11a7169, 0x1c446be, 0x0e95c10,
  48111. 0x0d31eb4, 0x1e16cb2, 0x1c44135, 0x106a838, 0x0dbd4b2, 0x0d2e36e,
  48112. 0x07b46c2, 0x0ffd2b9, 0x1863abe, 0x0f2326c, 0x021ac67 },
  48113. { 0x17fbcd2, 0x1071f96, 0x1062ad0, 0x072f7bf, 0x1272247, 0x1aea5a0,
  48114. 0x0cfe137, 0x1a69240, 0x03807b7, 0x1e6a11b, 0x10d895b, 0x1613667,
  48115. 0x14dfc19, 0x1079140, 0x15bcdd6, 0x0337027, 0x059037c, 0x0384bc5,
  48116. 0x1fc9ee7, 0x13132e1, 0x03894f3, 0x02b0ad2, 0x1f03869, 0x0c05ee9,
  48117. 0x1496a3e, 0x10e7fd1, 0x06c9872, 0x07e3886, 0x0164cdc, 0x08edf70,
  48118. 0x07d8488, 0x1cfef7d, 0x0463ee4, 0x170dd98, 0x19e24b0, 0x0c02bef,
  48119. 0x04483a5, 0x1ec46b1, 0x1676198, 0x1ce1cc5, 0x00e8ec1 },
  48120. { 0x00878dd, 0x06614c5, 0x1c6aa23, 0x1acc800, 0x19ac175, 0x0b9b0bc,
  48121. 0x1208294, 0x02b2068, 0x0dd58a3, 0x0b6811f, 0x088684c, 0x17a911a,
  48122. 0x0330785, 0x0ace247, 0x12cf79e, 0x14ee36e, 0x1824c67, 0x1a17701,
  48123. 0x02e4514, 0x1ed9bbc, 0x1e9159e, 0x144d91b, 0x1e0c2b8, 0x0bb064a,
  48124. 0x07a4c49, 0x13370c2, 0x1b41dcd, 0x0f6242f, 0x14a3256, 0x1643514,
  48125. 0x0996064, 0x10c9b06, 0x0aa0f56, 0x09f2dbb, 0x144bd2c, 0x1bc5457,
  48126. 0x1b6b73f, 0x0860e00, 0x0d8d761, 0x0beba20, 0x0653a79 },
  48127. { 0x0dcb199, 0x144c2a8, 0x0d833f8, 0x1cff405, 0x135b8e5, 0x1b01e85,
  48128. 0x15f0f25, 0x16b794f, 0x127f131, 0x0729446, 0x04b54ac, 0x09bdc56,
  48129. 0x073aa70, 0x0edb92e, 0x01ac760, 0x16227c4, 0x19ac5d1, 0x1858941,
  48130. 0x0d175d8, 0x12e197b, 0x1e8e14f, 0x1f59092, 0x1265fe4, 0x0fb544d,
  48131. 0x1739cee, 0x074deba, 0x1c7fbc8, 0x0dd97a7, 0x0a42b14, 0x108a3e3,
  48132. 0x147e652, 0x04ff61f, 0x089eb4f, 0x06d25e9, 0x14c6690, 0x0c2230d,
  48133. 0x1b9d797, 0x1fb2d2f, 0x19d7820, 0x0f7a888, 0x030dfc4 },
  48134. { 0x0aadfe8, 0x02d714f, 0x004af3f, 0x0969a9d, 0x05027e5, 0x099ab09,
  48135. 0x00b7e2d, 0x029560e, 0x056a6a2, 0x15ce102, 0x041a3a8, 0x1ef460b,
  48136. 0x0fb1a3d, 0x0c41888, 0x1452c86, 0x11c3946, 0x136c4b7, 0x05bdf11,
  48137. 0x18bda61, 0x0e79cc7, 0x1ac6170, 0x1316efb, 0x01b8452, 0x1af8791,
  48138. 0x192bf07, 0x14493b0, 0x0fac6b8, 0x1b4d3c1, 0x1849395, 0x18ba928,
  48139. 0x08260eb, 0x080f475, 0x0c52a4d, 0x1f10c4d, 0x1f6ab83, 0x022a6b8,
  48140. 0x197f250, 0x17f4391, 0x04b3f85, 0x03ea984, 0x0572a59 },
  48141. { 0x1a5553a, 0x1420c84, 0x0ef1259, 0x1064ee6, 0x1f05431, 0x17eb481,
  48142. 0x0d2c8fb, 0x1a9f39d, 0x1f22126, 0x09e5fcd, 0x1655e2f, 0x03805fd,
  48143. 0x186d967, 0x0501836, 0x0965f3b, 0x09fcb77, 0x1613d67, 0x15b82f6,
  48144. 0x1fccfdd, 0x06c456c, 0x0c31f1d, 0x0308e5c, 0x056f3cf, 0x07a3552,
  48145. 0x067dce5, 0x1a1d1c2, 0x07e422a, 0x005fd25, 0x15767a9, 0x04cec68,
  48146. 0x1edb8f9, 0x1215fa0, 0x142db5c, 0x18c8740, 0x1ef1b22, 0x1c2418d,
  48147. 0x04919a4, 0x0432a99, 0x0b0f203, 0x1c3b190, 0x065c2cb },
  48148. { 0x060bb63, 0x06d1053, 0x0915a13, 0x150dd0c, 0x07dc3b0, 0x10776b9,
  48149. 0x0b3d9ae, 0x0b0ec8e, 0x1679dd1, 0x0e0b172, 0x14b511e, 0x04ee108,
  48150. 0x1eb6884, 0x009fabc, 0x06f1acd, 0x02ee105, 0x1ec9501, 0x1c9750a,
  48151. 0x1dce060, 0x09c6008, 0x12f15e3, 0x04b9f0e, 0x030f28d, 0x137a7bd,
  48152. 0x0f1dc22, 0x169d2e2, 0x0e53bdf, 0x107dfe3, 0x0e7a1a7, 0x19c6efd,
  48153. 0x1491b6d, 0x0341330, 0x153d72e, 0x07a55a1, 0x1562837, 0x124a675,
  48154. 0x0e7888b, 0x02a80b0, 0x1fd9b60, 0x1aa774e, 0x0831440 },
  48155. { 0x011b2da, 0x117197b, 0x1ab3d0f, 0x13a1f48, 0x1d066e2, 0x059e06a,
  48156. 0x1cfa208, 0x1e1d12f, 0x01d3e44, 0x02e1473, 0x09e99b1, 0x1ecdbfa,
  48157. 0x17929d7, 0x080f428, 0x16e1828, 0x0f1bae6, 0x0983de0, 0x1751fe7,
  48158. 0x0e33846, 0x0efb6ac, 0x0b3bc99, 0x17a429b, 0x01220e0, 0x195bf8c,
  48159. 0x07a3c64, 0x1b8bf06, 0x1e0851e, 0x19a2fef, 0x011e3e3, 0x11e60da,
  48160. 0x1b7a559, 0x130bf68, 0x139ac8f, 0x08ce52b, 0x0736f3c, 0x0a70a73,
  48161. 0x015a281, 0x0c2d387, 0x115992a, 0x114dabe, 0x0504c3a },
  48162. { 0x0fa53c7, 0x0a941dc, 0x138c02d, 0x10a128e, 0x185cff3, 0x1e712fc,
  48163. 0x090710d, 0x1da469a, 0x0e5a129, 0x0c19218, 0x1319d0a, 0x12ad557,
  48164. 0x016ad38, 0x1f740f7, 0x1700075, 0x04e0545, 0x0b6670b, 0x1a611e3,
  48165. 0x1ba28ee, 0x1cacfd4, 0x13eab35, 0x07534b3, 0x0f1c2cf, 0x1c51d59,
  48166. 0x1a9c3e6, 0x1ed42d3, 0x1954ded, 0x15cd09b, 0x0937dc2, 0x01f2b6f,
  48167. 0x0897b2b, 0x1f08608, 0x12ea6c9, 0x0e2905f, 0x1f41dff, 0x1a7195e,
  48168. 0x09f56ad, 0x1d7858b, 0x0874b09, 0x1338e3a, 0x0496e46 },
  48169. { 0x1a93467, 0x07e414f, 0x1852e85, 0x081d654, 0x02e3768, 0x19f04de,
  48170. 0x13ebd20, 0x198cb37, 0x03686bd, 0x042cba9, 0x0c85aaf, 0x010103e,
  48171. 0x1840bfd, 0x0be040d, 0x18ef698, 0x0f27788, 0x086bb04, 0x0de80fd,
  48172. 0x1359031, 0x03d9cc5, 0x15c45a2, 0x0a1101e, 0x05efda9, 0x022cf6f,
  48173. 0x00edc95, 0x134675a, 0x1dd96e8, 0x0cf5595, 0x0b51f9d, 0x0cf4d75,
  48174. 0x0ea2e83, 0x161ad0c, 0x14b215e, 0x034a960, 0x136f97c, 0x0a6a99b,
  48175. 0x0b3744b, 0x15ae67e, 0x1ffa13c, 0x0e62606, 0x0133891 },
  48176. { 0x1003cd1, 0x0032022, 0x0b1bb9a, 0x18895c5, 0x1dac17b, 0x07298a7,
  48177. 0x1067f7a, 0x0b8979a, 0x1c7cea9, 0x0f1a75c, 0x0df8060, 0x0c5a71e,
  48178. 0x08bb577, 0x1304c86, 0x1133ec0, 0x094f7d9, 0x1f950a3, 0x185e249,
  48179. 0x10cc13b, 0x0e82e4a, 0x0a2a680, 0x1935e45, 0x0bb03f2, 0x08bfd4b,
  48180. 0x09b463b, 0x1d64f3d, 0x1957ef6, 0x17652a5, 0x05dff44, 0x0053024,
  48181. 0x05943c3, 0x09bd48f, 0x0c5104d, 0x11d0101, 0x0825a57, 0x0ba59df,
  48182. 0x0da1f34, 0x00815a3, 0x0fef532, 0x0e7e706, 0x0422eb5 },
  48183. { 0x0ad3f47, 0x0975b53, 0x083ab16, 0x1b2e297, 0x10861f6, 0x140a2cd,
  48184. 0x1a4641c, 0x006af83, 0x064ea58, 0x1be4a71, 0x049c8f3, 0x0d58a96,
  48185. 0x0a72537, 0x0d7db9b, 0x09ae907, 0x079b9e5, 0x120cba0, 0x0e44f44,
  48186. 0x0c3f4eb, 0x041968b, 0x19fef2e, 0x0a6b302, 0x09ba969, 0x13bf178,
  48187. 0x1fa8b88, 0x15ff731, 0x059a8fc, 0x01e38fc, 0x1312e14, 0x1e4e3a3,
  48188. 0x1fc27fa, 0x0e4f333, 0x119b9c2, 0x09582be, 0x0d32dff, 0x0d53f77,
  48189. 0x00da2dc, 0x1d13ebd, 0x0960b3e, 0x19e584a, 0x0368541 },
  48190. { 0x0799d37, 0x09e4f11, 0x0ce9443, 0x0b59f46, 0x1b677de, 0x07bcad8,
  48191. 0x1863c20, 0x1849cd5, 0x0afc8df, 0x0da9e15, 0x10b709a, 0x036c1d0,
  48192. 0x0879754, 0x16033ff, 0x09bcabe, 0x1b0efab, 0x003bd07, 0x1681045,
  48193. 0x152f8bc, 0x08e7e0c, 0x023e34b, 0x157a8af, 0x199f040, 0x1835e91,
  48194. 0x1bf9d2a, 0x0805806, 0x06da84f, 0x04c9f48, 0x094c11e, 0x1c354bf,
  48195. 0x1d059a5, 0x10d4b0d, 0x1d8cf2d, 0x093f484, 0x01a71fe, 0x0c0e77f,
  48196. 0x0241a56, 0x0bbc401, 0x04cd2e2, 0x0b2444c, 0x059a5bf },
  48197. { 0x1347191, 0x0e48f40, 0x05cba74, 0x19d72d3, 0x186c1ab, 0x0a353f8,
  48198. 0x01d9ea7, 0x12e0f11, 0x0daa7d3, 0x149e7e6, 0x0e6a836, 0x13e3b23,
  48199. 0x0c08bee, 0x1c6e9e3, 0x19ff5e3, 0x1020104, 0x0d09422, 0x1fc9c30,
  48200. 0x0b6d1fe, 0x14e355b, 0x0f8a6a6, 0x1bd30ab, 0x072a81a, 0x1091793,
  48201. 0x105e039, 0x09ad50d, 0x1caaaa4, 0x0dbb846, 0x1f3bd13, 0x103cd89,
  48202. 0x135df9f, 0x09598be, 0x10b5cbe, 0x07e9b46, 0x17e2613, 0x1009b48,
  48203. 0x13d3e0f, 0x077b0c6, 0x1e673c5, 0x18287d6, 0x0467564 },
  48204. { 0x0fff5d7, 0x12c825b, 0x1d4a35c, 0x1f25b88, 0x037f33a, 0x105c550,
  48205. 0x155d5b4, 0x073212b, 0x143baec, 0x111afe0, 0x0ae6c0c, 0x095ed14,
  48206. 0x01a2feb, 0x0a69ae3, 0x1140c62, 0x0e90cc3, 0x0a2ea87, 0x1d6495b,
  48207. 0x046f1bc, 0x09162a0, 0x1cb28eb, 0x1463cf6, 0x08a3f84, 0x1a5400d,
  48208. 0x1bc0ca5, 0x0284fb8, 0x08bc56e, 0x062cee6, 0x036218f, 0x19463d0,
  48209. 0x07bfa35, 0x09f03c1, 0x08f39cb, 0x0286c83, 0x0059edf, 0x062ee7e,
  48210. 0x0d6a1e0, 0x07bd6df, 0x0135434, 0x02c9dd3, 0x08a0dee },
  48211. { 0x1366e6f, 0x0c8dfa3, 0x0015412, 0x1fd0d86, 0x18084d9, 0x06671b5,
  48212. 0x11d4690, 0x1c42989, 0x03f1961, 0x1da3553, 0x11790ee, 0x0bf2808,
  48213. 0x1f56a78, 0x048f10a, 0x0346d5f, 0x1011bb7, 0x13ec7ee, 0x0354722,
  48214. 0x0ea87a3, 0x0cfdf17, 0x0109c03, 0x18f1f0c, 0x0c43647, 0x0414586,
  48215. 0x0fd0e7e, 0x13bfcbe, 0x1155330, 0x03d0190, 0x028403f, 0x1e0ebdb,
  48216. 0x1f3a26e, 0x07fc142, 0x178a966, 0x00039bb, 0x067f07c, 0x053d3b6,
  48217. 0x16f6bed, 0x13ff3ed, 0x1388cb3, 0x1a5dd2f, 0x07b04b5 },
  48218. { 0x0c5faf8, 0x035e3c1, 0x025d6d5, 0x1d1d702, 0x1a734c5, 0x1c28f00,
  48219. 0x1a1879d, 0x03e7aac, 0x1e956d5, 0x19d0809, 0x0f0df20, 0x0e63878,
  48220. 0x0cc7351, 0x1060a47, 0x1dce3ef, 0x1de82c0, 0x0bbe1bb, 0x1976378,
  48221. 0x1e94615, 0x0558dd9, 0x0df00aa, 0x0bb371d, 0x01ca40b, 0x045adc6,
  48222. 0x15089c6, 0x017e6a6, 0x0e9b760, 0x15c4364, 0x0863723, 0x0d2a99c,
  48223. 0x08b9519, 0x151b030, 0x05119a0, 0x14bbd6c, 0x00c8de1, 0x189e29a,
  48224. 0x1c7b272, 0x0d840e4, 0x18c7145, 0x1499337, 0x01c6a95 },
  48225. { 0x0821363, 0x0a56ae1, 0x18729ac, 0x069a2fb, 0x029c182, 0x16f4244,
  48226. 0x14b1332, 0x04f5deb, 0x182489e, 0x009559c, 0x07649fd, 0x0131e10,
  48227. 0x1f92c9c, 0x1ae5d68, 0x01ef7d1, 0x13f62df, 0x0b81a1d, 0x17a556d,
  48228. 0x1d7cedd, 0x14f2476, 0x08fe475, 0x0b6dddd, 0x067742b, 0x0e1568b,
  48229. 0x161644b, 0x178c1b7, 0x04d2f66, 0x148c910, 0x1abda32, 0x11375d4,
  48230. 0x1ed7244, 0x1ccac4b, 0x0ec8709, 0x0725f26, 0x0678206, 0x19a9672,
  48231. 0x14f6879, 0x004e420, 0x1932697, 0x0046150, 0x072708a },
  48232. { 0x14a466c, 0x1e058f9, 0x16e93cc, 0x18ff3a8, 0x01bae09, 0x143c2e5,
  48233. 0x03fb838, 0x103ae1e, 0x0908808, 0x12638a3, 0x10f68e0, 0x1855760,
  48234. 0x12e2416, 0x07637a1, 0x0f69c4f, 0x07c38e6, 0x049c979, 0x095ac83,
  48235. 0x0d724d9, 0x05ab616, 0x1b2adb6, 0x111f2e0, 0x0d57adb, 0x02d6a2a,
  48236. 0x0b5cebb, 0x08e67f4, 0x07dc25a, 0x1c1030d, 0x085bd59, 0x1cfdb0d,
  48237. 0x1df2197, 0x1f5c207, 0x169d3cc, 0x13f4ef8, 0x11cdcd1, 0x072a4b8,
  48238. 0x0369511, 0x1aae05a, 0x17485f6, 0x098e64c, 0x07491c7 },
  48239. { 0x0d2b94d, 0x16adfc0, 0x182cc4b, 0x0774964, 0x1b8ac63, 0x110cd08,
  48240. 0x1163358, 0x11d590d, 0x1aeb82c, 0x0be67b5, 0x1e73b4c, 0x13dcb3d,
  48241. 0x1a2dfb2, 0x1215e6a, 0x09f6263, 0x16403b5, 0x1c85974, 0x049f14a,
  48242. 0x07f16b7, 0x0eaf09b, 0x03ba69e, 0x0f80955, 0x15b11c2, 0x0ba7973,
  48243. 0x09f37c8, 0x15e8fed, 0x174f752, 0x0a90fc4, 0x1ba22ee, 0x0580859,
  48244. 0x0ec03f5, 0x18dd1b9, 0x1591493, 0x1433265, 0x1eaef39, 0x0d6e653,
  48245. 0x08906b7, 0x14e8e13, 0x1a105a0, 0x1cae82e, 0x08bcfd3 },
  48246. { 0x1c8c314, 0x0139a69, 0x00cc1a2, 0x02230e1, 0x15f0b2f, 0x145d0b4,
  48247. 0x1df0f01, 0x10f726f, 0x0779247, 0x1b2f06c, 0x04889d4, 0x1cbc3f3,
  48248. 0x0f15527, 0x13effea, 0x01a5920, 0x0c71214, 0x1f22f58, 0x0eac59e,
  48249. 0x0bc83ab, 0x08d712d, 0x0257834, 0x05a83a3, 0x0275e5c, 0x0454d22,
  48250. 0x0d20640, 0x1bcecf4, 0x1d9c7b0, 0x03cbf15, 0x1fe91ed, 0x128482b,
  48251. 0x061bd50, 0x0a51208, 0x14dda81, 0x09956f8, 0x043876e, 0x117af00,
  48252. 0x105a937, 0x0c68f24, 0x0ad24f8, 0x1ef7a6f, 0x053cadc },
  48253. { 0x053d0ff, 0x0f6fbaf, 0x1d9c6ed, 0x1911157, 0x1886606, 0x10368ae,
  48254. 0x0c3e048, 0x066c923, 0x1e22b6a, 0x180c1a2, 0x0ecc5ec, 0x129762e,
  48255. 0x15aba67, 0x1ee4f2c, 0x079619d, 0x049a318, 0x0822396, 0x1a70832,
  48256. 0x0957754, 0x0a5cb3b, 0x079c617, 0x15cf214, 0x0062d3a, 0x03e57da,
  48257. 0x0784b49, 0x14f657b, 0x0879e50, 0x1b9b73a, 0x1262243, 0x0a42887,
  48258. 0x170da50, 0x14ca1d8, 0x06f190a, 0x14bb008, 0x16bada6, 0x0cea854,
  48259. 0x032d104, 0x1ebaf4e, 0x18ac5a6, 0x0c97f18, 0x0908499 },
  48260. { 0x093c661, 0x0867b2d, 0x015ac4e, 0x093b6be, 0x1848626, 0x0d0bc40,
  48261. 0x0ea7694, 0x1352552, 0x16772de, 0x1865dc7, 0x0521f06, 0x1d7af8e,
  48262. 0x1e6e67f, 0x0731211, 0x0d0e0b5, 0x085f1f3, 0x10ebb5a, 0x14b7ed2,
  48263. 0x022693c, 0x03666ec, 0x0516c92, 0x1dc3af6, 0x1274cb5, 0x0202496,
  48264. 0x0d2cac4, 0x1bd5ec3, 0x071087e, 0x0d0c441, 0x17de33f, 0x04d5fb5,
  48265. 0x1a0f865, 0x1d27924, 0x1ee18f0, 0x0266066, 0x1578237, 0x05a9db7,
  48266. 0x13580d2, 0x1badf23, 0x15fa30a, 0x1f48d19, 0x03d7f6f },
  48267. { 0x1fbd5d1, 0x194866f, 0x037fa9e, 0x0d2e067, 0x1d759da, 0x1f76e4c,
  48268. 0x02c2243, 0x11cacd0, 0x142dce6, 0x034857a, 0x19360af, 0x1e57655,
  48269. 0x008519d, 0x1f8cadb, 0x04919fd, 0x043e8ac, 0x02cd83c, 0x1b2cd1a,
  48270. 0x159458c, 0x0e37eaa, 0x0562557, 0x1aaa45d, 0x17f1a24, 0x125e474,
  48271. 0x1920394, 0x00bdaa0, 0x0e72718, 0x0cea51c, 0x1e60195, 0x076a288,
  48272. 0x154fc19, 0x03a2d4a, 0x03f9eb9, 0x055f718, 0x13f4895, 0x187c318,
  48273. 0x1d434e7, 0x0ca6b7f, 0x1d39902, 0x07edbbc, 0x08fb12d },
  48274. { 0x13cb7a4, 0x1c0d114, 0x1935b18, 0x0170f6f, 0x053e09f, 0x0561f7a,
  48275. 0x0a08c1e, 0x1229e42, 0x0578cae, 0x04ffd68, 0x0e9377a, 0x12d4e2d,
  48276. 0x004a2b6, 0x1b7ac05, 0x1a06853, 0x0260e28, 0x17b4c2f, 0x089ac7c,
  48277. 0x04cbee2, 0x12d32c5, 0x1af7878, 0x0513452, 0x0a77614, 0x0473f06,
  48278. 0x11f6dfe, 0x0ced7bb, 0x193d1d2, 0x1e41fa5, 0x1ca0e95, 0x1f3bc33,
  48279. 0x1b26d90, 0x06eb303, 0x1858ecd, 0x18e4bf3, 0x096466a, 0x077d28d,
  48280. 0x06ff345, 0x0981d10, 0x0dec53e, 0x062eba4, 0x03fcc67 },
  48281. { 0x121f920, 0x0f5eaef, 0x0e41427, 0x1f82803, 0x1af70e1, 0x132557f,
  48282. 0x12ff656, 0x0444853, 0x12c37a1, 0x109042a, 0x0e49afc, 0x07e8fbd,
  48283. 0x1c1d4c9, 0x0fd9f8e, 0x1cf9302, 0x1788c25, 0x0595b51, 0x12b042d,
  48284. 0x043f6f4, 0x1ebac5e, 0x13c22a2, 0x07ef865, 0x183758b, 0x01e4a96,
  48285. 0x024a36b, 0x15b8aa2, 0x1559184, 0x074b40b, 0x15249cc, 0x1867d0f,
  48286. 0x022faf8, 0x0fcc543, 0x0ec6903, 0x14c9c92, 0x0eb2bd0, 0x0aebe1f,
  48287. 0x13fa868, 0x09a2ee5, 0x070d350, 0x1fb8e2a, 0x0645146 },
  48288. { 0x01924f9, 0x0319d5d, 0x1b87b3b, 0x0c00c64, 0x1ba6f13, 0x087e0bd,
  48289. 0x15eb1f9, 0x000406e, 0x1ef3d8e, 0x1298c8c, 0x1169d32, 0x0d54a3b,
  48290. 0x189545a, 0x098a095, 0x087563f, 0x1a000dc, 0x0057bb1, 0x180de18,
  48291. 0x1b46a70, 0x1138d2d, 0x1a48f17, 0x0fcc2c7, 0x1ebcb4d, 0x12f7d0a,
  48292. 0x109b981, 0x12ea1a6, 0x14a6a89, 0x1b80eea, 0x18fa801, 0x1df3e02,
  48293. 0x13b2b40, 0x0a97429, 0x0d70a9f, 0x0853a49, 0x1415b01, 0x14db8f0,
  48294. 0x0d005dd, 0x1e5254a, 0x07cb8a9, 0x0e557f7, 0x0448d3d },
  48295. { 0x1b33989, 0x178a294, 0x056b715, 0x19535d0, 0x068351b, 0x03a20a4,
  48296. 0x1584d2c, 0x07767e8, 0x03cd9f3, 0x0ae7215, 0x1b928e5, 0x09d8bfe,
  48297. 0x1113ade, 0x1287554, 0x0ab1c56, 0x1dfbfa7, 0x0995666, 0x10630f6,
  48298. 0x1a911c2, 0x145171e, 0x04c9108, 0x0272a42, 0x100bbd6, 0x1c5e66e,
  48299. 0x1b162d0, 0x05e5c12, 0x1ed1bdf, 0x1b9a263, 0x12fd893, 0x1c764b7,
  48300. 0x1e08205, 0x04b2518, 0x18c5d67, 0x1e22ca6, 0x0f7e658, 0x1e50b46,
  48301. 0x192a309, 0x04b8bae, 0x06695c9, 0x0f396e0, 0x0768814 },
  48302. { 0x1767eed, 0x1d08a48, 0x176ee90, 0x1b257ec, 0x1e11b9a, 0x12f10d2,
  48303. 0x0b3800e, 0x02bd144, 0x12a3354, 0x1b02210, 0x1ab5898, 0x0768953,
  48304. 0x05c2c56, 0x1059577, 0x1018992, 0x1c3ae97, 0x1758bf2, 0x0badc6a,
  48305. 0x0228997, 0x1e1dcfa, 0x12a71cf, 0x0ed85b8, 0x05e4538, 0x030d25a,
  48306. 0x125d04b, 0x00ae1ac, 0x115b33a, 0x1c4a7e9, 0x1f0e3ad, 0x120e4ff,
  48307. 0x06691e4, 0x1bb57da, 0x0b9d06e, 0x1728328, 0x098167e, 0x00ce26a,
  48308. 0x132ce18, 0x1b007da, 0x0189bcd, 0x038bcb5, 0x0670eb0 },
  48309. { 0x1cdbb43, 0x1e057b9, 0x06b77dc, 0x0afe486, 0x0f08ecc, 0x0d1c22e,
  48310. 0x01504a8, 0x1e322f0, 0x09224dd, 0x0d08279, 0x11fbfda, 0x071b7d5,
  48311. 0x024352f, 0x1e16899, 0x0eced39, 0x168edf8, 0x030b5e4, 0x0534f4a,
  48312. 0x1d691bc, 0x0646812, 0x0ece7d9, 0x0f2eb27, 0x0024e26, 0x0468bd3,
  48313. 0x01250db, 0x0b5bdc1, 0x09fd2de, 0x06aa526, 0x190b1f2, 0x060aa5d,
  48314. 0x158bba7, 0x12225ef, 0x1a9c8f5, 0x157190f, 0x1e6072e, 0x145a1e5,
  48315. 0x0075166, 0x1f81b30, 0x1fc9edd, 0x1cec6bb, 0x0504852 },
  48316. { 0x0f392fa, 0x19e72d1, 0x01e0bc3, 0x15d8d92, 0x126c076, 0x1d557b1,
  48317. 0x17a4a12, 0x1275a03, 0x1cbe8e9, 0x00d8b69, 0x142422c, 0x18485b2,
  48318. 0x1871305, 0x1c29d79, 0x1bf585c, 0x053418c, 0x00ed3c4, 0x1bb9a8a,
  48319. 0x1eafc09, 0x0362543, 0x11778a3, 0x0102c59, 0x0814c00, 0x18fbd73,
  48320. 0x1d9fca9, 0x09855ff, 0x0fa199f, 0x00bded3, 0x09e13fd, 0x198474d,
  48321. 0x070bce9, 0x1723d5d, 0x14c9a19, 0x073621f, 0x1b9d863, 0x00a1a19,
  48322. 0x1240f8b, 0x126e202, 0x03313ec, 0x0a3efd2, 0x0992fe1 },
  48323. { 0x0f197aa, 0x06d989c, 0x1e61115, 0x1b0f0e5, 0x04ded69, 0x1854145,
  48324. 0x09ec113, 0x18d2f68, 0x0a31e48, 0x010f0d7, 0x03bfb26, 0x013fbb3,
  48325. 0x0ee38cb, 0x040659d, 0x0e13ea1, 0x0aae641, 0x0a84747, 0x1dd2dda,
  48326. 0x1543a5a, 0x1c10159, 0x1550a9b, 0x0e77881, 0x111147a, 0x08264b9,
  48327. 0x0e75fc4, 0x19eb137, 0x00e2978, 0x1dd4bd3, 0x10abd26, 0x1f5cd15,
  48328. 0x0a5cc86, 0x136c105, 0x092e484, 0x1e61565, 0x1a2a64a, 0x163b902,
  48329. 0x1c8eb9f, 0x0767a5c, 0x1c7804d, 0x15098b6, 0x05a68bf },
  48330. { 0x10a2bfb, 0x19da2ff, 0x02c2d3f, 0x12aa05f, 0x1105fff, 0x0e06136,
  48331. 0x162156c, 0x00829bc, 0x10d3b9d, 0x08b432d, 0x14e45fb, 0x08a604d,
  48332. 0x0e2f5a2, 0x1a6d9e0, 0x08bd24f, 0x11e5cd4, 0x08ae241, 0x0a438aa,
  48333. 0x026fbd8, 0x06c750a, 0x1bec6ab, 0x1d5c65d, 0x0472878, 0x023472d,
  48334. 0x0dc9840, 0x0bbb8f0, 0x0835729, 0x1f305c1, 0x097bc1f, 0x1822c0c,
  48335. 0x19fad02, 0x010b5ab, 0x1c24a46, 0x1bdbe25, 0x1e8298c, 0x1fa2b91,
  48336. 0x1ef1628, 0x07377bd, 0x1d0e55b, 0x1f33ebd, 0x078acfd },
  48337. { 0x0520189, 0x1bf8afc, 0x071116f, 0x018efec, 0x154202a, 0x11170dc,
  48338. 0x11ae77e, 0x10e73db, 0x11f4a34, 0x16b0133, 0x13314b4, 0x1252902,
  48339. 0x03cd933, 0x02f4f89, 0x1da8490, 0x16defbc, 0x0a0ae36, 0x0711837,
  48340. 0x00e9638, 0x02a4317, 0x031a538, 0x1b50209, 0x0618aed, 0x0637ce3,
  48341. 0x0253cbf, 0x10ff46d, 0x08df7a1, 0x1bf8a66, 0x0e48902, 0x09fb485,
  48342. 0x14bc972, 0x11754dd, 0x0bcb8f0, 0x1a514b3, 0x183e422, 0x12de215,
  48343. 0x1061c94, 0x1a5a465, 0x08d9a32, 0x0e7a0eb, 0x00ad92d },
  48344. { 0x0ca548a, 0x0aff6e1, 0x06aefee, 0x01019b1, 0x0778c62, 0x1361402,
  48345. 0x0552cd1, 0x0057d32, 0x1d4be89, 0x11df049, 0x1a07b7a, 0x132a27c,
  48346. 0x01847b7, 0x017a00b, 0x0aa3d2c, 0x0ffd1e4, 0x14d4aeb, 0x11f7965,
  48347. 0x0ebb57d, 0x18a2a36, 0x11639ad, 0x08cc618, 0x1b0733f, 0x1afb11f,
  48348. 0x0c17ba3, 0x04bee15, 0x0d19084, 0x11f4c9a, 0x190bcf0, 0x005bca5,
  48349. 0x1ad7afe, 0x016a153, 0x178b4ba, 0x153358d, 0x04d09e6, 0x1a349fd,
  48350. 0x075b3ce, 0x1a6e578, 0x1a6ba3b, 0x140e14d, 0x095bbd8 },
  48351. { 0x014bbd0, 0x0924af3, 0x0d8d67e, 0x0f7047c, 0x1567a88, 0x0deb53b,
  48352. 0x127b3f0, 0x085c48f, 0x18e835c, 0x1fd57a3, 0x1819a8a, 0x09c155b,
  48353. 0x16314ef, 0x0e0b699, 0x0aea98d, 0x1c7120e, 0x071e2f0, 0x1fd214e,
  48354. 0x141f643, 0x03cba17, 0x1c04cac, 0x1528a7a, 0x1a7fcd7, 0x0aa9d82,
  48355. 0x053fcc0, 0x03fc498, 0x1ca8d65, 0x163b0d6, 0x0be487a, 0x1830157,
  48356. 0x0878a7e, 0x1bf739e, 0x0a10d6d, 0x0fe7ad0, 0x0167c83, 0x155a28e,
  48357. 0x18867a2, 0x06e337d, 0x0a46520, 0x09f824b, 0x0375a88 },
  48358. { 0x017f7ea, 0x05f1709, 0x16ac5e3, 0x150eb8d, 0x1a161e2, 0x0d8d2a0,
  48359. 0x1fb006f, 0x195eee0, 0x0e4fd73, 0x1c43250, 0x0836199, 0x0cc9a27,
  48360. 0x08baebc, 0x0469833, 0x0c97e67, 0x0b2a080, 0x1c92f1c, 0x1dc9f6c,
  48361. 0x1078199, 0x06cec6a, 0x0763fdf, 0x185c8d3, 0x1f65fee, 0x0f39341,
  48362. 0x069ea60, 0x0239355, 0x007aaa3, 0x0e60790, 0x063c55c, 0x0e40d7d,
  48363. 0x16f7b1d, 0x09fa255, 0x1cdcde2, 0x041c500, 0x169c65a, 0x133fc1b,
  48364. 0x1841537, 0x1d849d9, 0x013b19a, 0x1161197, 0x0268d81 },
  48365. { 0x1580555, 0x171ac20, 0x00edcf6, 0x0e8e7a2, 0x0fc32e6, 0x0660d5a,
  48366. 0x0404efb, 0x1bc4818, 0x0b24ee9, 0x1204cf9, 0x03819b6, 0x16b73f5,
  48367. 0x0e37b0c, 0x121c6bf, 0x0b81391, 0x002816b, 0x1642b72, 0x03fbe98,
  48368. 0x0e7929e, 0x1e9db66, 0x037586e, 0x169d3ec, 0x0979dfb, 0x0e0f85d,
  48369. 0x1ad37bd, 0x0c4c41f, 0x083e5e4, 0x02d6c67, 0x1a208e8, 0x0145173,
  48370. 0x1ab8930, 0x0886aa2, 0x171fe3c, 0x195fa88, 0x0ccd3d7, 0x0c7d727,
  48371. 0x01b53a5, 0x0cf6a58, 0x0912e10, 0x0b80ad9, 0x08b0273 },
  48372. { 0x1019195, 0x1da3270, 0x0306e26, 0x0de7f85, 0x1de4c02, 0x1e1d908,
  48373. 0x039b8af, 0x05f5824, 0x091bdf9, 0x038de2d, 0x056f27b, 0x15681b3,
  48374. 0x1e485d7, 0x13248ff, 0x119da3b, 0x1c4cb2f, 0x119afbc, 0x16caa96,
  48375. 0x186ddb0, 0x0d8ffd1, 0x0d1bbae, 0x00ebf1d, 0x059f60a, 0x1312e68,
  48376. 0x09af95e, 0x0c11f0a, 0x1228320, 0x03e0049, 0x006c0dd, 0x1fede18,
  48377. 0x133d5c7, 0x0b0ee7a, 0x12ecf7e, 0x0a06c59, 0x1e0bf4d, 0x04b0454,
  48378. 0x0436504, 0x1a2e1f8, 0x017f96a, 0x140969b, 0x0400e3a },
  48379. { 0x046e4a2, 0x10b24af, 0x01d11cc, 0x084826c, 0x17a2ed6, 0x0763be9,
  48380. 0x08ec718, 0x05ccb24, 0x1e5e0ac, 0x109d561, 0x01eadd7, 0x08378a2,
  48381. 0x1bda17c, 0x19e129e, 0x0c8bb25, 0x0452ccb, 0x1b8a501, 0x1ff9c33,
  48382. 0x1886a66, 0x0cc1aa0, 0x03f5fed, 0x03644fe, 0x08f0a14, 0x0c8a34f,
  48383. 0x150b9f1, 0x0379f69, 0x099f2d6, 0x0f87c06, 0x1185b12, 0x03bccb3,
  48384. 0x06f201f, 0x0942601, 0x1c157d4, 0x18fa684, 0x191eb6b, 0x106c5ee,
  48385. 0x13a6a19, 0x015cd67, 0x180e529, 0x1451b4d, 0x0131c3d },
  48386. { 0x1da83ba, 0x02ff8d3, 0x10d929e, 0x0ba09e8, 0x1415b42, 0x01fc097,
  48387. 0x066f7b0, 0x144f811, 0x080f5f4, 0x0c6a08d, 0x0946e71, 0x0c21fb4,
  48388. 0x123d32d, 0x069d979, 0x0ed1413, 0x0107933, 0x04bf4c2, 0x08cc622,
  48389. 0x0c3a0ff, 0x04c35ee, 0x1b9060c, 0x0fe5816, 0x0183293, 0x1e3cf90,
  48390. 0x1838b9d, 0x06487fb, 0x1f131a4, 0x16f39f2, 0x15f1546, 0x0a6baeb,
  48391. 0x1fc4c54, 0x03961d1, 0x1c074f1, 0x0bb0ad3, 0x0b06cb0, 0x0172415,
  48392. 0x04aa0ff, 0x004c56a, 0x173a77a, 0x0d468a8, 0x071d1a4 },
  48393. { 0x01b382e, 0x1c7bb7d, 0x0835d85, 0x06ee5bb, 0x00d8ecc, 0x0a68985,
  48394. 0x0acab17, 0x05954b5, 0x08d7262, 0x1e9c5d2, 0x0fb4189, 0x1b6d947,
  48395. 0x0fc5410, 0x1c9e766, 0x0de9621, 0x1c7afec, 0x0fd6e65, 0x08fb2ed,
  48396. 0x0291590, 0x08950ac, 0x140bc3b, 0x1427bc2, 0x03d1ece, 0x09ac1ec,
  48397. 0x1dadd5e, 0x16ac127, 0x105f4ed, 0x1199f21, 0x1fc13ad, 0x15ef992,
  48398. 0x0e4023a, 0x06c91f5, 0x090d716, 0x096a59f, 0x1ce8931, 0x1672c9f,
  48399. 0x133d0ac, 0x0e620b2, 0x1d486e5, 0x13e22cf, 0x06cd269 },
  48400. { 0x0f4f3ac, 0x0059d89, 0x17ecb63, 0x0533a37, 0x103dcfe, 0x19b9935,
  48401. 0x0d3e0c3, 0x104a800, 0x17c5a8c, 0x16eb449, 0x1c51088, 0x07a19b1,
  48402. 0x12eb709, 0x0c2ba17, 0x09e569d, 0x1b5bb12, 0x02c087a, 0x170af94,
  48403. 0x1aaded7, 0x1b8e922, 0x0bb47bb, 0x05d2c56, 0x14c3f90, 0x1758737,
  48404. 0x017ebe2, 0x05e06f2, 0x1b18681, 0x1696334, 0x1355694, 0x01a6f93,
  48405. 0x1be4ce3, 0x0615632, 0x0f03742, 0x064b2f4, 0x12e1b22, 0x0df45df,
  48406. 0x07eeb82, 0x17713a6, 0x1770867, 0x07fb468, 0x0327c06 },
  48407. { 0x147cd53, 0x0cf7fad, 0x1bfaace, 0x1a32875, 0x1be9869, 0x0154335,
  48408. 0x131ec50, 0x02dcc9d, 0x0b1c25a, 0x1f3e155, 0x1789c70, 0x16f2045,
  48409. 0x1fc4216, 0x1b36b52, 0x037f320, 0x0666dcb, 0x09eda81, 0x068aca8,
  48410. 0x0c2fedf, 0x0801e42, 0x0780370, 0x0cc9da4, 0x06f9381, 0x1e79a44,
  48411. 0x1a1fe39, 0x1c38311, 0x0bbb2d3, 0x0554456, 0x07b83b7, 0x024b361,
  48412. 0x0fc6bd3, 0x1b4bf4b, 0x042a94b, 0x00d793d, 0x008922c, 0x1935f75,
  48413. 0x1670112, 0x15ce951, 0x1a15bad, 0x1a381be, 0x0020f19 },
  48414. { 0x0dbba20, 0x08d4352, 0x1714dc1, 0x0db63bc, 0x1618ebc, 0x092c205,
  48415. 0x0286799, 0x09b34f0, 0x1d2bccc, 0x0201816, 0x0168925, 0x047a205,
  48416. 0x08e9ff0, 0x1d24313, 0x04dfb8c, 0x0228e77, 0x0f24cd6, 0x1f1bf71,
  48417. 0x0f415f3, 0x177fa74, 0x0fce79f, 0x09e66ef, 0x17ee85b, 0x0462e4e,
  48418. 0x058ec5b, 0x16dc8b0, 0x19c830e, 0x0ed33d7, 0x0f6bba4, 0x01c345a,
  48419. 0x1c0989d, 0x1e3140e, 0x0b0092a, 0x108b02a, 0x03aeb32, 0x0133a12,
  48420. 0x0c888f6, 0x0bf0ff8, 0x01513dd, 0x041600a, 0x079e727 },
  48421. { 0x020a239, 0x1679294, 0x0c418ca, 0x1d55cd6, 0x11a3974, 0x0050efd,
  48422. 0x15ae923, 0x155ac3f, 0x15a3ee7, 0x1229e1c, 0x0111b74, 0x0b41730,
  48423. 0x0f54845, 0x0f0b33b, 0x0a765ef, 0x0eb433e, 0x00c7893, 0x0f92965,
  48424. 0x1d0ea61, 0x035e7ce, 0x1d8de96, 0x0b3366d, 0x1c31e71, 0x18a71f2,
  48425. 0x1854ecb, 0x08e0a51, 0x0a849a1, 0x11b54e7, 0x1f558c5, 0x1da2954,
  48426. 0x017a6d6, 0x1f7a2bc, 0x1af7f83, 0x0c9ce9b, 0x049ce28, 0x0d4890f,
  48427. 0x1511a05, 0x14595ac, 0x011b790, 0x1c6e02b, 0x0001d3c },
  48428. { 0x145b1d7, 0x11b5cf0, 0x19935af, 0x140138a, 0x13e3938, 0x007b6df,
  48429. 0x0b9f79f, 0x0725cac, 0x0c343f5, 0x0882273, 0x025ec65, 0x0571b21,
  48430. 0x1ca5ab6, 0x0897bcb, 0x087dc2d, 0x051c963, 0x154750f, 0x0c8e6eb,
  48431. 0x1ee0597, 0x101c5ff, 0x02b3b4c, 0x03aca68, 0x197b4e7, 0x1067db8,
  48432. 0x0a49d56, 0x10c6609, 0x13cda4e, 0x0e6d297, 0x12c404e, 0x09a57e6,
  48433. 0x050d330, 0x023a803, 0x11bd5fc, 0x02f2303, 0x011ff16, 0x080aeb2,
  48434. 0x190b7a0, 0x1401b03, 0x11a12cc, 0x1f8815f, 0x04bb8c6 },
  48435. { 0x10f8796, 0x0716efe, 0x0778c48, 0x1b62679, 0x0968a40, 0x1b4e373,
  48436. 0x19b02a4, 0x077fd46, 0x0600727, 0x1f2db6b, 0x0050e4d, 0x19e1197,
  48437. 0x0539e4e, 0x0ff5e00, 0x1ffa736, 0x16a7890, 0x0440199, 0x1f5c57a,
  48438. 0x04d467a, 0x049c765, 0x1c162f1, 0x0564164, 0x0183086, 0x13b8b21,
  48439. 0x1d6f270, 0x094d668, 0x14db541, 0x0d2daa8, 0x120bfc5, 0x0efcac8,
  48440. 0x04300fd, 0x021ff4d, 0x1a3e88d, 0x19413cc, 0x1e95b10, 0x13a9f39,
  48441. 0x1a135d8, 0x07f54f4, 0x1f9e0ba, 0x1036d4e, 0x03699a8 },
  48442. { 0x0b1c64d, 0x119b90f, 0x05516f2, 0x1be3a50, 0x09cf3a2, 0x1b8837f,
  48443. 0x1a6cd94, 0x09b6fc5, 0x14f7cbf, 0x160b8a8, 0x02cdfc1, 0x02dc40b,
  48444. 0x05cbde4, 0x041a74e, 0x114e9fa, 0x074eb05, 0x1e2e9ac, 0x14a6def,
  48445. 0x1799f00, 0x1d8d978, 0x080d795, 0x0f8a135, 0x0308f09, 0x11a9f3f,
  48446. 0x0d20d6a, 0x11af716, 0x134edf0, 0x071b54a, 0x1a4d528, 0x07601eb,
  48447. 0x1cee782, 0x0f03968, 0x09475e9, 0x18e5565, 0x0e797b0, 0x0ee4e3e,
  48448. 0x0253518, 0x18474fc, 0x1fe2c77, 0x0064115, 0x04f3a4b },
  48449. { 0x0d095f8, 0x1c0838f, 0x15383de, 0x0db444d, 0x03e37fa, 0x19b68e9,
  48450. 0x0614abe, 0x023161f, 0x007d8e3, 0x08a31a7, 0x03c5bac, 0x152fc7c,
  48451. 0x17b9634, 0x010f761, 0x152ee71, 0x0438248, 0x1dbd72b, 0x05a766a,
  48452. 0x17c835f, 0x0070d0d, 0x00a2f96, 0x1eefc37, 0x07d4d67, 0x1891155,
  48453. 0x154fa5a, 0x0fa621e, 0x0f44127, 0x0dae295, 0x00607a5, 0x159f581,
  48454. 0x1784c54, 0x0f40464, 0x1be1c18, 0x1426da4, 0x1d294ab, 0x0089e49,
  48455. 0x0b5a7b8, 0x092e018, 0x1e7f679, 0x08d4da2, 0x06d8744 },
  48456. { 0x09a42f5, 0x083d55f, 0x13234a7, 0x186f039, 0x1fd5316, 0x034f508,
  48457. 0x169b677, 0x034e34e, 0x188fee9, 0x10cf06f, 0x113c493, 0x09b9f1a,
  48458. 0x0499c2b, 0x18d74a7, 0x1db7e48, 0x199840b, 0x076cf28, 0x193fdd4,
  48459. 0x15fdf3a, 0x141e03e, 0x1b746e1, 0x1a79fe9, 0x180fc7c, 0x183a427,
  48460. 0x1c4a742, 0x0c05076, 0x01f7ae1, 0x195584e, 0x0848bc5, 0x1c8fd78,
  48461. 0x0743d75, 0x00f58eb, 0x1f514ad, 0x1e2988b, 0x1cd2413, 0x1b2b472,
  48462. 0x1bb70f3, 0x125654b, 0x1582656, 0x193ff38, 0x03cf384 },
  48463. { 0x01fc9e3, 0x0835d67, 0x0e65c01, 0x04ced60, 0x0972174, 0x15fbd9a,
  48464. 0x06e379c, 0x1ee5694, 0x079b209, 0x1430154, 0x1aa3872, 0x17219c4,
  48465. 0x1a90580, 0x1f1279c, 0x1cce6df, 0x0c5c23d, 0x1916293, 0x05b62ec,
  48466. 0x1dec93d, 0x0e9c34a, 0x11e9511, 0x1a82f22, 0x1ce03f2, 0x106437b,
  48467. 0x17afb14, 0x0957a6c, 0x0dd1f97, 0x13300d7, 0x19a6080, 0x0eb2df4,
  48468. 0x0821549, 0x1a8abd0, 0x04828d9, 0x1053293, 0x1017615, 0x011918a,
  48469. 0x1103077, 0x13f39e3, 0x17c98f1, 0x0a1dce7, 0x02b2488 },
  48470. { 0x141159f, 0x1e6f342, 0x02c885c, 0x109f682, 0x18224c1, 0x1650e3b,
  48471. 0x018647c, 0x0800f45, 0x0a8b23e, 0x16103eb, 0x08d1294, 0x04214d6,
  48472. 0x05071a0, 0x1af694a, 0x03961f2, 0x198d9b6, 0x0ef810f, 0x0b62b5c,
  48473. 0x0b610ee, 0x118b1ec, 0x0975124, 0x1eba633, 0x12e40d8, 0x0d8cdec,
  48474. 0x0f7f2e6, 0x05f31a4, 0x07049af, 0x05f3a88, 0x0e49e8b, 0x1951b9e,
  48475. 0x1c2b01f, 0x1d0361b, 0x0486758, 0x110e8a9, 0x1534751, 0x1942116,
  48476. 0x14414a1, 0x130f673, 0x108545c, 0x198d475, 0x0938b3b },
  48477. { 0x0ded340, 0x050b5f2, 0x00daa79, 0x1501d10, 0x0e65fb2, 0x0b9d65c,
  48478. 0x0581b73, 0x1532e11, 0x0aaa657, 0x01d021a, 0x006c187, 0x18b0922,
  48479. 0x0cf304f, 0x0d05db2, 0x03ed86b, 0x05bebcc, 0x0ecf554, 0x1c0c615,
  48480. 0x1bddb57, 0x040aeca, 0x1d97740, 0x0849299, 0x0d59ade, 0x1add6bf,
  48481. 0x055e574, 0x05bd723, 0x16956d1, 0x01ef436, 0x147ea56, 0x0bcdc9b,
  48482. 0x159e5c0, 0x1e5b59c, 0x0e7e0e8, 0x01e0345, 0x181e13a, 0x03308e8,
  48483. 0x1530734, 0x1464f68, 0x075ac93, 0x14bb3d1, 0x06cff58 },
  48484. { 0x1e51f68, 0x000d801, 0x1f59423, 0x0a3a5fc, 0x01d1f22, 0x1ec402f,
  48485. 0x0342c26, 0x16fef33, 0x003e415, 0x0af483d, 0x165e609, 0x0cfac0f,
  48486. 0x16d1484, 0x0da29c4, 0x170ec7a, 0x0a1e80a, 0x013809f, 0x01a8008,
  48487. 0x008cff7, 0x165f4da, 0x00b8fbb, 0x057f8c1, 0x02da02c, 0x1a62fc0,
  48488. 0x004dc38, 0x1efd8ea, 0x1333231, 0x067aa88, 0x013f841, 0x03f3376,
  48489. 0x121fea1, 0x008dc5c, 0x13f83d8, 0x1d9d661, 0x1f15218, 0x0e78c4f,
  48490. 0x0b936af, 0x13fc557, 0x04c9d7d, 0x11e636f, 0x05fe4ac },
  48491. { 0x16f401e, 0x1525fc5, 0x1b51606, 0x075ab8f, 0x05db12a, 0x183da50,
  48492. 0x01c99be, 0x1a8f603, 0x09c22bc, 0x0e88f82, 0x1c7257f, 0x0fa8d26,
  48493. 0x0f5454a, 0x0cd2375, 0x1b157ee, 0x12da00c, 0x07c7fef, 0x00c31be,
  48494. 0x0e0fa57, 0x183a68d, 0x02dcbaf, 0x09805da, 0x1570e16, 0x1cfce24,
  48495. 0x1ec2b34, 0x1746ec6, 0x02c6133, 0x13939f6, 0x0278646, 0x062124d,
  48496. 0x19e3730, 0x04021e5, 0x10d95f2, 0x1d21014, 0x1325a5d, 0x1b0dc4a,
  48497. 0x0b2abda, 0x098e44f, 0x0152082, 0x0c82438, 0x0813771 },
  48498. { 0x05a8edf, 0x1592f4e, 0x1eb5899, 0x0420f14, 0x0e1388c, 0x1b776fb,
  48499. 0x1cdf521, 0x02ebe04, 0x1627446, 0x017d3fc, 0x14e0a89, 0x17b3670,
  48500. 0x0f3e2cf, 0x017b8df, 0x16b5ec4, 0x0152575, 0x0fa677d, 0x02b155e,
  48501. 0x07f7fcd, 0x1d7a2ea, 0x0c78573, 0x093e128, 0x15fd961, 0x0f9512d,
  48502. 0x116eec4, 0x04f7067, 0x019d88b, 0x199af36, 0x12c0758, 0x0c417c7,
  48503. 0x054c7f1, 0x14c010a, 0x032b37e, 0x062dd49, 0x0d860ba, 0x1c9af76,
  48504. 0x12f146f, 0x1239ae6, 0x16e62fc, 0x1dd39a5, 0x079c280 },
  48505. { 0x0b48122, 0x04101f9, 0x123af73, 0x0d60958, 0x08c0491, 0x02442f5,
  48506. 0x193727f, 0x03959e0, 0x182c100, 0x1c1c4cb, 0x178942a, 0x0e42ced,
  48507. 0x007339e, 0x070d5c1, 0x0a96baa, 0x0965c2f, 0x0a06bc1, 0x0126946,
  48508. 0x05ad88c, 0x18b76f0, 0x1606570, 0x0e67735, 0x1b1448d, 0x07d5c84,
  48509. 0x1f89f18, 0x1a58d95, 0x1a71989, 0x1c75e78, 0x1e38bc3, 0x02135a8,
  48510. 0x0ef82c1, 0x0e7c81c, 0x0dbc58e, 0x12df213, 0x15e2d6f, 0x107f3ba,
  48511. 0x12c8f40, 0x0cfbc8a, 0x1fd3e7f, 0x14953c7, 0x0758073 },
  48512. { 0x091ca22, 0x1d82bc3, 0x06d9f49, 0x0c27454, 0x1206bfd, 0x1caa09f,
  48513. 0x14e16b1, 0x00fd097, 0x0755366, 0x0e8c515, 0x0389331, 0x1bcf914,
  48514. 0x1d2e166, 0x1e23a6d, 0x155d430, 0x10874ad, 0x0c11366, 0x16f7a22,
  48515. 0x1d2e10c, 0x08dca79, 0x1783146, 0x1854fec, 0x12f0340, 0x0fdc406,
  48516. 0x0c82429, 0x163ded2, 0x1ff5ef9, 0x1a16217, 0x07f3ff3, 0x123b046,
  48517. 0x114b485, 0x169fa98, 0x0e52599, 0x0f08203, 0x1e8527a, 0x1bf7573,
  48518. 0x0661d32, 0x0153fd4, 0x1aaa24d, 0x0b1f5ec, 0x03f3e34 },
  48519. { 0x11597aa, 0x01ad7ca, 0x13ad47b, 0x1893bec, 0x1677d4a, 0x1a77fad,
  48520. 0x136726f, 0x06a04ed, 0x1515a29, 0x11f6524, 0x0ee70d0, 0x0aa7fb3,
  48521. 0x1c8a696, 0x16f0f84, 0x07ba77f, 0x0bf31f3, 0x156199e, 0x15c7d14,
  48522. 0x14a4b0c, 0x070eb06, 0x081bb76, 0x0e7e207, 0x01cd3b7, 0x08afb2b,
  48523. 0x15e9f65, 0x095ec16, 0x18c31e3, 0x11dc647, 0x033d67c, 0x172660a,
  48524. 0x0bb9dec, 0x0790629, 0x0d9f807, 0x117b1ab, 0x1788a83, 0x1c883dd,
  48525. 0x0c48295, 0x0f0bf6b, 0x053bc7a, 0x1886985, 0x0640d20 },
  48526. { 0x084d513, 0x105c719, 0x14e93a6, 0x0be62a0, 0x074c354, 0x166a950,
  48527. 0x1d01d16, 0x16f66dc, 0x01de50d, 0x005ee7e, 0x07f11b6, 0x0fb84a9,
  48528. 0x088d9d4, 0x181f83d, 0x0dbbc4c, 0x1a98453, 0x0ca6d4a, 0x1a7230d,
  48529. 0x127c6dc, 0x1c6a3bf, 0x0e65ca8, 0x06aba30, 0x02f1025, 0x065a6cf,
  48530. 0x02b330f, 0x1745b18, 0x18a15d0, 0x1340e96, 0x0c29c36, 0x1588c3b,
  48531. 0x1eb7f94, 0x12257a2, 0x19e4609, 0x1531cf9, 0x1598d26, 0x031dc81,
  48532. 0x072e05c, 0x1448156, 0x0a05ae5, 0x15181b2, 0x00f9c1c },
  48533. { 0x1433df3, 0x1d559b3, 0x0a307ae, 0x0e2ba6c, 0x16aa534, 0x1862e65,
  48534. 0x083625f, 0x1f22746, 0x165e408, 0x1648c65, 0x1cd145c, 0x10a9aa6,
  48535. 0x094b638, 0x05a6e50, 0x04e668c, 0x0264ce6, 0x1300a3b, 0x06792b3,
  48536. 0x1822ce2, 0x0c1bf4c, 0x0dfd5ea, 0x183d948, 0x162b5d2, 0x0d29f36,
  48537. 0x02789d7, 0x1d8c190, 0x02d98c3, 0x10b27b7, 0x1e3eaf4, 0x1fb8632,
  48538. 0x1e0f6d1, 0x07ce4c7, 0x1949c91, 0x17f99b1, 0x1b1b9b9, 0x0137359,
  48539. 0x098a824, 0x1ecdd38, 0x1bb14d2, 0x05e8ba6, 0x07e31c1 },
  48540. { 0x1fd2dd7, 0x00eb406, 0x0762f8a, 0x004956c, 0x1efacb0, 0x018fcb8,
  48541. 0x0017e51, 0x1797386, 0x0959cb3, 0x10646fd, 0x0ed0199, 0x18619ff,
  48542. 0x0dfdd5f, 0x1cb4d08, 0x118c6f9, 0x1fa36f4, 0x09ede13, 0x119b718,
  48543. 0x1251c1d, 0x077f5bf, 0x022376b, 0x0eee639, 0x1ea4649, 0x0d89dc3,
  48544. 0x10d7315, 0x1a3ba0f, 0x0438acd, 0x1ec9dc8, 0x04d93c4, 0x0969f7e,
  48545. 0x0ba1afa, 0x1f89f76, 0x13b7e03, 0x050dde2, 0x13d4cdf, 0x015832d,
  48546. 0x1e23ba6, 0x120d183, 0x14d5d37, 0x08a64da, 0x01a219c },
  48547. { 0x04db0bc, 0x1bf7c55, 0x058ff73, 0x0cf6d93, 0x0e23180, 0x050c979,
  48548. 0x0419cf6, 0x0e384c7, 0x0ffdc77, 0x0676171, 0x103b6f0, 0x1c6b45f,
  48549. 0x03997c8, 0x0166302, 0x1843b06, 0x10240f1, 0x0cb2b0c, 0x17e86f1,
  48550. 0x0795fe3, 0x188afed, 0x11c34d6, 0x192da9f, 0x054f9a6, 0x1f13971,
  48551. 0x0330ac4, 0x1f32115, 0x065559a, 0x05fe465, 0x1442d19, 0x0816a1b,
  48552. 0x00dcf35, 0x17d4d28, 0x04ce590, 0x1833178, 0x0dfbe00, 0x06d582a,
  48553. 0x16d0bf9, 0x15e7bbd, 0x064bf80, 0x1337920, 0x017aaa9 },
  48554. { 0x055db2e, 0x0ab21c7, 0x014434f, 0x067728d, 0x035dee4, 0x042317c,
  48555. 0x103956e, 0x0f83428, 0x1ea17e2, 0x17f9d9a, 0x17dea69, 0x186dbb2,
  48556. 0x0f23f99, 0x1eeb396, 0x05ff766, 0x08b80e4, 0x01edd20, 0x0fa0056,
  48557. 0x1fc1ac9, 0x0ab90e9, 0x09be94b, 0x1287252, 0x0291283, 0x076d026,
  48558. 0x05e91b4, 0x162f449, 0x04853e5, 0x117dbbc, 0x17fa977, 0x152607c,
  48559. 0x19c3d15, 0x14b7fa4, 0x08fd86b, 0x10477d1, 0x163ef9d, 0x1876965,
  48560. 0x026474b, 0x0affc61, 0x0c92bef, 0x1e14be7, 0x06b282a },
  48561. { 0x141a595, 0x0012fb1, 0x0a31e3f, 0x0d488bc, 0x191c38d, 0x0234212,
  48562. 0x1b8f7ad, 0x066e57a, 0x1755478, 0x1ca3369, 0x185b10f, 0x09a6107,
  48563. 0x1491141, 0x0ad3d65, 0x176519a, 0x1f6c828, 0x1098fd2, 0x08816ef,
  48564. 0x0ff61ec, 0x165a5a1, 0x10882a2, 0x0e2ca2a, 0x1a7a6f9, 0x0048bbc,
  48565. 0x18bf4a8, 0x187771b, 0x02c8c1a, 0x01617ad, 0x1e9f3d8, 0x02e3615,
  48566. 0x115da95, 0x0900584, 0x09d167b, 0x096fda1, 0x109cad0, 0x0427cc8,
  48567. 0x0e8d976, 0x127a94f, 0x1bafed9, 0x046a8e0, 0x06d4f5d },
  48568. { 0x0ba9f88, 0x0795b00, 0x02fcd72, 0x00f76da, 0x1dc807e, 0x1c0f2df,
  48569. 0x1b50ace, 0x03c1424, 0x0a7ac78, 0x1ae7367, 0x172e98c, 0x1cdfe6f,
  48570. 0x073e308, 0x11e4b24, 0x0372989, 0x0869a05, 0x17e8818, 0x13975d2,
  48571. 0x06de289, 0x07ab3ef, 0x0ea3a9e, 0x0e9783d, 0x14bc29f, 0x1a0bee9,
  48572. 0x0467824, 0x15b707f, 0x00045b7, 0x0410a2e, 0x137580b, 0x0f492c7,
  48573. 0x0ce70a9, 0x0e80e17, 0x18bd7a5, 0x1bec873, 0x01cae65, 0x08aa3f9,
  48574. 0x00db81b, 0x0d49e22, 0x0d2b5bb, 0x09facba, 0x04aaf0b },
  48575. { 0x114c7af, 0x192831a, 0x1ab66fb, 0x1b78303, 0x109e7da, 0x11f62c5,
  48576. 0x0ba1e3e, 0x10bde79, 0x1173b86, 0x06dfd5a, 0x14cb776, 0x1f81243,
  48577. 0x06b2490, 0x05ece23, 0x1bce1ae, 0x1b7b69d, 0x12fa061, 0x1e0e6ea,
  48578. 0x16f0136, 0x1d31344, 0x063664d, 0x15c2b94, 0x01be60d, 0x1c89540,
  48579. 0x1a8048b, 0x06388d2, 0x1825c06, 0x0dbdbc9, 0x011fb11, 0x02bbd96,
  48580. 0x165cabb, 0x14e43d9, 0x04dade1, 0x1f9d48a, 0x09af5ba, 0x0ff338a,
  48581. 0x1c2e14d, 0x0a0b2d8, 0x18cde87, 0x0730578, 0x08b2cbd },
  48582. { 0x052e991, 0x00df945, 0x0bb0a3b, 0x0d9f3a8, 0x0ba202f, 0x1a75228,
  48583. 0x144c318, 0x139060f, 0x1c5762b, 0x1e12bd9, 0x10a8b4f, 0x11a290f,
  48584. 0x0abd329, 0x118ca44, 0x053c69e, 0x00da594, 0x13b06ba, 0x0e38654,
  48585. 0x19017a2, 0x07e967d, 0x0ae79aa, 0x199aef7, 0x13193ba, 0x17e3a99,
  48586. 0x1f57803, 0x1fee8aa, 0x151585a, 0x083d816, 0x0e33f60, 0x0073043,
  48587. 0x1d48f7e, 0x1e04879, 0x19a79c8, 0x066ac1c, 0x093a1d3, 0x030d850,
  48588. 0x0fc5c83, 0x0775764, 0x0d9c088, 0x008fb7c, 0x057e283 },
  48589. { 0x1cdf666, 0x05b4c7d, 0x0749b98, 0x1317d76, 0x1dd06a9, 0x04c21b5,
  48590. 0x0b6ea01, 0x11a8089, 0x0522bc8, 0x1b5fbaf, 0x08ec835, 0x1736508,
  48591. 0x12655c4, 0x099cc53, 0x103d249, 0x0ec02cb, 0x0b70ca3, 0x13b6a79,
  48592. 0x00c3e96, 0x11324a4, 0x0705469, 0x03db02a, 0x05acdfa, 0x1bc365f,
  48593. 0x0f73153, 0x182f7cb, 0x12b553b, 0x1d97791, 0x1617b05, 0x0e85549,
  48594. 0x1f7aca2, 0x0f97442, 0x0c0fbd5, 0x0516b9d, 0x0d58675, 0x07a1a79,
  48595. 0x091d606, 0x1f74ea6, 0x1f69ba2, 0x06ed2df, 0x04f12e0 },
  48596. { 0x1f1a610, 0x1d2110a, 0x0669333, 0x0a6f0ca, 0x004a5c5, 0x01c09a4,
  48597. 0x09151ce, 0x054248d, 0x04b284e, 0x10ada42, 0x144c83e, 0x18ca28d,
  48598. 0x1a36464, 0x1854507, 0x1aea231, 0x1009df6, 0x0e793c4, 0x13a73e7,
  48599. 0x056b85a, 0x09a4597, 0x14dd8c3, 0x0ffce0e, 0x0767b62, 0x004a6e3,
  48600. 0x0866d32, 0x02530d0, 0x0a6f591, 0x0b64656, 0x17bab14, 0x1496793,
  48601. 0x00be223, 0x1528916, 0x1e69c6e, 0x10f65b9, 0x1aa56d4, 0x043492d,
  48602. 0x1858afb, 0x1bc753a, 0x1be46a3, 0x07d624c, 0x083d233 },
  48603. { 0x1b478d7, 0x1994433, 0x1270718, 0x02a145f, 0x01ee1ae, 0x09120dd,
  48604. 0x0acc063, 0x12c0b6d, 0x0893cd6, 0x0f8f944, 0x05ea1da, 0x0cc1502,
  48605. 0x17159d6, 0x18739eb, 0x0480465, 0x0be15d0, 0x10093f5, 0x12947f7,
  48606. 0x01537ec, 0x0f1b71b, 0x1fbbb39, 0x1b7a2ec, 0x15ad0fb, 0x17dc72f,
  48607. 0x04bfed5, 0x0d68bef, 0x05afddb, 0x003c1eb, 0x00754ca, 0x14071ea,
  48608. 0x1cca2c8, 0x1f1d0dd, 0x0db6122, 0x0f2c347, 0x1abedf4, 0x17044d6,
  48609. 0x0f40a55, 0x1a990a9, 0x0588518, 0x07d8b46, 0x07362f1 },
  48610. { 0x1c0c430, 0x1593e39, 0x195de4b, 0x1f4a386, 0x0cc0a65, 0x0ca78dc,
  48611. 0x13b3b48, 0x08ea14b, 0x0814b49, 0x04a2b44, 0x1eefd06, 0x103496d,
  48612. 0x08bbf0a, 0x1855430, 0x1bd3d63, 0x0f2bc6e, 0x1683987, 0x0ec9b0e,
  48613. 0x0ea3435, 0x0219b1c, 0x0455b65, 0x1fdb60d, 0x18f8bf6, 0x19123f2,
  48614. 0x1154eae, 0x1b21648, 0x17fd5a3, 0x1d63ce2, 0x0b399e0, 0x0e6b979,
  48615. 0x02f9ebe, 0x113e17e, 0x1c39bac, 0x01b4a8f, 0x164a426, 0x11e10c3,
  48616. 0x1a0a20a, 0x18b7816, 0x03ab766, 0x07f4718, 0x02f1069 },
  48617. { 0x006ded2, 0x1674886, 0x01ec1e9, 0x1e5fb21, 0x1974842, 0x1b1ad37,
  48618. 0x0ff5aa7, 0x04dc8d1, 0x11ed606, 0x05b0c48, 0x1b95201, 0x113e6d3,
  48619. 0x011fb2f, 0x0e4b510, 0x0f4444f, 0x0675939, 0x0fe10d6, 0x133acd6,
  48620. 0x1ea98a7, 0x14cdf91, 0x028364b, 0x04a3f9c, 0x09a1ab9, 0x139b533,
  48621. 0x03a05d5, 0x1b74146, 0x1023a8b, 0x18f5f62, 0x1953c87, 0x0472579,
  48622. 0x13c9547, 0x13b553c, 0x153d279, 0x18ca02d, 0x0352b5b, 0x163dfed,
  48623. 0x16437cd, 0x1aedeec, 0x0810c9d, 0x1c89fcf, 0x0985f83 },
  48624. { 0x0f45294, 0x01e0b75, 0x1d46258, 0x018496a, 0x1013116, 0x0b5a96b,
  48625. 0x08060e7, 0x0809822, 0x0ed9433, 0x03ce781, 0x106da1c, 0x0516e9e,
  48626. 0x010c5b0, 0x0e4560f, 0x10fc1da, 0x09e1c7b, 0x0a3f8b2, 0x12d62f7,
  48627. 0x0d31708, 0x0d0975c, 0x052aee6, 0x11cd5e2, 0x0949679, 0x1be8b99,
  48628. 0x12cd1e9, 0x07d583e, 0x0c6910f, 0x0e03392, 0x0003b30, 0x0d54c96,
  48629. 0x0b9a3f7, 0x01b1978, 0x19f179c, 0x00e5396, 0x09bc79e, 0x1377e2b,
  48630. 0x10dcc79, 0x0bbceaa, 0x18bc553, 0x0801fd2, 0x00c88e5 },
  48631. { 0x0f44357, 0x18d3574, 0x0daa13d, 0x0c74795, 0x175b4bf, 0x15e3407,
  48632. 0x076796b, 0x1e46699, 0x08a753e, 0x1657842, 0x18f23b3, 0x09820eb,
  48633. 0x1ae2801, 0x1ba7c69, 0x07568e3, 0x0655d77, 0x064b80e, 0x13acc42,
  48634. 0x0af0de4, 0x051cdfe, 0x01977b3, 0x17f7687, 0x1aeec7e, 0x0660cb5,
  48635. 0x0ac955a, 0x07433a7, 0x1e48b6f, 0x1833fb1, 0x1b907a8, 0x1742cc3,
  48636. 0x15e305e, 0x0767459, 0x1f33627, 0x1bb97c4, 0x0067ea1, 0x0dd75d4,
  48637. 0x1a25ced, 0x0ef24c9, 0x01c5539, 0x1715e22, 0x08e2560 },
  48638. { 0x141aba6, 0x1ba3618, 0x1e795b4, 0x1f75659, 0x05a1079, 0x0e93e3a,
  48639. 0x0a0c673, 0x01d6c70, 0x09dfd95, 0x111bb19, 0x1023fc8, 0x0b9a752,
  48640. 0x181e0b1, 0x188b008, 0x0a00802, 0x1774e93, 0x15da383, 0x0938ced,
  48641. 0x14411b5, 0x106814c, 0x1b1f607, 0x0f4ba91, 0x024a753, 0x0145157,
  48642. 0x0345c8e, 0x0e3a020, 0x082b7c2, 0x024eb58, 0x11d6116, 0x1932919,
  48643. 0x142d06a, 0x0a72394, 0x10cc77c, 0x1118a91, 0x124a3e4, 0x13117c1,
  48644. 0x12fd9a2, 0x19ec95c, 0x1cb97fb, 0x0450649, 0x059005f },
  48645. { 0x04c1c74, 0x0ba861e, 0x0de5aec, 0x01d2cdf, 0x1e73aac, 0x02cb9fd,
  48646. 0x176499b, 0x16d0b4e, 0x03a8656, 0x04bfc99, 0x11b37a3, 0x0762a08,
  48647. 0x1f2b704, 0x1ff9c4b, 0x0245bdc, 0x0e564a9, 0x01cb18b, 0x1489ee8,
  48648. 0x0230379, 0x0ea3e29, 0x0a58d0a, 0x0a42ac6, 0x0645d5c, 0x14cc7b4,
  48649. 0x1430144, 0x10c4bb8, 0x12c3821, 0x1be3215, 0x1ead9c2, 0x1e0679c,
  48650. 0x0840203, 0x02e705b, 0x085ac6e, 0x1519c00, 0x0144c98, 0x1bd2f23,
  48651. 0x143bae8, 0x04ac9b5, 0x17dbb91, 0x04daf07, 0x057a78e },
  48652. { 0x0dbddd8, 0x19a37a0, 0x0eb0586, 0x0f28218, 0x0b49a92, 0x03679d9,
  48653. 0x09e0c62, 0x1d718a8, 0x033b93d, 0x16f9919, 0x1d5e75c, 0x13ea81b,
  48654. 0x009c8d5, 0x01077a8, 0x15e99f7, 0x10c87cb, 0x11867f0, 0x1e2359c,
  48655. 0x165ab70, 0x14488b5, 0x04d0ecf, 0x0d8622a, 0x1963d62, 0x1082fae,
  48656. 0x09301e0, 0x1447376, 0x0b11538, 0x194bded, 0x0f462d6, 0x0247d60,
  48657. 0x0d90644, 0x011b140, 0x12407d8, 0x1adbf42, 0x0e9fdb4, 0x0f698a6,
  48658. 0x0f6ada8, 0x08f2094, 0x1cba0c9, 0x18b0388, 0x01ca370 },
  48659. { 0x001b68a, 0x0a8b8d4, 0x02ce52f, 0x19fa333, 0x1312879, 0x0b19013,
  48660. 0x0aafd04, 0x1b6920b, 0x0f5b01f, 0x0ff43fa, 0x084a2ed, 0x047539b,
  48661. 0x1778de5, 0x03de98f, 0x1c58687, 0x0986a17, 0x1d02390, 0x0daef67,
  48662. 0x0623c4b, 0x165105c, 0x0e74224, 0x0efcced, 0x0374a00, 0x19a39a4,
  48663. 0x067b508, 0x11ce56a, 0x170219f, 0x1862387, 0x0250726, 0x0b9015a,
  48664. 0x00dc684, 0x05dfb20, 0x1bf464e, 0x09d81c1, 0x122876f, 0x14a7a08,
  48665. 0x06265ba, 0x0da97a7, 0x0b1e4cb, 0x0989867, 0x02584b3 },
  48666. { 0x0eec688, 0x031c495, 0x148cf2e, 0x148bf7c, 0x05e740b, 0x105afc5,
  48667. 0x1c7dff5, 0x07a845c, 0x0487491, 0x0ae8c2e, 0x1f60351, 0x166df42,
  48668. 0x0404c2b, 0x1602a29, 0x09c6152, 0x14cae7e, 0x045a8b9, 0x03b6e98,
  48669. 0x0bb9f32, 0x0587c2c, 0x07d02e4, 0x0326fb6, 0x000999c, 0x0f96910,
  48670. 0x1dd51dc, 0x1f02c93, 0x1861e25, 0x167f557, 0x15737c6, 0x0917796,
  48671. 0x1fff9ab, 0x1fea353, 0x1b60269, 0x03dd557, 0x1515a60, 0x15c3906,
  48672. 0x151ca49, 0x0edb7fc, 0x0c216b3, 0x0e87f35, 0x07e8113 },
  48673. { 0x10a88b1, 0x11545c1, 0x1f86b5c, 0x119c222, 0x11918ea, 0x04da3ec,
  48674. 0x142e010, 0x1a67c05, 0x16c46d1, 0x09c0969, 0x059a72d, 0x1b61cb1,
  48675. 0x1e2fd09, 0x0ad866a, 0x1173418, 0x188a730, 0x15a2386, 0x1860e0a,
  48676. 0x17fd0f2, 0x0e9bcbe, 0x00cdda7, 0x0c71c8e, 0x0ec1dae, 0x009e50d,
  48677. 0x11eff50, 0x1ff4beb, 0x12bbb02, 0x07c168d, 0x01ad942, 0x0333995,
  48678. 0x08b914e, 0x072db48, 0x00c9f81, 0x195ff7f, 0x06898f6, 0x02c6ed8,
  48679. 0x1a56fa9, 0x0e3c8c5, 0x0169800, 0x0c9bf09, 0x0436b8c },
  48680. { 0x0b764bc, 0x0bf4ec5, 0x1e12204, 0x0940efb, 0x1fa61e9, 0x0c775ee,
  48681. 0x1974c30, 0x1b8b4ee, 0x1fc9451, 0x0448b57, 0x08d1e95, 0x1c660e3,
  48682. 0x1f01a52, 0x191da0e, 0x0ee577a, 0x1850cc6, 0x0c943c8, 0x06ebeb4,
  48683. 0x0365c1a, 0x13a83c3, 0x199de4f, 0x0846493, 0x1e6422e, 0x0e72946,
  48684. 0x0148ed4, 0x09ff30a, 0x1f35479, 0x0a030a2, 0x03dcb6e, 0x03af012,
  48685. 0x0154180, 0x02f2a88, 0x1dcde62, 0x0d2fff2, 0x03854df, 0x0cdef92,
  48686. 0x0768cb6, 0x1bd5720, 0x0578477, 0x13cdb7d, 0x05266ca },
  48687. { 0x186b3db, 0x0f73689, 0x1502137, 0x14f871c, 0x19e4af5, 0x027a4ef,
  48688. 0x01103ac, 0x1fb6683, 0x0fde5a4, 0x09c50f4, 0x15f3f08, 0x1248604,
  48689. 0x013e6e6, 0x0cfeb86, 0x0671b8c, 0x03fe06a, 0x17486c3, 0x0479a70,
  48690. 0x103387a, 0x0531fb2, 0x0d7cf1e, 0x0e8a4b0, 0x1bee32c, 0x05e77fe,
  48691. 0x013472b, 0x07f903e, 0x1051bbe, 0x1334416, 0x13e2208, 0x1b15bde,
  48692. 0x09df7b0, 0x0c4d7d4, 0x175044e, 0x065b3d4, 0x11253ed, 0x141e656,
  48693. 0x1fc6703, 0x1d04900, 0x128af05, 0x17339b0, 0x041f325 },
  48694. { 0x02843a4, 0x16a89e7, 0x0bf0c4b, 0x1c00e51, 0x0748498, 0x032672f,
  48695. 0x0a08936, 0x07751de, 0x0a62008, 0x0032382, 0x14ce34d, 0x03b297d,
  48696. 0x185905e, 0x031f3d9, 0x15e32d4, 0x0f77254, 0x196289e, 0x0cc13b6,
  48697. 0x05edcd0, 0x05b88fe, 0x0944dfe, 0x0f8ed64, 0x1648d48, 0x080154e,
  48698. 0x0d28d23, 0x1219edb, 0x1a9d86e, 0x0c8ee0b, 0x1d07ddc, 0x1d36cdf,
  48699. 0x1f6251e, 0x0485951, 0x0f2e3ac, 0x01a3400, 0x19c3ae3, 0x1a93de8,
  48700. 0x19aa18f, 0x19e9bde, 0x1aa79f6, 0x16dcb19, 0x056b30f },
  48701. { 0x180a428, 0x06e5566, 0x02441fb, 0x190e659, 0x1af922d, 0x0d220fb,
  48702. 0x01e60eb, 0x11441b1, 0x0924b00, 0x1f6cd22, 0x0070e8e, 0x067965d,
  48703. 0x1321235, 0x12fc03e, 0x13901d5, 0x15d9786, 0x1a51f2f, 0x085fd77,
  48704. 0x17a2a23, 0x0c694b5, 0x0a9178b, 0x1c4a1c9, 0x11382df, 0x17639b1,
  48705. 0x0237790, 0x0571849, 0x0be1c81, 0x1d5369f, 0x13cd83d, 0x00fac2e,
  48706. 0x1e4fb7e, 0x18ca474, 0x0f88c51, 0x06cb4ac, 0x0e2c5f0, 0x0fc8e5f,
  48707. 0x1ccf7f0, 0x0840f2e, 0x1451a26, 0x0aeb17b, 0x01353cc },
  48708. { 0x1bf6e18, 0x0b24b9c, 0x071ca29, 0x04c9371, 0x19e8b5a, 0x145c73a,
  48709. 0x0d28373, 0x0191b28, 0x1204704, 0x09adfa8, 0x0e3a0b6, 0x02c8d4f,
  48710. 0x142ab3a, 0x13fc094, 0x160fb58, 0x0e52fe2, 0x1e072d6, 0x1c20b53,
  48711. 0x14e790a, 0x10bb0d9, 0x1bad496, 0x03cac6e, 0x029e5ff, 0x0b9cdbd,
  48712. 0x0f92815, 0x11ad2ac, 0x03e28d8, 0x0be9cae, 0x077ae57, 0x07e0294,
  48713. 0x0f6f1a7, 0x14d62dd, 0x14193a9, 0x060f8c7, 0x10f2ec7, 0x131a3be,
  48714. 0x1a21e78, 0x1d41872, 0x17d61c8, 0x0bbe8a3, 0x03ec218 },
  48715. { 0x10bc2d7, 0x063eb8f, 0x104ae75, 0x18dca3a, 0x0982c6c, 0x0fc07b3,
  48716. 0x0b64e82, 0x13925c0, 0x1047ae0, 0x1ee9692, 0x0d47e6d, 0x093e6fe,
  48717. 0x1e35031, 0x03bc285, 0x1527387, 0x1a590d3, 0x0cb12f0, 0x0b01215,
  48718. 0x0f0a2e7, 0x1118acf, 0x0550ba1, 0x10835e0, 0x0390184, 0x0fa8653,
  48719. 0x04b1f8d, 0x0f0586c, 0x1f4e254, 0x094cf5c, 0x097607b, 0x02bdc5e,
  48720. 0x1cad49f, 0x0a92f54, 0x093c5f3, 0x0eb335e, 0x0330e6f, 0x06be3bd,
  48721. 0x09d447a, 0x03ee2e7, 0x0af94c2, 0x16d4423, 0x089b356 },
  48722. { 0x1dcc837, 0x0d857ef, 0x1ea7b5b, 0x1550e36, 0x0fb80ba, 0x0ea5b90,
  48723. 0x0ff2470, 0x0b88275, 0x1adac9e, 0x0dab5fb, 0x195e8fd, 0x05b5170,
  48724. 0x0e5664a, 0x0720eca, 0x0c13dc8, 0x06cb023, 0x1263743, 0x131f08e,
  48725. 0x109b6ba, 0x051d9de, 0x0dc2ee6, 0x04e58b1, 0x0045867, 0x0c90c86,
  48726. 0x1817f87, 0x0434e7a, 0x095612f, 0x03772e0, 0x1f7928e, 0x1e77805,
  48727. 0x194b309, 0x1b8c1dd, 0x0f3a80e, 0x0e17ca7, 0x0afa1eb, 0x04fc240,
  48728. 0x0a0d4f5, 0x178c704, 0x1449995, 0x01aaf8b, 0x039c4f1 },
  48729. { 0x08aecd3, 0x0db4674, 0x0a76cea, 0x114a315, 0x155b091, 0x0a772a2,
  48730. 0x136b52f, 0x109db83, 0x102068d, 0x0db45b3, 0x0b1cb5e, 0x01a1023,
  48731. 0x187dac8, 0x140d053, 0x079b4d6, 0x0c506da, 0x1ea3bd1, 0x06420f4,
  48732. 0x0531111, 0x182eeb1, 0x1202a7b, 0x12f8d50, 0x1cad8dc, 0x1a98aad,
  48733. 0x1767ec7, 0x08ddf63, 0x0f51bfd, 0x102fd76, 0x17e3392, 0x1f46b9f,
  48734. 0x113f796, 0x0b5da49, 0x0c6c977, 0x0bce7a2, 0x1c1edb9, 0x1817342,
  48735. 0x1069fbc, 0x18b23c4, 0x0ac033f, 0x05a922a, 0x0414b54 },
  48736. { 0x06e173b, 0x18f2c30, 0x04e8cf0, 0x1721cce, 0x1b7f4e1, 0x1d9057a,
  48737. 0x0d44b7a, 0x0e084bf, 0x105120e, 0x1c4630b, 0x0f93b31, 0x0c05202,
  48738. 0x173ef05, 0x00e3736, 0x074d6b2, 0x0d2153f, 0x08f9450, 0x17098f4,
  48739. 0x12bc20b, 0x1f36648, 0x0ea9708, 0x160dd15, 0x0cb9359, 0x01b6539,
  48740. 0x14a6e74, 0x003d78f, 0x034610c, 0x0957249, 0x156a6c7, 0x077c76a,
  48741. 0x0984cce, 0x04e1a2f, 0x08e623e, 0x07adffa, 0x0bea582, 0x0a78e6c,
  48742. 0x044e851, 0x0bbc3a2, 0x02ca90e, 0x0d5c017, 0x052678d },
  48743. { 0x136aeb4, 0x18e2cef, 0x02ad77f, 0x1952578, 0x12d6653, 0x1d2fc0a,
  48744. 0x1d25a49, 0x03e1c07, 0x02dfd49, 0x084ea0a, 0x07e26e1, 0x18a54ae,
  48745. 0x05258c2, 0x0999a24, 0x1586012, 0x13c1257, 0x14f3f7d, 0x10d19f4,
  48746. 0x106fe41, 0x0831a65, 0x095cfab, 0x072d52b, 0x1ce7124, 0x1a5afff,
  48747. 0x1196ef6, 0x0548720, 0x143de52, 0x1d9a80e, 0x053b4f3, 0x1cd9698,
  48748. 0x1252d63, 0x0bb32e9, 0x0ee842a, 0x17b415c, 0x1076fc8, 0x0c474b3,
  48749. 0x08efcea, 0x0d630a6, 0x1bb7411, 0x0b78219, 0x07040ba },
  48750. { 0x15a1a96, 0x127c0a8, 0x1f80b0d, 0x0630864, 0x11a6350, 0x0c9ea79,
  48751. 0x199406b, 0x0e61412, 0x1273b61, 0x0bb4a78, 0x16a74a7, 0x10eda59,
  48752. 0x178886d, 0x140a60b, 0x0069d08, 0x0d2d63c, 0x16b8667, 0x11a4913,
  48753. 0x0c97c01, 0x09e18cb, 0x0c4a2fd, 0x0ffd94a, 0x1949cd2, 0x03a66de,
  48754. 0x00d8ade, 0x10760ff, 0x039f8e1, 0x1f3447d, 0x14c31ea, 0x1b90dbb,
  48755. 0x12a5f4a, 0x086caf0, 0x0c3e582, 0x07551fd, 0x1d39c3d, 0x11fe5bf,
  48756. 0x1e87324, 0x140f0d7, 0x12704f4, 0x1ac17a3, 0x09043a6 },
  48757. { 0x06c7937, 0x0d07f3b, 0x0f8c544, 0x1957787, 0x1b2ded5, 0x0444560,
  48758. 0x1833380, 0x1e65582, 0x1616200, 0x143aa5e, 0x0ba81a4, 0x107a694,
  48759. 0x0fb801c, 0x0e5f083, 0x15e80ea, 0x19b2915, 0x022cedf, 0x04cb584,
  48760. 0x101a620, 0x068c75c, 0x1663c3c, 0x06facbf, 0x1ec4ba9, 0x19255f3,
  48761. 0x1383440, 0x0aa1646, 0x193a368, 0x13790b8, 0x0e801a7, 0x0fd16da,
  48762. 0x0ca55dc, 0x03c6af3, 0x1d2c138, 0x1683c3d, 0x177ffea, 0x0dc8b8e,
  48763. 0x173eac4, 0x1b051e5, 0x17cd6c1, 0x0907424, 0x026362b },
  48764. { 0x0fc3e89, 0x1469477, 0x19c4971, 0x0ed3d3d, 0x0d0ee87, 0x0f25ba9,
  48765. 0x0ee1abd, 0x067160f, 0x0cb86b3, 0x1b84839, 0x14aeb36, 0x01d5fea,
  48766. 0x09fd3d2, 0x0606d0f, 0x1bacac5, 0x0e28b4b, 0x08a44f9, 0x09c8fb4,
  48767. 0x181b521, 0x17a6203, 0x0d4921f, 0x12df54e, 0x11793ca, 0x17e43b4,
  48768. 0x0d464a7, 0x038bdb0, 0x0015355, 0x127f119, 0x00f2e91, 0x09e8df7,
  48769. 0x1cd6b39, 0x1828724, 0x0c26563, 0x15af749, 0x02ca5b1, 0x15390dc,
  48770. 0x09ff59b, 0x17f1188, 0x04d7914, 0x040aab9, 0x02e952b },
  48771. { 0x15f886e, 0x035e56b, 0x1160aa1, 0x1da87bf, 0x068a5db, 0x1d8dc37,
  48772. 0x116d801, 0x16a207c, 0x1355ff2, 0x0071764, 0x0fb3256, 0x1e4d44c,
  48773. 0x13bc702, 0x0c0f2f1, 0x0d6ce18, 0x040ec50, 0x1ec6c12, 0x0812889,
  48774. 0x1ef615b, 0x04dc74f, 0x1cb1a5c, 0x19ceb75, 0x03be0fe, 0x09a5f51,
  48775. 0x053f2a4, 0x14bbd55, 0x0d4ec7e, 0x1829de6, 0x159a307, 0x05088ba,
  48776. 0x183fd81, 0x16126ef, 0x1cd96b0, 0x1813995, 0x025b6cb, 0x0d4b829,
  48777. 0x0b53ef0, 0x054264f, 0x0392c70, 0x02e606f, 0x01236d0 },
  48778. { 0x084373b, 0x00e47e0, 0x1ebb5d2, 0x10c8c12, 0x09ae476, 0x1de1a59,
  48779. 0x17e8184, 0x1602601, 0x0934bc2, 0x18938a6, 0x0f9f88d, 0x0c521c5,
  48780. 0x0086524, 0x1680840, 0x13eee7f, 0x08aecaa, 0x1384231, 0x1787605,
  48781. 0x0c28ca0, 0x15eb286, 0x181765b, 0x1438377, 0x0ef7786, 0x0ea61d2,
  48782. 0x0727dba, 0x0e5be96, 0x19d3325, 0x1618bac, 0x18906db, 0x09b2921,
  48783. 0x1cecff3, 0x1a28cb1, 0x1881941, 0x1f8748c, 0x1555b25, 0x15cc2de,
  48784. 0x0b9ec7e, 0x1e16c2a, 0x0d5b8d4, 0x028c419, 0x002a480 },
  48785. { 0x06ccd38, 0x1691ea8, 0x0a98475, 0x0920b37, 0x029a1c5, 0x0808e29,
  48786. 0x0709da7, 0x0fae2f9, 0x0d82893, 0x03f0da3, 0x0d420fa, 0x1777070,
  48787. 0x18f5d63, 0x156d612, 0x09ed09e, 0x09a3fe1, 0x0bd9f15, 0x0ccd593,
  48788. 0x1b2557f, 0x01ff7f1, 0x1880dec, 0x13a4fe5, 0x1ba55f1, 0x00229bd,
  48789. 0x15dee1e, 0x163991c, 0x1cda7d1, 0x1254c96, 0x0b25991, 0x033048f,
  48790. 0x1690c11, 0x145d187, 0x02da887, 0x0b68c5f, 0x10970d5, 0x07489c5,
  48791. 0x155f75f, 0x1c820a5, 0x1ff80c4, 0x0df1e42, 0x01d8bde },
  48792. { 0x0028924, 0x09cfc51, 0x0e7c0f3, 0x1960dd9, 0x0e54f19, 0x182c233,
  48793. 0x0f2df5b, 0x0ed0c57, 0x05a0607, 0x1f0338b, 0x1fb0436, 0x12f5621,
  48794. 0x1c9397c, 0x178ddb2, 0x084e099, 0x17471e8, 0x0cba672, 0x120a6f6,
  48795. 0x022c179, 0x1a9a87f, 0x14d1594, 0x1d564a6, 0x1e64fd5, 0x162ec70,
  48796. 0x02a6abf, 0x0ad3a7e, 0x0edbf19, 0x1032d6b, 0x0d2139d, 0x0e42774,
  48797. 0x09b70dd, 0x06c1a74, 0x1b00a02, 0x09dc3dc, 0x0d737ae, 0x1d66dda,
  48798. 0x0c83209, 0x12d945e, 0x04f07d5, 0x0878c20, 0x0349c69 },
  48799. { 0x1e6c88a, 0x1ca2226, 0x01fb46c, 0x028e004, 0x15c2c47, 0x015bc06,
  48800. 0x1628887, 0x07d6de8, 0x0085099, 0x04fbab2, 0x1c3061d, 0x0af375d,
  48801. 0x10400ba, 0x19be387, 0x1d0a4e1, 0x0fd7e5a, 0x0ec2146, 0x1e2d471,
  48802. 0x0cdfd14, 0x14ccdca, 0x150a243, 0x03f685e, 0x12647c7, 0x17a3f23,
  48803. 0x13e90f4, 0x14d9d3f, 0x097c384, 0x0c113d1, 0x1896359, 0x10bb839,
  48804. 0x127434e, 0x04e3055, 0x0f842d5, 0x1e2e14e, 0x0a64205, 0x124232a,
  48805. 0x0725576, 0x17993f4, 0x163ea8c, 0x1571385, 0x0056587 },
  48806. { 0x0e4733d, 0x0b1768e, 0x1110021, 0x1731ca2, 0x1faff7c, 0x15a35ca,
  48807. 0x0087ea6, 0x026be06, 0x0b61a8c, 0x0a4a62f, 0x0d65da2, 0x006c6d6,
  48808. 0x1657c95, 0x1561697, 0x1a1323c, 0x0e07cd7, 0x0d89bd2, 0x1872d9a,
  48809. 0x1a1caae, 0x1b231ef, 0x0ee1c4a, 0x0fe2029, 0x10aa27a, 0x1216a3d,
  48810. 0x0ee3f31, 0x0a7e165, 0x1dbffc9, 0x11fa286, 0x1e09725, 0x06b4441,
  48811. 0x0e1bcf0, 0x01f62a8, 0x1d0a0e9, 0x1570031, 0x192fdb2, 0x198870e,
  48812. 0x1f1d0f6, 0x0f8ab29, 0x16f7a05, 0x1db70d9, 0x01b87f2 },
  48813. { 0x10b15b1, 0x095dd95, 0x1de4d5e, 0x0f9cd74, 0x03e4b5a, 0x079bbcd,
  48814. 0x1ff6776, 0x1dff759, 0x1c298d1, 0x02a285e, 0x00c7180, 0x0aad88e,
  48815. 0x060e3f5, 0x0aeb403, 0x1c3c1ea, 0x0a5840e, 0x0e02d10, 0x0671f42,
  48816. 0x0aa3315, 0x00f23cf, 0x03a3b05, 0x19dd191, 0x1358879, 0x0c65320,
  48817. 0x1b94d39, 0x0b6c3dc, 0x1dfae01, 0x1bf3968, 0x1ca0cc8, 0x06f476f,
  48818. 0x12b890c, 0x12e2541, 0x14bf416, 0x0454c9b, 0x11de221, 0x1d7c7e7,
  48819. 0x04a3e59, 0x15c3d8e, 0x0f08ec8, 0x1887d2b, 0x08e0227 },
  48820. { 0x010964d, 0x1115419, 0x1bac003, 0x0bfe0ad, 0x1ccd5df, 0x18f56be,
  48821. 0x0e87f6b, 0x1c6042e, 0x067cdca, 0x01419f0, 0x1324334, 0x099717b,
  48822. 0x151cc57, 0x19125a7, 0x1b29c50, 0x105310d, 0x03abb3f, 0x1e80730,
  48823. 0x106a37a, 0x1d9c361, 0x061db98, 0x121bc61, 0x08a291b, 0x02cbcba,
  48824. 0x1dd0da6, 0x071637c, 0x052dfbc, 0x075c713, 0x09f306b, 0x0b59ded,
  48825. 0x16ce8f0, 0x0714109, 0x09a26d3, 0x074a82f, 0x064d4e5, 0x18a51cb,
  48826. 0x0ea206b, 0x076588a, 0x175ba12, 0x16a80a8, 0x014b15a },
  48827. { 0x04c59a2, 0x0c364b3, 0x0a943db, 0x02c1faf, 0x1dfe2be, 0x1965c71,
  48828. 0x0d5a641, 0x1c067f3, 0x18176a7, 0x19192ec, 0x1c202d7, 0x09ce8b0,
  48829. 0x0579a0d, 0x06aea70, 0x1b837bc, 0x051c349, 0x1fac87b, 0x16056cf,
  48830. 0x1c26d3b, 0x031a5e7, 0x1d87d6f, 0x1394974, 0x13225ab, 0x128ec79,
  48831. 0x0953d60, 0x0fd6544, 0x0063efe, 0x17dd2f5, 0x03d701d, 0x1074a5b,
  48832. 0x0bf7c83, 0x08fd4e4, 0x1ba6e30, 0x1ab8fe5, 0x072984a, 0x0b9cafc,
  48833. 0x009a55f, 0x0b563b0, 0x078b878, 0x1b18871, 0x0742bbe },
  48834. { 0x1dc2c73, 0x1436e60, 0x0afc8fa, 0x1782c87, 0x0bbbfd5, 0x0c650fa,
  48835. 0x1e87c93, 0x18e0ff1, 0x08cb5ca, 0x1345370, 0x19a9f77, 0x0c96a9c,
  48836. 0x187d54c, 0x14dbd6b, 0x076e88a, 0x15728f1, 0x140e364, 0x0a6c46a,
  48837. 0x1dcb804, 0x05c05a3, 0x0278c8c, 0x0ba3715, 0x1320981, 0x030f8fa,
  48838. 0x15bb34b, 0x064f361, 0x1bae3f8, 0x1b167bf, 0x11e415e, 0x1a743e8,
  48839. 0x1e6daf0, 0x170cb8f, 0x1908bbf, 0x060be59, 0x139b87b, 0x16e2fa3,
  48840. 0x17cdd69, 0x0f19847, 0x1049054, 0x0296b92, 0x097bd5a },
  48841. { 0x1e82861, 0x0317f40, 0x103b807, 0x1bba858, 0x103d4b6, 0x0f48f2b,
  48842. 0x1956f99, 0x1bafca5, 0x05abbbf, 0x05a49ba, 0x0917d2e, 0x1ea58e5,
  48843. 0x18b4f15, 0x0a8794e, 0x010d6a1, 0x1cebf9d, 0x19b582d, 0x14efbb5,
  48844. 0x08322e5, 0x1098bf4, 0x0af452e, 0x0885450, 0x0bddf4b, 0x0c02787,
  48845. 0x1bbd8ca, 0x02f81c4, 0x089be0c, 0x01b3737, 0x0c8b9ab, 0x1424067,
  48846. 0x063c14f, 0x1ff57b4, 0x163367a, 0x1261526, 0x0f92990, 0x1ca1ea7,
  48847. 0x064fba2, 0x0962c64, 0x151a7e2, 0x0629198, 0x0317c6d },
  48848. { 0x0b7d42b, 0x092d816, 0x12b830d, 0x12621f5, 0x15240bc, 0x102047a,
  48849. 0x0808bfc, 0x1411aba, 0x1e0c10e, 0x180a017, 0x1ac8f5a, 0x0d14e31,
  48850. 0x197fbef, 0x0092950, 0x051ad69, 0x01add40, 0x048110e, 0x0acd7e7,
  48851. 0x08b7860, 0x03a4fe0, 0x09dae9a, 0x0b6e1fa, 0x1b6e5b4, 0x17c8010,
  48852. 0x0e3f5ef, 0x08e7e0d, 0x07b32f0, 0x13ae0c8, 0x1f8636f, 0x113ca92,
  48853. 0x0c12408, 0x184ec78, 0x169796a, 0x031859b, 0x00f0764, 0x0f39869,
  48854. 0x0e3d3f1, 0x0b28f87, 0x0e3f514, 0x0733b41, 0x06ae597 },
  48855. { 0x1f4d2ee, 0x09de3df, 0x0f615ec, 0x126162e, 0x0075422, 0x0a49b61,
  48856. 0x12f541e, 0x17d6c4a, 0x05efd55, 0x0af9195, 0x10ce247, 0x150a9c1,
  48857. 0x04c06f4, 0x0730fca, 0x0b16d66, 0x10f6f9e, 0x01ffd5f, 0x062b243,
  48858. 0x08abe93, 0x0c3f62b, 0x0774ee2, 0x1316cbd, 0x0c3fdc8, 0x19e00f5,
  48859. 0x1ae22d6, 0x10a0d44, 0x134d1bc, 0x11100a6, 0x16497e2, 0x1dffcbd,
  48860. 0x1f23f9c, 0x1f455ff, 0x08595b2, 0x0d39345, 0x1cfbc54, 0x173df39,
  48861. 0x0744b82, 0x0772f8f, 0x1f9caa1, 0x11b78c7, 0x0664904 },
  48862. { 0x08b760d, 0x1ddbc0f, 0x0a8246d, 0x104b55b, 0x147b0bd, 0x1a9137e,
  48863. 0x0f67fea, 0x11d0292, 0x0bffc14, 0x136e913, 0x0f8f6d2, 0x1f15453,
  48864. 0x0b5a032, 0x1a58558, 0x036f1c0, 0x090d063, 0x1b57d65, 0x16e665f,
  48865. 0x1160791, 0x0d566f3, 0x0ce2850, 0x1714187, 0x0244da9, 0x0d9018e,
  48866. 0x19356cf, 0x143245b, 0x1fbdac7, 0x142ec6e, 0x10f1c9f, 0x0e60c1f,
  48867. 0x174b270, 0x02d57db, 0x0f0526d, 0x186f24b, 0x038aa4e, 0x147c1d3,
  48868. 0x0f13873, 0x16bd6d0, 0x127b1bc, 0x0b9e7f4, 0x04eb93b },
  48869. { 0x11fae32, 0x0fbf2f0, 0x1d46f62, 0x0b88047, 0x113d74f, 0x0e1fb7e,
  48870. 0x0537d24, 0x16e3600, 0x1555279, 0x0c24d2b, 0x0801a07, 0x112e0b7,
  48871. 0x0abb9e8, 0x009e516, 0x0889067, 0x0cedf04, 0x085fd33, 0x157dddb,
  48872. 0x161e28a, 0x187ea4e, 0x1173931, 0x17f79ea, 0x04abbbf, 0x114d0f0,
  48873. 0x05cc8bd, 0x00b0c4d, 0x0f667c3, 0x059ffb6, 0x1d48b68, 0x0a0350c,
  48874. 0x182fd59, 0x1d38d89, 0x005e223, 0x020b92b, 0x077a1a0, 0x10a7cf0,
  48875. 0x07001cc, 0x1ae485e, 0x0fda337, 0x126f808, 0x02b582d },
  48876. { 0x1abc2ae, 0x12e4140, 0x1b2a845, 0x0bc56d3, 0x073380f, 0x1ffb37d,
  48877. 0x0cf481f, 0x00d812f, 0x0547765, 0x0b01c13, 0x1e88717, 0x13e76af,
  48878. 0x15dcbac, 0x04c6dee, 0x1d436d3, 0x1e654f0, 0x103d9ef, 0x042f108,
  48879. 0x1c47107, 0x1a2e585, 0x0c09cee, 0x124f1a4, 0x0a38e49, 0x03dbbf7,
  48880. 0x1936b83, 0x051b8e5, 0x1bd4219, 0x02b87a0, 0x1acfcd9, 0x19e6f49,
  48881. 0x0abfa38, 0x167e5ef, 0x1ee10d7, 0x0774d25, 0x0d23adf, 0x1b83b1d,
  48882. 0x1a574af, 0x124e71f, 0x0d3013e, 0x0130c5b, 0x0786151 },
  48883. { 0x0e72c21, 0x1fa403d, 0x1694ff8, 0x09fa1e1, 0x031aa14, 0x01d22a3,
  48884. 0x187a3e3, 0x1578edd, 0x051b4f1, 0x1cd704a, 0x16ec90d, 0x072faf9,
  48885. 0x0d2a3a4, 0x015eafe, 0x0533ffa, 0x1deb4f4, 0x112f427, 0x1ddf276,
  48886. 0x0134f33, 0x1487dc5, 0x0e1e9b0, 0x09c7763, 0x15ede2e, 0x171d0f6,
  48887. 0x004e467, 0x0100c6a, 0x14d0dd3, 0x1915b80, 0x08deb50, 0x1b02aa1,
  48888. 0x13d90dc, 0x1875f45, 0x0d80ec0, 0x0ab7cda, 0x04f0eaa, 0x10daa3f,
  48889. 0x04161c6, 0x0d1455c, 0x100967e, 0x16ed793, 0x0540b6b },
  48890. { 0x01d315d, 0x0b9a619, 0x1740138, 0x05b0dc0, 0x0ef5661, 0x1466c0a,
  48891. 0x18516ee, 0x135d5f5, 0x1acdc78, 0x1d83d24, 0x1d5c3c7, 0x135ab0e,
  48892. 0x1e6a21e, 0x1cde29e, 0x12a0dfa, 0x131d65c, 0x0931d62, 0x0a1b6d9,
  48893. 0x08d8bd1, 0x1f78f1d, 0x058543a, 0x0bd55fb, 0x0aa5cf6, 0x1249ac0,
  48894. 0x1dabe0c, 0x074ee73, 0x01f2b7c, 0x0d3b31e, 0x020538f, 0x02d0ba8,
  48895. 0x0a782d4, 0x088c39a, 0x1b7d1a3, 0x0740c1e, 0x1dd9788, 0x0dc3850,
  48896. 0x12dd50f, 0x112c33a, 0x0e230b2, 0x02925c0, 0x0897cab },
  48897. { 0x18bab8a, 0x09c0986, 0x002967b, 0x1948704, 0x011d364, 0x0c0a0ae,
  48898. 0x0fcb101, 0x0e80d0f, 0x07ac896, 0x156869d, 0x1046821, 0x020b72e,
  48899. 0x1c44928, 0x19c19b8, 0x0612c47, 0x1063ce9, 0x1840d1a, 0x0386976,
  48900. 0x1244bf8, 0x06c516d, 0x08d2d88, 0x1d8a7d4, 0x113e3df, 0x015927c,
  48901. 0x12a4dcf, 0x1d32b27, 0x0a9b093, 0x05ec535, 0x0cd9498, 0x15d1dfb,
  48902. 0x0b6ae41, 0x0414a30, 0x0822e67, 0x1c9d296, 0x16b0c3a, 0x145fe8f,
  48903. 0x1ff673a, 0x1162527, 0x03b1771, 0x0c68ed6, 0x064b007 },
  48904. { 0x1c9a404, 0x1a99f59, 0x054878f, 0x076fdf3, 0x11db7f7, 0x129b49d,
  48905. 0x0f8a5b0, 0x1a98fe2, 0x00738ee, 0x073fa62, 0x1b2b41f, 0x16679c4,
  48906. 0x11ccfd3, 0x00f62e7, 0x1e124d4, 0x09c03b0, 0x09ddc08, 0x19fc7e0,
  48907. 0x0e6d6b3, 0x1956658, 0x151c217, 0x1dcf7aa, 0x10b6bc2, 0x042f52a,
  48908. 0x16f56e1, 0x0157de3, 0x0b08dc0, 0x002f162, 0x10a2938, 0x01cfd83,
  48909. 0x1902d4b, 0x0aed952, 0x1925153, 0x1471b71, 0x1090675, 0x084aab2,
  48910. 0x09e50e8, 0x0fdc160, 0x1b630a4, 0x14ccc31, 0x07dd22e },
  48911. { 0x1cbb3bf, 0x14225a4, 0x0c95fff, 0x08aac5f, 0x1e0cc70, 0x0d422d6,
  48912. 0x194de7d, 0x1f83cdd, 0x0e51277, 0x0b6bf93, 0x0d5c625, 0x097260c,
  48913. 0x142c75d, 0x0b4abf9, 0x085224a, 0x0e85673, 0x13282e5, 0x1467a75,
  48914. 0x0c91edc, 0x1a7bbb0, 0x02376b0, 0x19900d2, 0x19ea7d8, 0x029490a,
  48915. 0x003c114, 0x08b20b2, 0x1edbdaa, 0x015fa88, 0x06f7906, 0x04986d6,
  48916. 0x00a57e5, 0x17a773b, 0x05ff94b, 0x16f87b4, 0x03f1472, 0x12b91f3,
  48917. 0x113b748, 0x0ce4455, 0x1f32255, 0x0ccbe31, 0x031377c },
  48918. { 0x1cfb35f, 0x0ef04be, 0x1be0d71, 0x1e03986, 0x0dccca9, 0x1b65b19,
  48919. 0x1a175d5, 0x0eafd27, 0x0f7b4b3, 0x016ea45, 0x0866d43, 0x1a9f613,
  48920. 0x079d95c, 0x18dff30, 0x0bb4565, 0x1b5a4ea, 0x0cf2596, 0x1a1cc40,
  48921. 0x07a429b, 0x1df6a6d, 0x060ae52, 0x1181e9f, 0x11025d9, 0x0a0e1c0,
  48922. 0x164faa9, 0x0e97e79, 0x1815893, 0x11f3276, 0x15e467d, 0x0c12006,
  48923. 0x092cd6a, 0x0191e8a, 0x089d024, 0x100bcf1, 0x08f1922, 0x1bde8a8,
  48924. 0x187edab, 0x0feb4aa, 0x149c4e9, 0x019423c, 0x03dacc5 },
  48925. { 0x099ae4c, 0x127ca32, 0x149f2cf, 0x02e0a78, 0x046dcbe, 0x1c17455,
  48926. 0x173a6f9, 0x08b00fe, 0x0d8481e, 0x1632694, 0x01bf42d, 0x0a31545,
  48927. 0x09f35e4, 0x0f8e6da, 0x0dee6eb, 0x07d5fef, 0x010aec2, 0x1f9fdb1,
  48928. 0x06ff4be, 0x17470b7, 0x13a00a9, 0x09c403f, 0x1946835, 0x0f65085,
  48929. 0x04404b1, 0x1853d59, 0x1fe7767, 0x1faaed0, 0x09df646, 0x1eda79f,
  48930. 0x137347b, 0x0c1be32, 0x1d2df7a, 0x0ef82ae, 0x0b0f81a, 0x037da7e,
  48931. 0x03248a3, 0x0dbab09, 0x113dd1a, 0x1c2d28e, 0x0866949 },
  48932. { 0x14ab07a, 0x106d29f, 0x1efcea6, 0x07ea94d, 0x0cd6f33, 0x1e79481,
  48933. 0x1a486c8, 0x0b01925, 0x0848e3d, 0x0ac0e1f, 0x0862af2, 0x1f7ba76,
  48934. 0x1793af1, 0x03365a6, 0x1663a84, 0x0074070, 0x14e990c, 0x0a8009c,
  48935. 0x1421ded, 0x0c963cf, 0x10913b6, 0x1deba63, 0x15e76c6, 0x05abba1,
  48936. 0x144354e, 0x1c14296, 0x0ccca76, 0x1a57083, 0x16d4800, 0x07583dc,
  48937. 0x11bea11, 0x1852bb8, 0x1a50569, 0x1f6271b, 0x0dce53d, 0x0f85a70,
  48938. 0x1b08317, 0x1c427fa, 0x0966370, 0x171163f, 0x0574352 },
  48939. { 0x15d7ce9, 0x0c9fb86, 0x1abfb48, 0x0c1690f, 0x1c19fd2, 0x132fe81,
  48940. 0x0ad65ef, 0x0acf889, 0x078270d, 0x0ced430, 0x1c06637, 0x1801754,
  48941. 0x1f8a84e, 0x142cc2e, 0x109f924, 0x051b05d, 0x0f0de20, 0x0ccb665,
  48942. 0x0708807, 0x0c918ec, 0x19eb4e7, 0x1e048e0, 0x0a58cd6, 0x1acf057,
  48943. 0x03a69f0, 0x049929d, 0x034a519, 0x1e40868, 0x1f68733, 0x10d084c,
  48944. 0x0691114, 0x0d32c02, 0x1cbcc09, 0x1d4a72f, 0x1763e14, 0x027109a,
  48945. 0x13b6a3a, 0x0c63126, 0x0f13c90, 0x1e40d5c, 0x03e431a },
  48946. { 0x1d381f1, 0x1ec9cc1, 0x0f0fe59, 0x1da1806, 0x16501aa, 0x0083b41,
  48947. 0x1d34151, 0x1a77e75, 0x05093a6, 0x0368acc, 0x1ca402a, 0x0e83b25,
  48948. 0x1543ae0, 0x1b785ba, 0x0cabe98, 0x0dadffd, 0x0a3aa45, 0x1684853,
  48949. 0x1bf6d91, 0x149fb55, 0x0f7d336, 0x020d4a1, 0x1f46ff9, 0x03dc83d,
  48950. 0x0a3ed85, 0x0e2bfe1, 0x1847a4d, 0x1e392d0, 0x1bb3434, 0x1b3329d,
  48951. 0x0ab355d, 0x15b12d8, 0x06931ba, 0x1fd20f9, 0x0f461ae, 0x03141f7,
  48952. 0x0203cef, 0x1ebec15, 0x134d470, 0x02bc4cc, 0x06dad3f },
  48953. { 0x0ec35a1, 0x005be89, 0x04a3465, 0x0dcfbf6, 0x0219c5b, 0x1990eab,
  48954. 0x1e31bc4, 0x16c5984, 0x033c58e, 0x13b4825, 0x00f10d7, 0x1eabb32,
  48955. 0x1915090, 0x01ecb50, 0x06f249b, 0x1974e0c, 0x1038c0a, 0x1cba54f,
  48956. 0x0662c86, 0x028042e, 0x0c6f7a4, 0x0efc4ac, 0x0c1a566, 0x17a0253,
  48957. 0x12f1dbe, 0x0e1a8bf, 0x0f7cea3, 0x02134c2, 0x0375c51, 0x0224339,
  48958. 0x14c2396, 0x12707a5, 0x0590ba4, 0x1c1be2b, 0x1f182ff, 0x1ff87dc,
  48959. 0x07d2d55, 0x1d29c81, 0x1e8ff21, 0x1a8bea2, 0x02438e9 },
  48960. { 0x015af3c, 0x0298444, 0x1b57129, 0x05e7937, 0x055f1a3, 0x1b2eeff,
  48961. 0x137265e, 0x16b5de3, 0x012e51e, 0x0e30eca, 0x1c92418, 0x18a9cc7,
  48962. 0x11bd0da, 0x0859f11, 0x0510a73, 0x0c020de, 0x1c2f1da, 0x0fb9be1,
  48963. 0x0ef13ec, 0x01c096d, 0x01cb715, 0x048df14, 0x0816d32, 0x0e03eb6,
  48964. 0x0633cd7, 0x04878da, 0x18a944d, 0x1667de8, 0x11f7f28, 0x1e39b47,
  48965. 0x19f76d1, 0x17a82d6, 0x0ada511, 0x0add9fa, 0x1f37fde, 0x0f3a552,
  48966. 0x16200e6, 0x145bd94, 0x0380402, 0x0235fc6, 0x013f390 },
  48967. { 0x1d0c827, 0x14b77bd, 0x1d18f74, 0x069453f, 0x106110f, 0x0d28ad2,
  48968. 0x0c1a072, 0x0eff0f2, 0x1268bca, 0x146c022, 0x01177f7, 0x0049330,
  48969. 0x04cbb83, 0x146072c, 0x0435c41, 0x0c0c47f, 0x0a8263b, 0x19541c6,
  48970. 0x0d71742, 0x176bcea, 0x1110293, 0x0aab20a, 0x13baa67, 0x17b400b,
  48971. 0x11ad01b, 0x00c7f18, 0x1e93634, 0x092fc17, 0x12b8662, 0x1bd00e7,
  48972. 0x02ccf75, 0x1b18975, 0x0075b73, 0x1bde4de, 0x1b51c8a, 0x165308c,
  48973. 0x0bda1b0, 0x13e7126, 0x00ed85e, 0x0d6d00e, 0x0458d4b },
  48974. { 0x154d8b2, 0x1510726, 0x0836289, 0x1c9a641, 0x05a5696, 0x0a7b800,
  48975. 0x16163e6, 0x150d316, 0x02f6549, 0x1256e1e, 0x134035e, 0x10326d2,
  48976. 0x1d1812e, 0x1982015, 0x0e6c001, 0x0c8208d, 0x049a1b3, 0x070850a,
  48977. 0x048c088, 0x12bd4b3, 0x00c3eae, 0x0d8da41, 0x0fbf0ba, 0x193d714,
  48978. 0x15cb585, 0x0327f2d, 0x065e11c, 0x035c063, 0x07d49f2, 0x05b8479,
  48979. 0x1ada3bc, 0x05ee4aa, 0x059ef18, 0x0d80d19, 0x115d893, 0x18015c0,
  48980. 0x1668f95, 0x071d832, 0x0fe458a, 0x1f56df7, 0x05f13f5 },
  48981. { 0x09b0dc6, 0x16cd71d, 0x1b21f1b, 0x12df107, 0x0ea1bde, 0x059b3bd,
  48982. 0x0fe23aa, 0x157d4cd, 0x09a66e3, 0x17d355e, 0x05fff77, 0x02f6d04,
  48983. 0x1cc4d33, 0x1486f82, 0x10723c8, 0x0ce9dee, 0x1177d11, 0x10f87ef,
  48984. 0x0d66272, 0x01d9cf8, 0x082dfdf, 0x0fb5ce2, 0x03bb64b, 0x17e394e,
  48985. 0x13e6655, 0x0ce39b8, 0x00973b2, 0x0159652, 0x03e69c9, 0x11d1740,
  48986. 0x068df27, 0x02ee274, 0x00a3c53, 0x10ba6be, 0x1595bd6, 0x0c6a1b8,
  48987. 0x05f802f, 0x112d220, 0x0928845, 0x0bb46f7, 0x0219649 },
  48988. { 0x1142680, 0x197e989, 0x13d0032, 0x0ecba29, 0x0b9e91d, 0x11334f5,
  48989. 0x13aaf7f, 0x18b8d41, 0x00ae22b, 0x177e72c, 0x1b0942f, 0x130d96d,
  48990. 0x1f3c2b7, 0x0b9c78f, 0x0b6c68b, 0x191d909, 0x028516e, 0x0cb84de,
  48991. 0x1a3df6d, 0x1262531, 0x17f9f36, 0x15cad8c, 0x1123bf1, 0x1554809,
  48992. 0x109529a, 0x0584ff8, 0x1451055, 0x1879197, 0x1f34352, 0x1de1a13,
  48993. 0x104cfbd, 0x1a4312f, 0x0a17940, 0x0a45002, 0x11f5b39, 0x04b5418,
  48994. 0x1d56fa6, 0x18e7539, 0x17c20a5, 0x160088e, 0x093ad0e },
  48995. { 0x08a9963, 0x1b4b3cc, 0x0375e82, 0x0eca2bd, 0x01e477f, 0x15a8793,
  48996. 0x18e18ed, 0x1bcc4e9, 0x1d33922, 0x1d4dc6a, 0x096cf58, 0x07f6d0f,
  48997. 0x033c38d, 0x0981719, 0x1dbc270, 0x1999e31, 0x1c3e02f, 0x192a602,
  48998. 0x1b998bd, 0x1da16e4, 0x0079c04, 0x1c0a1ff, 0x075591a, 0x002d918,
  48999. 0x09448c9, 0x1cbf7c5, 0x0fe08f5, 0x0ace989, 0x0de451e, 0x1b97de6,
  49000. 0x178161b, 0x0882fd5, 0x1fc88d5, 0x12c46e2, 0x08255db, 0x12572a4,
  49001. 0x1844d1f, 0x046ea12, 0x100d110, 0x1e1d483, 0x073f8c3 },
  49002. { 0x1f763dd, 0x1a7e42e, 0x00da254, 0x06758e3, 0x1b1427f, 0x078ad01,
  49003. 0x0f85dba, 0x11c1b6b, 0x0cb2088, 0x09c84a2, 0x12ba987, 0x135b0af,
  49004. 0x137804c, 0x08cfbdf, 0x16110a1, 0x1519f54, 0x0f1293a, 0x0b13776,
  49005. 0x08da805, 0x1c1b31d, 0x0dcd749, 0x171990f, 0x1bffdb6, 0x16f2399,
  49006. 0x1eea628, 0x1b0cb1e, 0x08b45b8, 0x029c0aa, 0x1ae206a, 0x0c7e58a,
  49007. 0x1928b81, 0x1f9464b, 0x1268745, 0x00d4507, 0x101c84d, 0x10f9f3a,
  49008. 0x1caa51b, 0x1692ecb, 0x175d77f, 0x0735b7d, 0x00108ae },
  49009. { 0x1e88f63, 0x0bc79d4, 0x0c95534, 0x1d5618e, 0x0a05b11, 0x10ec535,
  49010. 0x14f9b89, 0x190ee74, 0x08d0b91, 0x06dbed7, 0x0c01349, 0x00e7d37,
  49011. 0x0bde10b, 0x0a71848, 0x02fbf9d, 0x13913f9, 0x1990cc6, 0x10b5782,
  49012. 0x1565446, 0x1070073, 0x1afcddc, 0x0ca362e, 0x10fd96e, 0x1c14b33,
  49013. 0x04be81e, 0x18bfddf, 0x1becea6, 0x11123c6, 0x1dad008, 0x16baa22,
  49014. 0x07c326a, 0x1aa12fc, 0x1fc46ab, 0x0d270ef, 0x026eb21, 0x0710901,
  49015. 0x00c4523, 0x05da17d, 0x1077cd2, 0x1b1d627, 0x0807c06 },
  49016. { 0x0ee0ef6, 0x0b4f64c, 0x1ebc02a, 0x07176f6, 0x1a9d548, 0x17c7edd,
  49017. 0x1324a80, 0x0f84890, 0x08b7055, 0x1ed900d, 0x146bc9e, 0x07c8c15,
  49018. 0x1be5934, 0x0cc64af, 0x0a6a50a, 0x03a76a7, 0x1deda86, 0x14ba6d9,
  49019. 0x14e6703, 0x0a4b93d, 0x09bdce1, 0x00fb908, 0x026d5a2, 0x1042349,
  49020. 0x17d1599, 0x1ad047f, 0x0bbc3c9, 0x1beed67, 0x0f358b5, 0x007bfd1,
  49021. 0x0d24fc6, 0x187360c, 0x0c4ffcf, 0x01da9d5, 0x18985d6, 0x184d258,
  49022. 0x155399f, 0x1efd1b5, 0x1e986cb, 0x0d932c0, 0x016424c },
  49023. { 0x12744a9, 0x12e2aee, 0x1061775, 0x05fc75e, 0x0544c1c, 0x1458449,
  49024. 0x0ba67bf, 0x0346590, 0x1a9df69, 0x05bd592, 0x0659d0c, 0x0aa137d,
  49025. 0x0298384, 0x0579689, 0x1b34963, 0x0e4e579, 0x098bcc7, 0x0445720,
  49026. 0x0e3be83, 0x12c2829, 0x112cd43, 0x1cf6b26, 0x113fd9e, 0x0fe6808,
  49027. 0x055e42e, 0x0f5d4f3, 0x1516c3a, 0x1a2df88, 0x1ded283, 0x1f0a781,
  49028. 0x1711d28, 0x1599970, 0x1c9adff, 0x1d28dd1, 0x0f05c94, 0x027bfcd,
  49029. 0x1b5831b, 0x0d7a5cf, 0x11e2b77, 0x00549e8, 0x05544e6 },
  49030. { 0x0a80b4f, 0x02989dd, 0x03be25f, 0x1ec77b9, 0x0122716, 0x0162d40,
  49031. 0x10b6ded, 0x1195c4e, 0x1088330, 0x0ecf0f4, 0x106ac7a, 0x187e5a6,
  49032. 0x10352c8, 0x16ca2c3, 0x0f41403, 0x1b3b02c, 0x173c290, 0x0c1a4ee,
  49033. 0x1db1f4a, 0x078bc03, 0x033c205, 0x0365a10, 0x00c41d1, 0x1a135e3,
  49034. 0x08bd209, 0x140bb64, 0x1ac9e51, 0x01ee1cd, 0x11b540d, 0x0cef0cd,
  49035. 0x10dc82d, 0x0453296, 0x0b7ecdc, 0x029e7c0, 0x1738b7b, 0x0583499,
  49036. 0x1ed60f4, 0x1e9f6e8, 0x1498775, 0x0b9c483, 0x0573599 },
  49037. { 0x0237056, 0x1d1fdd0, 0x0e23712, 0x0867566, 0x0856c16, 0x0f63093,
  49038. 0x1aef49c, 0x1d9803d, 0x1e3031b, 0x1ef5819, 0x0287d6a, 0x0832c23,
  49039. 0x134eee4, 0x0db0079, 0x125d085, 0x10ee7d8, 0x1cf0886, 0x08db8c2,
  49040. 0x106df7f, 0x188d9af, 0x1e897b0, 0x0d25262, 0x1450ecb, 0x03ff29b,
  49041. 0x05984bb, 0x032edcd, 0x13273cd, 0x187209c, 0x0e64c9a, 0x0de0756,
  49042. 0x06be1ca, 0x0ed15b3, 0x0c22821, 0x0a0612e, 0x02062a5, 0x0f77a76,
  49043. 0x049a691, 0x1476af8, 0x17bc391, 0x1be7d88, 0x0885486 },
  49044. { 0x1dff464, 0x01649a5, 0x1145aa5, 0x1e4b4f6, 0x1db2719, 0x0df1921,
  49045. 0x01c2cc9, 0x0739960, 0x119fe33, 0x02ad18d, 0x1ba3fc8, 0x15d0483,
  49046. 0x0faca69, 0x0af7c6f, 0x01f7421, 0x0e78cec, 0x00f1a1b, 0x04f124b,
  49047. 0x074da04, 0x01d144e, 0x06b9bcb, 0x113442f, 0x0a7846a, 0x0bd5c32,
  49048. 0x1d0ab18, 0x08e4c5a, 0x103e07e, 0x14172dc, 0x0fc5031, 0x05e7cca,
  49049. 0x181343a, 0x1e233ad, 0x1d81697, 0x0670619, 0x0a1eaa9, 0x0e52106,
  49050. 0x091ff9d, 0x0ea69f6, 0x058b717, 0x1d1a957, 0x031cecf },
  49051. { 0x08b21e8, 0x1fecd7e, 0x1b7d0de, 0x0763286, 0x05dd32b, 0x0e1b507,
  49052. 0x00b5248, 0x121fcb2, 0x1a3d0fa, 0x14ef426, 0x148ef63, 0x0d5ab76,
  49053. 0x159663e, 0x1766b4b, 0x00288fe, 0x16b3930, 0x0d9b4fb, 0x08804e0,
  49054. 0x07483fc, 0x154f7b9, 0x1a3d839, 0x16f66b7, 0x1d40bd9, 0x0a2d953,
  49055. 0x0d4fbc5, 0x1622407, 0x19b1d0a, 0x0bff4be, 0x1252f86, 0x1ca2ff9,
  49056. 0x0f4adf1, 0x0ebb396, 0x0fefc05, 0x178e939, 0x18ef5b5, 0x0623610,
  49057. 0x1a6a4ec, 0x079e784, 0x11ecd76, 0x0d5b44a, 0x06961b4 },
  49058. { 0x135e2ac, 0x1ac3f65, 0x136741e, 0x16af5e2, 0x1ed5546, 0x1450260,
  49059. 0x1e96f6c, 0x1e1d942, 0x0709d54, 0x0fc8ea2, 0x1d003a8, 0x13fb38d,
  49060. 0x10a6e71, 0x1dc670c, 0x12e23b7, 0x07fa49c, 0x0dd246e, 0x0fcbc0f,
  49061. 0x1956bd7, 0x0241cd6, 0x1ca7d67, 0x0ec9a09, 0x169e0b4, 0x00ff443,
  49062. 0x020a297, 0x091b4bf, 0x0953a10, 0x1d6a3e6, 0x051f9f1, 0x06cf1b0,
  49063. 0x1a4b895, 0x0e79cb7, 0x1aec42b, 0x1bca7ee, 0x0cbb34f, 0x1313534,
  49064. 0x0781aad, 0x1271178, 0x1484865, 0x018a6ea, 0x06a63a9 },
  49065. { 0x17acbbb, 0x0a7001e, 0x0421d95, 0x156e9ec, 0x0c01668, 0x0628cd9,
  49066. 0x059c8e2, 0x09fc945, 0x03eb94d, 0x0b33b8a, 0x1b4bd80, 0x19be19a,
  49067. 0x1f086a3, 0x1d9b87b, 0x1960085, 0x07cf9f0, 0x0c15a4d, 0x0b2c440,
  49068. 0x0e8fd28, 0x1ab02cb, 0x11ddd6e, 0x09ae523, 0x0af31e0, 0x0894aed,
  49069. 0x1f074e8, 0x175404d, 0x0dba940, 0x0a75036, 0x021ed3a, 0x0983870,
  49070. 0x197082e, 0x10c2fe2, 0x027f892, 0x0e685c6, 0x111a08d, 0x034a8ec,
  49071. 0x0255296, 0x044ffec, 0x1643bff, 0x045a2a3, 0x051ed4a },
  49072. { 0x09701b4, 0x14b1d22, 0x0bc8df5, 0x07764f9, 0x0a8d91a, 0x194b2ff,
  49073. 0x0f856d5, 0x0fa7df3, 0x1db50bf, 0x0d3d02a, 0x10ee6dd, 0x101d9cc,
  49074. 0x1efd674, 0x1675aea, 0x09834b5, 0x1912fe5, 0x00c5ed7, 0x1b47e19,
  49075. 0x0339a17, 0x0a79ec5, 0x015e41c, 0x0fb8833, 0x038a5c4, 0x0a01d98,
  49076. 0x1213823, 0x1243d43, 0x01b0a7f, 0x1e1524c, 0x0f9712a, 0x1f9570f,
  49077. 0x0fe4f7c, 0x1a5a2d3, 0x15f6fb1, 0x0bc9e06, 0x1899d2a, 0x0dd6f5f,
  49078. 0x09f4925, 0x19eca57, 0x1739505, 0x1785716, 0x02d6951 },
  49079. { 0x04e222e, 0x03ecfc8, 0x0427740, 0x1f0de9c, 0x133f248, 0x014f771,
  49080. 0x13a2e3d, 0x031a932, 0x1cfc775, 0x0ab9a0a, 0x1d0bc4a, 0x1474161,
  49081. 0x196e7fe, 0x013a1a8, 0x0572df7, 0x0e3418f, 0x166711e, 0x0c10547,
  49082. 0x0e1d3d5, 0x12bb385, 0x162783d, 0x1c73870, 0x152d935, 0x1254e85,
  49083. 0x153f58b, 0x136c921, 0x0511ed7, 0x0440916, 0x1931a03, 0x19865e7,
  49084. 0x1a02eb5, 0x14f5e44, 0x1c4d089, 0x1c9fcba, 0x1306e0e, 0x1c8c920,
  49085. 0x165b3ae, 0x075d010, 0x117c289, 0x0f1c119, 0x065c48e },
  49086. { 0x0222c22, 0x039e76f, 0x0ed0687, 0x1bf9d44, 0x1683d8c, 0x0a1d832,
  49087. 0x12c52c8, 0x0ee0603, 0x159fcec, 0x0256fc7, 0x0133bca, 0x1038624,
  49088. 0x07fb1c5, 0x0a39a88, 0x134fbba, 0x11181ea, 0x10b4d31, 0x16dfb3f,
  49089. 0x03c6344, 0x07e5a22, 0x001376a, 0x1403e9f, 0x0e027e8, 0x1cfd9c0,
  49090. 0x10a4625, 0x0977837, 0x16ca257, 0x1050cfd, 0x10553ad, 0x1a44845,
  49091. 0x117841b, 0x1de48a8, 0x0280fa6, 0x0d1e5f1, 0x1e16a36, 0x1a805aa,
  49092. 0x1438ba2, 0x1eecffe, 0x089bfd8, 0x058f4d6, 0x036b5cd },
  49093. { 0x05679a7, 0x1a7102a, 0x1d421ff, 0x028a418, 0x04d80b4, 0x02ce6c3,
  49094. 0x15fea6d, 0x1472146, 0x1c85af1, 0x0cf579c, 0x0d697a8, 0x1af31b2,
  49095. 0x0a0d475, 0x1c0d33c, 0x140660d, 0x1d020e8, 0x1790cc2, 0x03a41cb,
  49096. 0x1d04891, 0x043a225, 0x1a37c6a, 0x1c9b528, 0x0343a17, 0x14e9bf1,
  49097. 0x0151eea, 0x0e27fa8, 0x1e4f3e6, 0x09c3054, 0x0a9ab61, 0x1ef89bb,
  49098. 0x1fd1564, 0x0a44713, 0x0f73caf, 0x02f450c, 0x0583dd1, 0x11a4f99,
  49099. 0x19a51dc, 0x097a629, 0x0ff601a, 0x089b673, 0x008d7c1 },
  49100. { 0x0cca773, 0x006cb1f, 0x055a027, 0x05a9184, 0x07ea919, 0x15eb20c,
  49101. 0x135d36d, 0x1bfe1d9, 0x02a678c, 0x19891ba, 0x01edf9d, 0x1b17a2b,
  49102. 0x067a966, 0x1098526, 0x1068405, 0x02f7be7, 0x0385fce, 0x03e6374,
  49103. 0x0379ea9, 0x12b7715, 0x08e395e, 0x1ac4c18, 0x0ff87a2, 0x08ed294,
  49104. 0x1243ee3, 0x15f80cb, 0x0aec334, 0x07fd388, 0x1b2b49f, 0x093207c,
  49105. 0x07ed641, 0x18e6cfa, 0x0385e8b, 0x10a3da6, 0x02bad7b, 0x123a60a,
  49106. 0x04004ad, 0x161c3c8, 0x0080a38, 0x1dd756e, 0x05f2aa8 },
  49107. { 0x066524b, 0x06a3209, 0x1d9b882, 0x01a1433, 0x17bf388, 0x08375fd,
  49108. 0x1a17b68, 0x08d4b54, 0x1e642dd, 0x134f469, 0x0b93582, 0x18c38d0,
  49109. 0x0cef349, 0x07e5a9a, 0x1dbb8ec, 0x0cf704d, 0x12705eb, 0x13ed5d0,
  49110. 0x02f817d, 0x1764fc3, 0x05d12ba, 0x1d4716c, 0x0566bf2, 0x1b3a70d,
  49111. 0x12d1ae2, 0x03776e7, 0x187a9bc, 0x13b8a5c, 0x0e5ae85, 0x1c5a433,
  49112. 0x11f0a09, 0x00579a7, 0x1ff0340, 0x1f417ec, 0x11d9e12, 0x09d1095,
  49113. 0x03c9f22, 0x0b24c04, 0x1e5268c, 0x13168df, 0x062501a },
  49114. { 0x1264086, 0x1becd56, 0x12f558f, 0x174bc1c, 0x0a6a33d, 0x069eb3e,
  49115. 0x0c00a32, 0x033d04a, 0x046e64b, 0x1446d64, 0x0914da8, 0x032e415,
  49116. 0x0cfa3c9, 0x16aa9f5, 0x0c326c3, 0x157a702, 0x0e02ea8, 0x1b11403,
  49117. 0x1b33f9d, 0x17ea9b9, 0x1b7052f, 0x18a7868, 0x0f66a38, 0x1362e83,
  49118. 0x12133d5, 0x14528ce, 0x1269bfa, 0x1ae8203, 0x04eb10f, 0x1bd05ae,
  49119. 0x17b46b3, 0x123f3b4, 0x0499b73, 0x152c33c, 0x1127037, 0x1557549,
  49120. 0x01f3531, 0x0e2fb9d, 0x1199732, 0x1fdfa7f, 0x0497b15 },
  49121. { 0x05568e9, 0x165d57a, 0x09be295, 0x1d8e325, 0x1491a0f, 0x1929cd7,
  49122. 0x0f74e6a, 0x153b760, 0x04ac37d, 0x032917c, 0x03d6d32, 0x1744054,
  49123. 0x1f8c8cd, 0x114e29c, 0x027f1d6, 0x1e05d02, 0x131ca90, 0x1ce6836,
  49124. 0x1885b6f, 0x03e0887, 0x1d918f3, 0x165d1f5, 0x066a9a2, 0x1800fe9,
  49125. 0x0d0d242, 0x1e71540, 0x1e1aa6d, 0x1b1bff7, 0x108edcd, 0x1f426b1,
  49126. 0x1290174, 0x00d0025, 0x0fa33fe, 0x10838ed, 0x144fb7a, 0x0d85dd7,
  49127. 0x0ff637e, 0x173f2e1, 0x132dede, 0x0d93ca2, 0x018d46a },
  49128. { 0x18b7802, 0x05d9153, 0x0bd21a3, 0x0492f97, 0x0745ddb, 0x17456e8,
  49129. 0x0bcf90a, 0x1c989d6, 0x0b4ceb4, 0x0055e6d, 0x17f502b, 0x064b464,
  49130. 0x052e0d8, 0x09d639a, 0x1f815c4, 0x0e372d9, 0x188b141, 0x1ba03d3,
  49131. 0x169e94a, 0x160c06d, 0x16ac70e, 0x1cec28b, 0x0ac2cdb, 0x052a9e7,
  49132. 0x09d297c, 0x0d68a08, 0x03735c1, 0x0e1bd39, 0x15e7513, 0x1ae6bdd,
  49133. 0x030fc36, 0x140dce1, 0x1f93d41, 0x18286a2, 0x1e29fa4, 0x1221aa9,
  49134. 0x1a38fef, 0x137c722, 0x0b901a7, 0x003a7ec, 0x0550446 },
  49135. { 0x0cb9cc9, 0x0e48803, 0x0053471, 0x0e83a00, 0x142074d, 0x11b7dc2,
  49136. 0x198f844, 0x104f9b0, 0x029ad5f, 0x0b90fff, 0x07f20ce, 0x17f452a,
  49137. 0x0f1d21f, 0x00068a2, 0x1781b9d, 0x05cd639, 0x16b9179, 0x148212c,
  49138. 0x06b5459, 0x0b91ca5, 0x1e98336, 0x02cd777, 0x188883a, 0x1855dc7,
  49139. 0x1318970, 0x05e5e5a, 0x0e7fc40, 0x0ef947b, 0x12973f4, 0x00bb7a9,
  49140. 0x06c9c1d, 0x13457a0, 0x12118ac, 0x1cfc9d0, 0x0824f75, 0x17e684a,
  49141. 0x06f5d7d, 0x1d47fbe, 0x1b13d58, 0x1f9af61, 0x00da313 },
  49142. { 0x1aa2557, 0x12d460a, 0x1a70dc4, 0x1801127, 0x0a21d70, 0x1c5411e,
  49143. 0x0e6519e, 0x05490e2, 0x07cb004, 0x09f4d3a, 0x0b38603, 0x09ff93c,
  49144. 0x022d2bf, 0x024d756, 0x14c6834, 0x00cc1aa, 0x016f03d, 0x02694d3,
  49145. 0x1c6dfc0, 0x1aa1ac3, 0x050c473, 0x1de51ef, 0x0ebc3b2, 0x1851e4e,
  49146. 0x19bea09, 0x132714a, 0x03e1c11, 0x1af85d4, 0x1083ef6, 0x1270b98,
  49147. 0x152b7eb, 0x128384a, 0x0940c26, 0x11681a8, 0x1042845, 0x1c882ce,
  49148. 0x1e82290, 0x01186c0, 0x12b3188, 0x1d1b682, 0x063630b },
  49149. { 0x07d2e41, 0x0a91145, 0x01e6fe3, 0x07d6c5f, 0x09e7582, 0x0016c4a,
  49150. 0x0cf75b1, 0x15a369a, 0x0de2c59, 0x01f026b, 0x0770e22, 0x11e8937,
  49151. 0x0cbf3f3, 0x1a5b862, 0x065f462, 0x1408b3b, 0x00c13ce, 0x08fb4d9,
  49152. 0x038981b, 0x1ae04ab, 0x1b79ca3, 0x1b930e8, 0x0f53f65, 0x0286df4,
  49153. 0x0afa85a, 0x003ab57, 0x02ed10f, 0x0d367d3, 0x18f6be3, 0x0c3672a,
  49154. 0x027f394, 0x1f1591f, 0x10cd478, 0x0d53975, 0x1cdf579, 0x00d00e9,
  49155. 0x08544eb, 0x0c22e03, 0x023b4a5, 0x0e3e2cd, 0x0306a98 },
  49156. { 0x14ec136, 0x08f4eb1, 0x163ef11, 0x141cdec, 0x1edf27c, 0x0da0900,
  49157. 0x0054b03, 0x0cf537c, 0x0c5bfee, 0x1db7790, 0x15808e1, 0x0471345,
  49158. 0x1935283, 0x03d7dc4, 0x1959363, 0x185bcc1, 0x1c00ac9, 0x1a57915,
  49159. 0x0aa748a, 0x0dec630, 0x101b28e, 0x00fa993, 0x101d71c, 0x00ebf23,
  49160. 0x018f882, 0x088fb6a, 0x146faa9, 0x13f4c51, 0x12a13df, 0x1d0bb73,
  49161. 0x0715479, 0x0efe980, 0x106215b, 0x0eac449, 0x1cc64f2, 0x08e3574,
  49162. 0x18e57cd, 0x01f5f02, 0x0f8dd91, 0x083d020, 0x02833ac },
  49163. { 0x1a5ec5c, 0x125c346, 0x0c91f95, 0x103811b, 0x0c3d9da, 0x0bd3945,
  49164. 0x07c2e31, 0x1853af8, 0x19d343d, 0x08957f3, 0x180ce4d, 0x099ffb8,
  49165. 0x01b438e, 0x0e7d0ca, 0x1689c03, 0x00892fa, 0x1f82732, 0x16af991,
  49166. 0x0e4f1b9, 0x0f4b1c2, 0x04311b8, 0x08825d5, 0x1b2da2f, 0x04569af,
  49167. 0x01c5a47, 0x1d5604e, 0x1c81ad7, 0x085f552, 0x16327ef, 0x1e6b4cb,
  49168. 0x1678772, 0x010ef0f, 0x15ba9e4, 0x000c8b2, 0x1d5f797, 0x117ab38,
  49169. 0x0bcf353, 0x1810768, 0x18c0d9c, 0x0a9493a, 0x0120cd4 },
  49170. { 0x0b0f9ee, 0x0dc7a65, 0x03bbaff, 0x00599cb, 0x1c003ef, 0x068332d,
  49171. 0x1a1056a, 0x0e936d4, 0x09b9577, 0x01769d3, 0x06ad719, 0x0fe08e4,
  49172. 0x133de48, 0x10d2786, 0x0bfce00, 0x1bb9bde, 0x15829db, 0x15e8b7a,
  49173. 0x1a4f7fc, 0x00b6961, 0x0ec12ef, 0x0905e4d, 0x1787ea8, 0x0cff525,
  49174. 0x0e2c2d4, 0x11a336d, 0x117accf, 0x0b1b5ec, 0x0103cb7, 0x0cfb478,
  49175. 0x0c299eb, 0x137c048, 0x11f693a, 0x02a5e0a, 0x125bad0, 0x1daad30,
  49176. 0x1019336, 0x18b3bf3, 0x1a8fa3b, 0x02cffbd, 0x0021cfd },
  49177. { 0x15c36f3, 0x1b8afef, 0x095171c, 0x0fac95a, 0x103bde3, 0x07bb89b,
  49178. 0x03443cb, 0x190aa6d, 0x10f3993, 0x12f63db, 0x0b93287, 0x0eec609,
  49179. 0x0bfdb16, 0x1e9dd8c, 0x03dc5f8, 0x07ab41b, 0x13f6634, 0x0a93383,
  49180. 0x158022d, 0x16a5de2, 0x070ffae, 0x1c91252, 0x0e5eb57, 0x0556a35,
  49181. 0x0e391ed, 0x01657c3, 0x1e65d0c, 0x1818fca, 0x0ae28ad, 0x140bfe8,
  49182. 0x073223e, 0x17f1dab, 0x07c22df, 0x145db40, 0x08c7ac4, 0x06bbdb8,
  49183. 0x020595a, 0x16e6ce5, 0x1de39c7, 0x08d8e79, 0x007265b },
  49184. { 0x166232f, 0x0ccf85e, 0x1c59cf7, 0x138804e, 0x059aaf8, 0x0307e26,
  49185. 0x1b7e96e, 0x0775f04, 0x07a943f, 0x1cf5455, 0x110a348, 0x1634a47,
  49186. 0x1a0e0e1, 0x14b9dca, 0x1a838e9, 0x0ea76ab, 0x0aa2557, 0x1f51cce,
  49187. 0x1a55ec7, 0x1bee5e0, 0x0302f8a, 0x009de9a, 0x00e27cd, 0x148752e,
  49188. 0x127d0f8, 0x0b7999f, 0x02b6bde, 0x1b38181, 0x012aa2c, 0x124da4e,
  49189. 0x1a5b732, 0x0f4158d, 0x188deee, 0x004076e, 0x1d74191, 0x1b1e8ea,
  49190. 0x0cc2f4b, 0x0eb33e8, 0x125b1ba, 0x09663a2, 0x036c575 },
  49191. { 0x123d84b, 0x0023779, 0x113e448, 0x04fcf13, 0x0699112, 0x0dc02ad,
  49192. 0x0bd3a48, 0x09c961d, 0x0807997, 0x19cc225, 0x1e31e58, 0x0cd4e81,
  49193. 0x09c9054, 0x06b6f7a, 0x06343df, 0x1c97438, 0x06b4b23, 0x0a94bed,
  49194. 0x1060031, 0x13bfe78, 0x07771c0, 0x0d9bf7b, 0x1b1241d, 0x0a27bda,
  49195. 0x03a4050, 0x182d4a6, 0x05ac2c5, 0x1ace85d, 0x0af5ae3, 0x024a624,
  49196. 0x17b01e1, 0x192b045, 0x0c01532, 0x06ca7a0, 0x1797059, 0x0b45bb5,
  49197. 0x02975eb, 0x054564d, 0x0513bf2, 0x0c2328d, 0x006fbf8 },
  49198. { 0x145aa97, 0x099c71f, 0x1facb59, 0x103a081, 0x183b58c, 0x0f7c5ce,
  49199. 0x1d66c3f, 0x0f80bfd, 0x0e4d741, 0x1f5838d, 0x08688de, 0x03eb661,
  49200. 0x03982b6, 0x1db2de8, 0x17ca8ab, 0x0d7e698, 0x09d5cbf, 0x0f2055e,
  49201. 0x01984a9, 0x1864dbe, 0x0e28422, 0x0ecab8d, 0x124879a, 0x1a6869d,
  49202. 0x0b10b23, 0x099be44, 0x1e7681e, 0x0da5d2a, 0x19cf4d9, 0x03509b0,
  49203. 0x0860cf5, 0x1b2bddf, 0x1d19653, 0x147876c, 0x104680f, 0x0254fb0,
  49204. 0x04bb5ab, 0x1214a98, 0x0a7a979, 0x1fa3e1f, 0x05e9ca0 },
  49205. { 0x17c5dc4, 0x0a2b88c, 0x16896f5, 0x1fcf152, 0x02da40b, 0x0d87597,
  49206. 0x07bf3ff, 0x0f8cbf7, 0x00d1746, 0x0a96e16, 0x031a8fa, 0x18f78eb,
  49207. 0x1ac1fc9, 0x0a01a54, 0x1e558b3, 0x096adf8, 0x1be61f6, 0x19371b7,
  49208. 0x1a11ca2, 0x18973c3, 0x0c8a6ad, 0x09d47cd, 0x1fc597f, 0x1c7c026,
  49209. 0x13a4503, 0x071bde4, 0x0d9591e, 0x1598aa2, 0x0ddc77e, 0x0b8b832,
  49210. 0x0534ce4, 0x0ed26d2, 0x1b318dc, 0x012533a, 0x071cd89, 0x08d363e,
  49211. 0x09955f3, 0x01022da, 0x1abe233, 0x1678d06, 0x0940622 },
  49212. { 0x1997973, 0x0665b86, 0x04551c4, 0x1ba7f1e, 0x1b29625, 0x0bd5ea9,
  49213. 0x113556e, 0x14b19e1, 0x0673e14, 0x1190f05, 0x18891b1, 0x1f3a7a4,
  49214. 0x110541a, 0x17e41d8, 0x1b61d51, 0x0a549bc, 0x1a8f016, 0x123f4be,
  49215. 0x16600ad, 0x05674d5, 0x04b20f8, 0x1ad74e2, 0x1a6a901, 0x1a57eee,
  49216. 0x15de2ce, 0x06d579f, 0x0925e90, 0x1de3d51, 0x03ba9c1, 0x03041e1,
  49217. 0x120b83e, 0x1e32145, 0x0a998a4, 0x119b46c, 0x12333f7, 0x03c5693,
  49218. 0x1de6bd7, 0x1a4c125, 0x1b6dae7, 0x0c8f0b7, 0x080bb16 },
  49219. { 0x1145cb5, 0x0baff7e, 0x020c179, 0x0358bcd, 0x155ee56, 0x09d9398,
  49220. 0x1c33e1e, 0x0708c3c, 0x0133b23, 0x18aa9ef, 0x1ee81e7, 0x0187454,
  49221. 0x1a2fb9e, 0x1f38437, 0x0ff5aa0, 0x1972787, 0x1008bb4, 0x0db5d42,
  49222. 0x1be0b6f, 0x0daf12e, 0x09ff0b6, 0x1b2a75a, 0x1f569bf, 0x0416644,
  49223. 0x1d2371f, 0x06e66b2, 0x09538a7, 0x13d4938, 0x118ff97, 0x0cb1e58,
  49224. 0x02d925d, 0x198b000, 0x09598dd, 0x03bce4b, 0x0460443, 0x0b2a20f,
  49225. 0x03b85a3, 0x1e0aa43, 0x08d43b7, 0x1d48242, 0x0077ba5 },
  49226. { 0x1d86f61, 0x11c69e6, 0x02ac2ce, 0x0a0a054, 0x0312144, 0x1681392,
  49227. 0x1b71601, 0x01e3225, 0x08a32f1, 0x0ee0fcc, 0x031d800, 0x03a21d0,
  49228. 0x13bb1d3, 0x1a32745, 0x1bb1f97, 0x093dda8, 0x1369abf, 0x1eab4d7,
  49229. 0x136b79d, 0x10dd4e5, 0x19209d2, 0x06a2d6a, 0x0af9c08, 0x1335cfe,
  49230. 0x1236e62, 0x003d5f2, 0x174fd57, 0x1262f37, 0x150e80c, 0x0cad291,
  49231. 0x01a04e2, 0x15fe0eb, 0x101265c, 0x1cb2984, 0x06cbd1c, 0x02b6790,
  49232. 0x1bc77d2, 0x1bac0ec, 0x08b8aeb, 0x1be8b23, 0x06b2006 },
  49233. { 0x05b1bc1, 0x128544b, 0x13f6cbf, 0x152c576, 0x131f536, 0x073fccc,
  49234. 0x034cc00, 0x0bdaae3, 0x153d512, 0x0394792, 0x0972be1, 0x0309a42,
  49235. 0x1e4f8a6, 0x1abfb3c, 0x1c69c04, 0x180b4a9, 0x00c1531, 0x0b854fa,
  49236. 0x1ea2ddd, 0x01972ed, 0x0ce910d, 0x0f4ee09, 0x0d1dbd0, 0x0abf129,
  49237. 0x17a7527, 0x0d22e46, 0x01895d0, 0x0d825c2, 0x17b16cd, 0x17dc648,
  49238. 0x08098a9, 0x071ad61, 0x0d116e6, 0x1c74192, 0x0300cb0, 0x19092a8,
  49239. 0x06868af, 0x0dc88e3, 0x0d54215, 0x14d7a4d, 0x053217e },
  49240. { 0x19f52b4, 0x0023992, 0x11b3f21, 0x17cc422, 0x168da9c, 0x05e9374,
  49241. 0x0e17b2b, 0x0892c9d, 0x1e4a543, 0x1bed516, 0x093fdea, 0x1090703,
  49242. 0x0f6dc3b, 0x00e40af, 0x1ea5acd, 0x163c340, 0x1e8c3d4, 0x0627d74,
  49243. 0x0b3a7aa, 0x071a3c8, 0x052f0f9, 0x061ae60, 0x09c9f6b, 0x140de0f,
  49244. 0x001c9e9, 0x0d0e40f, 0x0d29b59, 0x13c11b9, 0x04a9a6a, 0x08b9b02,
  49245. 0x16fe38b, 0x1e57a52, 0x1893dd0, 0x00d894c, 0x0de7e5e, 0x05411a6,
  49246. 0x01830ac, 0x1eb000b, 0x0fbbd92, 0x03db35b, 0x0038693 },
  49247. { 0x09885a5, 0x1d5d9e8, 0x0c1f435, 0x0fc6ab7, 0x0d9d2b6, 0x175d76f,
  49248. 0x0e33d4d, 0x1ac7784, 0x0699ce4, 0x0e5173c, 0x1653358, 0x088e222,
  49249. 0x12354ff, 0x0198b56, 0x12f9c24, 0x1eb88ab, 0x1fd49ff, 0x020c33c,
  49250. 0x1e71b10, 0x159aea1, 0x121a75b, 0x0414b93, 0x19dfb72, 0x1dea05e,
  49251. 0x16887e5, 0x107412c, 0x1efcc83, 0x0b3d26c, 0x1dccb24, 0x1b77c5d,
  49252. 0x0f60738, 0x16ecd0c, 0x1a097fc, 0x036dc0d, 0x075b563, 0x179a744,
  49253. 0x14a8748, 0x04b3e6d, 0x0708039, 0x0922a08, 0x02caaf7 },
  49254. { 0x0d20424, 0x0c00337, 0x151513e, 0x06448e2, 0x13e4ea2, 0x0d46435,
  49255. 0x14695e0, 0x0164d1d, 0x17ae5b7, 0x06855ba, 0x14e6092, 0x06406ad,
  49256. 0x046ca8b, 0x16f98fd, 0x1a39a04, 0x1b9e539, 0x032d925, 0x15c84e9,
  49257. 0x159c8f7, 0x191ef1e, 0x16f9302, 0x14d5d64, 0x045c975, 0x1a342e0,
  49258. 0x047ca57, 0x1f3b2b5, 0x070628a, 0x176baa2, 0x10d9d96, 0x02f8d6a,
  49259. 0x062d5b9, 0x0e160aa, 0x0e886e2, 0x07fc89b, 0x1cf4276, 0x1d8f8e3,
  49260. 0x1350361, 0x10ddf14, 0x0ef6196, 0x0648bfc, 0x086d7f5 },
  49261. { 0x0bf719a, 0x0b75b58, 0x044e67c, 0x111787b, 0x1697509, 0x0680da5,
  49262. 0x039489b, 0x039f5ca, 0x090898d, 0x1f1d62a, 0x1b199b4, 0x13b710f,
  49263. 0x184da3b, 0x1df522d, 0x0c01913, 0x160b0b0, 0x1d98355, 0x19b4f9d,
  49264. 0x1e6f304, 0x047350a, 0x18110fb, 0x1cb715e, 0x13d6d14, 0x0331fa4,
  49265. 0x13baf24, 0x08e803f, 0x0e20df5, 0x114cedb, 0x075b166, 0x1531757,
  49266. 0x0f1a3bb, 0x07b6c10, 0x1fe5f94, 0x1b62d2f, 0x143df60, 0x0aa5929,
  49267. 0x0bc1ff8, 0x061e37e, 0x0d37569, 0x1c70d81, 0x0682a55 },
  49268. { 0x07495aa, 0x11ad22c, 0x117723c, 0x18698e4, 0x0276026, 0x0d23719,
  49269. 0x03316dd, 0x1cfad5c, 0x1ecc3e5, 0x0869cb2, 0x0598a62, 0x085e285,
  49270. 0x071b133, 0x0543b91, 0x0649f9a, 0x14d1791, 0x07e2324, 0x10aa1f9,
  49271. 0x0737086, 0x08ed089, 0x10ac6c4, 0x078a296, 0x06f1ff5, 0x09608b9,
  49272. 0x10a31ff, 0x1089661, 0x0214bdd, 0x02ba8d4, 0x1dd7a64, 0x1829637,
  49273. 0x046b5cd, 0x0f698f9, 0x0ecc3ab, 0x06b866e, 0x006dda2, 0x0ba59be,
  49274. 0x040d390, 0x0792a17, 0x1373415, 0x14dfdfc, 0x002227f },
  49275. { 0x151948b, 0x0f7ecdb, 0x0974601, 0x0dfbfa4, 0x0efeed4, 0x1645914,
  49276. 0x038253c, 0x1cb9625, 0x196f7c5, 0x088485f, 0x0fb2827, 0x0089699,
  49277. 0x040959d, 0x0704658, 0x12557e6, 0x09f9c43, 0x19d68fa, 0x15e0f93,
  49278. 0x1c42ba6, 0x03c29c0, 0x07f4b02, 0x0fc408b, 0x19345ba, 0x193e34a,
  49279. 0x1c22ebb, 0x1757ad2, 0x1f8d083, 0x1e6e2db, 0x04e8435, 0x1c8aeae,
  49280. 0x0065c7a, 0x051ff75, 0x0fc55fc, 0x1babc32, 0x1535f74, 0x00684fc,
  49281. 0x15ebc7d, 0x1735310, 0x05de111, 0x134524d, 0x0547e24 },
  49282. { 0x1ffda27, 0x1434550, 0x1d411c1, 0x18f2ab9, 0x14e6cdc, 0x11f9ec5,
  49283. 0x1478429, 0x015eca2, 0x09de5e7, 0x1a093f5, 0x10a08d6, 0x1375f26,
  49284. 0x113d2c0, 0x1517bea, 0x126760e, 0x1804a31, 0x11dddee, 0x15062dd,
  49285. 0x0f73c73, 0x1bbf080, 0x1eda7ff, 0x14b0b7e, 0x195f934, 0x06543e1,
  49286. 0x1656979, 0x071e922, 0x00c6475, 0x08ebc1d, 0x00218b7, 0x1f50e11,
  49287. 0x014d1e6, 0x117964a, 0x0eb5c90, 0x099737e, 0x13a8f18, 0x1638d0b,
  49288. 0x1fe6c1e, 0x16e3a2d, 0x03bab10, 0x181a561, 0x045a41c },
  49289. { 0x1bbf0e1, 0x0d963a6, 0x1c38faa, 0x1f42f9e, 0x01ff962, 0x15a6332,
  49290. 0x09d617b, 0x0fdb83d, 0x0a9beb1, 0x1aa0969, 0x15d0693, 0x1ea5450,
  49291. 0x1f2c9e4, 0x0c27e88, 0x17df692, 0x0309d27, 0x1dc0df3, 0x0d957de,
  49292. 0x10878dd, 0x047a4a4, 0x181e963, 0x1224efb, 0x121ef87, 0x0b137d5,
  49293. 0x001ed3d, 0x16e8a2b, 0x14a3ffd, 0x1e17b37, 0x0f298c0, 0x0cea450,
  49294. 0x110b4c9, 0x1b11cd2, 0x02d7a77, 0x0157b1b, 0x1adadab, 0x0550980,
  49295. 0x1087da0, 0x028564e, 0x10322ea, 0x19285dc, 0x0128763 },
  49296. { 0x0bac178, 0x00783d6, 0x1db8a6a, 0x0869611, 0x1cc2004, 0x1f6f693,
  49297. 0x07451c3, 0x0cfd2c6, 0x1866157, 0x108aed1, 0x021522c, 0x0b89961,
  49298. 0x037c75f, 0x0d17470, 0x0a7484e, 0x02ea4b6, 0x0668b88, 0x07f4fed,
  49299. 0x0779faf, 0x1b1b118, 0x01233f1, 0x0f0190c, 0x0d1d959, 0x1932be7,
  49300. 0x05561b1, 0x18d839b, 0x02c4fad, 0x02c1963, 0x13a0eb2, 0x1289ccd,
  49301. 0x1d1fa36, 0x1641f9a, 0x08ca1f9, 0x136b92f, 0x019ed04, 0x1ed4fc0,
  49302. 0x08bb637, 0x01025bb, 0x1d3487a, 0x199f89e, 0x075e96b },
  49303. { 0x119716e, 0x08fee06, 0x1494627, 0x10f8708, 0x1f58505, 0x0c3e956,
  49304. 0x11b47aa, 0x01ec950, 0x16c0715, 0x15b5fc1, 0x1f56dc4, 0x1a8c9ad,
  49305. 0x1f91d85, 0x07a9faa, 0x1e220d9, 0x1225352, 0x1d88150, 0x030041d,
  49306. 0x0a1dbd2, 0x0e4d07d, 0x0489a76, 0x1d60ad9, 0x1a02cb9, 0x1a3b325,
  49307. 0x0f8d242, 0x0494c2f, 0x073cf79, 0x18af605, 0x0876279, 0x1c1e58a,
  49308. 0x01ff80b, 0x115cb6d, 0x0ba4fe4, 0x1c0cb57, 0x026d75a, 0x1b150de,
  49309. 0x016e523, 0x07ab35d, 0x0252762, 0x135744d, 0x0309a6e },
  49310. { 0x1fbe97a, 0x1f7285e, 0x1137bc9, 0x1f718a1, 0x1a5fe70, 0x104fae0,
  49311. 0x1ac05ff, 0x18b98f7, 0x1bed36c, 0x1d0ad42, 0x03b4ea3, 0x19b6eaa,
  49312. 0x01c0c3a, 0x15c8434, 0x007be1f, 0x0b9978b, 0x162c49d, 0x050ad99,
  49313. 0x1e8993a, 0x162e283, 0x0e880fb, 0x07c70f7, 0x099fe36, 0x1856c7a,
  49314. 0x0cfd621, 0x17ee98e, 0x154ef9f, 0x049b7cf, 0x0a358a9, 0x03bfed9,
  49315. 0x10750ba, 0x0ebad15, 0x19673c7, 0x1f52ae7, 0x03f5c53, 0x05c6b2f,
  49316. 0x1769b20, 0x19b329a, 0x0de27ba, 0x115aeb2, 0x0045825 },
  49317. { 0x042dbdf, 0x18d3a50, 0x1e8977d, 0x0eaef3b, 0x0d40585, 0x17332b9,
  49318. 0x12e9c34, 0x05c1ccd, 0x1ca2e89, 0x02eb3a2, 0x19ad7ca, 0x1bde1e1,
  49319. 0x03f56a8, 0x1183b3e, 0x1ba1476, 0x0d739c1, 0x0584334, 0x14c602b,
  49320. 0x1acf1d0, 0x1f9c4da, 0x1e00b35, 0x1f9cbbb, 0x102256f, 0x16db10d,
  49321. 0x0f6a6e7, 0x025c1e4, 0x0d3c0a4, 0x1dc2908, 0x04ec34b, 0x08ad974,
  49322. 0x045fdd2, 0x12da213, 0x0af663c, 0x1d6605d, 0x1d5f907, 0x1200970,
  49323. 0x0f86c02, 0x1c4072b, 0x1cd628a, 0x1c12b6e, 0x053f4a3 },
  49324. { 0x1fc48e7, 0x1846744, 0x0bac46e, 0x0f5f56b, 0x1a60c57, 0x00e5ad5,
  49325. 0x12fe283, 0x16de0d7, 0x079757c, 0x0977d75, 0x064581f, 0x0162ec6,
  49326. 0x09e26d9, 0x15bbdbd, 0x0a86ad8, 0x1e57e85, 0x0cd285d, 0x01c7760,
  49327. 0x0ea3dfc, 0x128febe, 0x15b5d35, 0x077e0e5, 0x05f2370, 0x0b08b9f,
  49328. 0x0cca0c4, 0x1797f5c, 0x0492789, 0x0dd1b31, 0x1ed89a1, 0x0736a41,
  49329. 0x1cdf099, 0x0a3b220, 0x1a3f145, 0x14cf809, 0x18b8c17, 0x070a02a,
  49330. 0x0908d56, 0x1cc6ba3, 0x148daab, 0x0a7ae47, 0x00a99e6 },
  49331. { 0x1bc0559, 0x1b7a355, 0x05808d4, 0x1735434, 0x0163067, 0x0b40dae,
  49332. 0x148a430, 0x00e453f, 0x11378e9, 0x092a5f0, 0x04e8b58, 0x0af556f,
  49333. 0x1bc60ff, 0x0332a96, 0x1cb7e2d, 0x0146d4d, 0x0938c17, 0x14d698c,
  49334. 0x06dd366, 0x1b357c5, 0x0523c5c, 0x19fbc24, 0x13dd1c9, 0x01c60c7,
  49335. 0x0a93a0d, 0x1ec6093, 0x0d09238, 0x1c4043c, 0x03ddfaf, 0x01f7419,
  49336. 0x19f65cd, 0x0664c73, 0x1768775, 0x12aa44f, 0x10c5d4c, 0x152ca1f,
  49337. 0x1eebf7e, 0x0aede89, 0x12f02d6, 0x08a021f, 0x03a95cb },
  49338. { 0x1d7ff2e, 0x134659c, 0x123e553, 0x1783ab8, 0x0dd1cb4, 0x14a1c54,
  49339. 0x0b1ddc5, 0x19c0552, 0x091cad8, 0x0b2e058, 0x142349e, 0x1156659,
  49340. 0x1a0c579, 0x134815e, 0x16f0f0e, 0x1a43034, 0x1255186, 0x1aa2e84,
  49341. 0x09f9936, 0x0ef9b7a, 0x12daf00, 0x1246684, 0x0055f2a, 0x0a65566,
  49342. 0x1a3a024, 0x1d19517, 0x0d0732a, 0x0bf6c73, 0x04aee6a, 0x16e0a3a,
  49343. 0x16805c0, 0x19b7527, 0x05bb436, 0x1c278a4, 0x1d98ca5, 0x0726b2f,
  49344. 0x1ad672c, 0x189e0ee, 0x1c91575, 0x05c0616, 0x0366d22 },
  49345. { 0x13ea5b2, 0x1a43aab, 0x1137542, 0x17521b4, 0x0fce401, 0x0d01880,
  49346. 0x1e995e8, 0x0c0f6a7, 0x1cf1144, 0x1154052, 0x02fd25c, 0x1e0b4a7,
  49347. 0x010b8eb, 0x0995669, 0x050451f, 0x1a0fb5c, 0x12c7b5a, 0x1b34938,
  49348. 0x1d23281, 0x0bfdce7, 0x18d86dc, 0x0c95c53, 0x063b452, 0x05e2eb3,
  49349. 0x13145dd, 0x1c72745, 0x057e5c6, 0x06811bc, 0x11b3684, 0x136ed6f,
  49350. 0x1f8157a, 0x1cb2656, 0x1b76e73, 0x049fea5, 0x054f4c2, 0x148850e,
  49351. 0x0661bfd, 0x1ee6690, 0x1f4945c, 0x132f3bd, 0x09072ba },
  49352. { 0x020ea39, 0x0f26ecb, 0x1ba11d3, 0x1f90639, 0x1bf1649, 0x1d4e21f,
  49353. 0x02ec734, 0x1aa161d, 0x13f3df1, 0x11c1437, 0x1b26cda, 0x05671e1,
  49354. 0x034ed07, 0x194e04f, 0x193261d, 0x044854d, 0x0c68ad1, 0x1751f45,
  49355. 0x0f7e96e, 0x01c457f, 0x15926ae, 0x07d8507, 0x1585c7b, 0x10e3f1a,
  49356. 0x0886d6b, 0x1ed19d9, 0x04d7846, 0x16337d5, 0x0f153f6, 0x0d203f8,
  49357. 0x1b93605, 0x0fad805, 0x0608d97, 0x047a33f, 0x0f66daa, 0x08fd1e4,
  49358. 0x039d165, 0x164b292, 0x1b0a49a, 0x17a6aa8, 0x08d92c6 },
  49359. { 0x1eb0ff7, 0x06be755, 0x0be2cf8, 0x087c1c8, 0x1be3525, 0x00424cf,
  49360. 0x0c89b7a, 0x186afa3, 0x11cd44b, 0x167170f, 0x13fb867, 0x1b7886b,
  49361. 0x1c1245a, 0x1c9fac0, 0x13ba103, 0x1728f0e, 0x19cbda0, 0x148b53b,
  49362. 0x095eb82, 0x1902b5f, 0x01b0abc, 0x16f8531, 0x05eb7b0, 0x1f217b9,
  49363. 0x0502b81, 0x11edf35, 0x054ef79, 0x097f3bc, 0x084c255, 0x0d5fbc4,
  49364. 0x1c2a23f, 0x19776a8, 0x0aa52b1, 0x09f7a98, 0x05b0a41, 0x15f00a7,
  49365. 0x0dd827e, 0x01ec4c4, 0x1970235, 0x02eb835, 0x04e4bec },
  49366. { 0x0c09676, 0x041d17e, 0x0a52fe1, 0x1e33d53, 0x057c4a3, 0x0152eea,
  49367. 0x0bbcf5c, 0x1b14d0a, 0x0843fe7, 0x1c8afe9, 0x0d45639, 0x15302dc,
  49368. 0x10644bb, 0x0f6ba37, 0x06e5742, 0x1e16b1a, 0x181b90a, 0x123b822,
  49369. 0x13f44d7, 0x0978d7a, 0x13a50bd, 0x13da741, 0x09b7381, 0x0ad5343,
  49370. 0x08f30ff, 0x1ff1607, 0x03b0b18, 0x1390100, 0x1508a8a, 0x1052cc7,
  49371. 0x0e91270, 0x0652502, 0x0b94cb3, 0x140d101, 0x14a3b1f, 0x0ec8fc7,
  49372. 0x1487767, 0x133e8d5, 0x1b491cb, 0x1eadf3b, 0x07a4aa3 },
  49373. { 0x07a0045, 0x178dd71, 0x0d41567, 0x1f64859, 0x1c812d4, 0x07c6926,
  49374. 0x1e390e7, 0x0a84748, 0x19b3f9c, 0x1aa27e2, 0x087f3e5, 0x02655ff,
  49375. 0x1b5ac68, 0x1a51641, 0x1e3fb80, 0x0976ee9, 0x00fcd3f, 0x14b6632,
  49376. 0x0144ba9, 0x1b9d3b6, 0x181e775, 0x0ee6e71, 0x19f7286, 0x1a7fcaa,
  49377. 0x0b3f3a9, 0x1a7e0f7, 0x0868649, 0x11c17e8, 0x169b123, 0x17da146,
  49378. 0x1e05664, 0x13fa13b, 0x0fcebde, 0x15aefa4, 0x093ed06, 0x0bb93bf,
  49379. 0x00a269c, 0x1ebee46, 0x0b78432, 0x0f7efe1, 0x060282a },
  49380. { 0x0eea2e7, 0x1f29c6e, 0x1875f01, 0x1078840, 0x18a322c, 0x0fb28b1,
  49381. 0x0a3e53c, 0x020ced0, 0x1c7776a, 0x10db4fd, 0x1ad017c, 0x082f6bc,
  49382. 0x02c63a3, 0x08d3db2, 0x067c962, 0x0288099, 0x0a82cad, 0x09c3496,
  49383. 0x021a6f3, 0x105ffc0, 0x066af1e, 0x070b7f2, 0x10c2dc5, 0x0032271,
  49384. 0x142f919, 0x1572fdb, 0x003e945, 0x1202cda, 0x073a43e, 0x1bd66c6,
  49385. 0x1c95543, 0x1f78b86, 0x16a407d, 0x01cf696, 0x14e5a33, 0x01c8f4e,
  49386. 0x0a5fbe7, 0x09436ca, 0x0e508ff, 0x18e478d, 0x05f4ae9 },
  49387. { 0x1f4d561, 0x116ed29, 0x064b65a, 0x002db43, 0x086d45d, 0x0a58289,
  49388. 0x007eff7, 0x1d48934, 0x19f2195, 0x0a44506, 0x1986cc9, 0x161546e,
  49389. 0x02c4151, 0x1cf2f70, 0x0311c7b, 0x1102f73, 0x06ea865, 0x1525e54,
  49390. 0x09a3f02, 0x15b70ef, 0x06a9bbc, 0x04b5b9b, 0x022cd19, 0x0cc385b,
  49391. 0x098d415, 0x1061977, 0x1b24050, 0x0b67698, 0x0752aff, 0x139a979,
  49392. 0x07288d4, 0x0a21c9b, 0x164ce73, 0x0554017, 0x1c9ab29, 0x072734f,
  49393. 0x001aa50, 0x09f148a, 0x0bf4a73, 0x047b88d, 0x092a014 },
  49394. { 0x02f7dbd, 0x125f08e, 0x1feba7c, 0x1f6faa4, 0x1a8c900, 0x0478946,
  49395. 0x096ee19, 0x0832c7c, 0x0481419, 0x15b89f1, 0x1d5bee6, 0x1a02f4c,
  49396. 0x1de87f7, 0x02c6c85, 0x1376178, 0x0d57a4e, 0x07a8256, 0x0c11ff7,
  49397. 0x1090065, 0x0461aee, 0x046e9f6, 0x16565af, 0x0115e7c, 0x14990fc,
  49398. 0x0626316, 0x02b9511, 0x0f666c2, 0x1943348, 0x08789e9, 0x15d1f24,
  49399. 0x0f61b70, 0x1280d87, 0x160b5b9, 0x04abf7c, 0x0a2e258, 0x16de588,
  49400. 0x161c515, 0x1a43830, 0x12e6e41, 0x03d5511, 0x00fc8fe },
  49401. { 0x0b90f2d, 0x10df6ff, 0x1565a2b, 0x1949162, 0x1393bb3, 0x074b1af,
  49402. 0x0be73d9, 0x18457cc, 0x0f8be75, 0x0a61208, 0x1dd4a4d, 0x0e06bcd,
  49403. 0x11bd7ea, 0x0b16559, 0x1921a38, 0x1e7ff84, 0x070c860, 0x1589c8f,
  49404. 0x16260df, 0x0cf8ea3, 0x0941df3, 0x1a15f99, 0x18542da, 0x182631f,
  49405. 0x0f46e78, 0x0b04af4, 0x0e8b12c, 0x167e3b5, 0x1afbf32, 0x1ae7380,
  49406. 0x1171b33, 0x0bd10e9, 0x0d27530, 0x16e5f1d, 0x1945771, 0x1a7250b,
  49407. 0x199892d, 0x0aa6c36, 0x1e27cf2, 0x0c5bfa6, 0x02d0ba8 },
  49408. { 0x072e1af, 0x0c7745a, 0x0f33ab3, 0x1d6ed57, 0x0b354ea, 0x0c9fdef,
  49409. 0x02fe343, 0x00d36a4, 0x1fe6fc7, 0x066b06b, 0x18bce7f, 0x1bbd49d,
  49410. 0x1ea9353, 0x0d40f28, 0x0c2497a, 0x0ceeebd, 0x1a1d136, 0x0f719a6,
  49411. 0x14d535a, 0x05193fa, 0x0d54c1d, 0x0ac952f, 0x0e5dc5d, 0x1ee1b03,
  49412. 0x0367fb7, 0x13d2e9f, 0x0aa4ceb, 0x17cfdd9, 0x1cfbb77, 0x18fcf11,
  49413. 0x0049933, 0x11292ed, 0x1129f4a, 0x111ad86, 0x169026d, 0x14e0a6e,
  49414. 0x08a376d, 0x1b263aa, 0x16ff333, 0x0249a83, 0x0963c87 },
  49415. { 0x036a814, 0x14865ef, 0x0ad6eb8, 0x0ae6762, 0x1bdb019, 0x1ff070c,
  49416. 0x1619fdd, 0x1d41d75, 0x129720c, 0x13e8cfe, 0x07b1c82, 0x0ca3205,
  49417. 0x1e434d7, 0x1da8c88, 0x1abfc5e, 0x0fec10a, 0x19ad80a, 0x168512e,
  49418. 0x0123041, 0x150d5ff, 0x149cffc, 0x1ca1d6b, 0x14fa2f7, 0x1cd2d76,
  49419. 0x00284e3, 0x10afdcf, 0x0bbbb90, 0x1d6cc61, 0x0f3c633, 0x1dcf176,
  49420. 0x102763e, 0x09c0181, 0x1da4ffa, 0x1df5638, 0x1965755, 0x1f652d7,
  49421. 0x08cec7e, 0x08fdd6d, 0x15ef45d, 0x079feab, 0x02d03eb },
  49422. { 0x0f2ec1d, 0x1492f82, 0x1b8bac5, 0x0c1a28f, 0x0878f27, 0x0cecf05,
  49423. 0x1d812ab, 0x0b6885b, 0x13f7103, 0x08efa25, 0x05756e2, 0x0567197,
  49424. 0x03c2827, 0x0f74769, 0x053bed5, 0x1e7c6de, 0x00f13b0, 0x179e223,
  49425. 0x0f5ccd7, 0x1f37aed, 0x1a6e889, 0x18fbaad, 0x0227b9d, 0x04336d9,
  49426. 0x184feed, 0x008b134, 0x1fb0bb9, 0x1a898e6, 0x0fcd372, 0x02d131f,
  49427. 0x1aee50e, 0x0cc6f04, 0x109321b, 0x15bd3ec, 0x09e4fb9, 0x0f849f1,
  49428. 0x07cf61b, 0x0546925, 0x0b3668f, 0x1838a97, 0x0842e40 },
  49429. { 0x061d843, 0x1476b53, 0x0335689, 0x149eb66, 0x02328cc, 0x08f0bb8,
  49430. 0x1fb444c, 0x0ce2dcd, 0x0c66959, 0x086f65a, 0x0b8a01a, 0x17ecaf6,
  49431. 0x10bdac5, 0x0f7f216, 0x1fe0b28, 0x1945f04, 0x00aca5f, 0x162aa76,
  49432. 0x1791541, 0x04ed83b, 0x1513ac5, 0x047183b, 0x0dfd32c, 0x10f2f99,
  49433. 0x16d9acc, 0x1694657, 0x10364cc, 0x0b2c902, 0x1a409fd, 0x114b942,
  49434. 0x04f31ab, 0x0c447a1, 0x173c2a5, 0x07e04bb, 0x1ab144a, 0x185aa4c,
  49435. 0x1c31fe6, 0x0b5be5d, 0x04ca296, 0x1359592, 0x00e6331 },
  49436. { 0x0360ac2, 0x097d6f8, 0x016ad73, 0x1c50bcc, 0x06b660d, 0x0dcd8a4,
  49437. 0x13c4389, 0x0a9058d, 0x1aa9ac5, 0x0afd1c6, 0x101c3a7, 0x0370a4d,
  49438. 0x0d3dfcf, 0x1fe6629, 0x1e6a5ac, 0x18fea06, 0x0290bfc, 0x0f1b2ce,
  49439. 0x074f9a8, 0x147b6ad, 0x02d55b1, 0x1acdbda, 0x0d054a2, 0x045400d,
  49440. 0x1efa49c, 0x1db49a6, 0x026d338, 0x01e7003, 0x0baf329, 0x1e0259d,
  49441. 0x18ac1ce, 0x1ff0713, 0x1a5a222, 0x0d1ad93, 0x1547fe9, 0x0416f53,
  49442. 0x08e1a7c, 0x1cf6779, 0x1c16924, 0x14430e4, 0x088839d },
  49443. { 0x01ce29a, 0x1361838, 0x15415ad, 0x0cb1303, 0x1acaf12, 0x0fcf909,
  49444. 0x1f03041, 0x027a9b5, 0x0373e3d, 0x172b8f3, 0x1b8f2bf, 0x190df45,
  49445. 0x1ae7269, 0x0e901c2, 0x132992b, 0x1d359eb, 0x1573000, 0x190bf93,
  49446. 0x19c9cfb, 0x09b68e1, 0x0776c93, 0x1b9aadb, 0x10a53d3, 0x180a300,
  49447. 0x036b96f, 0x0858fd5, 0x0ec1486, 0x1f1163b, 0x0aef528, 0x0dc874f,
  49448. 0x040d5e4, 0x1b6d037, 0x17fb2eb, 0x0e1b4f9, 0x1475105, 0x1273a14,
  49449. 0x1d2e21c, 0x0ce6538, 0x0309bf1, 0x1fd43ea, 0x064128c },
  49450. { 0x0f5b0b5, 0x13c5174, 0x0167c0d, 0x19a681e, 0x1c7e249, 0x053e762,
  49451. 0x011064f, 0x1308288, 0x0bc83af, 0x1ae51a3, 0x02eec01, 0x0067f55,
  49452. 0x17f39f0, 0x19c1187, 0x063c3b7, 0x1e68a7a, 0x00cd448, 0x0bc6ff8,
  49453. 0x146a91d, 0x045181a, 0x08d1849, 0x0418649, 0x175389c, 0x0259fa7,
  49454. 0x1a6868f, 0x1036335, 0x0e22ce8, 0x122093b, 0x0dae010, 0x082c80b,
  49455. 0x1f76197, 0x1c4a7c6, 0x199e905, 0x0c38da2, 0x0309f3a, 0x1c6459e,
  49456. 0x174a132, 0x07aa6d0, 0x12f6805, 0x0137b57, 0x093634a },
  49457. { 0x1a2e304, 0x13593d4, 0x04918a0, 0x0d83498, 0x057e186, 0x1c0b886,
  49458. 0x0e0c888, 0x1fd2275, 0x1a9847c, 0x14db5c2, 0x1d1bf5f, 0x19e256b,
  49459. 0x0d29655, 0x001c733, 0x0555cae, 0x0bd56e5, 0x0016fa9, 0x0f265d3,
  49460. 0x077b6a0, 0x0220e37, 0x161ebbc, 0x0d1f8e7, 0x05fc002, 0x07c19f7,
  49461. 0x0777b37, 0x11da9b9, 0x1344e75, 0x005f213, 0x07d78e3, 0x196d27c,
  49462. 0x18c7b59, 0x168090e, 0x02077a3, 0x011591b, 0x0cb6773, 0x0f88118,
  49463. 0x06deeee, 0x062df91, 0x0d5f92d, 0x0cf780c, 0x0266cb4 },
  49464. { 0x16363e8, 0x120aa5a, 0x136dbea, 0x1078354, 0x0b4fd07, 0x0f32cba,
  49465. 0x03778ae, 0x108286b, 0x0fa004b, 0x19a571f, 0x0446996, 0x05d9e33,
  49466. 0x18cf44b, 0x129b5fb, 0x12aa0ce, 0x1b92aab, 0x0b98870, 0x0b0370f,
  49467. 0x07cd447, 0x0650fa1, 0x1364e3c, 0x15ceae7, 0x1a2cbd3, 0x157193c,
  49468. 0x0e89263, 0x108e0aa, 0x1b0daad, 0x0a91051, 0x17d1201, 0x1fe5d0d,
  49469. 0x15c24ca, 0x0a62b71, 0x0e7b5bc, 0x19d60bf, 0x0347dd1, 0x06f05fa,
  49470. 0x1c8f2af, 0x1814d41, 0x13b86f2, 0x036a48a, 0x04b1d5a },
  49471. { 0x1d52c0c, 0x128ba31, 0x06744bf, 0x1c31181, 0x1735525, 0x071cab1,
  49472. 0x0558cd8, 0x086b8c4, 0x0acfa5a, 0x059f8e5, 0x1a041e2, 0x1414f2f,
  49473. 0x0a90123, 0x18af040, 0x0c7dad6, 0x1b5b574, 0x012fca3, 0x06bef2f,
  49474. 0x17d4472, 0x0e6c361, 0x1d4e328, 0x0a32bab, 0x1f32003, 0x00fd922,
  49475. 0x10f3d52, 0x0718840, 0x04c3ba8, 0x1a9cade, 0x05a2ec0, 0x17099f5,
  49476. 0x142efdf, 0x17cd577, 0x1c07762, 0x1fb0cb7, 0x1738482, 0x159063f,
  49477. 0x1622d42, 0x1a1cfd5, 0x12c9f81, 0x07ea11c, 0x08186b9 },
  49478. { 0x1312867, 0x0e8aa04, 0x16d3186, 0x0b7f5ef, 0x1e042c0, 0x0faeed3,
  49479. 0x059a07d, 0x105839e, 0x1a4fc3d, 0x055282b, 0x02e3f94, 0x1acb9cd,
  49480. 0x04ed30e, 0x1f5a6b2, 0x0c0702e, 0x0092fd9, 0x044831c, 0x03daee2,
  49481. 0x0df66c7, 0x1cd4013, 0x1c91351, 0x1ceca3b, 0x12ee18e, 0x1a82214,
  49482. 0x0589105, 0x1bd55d3, 0x110d602, 0x0010d9e, 0x1e357e3, 0x003b485,
  49483. 0x13ac4e7, 0x04f6a42, 0x0bfff1a, 0x1d5ab89, 0x1b5c8b0, 0x14f39f8,
  49484. 0x134a9bf, 0x01ef2bf, 0x0aca91d, 0x12f93dc, 0x00bf97e },
  49485. { 0x1a19e96, 0x027646e, 0x1a2e5bb, 0x14d860d, 0x14ce18e, 0x1b48c52,
  49486. 0x184ad97, 0x132fd06, 0x10d9a0d, 0x1637b45, 0x1730246, 0x0f48c5f,
  49487. 0x1398a69, 0x0ade1f0, 0x13897c6, 0x12e60cb, 0x0dab393, 0x10c4b76,
  49488. 0x0bc4a01, 0x10341e6, 0x07df9eb, 0x170e96e, 0x14f5d05, 0x08e6b33,
  49489. 0x07976ad, 0x01cf116, 0x0a7d7bd, 0x1bc6f53, 0x09d94e3, 0x0055cf3,
  49490. 0x121adeb, 0x0153a17, 0x0bfa9e0, 0x1789073, 0x1c3559d, 0x1eaed50,
  49491. 0x1eaac23, 0x0c8dda7, 0x0aaecef, 0x0587c81, 0x08fe548 },
  49492. { 0x09a4d1e, 0x133e167, 0x00e216b, 0x069e3a4, 0x0c3eb80, 0x0830c92,
  49493. 0x03ce897, 0x038b8d9, 0x1308fb4, 0x01ef056, 0x10a53a0, 0x0b79ce3,
  49494. 0x1a9961f, 0x1817586, 0x1881e37, 0x1d16db8, 0x115b64a, 0x1e43f7a,
  49495. 0x02d3463, 0x0f3e3ca, 0x1f43696, 0x10a90cc, 0x1170026, 0x0c814bf,
  49496. 0x084be0f, 0x0b353ea, 0x048f6ad, 0x1923176, 0x075d2c4, 0x08a6321,
  49497. 0x15a99f0, 0x195a5bd, 0x1a913b9, 0x1ae46ca, 0x062dad2, 0x0c313da,
  49498. 0x142d3bf, 0x15b1035, 0x0f0fd2b, 0x0d37791, 0x03928c6 },
  49499. { 0x0cb4b64, 0x1f5256d, 0x0687792, 0x09e4c2f, 0x03f62a4, 0x0889520,
  49500. 0x12539ea, 0x03de755, 0x1d36f33, 0x02247de, 0x0e17124, 0x057880f,
  49501. 0x1b42604, 0x1090dbb, 0x1629658, 0x1d308b5, 0x04f67ce, 0x098b3a5,
  49502. 0x18ecbc3, 0x1d177c9, 0x10eb7fa, 0x0ed3e49, 0x1a077db, 0x0b3a1a8,
  49503. 0x0fa98c2, 0x0fed6f7, 0x1afa870, 0x1629b3c, 0x1405d11, 0x0e4590e,
  49504. 0x150eeab, 0x0e7124e, 0x01dff93, 0x0e6f278, 0x0cfbc1c, 0x130386b,
  49505. 0x1150d0d, 0x026970c, 0x0d3d85c, 0x11e6aa2, 0x06ccc88 },
  49506. { 0x0d7504c, 0x1b7873d, 0x1777e34, 0x1fef2b3, 0x1ca3265, 0x0f33d55,
  49507. 0x07b7bfb, 0x05e1b9a, 0x0baebf3, 0x13b7a67, 0x1b73f04, 0x0dcc029,
  49508. 0x176825a, 0x0cd6c75, 0x0306a0a, 0x19c3c17, 0x0a909b8, 0x1189012,
  49509. 0x12f4d46, 0x1fb3173, 0x08becb8, 0x1c7d58f, 0x092104d, 0x0e7959f,
  49510. 0x10f5d39, 0x12a0bf6, 0x1096754, 0x02fc290, 0x191393a, 0x1c21ba5,
  49511. 0x1a54f56, 0x0359479, 0x1792b21, 0x07c0ac7, 0x0443230, 0x1a06bfe,
  49512. 0x0d4ed7b, 0x1d31abd, 0x0bbe5ab, 0x10164df, 0x02f1519 },
  49513. { 0x1d2d439, 0x118ed14, 0x0554321, 0x0578073, 0x121fbbc, 0x02dbad8,
  49514. 0x05e49b0, 0x1d87cb5, 0x0b6ce47, 0x0b67a60, 0x031961b, 0x0ecf3b1,
  49515. 0x17baaa1, 0x199aad0, 0x076e79f, 0x0b50a06, 0x1d80aef, 0x1c1c0f1,
  49516. 0x168c6f7, 0x1b65202, 0x1d7dc71, 0x1a4a4c7, 0x18e3dad, 0x17dddec,
  49517. 0x1f3f913, 0x1d9a276, 0x07d2ad9, 0x0c2e64e, 0x02df11e, 0x16387e9,
  49518. 0x048e880, 0x040b89d, 0x1be0389, 0x1cc907b, 0x0216a3a, 0x1438432,
  49519. 0x1eb54aa, 0x002e745, 0x03595b2, 0x16e158b, 0x0354b05 },
  49520. { 0x09170e9, 0x0f11b3d, 0x0335c5c, 0x1a995aa, 0x01eec42, 0x0ee67d8,
  49521. 0x0093cf3, 0x035ff7d, 0x1a66cae, 0x19f4671, 0x11f4069, 0x14ff2cb,
  49522. 0x1eb7138, 0x0e1ecb8, 0x01638fd, 0x14e5600, 0x0c32ff0, 0x1a92c8d,
  49523. 0x0ef39db, 0x1f6b797, 0x1a18a32, 0x1c54fc0, 0x1cc906a, 0x14d0c61,
  49524. 0x13332ec, 0x09df98e, 0x11120bc, 0x08f5f3f, 0x081be28, 0x110bd23,
  49525. 0x1e5865b, 0x1cabdf9, 0x138f932, 0x06382cc, 0x12e1c2b, 0x047cfb5,
  49526. 0x0f09fac, 0x0df449e, 0x08e8750, 0x1895c6a, 0x048dc55 },
  49527. { 0x1092193, 0x11c1352, 0x1c32398, 0x04d1312, 0x046ec36, 0x04f5a0f,
  49528. 0x15abc97, 0x08a5e26, 0x083c7d2, 0x0bc0320, 0x0038e10, 0x1ecf2fa,
  49529. 0x1c982de, 0x12890a8, 0x0badb9e, 0x110d270, 0x0778af5, 0x10aa708,
  49530. 0x09473c0, 0x00e0eb1, 0x1c58187, 0x1bb8989, 0x137aea7, 0x02ab209,
  49531. 0x1b973ba, 0x19d2eb3, 0x0c7435e, 0x0a393e9, 0x0af2cd8, 0x0eb8c5c,
  49532. 0x18867ca, 0x130d71a, 0x194ccff, 0x1ce19e5, 0x092ee4e, 0x110e4bc,
  49533. 0x06e38c6, 0x0e7262b, 0x1008501, 0x1ba16db, 0x05f6a8e },
  49534. { 0x19a8690, 0x02652c7, 0x101e0dc, 0x0c5eed4, 0x1f36976, 0x1008141,
  49535. 0x0b631a4, 0x19ff782, 0x0bce3a4, 0x06ac78b, 0x0ac9b53, 0x0c94095,
  49536. 0x0878046, 0x07522bd, 0x173eee9, 0x12f2800, 0x1b3b8a5, 0x0a9bca8,
  49537. 0x1f87dce, 0x0573c89, 0x17974ca, 0x06ef992, 0x1910a2b, 0x14487b7,
  49538. 0x1a3420e, 0x00f3246, 0x0fd0f38, 0x19ccac5, 0x1db490c, 0x0210f93,
  49539. 0x1c2103c, 0x117f6f9, 0x16ccb70, 0x1cbe98a, 0x00356a1, 0x1736669,
  49540. 0x1eb814b, 0x09703d4, 0x01eb0b8, 0x0e594ff, 0x01ca650 },
  49541. { 0x19d25a0, 0x190e795, 0x1b6feec, 0x14814e8, 0x06affdc, 0x11b45ab,
  49542. 0x14c3967, 0x11f8382, 0x07d8006, 0x1768f52, 0x1f75a15, 0x11fcac8,
  49543. 0x089b74d, 0x04dbc6d, 0x05ad41e, 0x067223b, 0x0438bbe, 0x19cdba9,
  49544. 0x1616317, 0x1a887c1, 0x0a34ef8, 0x04cb235, 0x1374b6d, 0x0cea878,
  49545. 0x13bd1e6, 0x0c2bfd6, 0x01a2602, 0x01ae218, 0x1acabad, 0x1f9924f,
  49546. 0x04a7deb, 0x029f343, 0x15dec1c, 0x183d082, 0x0e647ec, 0x09594cc,
  49547. 0x15ffff6, 0x027ec89, 0x0f3bab1, 0x16d975a, 0x0462caf },
  49548. { 0x03237dd, 0x05323ef, 0x1010598, 0x190570e, 0x15f735c, 0x1d2afc4,
  49549. 0x07d6777, 0x095ef0f, 0x0726b91, 0x0f7821f, 0x0f8a605, 0x127a392,
  49550. 0x1118753, 0x1778c19, 0x08af9d1, 0x1425743, 0x1fc25a9, 0x1a73f46,
  49551. 0x070e45f, 0x1f92fb5, 0x1e41dfe, 0x0185175, 0x0f21d74, 0x065a399,
  49552. 0x1d235a7, 0x16987ba, 0x1b66ea9, 0x0dfdcff, 0x1485760, 0x07d5b2f,
  49553. 0x102a9e1, 0x0a27f07, 0x1155e22, 0x1ce8991, 0x1c60fa3, 0x1ba5f6e,
  49554. 0x1546eaf, 0x148a81d, 0x0d820a8, 0x118d9b2, 0x01293c9 },
  49555. { 0x1d53b77, 0x00928a4, 0x0b1dc9e, 0x1b2dd5f, 0x06ab403, 0x1b5b88d,
  49556. 0x11f6d28, 0x1836faf, 0x087e771, 0x11c6384, 0x0dd48a0, 0x157e676,
  49557. 0x0d495f6, 0x0643a98, 0x0c0a272, 0x0223561, 0x186e77b, 0x16541e5,
  49558. 0x06f4627, 0x181f714, 0x17c7be1, 0x1d8d74e, 0x1633ecb, 0x08187d0,
  49559. 0x023c549, 0x083e82e, 0x05d2b64, 0x0dcf3c8, 0x0e71421, 0x1f82832,
  49560. 0x13e8291, 0x1fbfac2, 0x0929cd4, 0x14c45e3, 0x0130e51, 0x03db64b,
  49561. 0x046f8fb, 0x125af9f, 0x052e9cf, 0x142d1d5, 0x053b79a },
  49562. { 0x0bbb6a1, 0x1d7e722, 0x1ca085b, 0x00cf042, 0x13a5bba, 0x0ec9cd6,
  49563. 0x12cc2a7, 0x1fdde3c, 0x1f19efa, 0x117579e, 0x1b00500, 0x179cf69,
  49564. 0x18fed5a, 0x0896339, 0x05a3b99, 0x11344c9, 0x06929fe, 0x09188cc,
  49565. 0x1ce5f01, 0x073b1a8, 0x16c40d5, 0x0a11a2c, 0x19002f1, 0x08cc23a,
  49566. 0x07f5853, 0x107dc94, 0x0f27576, 0x0813320, 0x1af2a80, 0x04cbe41,
  49567. 0x18797bd, 0x06502a3, 0x09dc01b, 0x0088264, 0x12a5610, 0x1a2a1f6,
  49568. 0x13872c9, 0x137beaf, 0x1a0cd02, 0x1a2ad85, 0x08290d6 },
  49569. { 0x0546946, 0x11be36c, 0x1febe11, 0x12d3d8a, 0x1a134a3, 0x04803f6,
  49570. 0x166935e, 0x013a846, 0x00dc7b8, 0x012abff, 0x1e12a6d, 0x0a5a5ac,
  49571. 0x1fe62ae, 0x05e56da, 0x1c53298, 0x1f94b44, 0x1e633aa, 0x0e61046,
  49572. 0x1659e04, 0x01dab9d, 0x1660238, 0x14ed990, 0x1b9ad57, 0x0ea46b4,
  49573. 0x0d02ca6, 0x0708df5, 0x06ccfe8, 0x0398ddf, 0x0a2a085, 0x1f13783,
  49574. 0x13ff488, 0x1d88f67, 0x0f332e1, 0x14c2700, 0x05ee82a, 0x088b3e5,
  49575. 0x0e952e1, 0x10ecb4f, 0x0aec1be, 0x156609f, 0x0506ef1 },
  49576. { 0x1bff163, 0x075939a, 0x061046d, 0x1fd53f5, 0x1130b96, 0x1593e73,
  49577. 0x1acfe77, 0x1aacd59, 0x19dd1c3, 0x16d78d2, 0x01d6aa8, 0x14fd4e6,
  49578. 0x18f5090, 0x11838da, 0x09abce7, 0x15b386d, 0x13ddf73, 0x15146b1,
  49579. 0x1722685, 0x0a99597, 0x1c3cdd3, 0x11ea6e5, 0x17fa8d0, 0x13b25a3,
  49580. 0x074d237, 0x1b2b776, 0x1e3bb59, 0x02948ad, 0x0feb1fe, 0x1ba1fd4,
  49581. 0x11feaf9, 0x1731f97, 0x004ccf8, 0x138370a, 0x1effdc6, 0x10d99a5,
  49582. 0x0d85c67, 0x179feda, 0x00d136a, 0x17e2a40, 0x0415b7d },
  49583. { 0x18377a7, 0x082c33e, 0x09ca5c0, 0x1197006, 0x068a3d6, 0x1d26190,
  49584. 0x14a27c0, 0x121facf, 0x193c8f2, 0x1e384ae, 0x168ae12, 0x0279d3c,
  49585. 0x1b712fa, 0x07f5cf9, 0x1ab1b18, 0x0a985f8, 0x0d96e0e, 0x0866d1b,
  49586. 0x18c8280, 0x132ea30, 0x0f11454, 0x08cbf80, 0x1e4c632, 0x126ca11,
  49587. 0x04c3fe6, 0x05500ee, 0x0617c1a, 0x0d345df, 0x15511c7, 0x0778515,
  49588. 0x014d48b, 0x168245c, 0x06965ed, 0x0ea1f80, 0x0bf305d, 0x13f9c1f,
  49589. 0x0c831d5, 0x0ee4def, 0x01e7549, 0x1e35eb1, 0x01ec314 },
  49590. { 0x08310c2, 0x1ff7796, 0x1dd0198, 0x148afc7, 0x0a7e14d, 0x1a3443d,
  49591. 0x043f394, 0x18a7256, 0x1637ec2, 0x0f251c7, 0x0be37f3, 0x06416a8,
  49592. 0x1150773, 0x1bef0b8, 0x04c0be7, 0x1378c68, 0x063ae4b, 0x180c58e,
  49593. 0x14be79b, 0x0388ddb, 0x0fa0f00, 0x0b93766, 0x14eec2a, 0x08dc18f,
  49594. 0x1b99d77, 0x1765498, 0x1fd61d6, 0x01916de, 0x139c82e, 0x18be4b4,
  49595. 0x192eccb, 0x07bcb4c, 0x05135d2, 0x1fd35bb, 0x12d14aa, 0x1ce326d,
  49596. 0x0dc105d, 0x0e60479, 0x15e22b5, 0x024fffe, 0x017e91d },
  49597. { 0x1e051ca, 0x16769db, 0x1b52fa4, 0x1a338ee, 0x0644d4f, 0x033c25e,
  49598. 0x12d4802, 0x0639156, 0x1ce9d6b, 0x1533113, 0x07a71cf, 0x1347a51,
  49599. 0x0e39524, 0x08950cf, 0x1427997, 0x0b5d8a8, 0x0928c36, 0x153dea3,
  49600. 0x1e58f83, 0x132fc8e, 0x132d354, 0x0bdaccb, 0x035d965, 0x1a9476c,
  49601. 0x04aeb91, 0x1144cac, 0x1077acf, 0x1cca7d4, 0x0571df6, 0x0c76ab9,
  49602. 0x1e729f2, 0x16315c3, 0x101a38f, 0x1dcbf79, 0x1f098fd, 0x0a2c53e,
  49603. 0x0fc4a0d, 0x1211415, 0x030077c, 0x0967bba, 0x0118f3b },
  49604. { 0x0d4762b, 0x050543d, 0x05d5d28, 0x1518b1a, 0x1aef84d, 0x1bb6c30,
  49605. 0x1258133, 0x1162dfe, 0x07e60d9, 0x05f43c3, 0x1076eb0, 0x1ff67d9,
  49606. 0x1a83637, 0x0eeb0a3, 0x1129825, 0x08dcb84, 0x0345b08, 0x0d1f0bc,
  49607. 0x1de9301, 0x1d6d0dc, 0x0695735, 0x07efbac, 0x16f062d, 0x1bfca5e,
  49608. 0x18d0b1b, 0x1d08ab0, 0x1401c56, 0x0f1d981, 0x1d617f8, 0x1e8d616,
  49609. 0x04076f6, 0x0436c2e, 0x1d2b631, 0x0c9e110, 0x09e513d, 0x08459d1,
  49610. 0x04f1702, 0x0da9b52, 0x19c9cee, 0x0f91a07, 0x001d0a6 },
  49611. { 0x046533c, 0x1211b0f, 0x0ab9ee5, 0x01f7118, 0x0947799, 0x16250c7,
  49612. 0x1745a90, 0x08a0336, 0x1d83c7a, 0x09af40e, 0x198f8dc, 0x17ba996,
  49613. 0x0374a69, 0x13b606b, 0x19fb36f, 0x11b4cf6, 0x12111e6, 0x101eaa2,
  49614. 0x0ba1942, 0x199d6ba, 0x1b37596, 0x1e95781, 0x1355cb7, 0x17ab2a5,
  49615. 0x04ba1fa, 0x0b4a91b, 0x1ad3b61, 0x1e8fa8a, 0x10d5d47, 0x1ab964a,
  49616. 0x0116b62, 0x090dc5f, 0x0dd2dfa, 0x1d82265, 0x0d0f15a, 0x0dbaa4f,
  49617. 0x197c08e, 0x16dd124, 0x0c83f26, 0x00cfb4c, 0x01b625b },
  49618. { 0x1d8446d, 0x1d53da7, 0x0fad137, 0x035edfd, 0x001b2f0, 0x041c5ae,
  49619. 0x10e23fa, 0x1177e88, 0x1bba975, 0x19e21a7, 0x15af27c, 0x19750e2,
  49620. 0x0b2b971, 0x0fa484c, 0x0917970, 0x18bbad6, 0x1342b41, 0x1c3ee5a,
  49621. 0x13614b5, 0x1f018c6, 0x1a34db1, 0x0c1219e, 0x1b5b8c9, 0x0fbe184,
  49622. 0x020653f, 0x1b2fb34, 0x10d832c, 0x0994acf, 0x06656ac, 0x15614c1,
  49623. 0x1a0c87e, 0x17e0d2e, 0x1f5ca6f, 0x1b31c89, 0x04869c1, 0x1c2a72f,
  49624. 0x0400736, 0x18a1944, 0x05236f7, 0x12c33f9, 0x0333eca },
  49625. { 0x0775d81, 0x1bca456, 0x0f288cc, 0x1fa83b7, 0x18c2518, 0x1e74a41,
  49626. 0x1e93ef3, 0x1cec478, 0x054703f, 0x169b11b, 0x0ced6ea, 0x074827f,
  49627. 0x102b3a1, 0x1fae00f, 0x0cd5969, 0x12cc2bb, 0x0dc5235, 0x0eb9204,
  49628. 0x1585ba4, 0x0ff1ca3, 0x19995a1, 0x15e592d, 0x04305bb, 0x126e87d,
  49629. 0x08cf133, 0x053f9af, 0x0b952d9, 0x10fb4e9, 0x0d449d9, 0x191532e,
  49630. 0x17555ec, 0x06fcf62, 0x05082a5, 0x089a7bb, 0x1d0bcb3, 0x0c9a4b8,
  49631. 0x0ccf074, 0x0ece03a, 0x144d6ba, 0x0210e51, 0x072fc21 },
  49632. { 0x16004c8, 0x15901fc, 0x17fea41, 0x1e8b00a, 0x183f95c, 0x19ac84e,
  49633. 0x1619d57, 0x1ddaefa, 0x1e550c8, 0x14f537d, 0x0182052, 0x1952ab4,
  49634. 0x0291c8c, 0x1e74103, 0x07fb9e2, 0x1f0bc94, 0x0069a3d, 0x175cd6f,
  49635. 0x14f7999, 0x1b9e18f, 0x0d51fbb, 0x0dae99b, 0x08a28e4, 0x05ff878,
  49636. 0x18d285c, 0x12dbb07, 0x0cbdec5, 0x1dc91bc, 0x1770401, 0x1ec22b0,
  49637. 0x0800e00, 0x13bdff3, 0x173f648, 0x11ad272, 0x0e3a85f, 0x0dc344e,
  49638. 0x0840a6c, 0x0778be4, 0x164b48e, 0x1f1623d, 0x0480946 },
  49639. { 0x171f119, 0x1a3d47e, 0x1a56131, 0x1ca7d66, 0x19e65c5, 0x0c2c3d0,
  49640. 0x19e198a, 0x1e81c5e, 0x1ab18d6, 0x052444c, 0x02e3012, 0x00498c6,
  49641. 0x12a1a99, 0x16557c4, 0x05d4258, 0x1ac4909, 0x0bae20f, 0x064434d,
  49642. 0x10adf75, 0x05609ad, 0x17d03b7, 0x1b04c97, 0x189dd7a, 0x00dcd09,
  49643. 0x1c06e7d, 0x0038044, 0x0792ef4, 0x167686c, 0x0846e4c, 0x1335a5d,
  49644. 0x07a86b9, 0x08c8c9b, 0x01c2eb2, 0x029cfe0, 0x0f9b07e, 0x0ff0de5,
  49645. 0x0f68afc, 0x1474576, 0x1a4085b, 0x1fb8e70, 0x08dab61 },
  49646. { 0x14d1d45, 0x0e481ea, 0x0e890a9, 0x1dfe9f3, 0x0cd4297, 0x0a3c5a5,
  49647. 0x0d480d3, 0x0345b11, 0x108c462, 0x0d95d15, 0x195008d, 0x1376690,
  49648. 0x06d3d23, 0x088f997, 0x19dabb6, 0x1fb843b, 0x1cf3f06, 0x143bfc5,
  49649. 0x1b14540, 0x0e29833, 0x100d802, 0x15d2c83, 0x0841113, 0x1b992af,
  49650. 0x0229f31, 0x1f6c34a, 0x0ee05a7, 0x1d9cef5, 0x0f080e5, 0x050a965,
  49651. 0x1c556fa, 0x197af9d, 0x0b21b14, 0x0bf709f, 0x0b459ee, 0x193bdef,
  49652. 0x118f690, 0x1e543c8, 0x0a79f80, 0x05bf336, 0x06f77e6 },
  49653. { 0x00bbf59, 0x0def6f2, 0x0b5a89c, 0x06c8035, 0x177ba45, 0x0a0e688,
  49654. 0x180d5cd, 0x05e2eab, 0x04b71b0, 0x032da33, 0x0cd67cd, 0x0227502,
  49655. 0x0722eb7, 0x179c756, 0x04aa3f5, 0x1e76b2f, 0x12fff3b, 0x188d500,
  49656. 0x0170fef, 0x15f57ff, 0x0c4299a, 0x1783606, 0x047828b, 0x076f675,
  49657. 0x15d5777, 0x00518a6, 0x1b59a61, 0x1cbc5ce, 0x1a8be6a, 0x1039972,
  49658. 0x002184d, 0x1839eab, 0x06d7578, 0x1688177, 0x003da2f, 0x164689c,
  49659. 0x0184f0e, 0x0ebc434, 0x13e01e6, 0x12387a5, 0x063819c },
  49660. { 0x084b073, 0x1c970bc, 0x1fab294, 0x19d624c, 0x1ec3a1f, 0x181c53c,
  49661. 0x1d7c241, 0x0e07a0f, 0x0e4c47b, 0x195603e, 0x05ae472, 0x09dc37f,
  49662. 0x1ff9666, 0x157527d, 0x1d5d624, 0x0ca01d7, 0x191fade, 0x02d55f9,
  49663. 0x1c74481, 0x066ede2, 0x181ac5b, 0x08d069e, 0x07fd831, 0x0d50896,
  49664. 0x0cfe797, 0x12d0859, 0x0af6984, 0x0263993, 0x1d453ee, 0x0b69a75,
  49665. 0x10783f0, 0x0a096d7, 0x0d0319a, 0x1c655e0, 0x0f9c28b, 0x0fc8741,
  49666. 0x15e49b4, 0x057f762, 0x15fbb20, 0x02504cb, 0x067d48d },
  49667. { 0x02d56d6, 0x0acd3f5, 0x098c1a3, 0x1c4e901, 0x171abd0, 0x19b366e,
  49668. 0x076c2b9, 0x178d7a2, 0x007204e, 0x1db1ce5, 0x198a4fe, 0x05cfeef,
  49669. 0x1d89a24, 0x1add461, 0x19f28ad, 0x1f351bd, 0x03d64a2, 0x02396ee,
  49670. 0x1586804, 0x053be8e, 0x09d4842, 0x02e2db2, 0x057d8b2, 0x1924f9b,
  49671. 0x16b1b4d, 0x0cb7eea, 0x017b981, 0x1d17624, 0x129401f, 0x152855f,
  49672. 0x010fbf2, 0x021a383, 0x0900d0f, 0x00efaea, 0x0ea4a2c, 0x0a59e22,
  49673. 0x1f0e43f, 0x0bf5e18, 0x1371e8f, 0x071d070, 0x027950e },
  49674. { 0x1d0fa79, 0x10ff870, 0x17a7aac, 0x060916b, 0x0b9fd03, 0x11ba65a,
  49675. 0x11a24bf, 0x0d69926, 0x04eb21f, 0x1a413fd, 0x179f9ee, 0x1ef3524,
  49676. 0x1146716, 0x1eea629, 0x10afcd9, 0x0dbbe28, 0x14cd2e9, 0x09039ca,
  49677. 0x140aaa2, 0x02835d0, 0x0cc94e0, 0x0d4777b, 0x03b8038, 0x1019b5f,
  49678. 0x0849158, 0x0232ae7, 0x11a58a0, 0x1e7574b, 0x15dfbff, 0x027c2e8,
  49679. 0x094cd73, 0x13ed09e, 0x1f0440c, 0x12dec53, 0x14feec7, 0x175d008,
  49680. 0x1f2225a, 0x04cc09f, 0x175c687, 0x108f364, 0x054ff78 },
  49681. { 0x040b068, 0x177186f, 0x14789f1, 0x17cde74, 0x1226465, 0x1d90fb4,
  49682. 0x11813e8, 0x02bc494, 0x1c04181, 0x052d2d6, 0x0434ad4, 0x08831bf,
  49683. 0x0fe3285, 0x0e58600, 0x1d3963f, 0x011c776, 0x13b4a2c, 0x0e3478d,
  49684. 0x13367b2, 0x1be1021, 0x0a9f339, 0x0e5bc37, 0x0454d8b, 0x0ab5d5b,
  49685. 0x05e31c9, 0x035944a, 0x162da9b, 0x0d45803, 0x18a427d, 0x016e1b3,
  49686. 0x0b01a7a, 0x0519260, 0x1875500, 0x080f30b, 0x05967e8, 0x0d159b5,
  49687. 0x0e30b28, 0x0722b9f, 0x0c3f939, 0x10a7e30, 0x08adbad },
  49688. { 0x169d524, 0x1708f84, 0x11e4182, 0x0fe7379, 0x142fdaf, 0x00fe617,
  49689. 0x19d99f3, 0x09e79d8, 0x0e2336d, 0x0b5ce79, 0x103dfd1, 0x0bbd1c3,
  49690. 0x0e6aa1f, 0x04c27d8, 0x0f0ab48, 0x096519b, 0x1a61b46, 0x1a04867,
  49691. 0x090fcfb, 0x10de602, 0x07e740d, 0x0666af4, 0x056c5b3, 0x04d9a83,
  49692. 0x1168c30, 0x198201f, 0x0e05b01, 0x17c70d9, 0x007a1dd, 0x0379ac2,
  49693. 0x0bc53ae, 0x02e2fc3, 0x188b4f8, 0x1e4b67a, 0x06999b2, 0x036eb88,
  49694. 0x027e71c, 0x0160d50, 0x1797fcd, 0x06d8128, 0x0739300 },
  49695. { 0x0cdaf42, 0x1babe91, 0x0aae553, 0x1be8303, 0x188b591, 0x08a792b,
  49696. 0x1a067d5, 0x1791730, 0x0f18fd5, 0x0b21704, 0x13ae45a, 0x0ba2045,
  49697. 0x0592b30, 0x1527b4c, 0x05640f9, 0x1395c2e, 0x09d6117, 0x125ebeb,
  49698. 0x0a7006a, 0x1bfabba, 0x08ccdac, 0x0d6c888, 0x1c17775, 0x1591e2a,
  49699. 0x0c7b164, 0x197a1a5, 0x06d4918, 0x034a29c, 0x1fc4476, 0x130db98,
  49700. 0x0c516e7, 0x1c12c36, 0x1561348, 0x17911e7, 0x059dcfa, 0x0738515,
  49701. 0x0a7c99d, 0x0880c15, 0x197896f, 0x095c852, 0x08bc6ec },
  49702. { 0x1f2a32b, 0x172e073, 0x08c3425, 0x1812711, 0x1f54800, 0x0f1b067,
  49703. 0x10df100, 0x14c0dfc, 0x0bb6054, 0x12afe4e, 0x1ea9b99, 0x10c108a,
  49704. 0x17510e1, 0x1594d95, 0x0b3f288, 0x1b4c341, 0x1e351b7, 0x1399241,
  49705. 0x0f9b232, 0x08e3dcd, 0x09a1e31, 0x0e45b2e, 0x195950c, 0x1acb977,
  49706. 0x0c3b948, 0x1547e4d, 0x06ba6ca, 0x0611f84, 0x00aa6ad, 0x0f86d53,
  49707. 0x1535a9f, 0x1305f81, 0x044d96a, 0x1d26b94, 0x10b1611, 0x0b56025,
  49708. 0x1ceb895, 0x1e47b8e, 0x1f854ac, 0x0fb7d38, 0x08e8543 },
  49709. };
  49710. /* Perform the modular exponentiation in Fp* for SAKKE.
  49711. *
  49712. * Base is fixed to be the g parameter - a precomputed table is used.
  49713. *
  49714. * Striping: 128 points at a distance of 8 combined.
  49715. * Total of 256 points in table.
  49716. * Square and multiply performed in Fp*.
  49717. *
  49718. * base [in] Base. MP integer.
  49719. * exp [in] Exponent. MP integer.
  49720. * res [out] Result. MP integer.
  49721. * returns 0 on success, MP_READ_E if there are too many bytes in an array
  49722. * and MEMORY_E if memory allocation fails.
  49723. */
  49724. int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
  49725. {
  49726. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  49727. defined(WOLFSSL_SP_SMALL_STACK)
  49728. sp_digit* td;
  49729. sp_digit* t;
  49730. sp_digit* tx;
  49731. sp_digit* ty;
  49732. #else
  49733. sp_digit t[36 * 2 * 42];
  49734. sp_digit tx[2 * 42];
  49735. sp_digit ty[2 * 42];
  49736. #endif
  49737. sp_digit* r = NULL;
  49738. unsigned char e[128];
  49739. int err = MP_OKAY;
  49740. int i;
  49741. int y;
  49742. (void)base;
  49743. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  49744. defined(WOLFSSL_SP_SMALL_STACK)
  49745. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 38 * 42 * 2, NULL,
  49746. DYNAMIC_TYPE_TMP_BUFFER);
  49747. if (td == NULL) {
  49748. err = MEMORY_E;
  49749. }
  49750. #endif
  49751. if (err == MP_OKAY) {
  49752. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  49753. defined(WOLFSSL_SP_SMALL_STACK)
  49754. t = td;
  49755. tx = td + 36 * 42 * 2;
  49756. ty = td + 37 * 42 * 2;
  49757. #endif
  49758. r = ty;
  49759. (void)mp_to_unsigned_bin_len(exp, e, 128);
  49760. XMEMCPY(tx, p1024_norm_mod, sizeof(sp_digit) * 42);
  49761. y = e[112] >> 7;
  49762. y |= (e[96] >> 7) << 1;
  49763. y |= (e[80] >> 7) << 2;
  49764. y |= (e[64] >> 7) << 3;
  49765. y |= (e[48] >> 7) << 4;
  49766. y |= (e[32] >> 7) << 5;
  49767. y |= (e[16] >> 7) << 6;
  49768. y |= (e[0] >> 7) << 7;
  49769. XMEMCPY(ty, sp_1024_g_table[y], sizeof(sp_digit) * 42);
  49770. for (i = 126; i >= 0; i--) {
  49771. y = (e[127 - (i / 8)] >> (i & 0x7)) & 1;
  49772. y |= ((e[111 - (i / 8)] >> (i & 0x7)) & 1) << 1;
  49773. y |= ((e[95 - (i / 8)] >> (i & 0x7)) & 1) << 2;
  49774. y |= ((e[79 - (i / 8)] >> (i & 0x7)) & 1) << 3;
  49775. y |= ((e[63 - (i / 8)] >> (i & 0x7)) & 1) << 4;
  49776. y |= ((e[47 - (i / 8)] >> (i & 0x7)) & 1) << 5;
  49777. y |= ((e[31 - (i / 8)] >> (i & 0x7)) & 1) << 6;
  49778. y |= ((e[15 - (i / 8)] >> (i & 0x7)) & 1) << 7;
  49779. sp_1024_proj_sqr_42(tx, ty, t);
  49780. sp_1024_proj_mul_qx1_42(tx, ty, sp_1024_g_table[y], t);
  49781. }
  49782. }
  49783. if (err == MP_OKAY) {
  49784. sp_1024_mont_inv_42(tx, tx, t);
  49785. sp_1024_mont_mul_42(r, tx, ty, p1024_mod, p1024_mp_mod);
  49786. XMEMSET(r + 42, 0, sizeof(sp_digit) * 42);
  49787. sp_1024_mont_reduce_42(r, p1024_mod, p1024_mp_mod);
  49788. err = sp_1024_to_mp(r, res);
  49789. }
  49790. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  49791. defined(WOLFSSL_SP_SMALL_STACK)
  49792. if (td != NULL) {
  49793. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  49794. }
  49795. #endif
  49796. return err;
  49797. }
  49798. #endif /* WOLFSSL_SP_SMALL */
  49799. /* Multiply p* by q* in projective coordinates.
  49800. *
  49801. * p.x' = (p.x * q.x) - (p.y * q.y)
  49802. * p.y' = (p.x * q.y) + (p.y * q.x)
  49803. * But applying Karatsuba:
  49804. * v0 = p.x * q.x
  49805. * v1 = p.y * q.y
  49806. * p.x' = v0 - v1
  49807. * p.y' = (px + py) * (qx + qy) - v0 - v1
  49808. *
  49809. * px [in,out] A single precision integer - X ordinate of number to multiply.
  49810. * py [in,out] A single precision integer - Y ordinate of number to multiply.
  49811. * qx [in] A single precision integer - X ordinate of number of
  49812. * multiplier.
  49813. * qy [in] A single precision integer - Y ordinate of number of
  49814. * multiplier.
  49815. * t [in] Two single precision integers - temps.
  49816. */
  49817. static void sp_1024_proj_mul_42(sp_digit* px, sp_digit* py,
  49818. const sp_digit* qx, const sp_digit* qy, sp_digit* t)
  49819. {
  49820. sp_digit* t1 = t;
  49821. sp_digit* t2 = t + 2 * 42;
  49822. /* t1 = px + py */
  49823. sp_1024_mont_add_42(t1, px, py, p1024_mod);
  49824. /* t2 = qx + qy */
  49825. sp_1024_mont_add_42(t2, qx, qy, p1024_mod);
  49826. /* t2 = (px + py) * (qx + qy) */
  49827. sp_1024_mont_mul_42(t2, t1, t2, p1024_mod, p1024_mp_mod);
  49828. /* t1 = py * qy */
  49829. sp_1024_mont_mul_42(t1, py, qy, p1024_mod, p1024_mp_mod);
  49830. /* t2 = (px + py) * (qx + qy) - (py * qy) */
  49831. sp_1024_mont_sub_42(t2, t2, t1, p1024_mod);
  49832. /* px = px * qx */
  49833. sp_1024_mont_mul_42(px, px, qx, p1024_mod, p1024_mp_mod);
  49834. /* py = (px + py) * (qx + qy) - (py * qy) - (px * qx) */
  49835. sp_1024_mont_sub_42(py, t2, px, p1024_mod);
  49836. /* px = (px * qx) - (py * qy)*/
  49837. sp_1024_mont_sub_42(px, px, t1, p1024_mod);
  49838. }
  49839. #ifndef WOLFSSL_SP_SMALL
  49840. /*
  49841. * Convert point from projective to affine but keep in Montgomery form.
  49842. *
  49843. * p [in,out] Point to convert.
  49844. * t [in] Temporary numbers: 2.
  49845. */
  49846. static void sp_1024_mont_map_42(sp_point_1024* p, sp_digit* t)
  49847. {
  49848. sp_digit* t1 = t;
  49849. sp_digit* t2 = t + 2 * 42;
  49850. sp_1024_mont_inv_42(t1, p->z, t2);
  49851. sp_1024_mont_sqr_42(t2, t1, p1024_mod, p1024_mp_mod);
  49852. sp_1024_mont_mul_42(t1, t2, t1, p1024_mod, p1024_mp_mod);
  49853. sp_1024_mont_mul_42(p->x, p->x, t2, p1024_mod, p1024_mp_mod);
  49854. sp_1024_mont_mul_42(p->y, p->y, t1, p1024_mod, p1024_mp_mod);
  49855. XMEMCPY(p->z, p1024_norm_mod, sizeof(sp_digit) * 42);
  49856. }
  49857. #endif /* WOLFSSL_SP_SMALL */
  49858. /*
  49859. * Calculate gradient of line through P, P and [-2]P, accumulate line and
  49860. * double P.
  49861. *
  49862. * Calculations:
  49863. * l = 3 * (p.x^2 - p.z^4) = 3 * (p.x - p.z^2) * (p.x + p.z^2)
  49864. * r.x = l * (p.x + q.x * p.z^2) - 2 * p.y^2
  49865. * r.y = 2 * p.y * p.z^3 * q.y (= p'.z * p.z^2 * q.y)
  49866. * v* = v*^2 * r*
  49867. * p'.x = l^2 - 8 * p.y^2 * p.x
  49868. * p'.y = (4 * p.y^2 * p.x - p'.x) * l - 8 * p.y^4
  49869. * p'.z = 2 * p.y * p.z
  49870. *
  49871. * @param [in,out] vx X-ordinate of projective value in F*.
  49872. * @param [in,out] vy Y-ordinate of projective value in F*.
  49873. * @param [in,out] p ECC point - point on E(F_p^2) to double.
  49874. * @param [in] q ECC point - second point on E(F_P^2).
  49875. * @param [in] t SP temporaries (6 used).
  49876. */
  49877. static void sp_1024_accumulate_line_dbl_42(sp_digit* vx, sp_digit* vy,
  49878. sp_point_1024* p, const sp_point_1024* q, sp_digit* t)
  49879. {
  49880. sp_digit* t1 = t + 0 * 42;
  49881. sp_digit* pz2 = t + 2 * 42;
  49882. sp_digit* rx = t + 4 * 42;
  49883. sp_digit* ry = t + 6 * 42;
  49884. sp_digit* l = t + 8 * 42;
  49885. sp_digit* ty = t + 10 * 42;
  49886. /* v = v^2 */
  49887. sp_1024_proj_sqr_42(vx, vy, t);
  49888. /* pz2 = p.z^2 */
  49889. sp_1024_mont_sqr_42(pz2, p->z, p1024_mod, p1024_mp_mod);
  49890. /* t1 = p.x + p.z^2 */
  49891. sp_1024_mont_add_42(ty, p->x, pz2, p1024_mod);
  49892. /* l = p.x - p.z^2 */
  49893. sp_1024_mont_sub_42(l, p->x, pz2, p1024_mod);
  49894. /* t1 = (p.x + p.z^2) * (p.x - p.z^2) = p.x^2 - p.z^4 */
  49895. sp_1024_mont_mul_42(t1, l, ty, p1024_mod, p1024_mp_mod);
  49896. /* l = 3 * (p.x^2 - p.z^4) */
  49897. sp_1024_mont_tpl_42(l, t1, p1024_mod);
  49898. /* t1 = q.x * p.z^2 */
  49899. sp_1024_mont_mul_42(t1, q->x, pz2, p1024_mod, p1024_mp_mod);
  49900. /* t1 = p.x + q.x * p.z^2 */
  49901. sp_1024_mont_add_42(t1, p->x, t1, p1024_mod);
  49902. /* r.x = l * (p.x + q.x * p.z^2) */
  49903. sp_1024_mont_mul_42(rx, l, t1, p1024_mod, p1024_mp_mod);
  49904. /* r.y = 2 * p.y */
  49905. sp_1024_mont_dbl_42(ry, p->y, p1024_mod);
  49906. /* ty = 4 * p.y ^ 2 */
  49907. sp_1024_mont_sqr_42(ty, ry, p1024_mod, p1024_mp_mod);
  49908. /* t1 = 2 * p.y ^ 2 */
  49909. sp_1024_mont_div2_42(t1, ty, p1024_mod);
  49910. /* r.x -= 2 * (p.y ^ 2) */
  49911. sp_1024_mont_sub_42(rx, rx, t1, p1024_mod);
  49912. /* p'.z = p.y * 2 * p.z */
  49913. sp_1024_mont_mul_42(p->z, p->z, ry, p1024_mod, p1024_mp_mod);
  49914. /* r.y = p'.z * p.z^2 */
  49915. sp_1024_mont_mul_42(t1, p->z, pz2, p1024_mod, p1024_mp_mod);
  49916. /* r.y = p'.z * p.z^2 * q.y */
  49917. sp_1024_mont_mul_42(ry, t1, q->y, p1024_mod, p1024_mp_mod);
  49918. /* v = v^2 * r */
  49919. sp_1024_proj_mul_42(vx, vy, rx, ry, t);
  49920. /* Double point using previously calculated values
  49921. * l = 3 * (p.x - p.z^2).(p.x + p.z^2)
  49922. * ty = 4 * p.y^2
  49923. * p'.z = 2 * p.y * p.z
  49924. */
  49925. /* t1 = (4 * p.y^2) ^ 2 = 16 * p.y^4 */
  49926. sp_1024_mont_sqr_42(t1, ty, p1024_mod, p1024_mp_mod);
  49927. /* t1 = 16 * p.y^4 / 2 = 8 * p.y^4 */
  49928. sp_1024_mont_div2_42(t1, t1, p1024_mod);
  49929. /* p'.y = 4 * p.y^2 * p.x */
  49930. sp_1024_mont_mul_42(p->y, ty, p->x, p1024_mod, p1024_mp_mod);
  49931. /* p'.x = l^2 */
  49932. sp_1024_mont_sqr_42(p->x, l, p1024_mod, p1024_mp_mod);
  49933. /* p'.x = l^2 - 4 * p.y^2 * p.x */
  49934. sp_1024_mont_sub_42(p->x, p->x, p->y, p1024_mod);
  49935. /* p'.x = l^2 - 8 * p.y^2 * p.x */
  49936. sp_1024_mont_sub_42(p->x, p->x, p->y, p1024_mod);
  49937. /* p'.y = 4 * p.y^2 * p.x - p.x' */
  49938. sp_1024_mont_sub_42(ty, p->y, p->x, p1024_mod);
  49939. /* p'.y = (4 * p.y^2 * p.x - p'.x) * l */
  49940. sp_1024_mont_mul_42(p->y, ty, l, p1024_mod, p1024_mp_mod);
  49941. /* p'.y = (4 * p.y^2 * p.x - p'.x) * l - 8 * p.y^4 */
  49942. sp_1024_mont_sub_42(p->y, p->y, t1, p1024_mod);
  49943. }
  49944. #ifdef WOLFSSL_SP_SMALL
  49945. /*
  49946. * Calculate gradient of line through C, P and -C-P, accumulate line and
  49947. * add P to C.
  49948. *
  49949. * Calculations:
  49950. * r.x = (q.x + p.x) * c.y - (q.x * c.z^2 + c.x) * p.y * c.z
  49951. * r.y = (c.x - p.x * c.z^2) * q.y * c.z
  49952. * v* = v* * r*
  49953. * r = p.y * c.z^3 - c.y
  49954. * c'.x = r^2 + h^3 - 2 * c.x * h^2
  49955. * c'.y = r * (c'.x - c.x * h^2) - c.y * h^3
  49956. * c'.z = (c.x - p.x * c.z^2) * c.z
  49957. *
  49958. * @param [in,out] vx X-ordinate of projective value in F*.
  49959. * @param [in,out] vy Y-ordinate of projective value in F*.
  49960. * @param [in,out] c ECC point - current point on E(F_p^2) to be added
  49961. * to.
  49962. * @param [in] p ECC point - point on E(F_p^2) to add.
  49963. * @param [in] q ECC point - second point on E(F_P^2).
  49964. * @param [in] qx_px SP that is a constant value across adds.
  49965. * @param [in] t SP temporaries (6 used).
  49966. */
  49967. static void sp_1024_accumulate_line_add_one_42(sp_digit* vx, sp_digit* vy,
  49968. sp_point_1024* c, sp_point_1024* p, sp_point_1024* q, sp_digit* qx_px,
  49969. sp_digit* t)
  49970. {
  49971. sp_digit* t1 = t;
  49972. sp_digit* t2 = t + 2 * 42;
  49973. sp_digit* rx = t + 4 * 42;
  49974. sp_digit* ry = t + 6 * 42;
  49975. sp_digit* h = t + 8 * 42;
  49976. sp_digit* r = t + 10 * 42;
  49977. /* r.x = (q.x + p.x) * c.y */
  49978. sp_1024_mont_mul_42(rx, qx_px, c->y, p1024_mod, p1024_mp_mod);
  49979. /* t2 = c.z^2 */
  49980. sp_1024_mont_sqr_42(t2, c->z, p1024_mod, p1024_mp_mod);
  49981. /* t1 = q.x * c.z^2 */
  49982. sp_1024_mont_mul_42(t1, q->x, t2, p1024_mod, p1024_mp_mod);
  49983. /* t1 = q.x * c.z^2 + c.x */
  49984. sp_1024_mont_add_42(h, t1, c->x, p1024_mod);
  49985. /* r = p.y * c.z */
  49986. sp_1024_mont_mul_42(ry, p->y, c->z, p1024_mod, p1024_mp_mod);
  49987. /* t1 = (q.x * c.z^2 + c.x) * p.y * c.z */
  49988. sp_1024_mont_mul_42(t1, h, ry, p1024_mod, p1024_mp_mod);
  49989. /* r = p.y * c.z * c.z^2 = p.y * c.z^3 */
  49990. sp_1024_mont_mul_42(r, ry, t2, p1024_mod, p1024_mp_mod);
  49991. /* r.x -= (q.x * c.z^2 + c.x) * p.y * c.z */
  49992. sp_1024_mont_sub_42(rx, rx, t1, p1024_mod);
  49993. /* t1 = p.x * c.z^2 */
  49994. sp_1024_mont_mul_42(t1, p->x, t2, p1024_mod, p1024_mp_mod);
  49995. /* h = c.x - p.x * c.z^2 */
  49996. sp_1024_mont_sub_42(h, c->x, t1, p1024_mod);
  49997. /* c'.z = (c.x - p.x * c.z^2) * c.z */
  49998. sp_1024_mont_mul_42(c->z, h, c->z, p1024_mod, p1024_mp_mod);
  49999. /* r.y = (c.x - p.x * c.z^2) * c.z * q.y */
  50000. sp_1024_mont_mul_42(ry, c->z, q->y, p1024_mod, p1024_mp_mod);
  50001. /* v = v * r */
  50002. sp_1024_proj_mul_42(vx, vy, rx, ry, t);
  50003. /* Add p to c using previously calculated values.
  50004. * h = c.x - p.x * c.z^2
  50005. * r = p.y * c.z^3
  50006. * c'.z = (c.x - p.x * c.z^2) * c.z
  50007. */
  50008. /* r = p.y * c.z^3 - c.y */
  50009. sp_1024_mont_sub_42(r, r, c->y, p1024_mod);
  50010. /* t1 = r^2 */
  50011. sp_1024_mont_sqr_42(t1, r, p1024_mod, p1024_mp_mod);
  50012. /* t2 = h^2 */
  50013. sp_1024_mont_sqr_42(rx, h, p1024_mod, p1024_mp_mod);
  50014. /* ry = c.x * h^2 */
  50015. sp_1024_mont_mul_42(ry, c->x, rx, p1024_mod, p1024_mp_mod);
  50016. /* t2 = h^3 */
  50017. sp_1024_mont_mul_42(t2, rx, h, p1024_mod, p1024_mp_mod);
  50018. /* c->x = r^2 + h^3 */
  50019. sp_1024_mont_add_42(c->x, t1, t2, p1024_mod);
  50020. /* t1 = 2 * c.x * h^2 */
  50021. sp_1024_mont_dbl_42(t1, ry, p1024_mod);
  50022. /* c'.x = r^2 + h^3 - 2 * c.x * h^2 */
  50023. sp_1024_mont_sub_42(c->x, c->x, t1, p1024_mod);
  50024. /* ry = c'.x - c.x * h^2 */
  50025. sp_1024_mont_sub_42(t1, c->x, ry, p1024_mod);
  50026. /* ry = r * (c'.x - c.x * h^2) */
  50027. sp_1024_mont_mul_42(ry, t1, r, p1024_mod, p1024_mp_mod);
  50028. /* t2 = c.y * h^3 */
  50029. sp_1024_mont_mul_42(t1, t2, c->y, p1024_mod, p1024_mp_mod);
  50030. /* c'.y = r * (c'.x - c.x * h^2) - c.y * h^3 */
  50031. sp_1024_mont_sub_42(c->y, ry, t1, p1024_mod);
  50032. }
  50033. /*
  50034. * Calculate r = pairing <P, Q>.
  50035. *
  50036. * That is, multiply base in PF_p[q] by the scalar s, such that s.P = Q.
  50037. *
  50038. * @param [in] key SAKKE key.
  50039. * @param [in] p First point on E(F_p)[q].
  50040. * @param [in] q Second point on E(F_p)[q].
  50041. * @param [in] r Result of calculation.
  50042. * @return 0 on success.
  50043. * @return MEMORY_E when dynamic memory allocation fails.
  50044. * @return Other -ve value on internal failure.
  50045. */
  50046. int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
  50047. {
  50048. int err = MP_OKAY;
  50049. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50050. defined(WOLFSSL_SP_SMALL_STACK)
  50051. sp_digit* td = NULL;
  50052. sp_digit* t;
  50053. sp_digit* vx;
  50054. sp_digit* vy;
  50055. sp_digit* qx_px;
  50056. #else
  50057. sp_digit t[36 * 2 * 42];
  50058. sp_digit vx[2 * 42];
  50059. sp_digit vy[2 * 42];
  50060. sp_digit qx_px[2 * 42];
  50061. sp_point_1024 pd;
  50062. sp_point_1024 qd;
  50063. sp_point_1024 cd;
  50064. #endif
  50065. sp_point_1024* p = NULL;
  50066. sp_point_1024* q = NULL;
  50067. sp_point_1024* c = NULL;
  50068. sp_digit* r = NULL;
  50069. int i;
  50070. err = sp_1024_point_new_42(NULL, pd, p);
  50071. if (err == MP_OKAY) {
  50072. err = sp_1024_point_new_42(NULL, qd, q);
  50073. }
  50074. if (err == MP_OKAY) {
  50075. err = sp_1024_point_new_42(NULL, cd, c);
  50076. }
  50077. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50078. defined(WOLFSSL_SP_SMALL_STACK)
  50079. if (err == MP_OKAY) {
  50080. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 39 * 42 * 2, NULL,
  50081. DYNAMIC_TYPE_TMP_BUFFER);
  50082. if (td == NULL) {
  50083. err = MEMORY_E;
  50084. }
  50085. }
  50086. #endif
  50087. if (err == MP_OKAY) {
  50088. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50089. defined(WOLFSSL_SP_SMALL_STACK)
  50090. t = td;
  50091. vx = td + 36 * 42 * 2;
  50092. vy = td + 37 * 42 * 2;
  50093. qx_px = td + 38 * 42 * 2;
  50094. #endif
  50095. r = vy;
  50096. sp_1024_point_from_ecc_point_42(p, pm);
  50097. sp_1024_point_from_ecc_point_42(q, qm);
  50098. err = sp_1024_mod_mul_norm_42(p->x, p->x, p1024_mod);
  50099. }
  50100. if (err == MP_OKAY) {
  50101. err = sp_1024_mod_mul_norm_42(p->y, p->y, p1024_mod);
  50102. }
  50103. if (err == MP_OKAY) {
  50104. err = sp_1024_mod_mul_norm_42(p->z, p->z, p1024_mod);
  50105. }
  50106. if (err == MP_OKAY) {
  50107. err = sp_1024_mod_mul_norm_42(q->x, q->x, p1024_mod);
  50108. }
  50109. if (err == MP_OKAY) {
  50110. err = sp_1024_mod_mul_norm_42(q->y, q->y, p1024_mod);
  50111. }
  50112. if (err == MP_OKAY) {
  50113. XMEMCPY(c, p, sizeof(sp_point_1024));
  50114. XMEMSET(vx, 0, sizeof(sp_digit) * 2 * 42);
  50115. vx[0] = 1;
  50116. XMEMSET(vy, 0, sizeof(sp_digit) * 2 * 42);
  50117. sp_1024_mont_add_42(qx_px, q->x, p->x, p1024_mod);
  50118. for (i = 1020; i >= 0; i--) {
  50119. /* Accumulate line into v and double point. */
  50120. sp_1024_accumulate_line_dbl_42(vx, vy, c, q, t);
  50121. if ((i > 0) && ((p1024_order[i / 25] >> (i % 25)) & 1)) {
  50122. /* Accumulate line into v and add P into C. */
  50123. sp_1024_accumulate_line_add_one_42(vx, vy, c, p, q, qx_px, t);
  50124. }
  50125. }
  50126. /* Final exponentiation */
  50127. sp_1024_proj_sqr_42(vx, vy, t);
  50128. sp_1024_proj_sqr_42(vx, vy, t);
  50129. /* Convert from PF_p[q] to F_p */
  50130. sp_1024_mont_inv_42(vx, vx, t);
  50131. sp_1024_mont_mul_42(r, vx, vy, p1024_mod, p1024_mp_mod);
  50132. XMEMSET(r + 42, 0, sizeof(sp_digit) * 42);
  50133. sp_1024_mont_reduce_42(r, p1024_mod, p1024_mp_mod);
  50134. err = sp_1024_to_mp(r, res);
  50135. }
  50136. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50137. defined(WOLFSSL_SP_SMALL_STACK)
  50138. if (td != NULL) {
  50139. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  50140. }
  50141. #endif
  50142. sp_1024_point_free_42(c, 1, NULL);
  50143. sp_1024_point_free_42(q, 1, NULL);
  50144. sp_1024_point_free_42(p, 1, NULL);
  50145. return err;
  50146. }
  50147. #else
  50148. /*
  50149. * Calculate gradient of line through C, P and -C-P, accumulate line and
  50150. * add P to C.
  50151. *
  50152. * Both C and P have z ordinates to use in the calculation.
  50153. *
  50154. * Calculations:
  50155. * r.x = (q.x * c.z^2 + c.x) * p.y * c.z - (q.x * p.z^2 + p.x) * c.y * p.z
  50156. * r.y = (p.x * c.z^2 - c.x * p.z^2) * q.y * p.z * c.z
  50157. * v* = v* * r*
  50158. * h = p.x * c.z^2 - c.x * p.z^2
  50159. * r = p.y * c.z^3 - c.y * p.z^3
  50160. * c'.x = r^2 - h^3 - 2 * c.x * p.z^2 * h^2
  50161. * c'.y = r * (c.x * p.z^2 * h^2 - c'.x) - c.y * p.z^3 * h^3
  50162. * c'.z = (p.x * c.z^2 - c.x * p.z^2) * c.z
  50163. *
  50164. * @param [in,out] vx X-ordinate of projective value in F*.
  50165. * @param [in,out] vy Y-ordinate of projective value in F*.
  50166. * @param [in,out] c ECC point - current point on E(F_p^2) to be added
  50167. * to.
  50168. * @param [in,out] p ECC point - point on E(F_p^2) to add.
  50169. * @param [in,out] q ECC point - second point on E(F_P^2).
  50170. * @param [in,out] t SP temporaries (6 used).
  50171. * @param [in,out] neg Indicates to use negative P.
  50172. * @return 0 on success.
  50173. * @return MEMORY_E when dynamic memory allocation fails.
  50174. * @return Other -ve value on internal failure.
  50175. */
  50176. static void sp_1024_accumulate_line_add_n_42(sp_digit* vx, sp_digit* vy,
  50177. const sp_point_1024* p, const sp_point_1024* q,
  50178. sp_point_1024* c, sp_digit* t, int neg)
  50179. {
  50180. sp_digit* t1 = t;
  50181. sp_digit* t2 = t + 2 * 42;
  50182. sp_digit* rx = t + 4 * 42;
  50183. sp_digit* ry = t + 6 * 42;
  50184. sp_digit* h = t + 8 * 42;
  50185. sp_digit* r = t + 10 * 42;
  50186. /* h = p.z^2 */
  50187. sp_1024_mont_sqr_42(h, p->z, p1024_mod, p1024_mp_mod);
  50188. /* rx = q.x * p.z^2 */
  50189. sp_1024_mont_mul_42(rx, q->x, h, p1024_mod, p1024_mp_mod);
  50190. /* rx = q.x * p.z^2 + p.x */
  50191. sp_1024_mont_add_42(t2, rx, p->x, p1024_mod);
  50192. /* c.y = c.y * p.z */
  50193. sp_1024_mont_mul_42(t1, c->y, p->z, p1024_mod, p1024_mp_mod);
  50194. /* r.x = (q.x * p.z^2 + p.x) * c.y * p.z */
  50195. sp_1024_mont_mul_42(rx, t2, t1, p1024_mod, p1024_mp_mod);
  50196. /* c.y = c.y * p.z^3 */
  50197. sp_1024_mont_mul_42(c->y, t1, h, p1024_mod, p1024_mp_mod);
  50198. /* t2 = c.z^2 */
  50199. sp_1024_mont_sqr_42(t2, c->z, p1024_mod, p1024_mp_mod);
  50200. /* t1 = q.x * c.z^2 */
  50201. sp_1024_mont_mul_42(t1, q->x, t2, p1024_mod, p1024_mp_mod);
  50202. /* t1 = q.x * c.z^2 + c.x */
  50203. sp_1024_mont_add_42(t1, t1, c->x, p1024_mod);
  50204. /* c.x = c.x * p.z^2 */
  50205. sp_1024_mont_mul_42(c->x, c->x, h, p1024_mod, p1024_mp_mod);
  50206. /* r = p.y * c.z */
  50207. sp_1024_mont_mul_42(r, p->y, c->z, p1024_mod, p1024_mp_mod);
  50208. if (neg) {
  50209. /* r = -p.y * c.z */
  50210. sp_1024_mont_sub_42(r, p1024_mod, r, p1024_mod);
  50211. }
  50212. /* t1 = (q.x * c.z^2 + c.x) * p.y * c.z */
  50213. sp_1024_mont_mul_42(ry, t1, r, p1024_mod, p1024_mp_mod);
  50214. /* r.x -= (q.x * c.z^2 + c.x) * p.y * c.z */
  50215. sp_1024_mont_sub_42(rx, ry, rx, p1024_mod);
  50216. /* t1 = p.x * c.z^2 */
  50217. sp_1024_mont_mul_42(t1, p->x, t2, p1024_mod, p1024_mp_mod);
  50218. /* h = p.x * c.z^2 - c.x * p.z^2 */
  50219. sp_1024_mont_sub_42(h, t1, c->x, p1024_mod);
  50220. /* c'.z = (p.x * c.z^2 - c.x * p.z^2) * c.z */
  50221. sp_1024_mont_mul_42(t1, h, c->z, p1024_mod, p1024_mp_mod);
  50222. /* c'.z = (p.x * c.z^2 - c.x * p.z^2) * c.z * p.z */
  50223. sp_1024_mont_mul_42(c->z, t1, p->z, p1024_mod, p1024_mp_mod);
  50224. /* r.y = (p.x * c.z^2 - c.x * p.z^2) * c.z * p.z * q.y */
  50225. sp_1024_mont_mul_42(ry, c->z, q->y, p1024_mod, p1024_mp_mod);
  50226. /* r = p.y * c.z^3 */
  50227. sp_1024_mont_mul_42(t1, r, t2, p1024_mod, p1024_mp_mod);
  50228. /* r = p.y * c.z^3 - c.y * p.z^3 */
  50229. sp_1024_mont_sub_42(r, t1, c->y, p1024_mod);
  50230. /* v = v * r */
  50231. sp_1024_proj_mul_42(vx, vy, rx, ry, t);
  50232. /* Add p to c using previously calculated values.
  50233. * h = p.x * c.z^2 - c.x * p.z^2
  50234. * r = p.y * c.z^3 - c.y * p.z^3
  50235. * c'.z = (p.x * c.z^2 - c.x * p.z^2) * c.z
  50236. */
  50237. /* t1 = r^2 */
  50238. sp_1024_mont_sqr_42(t1, r, p1024_mod, p1024_mp_mod);
  50239. /* t2 = h^2 */
  50240. sp_1024_mont_sqr_42(rx, h, p1024_mod, p1024_mp_mod);
  50241. /* ry = c.x * p.z^2 * h^2 */
  50242. sp_1024_mont_mul_42(ry, rx, c->x, p1024_mod, p1024_mp_mod);
  50243. /* t2 = h^3 */
  50244. sp_1024_mont_mul_42(t2, rx, h, p1024_mod, p1024_mp_mod);
  50245. /* c'.x = r^2 - h^3 */
  50246. sp_1024_mont_sub_42(c->x, t1, t2, p1024_mod);
  50247. /* t1 = 2 * c.x * p.z^2 * h^2 */
  50248. sp_1024_mont_dbl_42(t1, ry, p1024_mod);
  50249. /* c'.x = r^2 - h^3 - 2 * c.x * p.z^2 * h^2 */
  50250. sp_1024_mont_sub_42(c->x, c->x, t1, p1024_mod);
  50251. /* ry = c.x * p.z^2 * h^2 - c'.x */
  50252. sp_1024_mont_sub_42(t1, ry, c->x, p1024_mod);
  50253. /* ry = r * (c.x * p.z^2 * h^2 - c'.x) */
  50254. sp_1024_mont_mul_42(ry, t1, r, p1024_mod, p1024_mp_mod);
  50255. /* t2 = c.y * p.z^3 * h^3 */
  50256. sp_1024_mont_mul_42(t1, t2, c->y, p1024_mod, p1024_mp_mod);
  50257. /* c'.y = r * (c.x * p.z^2 * h^2 - c'.x) - c.y * p.z^3 * h^3 */
  50258. sp_1024_mont_sub_42(c->y, ry, t1, p1024_mod);
  50259. }
  50260. /*
  50261. * Perform n accumulate doubles and doubles of P.
  50262. *
  50263. * py = 2 * p.y
  50264. *
  50265. * For each double:
  50266. * Calculate gradient of line through P, P and [-2]P, accumulate line and
  50267. * double P.
  50268. *
  50269. * Calculations:
  50270. * l = 3 * (p.x^2 - p.z^4) = 3 * (p.x - p.z^2) * (p.x + p.z^2)
  50271. * r.x = l * (p.x + q.x * p.z^2) - py^2 / 2
  50272. * r.y = py * p.z^3 * q.y (= p'.z * p.z^2 * q.y)
  50273. * v* = v*^2 * r*
  50274. * p'.x = l^2 - 2 * py^2 * p.x
  50275. * py' = (py^2 * p.x - p'.x) * l - py^4 (= 2 * p'.y)
  50276. * p'.z = py * p.z
  50277. *
  50278. * Finally:
  50279. * p'.y = py' / 2
  50280. *
  50281. * @param [in,out] vx X-ordinate of projective value in F*.
  50282. * @param [in,out] vy Y-ordinate of projective value in F*.
  50283. * @param [in,out] p ECC point - point on E(F_p^2) to double.
  50284. * @param [in] q ECC point - second point on E(F_P^2).
  50285. * @param [in] n Number of times to double.
  50286. * @param [in] t SP temporaries (6 used).
  50287. */
  50288. static void sp_1024_accumulate_line_dbl_n_42(sp_digit* vx, sp_digit* vy,
  50289. sp_point_1024* p, const sp_point_1024* q, int n, sp_digit* t)
  50290. {
  50291. sp_digit* t1 = t + 0 * 42;
  50292. sp_digit* pz2 = t + 2 * 42;
  50293. sp_digit* rx = t + 4 * 42;
  50294. sp_digit* ry = t + 6 * 42;
  50295. sp_digit* l = t + 8 * 42;
  50296. sp_digit* ty = t + 10 * 42;
  50297. int i;
  50298. /* py = 2 * p.y */
  50299. sp_1024_mont_dbl_42(p->y, p->y, p1024_mod);
  50300. for (i = 0; i < n; i++) {
  50301. /* v = v^2 */
  50302. sp_1024_proj_sqr_42(vx, vy, t);
  50303. /* pz2 = p.z^2 */
  50304. sp_1024_mont_sqr_42(pz2, p->z, p1024_mod, p1024_mp_mod);
  50305. /* t1 = p.x + p.z^2 */
  50306. sp_1024_mont_add_42(t1, p->x, pz2, p1024_mod);
  50307. /* l = p.x - p.z^2 */
  50308. sp_1024_mont_sub_42(l, p->x, pz2, p1024_mod);
  50309. /* t1 = (p.x + p.z^2) * (p.x - p.z^2) = p.x^2 - p.z^4 */
  50310. sp_1024_mont_mul_42(ty, l, t1, p1024_mod, p1024_mp_mod);
  50311. /* l = 3 * (p.x^2 - p.z^4) */
  50312. sp_1024_mont_tpl_42(l, ty, p1024_mod);
  50313. /* t1 = q.x * p.z^2 */
  50314. sp_1024_mont_mul_42(t1, q->x, pz2, p1024_mod, p1024_mp_mod);
  50315. /* t1 = p.x + q.x * p.z^2 */
  50316. sp_1024_mont_add_42(t1, p->x, t1, p1024_mod);
  50317. /* r.x = l * (p.x + q.x * p.z^2) */
  50318. sp_1024_mont_mul_42(rx, l, t1, p1024_mod, p1024_mp_mod);
  50319. /* ty = py ^ 2 */
  50320. sp_1024_mont_sqr_42(ty, p->y, p1024_mod, p1024_mp_mod);
  50321. /* t1 = py ^ 2 / 2 */
  50322. sp_1024_mont_div2_42(t1, ty, p1024_mod);
  50323. /* r.x -= py ^ 2 / 2 */
  50324. sp_1024_mont_sub_42(rx, rx, t1, p1024_mod);
  50325. /* p'.z = py * pz */
  50326. sp_1024_mont_mul_42(p->z, p->z, p->y, p1024_mod, p1024_mp_mod);
  50327. /* r.y = p'.z * p.z^2 */
  50328. sp_1024_mont_mul_42(t1, p->z, pz2, p1024_mod, p1024_mp_mod);
  50329. /* r.y = p'.z * p.z^2 * q.y */
  50330. sp_1024_mont_mul_42(ry, t1, q->y, p1024_mod, p1024_mp_mod);
  50331. /* v = v^2 * r */
  50332. sp_1024_proj_mul_42(vx, vy, rx, ry, t);
  50333. /* Double point using previously calculated values
  50334. * l = 3 * (p.x - p.z^2).(p.x + p.z^2)
  50335. * ty = py^2
  50336. * p'.z = py * p.z
  50337. */
  50338. /* t1 = py^2 ^ 2 = py^4 */
  50339. sp_1024_mont_sqr_42(t1, ty, p1024_mod, p1024_mp_mod);
  50340. /* py' = py^2 * p. x */
  50341. sp_1024_mont_mul_42(p->y, ty, p->x, p1024_mod, p1024_mp_mod);
  50342. /* p'.x = l^2 */
  50343. sp_1024_mont_sqr_42(p->x, l, p1024_mod, p1024_mp_mod);
  50344. /* p'.x = l^2 - py^2 * p.x */
  50345. sp_1024_mont_sub_42(p->x, p->x, p->y, p1024_mod);
  50346. /* p'.x = l^2 - 2 * p.y^2 * p.x */
  50347. sp_1024_mont_sub_42(p->x, p->x, p->y, p1024_mod);
  50348. /* py' = py^2 * p.x - p.x' */
  50349. sp_1024_mont_sub_42(ty, p->y, p->x, p1024_mod);
  50350. /* py' = (p.y^2 * p.x - p'.x) * l */
  50351. sp_1024_mont_mul_42(p->y, ty, l, p1024_mod, p1024_mp_mod);
  50352. /* py' = (p.y^2 * p.x - p'.x) * l * 2 */
  50353. sp_1024_mont_dbl_42(p->y, p->y, p1024_mod);
  50354. /* py' = (p.y^2 * p.x - p'.x) * l * 2 - p.y^4 */
  50355. sp_1024_mont_sub_42(p->y, p->y, t1, p1024_mod);
  50356. }
  50357. /* p'.y = py' / 2 */
  50358. sp_1024_mont_div2_42(p->y, p->y, p1024_mod);
  50359. }
  50360. /* Operations to perform based on order - 1.
  50361. * Sliding window. Start at bottom and stop when bottom bit is one.
  50362. * Subtract if top bit in window is one.
  50363. * Width of 6 bits.
  50364. * Pairs: #dbls, add/subtract window value
  50365. */
  50366. static const signed char sp_1024_order_op[] = {
  50367. 5, 6, -13, 9, -21, 6, -5, 8, 31, 6, 3, 6, -27, 6, 25, 9,
  50368. -1, 6, -11, 6, -13, 6, -7, 6, -15, 6, -29, 7, 25, 6, -9, 6,
  50369. -19, 7, 3, 6, 11, 9, -23, 6, 1, 6, 27, 6, 1, 7, -25, 8,
  50370. 13, 7, -13, 7, -23, 10, 19, 7, 7, 7, -3, 7, 27, 6, -7, 7,
  50371. -21, 7, 11, 7, 31, 8, 1, 7, -23, 6, -17, 6, -3, 10, 11, 6,
  50372. -21, 7, -27, 11, -29, 6, -1, 10, 15, 8, 27, 7, 17, 6, 17, 7,
  50373. -13, 8, 13, 6, 21, 7, -29, 6, 19, 7, -25, 6, 11, 9, 29, 7,
  50374. -7, 8, 27, 7, 29, 10, -1, 8, -7, 8, 17, 6, 17, 7, -27, 7,
  50375. -21, 6, -9, 6, -27, 12, -23, 6, 19, 6, 13, 6, -11, 7, 27, 6,
  50376. 17, 6, -7, 6, -25, 7, -29, 6, 9, 7, 7, 6, 13, 6, -25, 6,
  50377. -19, 6, 13, 6, -11, 6, 5, 8, 19, 6, -21, 8, 23, 7, 27, 6,
  50378. -13, 6, -19, 11, 29, 7, -15, 6, -9, 7, -21, 10, -3, 7, 21, 10,
  50379. 25, 6, -15, 6, -23, 6, 21, 6, 1, 6, 21, 7, -3, 6, -3, 7,
  50380. -7, 6, -23, 7, 7, 8, 15, 9, 5, 6, -11, 6, 21, 11, -27, 7,
  50381. 27, 6, -11, 6, 31, 6, -21, 6, 19, 6, -7, 8, -7, 13, -3, 6,
  50382. -7, 7, -3, 6, 1, 6, 7, 8, 19, 8, 11, 9, -9, 7, -31, 12,
  50383. 25, 6, -17, 9, -15, 7, 5, 6, 25, 7, -5, 7, -25, 6, 17, 8,
  50384. -19, 6, -13, 6, 27, 8, 1, 7, -5, 7, -1, 6, 21, 6, 3, 10,
  50385. -3, 1,
  50386. };
  50387. /*
  50388. * Calculate r = pairing <P, Q>.
  50389. *
  50390. * That is, multiply base in PF_p[q] by the scalar s, such that s.P = Q.
  50391. *
  50392. * Sliding window. Start at bottom and stop when bottom bit is one.
  50393. * Subtract if top bit in window is one.
  50394. * Width of 6 bits.
  50395. *
  50396. * @param [in] pm First point on E(F_p)[q].
  50397. * @param [in] qm Second point on E(F_p)[q].
  50398. * @param [in] res Result of calculation.
  50399. * @return 0 on success.
  50400. * @return MEMORY_E when dynamic memory allocation fails.
  50401. */
  50402. int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
  50403. {
  50404. int err;
  50405. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50406. defined(WOLFSSL_SP_SMALL_STACK)
  50407. sp_digit* td = NULL;
  50408. sp_digit* t;
  50409. sp_digit* vx;
  50410. sp_digit* vy;
  50411. sp_digit (*pre_vx)[84];
  50412. sp_digit (*pre_vy)[84];
  50413. sp_digit (*pre_nvy)[84];
  50414. sp_point_1024* pre_p;
  50415. #else
  50416. sp_digit t[36 * 2 * 42];
  50417. sp_digit vx[2 * 42];
  50418. sp_digit vy[2 * 42];
  50419. sp_digit pre_vx[16][84];
  50420. sp_digit pre_vy[16][84];
  50421. sp_digit pre_nvy[16][84];
  50422. sp_point_1024 pre_p[16];
  50423. sp_point_1024 pd;
  50424. sp_point_1024 qd;
  50425. sp_point_1024 cd;
  50426. #endif
  50427. sp_point_1024* p = NULL;
  50428. sp_point_1024* q = NULL;
  50429. sp_point_1024* c = NULL;
  50430. sp_digit* r = NULL;
  50431. int i;
  50432. int j;
  50433. err = sp_1024_point_new_42(NULL, pd, p);
  50434. if (err == MP_OKAY) {
  50435. err = sp_1024_point_new_42(NULL, qd, q);
  50436. }
  50437. if (err == MP_OKAY) {
  50438. err = sp_1024_point_new_42(NULL, cd, c);
  50439. }
  50440. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50441. defined(WOLFSSL_SP_SMALL_STACK)
  50442. if (err == MP_OKAY) {
  50443. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 86 * 42 * 2 + 16 * sizeof(sp_point_1024), NULL,
  50444. DYNAMIC_TYPE_TMP_BUFFER);
  50445. if (td == NULL) {
  50446. err = MEMORY_E;
  50447. }
  50448. }
  50449. #endif
  50450. if (err == MP_OKAY) {
  50451. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50452. defined(WOLFSSL_SP_SMALL_STACK)
  50453. t = td;
  50454. vx = td + 36 * 42 * 2;
  50455. vy = td + 37 * 42 * 2;
  50456. pre_vx = (sp_digit(*)[84])(td + 38 * 42 * 2);
  50457. pre_vy = (sp_digit(*)[84])(td + 54 * 42 * 2);
  50458. pre_nvy = (sp_digit(*)[84])(td + 70 * 42 * 2);
  50459. pre_p = (sp_point_1024*)(td + 86 * 42 * 2);
  50460. #endif
  50461. r = vy;
  50462. sp_1024_point_from_ecc_point_42(p, pm);
  50463. sp_1024_point_from_ecc_point_42(q, qm);
  50464. err = sp_1024_mod_mul_norm_42(p->x, p->x, p1024_mod);
  50465. }
  50466. if (err == MP_OKAY) {
  50467. err = sp_1024_mod_mul_norm_42(p->y, p->y, p1024_mod);
  50468. }
  50469. if (err == MP_OKAY) {
  50470. err = sp_1024_mod_mul_norm_42(p->z, p->z, p1024_mod);
  50471. }
  50472. if (err == MP_OKAY) {
  50473. err = sp_1024_mod_mul_norm_42(q->x, q->x, p1024_mod);
  50474. }
  50475. if (err == MP_OKAY) {
  50476. err = sp_1024_mod_mul_norm_42(q->y, q->y, p1024_mod);
  50477. }
  50478. if (err == MP_OKAY) {
  50479. /* Generate pre-computation table: 1, 3, ... , 31 */
  50480. XMEMCPY(&pre_p[0], p, sizeof(sp_point_1024));
  50481. XMEMSET(pre_vx[0], 0, sizeof(sp_digit) * 2 * 42);
  50482. pre_vx[0][0] = 1;
  50483. XMEMSET(pre_vy[0], 0, sizeof(sp_digit) * 2 * 42);
  50484. sp_1024_mont_sub_42(pre_nvy[0], p1024_mod, pre_vy[0], p1024_mod);
  50485. /* [2]P for adding */
  50486. XMEMCPY(c, p, sizeof(sp_point_1024));
  50487. XMEMSET(vx, 0, sizeof(sp_digit) * 2 * 42);
  50488. vx[0] = 1;
  50489. XMEMSET(vy, 0, sizeof(sp_digit) * 2 * 42);
  50490. sp_1024_accumulate_line_dbl_42(vx, vy, c, q, t);
  50491. /* 3, 5, ... */
  50492. for (i = 1; i < 16; i++) {
  50493. XMEMCPY(&pre_p[i], &pre_p[i-1], sizeof(sp_point_1024));
  50494. XMEMCPY(pre_vx[i], pre_vx[i-1], sizeof(sp_digit) * 2 * 42);
  50495. XMEMCPY(pre_vy[i], pre_vy[i-1], sizeof(sp_digit) * 2 * 42);
  50496. sp_1024_proj_mul_42(pre_vx[i], pre_vy[i], vx, vy, t);
  50497. sp_1024_accumulate_line_add_n_42(pre_vx[i], pre_vy[i], c,
  50498. q, &pre_p[i], t, 0);
  50499. sp_1024_mont_sub_42(pre_nvy[i], p1024_mod, pre_vy[i], p1024_mod);
  50500. }
  50501. j = sp_1024_order_op[0] / 2;
  50502. XMEMCPY(c, &pre_p[j], sizeof(sp_point_1024));
  50503. XMEMCPY(vx, pre_vx[j], sizeof(sp_digit) * 2 * 42);
  50504. XMEMCPY(vy, pre_vy[j], sizeof(sp_digit) * 2 * 42);
  50505. /* Accumulate line into v and double point n times. */
  50506. sp_1024_accumulate_line_dbl_n_42(vx, vy, c, q,
  50507. sp_1024_order_op[1], t);
  50508. for (i = 2; i < 290; i += 2) {
  50509. j = sp_1024_order_op[i];
  50510. if (j > 0) {
  50511. j /= 2;
  50512. /* Accumulate line into v and add P into C. */
  50513. sp_1024_proj_mul_42(vx, vy, pre_vx[j], pre_vy[j], t);
  50514. sp_1024_accumulate_line_add_n_42(vx, vy, &pre_p[j], q, c,
  50515. t, 0);
  50516. }
  50517. else {
  50518. j = -j / 2;
  50519. /* Accumulate line into v and add P into C. */
  50520. sp_1024_proj_mul_42(vx, vy, pre_vx[j], pre_nvy[j], t);
  50521. sp_1024_accumulate_line_add_n_42(vx, vy, &pre_p[j], q, c,
  50522. t, 1);
  50523. }
  50524. /* Accumulate line into v and double point n times. */
  50525. sp_1024_accumulate_line_dbl_n_42(vx, vy, c, q,
  50526. sp_1024_order_op[i + 1], t);
  50527. }
  50528. /* Final exponentiation */
  50529. sp_1024_proj_sqr_42(vx, vy, t);
  50530. sp_1024_proj_sqr_42(vx, vy, t);
  50531. /* Convert from PF_p[q] to F_p */
  50532. sp_1024_mont_inv_42(vx, vx, t);
  50533. sp_1024_mont_mul_42(r, vx, vy, p1024_mod, p1024_mp_mod);
  50534. XMEMSET(r + 42, 0, sizeof(sp_digit) * 42);
  50535. sp_1024_mont_reduce_42(r, p1024_mod, p1024_mp_mod);
  50536. err = sp_1024_to_mp(r, res);
  50537. }
  50538. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50539. defined(WOLFSSL_SP_SMALL_STACK)
  50540. if (td != NULL) {
  50541. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  50542. }
  50543. #endif
  50544. sp_1024_point_free_42(c, 1, NULL);
  50545. sp_1024_point_free_42(q, 1, NULL);
  50546. sp_1024_point_free_42(p, 1, NULL);
  50547. return err;
  50548. }
  50549. #endif /* WOLFSSL_SP_SMALL */
  50550. #ifdef WOLFSSL_SP_SMALL
  50551. /*
  50552. * Generate table for pairing.
  50553. *
  50554. * Small implementation does not use a table - returns 0 length.
  50555. *
  50556. * pm [in] Point to generate table for.
  50557. * table [in] Generated table.
  50558. * len [in,out] On in, the size of the buffer.
  50559. * On out, length of table generated.
  50560. * @return 0 on success.
  50561. * LENGTH_ONLY_E when table is NULL and only length returned.
  50562. * BUFFER_E when len is too small.
  50563. */
  50564. int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
  50565. word32* len)
  50566. {
  50567. int err = 0;
  50568. if (table == NULL) {
  50569. *len = 0;
  50570. err = LENGTH_ONLY_E;
  50571. }
  50572. else if (*len != 0) {
  50573. err = BUFFER_E;
  50574. }
  50575. (void)*pm;
  50576. return err;
  50577. }
  50578. /*
  50579. * Calculate r = pairing <P, Q>.
  50580. *
  50581. * That is, multiply base in PF_p[q] by the scalar s, such that s.P = Q.
  50582. *
  50583. * Small implementation does not use a table - use the normal implementation.
  50584. *
  50585. * @param [in] pm First point on E(F_p)[q].
  50586. * @param [in] qm Second point on E(F_p)[q].
  50587. * @param [in] res Result of calculation.
  50588. * @param [in] table Precomputed table of values.
  50589. * @param [in] len Length of precomputed table of values in bytes.
  50590. * @return 0 on success.
  50591. * @return MEMORY_E when dynamic memory allocation fails.
  50592. */
  50593. int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
  50594. mp_int* res, const byte* table, word32 len)
  50595. {
  50596. (void)table;
  50597. (void)len;
  50598. return sp_Pairing_1024(pm, qm, res);
  50599. }
  50600. #else
  50601. /*
  50602. * Calc l and c for the point when doubling p.
  50603. *
  50604. * l = 3 * (p.x^2 - 1) / (2 * p.y)
  50605. * c = l * p.x - p.y
  50606. *
  50607. * @param [out] lr Gradient result - table entry.
  50608. * @param [out] cr Constant result - table entry.
  50609. * @param [in] px X-ordinate of point to double.
  50610. * @param [in] py Y-ordinate of point to double.
  50611. * @param [in] t SP temporaries (3 used).
  50612. */
  50613. static void sp_1024_accum_dbl_calc_lc_42(sp_digit* lr, sp_digit* cr,
  50614. const sp_digit* px, const sp_digit* py, sp_digit* t)
  50615. {
  50616. sp_digit* t1 = t + 33 * 2 * 42;
  50617. sp_digit* t2 = t + 34 * 2 * 42;
  50618. sp_digit* l = t + 35 * 2 * 42;
  50619. /* l = 1 / 2 * p.y */
  50620. sp_1024_mont_dbl_42(l, py, p1024_mod);
  50621. sp_1024_mont_inv_42(l, l, t);
  50622. /* t1 = p.x^2 */
  50623. sp_1024_mont_sqr_42(t1, px, p1024_mod, p1024_mp_mod);
  50624. /* t1 = p.x - 1 */
  50625. sp_1024_mont_sub_42(t1, t1, p1024_norm_mod, p1024_mod);
  50626. /* t1 = 3 * (p.x^2 - 1) */
  50627. sp_1024_mont_dbl_42(t2, t1, p1024_mod);
  50628. sp_1024_mont_add_42(t1, t1, t2, p1024_mod);
  50629. /* t1 = 3 * (p.x^2 - 1) / (2 * p.y) */
  50630. sp_1024_mont_mul_42(l, l, t1, p1024_mod, p1024_mp_mod);
  50631. /* t2 = l * p.x */
  50632. sp_1024_mont_mul_42(t2, l, px, p1024_mod, p1024_mp_mod);
  50633. /* c = t2 = l * p.x - p.y */
  50634. sp_1024_mont_sub_42(t2, t2, py, p1024_mod);
  50635. XMEMCPY(lr, l, sizeof(sp_digit) * 42);
  50636. XMEMCPY(cr, t2, sizeof(sp_digit) * 42);
  50637. }
  50638. /*
  50639. * Calc l and c when adding p and c.
  50640. *
  50641. * l = (c.y - p.y) / (c.x - p.x)
  50642. * c = (p.x * c.y - cx * p.y) / (cx - p.x)
  50643. *
  50644. * @param [out] lr Gradient result - table entry.
  50645. * @param [out] cr Constant result - table entry.
  50646. * @param [in] px X-ordinate of point to add.
  50647. * @param [in] py Y-ordinate of point to add.
  50648. * @param [in] cx X-ordinate of current point.
  50649. * @param [in] cy Y-ordinate of current point.
  50650. * @param [in] t SP temporaries (3 used).
  50651. */
  50652. static void sp_1024_accum_add_calc_lc_42(sp_digit* lr, sp_digit* cr,
  50653. const sp_digit* px, const sp_digit* py, const sp_digit* cx,
  50654. const sp_digit* cy, sp_digit* t)
  50655. {
  50656. sp_digit* t1 = t + 33 * 2 * 42;
  50657. sp_digit* c = t + 34 * 2 * 42;
  50658. sp_digit* l = t + 35 * 2 * 42;
  50659. /* l = 1 / (c.x - p.x) */
  50660. sp_1024_mont_sub_42(l, cx, px, p1024_mod);
  50661. sp_1024_mont_inv_42(l, l, t);
  50662. /* c = p.x * c.y */
  50663. sp_1024_mont_mul_42(c, px, cy, p1024_mod, p1024_mp_mod);
  50664. /* t1 = c.x * p.y */
  50665. sp_1024_mont_mul_42(t1, cx, py, p1024_mod, p1024_mp_mod);
  50666. /* c = (p.x * c.y) - (c.x * p.y) */
  50667. sp_1024_mont_sub_42(c, c, t1, p1024_mod);
  50668. /* c = ((p.x * c.y) - (c.x * p.y)) / (c.x - p.x) */
  50669. sp_1024_mont_mul_42(c, c, l, p1024_mod, p1024_mp_mod);
  50670. /* t1 = c.y - p.y */
  50671. sp_1024_mont_sub_42(t1, cy, py, p1024_mod);
  50672. /* l = (c.y - p.y) / (c.x - p.x) */
  50673. sp_1024_mont_mul_42(l, t1, l, p1024_mod, p1024_mp_mod);
  50674. XMEMCPY(lr, l, sizeof(sp_digit) * 42);
  50675. XMEMCPY(cr, c, sizeof(sp_digit) * 42);
  50676. }
  50677. /*
  50678. * Calculate vx and vy given gradient l and constant c and point q.
  50679. *
  50680. * l is a the gradient and is multiplied by q->x.
  50681. * c is a the constant that is added to the multiplicative result.
  50682. * q->y is the y-ordinate in result to multiply.
  50683. *
  50684. * if dbl
  50685. * v* = v*^2
  50686. * r.x = l * q.x + c
  50687. * r.y = q->y
  50688. * v* = v* * r*
  50689. *
  50690. * @param [in,out] vx X-ordinate of projective value in F*.
  50691. * @param [in,out] vy Y-ordinate of projective value in F*.
  50692. * @param [in] l Gradient to multiply with.
  50693. * @param [in] c Constant to add with.
  50694. * @param [in] q ECC point - second point on E(F_P^2).
  50695. * @param [in] t SP temporaries (3 used).
  50696. * @param [in] dbl Indicates whether this is for doubling. Otherwise
  50697. * adding.
  50698. */
  50699. static void sp_1024_accumulate_line_lc_42(sp_digit* vx, sp_digit* vy,
  50700. const sp_digit* l, const sp_digit* c, const sp_point_1024* q,
  50701. sp_digit* t, int dbl)
  50702. {
  50703. sp_digit* rx = t + 4 * 2 * 42;
  50704. /* v = v^2 */
  50705. if (dbl) {
  50706. sp_1024_proj_sqr_42(vx, vy, t);
  50707. }
  50708. /* rx = l * q.x + c */
  50709. sp_1024_mont_mul_42(rx, l, q->x, p1024_mod, p1024_mp_mod);
  50710. sp_1024_mont_add_42(rx, rx, c, p1024_mod);
  50711. /* v = v^2 * r */
  50712. sp_1024_proj_mul_42(vx, vy, rx, q->y, t);
  50713. }
  50714. /* Operations to perform based on order - 1.
  50715. * Sliding window. Start at bottom and stop when bottom bit is one.
  50716. * Subtract if top bit in window is one.
  50717. * Width of 6 bits.
  50718. * Pairs: #dbls, add/subtract window value
  50719. */
  50720. static const signed char sp_1024_order_op_pre[] = {
  50721. 5, 6, -13, 9, -21, 6, -5, 8, 31, 6, 3, 6, -27, 6, 25, 9,
  50722. -1, 6, -11, 6, -13, 6, -7, 6, -15, 6, -29, 7, 25, 6, -9, 6,
  50723. -19, 7, 3, 6, 11, 9, -23, 6, 1, 6, 27, 6, 1, 7, -25, 8,
  50724. 13, 7, -13, 7, -23, 10, 19, 7, 7, 7, -3, 7, 27, 6, -7, 7,
  50725. -21, 7, 11, 7, 31, 8, 1, 7, -23, 6, -17, 6, -3, 10, 11, 6,
  50726. -21, 7, -27, 11, -29, 6, -1, 10, 15, 8, 27, 7, 17, 6, 17, 7,
  50727. -13, 8, 13, 6, 21, 7, -29, 6, 19, 7, -25, 6, 11, 9, 29, 7,
  50728. -7, 8, 27, 7, 29, 10, -1, 8, -7, 8, 17, 6, 17, 7, -27, 7,
  50729. -21, 6, -9, 6, -27, 12, -23, 6, 19, 6, 13, 6, -11, 7, 27, 6,
  50730. 17, 6, -7, 6, -25, 7, -29, 6, 9, 7, 7, 6, 13, 6, -25, 6,
  50731. -19, 6, 13, 6, -11, 6, 5, 8, 19, 6, -21, 8, 23, 7, 27, 6,
  50732. -13, 6, -19, 11, 29, 7, -15, 6, -9, 7, -21, 10, -3, 7, 21, 10,
  50733. 25, 6, -15, 6, -23, 6, 21, 6, 1, 6, 21, 7, -3, 6, -3, 7,
  50734. -7, 6, -23, 7, 7, 8, 15, 9, 5, 6, -11, 6, 21, 11, -27, 7,
  50735. 27, 6, -11, 6, 31, 6, -21, 6, 19, 6, -7, 8, -7, 13, -3, 6,
  50736. -7, 7, -3, 6, 1, 6, 7, 8, 19, 8, 11, 9, -9, 7, -31, 12,
  50737. 25, 6, -17, 9, -15, 7, 5, 6, 25, 7, -5, 7, -25, 6, 17, 8,
  50738. -19, 6, -13, 6, 27, 8, 1, 7, -5, 7, -1, 6, 21, 6, 3, 10,
  50739. -3, 1,
  50740. };
  50741. /*
  50742. * Generate table for pairing.
  50743. *
  50744. * Calculate the graident (l) and constant (c) at each step of the way.
  50745. * Sliding window. Start at bottom and stop when bottom bit is one.
  50746. * Subtract if top bit in window is one.
  50747. * Width of 6 bits.
  50748. *
  50749. * pm [in] Point to generate table for.
  50750. * table [in] Generated table.
  50751. * len [in,out] On in, the size of the buffer.
  50752. * On out, length of table generated.
  50753. * @return 0 on success.
  50754. * LENGTH_ONLY_E when table is NULL and only length returned.
  50755. * BUFFER_E when len is too small.
  50756. * MEMORY_E when dynamic memory allocation fauls.
  50757. */
  50758. int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
  50759. word32* len)
  50760. {
  50761. int err = 0;
  50762. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50763. defined(WOLFSSL_SP_SMALL_STACK)
  50764. sp_digit* td = NULL;
  50765. sp_digit* t;
  50766. sp_point_1024* pre_p;
  50767. #else
  50768. sp_digit t[36 * 2 * 42];
  50769. sp_point_1024 pre_p[16];
  50770. sp_point_1024 pd;
  50771. sp_point_1024 cd;
  50772. sp_point_1024 negd;
  50773. #endif
  50774. sp_point_1024* p = NULL;
  50775. sp_point_1024* c = NULL;
  50776. sp_point_1024* neg = NULL;
  50777. int i;
  50778. int j;
  50779. int k;
  50780. sp_table_entry_1024* precomp = (sp_table_entry_1024*)table;
  50781. if (table == NULL) {
  50782. *len = sizeof(sp_table_entry_1024) * 1167;
  50783. err = LENGTH_ONLY_E;
  50784. }
  50785. if ((err == MP_OKAY) &&
  50786. (*len < (int)(sizeof(sp_table_entry_1024) * 1167))) {
  50787. err = BUFFER_E;
  50788. }
  50789. if (err == MP_OKAY) {
  50790. err = sp_1024_point_new_42(NULL, pd, p);
  50791. }
  50792. if (err == MP_OKAY) {
  50793. err = sp_1024_point_new_42(NULL, cd, c);
  50794. }
  50795. if (err == MP_OKAY) {
  50796. err = sp_1024_point_new_42(NULL, negd, neg);
  50797. }
  50798. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50799. defined(WOLFSSL_SP_SMALL_STACK)
  50800. if (err == MP_OKAY) {
  50801. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 36 * 42 * 2 + 16 *
  50802. sizeof(sp_point_1024), NULL, DYNAMIC_TYPE_TMP_BUFFER);
  50803. if (td == NULL) {
  50804. err = MEMORY_E;
  50805. }
  50806. }
  50807. #endif
  50808. if (err == MP_OKAY) {
  50809. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50810. defined(WOLFSSL_SP_SMALL_STACK)
  50811. t = td;
  50812. pre_p = (sp_point_1024*)(td + 36 * 42 * 2);
  50813. #endif
  50814. sp_1024_point_from_ecc_point_42(p, pm);
  50815. err = sp_1024_mod_mul_norm_42(p->x, p->x, p1024_mod);
  50816. }
  50817. if (err == MP_OKAY) {
  50818. err = sp_1024_mod_mul_norm_42(p->y, p->y, p1024_mod);
  50819. }
  50820. if (err == MP_OKAY) {
  50821. XMEMCPY(p->z, p1024_norm_mod, sizeof(p1024_norm_mod));
  50822. neg->infinity = 0;
  50823. c->infinity = 0;
  50824. /* Generate pre-computation table: 1, 3, ... , 31 */
  50825. XMEMCPY(&pre_p[0], p, sizeof(sp_point_1024));
  50826. /* [2]P for adding */
  50827. sp_1024_proj_point_dbl_42(c, p, t);
  50828. /* 1, 3, ... */
  50829. for (i = 1; i < 16; i++) {
  50830. sp_1024_proj_point_add_42(&pre_p[i], &pre_p[i-1], c, t);
  50831. sp_1024_mont_map_42(&pre_p[i], t);
  50832. }
  50833. k = 0;
  50834. j = sp_1024_order_op_pre[0] / 2;
  50835. XMEMCPY(c, &pre_p[j], sizeof(sp_point_1024));
  50836. for (j = 0; j < sp_1024_order_op_pre[1]; j++) {
  50837. sp_1024_accum_dbl_calc_lc_42(precomp[k].x, precomp[k].y, c->x,
  50838. c->y, t);
  50839. k++;
  50840. sp_1024_proj_point_dbl_42(c, c, t);
  50841. sp_1024_mont_map_42(c, t);
  50842. }
  50843. for (i = 2; i < 290; i += 2) {
  50844. j = sp_1024_order_op_pre[i];
  50845. if (j > 0) {
  50846. sp_1024_accum_add_calc_lc_42(precomp[k].x, precomp[k].y,
  50847. pre_p[j/2].x, pre_p[j/2].y, c->x, c->y, t);
  50848. k++;
  50849. sp_1024_proj_point_add_42(c, c, &pre_p[j/2], t);
  50850. sp_1024_mont_map_42(c, t);
  50851. }
  50852. else {
  50853. XMEMCPY(neg->x, pre_p[-j / 2].x, sizeof(pre_p->x));
  50854. sp_1024_mont_sub_42(neg->y, p1024_mod, pre_p[-j / 2].y,
  50855. p1024_mod);
  50856. XMEMCPY(neg->z, pre_p[-j / 2].z, sizeof(pre_p->z));
  50857. sp_1024_accum_add_calc_lc_42(precomp[k].x, precomp[k].y,
  50858. neg->x, neg->y, c->x, c->y, t);
  50859. k++;
  50860. sp_1024_proj_point_add_42(c, c, neg, t);
  50861. sp_1024_mont_map_42(c, t);
  50862. }
  50863. for (j = 0; j < sp_1024_order_op_pre[i + 1]; j++) {
  50864. sp_1024_accum_dbl_calc_lc_42(precomp[k].x, precomp[k].y, c->x,
  50865. c->y, t);
  50866. k++;
  50867. sp_1024_proj_point_dbl_42(c, c, t);
  50868. sp_1024_mont_map_42(c, t);
  50869. }
  50870. }
  50871. *len = sizeof(sp_table_entry_1024) * 1167;
  50872. }
  50873. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50874. defined(WOLFSSL_SP_SMALL_STACK)
  50875. if (td != NULL) {
  50876. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  50877. }
  50878. #endif
  50879. sp_1024_point_free_42(neg, 1, NULL);
  50880. sp_1024_point_free_42(c, 1, NULL);
  50881. sp_1024_point_free_42(p, 1, NULL);
  50882. return err;
  50883. }
  50884. /*
  50885. * Calculate r = pairing <P, Q>.
  50886. *
  50887. * That is, multiply base in PF_p[q] by the scalar s, such that s.P = Q.
  50888. *
  50889. * Sliding window. Start at bottom and stop when bottom bit is one.
  50890. * Subtract if top bit in window is one.
  50891. * Width of 6 bits.
  50892. * Pre-generate values in window (1, 3, ...) - only V.
  50893. * Table contains all gradient l and a constant for each point on the path.
  50894. *
  50895. * @param [in] pm First point on E(F_p)[q].
  50896. * @param [in] qm Second point on E(F_p)[q].
  50897. * @param [in] res Result of calculation.
  50898. * @param [in] table Precomputed table of values.
  50899. * @param [in] len Length of precomputed table of values in bytes.
  50900. * @return 0 on success.
  50901. * @return MEMORY_E when dynamic memory allocation fails.
  50902. */
  50903. int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
  50904. mp_int* res, const byte* table, word32 len)
  50905. {
  50906. int err = 0;
  50907. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50908. defined(WOLFSSL_SP_SMALL_STACK)
  50909. sp_digit* td = NULL;
  50910. sp_digit* t;
  50911. sp_digit* vx;
  50912. sp_digit* vy;
  50913. sp_digit (*pre_vx)[84];
  50914. sp_digit (*pre_vy)[84];
  50915. sp_digit (*pre_nvy)[84];
  50916. #else
  50917. sp_digit t[36 * 2 * 42];
  50918. sp_digit vx[2 * 42];
  50919. sp_digit vy[2 * 42];
  50920. sp_digit pre_vx[16][84];
  50921. sp_digit pre_vy[16][84];
  50922. sp_digit pre_nvy[16][84];
  50923. sp_point_1024 pd;
  50924. sp_point_1024 qd;
  50925. sp_point_1024 cd;
  50926. #endif
  50927. sp_point_1024* p = NULL;
  50928. sp_point_1024* q = NULL;
  50929. sp_point_1024* c = NULL;
  50930. sp_digit* r = NULL;
  50931. int i;
  50932. int j;
  50933. int k;
  50934. const sp_table_entry_1024* precomp = (const sp_table_entry_1024*)table;
  50935. if (len < (int)(sizeof(sp_table_entry_1024) * 1167)) {
  50936. err = BUFFER_E;
  50937. }
  50938. if (err == MP_OKAY) {
  50939. err = sp_1024_point_new_42(NULL, pd, p);
  50940. }
  50941. if (err == MP_OKAY) {
  50942. err = sp_1024_point_new_42(NULL, qd, q);
  50943. }
  50944. if (err == MP_OKAY) {
  50945. err = sp_1024_point_new_42(NULL, cd, c);
  50946. }
  50947. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50948. defined(WOLFSSL_SP_SMALL_STACK)
  50949. if (err == MP_OKAY) {
  50950. td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 86 * 42 * 2, NULL,
  50951. DYNAMIC_TYPE_TMP_BUFFER);
  50952. if (td == NULL) {
  50953. err = MEMORY_E;
  50954. }
  50955. }
  50956. #endif
  50957. if (err == MP_OKAY) {
  50958. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  50959. defined(WOLFSSL_SP_SMALL_STACK)
  50960. t = td;
  50961. vx = td + 36 * 42 * 2;
  50962. vy = td + 37 * 42 * 2;
  50963. pre_vx = (sp_digit(*)[84])(td + 38 * 42 * 2);
  50964. pre_vy = (sp_digit(*)[84])(td + 54 * 42 * 2);
  50965. pre_nvy = (sp_digit(*)[84])(td + 70 * 42 * 2);
  50966. #endif
  50967. r = vy;
  50968. sp_1024_point_from_ecc_point_42(p, pm);
  50969. sp_1024_point_from_ecc_point_42(q, qm);
  50970. err = sp_1024_mod_mul_norm_42(p->x, p->x, p1024_mod);
  50971. }
  50972. if (err == MP_OKAY) {
  50973. err = sp_1024_mod_mul_norm_42(p->y, p->y, p1024_mod);
  50974. }
  50975. if (err == MP_OKAY) {
  50976. err = sp_1024_mod_mul_norm_42(p->z, p->z, p1024_mod);
  50977. }
  50978. if (err == MP_OKAY) {
  50979. err = sp_1024_mod_mul_norm_42(q->x, q->x, p1024_mod);
  50980. }
  50981. if (err == MP_OKAY) {
  50982. err = sp_1024_mod_mul_norm_42(q->y, q->y, p1024_mod);
  50983. }
  50984. if (err == MP_OKAY) {
  50985. /* Generate pre-computation table: 1, 3, ... , 31 */
  50986. XMEMSET(pre_vx[0], 0, sizeof(sp_digit) * 2 * 42);
  50987. pre_vx[0][0] = 1;
  50988. XMEMSET(pre_vy[0], 0, sizeof(sp_digit) * 2 * 42);
  50989. sp_1024_mont_sub_42(pre_nvy[0], p1024_mod, pre_vy[0], p1024_mod);
  50990. /* [2]P for adding */
  50991. XMEMCPY(c, p, sizeof(sp_point_1024));
  50992. XMEMSET(vx, 0, sizeof(sp_digit) * 2 * 42);
  50993. vx[0] = 1;
  50994. XMEMSET(vy, 0, sizeof(sp_digit) * 2 * 42);
  50995. sp_1024_accumulate_line_dbl_42(vx, vy, c, q, t);
  50996. /* 3, 5, ... */
  50997. for (i = 1; i < 16; i++) {
  50998. XMEMCPY(pre_vx[i], pre_vx[i-1], sizeof(sp_digit) * 2 * 42);
  50999. XMEMCPY(pre_vy[i], pre_vy[i-1], sizeof(sp_digit) * 2 * 42);
  51000. sp_1024_proj_mul_42(pre_vx[i], pre_vy[i], vx, vy, t);
  51001. sp_1024_accumulate_line_add_n_42(pre_vx[i], pre_vy[i], c,
  51002. q, p, t, 0);
  51003. sp_1024_mont_sub_42(pre_nvy[i], p1024_mod, pre_vy[i],
  51004. p1024_mod);
  51005. }
  51006. XMEMCPY(c->z, p1024_norm_mod, sizeof(sp_digit) * 42);
  51007. c->infinity = 0;
  51008. j = sp_1024_order_op_pre[0] / 2;
  51009. XMEMCPY(vx, pre_vx[j], sizeof(sp_digit) * 2 * 42);
  51010. XMEMCPY(vy, pre_vy[j], sizeof(sp_digit) * 2 * 42);
  51011. k = 0;
  51012. for (j = 0; j < sp_1024_order_op_pre[1]; j++) {
  51013. /* Accumulate line into v and double point. */
  51014. sp_1024_accumulate_line_lc_42(vx, vy, precomp[k].x,
  51015. precomp[k].y, q, t, 1);
  51016. k++;
  51017. }
  51018. for (i = 2; i < 290; i += 2) {
  51019. sp_1024_accumulate_line_lc_42(vx, vy, precomp[k].x,
  51020. precomp[k].y, q, t, 0);
  51021. k++;
  51022. j = sp_1024_order_op_pre[i];
  51023. if (j > 0) {
  51024. j /= 2;
  51025. /* Accumulate line into v. */
  51026. sp_1024_proj_mul_42(vx, vy, pre_vx[j], pre_vy[j], t);
  51027. }
  51028. else {
  51029. j = -j / 2;
  51030. /* Accumulate line into v. */
  51031. sp_1024_proj_mul_42(vx, vy, pre_vx[j], pre_nvy[j], t);
  51032. }
  51033. for (j = 0; j < sp_1024_order_op_pre[i + 1]; j++) {
  51034. /* Accumulate line into v and double point. */
  51035. sp_1024_accumulate_line_lc_42(vx, vy, precomp[k].x,
  51036. precomp[k].y, q, t, 1);
  51037. k++;
  51038. }
  51039. }
  51040. /* Final exponentiation */
  51041. sp_1024_proj_sqr_42(vx, vy, t);
  51042. sp_1024_proj_sqr_42(vx, vy, t);
  51043. /* Convert from PF_p[q] to F_p */
  51044. sp_1024_mont_inv_42(vx, vx, t);
  51045. sp_1024_mont_mul_42(r, vx, vy, p1024_mod, p1024_mp_mod);
  51046. XMEMSET(r + 42, 0, sizeof(sp_digit) * 42);
  51047. sp_1024_mont_reduce_42(r, p1024_mod, p1024_mp_mod);
  51048. err = sp_1024_to_mp(r, res);
  51049. }
  51050. #if (defined(WOLFSSL_SP_SMALL) && !defined(WOLFSSL_SP_NO_MALLOC)) || \
  51051. defined(WOLFSSL_SP_SMALL_STACK)
  51052. if (td != NULL) {
  51053. XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
  51054. }
  51055. #endif
  51056. sp_1024_point_free_42(c, 1, NULL);
  51057. sp_1024_point_free_42(q, 1, NULL);
  51058. sp_1024_point_free_42(p, 1, NULL);
  51059. return err;
  51060. }
  51061. #endif /* WOLFSSL_SP_SMALL */
  51062. #ifdef HAVE_ECC_CHECK_KEY
  51063. /* Read big endian unsigned byte array into r.
  51064. *
  51065. * r A single precision integer.
  51066. * size Maximum number of bytes to convert
  51067. * a Byte array.
  51068. * n Number of bytes in array to read.
  51069. */
  51070. static void sp_1024_from_bin(sp_digit* r, int size, const byte* a, int n)
  51071. {
  51072. int i;
  51073. int j = 0;
  51074. word32 s = 0;
  51075. r[0] = 0;
  51076. for (i = n-1; i >= 0; i--) {
  51077. r[j] |= (((sp_digit)a[i]) << s);
  51078. if (s >= 17U) {
  51079. r[j] &= 0x1ffffff;
  51080. s = 25U - s;
  51081. if (j + 1 >= size) {
  51082. break;
  51083. }
  51084. r[++j] = (sp_digit)a[i] >> s;
  51085. s = 8U - s;
  51086. }
  51087. else {
  51088. s += 8U;
  51089. }
  51090. }
  51091. for (j++; j < size; j++) {
  51092. r[j] = 0;
  51093. }
  51094. }
  51095. /* Check that the x and y ordinates are a valid point on the curve.
  51096. *
  51097. * point EC point.
  51098. * heap Heap to use if dynamically allocating.
  51099. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  51100. * not on the curve and MP_OKAY otherwise.
  51101. */
  51102. static int sp_1024_ecc_is_point_42(const sp_point_1024* point,
  51103. void* heap)
  51104. {
  51105. #ifdef WOLFSSL_SP_SMALL_STACK
  51106. sp_digit* t1 = NULL;
  51107. #else
  51108. sp_digit t1[42 * 4];
  51109. #endif
  51110. sp_digit* t2 = NULL;
  51111. sp_int32 n;
  51112. int err = MP_OKAY;
  51113. #ifdef WOLFSSL_SP_SMALL_STACK
  51114. t1 = (sp_digit*)XMALLOC(sizeof(sp_digit) * 42 * 4, heap, DYNAMIC_TYPE_ECC);
  51115. if (t1 == NULL)
  51116. err = MEMORY_E;
  51117. #endif
  51118. (void)heap;
  51119. if (err == MP_OKAY) {
  51120. t2 = t1 + 2 * 42;
  51121. /* y^2 - x^3 - a.x = b */
  51122. sp_1024_sqr_42(t1, point->y);
  51123. (void)sp_1024_mod_42(t1, t1, p1024_mod);
  51124. sp_1024_sqr_42(t2, point->x);
  51125. (void)sp_1024_mod_42(t2, t2, p1024_mod);
  51126. sp_1024_mul_42(t2, t2, point->x);
  51127. (void)sp_1024_mod_42(t2, t2, p1024_mod);
  51128. sp_1024_mont_sub_42(t1, t1, t2, p1024_mod);
  51129. /* y^2 - x^3 + 3.x = b, when a = -3 */
  51130. sp_1024_mont_add_42(t1, t1, point->x, p1024_mod);
  51131. sp_1024_mont_add_42(t1, t1, point->x, p1024_mod);
  51132. sp_1024_mont_add_42(t1, t1, point->x, p1024_mod);
  51133. n = sp_1024_cmp_42(t1, p1024_mod);
  51134. sp_1024_cond_sub_42(t1, t1, p1024_mod, ~(n >> 24));
  51135. sp_1024_norm_42(t1);
  51136. if (!sp_1024_iszero_42(t1)) {
  51137. err = MP_VAL;
  51138. }
  51139. }
  51140. #ifdef WOLFSSL_SP_SMALL_STACK
  51141. if (t1 != NULL)
  51142. XFREE(t1, heap, DYNAMIC_TYPE_ECC);
  51143. #endif
  51144. return err;
  51145. }
  51146. /* Check that the x and y ordinates are a valid point on the curve.
  51147. *
  51148. * pX X ordinate of EC point.
  51149. * pY Y ordinate of EC point.
  51150. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  51151. * not on the curve and MP_OKAY otherwise.
  51152. */
  51153. int sp_ecc_is_point_1024(const mp_int* pX, const mp_int* pY)
  51154. {
  51155. #ifdef WOLFSSL_SP_SMALL_STACK
  51156. sp_point_1024* pub = NULL;
  51157. #else
  51158. sp_point_1024 pub[1];
  51159. #endif
  51160. const byte one[1] = { 1 };
  51161. int err = MP_OKAY;
  51162. #ifdef WOLFSSL_SP_SMALL_STACK
  51163. pub = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024), NULL,
  51164. DYNAMIC_TYPE_ECC);
  51165. if (pub == NULL)
  51166. err = MEMORY_E;
  51167. #endif
  51168. if (err == MP_OKAY) {
  51169. sp_1024_from_mp(pub->x, 42, pX);
  51170. sp_1024_from_mp(pub->y, 42, pY);
  51171. sp_1024_from_bin(pub->z, 42, one, (int)sizeof(one));
  51172. err = sp_1024_ecc_is_point_42(pub, NULL);
  51173. }
  51174. #ifdef WOLFSSL_SP_SMALL_STACK
  51175. if (pub != NULL)
  51176. XFREE(pub, NULL, DYNAMIC_TYPE_ECC);
  51177. #endif
  51178. return err;
  51179. }
  51180. /* Check that the private scalar generates the EC point (px, py), the point is
  51181. * on the curve and the point has the correct order.
  51182. *
  51183. * pX X ordinate of EC point.
  51184. * pY Y ordinate of EC point.
  51185. * privm Private scalar that generates EC point.
  51186. * returns MEMORY_E if dynamic memory allocation fails, MP_VAL if the point is
  51187. * not on the curve, ECC_INF_E if the point does not have the correct order,
  51188. * ECC_PRIV_KEY_E when the private scalar doesn't generate the EC point and
  51189. * MP_OKAY otherwise.
  51190. */
  51191. int sp_ecc_check_key_1024(const mp_int* pX, const mp_int* pY,
  51192. const mp_int* privm, void* heap)
  51193. {
  51194. #ifdef WOLFSSL_SP_SMALL_STACK
  51195. sp_digit* priv = NULL;
  51196. sp_point_1024* pub = NULL;
  51197. #else
  51198. sp_digit priv[42];
  51199. sp_point_1024 pub[2];
  51200. #endif
  51201. sp_point_1024* p = NULL;
  51202. const byte one[1] = { 1 };
  51203. int err = MP_OKAY;
  51204. /* Quick check the lengs of public key ordinates and private key are in
  51205. * range. Proper check later.
  51206. */
  51207. if (((mp_count_bits(pX) > 1024) ||
  51208. (mp_count_bits(pY) > 1024) ||
  51209. ((privm != NULL) && (mp_count_bits(privm) > 1024)))) {
  51210. err = ECC_OUT_OF_RANGE_E;
  51211. }
  51212. #ifdef WOLFSSL_SP_SMALL_STACK
  51213. if (err == MP_OKAY) {
  51214. pub = (sp_point_1024*)XMALLOC(sizeof(sp_point_1024) * 2, heap,
  51215. DYNAMIC_TYPE_ECC);
  51216. if (pub == NULL)
  51217. err = MEMORY_E;
  51218. }
  51219. if (err == MP_OKAY && privm) {
  51220. priv = (sp_digit*)XMALLOC(sizeof(sp_digit) * 42, heap,
  51221. DYNAMIC_TYPE_ECC);
  51222. if (priv == NULL)
  51223. err = MEMORY_E;
  51224. }
  51225. #endif
  51226. if (err == MP_OKAY) {
  51227. p = pub + 1;
  51228. sp_1024_from_mp(pub->x, 42, pX);
  51229. sp_1024_from_mp(pub->y, 42, pY);
  51230. sp_1024_from_bin(pub->z, 42, one, (int)sizeof(one));
  51231. if (privm)
  51232. sp_1024_from_mp(priv, 42, privm);
  51233. /* Check point at infinitiy. */
  51234. if ((sp_1024_iszero_42(pub->x) != 0) &&
  51235. (sp_1024_iszero_42(pub->y) != 0)) {
  51236. err = ECC_INF_E;
  51237. }
  51238. }
  51239. /* Check range of X and Y */
  51240. if ((err == MP_OKAY) &&
  51241. ((sp_1024_cmp_42(pub->x, p1024_mod) >= 0) ||
  51242. (sp_1024_cmp_42(pub->y, p1024_mod) >= 0))) {
  51243. err = ECC_OUT_OF_RANGE_E;
  51244. }
  51245. if (err == MP_OKAY) {
  51246. /* Check point is on curve */
  51247. err = sp_1024_ecc_is_point_42(pub, heap);
  51248. }
  51249. if (err == MP_OKAY) {
  51250. /* Point * order = infinity */
  51251. err = sp_1024_ecc_mulmod_42(p, pub, p1024_order, 1, 1, heap);
  51252. }
  51253. /* Check result is infinity */
  51254. if ((err == MP_OKAY) && ((sp_1024_iszero_42(p->x) == 0) ||
  51255. (sp_1024_iszero_42(p->y) == 0))) {
  51256. err = ECC_INF_E;
  51257. }
  51258. if (privm) {
  51259. if (err == MP_OKAY) {
  51260. /* Base * private = point */
  51261. err = sp_1024_ecc_mulmod_base_42(p, priv, 1, 1, heap);
  51262. }
  51263. /* Check result is public key */
  51264. if ((err == MP_OKAY) &&
  51265. ((sp_1024_cmp_42(p->x, pub->x) != 0) ||
  51266. (sp_1024_cmp_42(p->y, pub->y) != 0))) {
  51267. err = ECC_PRIV_KEY_E;
  51268. }
  51269. }
  51270. #ifdef WOLFSSL_SP_SMALL_STACK
  51271. if (pub != NULL)
  51272. XFREE(pub, heap, DYNAMIC_TYPE_ECC);
  51273. if (priv != NULL)
  51274. XFREE(priv, heap, DYNAMIC_TYPE_ECC);
  51275. #endif
  51276. return err;
  51277. }
  51278. #endif
  51279. #endif /* WOLFSSL_SP_1024 */
  51280. #endif /* WOLFCRYPT_HAVE_SAKKE */
  51281. #endif /* WOLFSSL_HAVE_SP_ECC */
  51282. #endif /* SP_WORD_SIZE == 32 */
  51283. #endif /* !WOLFSSL_SP_ASM */
  51284. #endif /* WOLFSSL_HAVE_SP_RSA | WOLFSSL_HAVE_SP_DH | WOLFSSL_HAVE_SP_ECC */