krb5.h 301 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135
  1. /* This file is generated, please don't edit it directly. */
  2. #ifndef KRB5_KRB5_H_INCLUDED
  3. #define KRB5_KRB5_H_INCLUDED
  4. /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
  5. /* General definitions for Kerberos version 5. */
  6. /*
  7. * Copyright 1989, 1990, 1995, 2001, 2003, 2007, 2011 by the Massachusetts
  8. * Institute of Technology. All Rights Reserved.
  9. *
  10. * Export of this software from the United States of America may
  11. * require a specific license from the United States Government.
  12. * It is the responsibility of any person or organization contemplating
  13. * export to obtain such a license before exporting.
  14. *
  15. * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  16. * distribute this software and its documentation for any purpose and
  17. * without fee is hereby granted, provided that the above copyright
  18. * notice appear in all copies and that both that copyright notice and
  19. * this permission notice appear in supporting documentation, and that
  20. * the name of M.I.T. not be used in advertising or publicity pertaining
  21. * to distribution of the software without specific, written prior
  22. * permission. Furthermore if you modify this software you must label
  23. * your software as modified software and not distribute it in such a
  24. * fashion that it might be confused with the original M.I.T. software.
  25. * M.I.T. makes no representations about the suitability of
  26. * this software for any purpose. It is provided "as is" without express
  27. * or implied warranty.
  28. */
  29. /*
  30. * Copyright (C) 1998 by the FundsXpress, INC.
  31. *
  32. * All rights reserved.
  33. *
  34. * Export of this software from the United States of America may require
  35. * a specific license from the United States Government. It is the
  36. * responsibility of any person or organization contemplating export to
  37. * obtain such a license before exporting.
  38. *
  39. * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  40. * distribute this software and its documentation for any purpose and
  41. * without fee is hereby granted, provided that the above copyright
  42. * notice appear in all copies and that both that copyright notice and
  43. * this permission notice appear in supporting documentation, and that
  44. * the name of FundsXpress. not be used in advertising or publicity pertaining
  45. * to distribution of the software without specific, written prior
  46. * permission. FundsXpress makes no representations about the suitability of
  47. * this software for any purpose. It is provided "as is" without express
  48. * or implied warranty.
  49. *
  50. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  51. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  52. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  53. */
  54. #ifndef KRB5_GENERAL__
  55. #define KRB5_GENERAL__
  56. /* By default, do not expose deprecated interfaces. */
  57. #ifndef KRB5_DEPRECATED
  58. #define KRB5_DEPRECATED 0
  59. #endif
  60. #if defined(__MACH__) && defined(__APPLE__)
  61. # include <TargetConditionals.h>
  62. # if TARGET_RT_MAC_CFM
  63. # error "Use KfM 4.0 SDK headers for CFM compilation."
  64. # endif
  65. #endif
  66. #if defined(_MSDOS) || defined(_WIN32)
  67. #include <win-mac.h>
  68. #endif
  69. #ifndef KRB5_CONFIG__
  70. #ifndef KRB5_CALLCONV
  71. #define KRB5_CALLCONV
  72. #define KRB5_CALLCONV_C
  73. #endif /* !KRB5_CALLCONV */
  74. #endif /* !KRB5_CONFIG__ */
  75. #ifndef KRB5_CALLCONV_WRONG
  76. #define KRB5_CALLCONV_WRONG
  77. #endif
  78. #ifndef THREEPARAMOPEN
  79. #define THREEPARAMOPEN(x,y,z) open(x,y,z)
  80. #endif
  81. #if KRB5_PRIVATE
  82. #ifndef WRITABLEFOPEN
  83. #define WRITABLEFOPEN(x,y) fopen(x,y)
  84. #endif
  85. #endif
  86. #define KRB5_OLD_CRYPTO
  87. #include <stdlib.h>
  88. #include <limits.h> /* for *_MAX */
  89. #include <stdarg.h>
  90. #ifndef KRB5INT_BEGIN_DECLS
  91. #if defined(__cplusplus)
  92. #define KRB5INT_BEGIN_DECLS extern "C" {
  93. #define KRB5INT_END_DECLS }
  94. #else
  95. #define KRB5INT_BEGIN_DECLS
  96. #define KRB5INT_END_DECLS
  97. #endif
  98. #endif
  99. KRB5INT_BEGIN_DECLS
  100. #if TARGET_OS_MAC
  101. # pragma pack(push,2)
  102. #endif
  103. #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 30203
  104. # define KRB5_ATTR_DEPRECATED __attribute__((deprecated))
  105. #elif defined _WIN32
  106. # define KRB5_ATTR_DEPRECATED __declspec(deprecated)
  107. #else
  108. # define KRB5_ATTR_DEPRECATED
  109. #endif
  110. /* from profile.h */
  111. struct _profile_t;
  112. /* typedef struct _profile_t *profile_t; */
  113. /*
  114. * begin wordsize.h
  115. */
  116. /*
  117. * Word-size related definition.
  118. */
  119. typedef unsigned char krb5_octet;
  120. #if INT_MAX == 0x7fff
  121. typedef int krb5_int16;
  122. typedef unsigned int krb5_ui_2;
  123. #elif SHRT_MAX == 0x7fff
  124. typedef short krb5_int16;
  125. typedef unsigned short krb5_ui_2;
  126. #else
  127. #error undefined 16 bit type
  128. #endif
  129. #if INT_MAX == 0x7fffffffL
  130. typedef int krb5_int32;
  131. typedef unsigned int krb5_ui_4;
  132. #elif LONG_MAX == 0x7fffffffL
  133. typedef long krb5_int32;
  134. typedef unsigned long krb5_ui_4;
  135. #elif SHRT_MAX == 0x7fffffffL
  136. typedef short krb5_int32;
  137. typedef unsigned short krb5_ui_4;
  138. #else
  139. #error: undefined 32 bit type
  140. #endif
  141. #define VALID_INT_BITS INT_MAX
  142. #define VALID_UINT_BITS UINT_MAX
  143. #define KRB5_INT32_MAX 2147483647
  144. /* this strange form is necessary since - is a unary operator, not a sign
  145. indicator */
  146. #define KRB5_INT32_MIN (-KRB5_INT32_MAX-1)
  147. #define KRB5_INT16_MAX 65535
  148. /* this strange form is necessary since - is a unary operator, not a sign
  149. indicator */
  150. #define KRB5_INT16_MIN (-KRB5_INT16_MAX-1)
  151. /*
  152. * end wordsize.h
  153. */
  154. /*
  155. * begin "base-defs.h"
  156. */
  157. /*
  158. * Basic definitions for Kerberos V5 library
  159. */
  160. #ifndef FALSE
  161. #define FALSE 0
  162. #endif
  163. #ifndef TRUE
  164. #define TRUE 1
  165. #endif
  166. typedef unsigned int krb5_boolean;
  167. typedef unsigned int krb5_msgtype;
  168. typedef unsigned int krb5_kvno;
  169. typedef krb5_int32 krb5_addrtype;
  170. typedef krb5_int32 krb5_enctype;
  171. typedef krb5_int32 krb5_cksumtype;
  172. typedef krb5_int32 krb5_authdatatype;
  173. typedef krb5_int32 krb5_keyusage;
  174. typedef krb5_int32 krb5_cryptotype;
  175. typedef krb5_int32 krb5_preauthtype; /* This may change, later on */
  176. typedef krb5_int32 krb5_flags;
  177. typedef krb5_int32 krb5_timestamp;
  178. typedef krb5_int32 krb5_error_code;
  179. typedef krb5_int32 krb5_deltat;
  180. typedef krb5_error_code krb5_magic;
  181. typedef struct _krb5_data {
  182. krb5_magic magic;
  183. unsigned int length;
  184. char *data;
  185. } krb5_data;
  186. typedef struct _krb5_octet_data {
  187. krb5_magic magic;
  188. unsigned int length;
  189. krb5_octet *data;
  190. } krb5_octet_data;
  191. /*
  192. * Hack length for crypto library to use the afs_string_to_key It is
  193. * equivalent to -1 without possible sign extension
  194. * We also overload for an unset salt type length - which is also -1, but
  195. * hey, why not....
  196. */
  197. #define SALT_TYPE_AFS_LENGTH UINT_MAX
  198. #define SALT_TYPE_NO_LENGTH UINT_MAX
  199. typedef void * krb5_pointer;
  200. typedef void const * krb5_const_pointer;
  201. typedef struct krb5_principal_data {
  202. krb5_magic magic;
  203. krb5_data realm;
  204. krb5_data *data; /**< An array of strings */
  205. krb5_int32 length;
  206. krb5_int32 type;
  207. } krb5_principal_data;
  208. typedef krb5_principal_data * krb5_principal;
  209. /*
  210. * Per V5 spec on definition of principal types
  211. */
  212. /* Name type not known */
  213. #define KRB5_NT_UNKNOWN 0
  214. /* Just the name of the principal as in DCE, or for users */
  215. #define KRB5_NT_PRINCIPAL 1
  216. /* Service and other unique instance (krbtgt) */
  217. #define KRB5_NT_SRV_INST 2
  218. /* Service with host name as instance (telnet, rcommands) */
  219. #define KRB5_NT_SRV_HST 3
  220. /* Service with host as remaining components */
  221. #define KRB5_NT_SRV_XHST 4
  222. /* Unique ID */
  223. #define KRB5_NT_UID 5
  224. /* PKINIT */
  225. #define KRB5_NT_X500_PRINCIPAL 6
  226. /* Name in form of SMTP email name */
  227. #define KRB5_NT_SMTP_NAME 7
  228. /* Windows 2000 UPN */
  229. #define KRB5_NT_ENTERPRISE_PRINCIPAL 10
  230. #define KRB5_NT_WELLKNOWN 11
  231. /* First component of NT_WELLKNOWN principals */
  232. #define KRB5_WELLKNOWN_NAMESTR "WELLKNOWN"
  233. /* Windows 2000 UPN and SID */
  234. #define KRB5_NT_MS_PRINCIPAL -128
  235. /* NT 4 style name */
  236. #define KRB5_NT_MS_PRINCIPAL_AND_ID -129
  237. /* NT 4 style name and SID */
  238. #define KRB5_NT_ENT_PRINCIPAL_AND_ID -130
  239. /** Constant version of krb5_principal_data */
  240. typedef const krb5_principal_data *krb5_const_principal;
  241. #define krb5_princ_realm(context, princ) (&(princ)->realm)
  242. #define krb5_princ_set_realm(context, princ,value) ((princ)->realm = *(value))
  243. #define krb5_princ_set_realm_length(context, princ,value) (princ)->realm.length = (value)
  244. #define krb5_princ_set_realm_data(context, princ,value) (princ)->realm.data = (value)
  245. #define krb5_princ_size(context, princ) (princ)->length
  246. #define krb5_princ_type(context, princ) (princ)->type
  247. #define krb5_princ_name(context, princ) (princ)->data
  248. #define krb5_princ_component(context, princ,i) \
  249. (((i) < krb5_princ_size(context, princ)) \
  250. ? (princ)->data + (i) \
  251. : NULL)
  252. /** Constant for realm referrals. */
  253. #define KRB5_REFERRAL_REALM ""
  254. /*
  255. * Referral-specific functions.
  256. */
  257. /**
  258. * Check for a match with KRB5_REFERRAL_REALM.
  259. *
  260. * @param [in] r Realm to check
  261. *
  262. * @return @c TRUE if @a r is zero-length, @c FALSE otherwise
  263. */
  264. krb5_boolean KRB5_CALLCONV
  265. krb5_is_referral_realm(const krb5_data *r);
  266. /**
  267. * Return an anonymous realm data.
  268. *
  269. * This function returns constant storage that must not be freed.
  270. *
  271. * @sa #KRB5_ANONYMOUS_REALMSTR
  272. */
  273. const krb5_data *KRB5_CALLCONV
  274. krb5_anonymous_realm(void);
  275. /**
  276. * Build an anonymous principal.
  277. *
  278. * This function returns constant storage that must not be freed.
  279. *
  280. * @sa KRB5_ANONYMOUS_PRINCSTR
  281. */
  282. krb5_const_principal KRB5_CALLCONV
  283. krb5_anonymous_principal(void);
  284. #define KRB5_ANONYMOUS_REALMSTR "WELLKNOWN:ANONYMOUS"
  285. #define KRB5_ANONYMOUS_PRINCSTR "ANONYMOUS" /* wellknown name type */
  286. /*
  287. * end "base-defs.h"
  288. */
  289. /*
  290. * begin "hostaddr.h"
  291. */
  292. /** Structure for address */
  293. typedef struct _krb5_address {
  294. krb5_magic magic;
  295. krb5_addrtype addrtype;
  296. unsigned int length;
  297. krb5_octet *contents;
  298. } krb5_address;
  299. /* per Kerberos v5 protocol spec */
  300. #define ADDRTYPE_INET 0x0002
  301. #define ADDRTYPE_CHAOS 0x0005
  302. #define ADDRTYPE_XNS 0x0006
  303. #define ADDRTYPE_ISO 0x0007
  304. #define ADDRTYPE_DDP 0x0010
  305. #define ADDRTYPE_NETBIOS 0x0014
  306. #define ADDRTYPE_INET6 0x0018
  307. /* not yet in the spec... */
  308. #define ADDRTYPE_ADDRPORT 0x0100
  309. #define ADDRTYPE_IPPORT 0x0101
  310. /* macros to determine if a type is a local type */
  311. #define ADDRTYPE_IS_LOCAL(addrtype) (addrtype & 0x8000)
  312. /*
  313. * end "hostaddr.h"
  314. */
  315. struct _krb5_context;
  316. typedef struct _krb5_context * krb5_context;
  317. struct _krb5_auth_context;
  318. typedef struct _krb5_auth_context * krb5_auth_context;
  319. struct _krb5_cryptosystem_entry;
  320. /*
  321. * begin "encryption.h"
  322. */
  323. /** Exposed contents of a key. */
  324. typedef struct _krb5_keyblock {
  325. krb5_magic magic;
  326. krb5_enctype enctype;
  327. unsigned int length;
  328. krb5_octet *contents;
  329. } krb5_keyblock;
  330. struct krb5_key_st;
  331. /**
  332. * Opaque identifier for a key.
  333. *
  334. * Use with the krb5_k APIs for better performance for repeated operations with
  335. * the same key and usage. Key identifiers must not be used simultaneously
  336. * within multiple threads, as they may contain mutable internal state and are
  337. * not mutex-protected.
  338. */
  339. typedef struct krb5_key_st *krb5_key;
  340. #ifdef KRB5_OLD_CRYPTO
  341. typedef struct _krb5_encrypt_block {
  342. krb5_magic magic;
  343. krb5_enctype crypto_entry; /* to call krb5_encrypt_size, you need
  344. this. it was a pointer, but it
  345. doesn't have to be. gross. */
  346. krb5_keyblock *key;
  347. } krb5_encrypt_block;
  348. #endif
  349. typedef struct _krb5_checksum {
  350. krb5_magic magic;
  351. krb5_cksumtype checksum_type; /* checksum type */
  352. unsigned int length;
  353. krb5_octet *contents;
  354. } krb5_checksum;
  355. typedef struct _krb5_enc_data {
  356. krb5_magic magic;
  357. krb5_enctype enctype;
  358. krb5_kvno kvno;
  359. krb5_data ciphertext;
  360. } krb5_enc_data;
  361. /**
  362. * Structure to describe a region of text to be encrypted or decrypted.
  363. *
  364. * The @a flags member describes the type of the iov.
  365. * The @a data member points to the memory that will be manipulated.
  366. * All iov APIs take a pointer to the first element of an array of krb5_crypto_iov's
  367. * along with the size of that array. Buffer contents are manipulated in-place;
  368. * data is overwritten. Callers must allocate the right number of krb5_crypto_iov
  369. * structures before calling into an iov API.
  370. */
  371. typedef struct _krb5_crypto_iov {
  372. krb5_cryptotype flags; /**< @ref KRB5_CRYPTO_TYPE type of the iov */
  373. krb5_data data;
  374. } krb5_crypto_iov;
  375. /* per Kerberos v5 protocol spec */
  376. #define ENCTYPE_NULL 0x0000
  377. #define ENCTYPE_DES_CBC_CRC 0x0001 /**< DES cbc mode with CRC-32 */
  378. #define ENCTYPE_DES_CBC_MD4 0x0002 /**< DES cbc mode with RSA-MD4 */
  379. #define ENCTYPE_DES_CBC_MD5 0x0003 /**< DES cbc mode with RSA-MD5 */
  380. #define ENCTYPE_DES_CBC_RAW 0x0004 /**< @deprecated DES cbc mode raw */
  381. #define ENCTYPE_DES3_CBC_SHA 0x0005 /**< @deprecated DES-3 cbc with SHA1 */
  382. #define ENCTYPE_DES3_CBC_RAW 0x0006 /**< @deprecated DES-3 cbc mode raw */
  383. #define ENCTYPE_DES_HMAC_SHA1 0x0008 /**< @deprecated */
  384. /* PKINIT */
  385. #define ENCTYPE_DSA_SHA1_CMS 0x0009 /**< DSA with SHA1, CMS signature */
  386. #define ENCTYPE_MD5_RSA_CMS 0x000a /**< MD5 with RSA, CMS signature */
  387. #define ENCTYPE_SHA1_RSA_CMS 0x000b /**< SHA1 with RSA, CMS signature */
  388. #define ENCTYPE_RC2_CBC_ENV 0x000c /**< RC2 cbc mode, CMS enveloped data */
  389. #define ENCTYPE_RSA_ENV 0x000d /**< RSA encryption, CMS enveloped data */
  390. #define ENCTYPE_RSA_ES_OAEP_ENV 0x000e /**< RSA w/OEAP encryption, CMS enveloped data */
  391. #define ENCTYPE_DES3_CBC_ENV 0x000f /**< DES-3 cbc mode, CMS enveloped data */
  392. #define ENCTYPE_DES3_CBC_SHA1 0x0010
  393. #define ENCTYPE_AES128_CTS_HMAC_SHA1_96 0x0011 /**< RFC 3962 */
  394. #define ENCTYPE_AES256_CTS_HMAC_SHA1_96 0x0012 /**< RFC 3962 */
  395. #define ENCTYPE_ARCFOUR_HMAC 0x0017
  396. #define ENCTYPE_ARCFOUR_HMAC_EXP 0x0018
  397. #define ENCTYPE_UNKNOWN 0x01ff
  398. #define CKSUMTYPE_CRC32 0x0001
  399. #define CKSUMTYPE_RSA_MD4 0x0002
  400. #define CKSUMTYPE_RSA_MD4_DES 0x0003
  401. #define CKSUMTYPE_DESCBC 0x0004
  402. /* des-mac-k */
  403. /* rsa-md4-des-k */
  404. #define CKSUMTYPE_RSA_MD5 0x0007
  405. #define CKSUMTYPE_RSA_MD5_DES 0x0008
  406. #define CKSUMTYPE_NIST_SHA 0x0009
  407. #define CKSUMTYPE_HMAC_SHA1_DES3 0x000c
  408. #define CKSUMTYPE_HMAC_SHA1_96_AES128 0x000f /**< RFC 3962. Used with
  409. ENCTYPE_AES128_CTS_HMAC_SHA1_96 */
  410. #define CKSUMTYPE_HMAC_SHA1_96_AES256 0x0010 /**< RFC 3962. Used with
  411. ENCTYPE_AES256_CTS_HMAC_SHA1_96 */
  412. #define CKSUMTYPE_MD5_HMAC_ARCFOUR -137 /*Microsoft netlogon cksumtype*/
  413. #define CKSUMTYPE_HMAC_MD5_ARCFOUR -138 /*Microsoft md5 hmac cksumtype*/
  414. /*
  415. * The following are entropy source designations. Whenever
  416. * krb5_C_random_add_entropy is called, one of these source ids is passed in.
  417. * This allows the library to better estimate bits of entropy in the sample and
  418. * to keep track of what sources of entropy have contributed enough entropy.
  419. * Sources marked internal MUST NOT be used by applications outside the
  420. * Kerberos library
  421. */
  422. enum {
  423. KRB5_C_RANDSOURCE_OLDAPI = 0, /*calls to krb5_C_RANDOM_SEED (INTERNAL)*/
  424. KRB5_C_RANDSOURCE_OSRAND = 1, /* /dev/random or equivalent (internal)*/
  425. KRB5_C_RANDSOURCE_TRUSTEDPARTY = 2, /* From KDC or other trusted party*/
  426. /*
  427. * This source should be used carefully; data in this category
  428. * should be from a third party trusted to give random bits
  429. * For example keys issued by the KDC in the application server.
  430. */
  431. KRB5_C_RANDSOURCE_TIMING = 3, /* Timing of operations*/
  432. KRB5_C_RANDSOURCE_EXTERNAL_PROTOCOL = 4, /*Protocol data possibly from attacker*/
  433. KRB5_C_RANDSOURCE_MAX = 5 /*Do not use; maximum source ID*/
  434. };
  435. #ifndef krb5_roundup
  436. /* round x up to nearest multiple of y */
  437. #define krb5_roundup(x, y) ((((x) + (y) - 1)/(y))*(y))
  438. #endif /* roundup */
  439. /* macro function definitions to help clean up code */
  440. #if 1
  441. #define krb5_x(ptr,args) ((ptr)?((*(ptr)) args):(abort(),1))
  442. #define krb5_xc(ptr,args) ((ptr)?((*(ptr)) args):(abort(),(char*)0))
  443. #else
  444. #define krb5_x(ptr,args) ((*(ptr)) args)
  445. #define krb5_xc(ptr,args) ((*(ptr)) args)
  446. #endif
  447. /**
  448. * Encrypt data using a key (operates on keyblock).
  449. *
  450. * @param [in] context Library context
  451. * @param [in] key Encryption key
  452. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  453. * @param [in,out] cipher_state Cipher state; specify NULL if not needed
  454. * @param [in] input Data to be encrypted
  455. * @param [out] output Encrypted data
  456. *
  457. * This function encrypts the data block @a input and stores the output into @a
  458. * output. The actual encryption key will be derived from @a key and @a usage
  459. * if key derivation is specified for the encryption type. If non-null, @a
  460. * cipher_state specifies the beginning state for the encryption operation, and
  461. * is updated with the state to be passed as input to the next operation.
  462. *
  463. * @note The caller must initialize @a output and allocate at least enough
  464. * space for the result (using krb5_c_encrypt_length() to determine the amount
  465. * of space needed). @a output->length will be set to the actual length of the
  466. * ciphertext.
  467. *
  468. * @retval 0 Success; otherwise - Kerberos error codes
  469. */
  470. krb5_error_code KRB5_CALLCONV
  471. krb5_c_encrypt(krb5_context context, const krb5_keyblock *key,
  472. krb5_keyusage usage, const krb5_data *cipher_state,
  473. const krb5_data *input, krb5_enc_data *output);
  474. /**
  475. * Decrypt data using a key (operates on keyblock).
  476. *
  477. * @param [in] context Library context
  478. * @param [in] key Encryption key
  479. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  480. * @param [in,out] cipher_state Cipher state; specify NULL if not needed
  481. * @param [in] input Encrypted data
  482. * @param [out] output Decrypted data
  483. *
  484. * This function decrypts the data block @a input and stores the output into @a
  485. * output. The actual decryption key will be derived from @a key and @a usage
  486. * if key derivation is specified for the encryption type. If non-null, @a
  487. * cipher_state specifies the beginning state for the decryption operation, and
  488. * is updated with the state to be passed as input to the next operation.
  489. *
  490. * @note The caller must initialize @a output and allocate at least enough
  491. * space for the result. The usual practice is to allocate an output buffer as
  492. * long as the ciphertext, and let krb5_c_decrypt() trim @a output->length.
  493. * For some enctypes, the resulting @a output->length may include padding
  494. * bytes.
  495. *
  496. * @retval 0 Success; otherwise - Kerberos error codes
  497. */
  498. krb5_error_code KRB5_CALLCONV
  499. krb5_c_decrypt(krb5_context context, const krb5_keyblock *key,
  500. krb5_keyusage usage, const krb5_data *cipher_state,
  501. const krb5_enc_data *input, krb5_data *output);
  502. /**
  503. * Compute encrypted data length.
  504. *
  505. * @param [in] context Library context
  506. * @param [in] enctype Encryption type
  507. * @param [in] inputlen Length of the data to be encrypted
  508. * @param [out] length Length of the encrypted data
  509. *
  510. * This function computes the length of the ciphertext produced by encrypting
  511. * @a inputlen bytes including padding, confounder, and checksum.
  512. *
  513. * @retval 0 Success; otherwise - Kerberos error codes
  514. */
  515. krb5_error_code KRB5_CALLCONV
  516. krb5_c_encrypt_length(krb5_context context, krb5_enctype enctype,
  517. size_t inputlen, size_t *length);
  518. /**
  519. * Return cipher block size.
  520. *
  521. * @param [in] context Library context
  522. * @param [in] enctype Encryption type
  523. * @param [out] blocksize Block size for @a enctype
  524. *
  525. * @retval 0 Success; otherwise - Kerberos error codes
  526. */
  527. krb5_error_code KRB5_CALLCONV
  528. krb5_c_block_size(krb5_context context, krb5_enctype enctype,
  529. size_t *blocksize);
  530. /**
  531. * Return length of the specified key in bytes.
  532. *
  533. * @param [in] context Library context
  534. * @param [in] enctype Encryption type
  535. * @param [out] keybytes Number of bytes required to make a key
  536. * @param [out] keylength Length of final key
  537. *
  538. * @retval 0 Success; otherwise - Kerberos error codes
  539. */
  540. krb5_error_code KRB5_CALLCONV
  541. krb5_c_keylengths(krb5_context context, krb5_enctype enctype,
  542. size_t *keybytes, size_t *keylength);
  543. /**
  544. * Initialize a new cipher state.
  545. *
  546. * @param [in] context Library context
  547. * @param [in] key Key
  548. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  549. * @param [out] new_state New cipher state
  550. *
  551. * @retval 0 Success; otherwise - Kerberos error codes
  552. */
  553. krb5_error_code KRB5_CALLCONV
  554. krb5_c_init_state(krb5_context context, const krb5_keyblock *key,
  555. krb5_keyusage usage, krb5_data *new_state);
  556. /**
  557. * Free a cipher state previously allocated by krb5_c_init_state().
  558. *
  559. * @param [in] context Library context
  560. * @param [in] key Key
  561. * @param [in] state Cipher state to be freed
  562. *
  563. * @retval 0 Success; otherwise - Kerberos error codes
  564. */
  565. krb5_error_code KRB5_CALLCONV
  566. krb5_c_free_state(krb5_context context, const krb5_keyblock *key,
  567. krb5_data *state);
  568. /**
  569. * Generate enctype-specific pseudo-random bytes.
  570. *
  571. * @param [in] context Library context
  572. * @param [in] keyblock Key
  573. * @param [in] input Input data
  574. * @param [out] output Output data
  575. *
  576. * This function selects a pseudo-random function based on @a keyblock and
  577. * computes its value over @a input, placing the result into @a output.
  578. * The caller must preinitialize @a output and allocate space for the
  579. * result, using krb5_c_prf_length() to determine the required length.
  580. *
  581. * @retval 0 Success; otherwise - Kerberos error codes
  582. */
  583. krb5_error_code KRB5_CALLCONV
  584. krb5_c_prf(krb5_context context, const krb5_keyblock *keyblock,
  585. krb5_data *input, krb5_data *output);
  586. /**
  587. * Get the output length of pseudo-random functions for an encryption type.
  588. *
  589. * @param [in] context Library context
  590. * @param [in] enctype Encryption type
  591. * @param [out] len Length of PRF output
  592. *
  593. * @retval 0 Success; otherwise - Kerberos error codes
  594. */
  595. krb5_error_code KRB5_CALLCONV
  596. krb5_c_prf_length(krb5_context context, krb5_enctype enctype, size_t *len);
  597. /**
  598. * Compute the KRB-FX-CF2 combination of two keys and pepper strings.
  599. *
  600. * @param [in] context Library context
  601. * @param [in] k1 KDC contribution key
  602. * @param [in] pepper1 String "PKINIT"
  603. * @param [in] k2 Reply key
  604. * @param [in] pepper2 String "KeyExchange"
  605. * @param [out] out Output key
  606. *
  607. * This function computes the KRB-FX-CF2 function over its inputs and places
  608. * the results in a newly allocated keyblock. This function is simple in that
  609. * it assumes that @a pepper1 and @a pepper2 are C strings with no internal
  610. * nulls and that the enctype of the result will be the same as that of @a k1.
  611. * @a k1 and @a k2 may be of different enctypes.
  612. *
  613. * @retval 0 Success; otherwise - Kerberos error codes
  614. */
  615. krb5_error_code KRB5_CALLCONV
  616. krb5_c_fx_cf2_simple(krb5_context context,
  617. krb5_keyblock *k1, const char *pepper1,
  618. krb5_keyblock *k2, const char *pepper2,
  619. krb5_keyblock **out);
  620. /**
  621. * Generate an enctype-specific random encryption key.
  622. *
  623. * @param [in] context Library context
  624. * @param [in] enctype Encryption type of the generated key
  625. * @param [out] k5_random_key An allocated and initialized keyblock
  626. *
  627. * Use krb5_free_keyblock_contents() to free @a k5_random_key when
  628. * no longer needed.
  629. *
  630. * @retval 0 Success; otherwise - Kerberos error codes
  631. */
  632. krb5_error_code KRB5_CALLCONV
  633. krb5_c_make_random_key(krb5_context context, krb5_enctype enctype,
  634. krb5_keyblock *k5_random_key);
  635. /**
  636. * Generate an enctype-specific key from random data.
  637. *
  638. * @param [in] context Library context
  639. * @param [in] enctype Encryption type
  640. * @param [in] random_data Random input data
  641. * @param [out] k5_random_key Resulting key
  642. *
  643. * This function takes random input data @a random_data and produces a valid
  644. * key @a k5_random_key for a given @a enctype.
  645. *
  646. * @note It is assumed that @a k5_random_key has already been initialized and
  647. * @a k5_random_key->contents has been allocated with the correct length.
  648. *
  649. * @sa krb5_c_keylengths()
  650. *
  651. * @retval 0 Success; otherwise - Kerberos error codes
  652. */
  653. krb5_error_code KRB5_CALLCONV
  654. krb5_c_random_to_key(krb5_context context, krb5_enctype enctype,
  655. krb5_data *random_data, krb5_keyblock *k5_random_key);
  656. /**
  657. * Add entropy to the pseudo-random number generator.
  658. *
  659. * @param [in] context Library context
  660. * @param [in] randsource Entropy source (see KRB5_RANDSOURCE types)
  661. * @param [in] data Data
  662. *
  663. * Contribute entropy to the PRNG used by krb5 crypto operations. This may or
  664. * may not affect the output of the next crypto operation requiring random
  665. * data.
  666. *
  667. * @retval 0 Success; otherwise - Kerberos error codes
  668. */
  669. krb5_error_code KRB5_CALLCONV
  670. krb5_c_random_add_entropy(krb5_context context, unsigned int randsource,
  671. const krb5_data *data);
  672. /**
  673. * Generate pseudo-random bytes.
  674. *
  675. * @param [in] context Library context
  676. * @param [out] data Random data
  677. *
  678. * Fills in @a data with bytes from the PRNG used by krb5 crypto operations.
  679. * The caller must preinitialize @a data and allocate the desired amount of
  680. * space.
  681. *
  682. * @retval 0 Success; otherwise - Kerberos error codes
  683. */
  684. krb5_error_code KRB5_CALLCONV
  685. krb5_c_random_make_octets(krb5_context context, krb5_data *data);
  686. /**
  687. * Collect entropy from the OS if possible.
  688. *
  689. * @param [in] context Library context
  690. * @param [in] strong Strongest available source of entropy
  691. * @param [out] success 1 if OS provides entropy, 0 otherwise
  692. *
  693. * If @a strong is non-zero, this function attempts to use the strongest
  694. * available source of entropy. Setting this flag may cause the function to
  695. * block on some operating systems. Good uses include seeding the PRNG for
  696. * kadmind and realm setup.
  697. *
  698. * @retval 0 Success; otherwise - Kerberos error codes
  699. */
  700. krb5_error_code KRB5_CALLCONV
  701. krb5_c_random_os_entropy(krb5_context context, int strong, int *success);
  702. /** @deprecated Replaced by krb5_c_ API family. */
  703. krb5_error_code KRB5_CALLCONV
  704. krb5_c_random_seed(krb5_context context, krb5_data *data);
  705. /**
  706. * Convert a string (such a password) to a key.
  707. *
  708. * @param [in] context Library context
  709. * @param [in] enctype Encryption type
  710. * @param [in] string String to be converted
  711. * @param [in] salt Salt value
  712. * @param [out] key Generated key
  713. *
  714. * This function converts @a string to a @a key of encryption type @a enctype,
  715. * using the specified @a salt. The newly created @a key must be released by
  716. * calling krb5_free_keyblock_contents() when it is no longer needed.
  717. *
  718. * @retval 0 Success; otherwise - Kerberos error codes
  719. */
  720. krb5_error_code KRB5_CALLCONV
  721. krb5_c_string_to_key(krb5_context context, krb5_enctype enctype,
  722. const krb5_data *string, const krb5_data *salt,
  723. krb5_keyblock *key);
  724. /**
  725. * Convert a string (such as a password) to a key with additional parameters.
  726. *
  727. * @param [in] context Library context
  728. * @param [in] enctype Encryption type
  729. * @param [in] string String to be converted
  730. * @param [in] salt Salt value
  731. * @param [in] params Parameters
  732. * @param [out] key Generated key
  733. *
  734. * This function is similar to krb5_c_string_to_key(), but also takes
  735. * parameters which may affect the algorithm in an enctype-dependent way. The
  736. * newly created @a key must be released by calling
  737. * krb5_free_keyblock_contents() when it is no longer needed.
  738. *
  739. * @retval 0 Success; otherwise - Kerberos error codes
  740. */
  741. krb5_error_code KRB5_CALLCONV
  742. krb5_c_string_to_key_with_params(krb5_context context,
  743. krb5_enctype enctype,
  744. const krb5_data *string,
  745. const krb5_data *salt,
  746. const krb5_data *params,
  747. krb5_keyblock *key);
  748. /**
  749. * Compare two encryption types.
  750. *
  751. * @param [in] context Library context
  752. * @param [in] e1 First encryption type
  753. * @param [in] e2 Second encryption type
  754. * @param [out] similar @c TRUE if types are similar, @c FALSE if not
  755. *
  756. * This function determines whether two encryption types use the same kind of
  757. * keys.
  758. *
  759. * @retval 0 Success; otherwise - Kerberos error codes
  760. */
  761. krb5_error_code KRB5_CALLCONV
  762. krb5_c_enctype_compare(krb5_context context, krb5_enctype e1, krb5_enctype e2,
  763. krb5_boolean *similar);
  764. /**
  765. * Compute a checksum (operates on keyblock).
  766. *
  767. * @param [in] context Library context
  768. * @param [in] cksumtype Checksum type (0 for mandatory type)
  769. * @param [in] key Encryption key for a keyed checksum
  770. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  771. * @param [in] input Input data
  772. * @param [out] cksum Generated checksum
  773. *
  774. * This function computes a checksum of type @a cksumtype over @a input, using
  775. * @a key if the checksum type is a keyed checksum. If @a cksumtype is 0 and
  776. * @a key is non-null, the checksum type will be the mandatory-to-implement
  777. * checksum type for the key's encryption type. The actual checksum key will
  778. * be derived from @a key and @a usage if key derivation is specified for the
  779. * checksum type. The newly created @a cksum must be released by calling
  780. * krb5_free_checksum_contents() when it is no longer needed.
  781. *
  782. * @note This function is similar to krb5_k_make_checksum(), but operates
  783. * on keyblock @a key.
  784. *
  785. * @sa krb5_c_verify_checksum()
  786. *
  787. * @retval 0 Success; otherwise - Kerberos error codes
  788. */
  789. krb5_error_code KRB5_CALLCONV
  790. krb5_c_make_checksum(krb5_context context, krb5_cksumtype cksumtype,
  791. const krb5_keyblock *key, krb5_keyusage usage,
  792. const krb5_data *input, krb5_checksum *cksum);
  793. /**
  794. * Verify a checksum (operates on keyblock).
  795. *
  796. * @param [in] context Library context
  797. * @param [in] key Encryption key for a keyed checksum
  798. * @param [in] usage @a key usage
  799. * @param [in] data Data to be used to compute a new checksum
  800. * using @a key to compare @a cksum against
  801. * @param [in] cksum Checksum to be verified
  802. * @param [out] valid Non-zero for success, zero for failure
  803. *
  804. * This function verifies that @a cksum is a valid checksum for @a data. If
  805. * the checksum type of @a cksum is a keyed checksum, @a key is used to verify
  806. * the checksum. The actual checksum key will be derived from @a key and @a
  807. * usage if key derivation is specified for the checksum type.
  808. *
  809. * @note This function is similar to krb5_k_verify_checksum(), but operates
  810. * on keyblock @a key.
  811. *
  812. * @retval 0 Success; otherwise - Kerberos error codes
  813. */
  814. krb5_error_code KRB5_CALLCONV
  815. krb5_c_verify_checksum(krb5_context context, const krb5_keyblock *key,
  816. krb5_keyusage usage, const krb5_data *data,
  817. const krb5_checksum *cksum, krb5_boolean *valid);
  818. /**
  819. * Return the length of checksums for a checksum type.
  820. *
  821. * @param [in] context Library context
  822. * @param [in] cksumtype Checksum type
  823. * @param [out] length Checksum length
  824. *
  825. * @retval 0 Success; otherwise - Kerberos error codes
  826. */
  827. krb5_error_code KRB5_CALLCONV
  828. krb5_c_checksum_length(krb5_context context, krb5_cksumtype cksumtype,
  829. size_t *length);
  830. /**
  831. * Return a list of keyed checksum types usable with an encryption type.
  832. *
  833. * @param [in] context Library context
  834. * @param [in] enctype Encryption type
  835. * @param [out] count Count of allowable checksum types
  836. * @param [out] cksumtypes Array of allowable checksum types
  837. *
  838. * Use krb5_free_cksumtypes() to free @a cksumtypes when it is no longer
  839. * needed.
  840. *
  841. * @retval 0 Success; otherwise - Kerberos error codes
  842. */
  843. krb5_error_code KRB5_CALLCONV
  844. krb5_c_keyed_checksum_types(krb5_context context, krb5_enctype enctype,
  845. unsigned int *count, krb5_cksumtype **cksumtypes);
  846. /** @defgroup KRB5_KEYUSAGE KRB5_KEYUSAGE
  847. * @{
  848. */
  849. #define KRB5_KEYUSAGE_AS_REQ_PA_ENC_TS 1
  850. #define KRB5_KEYUSAGE_KDC_REP_TICKET 2
  851. #define KRB5_KEYUSAGE_AS_REP_ENCPART 3
  852. #define KRB5_KEYUSAGE_TGS_REQ_AD_SESSKEY 4
  853. #define KRB5_KEYUSAGE_TGS_REQ_AD_SUBKEY 5
  854. #define KRB5_KEYUSAGE_TGS_REQ_AUTH_CKSUM 6
  855. #define KRB5_KEYUSAGE_TGS_REQ_AUTH 7
  856. #define KRB5_KEYUSAGE_TGS_REP_ENCPART_SESSKEY 8
  857. #define KRB5_KEYUSAGE_TGS_REP_ENCPART_SUBKEY 9
  858. #define KRB5_KEYUSAGE_AP_REQ_AUTH_CKSUM 10
  859. #define KRB5_KEYUSAGE_AP_REQ_AUTH 11
  860. #define KRB5_KEYUSAGE_AP_REP_ENCPART 12
  861. #define KRB5_KEYUSAGE_KRB_PRIV_ENCPART 13
  862. #define KRB5_KEYUSAGE_KRB_CRED_ENCPART 14
  863. #define KRB5_KEYUSAGE_KRB_SAFE_CKSUM 15
  864. #define KRB5_KEYUSAGE_APP_DATA_ENCRYPT 16
  865. #define KRB5_KEYUSAGE_APP_DATA_CKSUM 17
  866. #define KRB5_KEYUSAGE_KRB_ERROR_CKSUM 18
  867. #define KRB5_KEYUSAGE_AD_KDCISSUED_CKSUM 19
  868. #define KRB5_KEYUSAGE_AD_MTE 20
  869. #define KRB5_KEYUSAGE_AD_ITE 21
  870. /* XXX need to register these */
  871. #define KRB5_KEYUSAGE_GSS_TOK_MIC 22
  872. #define KRB5_KEYUSAGE_GSS_TOK_WRAP_INTEG 23
  873. #define KRB5_KEYUSAGE_GSS_TOK_WRAP_PRIV 24
  874. /* Defined in hardware preauth draft */
  875. #define KRB5_KEYUSAGE_PA_SAM_CHALLENGE_CKSUM 25
  876. #define KRB5_KEYUSAGE_PA_SAM_CHALLENGE_TRACKID 26
  877. #define KRB5_KEYUSAGE_PA_SAM_RESPONSE 27
  878. /* Defined in KDC referrals draft */
  879. /*
  880. * @note There is a conflict with the value of @c KRB5_KEYUSAGE_PA_REFERRAL:
  881. * it is used for hardware Pre-athentication @a and KDC referrals.
  882. */
  883. #define KRB5_KEYUSAGE_PA_REFERRAL 26 /* XXX note conflict with above */
  884. /* Defined in [MS-SFU] */
  885. #define KRB5_KEYUSAGE_PA_S4U_X509_USER_REQUEST 26 /* XXX note conflict with above */
  886. #define KRB5_KEYUSAGE_PA_S4U_X509_USER_REPLY 27 /* XXX note conflict with above */
  887. #define KRB5_KEYUSAGE_AD_SIGNEDPATH -21
  888. #define KRB5_KEYUSAGE_IAKERB_FINISHED 42
  889. #define KRB5_KEYUSAGE_PA_PKINIT_KX 44
  890. /* define in draft-ietf-krb-wg-preauth-framework*/
  891. #define KRB5_KEYUSAGE_FAST_REQ_CHKSUM 50
  892. #define KRB5_KEYUSAGE_FAST_ENC 51
  893. #define KRB5_KEYUSAGE_FAST_REP 52
  894. #define KRB5_KEYUSAGE_FAST_FINISHED 53
  895. #define KRB5_KEYUSAGE_ENC_CHALLENGE_CLIENT 54
  896. #define KRB5_KEYUSAGE_ENC_CHALLENGE_KDC 55
  897. #define KRB5_KEYUSAGE_AS_REQ 56
  898. /** @} */ /* end of KRB5_KEYUSAGE group */
  899. /**
  900. * Verify that a specified encryption type is a valid Kerberos encryption type.
  901. *
  902. * @param [in] ktype Encryption type
  903. *
  904. * @return @c TRUE if @a ktype is valid, @c FALSE if not
  905. */
  906. krb5_boolean KRB5_CALLCONV
  907. krb5_c_valid_enctype(krb5_enctype ktype);
  908. /**
  909. * Verify that specified checksum type is a valid Kerberos checksum type.
  910. *
  911. * @param [in] ctype Checksum type
  912. *
  913. * @return @c TRUE if @a ctype is valid, @c FALSE if not
  914. */
  915. krb5_boolean KRB5_CALLCONV
  916. krb5_c_valid_cksumtype(krb5_cksumtype ctype);
  917. /**
  918. * Test whether a checksum type is collision-proof.
  919. *
  920. * @param [in] ctype Checksum type
  921. *
  922. * @return @c TRUE if @a ctype is collision-proof, @c FALSE if it is not
  923. * collision-proof or not a valid checksum type.
  924. */
  925. krb5_boolean KRB5_CALLCONV
  926. krb5_c_is_coll_proof_cksum(krb5_cksumtype ctype);
  927. /**
  928. * Test whether a checksum type is keyed.
  929. *
  930. * @param [in] ctype Checksum type
  931. *
  932. * @return @c TRUE if @a ctype is a keyed checksum type, @c FALSE otherwise.
  933. */
  934. krb5_boolean KRB5_CALLCONV
  935. krb5_c_is_keyed_cksum(krb5_cksumtype ctype);
  936. /* AEAD APIs */
  937. /** @defgroup KRB5_CRYPTO_TYPE KRB5_CRYPTO_TYPE
  938. * @{
  939. */
  940. #define KRB5_CRYPTO_TYPE_EMPTY 0 /**< [in] ignored */
  941. #define KRB5_CRYPTO_TYPE_HEADER 1 /**< [out] header */
  942. #define KRB5_CRYPTO_TYPE_DATA 2 /**< [in, out] plaintext */
  943. #define KRB5_CRYPTO_TYPE_SIGN_ONLY 3 /**< [in] associated data */
  944. #define KRB5_CRYPTO_TYPE_PADDING 4 /**< [out] padding */
  945. #define KRB5_CRYPTO_TYPE_TRAILER 5 /**< [out] checksum for encrypt */
  946. #define KRB5_CRYPTO_TYPE_CHECKSUM 6 /**< [out] checksum for MIC */
  947. #define KRB5_CRYPTO_TYPE_STREAM 7 /**< [in] entire message without
  948. decomposing the structure into
  949. header, data and trailer buffers */
  950. /** @} */ /* end of KRB5_CRYPTO_TYPE group */
  951. /**
  952. * Fill in a checksum element in IOV array (operates on keyblock)
  953. *
  954. * @param [in] context Library context
  955. * @param [in] cksumtype Checksum type (0 for mandatory type)
  956. * @param [in] key Encryption key for a keyed checksum
  957. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  958. * @param [in,out] data IOV array
  959. * @param [in] num_data Size of @a data
  960. *
  961. * Create a checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element over
  962. * #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY chunks in @a data.
  963. * Only the #KRB5_CRYPTO_TYPE_CHECKSUM region is modified.
  964. *
  965. * @note This function is similar to krb5_k_make_checksum_iov(), but operates
  966. * on keyblock @a key.
  967. *
  968. * @sa krb5_c_verify_checksum_iov()
  969. *
  970. * @retval 0 Success; otherwise - Kerberos error codes
  971. */
  972. krb5_error_code KRB5_CALLCONV
  973. krb5_c_make_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
  974. const krb5_keyblock *key, krb5_keyusage usage,
  975. krb5_crypto_iov *data, size_t num_data);
  976. /**
  977. * Validate a checksum element in IOV array (operates on keyblock).
  978. *
  979. * @param [in] context Library context
  980. * @param [in] cksumtype Checksum type (0 for mandatory type)
  981. * @param [in] key Encryption key for a keyed checksum
  982. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  983. * @param [in] data IOV array
  984. * @param [in] num_data Size of @a data
  985. * @param [out] valid Non-zero for success, zero for failure
  986. *
  987. * Confirm that the checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element is a
  988. * valid checksum of the #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY
  989. * regions in the iov.
  990. *
  991. * @note This function is similar to krb5_k_verify_checksum_iov(), but operates
  992. * on keyblock @a key.
  993. *
  994. * @sa krb5_c_make_checksum_iov()
  995. *
  996. * @retval 0 Success; otherwise - Kerberos error codes
  997. */
  998. krb5_error_code KRB5_CALLCONV
  999. krb5_c_verify_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
  1000. const krb5_keyblock *key, krb5_keyusage usage,
  1001. const krb5_crypto_iov *data, size_t num_data,
  1002. krb5_boolean *valid);
  1003. /**
  1004. * Encrypt data in place supporting AEAD (operates on keyblock).
  1005. *
  1006. * @param [in] context Library context
  1007. * @param [in] keyblock Encryption key
  1008. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1009. * @param [in] cipher_state Cipher state; specify NULL if not needed
  1010. * @param [in,out] data IOV array. Modified in-place.
  1011. * @param [in] num_data Size of @a data
  1012. *
  1013. * This function encrypts the data block @a data and stores the output in-place.
  1014. * The actual encryption key will be derived from @a keyblock and @a usage
  1015. * if key derivation is specified for the encryption type. If non-null, @a
  1016. * cipher_state specifies the beginning state for the encryption operation, and
  1017. * is updated with the state to be passed as input to the next operation.
  1018. * The caller must allocate the right number of krb5_crypto_iov
  1019. * structures before calling into this API.
  1020. *
  1021. * @note On return from a krb5_c_encrypt_iov() call, the @a data->length in the
  1022. * iov structure are adjusted to reflect actual lengths of the ciphertext used.
  1023. * For example, if the padding length is too large, the length will be reduced.
  1024. * Lengths are never increased.
  1025. *
  1026. * @note This function is similar to krb5_k_encrypt_iov(), but operates
  1027. * on keyblock @a keyblock.
  1028. *
  1029. * @sa krb5_c_decrypt_iov()
  1030. *
  1031. * @retval 0 Success; otherwise - Kerberos error codes
  1032. */
  1033. krb5_error_code KRB5_CALLCONV
  1034. krb5_c_encrypt_iov(krb5_context context, const krb5_keyblock *keyblock,
  1035. krb5_keyusage usage, const krb5_data *cipher_state,
  1036. krb5_crypto_iov *data, size_t num_data);
  1037. /**
  1038. * Decrypt data in place supporting AEAD (operates on keyblock).
  1039. *
  1040. * @param [in] context Library context
  1041. * @param [in] keyblock Encryption key
  1042. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1043. * @param [in] cipher_state Cipher state; specify NULL if not needed
  1044. * @param [in,out] data IOV array. Modified in-place.
  1045. * @param [in] num_data Size of @a data
  1046. *
  1047. * This function decrypts the data block @a data and stores the output in-place.
  1048. * The actual decryption key will be derived from @a keyblock and @a usage
  1049. * if key derivation is specified for the encryption type. If non-null, @a
  1050. * cipher_state specifies the beginning state for the decryption operation, and
  1051. * is updated with the state to be passed as input to the next operation.
  1052. * The caller must allocate the right number of krb5_crypto_iov
  1053. * structures before calling into this API.
  1054. *
  1055. * @note On return from a krb5_c_decrypt_iov() call, the @a data->length in the
  1056. * iov structure are adjusted to reflect actual lengths of the ciphertext used.
  1057. * For example, if the padding length is too large, the length will be reduced.
  1058. * Lengths are never increased.
  1059. *
  1060. * @note This function is similar to krb5_k_decrypt_iov(), but operates
  1061. * on keyblock @a keyblock.
  1062. *
  1063. * @sa krb5_c_decrypt_iov()
  1064. *
  1065. * @retval 0 Success; otherwise - Kerberos error codes
  1066. */
  1067. krb5_error_code KRB5_CALLCONV
  1068. krb5_c_decrypt_iov(krb5_context context, const krb5_keyblock *keyblock,
  1069. krb5_keyusage usage, const krb5_data *cipher_state,
  1070. krb5_crypto_iov *data, size_t num_data);
  1071. /**
  1072. * Return a length of a message field specific to the encryption type.
  1073. *
  1074. * @param [in] context Library context
  1075. * @param [in] enctype Encryption type
  1076. * @param [in] type Type field (See @ref KRB5_CRYPTO_TYPE types)
  1077. * @param [out] size Length of the @a type specific to @a enctype
  1078. *
  1079. * @retval 0 Success; otherwise - Kerberos error codes
  1080. */
  1081. krb5_error_code KRB5_CALLCONV
  1082. krb5_c_crypto_length(krb5_context context, krb5_enctype enctype,
  1083. krb5_cryptotype type, unsigned int *size);
  1084. /**
  1085. * Fill in lengths for header, trailer and padding in a IOV array.
  1086. *
  1087. * @param [in] context Library context
  1088. * @param [in] enctype Encryption type
  1089. * @param [in,out] data IOV array
  1090. * @param [in] num_data Size of @a data
  1091. *
  1092. * Padding is set to the actual padding required based on the provided
  1093. * @a data buffers. Typically this API is used after setting up the data
  1094. * buffers and #KRB5_CRYPTO_TYPE_SIGN_ONLY buffers, but before actually
  1095. * allocating header, trailer and padding.
  1096. *
  1097. * @retval 0 Success; otherwise - Kerberos error codes
  1098. */
  1099. krb5_error_code KRB5_CALLCONV
  1100. krb5_c_crypto_length_iov(krb5_context context, krb5_enctype enctype,
  1101. krb5_crypto_iov *data, size_t num_data);
  1102. /**
  1103. * Return a number of padding octets.
  1104. *
  1105. * @param [in] context Library context
  1106. * @param [in] enctype Encryption type
  1107. * @param [in] data_length Length of the plaintext to pad
  1108. * @param [out] size Number of padding octets
  1109. *
  1110. * This function returns the number of the padding octets required to pad
  1111. * @a data_length octets of plaintext.
  1112. *
  1113. * @retval 0 Success; otherwise - KRB5_BAD_ENCTYPE
  1114. */
  1115. krb5_error_code KRB5_CALLCONV
  1116. krb5_c_padding_length(krb5_context context, krb5_enctype enctype,
  1117. size_t data_length, unsigned int *size);
  1118. /**
  1119. * Create a krb5_key from the enctype and key data in a keyblock.
  1120. *
  1121. * @param [in] context Library context
  1122. * @param [in] key_data Keyblock
  1123. * @param [out] out Opaque key
  1124. *
  1125. * The reference count on a key @a out is set to 1.
  1126. * Use krb5_k_free_key() to free @a out when it is no longer needed.
  1127. *
  1128. * @retval 0 Success; otherwise - KRB5_BAD_ENCTYPE
  1129. */
  1130. krb5_error_code KRB5_CALLCONV
  1131. krb5_k_create_key(krb5_context context, const krb5_keyblock *key_data,
  1132. krb5_key *out);
  1133. /** Increment the reference count on a key. */
  1134. void KRB5_CALLCONV
  1135. krb5_k_reference_key(krb5_context context, krb5_key key);
  1136. /** Decrement the reference count on a key and free it if it hits zero. */
  1137. void KRB5_CALLCONV
  1138. krb5_k_free_key(krb5_context context, krb5_key key);
  1139. /** Retrieve a copy of the keyblock from a krb5_key structure. */
  1140. krb5_error_code KRB5_CALLCONV
  1141. krb5_k_key_keyblock(krb5_context context, krb5_key key,
  1142. krb5_keyblock **key_data);
  1143. /** Retrieve the enctype of a krb5_key structure. */
  1144. krb5_enctype KRB5_CALLCONV
  1145. krb5_k_key_enctype(krb5_context context, krb5_key key);
  1146. /**
  1147. * Encrypt data using a key (operates on opaque key).
  1148. *
  1149. * @param [in] context Library context
  1150. * @param [in] key Encryption key
  1151. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1152. * @param [in,out] cipher_state Cipher state; specify NULL if not needed
  1153. * @param [in] input Data to be encrypted
  1154. * @param [out] output Encrypted data
  1155. *
  1156. * This function encrypts the data block @a input and stores the output into @a
  1157. * output. The actual encryption key will be derived from @a key and @a usage
  1158. * if key derivation is specified for the encryption type. If non-null, @a
  1159. * cipher_state specifies the beginning state for the encryption operation, and
  1160. * is updated with the state to be passed as input to the next operation.
  1161. *
  1162. * @note The caller must initialize @a output and allocate at least enough
  1163. * space for the result (using krb5_c_encrypt_length() to determine the amount
  1164. * of space needed). @a output->length will be set to the actual length of the
  1165. * ciphertext.
  1166. *
  1167. * @retval 0 Success; otherwise - Kerberos error codes
  1168. */
  1169. krb5_error_code KRB5_CALLCONV
  1170. krb5_k_encrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
  1171. const krb5_data *cipher_state, const krb5_data *input,
  1172. krb5_enc_data *output);
  1173. /**
  1174. * Encrypt data in place supporting AEAD (operates on opaque key).
  1175. *
  1176. * @param [in] context Library context
  1177. * @param [in] key Encryption key
  1178. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1179. * @param [in] cipher_state Cipher state; specify NULL if not needed
  1180. * @param [in,out] data IOV array. Modified in-place.
  1181. * @param [in] num_data Size of @a data
  1182. *
  1183. * This function encrypts the data block @a data and stores the output in-place.
  1184. * The actual encryption key will be derived from @a key and @a usage
  1185. * if key derivation is specified for the encryption type. If non-null, @a
  1186. * cipher_state specifies the beginning state for the encryption operation, and
  1187. * is updated with the state to be passed as input to the next operation.
  1188. * The caller must allocate the right number of krb5_crypto_iov
  1189. * structures before calling into this API.
  1190. *
  1191. * @note On return from a krb5_c_encrypt_iov() call, the @a data->length in the
  1192. * iov structure are adjusted to reflect actual lengths of the ciphertext used.
  1193. * For example, if the padding length is too large, the length will be reduced.
  1194. * Lengths are never increased.
  1195. *
  1196. * @note This function is similar to krb5_c_encrypt_iov(), but operates
  1197. * on opaque key @a key.
  1198. *
  1199. * @sa krb5_k_decrypt_iov()
  1200. *
  1201. * @retval 0 Success; otherwise - Kerberos error codes
  1202. */
  1203. krb5_error_code KRB5_CALLCONV
  1204. krb5_k_encrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
  1205. const krb5_data *cipher_state, krb5_crypto_iov *data,
  1206. size_t num_data);
  1207. /**
  1208. * Decrypt data using a key (operates on opaque key).
  1209. *
  1210. * @param [in] context Library context
  1211. * @param [in] key Encryption key
  1212. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1213. * @param [in,out] cipher_state Cipher state; specify NULL if not needed
  1214. * @param [in] input Encrypted data
  1215. * @param [out] output Decrypted data
  1216. *
  1217. * This function decrypts the data block @a input and stores the output into @a
  1218. * output. The actual decryption key will be derived from @a key and @a usage
  1219. * if key derivation is specified for the encryption type. If non-null, @a
  1220. * cipher_state specifies the beginning state for the decryption operation, and
  1221. * is updated with the state to be passed as input to the next operation.
  1222. *
  1223. * @note The caller must initialize @a output and allocate at least enough
  1224. * space for the result. The usual practice is to allocate an output buffer as
  1225. * long as the ciphertext, and let krb5_c_decrypt() trim @a output->length.
  1226. * For some enctypes, the resulting @a output->length may include padding
  1227. * bytes.
  1228. *
  1229. * @retval 0 Success; otherwise - Kerberos error codes
  1230. */
  1231. krb5_error_code KRB5_CALLCONV
  1232. krb5_k_decrypt(krb5_context context, krb5_key key, krb5_keyusage usage,
  1233. const krb5_data *cipher_state, const krb5_enc_data *input,
  1234. krb5_data *output);
  1235. /**
  1236. * Decrypt data in place supporting AEAD (operates on opaque key).
  1237. *
  1238. * @param [in] context Library context
  1239. * @param [in] key Encryption key
  1240. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1241. * @param [in] cipher_state Cipher state; specify NULL if not needed
  1242. * @param [in,out] data IOV array. Modified in-place.
  1243. * @param [in] num_data Size of @a data
  1244. *
  1245. * This function decrypts the data block @a data and stores the output in-place.
  1246. * The actual decryption key will be derived from @a key and @a usage
  1247. * if key derivation is specified for the encryption type. If non-null, @a
  1248. * cipher_state specifies the beginning state for the decryption operation, and
  1249. * is updated with the state to be passed as input to the next operation.
  1250. * The caller must allocate the right number of krb5_crypto_iov
  1251. * structures before calling into this API.
  1252. *
  1253. * @note On return from a krb5_c_decrypt_iov() call, the @a data->length in the
  1254. * iov structure are adjusted to reflect actual lengths of the ciphertext used.
  1255. * For example, if the padding length is too large, the length will be reduced.
  1256. * Lengths are never increased.
  1257. *
  1258. * @note This function is similar to krb5_c_decrypt_iov(), but operates
  1259. * on opaque key @a key.
  1260. *
  1261. * @sa krb5_k_encrypt_iov()
  1262. *
  1263. * @retval 0 Success; otherwise - Kerberos error codes
  1264. */
  1265. krb5_error_code KRB5_CALLCONV
  1266. krb5_k_decrypt_iov(krb5_context context, krb5_key key, krb5_keyusage usage,
  1267. const krb5_data *cipher_state, krb5_crypto_iov *data,
  1268. size_t num_data);
  1269. /**
  1270. * Compute a checksum (operates on opaque key).
  1271. *
  1272. * @param [in] context Library context
  1273. * @param [in] cksumtype Checksum type (0 for mandatory type)
  1274. * @param [in] key Encryption key for a keyed checksum
  1275. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1276. * @param [in] input Input data
  1277. * @param [out] cksum Generated checksum
  1278. *
  1279. * This function computes a checksum of type @a cksumtype over @a input, using
  1280. * @a key if the checksum type is a keyed checksum. If @a cksumtype is 0 and
  1281. * @a key is non-null, the checksum type will be the mandatory-to-implement
  1282. * checksum type for the key's encryption type. The actual checksum key will
  1283. * be derived from @a key and @a usage if key derivation is specified for the
  1284. * checksum type. The newly created @a cksum must be released by calling
  1285. * krb5_free_checksum_contents() when it is no longer needed.
  1286. *
  1287. * @note This function is similar to krb5_c_make_checksum(), but operates
  1288. * on opaque @a key.
  1289. *
  1290. * @sa krb5_c_verify_checksum()
  1291. *
  1292. * @retval 0 Success; otherwise - Kerberos error codes
  1293. */
  1294. krb5_error_code KRB5_CALLCONV
  1295. krb5_k_make_checksum(krb5_context context, krb5_cksumtype cksumtype,
  1296. krb5_key key, krb5_keyusage usage, const krb5_data *input,
  1297. krb5_checksum *cksum);
  1298. /**
  1299. * Fill in a checksum element in IOV array (operates on opaque key)
  1300. *
  1301. * @param [in] context Library context
  1302. * @param [in] cksumtype Checksum type (0 for mandatory type)
  1303. * @param [in] key Encryption key for a keyed checksum
  1304. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1305. * @param [in,out] data IOV array
  1306. * @param [in] num_data Size of @a data
  1307. *
  1308. * Create a checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element over
  1309. * #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY chunks in @a data.
  1310. * Only the #KRB5_CRYPTO_TYPE_CHECKSUM region is modified.
  1311. *
  1312. * @note This function is similar to krb5_c_make_checksum_iov(), but operates
  1313. * on opaque @a key.
  1314. *
  1315. * @sa krb5_k_verify_checksum_iov()
  1316. *
  1317. * @retval 0 Success; otherwise - Kerberos error codes
  1318. */
  1319. krb5_error_code KRB5_CALLCONV
  1320. krb5_k_make_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
  1321. krb5_key key, krb5_keyusage usage,
  1322. krb5_crypto_iov *data, size_t num_data);
  1323. /**
  1324. * Verify a checksum (operates on opaque key).
  1325. *
  1326. * @param [in] context Library context
  1327. * @param [in] key Encryption key for a keyed checksum
  1328. * @param [in] usage @a key usage
  1329. * @param [in] data Data to be used to compute a new checksum
  1330. * using @a key to compare @a cksum against
  1331. * @param [in] cksum Checksum to be verified
  1332. * @param [out] valid Non-zero for success, zero for failure
  1333. *
  1334. * This function verifies that @a cksum is a valid checksum for @a data. If
  1335. * the checksum type of @a cksum is a keyed checksum, @a key is used to verify
  1336. * the checksum. The actual checksum key will be derived from @a key and @a
  1337. * usage if key derivation is specified for the checksum type.
  1338. *
  1339. * @note This function is similar to krb5_c_verify_checksum(), but operates
  1340. * on opaque @a key.
  1341. *
  1342. * @retval 0 Success; otherwise - Kerberos error codes
  1343. */
  1344. krb5_error_code KRB5_CALLCONV
  1345. krb5_k_verify_checksum(krb5_context context, krb5_key key, krb5_keyusage usage,
  1346. const krb5_data *data, const krb5_checksum *cksum,
  1347. krb5_boolean *valid);
  1348. /**
  1349. * Validate a checksum element in IOV array (operates on opaque key).
  1350. *
  1351. * @param [in] context Library context
  1352. * @param [in] cksumtype Checksum type (0 for mandatory type)
  1353. * @param [in] key Encryption key for a keyed checksum
  1354. * @param [in] usage Key usage (see @ref KRB5_KEYUSAGE types)
  1355. * @param [in] data IOV array
  1356. * @param [in] num_data Size of @a data
  1357. * @param [out] valid Non-zero for success, zero for failure
  1358. *
  1359. * Confirm that the checksum in the #KRB5_CRYPTO_TYPE_CHECKSUM element is a
  1360. * valid checksum of the #KRB5_CRYPTO_TYPE_DATA and #KRB5_CRYPTO_TYPE_SIGN_ONLY
  1361. * regions in the iov.
  1362. *
  1363. * @note This function is similar to krb5_c_verify_checksum_iov(), but operates
  1364. * on opaque @a key.
  1365. *
  1366. * @sa krb5_k_make_checksum_iov()
  1367. *
  1368. * @retval 0 Success; otherwise - Kerberos error codes
  1369. */
  1370. krb5_error_code KRB5_CALLCONV
  1371. krb5_k_verify_checksum_iov(krb5_context context, krb5_cksumtype cksumtype,
  1372. krb5_key key, krb5_keyusage usage,
  1373. const krb5_crypto_iov *data, size_t num_data,
  1374. krb5_boolean *valid);
  1375. /**
  1376. * Generate enctype-specific pseudo-random bytes (operates on opaque key).
  1377. *
  1378. * @param [in] context Library context
  1379. * @param [in] key Key
  1380. * @param [in] input Input data
  1381. * @param [out] output Output data
  1382. *
  1383. * This function selects a pseudo-random function based on @a key and
  1384. * computes its value over @a input, placing the result into @a output.
  1385. * The caller must preinitialize @a output and allocate space for the
  1386. * result.
  1387. *
  1388. * @note This function is similar to krb5_c_prf(), but operates
  1389. * on opaque @a key.
  1390. *
  1391. * @retval 0 Success; otherwise - Kerberos error codes
  1392. */
  1393. krb5_error_code KRB5_CALLCONV
  1394. krb5_k_prf(krb5_context context, krb5_key key, krb5_data *input, krb5_data *output);
  1395. #ifdef KRB5_OLD_CRYPTO
  1396. /*
  1397. * old cryptosystem routine prototypes. These are now layered
  1398. * on top of the functions above.
  1399. */
  1400. /** @deprecated Replaced by krb5_c_ API family.*/
  1401. krb5_error_code KRB5_CALLCONV
  1402. krb5_encrypt(krb5_context context, krb5_const_pointer inptr,
  1403. krb5_pointer outptr, size_t size, krb5_encrypt_block *eblock,
  1404. krb5_pointer ivec);
  1405. /** @deprecated Replaced by krb5_c_ API family. */
  1406. krb5_error_code KRB5_CALLCONV
  1407. krb5_decrypt(krb5_context context, krb5_const_pointer inptr,
  1408. krb5_pointer outptr, size_t size, krb5_encrypt_block *eblock,
  1409. krb5_pointer ivec);
  1410. /** @deprecated Replaced by krb5_c_ API family. */
  1411. krb5_error_code KRB5_CALLCONV
  1412. krb5_process_key(krb5_context context, krb5_encrypt_block *eblock,
  1413. const krb5_keyblock * key);
  1414. /** @deprecated Replaced by krb5_c_ API family. */
  1415. krb5_error_code KRB5_CALLCONV
  1416. krb5_finish_key(krb5_context context, krb5_encrypt_block * eblock);
  1417. /** @deprecated See krb5_c_string_to_key() */
  1418. krb5_error_code KRB5_CALLCONV
  1419. krb5_string_to_key(krb5_context context, const krb5_encrypt_block *eblock,
  1420. krb5_keyblock * keyblock, const krb5_data *data,
  1421. const krb5_data *salt);
  1422. /** @deprecated Replaced by krb5_c_ API family. */
  1423. krb5_error_code KRB5_CALLCONV
  1424. krb5_init_random_key(krb5_context context, const krb5_encrypt_block *eblock,
  1425. const krb5_keyblock *keyblock, krb5_pointer *ptr);
  1426. /** @deprecated Replaced by krb5_c_ API family. */
  1427. krb5_error_code KRB5_CALLCONV
  1428. krb5_finish_random_key(krb5_context context, const krb5_encrypt_block *eblock,
  1429. krb5_pointer *ptr);
  1430. /** @deprecated Replaced by krb5_c_ API family. */
  1431. krb5_error_code KRB5_CALLCONV
  1432. krb5_random_key(krb5_context context, const krb5_encrypt_block *eblock,
  1433. krb5_pointer ptr, krb5_keyblock **keyblock);
  1434. /** @deprecated Replaced by krb5_c_ API family. */
  1435. krb5_enctype KRB5_CALLCONV
  1436. krb5_eblock_enctype(krb5_context context, const krb5_encrypt_block *eblock);
  1437. /** @deprecated Replaced by krb5_c_ API family. */
  1438. krb5_error_code KRB5_CALLCONV
  1439. krb5_use_enctype(krb5_context context, krb5_encrypt_block *eblock,
  1440. krb5_enctype enctype);
  1441. /** @deprecated Replaced by krb5_c_ API family. */
  1442. size_t KRB5_CALLCONV
  1443. krb5_encrypt_size(size_t length, krb5_enctype crypto);
  1444. /** @deprecated See krb5_c_checksum_length() */
  1445. size_t KRB5_CALLCONV
  1446. krb5_checksum_size(krb5_context context, krb5_cksumtype ctype);
  1447. /** @deprecated See krb5_c_make_checksum() */
  1448. krb5_error_code KRB5_CALLCONV
  1449. krb5_calculate_checksum(krb5_context context, krb5_cksumtype ctype,
  1450. krb5_const_pointer in, size_t in_length,
  1451. krb5_const_pointer seed, size_t seed_length,
  1452. krb5_checksum * outcksum);
  1453. /** @deprecated See krb5_c_verify_checksum() */
  1454. krb5_error_code KRB5_CALLCONV
  1455. krb5_verify_checksum(krb5_context context, krb5_cksumtype ctype,
  1456. const krb5_checksum * cksum, krb5_const_pointer in,
  1457. size_t in_length, krb5_const_pointer seed,
  1458. size_t seed_length);
  1459. #endif /* KRB5_OLD_CRYPTO */
  1460. /*
  1461. * end "encryption.h"
  1462. */
  1463. /*
  1464. * begin "fieldbits.h"
  1465. */
  1466. /* kdc_options for kdc_request */
  1467. /* options is 32 bits; each host is responsible to put the 4 bytes
  1468. representing these bits into net order before transmission */
  1469. /* #define KDC_OPT_RESERVED 0x80000000 */
  1470. #define KDC_OPT_FORWARDABLE 0x40000000
  1471. #define KDC_OPT_FORWARDED 0x20000000
  1472. #define KDC_OPT_PROXIABLE 0x10000000
  1473. #define KDC_OPT_PROXY 0x08000000
  1474. #define KDC_OPT_ALLOW_POSTDATE 0x04000000
  1475. #define KDC_OPT_POSTDATED 0x02000000
  1476. /* #define KDC_OPT_UNUSED 0x01000000 */
  1477. #define KDC_OPT_RENEWABLE 0x00800000
  1478. /* #define KDC_OPT_UNUSED 0x00400000 */
  1479. /* #define KDC_OPT_RESERVED 0x00200000 */
  1480. /* #define KDC_OPT_RESERVED 0x00100000 */
  1481. /* #define KDC_OPT_RESERVED 0x00080000 */
  1482. /* #define KDC_OPT_RESERVED 0x00040000 */
  1483. #define KDC_OPT_CNAME_IN_ADDL_TKT 0x00020000
  1484. #define KDC_OPT_CANONICALIZE 0x00010000
  1485. #define KDC_OPT_REQUEST_ANONYMOUS 0x00008000
  1486. /* #define KDC_OPT_RESERVED 0x00004000 */
  1487. /* #define KDC_OPT_RESERVED 0x00002000 */
  1488. /* #define KDC_OPT_RESERVED 0x00001000 */
  1489. /* #define KDC_OPT_RESERVED 0x00000800 */
  1490. /* #define KDC_OPT_RESERVED 0x00000400 */
  1491. /* #define KDC_OPT_RESERVED 0x00000200 */
  1492. /* #define KDC_OPT_RESERVED 0x00000100 */
  1493. /* #define KDC_OPT_RESERVED 0x00000080 */
  1494. /* #define KDC_OPT_RESERVED 0x00000040 */
  1495. #define KDC_OPT_DISABLE_TRANSITED_CHECK 0x00000020
  1496. #define KDC_OPT_RENEWABLE_OK 0x00000010
  1497. #define KDC_OPT_ENC_TKT_IN_SKEY 0x00000008
  1498. /* #define KDC_OPT_UNUSED 0x00000004 */
  1499. #define KDC_OPT_RENEW 0x00000002
  1500. #define KDC_OPT_VALIDATE 0x00000001
  1501. /*
  1502. * Mask of ticket flags in the TGT which should be converted into KDC
  1503. * options when using the TGT to get derivitive tickets.
  1504. *
  1505. * New mask = KDC_OPT_FORWARDABLE | KDC_OPT_PROXIABLE |
  1506. * KDC_OPT_ALLOW_POSTDATE | KDC_OPT_RENEWABLE
  1507. */
  1508. #define KDC_TKT_COMMON_MASK 0x54800000
  1509. /* definitions for ap_options fields */
  1510. /** @defgroup AP_OPTS AP_OPTS
  1511. *
  1512. * ap_options are 32 bits; each host is responsible to put the 4 bytes
  1513. * representing these bits into net order before transmission
  1514. * @{
  1515. */
  1516. #define AP_OPTS_RESERVED 0x80000000
  1517. #define AP_OPTS_USE_SESSION_KEY 0x40000000 /**< Use session key */
  1518. #define AP_OPTS_MUTUAL_REQUIRED 0x20000000 /**< Perform a mutual
  1519. authentication exchange */
  1520. #define AP_OPTS_ETYPE_NEGOTIATION 0x00000002
  1521. #define AP_OPTS_USE_SUBKEY 0x00000001 /**< Generate a subsession key
  1522. from the current session key
  1523. obtained from the
  1524. credentials */
  1525. /* #define AP_OPTS_RESERVED 0x10000000 */
  1526. /* #define AP_OPTS_RESERVED 0x08000000 */
  1527. /* #define AP_OPTS_RESERVED 0x04000000 */
  1528. /* #define AP_OPTS_RESERVED 0x02000000 */
  1529. /* #define AP_OPTS_RESERVED 0x01000000 */
  1530. /* #define AP_OPTS_RESERVED 0x00800000 */
  1531. /* #define AP_OPTS_RESERVED 0x00400000 */
  1532. /* #define AP_OPTS_RESERVED 0x00200000 */
  1533. /* #define AP_OPTS_RESERVED 0x00100000 */
  1534. /* #define AP_OPTS_RESERVED 0x00080000 */
  1535. /* #define AP_OPTS_RESERVED 0x00040000 */
  1536. /* #define AP_OPTS_RESERVED 0x00020000 */
  1537. /* #define AP_OPTS_RESERVED 0x00010000 */
  1538. /* #define AP_OPTS_RESERVED 0x00008000 */
  1539. /* #define AP_OPTS_RESERVED 0x00004000 */
  1540. /* #define AP_OPTS_RESERVED 0x00002000 */
  1541. /* #define AP_OPTS_RESERVED 0x00001000 */
  1542. /* #define AP_OPTS_RESERVED 0x00000800 */
  1543. /* #define AP_OPTS_RESERVED 0x00000400 */
  1544. /* #define AP_OPTS_RESERVED 0x00000200 */
  1545. /* #define AP_OPTS_RESERVED 0x00000100 */
  1546. /* #define AP_OPTS_RESERVED 0x00000080 */
  1547. /* #define AP_OPTS_RESERVED 0x00000040 */
  1548. /* #define AP_OPTS_RESERVED 0x00000020 */
  1549. /* #define AP_OPTS_RESERVED 0x00000010 */
  1550. /* #define AP_OPTS_RESERVED 0x00000008 */
  1551. /* #define AP_OPTS_RESERVED 0x00000004 */
  1552. #define AP_OPTS_WIRE_MASK 0xfffffff0
  1553. /** @} */ /* end of AP_OPTS group */
  1554. /* definitions for ad_type fields. */
  1555. #define AD_TYPE_RESERVED 0x8000
  1556. #define AD_TYPE_EXTERNAL 0x4000
  1557. #define AD_TYPE_REGISTERED 0x2000
  1558. #define AD_TYPE_FIELD_TYPE_MASK 0x1fff
  1559. /* Ticket flags */
  1560. /* flags are 32 bits; each host is responsible to put the 4 bytes
  1561. representing these bits into net order before transmission */
  1562. /* #define TKT_FLG_RESERVED 0x80000000 */
  1563. #define TKT_FLG_FORWARDABLE 0x40000000
  1564. #define TKT_FLG_FORWARDED 0x20000000
  1565. #define TKT_FLG_PROXIABLE 0x10000000
  1566. #define TKT_FLG_PROXY 0x08000000
  1567. #define TKT_FLG_MAY_POSTDATE 0x04000000
  1568. #define TKT_FLG_POSTDATED 0x02000000
  1569. #define TKT_FLG_INVALID 0x01000000
  1570. #define TKT_FLG_RENEWABLE 0x00800000
  1571. #define TKT_FLG_INITIAL 0x00400000
  1572. #define TKT_FLG_PRE_AUTH 0x00200000
  1573. #define TKT_FLG_HW_AUTH 0x00100000
  1574. #define TKT_FLG_TRANSIT_POLICY_CHECKED 0x00080000
  1575. #define TKT_FLG_OK_AS_DELEGATE 0x00040000
  1576. #define TKT_FLG_ENC_PA_REP 0x00010000
  1577. #define TKT_FLG_ANONYMOUS 0x00008000
  1578. /* #define TKT_FLG_RESERVED 0x00004000 */
  1579. /* #define TKT_FLG_RESERVED 0x00002000 */
  1580. /* #define TKT_FLG_RESERVED 0x00001000 */
  1581. /* #define TKT_FLG_RESERVED 0x00000800 */
  1582. /* #define TKT_FLG_RESERVED 0x00000400 */
  1583. /* #define TKT_FLG_RESERVED 0x00000200 */
  1584. /* #define TKT_FLG_RESERVED 0x00000100 */
  1585. /* #define TKT_FLG_RESERVED 0x00000080 */
  1586. /* #define TKT_FLG_RESERVED 0x00000040 */
  1587. /* #define TKT_FLG_RESERVED 0x00000020 */
  1588. /* #define TKT_FLG_RESERVED 0x00000010 */
  1589. /* #define TKT_FLG_RESERVED 0x00000008 */
  1590. /* #define TKT_FLG_RESERVED 0x00000004 */
  1591. /* #define TKT_FLG_RESERVED 0x00000002 */
  1592. /* #define TKT_FLG_RESERVED 0x00000001 */
  1593. /* definitions for lr_type fields. */
  1594. #define LR_TYPE_THIS_SERVER_ONLY 0x8000
  1595. #define LR_TYPE_INTERPRETATION_MASK 0x7fff
  1596. /* definitions for msec direction bit for KRB_SAFE, KRB_PRIV */
  1597. #define MSEC_DIRBIT 0x8000
  1598. #define MSEC_VAL_MASK 0x7fff
  1599. /*
  1600. * end "fieldbits.h"
  1601. */
  1602. /*
  1603. * begin "proto.h"
  1604. */
  1605. /** Protocol version number */
  1606. #define KRB5_PVNO 5
  1607. /* Message types */
  1608. #define KRB5_AS_REQ ((krb5_msgtype)10) /**< Initial authentication request */
  1609. #define KRB5_AS_REP ((krb5_msgtype)11) /**< Response to AS request */
  1610. #define KRB5_TGS_REQ ((krb5_msgtype)12) /**< Ticket granting server request */
  1611. #define KRB5_TGS_REP ((krb5_msgtype)13) /**< Response to TGS request */
  1612. #define KRB5_AP_REQ ((krb5_msgtype)14) /**< Auth req to application server */
  1613. #define KRB5_AP_REP ((krb5_msgtype)15) /**< Response to mutual AP request */
  1614. #define KRB5_SAFE ((krb5_msgtype)20) /**< Safe application message */
  1615. #define KRB5_PRIV ((krb5_msgtype)21) /**< Private application message */
  1616. #define KRB5_CRED ((krb5_msgtype)22) /**< Cred forwarding message */
  1617. #define KRB5_ERROR ((krb5_msgtype)30) /**< Error response */
  1618. /* LastReq types */
  1619. #define KRB5_LRQ_NONE 0
  1620. #define KRB5_LRQ_ALL_LAST_TGT 1
  1621. #define KRB5_LRQ_ONE_LAST_TGT (-1)
  1622. #define KRB5_LRQ_ALL_LAST_INITIAL 2
  1623. #define KRB5_LRQ_ONE_LAST_INITIAL (-2)
  1624. #define KRB5_LRQ_ALL_LAST_TGT_ISSUED 3
  1625. #define KRB5_LRQ_ONE_LAST_TGT_ISSUED (-3)
  1626. #define KRB5_LRQ_ALL_LAST_RENEWAL 4
  1627. #define KRB5_LRQ_ONE_LAST_RENEWAL (-4)
  1628. #define KRB5_LRQ_ALL_LAST_REQ 5
  1629. #define KRB5_LRQ_ONE_LAST_REQ (-5)
  1630. #define KRB5_LRQ_ALL_PW_EXPTIME 6
  1631. #define KRB5_LRQ_ONE_PW_EXPTIME (-6)
  1632. #define KRB5_LRQ_ALL_ACCT_EXPTIME 7
  1633. #define KRB5_LRQ_ONE_ACCT_EXPTIME (-7)
  1634. /* PADATA types */
  1635. #define KRB5_PADATA_NONE 0
  1636. #define KRB5_PADATA_AP_REQ 1
  1637. #define KRB5_PADATA_TGS_REQ KRB5_PADATA_AP_REQ
  1638. #define KRB5_PADATA_ENC_TIMESTAMP 2
  1639. #define KRB5_PADATA_PW_SALT 3
  1640. #if 0 /* Not used */
  1641. #define KRB5_PADATA_ENC_ENCKEY 4 /* Key encrypted within itself */
  1642. #endif
  1643. #define KRB5_PADATA_ENC_UNIX_TIME 5 /**< timestamp encrypted in key */
  1644. #define KRB5_PADATA_ENC_SANDIA_SECURID 6 /**< SecurId passcode */
  1645. #define KRB5_PADATA_SESAME 7 /**< Sesame project */
  1646. #define KRB5_PADATA_OSF_DCE 8 /**< OSF DCE */
  1647. #define KRB5_CYBERSAFE_SECUREID 9 /**< Cybersafe */
  1648. #define KRB5_PADATA_AFS3_SALT 10 /**< Cygnus */
  1649. #define KRB5_PADATA_ETYPE_INFO 11 /**< Etype info for preauth */
  1650. #define KRB5_PADATA_SAM_CHALLENGE 12 /**< draft challenge system */
  1651. #define KRB5_PADATA_SAM_RESPONSE 13 /**< draft challenge system response */
  1652. #define KRB5_PADATA_PK_AS_REQ_OLD 14 /**< PKINIT */
  1653. #define KRB5_PADATA_PK_AS_REP_OLD 15 /**< PKINIT */
  1654. #define KRB5_PADATA_PK_AS_REQ 16 /**< PKINIT */
  1655. #define KRB5_PADATA_PK_AS_REP 17 /**< PKINIT */
  1656. #define KRB5_PADATA_ETYPE_INFO2 19
  1657. #define KRB5_PADATA_USE_SPECIFIED_KVNO 20
  1658. #define KRB5_PADATA_SVR_REFERRAL_INFO 20 /**< Windows 2000 referrals */
  1659. #define KRB5_PADATA_SAM_REDIRECT 21
  1660. #define KRB5_PADATA_GET_FROM_TYPED_DATA 22
  1661. #define KRB5_PADATA_REFERRAL 25 /**< draft referral system */
  1662. #define KRB5_PADATA_SAM_CHALLENGE_2 30 /**< draft challenge system, updated */
  1663. #define KRB5_PADATA_SAM_RESPONSE_2 31 /**< draft challenge system, updated */
  1664. #define KRB5_PADATA_PAC_REQUEST 128 /**< include Windows PAC */
  1665. #define KRB5_PADATA_FOR_USER 129 /**< username protocol transition request */
  1666. #define KRB5_PADATA_S4U_X509_USER 130 /**< certificate protocol transition request */
  1667. #define KRB5_PADATA_FX_COOKIE 133
  1668. #define KRB5_PADATA_FX_FAST 136
  1669. #define KRB5_PADATA_FX_ERROR 137
  1670. #define KRB5_PADATA_ENCRYPTED_CHALLENGE 138
  1671. #define KRB5_PADATA_PKINIT_KX 147
  1672. #define KRB5_ENCPADATA_REQ_ENC_PA_REP 149
  1673. #define KRB5_SAM_USE_SAD_AS_KEY 0x80000000
  1674. #define KRB5_SAM_SEND_ENCRYPTED_SAD 0x40000000
  1675. #define KRB5_SAM_MUST_PK_ENCRYPT_SAD 0x20000000 /* currently must be zero */
  1676. /** Transited encoding types */
  1677. #define KRB5_DOMAIN_X500_COMPRESS 1
  1678. /** alternate authentication types */
  1679. #define KRB5_ALTAUTH_ATT_CHALLENGE_RESPONSE 64
  1680. /* authorization data types. See RFC 4120 section 5.2.6 */
  1681. /** @defgroup KRB5_AUTHDATA KRB5_AUTHDATA
  1682. * @{
  1683. */
  1684. #define KRB5_AUTHDATA_IF_RELEVANT 1
  1685. #define KRB5_AUTHDATA_KDC_ISSUED 4
  1686. #define KRB5_AUTHDATA_AND_OR 5
  1687. #define KRB5_AUTHDATA_MANDATORY_FOR_KDC 8
  1688. #define KRB5_AUTHDATA_INITIAL_VERIFIED_CAS 9
  1689. #define KRB5_AUTHDATA_OSF_DCE 64
  1690. #define KRB5_AUTHDATA_SESAME 65
  1691. #define KRB5_AUTHDATA_WIN2K_PAC 128
  1692. #define KRB5_AUTHDATA_ETYPE_NEGOTIATION 129 /* RFC 4537 */
  1693. #define KRB5_AUTHDATA_SIGNTICKET 512 /**< formerly 142 in krb5 1.8 */
  1694. #define KRB5_AUTHDATA_FX_ARMOR 71
  1695. /** @} */ /* end of KRB5_AUTHDATA group */
  1696. /* password change constants */
  1697. #define KRB5_KPASSWD_SUCCESS 0
  1698. #define KRB5_KPASSWD_MALFORMED 1
  1699. #define KRB5_KPASSWD_HARDERROR 2
  1700. #define KRB5_KPASSWD_AUTHERROR 3
  1701. #define KRB5_KPASSWD_SOFTERROR 4
  1702. /* These are Microsoft's extensions in RFC 3244, and it looks like
  1703. they'll become standardized, possibly with other additions. */
  1704. #define KRB5_KPASSWD_ACCESSDENIED 5 /* unused */
  1705. #define KRB5_KPASSWD_BAD_VERSION 6
  1706. #define KRB5_KPASSWD_INITIAL_FLAG_NEEDED 7 /* unused */
  1707. /*
  1708. * end "proto.h"
  1709. */
  1710. /* Time set */
  1711. /** Ticket start time, end time, and renewal duration. */
  1712. typedef struct _krb5_ticket_times {
  1713. krb5_timestamp authtime; /**< Time at which KDC issued the initial ticket that corresponds to this ticket */
  1714. /* XXX ? should ktime in KDC_REP == authtime
  1715. in ticket? otherwise client can't get this */
  1716. krb5_timestamp starttime; /**< optional in ticket, if not present, use @a authtime */
  1717. krb5_timestamp endtime; /**< Ticket expiration time */
  1718. krb5_timestamp renew_till; /**< Latest time at which renewal of ticket can be valid */
  1719. } krb5_ticket_times;
  1720. /** Structure for auth data */
  1721. typedef struct _krb5_authdata {
  1722. krb5_magic magic;
  1723. krb5_authdatatype ad_type; /**< ADTYPE */
  1724. unsigned int length; /**< Length of data */
  1725. krb5_octet *contents; /**< Data */
  1726. } krb5_authdata;
  1727. /** Structure for transited encoding */
  1728. typedef struct _krb5_transited {
  1729. krb5_magic magic;
  1730. krb5_octet tr_type; /**< Transited encoding type */
  1731. krb5_data tr_contents; /**< Contents */
  1732. } krb5_transited;
  1733. /** Encrypted part of ticket. */
  1734. typedef struct _krb5_enc_tkt_part {
  1735. krb5_magic magic;
  1736. /* to-be-encrypted portion */
  1737. krb5_flags flags; /**< flags */
  1738. krb5_keyblock *session; /**< session key: includes enctype */
  1739. krb5_principal client; /**< client name/realm */
  1740. krb5_transited transited; /**< list of transited realms */
  1741. krb5_ticket_times times; /**< auth, start, end, renew_till */
  1742. krb5_address **caddrs; /**< array of ptrs to addresses */
  1743. krb5_authdata **authorization_data; /**< auth data */
  1744. } krb5_enc_tkt_part;
  1745. /**
  1746. * Ticket structure.
  1747. *
  1748. * The C representation of the ticket message, with a pointer to the
  1749. * C representation of the encrypted part.
  1750. */
  1751. typedef struct _krb5_ticket {
  1752. krb5_magic magic;
  1753. /* cleartext portion */
  1754. krb5_principal server; /**< server name/realm */
  1755. krb5_enc_data enc_part; /**< encryption type, kvno, encrypted encoding */
  1756. krb5_enc_tkt_part *enc_part2; /**< ptr to decrypted version, if available */
  1757. } krb5_ticket;
  1758. /* the unencrypted version */
  1759. /**
  1760. * Ticket authenticator.
  1761. *
  1762. * The C representation of an unencrypted authenticator.
  1763. */
  1764. typedef struct _krb5_authenticator {
  1765. krb5_magic magic;
  1766. krb5_principal client; /**< client name/realm */
  1767. krb5_checksum *checksum; /**< checksum, includes type, optional */
  1768. krb5_int32 cusec; /**< client usec portion */
  1769. krb5_timestamp ctime; /**< client sec portion */
  1770. krb5_keyblock *subkey; /**< true session key, optional */
  1771. krb5_ui_4 seq_number; /**< sequence #, optional */
  1772. krb5_authdata **authorization_data; /**< authoriazation data */
  1773. } krb5_authenticator;
  1774. /** Ticket authentication data. */
  1775. typedef struct _krb5_tkt_authent {
  1776. krb5_magic magic;
  1777. krb5_ticket *ticket;
  1778. krb5_authenticator *authenticator;
  1779. krb5_flags ap_options;
  1780. } krb5_tkt_authent;
  1781. /** Credentials structure including ticket, session key, and lifetime info. */
  1782. typedef struct _krb5_creds {
  1783. krb5_magic magic;
  1784. krb5_principal client; /**< client's principal identifier */
  1785. krb5_principal server; /**< server's principal identifier */
  1786. krb5_keyblock keyblock; /**< session encryption key info */
  1787. krb5_ticket_times times; /**< lifetime info */
  1788. krb5_boolean is_skey; /**< true if ticket is encrypted in
  1789. another ticket's skey */
  1790. krb5_flags ticket_flags; /**< flags in ticket */
  1791. krb5_address **addresses; /**< addrs in ticket */
  1792. krb5_data ticket; /**< ticket string itself */
  1793. krb5_data second_ticket; /**< second ticket, if related to
  1794. ticket (via DUPLICATE-SKEY or
  1795. ENC-TKT-IN-SKEY) */
  1796. krb5_authdata **authdata; /**< authorization data */
  1797. } krb5_creds;
  1798. /** Last request entry */
  1799. typedef struct _krb5_last_req_entry {
  1800. krb5_magic magic;
  1801. krb5_int32 lr_type; /**< LR type */
  1802. krb5_timestamp value; /**< Timestamp */
  1803. } krb5_last_req_entry;
  1804. /** Pre-authentication data */
  1805. typedef struct _krb5_pa_data {
  1806. krb5_magic magic;
  1807. krb5_preauthtype pa_type; /**< Preauthentication data type */
  1808. unsigned int length; /**< Length of data */
  1809. krb5_octet *contents; /**< Data */
  1810. } krb5_pa_data;
  1811. /*
  1812. * The FAST error handling logic currently assumes that pointers to this
  1813. * structure and krb5_pa_data can be safely cast to each other. If this
  1814. * structure changes, that code needs to be updated to copy.
  1815. */
  1816. /** Typed data */
  1817. typedef struct _krb5_typed_data {
  1818. krb5_magic magic;
  1819. krb5_int32 type;
  1820. unsigned int length;
  1821. krb5_octet *data;
  1822. } krb5_typed_data;
  1823. /** C representation of KDC-REQ protocol message, including KDC-REQ-BODY */
  1824. typedef struct _krb5_kdc_req {
  1825. krb5_magic magic;
  1826. krb5_msgtype msg_type; /**< KRB5_AS_REQ or KRB5_TGS_REQ */
  1827. krb5_pa_data **padata; /**< Preauthentication data */
  1828. /* real body */
  1829. krb5_flags kdc_options; /**< Requested options */
  1830. krb5_principal client; /**< Client principal and realm */
  1831. krb5_principal server; /**< Server principal and realm */
  1832. krb5_timestamp from; /**< Requested start time */
  1833. krb5_timestamp till; /**< Requested end time */
  1834. krb5_timestamp rtime; /**< Requested renewable end time */
  1835. krb5_int32 nonce; /**< Nonce to match request andresponse */
  1836. int nktypes; /**< Number of enctypes */
  1837. krb5_enctype *ktype; /**< Requested enctypes */
  1838. krb5_address **addresses; /**< Requested addresses (optional) */
  1839. krb5_enc_data authorization_data; /**< Encrypted authz data (optional) */
  1840. krb5_authdata **unenc_authdata; /**< Unencrypted authz data */
  1841. krb5_ticket **second_ticket; /**< Second ticket array (optional) */
  1842. } krb5_kdc_req;
  1843. /**
  1844. * C representation of @c EncKDCRepPart protocol message.
  1845. *
  1846. * This is the cleartext message that is encrypted and inserted in @c KDC-REP.
  1847. */
  1848. typedef struct _krb5_enc_kdc_rep_part {
  1849. krb5_magic magic;
  1850. /* encrypted part: */
  1851. krb5_msgtype msg_type; /**< krb5 message type */
  1852. krb5_keyblock *session; /**< Session key */
  1853. krb5_last_req_entry **last_req; /**< Array of pointers to entries */
  1854. krb5_int32 nonce; /**< Nonce from request */
  1855. krb5_timestamp key_exp; /**< Expiration date */
  1856. krb5_flags flags; /**< Ticket flags */
  1857. krb5_ticket_times times; /**< Lifetime info */
  1858. krb5_principal server; /**< Server's principal identifier */
  1859. krb5_address **caddrs; /**< Array of ptrs to addrs, optional */
  1860. krb5_pa_data **enc_padata; /**< Encrypted preauthentication data */
  1861. } krb5_enc_kdc_rep_part;
  1862. /** Representation of the @c KDC-REP protocol message. */
  1863. typedef struct _krb5_kdc_rep {
  1864. krb5_magic magic;
  1865. /* cleartext part: */
  1866. krb5_msgtype msg_type; /**< KRB5_AS_REP or KRB5_KDC_REP */
  1867. krb5_pa_data **padata; /**< Preauthentication data from KDC */
  1868. krb5_principal client; /**< Client principal and realm */
  1869. krb5_ticket *ticket; /**< Ticket */
  1870. krb5_enc_data enc_part; /**< Encrypted part of reply */
  1871. krb5_enc_kdc_rep_part *enc_part2; /**< Unencrypted version, if available */
  1872. } krb5_kdc_rep;
  1873. /** Error message structure */
  1874. typedef struct _krb5_error {
  1875. krb5_magic magic;
  1876. /* some of these may be meaningless in certain contexts */
  1877. krb5_timestamp ctime; /**< Client sec portion; optional */
  1878. krb5_int32 cusec; /**< Client usec portion; optional */
  1879. krb5_int32 susec; /**< Server usec portion */
  1880. krb5_timestamp stime; /**< Server sec portion */
  1881. krb5_ui_4 error; /**< Error code (protocol error #'s) */
  1882. krb5_principal client; /**< Client principal and realm */
  1883. krb5_principal server; /**< Server principal and realm */
  1884. krb5_data text; /**< Descriptive text */
  1885. krb5_data e_data; /**< Additional error-describing data */
  1886. } krb5_error;
  1887. /** Authentication header. */
  1888. typedef struct _krb5_ap_req {
  1889. krb5_magic magic;
  1890. krb5_flags ap_options; /**< Requested options */
  1891. krb5_ticket *ticket; /**< Ticket */
  1892. krb5_enc_data authenticator; /**< Encrypted authenticator */
  1893. } krb5_ap_req;
  1894. /**
  1895. * C representaton of AP-REP message.
  1896. *
  1897. * The server's response to a client's request for mutual authentication.
  1898. */
  1899. typedef struct _krb5_ap_rep {
  1900. krb5_magic magic;
  1901. krb5_enc_data enc_part; /**< Ciphertext of ApRepEncPart */
  1902. } krb5_ap_rep;
  1903. /** Cleartext that is encrypted and put into @c _krb5_ap_rep. */
  1904. typedef struct _krb5_ap_rep_enc_part {
  1905. krb5_magic magic;
  1906. krb5_timestamp ctime; /**< Client time, seconds portion */
  1907. krb5_int32 cusec; /**< Client time, microseconds portion */
  1908. krb5_keyblock *subkey; /**< Subkey (optional) */
  1909. krb5_ui_4 seq_number; /**< Sequence number */
  1910. } krb5_ap_rep_enc_part;
  1911. /* Unused */
  1912. typedef struct _krb5_response {
  1913. krb5_magic magic;
  1914. krb5_octet message_type;
  1915. krb5_data response;
  1916. krb5_int32 expected_nonce;
  1917. krb5_timestamp request_time;
  1918. } krb5_response;
  1919. /** Credentials information inserted into @c EncKrbCredPart. */
  1920. typedef struct _krb5_cred_info {
  1921. krb5_magic magic;
  1922. krb5_keyblock *session; /**< Session key used to encrypt ticket */
  1923. krb5_principal client; /**< Client principal and realm */
  1924. krb5_principal server; /**< Server principal and realm */
  1925. krb5_flags flags; /**< Ticket flags */
  1926. krb5_ticket_times times; /**< Auth, start, end, renew_till */
  1927. krb5_address **caddrs; /**< Array of pointers to addrs (optional) */
  1928. } krb5_cred_info;
  1929. /** Cleartext credentials information. */
  1930. typedef struct _krb5_cred_enc_part {
  1931. krb5_magic magic;
  1932. krb5_int32 nonce; /**< Nonce (optional) */
  1933. krb5_timestamp timestamp; /**< Generation time, seconds portion */
  1934. krb5_int32 usec; /**< Generation time, microseconds portion */
  1935. krb5_address *s_address; /**< Sender address (optional) */
  1936. krb5_address *r_address; /**< Recipient address (optional) */
  1937. krb5_cred_info **ticket_info;
  1938. } krb5_cred_enc_part;
  1939. /** Credentials data structure.*/
  1940. typedef struct _krb5_cred {
  1941. krb5_magic magic;
  1942. krb5_ticket **tickets; /**< Tickets */
  1943. krb5_enc_data enc_part; /**< Encrypted part */
  1944. krb5_cred_enc_part *enc_part2; /**< Unencrypted version, if available */
  1945. } krb5_cred;
  1946. /*
  1947. * Sandia password generation structure
  1948. * Used by internal functions only
  1949. */
  1950. typedef struct _passwd_phrase_element {
  1951. krb5_magic magic;
  1952. krb5_data *passwd;
  1953. krb5_data *phrase;
  1954. } passwd_phrase_element;
  1955. /*
  1956. * Password data.
  1957. * Used by internal functions only
  1958. */
  1959. typedef struct _krb5_pwd_data {
  1960. krb5_magic magic;
  1961. int sequence_count;
  1962. passwd_phrase_element **element;
  1963. } krb5_pwd_data;
  1964. /* these need to be here so the typedefs are available for the prototypes */
  1965. /*
  1966. * Note for Windows 2000 compatibility this is encoded
  1967. * in the enc_padata field of the krb5_enc_kdc_rep_part.
  1968. */
  1969. typedef struct _krb5_pa_svr_referral_data {
  1970. /** Referred name, only realm is required */
  1971. krb5_principal principal;
  1972. } krb5_pa_svr_referral_data;
  1973. typedef struct _krb5_pa_server_referral_data {
  1974. krb5_data *referred_realm;
  1975. krb5_principal true_principal_name;
  1976. krb5_principal requested_principal_name;
  1977. krb5_timestamp referral_valid_until;
  1978. krb5_checksum rep_cksum;
  1979. } krb5_pa_server_referral_data;
  1980. typedef struct _krb5_pa_pac_req {
  1981. /** TRUE if a PAC should be included in TGS-REP */
  1982. krb5_boolean include_pac;
  1983. } krb5_pa_pac_req;
  1984. /*
  1985. * begin "safepriv.h"
  1986. */
  1987. /** @defgroup KRB5_AUTH_CONTEXT KRB5_AUTH_CONTEXT
  1988. * @{
  1989. */
  1990. #define KRB5_AUTH_CONTEXT_DO_TIME 0x00000001 /**< set timestamp in the message */
  1991. #define KRB5_AUTH_CONTEXT_RET_TIME 0x00000002
  1992. #define KRB5_AUTH_CONTEXT_DO_SEQUENCE 0x00000004 /**< set sequence number in the message */
  1993. #define KRB5_AUTH_CONTEXT_RET_SEQUENCE 0x00000008
  1994. #define KRB5_AUTH_CONTEXT_PERMIT_ALL 0x00000010
  1995. #define KRB5_AUTH_CONTEXT_USE_SUBKEY 0x00000020
  1996. /** @} */ /* end of KRB5_AUTH_CONTEXT group */
  1997. /**
  1998. * Replay data.
  1999. *
  2000. * Sequence number and timestamp information output by krb5_rd_priv() and
  2001. * krb5_rd_safe().
  2002. */
  2003. typedef struct krb5_replay_data {
  2004. krb5_timestamp timestamp; /**< Timestamp, seconds portion */
  2005. krb5_int32 usec; /**< Timestamp, microseconds portion */
  2006. krb5_ui_4 seq; /**< Sequence number */
  2007. } krb5_replay_data;
  2008. /* Flags for krb5_auth_con_genaddrs(). */
  2009. /** Generate the local network address. */
  2010. #define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR 0x00000001
  2011. /** Generate the remote network address. */
  2012. #define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR 0x00000002
  2013. /** Generate the local network address and the local port. */
  2014. #define KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR 0x00000004
  2015. /** Generate the remote network address and the remote port. */
  2016. #define KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR 0x00000008
  2017. /** Type of function used as a callback to generate checksum data for mk_req */
  2018. typedef krb5_error_code
  2019. (KRB5_CALLCONV * krb5_mk_req_checksum_func)(krb5_context, krb5_auth_context,
  2020. void *, krb5_data **);
  2021. /*
  2022. * end "safepriv.h"
  2023. */
  2024. /*
  2025. * begin "ccache.h"
  2026. */
  2027. /** Cursor for sequential lookup */
  2028. typedef krb5_pointer krb5_cc_cursor;
  2029. struct _krb5_ccache;
  2030. typedef struct _krb5_ccache *krb5_ccache;
  2031. struct _krb5_cc_ops;
  2032. typedef struct _krb5_cc_ops krb5_cc_ops;
  2033. struct _krb5_cccol_cursor;
  2034. /** Cursor for iterating over all ccaches */
  2035. typedef struct _krb5_cccol_cursor *krb5_cccol_cursor;
  2036. /* Flags for krb5_cc_retrieve_cred. */
  2037. /** The requested lifetime must be at least as great as the time specified. */
  2038. #define KRB5_TC_MATCH_TIMES 0x00000001
  2039. /** The is_skey field must match exactly. */
  2040. #define KRB5_TC_MATCH_IS_SKEY 0x00000002
  2041. /** All the flags set in the match credentials must be set. */
  2042. #define KRB5_TC_MATCH_FLAGS 0x00000004
  2043. /** All the time fields must match exactly. */
  2044. #define KRB5_TC_MATCH_TIMES_EXACT 0x00000008
  2045. /** All the flags must match exactly. */
  2046. #define KRB5_TC_MATCH_FLAGS_EXACT 0x00000010
  2047. /** The authorization data must match. */
  2048. #define KRB5_TC_MATCH_AUTHDATA 0x00000020
  2049. /** Only the name portion of the principal name must match. */
  2050. #define KRB5_TC_MATCH_SRV_NAMEONLY 0x00000040
  2051. /** The second ticket must match. */
  2052. #define KRB5_TC_MATCH_2ND_TKT 0x00000080
  2053. /** The encryption key type must match. */
  2054. #define KRB5_TC_MATCH_KTYPE 0x00000100
  2055. /** The supported key types must match. */
  2056. #define KRB5_TC_SUPPORTED_KTYPES 0x00000200
  2057. /* Flags for krb5_cc_set_flags and similar. */
  2058. /** Open and close the file for each cache operation. */
  2059. #define KRB5_TC_OPENCLOSE 0x00000001
  2060. #define KRB5_TC_NOTICKET 0x00000002
  2061. /**
  2062. * Retrieve the name, but not type of a credential cache.
  2063. *
  2064. * @param [in] context Library context
  2065. * @param [in] cache Credential cache handle
  2066. *
  2067. * @warning Returns the name of the credential cache. The result is an alias
  2068. * into @a cache and should not be freed or modified by the caller. This name
  2069. * does not include the cache type, so should not be used as input to
  2070. * krb5_cc_resolve().
  2071. *
  2072. * @return
  2073. * On success - the name of the credential cache.
  2074. */
  2075. const char * KRB5_CALLCONV
  2076. krb5_cc_get_name(krb5_context context, krb5_ccache cache);
  2077. /**
  2078. * Retrieve the full name of a credential cache.
  2079. *
  2080. * @param [in] context Library context
  2081. * @param [in] cache Credential cache handle
  2082. * @param [out] fullname_out Full name of cache
  2083. *
  2084. */
  2085. krb5_error_code KRB5_CALLCONV
  2086. krb5_cc_get_full_name(krb5_context context, krb5_ccache cache,
  2087. char **fullname_out);
  2088. #if KRB5_DEPRECATED
  2089. krb5_error_code KRB5_CALLCONV
  2090. krb5_cc_gen_new(krb5_context context, krb5_ccache *cache);
  2091. #endif /* KRB5_DEPRECATED */
  2092. /**
  2093. * Initialize a credential cache.
  2094. *
  2095. * @param [in] context Library context
  2096. * @param [in] cache Credential cache handle
  2097. * @param [in] principal Default principal name
  2098. *
  2099. * Destroy any existing contents of @a cache and initialize it for the default
  2100. * principal @a principal.
  2101. *
  2102. * @retval
  2103. * 0 Success
  2104. * @return
  2105. * System errors; Permission errors; Kerberos error codes
  2106. */
  2107. krb5_error_code KRB5_CALLCONV
  2108. krb5_cc_initialize(krb5_context context, krb5_ccache cache,
  2109. krb5_principal principal);
  2110. /**
  2111. * Destroy a credential cache.
  2112. *
  2113. * @param [in] context Library context
  2114. * @param [in] cache Credential cache handle
  2115. *
  2116. * This function destroys any existing contents of @a cache and closes the
  2117. * handle to it.
  2118. *
  2119. * @retval
  2120. * 0 Success
  2121. * @return
  2122. * Permission errors
  2123. */
  2124. krb5_error_code KRB5_CALLCONV
  2125. krb5_cc_destroy(krb5_context context, krb5_ccache cache);
  2126. /**
  2127. * Close a credential cache handle.
  2128. *
  2129. * @param [in] context Library context
  2130. * @param [in] cache Credential cache handle
  2131. *
  2132. * This function closes a credential cache handle @a cache without affecting
  2133. * the contents of the cache.
  2134. *
  2135. * @retval
  2136. * 0 Success
  2137. * @return
  2138. * Kerberos error codes
  2139. */
  2140. krb5_error_code KRB5_CALLCONV
  2141. krb5_cc_close(krb5_context context, krb5_ccache cache);
  2142. /**
  2143. * Store credentials in a credential cache.
  2144. *
  2145. * @param [in] context Library context
  2146. * @param [in,out] cache Credential cache handle
  2147. * @param [in] creds Credentials to be stored in cache
  2148. *
  2149. * This function stores @a creds into @a cache. If @a creds->server and the
  2150. * server in the decoded ticket @a creds->ticket differ, the credentials will
  2151. * be stored under both server principal names.
  2152. *
  2153. * @retval
  2154. * 0 Success
  2155. * @return Permission errors; storage failure errors; Kerberos error codes
  2156. */
  2157. krb5_error_code KRB5_CALLCONV
  2158. krb5_cc_store_cred(krb5_context context, krb5_ccache cache, krb5_creds *creds);
  2159. /**
  2160. * Retrieve a specified credentials from a credential cache.
  2161. *
  2162. * @param [in] context Library context
  2163. * @param [in] cache Credential cache handle
  2164. * @param [in] flags Flags bit mask
  2165. * @param [in] mcreds Credentials to match
  2166. * @param [out] creds Credentials matching the requested value
  2167. *
  2168. * This function searches a credential cache for credentials matching @a mcreds
  2169. * and returns it if found.
  2170. *
  2171. * Valid values for @a flags are:
  2172. *
  2173. * @li #KRB5_TC_MATCH_TIMES The requested lifetime must be at least as
  2174. * great as in @a mcreds .
  2175. * @li #KRB5_TC_MATCH_IS_SKEY The @a is_skey field much match exactly.
  2176. * @li #KRB5_TC_MATCH_FLAGS Flags set in @a mcreds must be set.
  2177. * @li #KRB5_TC_MATCH_TIMES_EXACT The requested lifetime must match exactly.
  2178. * @li #KRB5_TC_MATCH_FLAGS_EXACT Flags must match exactly.
  2179. * @li #KRB5_TC_MATCH_AUTHDATA The authorization data must match.
  2180. * @li #KRB5_TC_MATCH_SRV_NAMEONLY Only the name portion of the principal
  2181. * name must match, not the realm.
  2182. * @li #KRB5_TC_MATCH_2ND_TKT The second tickets must match.
  2183. * @li #KRB5_TC_MATCH_KTYPE The encryption key types must match.
  2184. * @li #KRB5_TC_SUPPORTED_KTYPES Check all matching entries that have any
  2185. * supported encryption type and return the
  2186. * one with the encryption type listed earliest.
  2187. *
  2188. * Use krb5_free_cred_contents() to free @a creds when it is no longer needed.
  2189. *
  2190. * @retval 0 Success; otherwise - Kerberos error codes
  2191. */
  2192. krb5_error_code KRB5_CALLCONV
  2193. krb5_cc_retrieve_cred(krb5_context context, krb5_ccache cache,
  2194. krb5_flags flags, krb5_creds *mcreds,
  2195. krb5_creds *creds);
  2196. /**
  2197. * Get the default principal of a credential cache.
  2198. *
  2199. * @param [in] context Library context
  2200. * @param [in] cache Credential cache handle
  2201. * @param [out] principal Primary principal
  2202. *
  2203. * Returns the default client principal of a credential cache as set by
  2204. * krb5_cc_initialize().
  2205. *
  2206. * Use krb5_free_principal() to free @a principal when it is no longer needed.
  2207. *
  2208. * @retval
  2209. * 0 Success
  2210. * @return
  2211. * Kerberos error codes
  2212. */
  2213. krb5_error_code KRB5_CALLCONV
  2214. krb5_cc_get_principal(krb5_context context, krb5_ccache cache,
  2215. krb5_principal *principal);
  2216. /**
  2217. * Prepare to sequentially read every credential in a credential cache.
  2218. *
  2219. * @param [in] context Library context
  2220. * @param [in] cache Credential cache handle
  2221. * @param [out] cursor Cursor
  2222. *
  2223. * krb5_cc_end_seq_get() must be called to complete the retrieve operation.
  2224. *
  2225. * @note If @a cache is modified between the time of the call to this function
  2226. * and the time of the final krb5_cc_end_seq_get(), the results are undefined.
  2227. *
  2228. * @retval 0 Success; otherwise - Kerberos error codes
  2229. */
  2230. krb5_error_code KRB5_CALLCONV
  2231. krb5_cc_start_seq_get(krb5_context context, krb5_ccache cache,
  2232. krb5_cc_cursor *cursor);
  2233. /**
  2234. * Retrieve the next entry from the credential cache.
  2235. *
  2236. * @param [in] context Library context
  2237. * @param [in] cache Credential cache handle
  2238. * @param [in,out] cursor Cursor
  2239. * @param [out] creds Next credential cache entry
  2240. *
  2241. * This function fills in @a creds with the next entry in @a cache and advances
  2242. * @a cursor.
  2243. *
  2244. * Use krb5_free_cred_contents() to free @a creds when it is no longer needed.
  2245. *
  2246. * @sa krb5_cc_start_seq_get(), krb5_end_seq_get()
  2247. *
  2248. * @retval 0 Success; otherwise - Kerberos error codes
  2249. */
  2250. krb5_error_code KRB5_CALLCONV
  2251. krb5_cc_next_cred(krb5_context context, krb5_ccache cache,
  2252. krb5_cc_cursor *cursor, krb5_creds *creds);
  2253. /**
  2254. * Finish a series of sequential processing credential cache entries.
  2255. *
  2256. * @param [in] context Library context
  2257. * @param [in] cache Credential cache handle
  2258. * @param [in,out] cursor Cursor
  2259. *
  2260. * This function finishes processing credential cache entries and invalidates
  2261. * @a cursor.
  2262. *
  2263. * @sa krb5_cc_start_seq_get(), krb5_cc_next_cred()
  2264. *
  2265. * @retval 0 (always)
  2266. */
  2267. krb5_error_code KRB5_CALLCONV
  2268. krb5_cc_end_seq_get(krb5_context context, krb5_ccache cache,
  2269. krb5_cc_cursor *cursor);
  2270. /**
  2271. * Remove credentials from a credential cache.
  2272. *
  2273. * @param [in] context Library context
  2274. * @param [in] cache Credential cache handle
  2275. * @param [in] flags Bitwise-ORed search flags
  2276. * @param [in] creds Credentials to be matched
  2277. *
  2278. * @warning This function is not implemented for some cache types.
  2279. *
  2280. * This function accepts the same flag values as krb5_cc_retrieve_cred().
  2281. *
  2282. * @retval KRB5_CC_NOSUPP Not implemented for this cache type
  2283. * @return No matches found; Data cannot be deleted; Kerberos error codes
  2284. */
  2285. krb5_error_code KRB5_CALLCONV
  2286. krb5_cc_remove_cred(krb5_context context, krb5_ccache cache, krb5_flags flags,
  2287. krb5_creds *creds);
  2288. /**
  2289. * Set options flags on a credential cache.
  2290. *
  2291. * @param [in] context Library context
  2292. * @param [in,out] cache Credential cache handle
  2293. * @param [in] flags Flag bit mask
  2294. *
  2295. * This function resets @a cache flags to @a flags.
  2296. *
  2297. * @retval 0 Success; otherwise - Kerberos error codes
  2298. */
  2299. krb5_error_code KRB5_CALLCONV
  2300. krb5_cc_set_flags(krb5_context context, krb5_ccache cache, krb5_flags flags);
  2301. /**
  2302. * Retrieve flags from a credential cache structure.
  2303. *
  2304. * @param [in] context Library context
  2305. * @param [in] cache Credential cache handle
  2306. * @param [out] flags Flag bit mask
  2307. *
  2308. * @warning For memory credential cache always returns a flag mask of 0.
  2309. *
  2310. * @retval 0 Success; otherwise - Kerberos error codes
  2311. */
  2312. krb5_error_code KRB5_CALLCONV
  2313. krb5_cc_get_flags(krb5_context context, krb5_ccache cache, krb5_flags *flags);
  2314. /**
  2315. * Retrieve the type of a credential cache.
  2316. *
  2317. * @param [in] context Library context
  2318. * @param [in] cache Credential cache handle
  2319. *
  2320. * @return The type of a credential cache as an alias that must not be modified
  2321. * or freed by the caller.
  2322. */
  2323. const char * KRB5_CALLCONV
  2324. krb5_cc_get_type(krb5_context context, krb5_ccache cache);
  2325. /**
  2326. * Move a credential cache.
  2327. *
  2328. * @param [in] context Library context
  2329. * @param [in] src The credential cache to move the content from
  2330. * @param [in] dst The credential cache to move the content to
  2331. *
  2332. * This function reinitializes @a dst and populates it with the credentials and
  2333. * default principal of @a src; then, if successful, destroys @a src.
  2334. *
  2335. * @retval
  2336. * 0 Success; @a src is closed.
  2337. * @return
  2338. * Kerberos error codes; @a src is still allocated.
  2339. */
  2340. krb5_error_code KRB5_CALLCONV
  2341. krb5_cc_move(krb5_context context, krb5_ccache src, krb5_ccache dst);
  2342. /**
  2343. * Return a timestamp of the last modification to a credential cache.
  2344. *
  2345. * @param [in] context Library context
  2346. * @param [in] ccache Credential cache handle
  2347. * @param [out] change_time The last change time of @a ccache
  2348. *
  2349. * If an error occurs, @a change_time is set to 0.
  2350. */
  2351. krb5_error_code KRB5_CALLCONV
  2352. krb5_cc_last_change_time(krb5_context context, krb5_ccache ccache,
  2353. krb5_timestamp *change_time);
  2354. /**
  2355. * Lock a credential cache.
  2356. *
  2357. * @param [in] context Library context
  2358. * @param [in] ccache Credential cache handle
  2359. *
  2360. * Use krb5_cc_unlock() to unlock the lock.
  2361. *
  2362. * @retval 0 Success; otherwise - Kerberos error codes
  2363. */
  2364. krb5_error_code KRB5_CALLCONV
  2365. krb5_cc_lock(krb5_context context, krb5_ccache ccache);
  2366. /**
  2367. * Unlock a credential cache.
  2368. *
  2369. * @param [in] context Library context
  2370. * @param [in] ccache Credential cache handle
  2371. *
  2372. * This function unlocks the @a ccache locked by krb5_cc_lock().
  2373. *
  2374. * @retval 0 Success; otherwise - Kerberos error codes
  2375. */
  2376. krb5_error_code KRB5_CALLCONV
  2377. krb5_cc_unlock(krb5_context context, krb5_ccache ccache);
  2378. /**
  2379. * Prepare to iterate over the collection of known credential caches.
  2380. *
  2381. * @param [in] context Library context
  2382. * @param [in,out] cursor Cursor
  2383. *
  2384. * Get a new cache iteration @a cursor that will iterate over all known
  2385. * credential caches independent of type.
  2386. *
  2387. * Use krb5_cccol_cursor_free() to release @a cursor when it is no longer
  2388. * needed.
  2389. *
  2390. * @sa krb5_cccol_cursor_next()
  2391. *
  2392. * @retval 0 Success; otherwise - Kerberos error codes
  2393. */
  2394. krb5_error_code KRB5_CALLCONV
  2395. krb5_cccol_cursor_new(krb5_context context, krb5_cccol_cursor *cursor);
  2396. /**
  2397. * Get the next credential cache in the collection.
  2398. *
  2399. * @param [in] context Library context
  2400. * @param [in,out] cursor Cursor
  2401. * @param [out] ccache Credential cache handle
  2402. *
  2403. * @note When all caches are iterated over and the end of the list is reached,
  2404. * @a ccache is set to NULL.
  2405. *
  2406. * Use krb5_cc_close() to close @a ccache when it is no longer needed.
  2407. *
  2408. * @sa krb5_cccol_cursor_new(), krb5_cccol_cursor_free()
  2409. *
  2410. * @retval 0 Success; otherwise - Kerberos error codes
  2411. */
  2412. krb5_error_code KRB5_CALLCONV
  2413. krb5_cccol_cursor_next(krb5_context context, krb5_cccol_cursor cursor,
  2414. krb5_ccache *ccache);
  2415. /**
  2416. * Free a credential cache collection cursor.
  2417. *
  2418. * @param [in] context Library context
  2419. * @param [in] cursor Cursor
  2420. *
  2421. * @sa krb5_cccol_cursor_new(), krb5_cccol_cursor_next()
  2422. *
  2423. * @retval 0 Success; otherwise - Kerberos error codes
  2424. */
  2425. krb5_error_code KRB5_CALLCONV
  2426. krb5_cccol_cursor_free(krb5_context context, krb5_cccol_cursor *cursor);
  2427. /**
  2428. * Return a timestamp of the last modification of any known credential cache.
  2429. *
  2430. * @param [in] context Library context
  2431. * @param [out] change_time Last modification timestamp
  2432. *
  2433. * This function returns the most recent modification time of any known
  2434. * credential cache, ignoring any caches which cannot supply a last
  2435. * modification time.
  2436. *
  2437. * If there are no known credential caches, @a change_time is set to 0.
  2438. *
  2439. * @retval 0 Success; otherwise - Kerberos error codes
  2440. */
  2441. krb5_error_code KRB5_CALLCONV
  2442. krb5_cccol_last_change_time(krb5_context context, krb5_timestamp *change_time);
  2443. /**
  2444. * Acquire a global lock for credential caches.
  2445. *
  2446. * @param [in] context Library context
  2447. *
  2448. * This function locks the global credential cache collection, ensuring
  2449. * that no ccaches are added to or removed from it until the collection
  2450. * lock is released.
  2451. *
  2452. * Use krb5_cccol_unlock() to unlock the lock.
  2453. *
  2454. * @retval 0 Success; otherwise - Kerberos error codes
  2455. */
  2456. krb5_error_code KRB5_CALLCONV
  2457. krb5_cccol_lock(krb5_context context);
  2458. /**
  2459. * Release a global lock for credential caches.
  2460. *
  2461. * @param [in] context Library context
  2462. *
  2463. * This function unlocks the lock from krb5_cccol_lock().
  2464. *
  2465. * @retval 0 Success; otherwise - Kerberos error codes
  2466. */
  2467. krb5_error_code KRB5_CALLCONV
  2468. krb5_cccol_unlock(krb5_context context);
  2469. /**
  2470. * Create a new credential cache of the specified type with a unique name.
  2471. *
  2472. * @param [in] context Library context
  2473. * @param [in] type Credential cache type name
  2474. * @param [in] hint Unused
  2475. * @param [out] id Credential cache handle
  2476. *
  2477. * @retval
  2478. * 0 Success
  2479. * @return
  2480. * Kerberos error codes
  2481. */
  2482. krb5_error_code KRB5_CALLCONV
  2483. krb5_cc_new_unique(krb5_context context, const char *type, const char *hint,
  2484. krb5_ccache *id);
  2485. /*
  2486. * end "ccache.h"
  2487. */
  2488. /*
  2489. * begin "rcache.h"
  2490. */
  2491. struct krb5_rc_st;
  2492. typedef struct krb5_rc_st *krb5_rcache;
  2493. /*
  2494. * end "rcache.h"
  2495. */
  2496. /*
  2497. * begin "keytab.h"
  2498. */
  2499. /* XXX */
  2500. #define MAX_KEYTAB_NAME_LEN 1100 /* Long enough for MAXPATHLEN + some extra */
  2501. typedef krb5_pointer krb5_kt_cursor;
  2502. /** A key table entry. */
  2503. typedef struct krb5_keytab_entry_st {
  2504. krb5_magic magic;
  2505. krb5_principal principal; /**< Principal of this key */
  2506. krb5_timestamp timestamp; /**< Time entry written to keytable */
  2507. krb5_kvno vno; /**< Key version number */
  2508. krb5_keyblock key; /**< The secret key */
  2509. } krb5_keytab_entry;
  2510. struct _krb5_kt;
  2511. typedef struct _krb5_kt *krb5_keytab;
  2512. /**
  2513. * Return the type of a key table.
  2514. *
  2515. * @param [in] context Library context
  2516. * @param [in] keytab Key table handle
  2517. *
  2518. * @return The type of a key table as an alias that must not be modified or
  2519. * freed by the caller.
  2520. */
  2521. const char * KRB5_CALLCONV
  2522. krb5_kt_get_type(krb5_context context, krb5_keytab keytab);
  2523. /**
  2524. * Get a key table name.
  2525. *
  2526. * @param [in] context Library context
  2527. * @param [in] keytab Key table handle
  2528. * @param [out] name Key table name
  2529. * @param [in] namelen Maximum length to fill in name
  2530. *
  2531. * Fills in @a with the name of @a keytab including the type and delimiter.
  2532. *
  2533. * @sa MAX_KEYTAB_NAME_LEN
  2534. *
  2535. * @retval
  2536. * 0 Success
  2537. * @retval
  2538. * KRB5_KT_NAME_TOOLONG Key table name does not fit in @a namelen bytes
  2539. *
  2540. * @return
  2541. * Kerberos error codes
  2542. */
  2543. krb5_error_code KRB5_CALLCONV
  2544. krb5_kt_get_name(krb5_context context, krb5_keytab keytab, char *name,
  2545. unsigned int namelen);
  2546. /**
  2547. * Close a key table handle.
  2548. *
  2549. * @param [in] context Library context
  2550. * @param [in] keytab Key table handle
  2551. *
  2552. * @retval 0
  2553. */
  2554. krb5_error_code KRB5_CALLCONV
  2555. krb5_kt_close(krb5_context context, krb5_keytab keytab);
  2556. /**
  2557. * Get an entry from a key table.
  2558. *
  2559. * @param [in] context Library context
  2560. * @param [in] keytab Key table handle
  2561. * @param [in] principal Principal name
  2562. * @param [in] vno Key version number (0 for highest available)
  2563. * @param [in] enctype Encryption type (0 zero for any enctype)
  2564. * @param [out] entry Returned entry from key table
  2565. *
  2566. * Retrieve an entry from a key table which matches the @a keytab, @a
  2567. * principal, @a vno, and @a enctype. If @a vno is zero, retrieve the
  2568. * highest-numbered kvno matching the other fields. If @a enctype is 0, match
  2569. * any enctype.
  2570. *
  2571. * Use krb5_free_keytab_entry_contents() to free @a entry when it is no longer
  2572. * needed.
  2573. *
  2574. * @note If @a vno is zero, the function retrieves the highest-numbered-kvno
  2575. * entry that matches the specified principal.
  2576. *
  2577. * @retval
  2578. * 0 Success
  2579. * @retval
  2580. * Kerberos error codes on failure
  2581. */
  2582. krb5_error_code KRB5_CALLCONV
  2583. krb5_kt_get_entry(krb5_context context, krb5_keytab keytab,
  2584. krb5_const_principal principal, krb5_kvno vno,
  2585. krb5_enctype enctype, krb5_keytab_entry *entry);
  2586. /**
  2587. * Start a sequential retrieval of key table entries.
  2588. *
  2589. * @param [in] context Library context
  2590. * @param [in] keytab Key table handle
  2591. * @param [out] cursor Cursor
  2592. *
  2593. * Prepare to read sequentially every key in the specified key table. Use
  2594. * krb5_kt_end_seq_get() to release the cursor when it is no longer needed.
  2595. *
  2596. * @sa krb5_kt_next_entry(), krb5_kt_end_seq_get()
  2597. *
  2598. * @retval
  2599. * 0 Success
  2600. * @return
  2601. * Kerberos error codes
  2602. */
  2603. krb5_error_code KRB5_CALLCONV
  2604. krb5_kt_start_seq_get(krb5_context context, krb5_keytab keytab,
  2605. krb5_kt_cursor *cursor);
  2606. /**
  2607. * Retrieve the next entry from the key table.
  2608. *
  2609. * @param [in] context Library context
  2610. * @param [in] keytab Key table handle
  2611. * @param [out] entry Returned key table entry
  2612. * @param [in,out] cursor Key table cursor
  2613. *
  2614. * Return the next sequential entry in @a keytab and advance @a cursor.
  2615. *
  2616. * @sa krb5_kt_start_seq_get(), krb5_kt_end_seq_get()
  2617. *
  2618. * @retval
  2619. * 0 Success
  2620. * @retval
  2621. * KRB5_KT_END - if the last entry was reached
  2622. * @return
  2623. * Kerberos error codes
  2624. */
  2625. krb5_error_code KRB5_CALLCONV
  2626. krb5_kt_next_entry(krb5_context context, krb5_keytab keytab,
  2627. krb5_keytab_entry *entry, krb5_kt_cursor *cursor);
  2628. /**
  2629. * Release a keytab cursor.
  2630. *
  2631. * @param [in] context Library context
  2632. * @param [in] keytab Key table handle
  2633. * @param [out] cursor Cursor
  2634. *
  2635. * This function should be called to release the cursor created by
  2636. * krb5_kt_start_seq_get().
  2637. *
  2638. * @retval
  2639. * 0 Success
  2640. * @return
  2641. * Kerberos error codes
  2642. */
  2643. krb5_error_code KRB5_CALLCONV
  2644. krb5_kt_end_seq_get(krb5_context context, krb5_keytab keytab,
  2645. krb5_kt_cursor *cursor);
  2646. /*
  2647. * end "keytab.h"
  2648. */
  2649. /*
  2650. * begin "func-proto.h"
  2651. */
  2652. #define KRB5_INIT_CONTEXT_SECURE 0x1 /**< Use secure context configuration */
  2653. #define KRB5_INIT_CONTEXT_KDC 0x2 /**< Use KDC configuration if available */
  2654. /**
  2655. * Create a krb5 library context.
  2656. *
  2657. * @param [out] context Library context
  2658. *
  2659. * The @a context must be released by calling krb5_free_context() when
  2660. * it is no longer needed.
  2661. *
  2662. * @warning Any program or module that needs the Kerberos code to not trust the
  2663. * environment must use krb5_init_secure_context(), or clean out the
  2664. * environment.
  2665. *
  2666. * @retval
  2667. * 0 Success
  2668. * @return
  2669. * Kerberos error codes
  2670. */
  2671. krb5_error_code KRB5_CALLCONV
  2672. krb5_init_context(krb5_context *context);
  2673. /**
  2674. * Create a krb5 library context using only configuration files.
  2675. *
  2676. * @param [out] context Library context
  2677. *
  2678. * Create a context structure, using only system configuration files. All
  2679. * information passed through the environment variables is ignored.
  2680. *
  2681. * The @a context must be released by calling krb5_free_context() when
  2682. * it is no longer needed.
  2683. *
  2684. * @retval
  2685. * 0 Success
  2686. * @return
  2687. * Kerberos error codes
  2688. */
  2689. krb5_error_code KRB5_CALLCONV
  2690. krb5_init_secure_context(krb5_context *context);
  2691. /**
  2692. * Create a krb5 library context using a specified profile.
  2693. *
  2694. * @param [in] profile Profile object (NULL to create default profile)
  2695. * @param [in] flags Context initialization flags
  2696. * @param [out] context Library context
  2697. *
  2698. * Create a context structure, optionally using a specified profile and
  2699. * initialization flags. If @a profile is NULL, the default profile will be
  2700. * created from config files. If @a profile is non-null, a copy of it will be
  2701. * made for the new context; the caller should still clean up its copy. Valid
  2702. * flag values are:
  2703. *
  2704. * @li #KRB5_INIT_CONTEXT_SECURE Ignore environment variables
  2705. * @li #KRB5_INIT_CONTEXT_KDC Use KDC configuration if creating profile
  2706. */
  2707. krb5_error_code KRB5_CALLCONV
  2708. krb5_init_context_profile(struct _profile_t *profile, krb5_flags flags,
  2709. krb5_context *context);
  2710. /**
  2711. * Free a krb5 library context.
  2712. *
  2713. * @param [in] context Library context
  2714. *
  2715. * This function frees a @a context that was created by krb5_init_context()
  2716. * or krb5_init_secure_context().
  2717. */
  2718. void KRB5_CALLCONV
  2719. krb5_free_context(krb5_context context);
  2720. /**
  2721. * Copy a krb5_context structure.
  2722. *
  2723. * @param [in] ctx Library context
  2724. * @param [out] nctx_out New context structure
  2725. *
  2726. * The newly created context must be released by calling krb5_free_context()
  2727. * when it is no longer needed.
  2728. *
  2729. * @retval
  2730. * 0 Success
  2731. * @return
  2732. * Kerberos error codes
  2733. */
  2734. krb5_error_code KRB5_CALLCONV
  2735. krb5_copy_context(krb5_context ctx, krb5_context *nctx_out);
  2736. /**
  2737. * Set default TGS encryption types in a krb5_context structure.
  2738. *
  2739. * @param [in,out] context Library context
  2740. * @param [in] etypes Encryption type(s) to set
  2741. *
  2742. * This function sets the default enctype list for TGS requests
  2743. * made using @a context to @a etypes.
  2744. *
  2745. * @note This overrides the default list (from config file or built-in).
  2746. *
  2747. * @retval
  2748. * 0 Success
  2749. * @retval
  2750. * KRB5_PROG_ETYPE_NOSUPP Program lacks support for encryption type
  2751. * @return
  2752. * Kerberos error codes
  2753. */
  2754. krb5_error_code KRB5_CALLCONV
  2755. krb5_set_default_tgs_enctypes(krb5_context context, const krb5_enctype *etypes);
  2756. /**
  2757. * Return a list of encryption types permitted for session keys.
  2758. *
  2759. * @param [in] context Library context
  2760. * @param [out] ktypes Zero-terminated list of encryption types
  2761. *
  2762. * This function returns the list of encryption types permitted for session
  2763. * keys within @a context, as determined by configuration or by a previous call
  2764. * to krb5_set_default_tgs_enctypes().
  2765. *
  2766. * @retval 0 Success; otherwise - Kerberos error codes
  2767. */
  2768. krb5_error_code KRB5_CALLCONV
  2769. krb5_get_permitted_enctypes(krb5_context context, krb5_enctype **ktypes);
  2770. /**
  2771. * Test whether the Kerberos library was built with multithread support.
  2772. *
  2773. * @retval
  2774. * TRUE if the library is threadsafe; FALSE otherwise
  2775. */
  2776. krb5_boolean KRB5_CALLCONV
  2777. krb5_is_thread_safe(void);
  2778. /* libkrb.spec */
  2779. /**
  2780. * Decrypt a ticket using the specified key table.
  2781. *
  2782. * @param [in] context Library context
  2783. * @param [in] kt Key table
  2784. * @param [in,out] ticket Ticket to be decrypted
  2785. *
  2786. * This function takes a @a ticket as input and decrypts it using
  2787. * key data from @a kt. The result is placed into @a ticket->enc_part2.
  2788. *
  2789. * @retval 0 Success; otherwise - Kerberos error codes
  2790. */
  2791. krb5_error_code KRB5_CALLCONV
  2792. krb5_server_decrypt_ticket_keytab(krb5_context context, const krb5_keytab kt,
  2793. krb5_ticket *ticket);
  2794. /**
  2795. * Free an array of credential structures.
  2796. *
  2797. * @param [in] context Library context
  2798. * @param [in] tgts Null-terminated array of credentials to free
  2799. *
  2800. * @note The last entry in the array @a tgts must be a NULL pointer.
  2801. */
  2802. void KRB5_CALLCONV
  2803. krb5_free_tgt_creds(krb5_context context, krb5_creds **tgts);
  2804. /** @defgroup KRB5_GC KRB5_GC
  2805. * @{
  2806. */
  2807. #define KRB5_GC_USER_USER 1 /**< Want user-user ticket */
  2808. #define KRB5_GC_CACHED 2 /**< Want cached ticket only */
  2809. #define KRB5_GC_CANONICALIZE 4 /**< Set canonicalize KDC option */
  2810. #define KRB5_GC_NO_STORE 8 /**< Do not store in credential cache */
  2811. #define KRB5_GC_FORWARDABLE 16 /**< Acquire forwardable tickets */
  2812. #define KRB5_GC_NO_TRANSIT_CHECK 32 /**< Disable transited check */
  2813. #define KRB5_GC_CONSTRAINED_DELEGATION 64 /**< Constrained delegation */
  2814. /** @} */ /* end of KRB5_GC group */
  2815. /**
  2816. * Get an additional ticket.
  2817. *
  2818. * @param [in] context Library context
  2819. * @param [in] options Options
  2820. * @param [in,out] ccache Credential cache handle
  2821. * @param [in] in_creds Input credentials
  2822. * @param [out] out_creds Output updated credentials
  2823. *
  2824. * Use @a ccache or a TGS exchange to get a service ticket matching @a
  2825. * in_creds.
  2826. *
  2827. * Valid values for @a options are:
  2828. * @li #KRB5_GC_CACHED Search only credential cache for the ticket
  2829. * @li #KRB5_GC_USER_USER Return a user to user authentication ticket
  2830. *
  2831. * @a in_creds must be non-null. @a in_creds->client and @a in_creds->server
  2832. * must be filled in to specify the client and the server respectively. If any
  2833. * authorization data needs to be requested for the service ticket (such as
  2834. * restrictions on how the ticket can be used), specify it in @a
  2835. * in_creds->authdata; otherwise set @a in_creds->authdata to NULL. The
  2836. * session key type is specified in @a in_creds->keyblock.enctype, if it is
  2837. * nonzero.
  2838. *
  2839. * The expiration date is specified in @a in_creds->times.endtime.
  2840. * The KDC may return tickets with an earlier expiration date.
  2841. * If @a in_creds->times.endtime is set to 0, the latest possible
  2842. * expiration date will be requested.
  2843. *
  2844. * Any returned ticket and intermediate ticket-granting tickets are stored
  2845. * in @a ccache.
  2846. *
  2847. * Use krb5_free_creds() to free @a out_creds when it is no longer needed.
  2848. *
  2849. * @retval
  2850. * 0 Success
  2851. * @return
  2852. * Kerberos error codes
  2853. */
  2854. krb5_error_code KRB5_CALLCONV
  2855. krb5_get_credentials(krb5_context context, krb5_flags options,
  2856. krb5_ccache ccache, krb5_creds *in_creds,
  2857. krb5_creds **out_creds);
  2858. /** @deprecated Replaced by krb5_get_validated_creds. */
  2859. krb5_error_code KRB5_CALLCONV
  2860. krb5_get_credentials_validate(krb5_context context, krb5_flags options,
  2861. krb5_ccache ccache, krb5_creds *in_creds,
  2862. krb5_creds **out_creds);
  2863. /** @deprecated Replaced by krb5_get_renewed_creds. */
  2864. krb5_error_code KRB5_CALLCONV
  2865. krb5_get_credentials_renew(krb5_context context, krb5_flags options,
  2866. krb5_ccache ccache, krb5_creds *in_creds,
  2867. krb5_creds **out_creds);
  2868. /**
  2869. * Create a @c KRB_AP_REQ message.
  2870. *
  2871. * @param [in] context Library context
  2872. * @param [in,out] auth_context Pre-existing or newly created auth context
  2873. * @param [in] ap_req_options @ref AP_OPTS options
  2874. * @param [in] service Service name, or NULL to use @c "host"
  2875. * @param [in] hostname Host name, or NULL to use local hostname
  2876. * @param [in] in_data Application data to be checksummed in the
  2877. * authenticator, or NULL
  2878. * @param [in] ccache Credential cache used to obtain credentials
  2879. * for the desired service.
  2880. * @param [out] outbuf @c AP-REQ message
  2881. *
  2882. * This function is similar to krb5_mk_req_extended() except that it uses a
  2883. * given @a hostname, @a service, and @a ccache to construct a service
  2884. * principal name and obtain credentials.
  2885. *
  2886. * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
  2887. *
  2888. * @retval 0 Success; otherwise - Kerberos error codes
  2889. */
  2890. krb5_error_code KRB5_CALLCONV
  2891. krb5_mk_req(krb5_context context, krb5_auth_context *auth_context,
  2892. krb5_flags ap_req_options, char *service, char *hostname,
  2893. krb5_data *in_data, krb5_ccache ccache, krb5_data *outbuf);
  2894. /**
  2895. * Create a @c KRB_AP_REQ message using supplied credentials.
  2896. *
  2897. * @param [in] context Library context
  2898. * @param [in,out] auth_context Pre-existing or newly created auth context
  2899. * @param [in] ap_req_options @ref AP_OPTS options
  2900. * @param [in] in_data Application data to be checksummed in the
  2901. * authenticator, or NULL
  2902. * @param [in] in_creds Credentials for the service with valid ticket
  2903. * and key
  2904. * @param [out] outbuf @c AP-REQ message
  2905. *
  2906. * Valid @a ap_req_options are:
  2907. * @li #AP_OPTS_USE_SESSION_KEY - Use the session key when creating the
  2908. * request used for user to user
  2909. * authentication.
  2910. * @li #AP_OPTS_MUTUAL_REQUIRED - Request a mutual authentication packet from
  2911. * the reciever.
  2912. * @li #AP_OPTS_USE_SUBKEY - Generate a subsession key from the current
  2913. * session key obtained from the credentials.
  2914. *
  2915. * This function creates a KRB_AP_REQ message using supplied credentials @a
  2916. * in_creds. @a auth_context may point to an existing auth context or to NULL,
  2917. * in which case a new one will be created. If @a in_data is non-null, a
  2918. * checksum of it will be included in the authenticator contained in the
  2919. * KRB_AP_REQ message. Use krb5_free_data_contents() to free @a outbuf when it
  2920. * is no longer needed.
  2921. *
  2922. * On successful return, the authenticator is stored in @a auth_context with
  2923. * the @a client and @a checksum fields nulled out. (This is to prevent
  2924. * pointer-sharing problems; the caller should not need these fields anyway,
  2925. * since the caller supplied them.)
  2926. *
  2927. * @sa krb5_mk_req()
  2928. *
  2929. * @retval 0 Success; otherwise - Kerberos error codes
  2930. */
  2931. krb5_error_code KRB5_CALLCONV
  2932. krb5_mk_req_extended(krb5_context context, krb5_auth_context *auth_context,
  2933. krb5_flags ap_req_options, krb5_data *in_data,
  2934. krb5_creds *in_creds, krb5_data *outbuf);
  2935. /**
  2936. * Format and encrypt a @c KRB_AP_REP message.
  2937. *
  2938. * @param [in] context Library context
  2939. * @param [in,out] auth_context Authentication context
  2940. * @param [out] outbuf @c AP-REP message
  2941. *
  2942. * This function fills in @a outbuf with an AP-REP message using information
  2943. * from @a auth_context.
  2944. *
  2945. * If the flags in @a auth_context indicate that a sequence number should be
  2946. * used (either #KRB5_AUTH_CONTEXT_DO_SEQUENCE or
  2947. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE) and the local sequence number in @a
  2948. * auth_context is 0, a new number will be generated with
  2949. * krb5_generate_seq_number().
  2950. *
  2951. * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
  2952. *
  2953. * @retval 0 Success; otherwise - Kerberos error codes
  2954. */
  2955. krb5_error_code KRB5_CALLCONV
  2956. krb5_mk_rep(krb5_context context, krb5_auth_context auth_context, krb5_data *outbuf);
  2957. /**
  2958. * Format and encrypt a @c KRB_AP_REP message for DCE RPC.
  2959. *
  2960. * @param [in] context Library context
  2961. * @param [in,out] auth_context Authentication context
  2962. * @param [out] outbuf @c AP-REP message
  2963. *
  2964. * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
  2965. *
  2966. * @retval 0 Success; otherwise - Kerberos error codes
  2967. */
  2968. krb5_error_code KRB5_CALLCONV
  2969. krb5_mk_rep_dce(krb5_context context, krb5_auth_context auth_context, krb5_data *outbuf);
  2970. /**
  2971. * Parse and decrypt a @c KRB_AP_REP message.
  2972. *
  2973. * @param [in] context Library context
  2974. * @param [in,out] auth_context Authentication context
  2975. * @param [in] inbuf AP-REP message
  2976. * @param [out] repl Decrypted reply message
  2977. *
  2978. * This function parses, decrypts and verifies a message from @a inbuf and
  2979. * fills in @a repl with a pointer to allocated memory containing the fields
  2980. * from the encrypted response.
  2981. *
  2982. * Use krb5_free_ap_rep_enc_part() to free @a repl when it is no longer needed.
  2983. *
  2984. * @retval 0 Success; otherwise - Kerberos error codes
  2985. */
  2986. krb5_error_code KRB5_CALLCONV
  2987. krb5_rd_rep(krb5_context context, krb5_auth_context auth_context,
  2988. const krb5_data *inbuf, krb5_ap_rep_enc_part **repl);
  2989. /**
  2990. * Parse and decrypt a @c KRB_AP_REP message for DCE RPC.
  2991. *
  2992. * @param [in] context Library context
  2993. * @param [in,out] auth_context Authentication context
  2994. * @param [in] inbuf AP-REP message
  2995. * @param [out] nonce Sequence number from the decrypted reply
  2996. *
  2997. * This function parses, decrypts and verifies a message from @a inbuf and
  2998. * fills in @a nonce with a decrypted reply sequence number.
  2999. *
  3000. * @retval 0 Success; otherwise - Kerberos error codes
  3001. */
  3002. krb5_error_code KRB5_CALLCONV
  3003. krb5_rd_rep_dce(krb5_context context, krb5_auth_context auth_context,
  3004. const krb5_data *inbuf, krb5_ui_4 *nonce);
  3005. /**
  3006. * Format and encode a @c KRB_ERROR message.
  3007. *
  3008. * @param [in] context Library context
  3009. * @param [in] dec_err Error structure to be encoded
  3010. * @param [out] enc_err Encoded error structure
  3011. *
  3012. * This function creates a @c KRB_ERROR message in @a enc_err. Use
  3013. * krb5_free_data_contents() to free @a enc_err when it is no longer needed.
  3014. *
  3015. * @retval 0 Success; otherwise - Kerberos error codes
  3016. */
  3017. krb5_error_code KRB5_CALLCONV
  3018. krb5_mk_error(krb5_context context, const krb5_error *dec_err,
  3019. krb5_data *enc_err);
  3020. /**
  3021. * Decode a @c KRB-ERROR message.
  3022. *
  3023. * @param [in] context Library context
  3024. * @param [in] enc_errbuf Encoded error message
  3025. * @param [out] dec_error Decoded error message
  3026. *
  3027. * This function processes @c KRB-ERROR message @a enc_errbuf and returns
  3028. * an allocated structure @a dec_error containing the error message.
  3029. * Use krb5_free_error() to free @a dec_error when it is no longer needed.
  3030. *
  3031. * @retval 0 Success; otherwise - Kerberos error codes
  3032. */
  3033. krb5_error_code KRB5_CALLCONV
  3034. krb5_rd_error(krb5_context context, const krb5_data *enc_errbuf,
  3035. krb5_error **dec_error);
  3036. /**
  3037. * Process @c KRB-SAFE message.
  3038. *
  3039. * @param [in] context Library context
  3040. * @param [in,out] auth_context Authentication structure
  3041. * @param [in] inbuf @c KRB-SAFE message to be parsed
  3042. * @param [out] outbuf Data parsed from @c KRB-SAFE message
  3043. * @param [out] outdata Replay data. Specify NULL if not needed
  3044. *
  3045. * This function parses a @c KRB-SAFE message, verifies its integrity, and
  3046. * stores its data into @a outbuf.
  3047. *
  3048. * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
  3049. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.
  3050. *
  3051. * @note @a auth_context must have a remote address set. This address will be
  3052. * used to verify the sender address in the KRB-SAFE message. If @a
  3053. * auth_context has a local address set, it will be used to verify the
  3054. * receiver address in the KRB-SAFE message if the message contains one.
  3055. * Both addresses must use type @c ADDRTYPE_ADDRPORT.
  3056. *
  3057. * If the #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag is set in @a auth_context, the
  3058. * sequence number of the KRB-SAFE message is checked against the remote
  3059. * sequence number field of @a auth_context. Otherwise, the sequence number is
  3060. * not used.
  3061. *
  3062. * If the #KRB5_AUTH_CONTEXT_DO_TIME flag is set in @a auth_context,
  3063. * then two additional checks are performed:
  3064. * @li The timestamp in the message must be within the permitted clock skew
  3065. * (which is usually five minutes).
  3066. * @li The message must not be a replayed message field in @a auth_context.
  3067. *
  3068. * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
  3069. *
  3070. * @retval 0 Success; otherwise - Kerberos error codes
  3071. */
  3072. krb5_error_code KRB5_CALLCONV
  3073. krb5_rd_safe(krb5_context context, krb5_auth_context auth_context,
  3074. const krb5_data *inbuf, krb5_data *outbuf,
  3075. krb5_replay_data *outdata);
  3076. /**
  3077. * Process a @c KRB-PRIV message.
  3078. *
  3079. * @param [in] context Library context
  3080. * @param [in,out] auth_context Authentication structure
  3081. * @param [in] inbuf @c KRB-PRIV message to be parsed
  3082. * @param [out] outbuf Data parsed from @c KRB-PRIV message
  3083. * @param [out] outdata Replay data. Specify NULL if not needed
  3084. *
  3085. * This function parses a @c KRB-PRIV message, verifies its integrity, and
  3086. * stores its unencrypted data into @a outbuf.
  3087. *
  3088. * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or @c
  3089. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in @a auth_context, @a
  3090. * outdata is required.
  3091. *
  3092. * @note @a auth_context must have a remote address set. This address will be
  3093. * used to verify the sender address in the KRB-PRIV message. If @a
  3094. * auth_context has a local address set, it will be used to verify the
  3095. * receiver address in the KRB-PRIV message if the message contains one.
  3096. * Both addresses must use type @c ADDRTYPE_ADDRPORT.
  3097. *
  3098. * If the #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag is set in @a auth_context, the
  3099. * sequence number of the KRB-SAFE message is checked against the remote
  3100. * sequence number field of @a auth_context. Otherwise, the sequence number is
  3101. * not used.
  3102. *
  3103. * If the #KRB5_AUTH_CONTEXT_DO_TIME flag is set in @a auth_context,
  3104. * then two additional checks are performed:
  3105. * @li The timestamp in the message must be within the permitted clock skew
  3106. * (which is usually five minutes).
  3107. * @li The message must not be a replayed message field in @a auth_context.
  3108. *
  3109. * @retval 0 Success; otherwise - Kerberos error codes
  3110. */
  3111. krb5_error_code KRB5_CALLCONV
  3112. krb5_rd_priv(krb5_context context, krb5_auth_context auth_context,
  3113. const krb5_data *inbuf, krb5_data *outbuf,
  3114. krb5_replay_data *outdata);
  3115. /**
  3116. * Convert a string principal name to a krb5_principal structure.
  3117. *
  3118. * @param [in] context Library context
  3119. * @param [in] name String representation of a principal name
  3120. * @param [out] nprincipal Principal
  3121. *
  3122. * Convert a string representation of a principal name to a krb5_principal
  3123. * structure.
  3124. *
  3125. * A string representation of a Kerberos name consists of one or more principal
  3126. * name components, separated by slashes, optionally followed by the \@
  3127. * character and a realm name. If the realm name is not specified, the local
  3128. * realm is used.
  3129. *
  3130. * To use the slash and \@ symbols as part of a component (quoted) instead of
  3131. * using them as a component separator or as a realm prefix), put a backslash
  3132. * (\) character in front of the symbol. Similarly, newline, tab, backspace,
  3133. * and NULL characters can be included in a component by using @c n, @c t, @c b
  3134. * or @c 0, respectively.
  3135. *
  3136. * @note The realm in a Kerberos @a name cannot contain slash, colon,
  3137. * or NULL characters.
  3138. *
  3139. * Use krb5_free_principal() to free @a nprincipal when it is no longer needed.
  3140. *
  3141. * @retval
  3142. * 0 Success
  3143. * @return
  3144. * Kerberos error codes
  3145. */
  3146. krb5_error_code KRB5_CALLCONV
  3147. krb5_parse_name(krb5_context context, const char *name, krb5_principal *nprincipal);
  3148. #define KRB5_PRINCIPAL_PARSE_NO_REALM 0x1 /**< Error if realm is present */
  3149. #define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 /**< Error if realm is not present */
  3150. #define KRB5_PRINCIPAL_PARSE_ENTERPRISE 0x4 /**< Create single-component
  3151. enterprise principle */
  3152. /**
  3153. * Convert a string principal name to a krb5_principal with flags
  3154. *
  3155. * @param [in] context Library context
  3156. * @param [in] name String representation of a principal name
  3157. * @param [in] flags Flag
  3158. * @param [out] nprincipal Principal
  3159. *
  3160. * Similar to krb5_parse_name(), this function converts a single-string
  3161. * representation of a principal name to a krb5_principal structure.
  3162. *
  3163. * The following flags are valid:
  3164. * @li #KRB5_PRINCIPAL_PARSE_NO_REALM - no realm must be present in @a name
  3165. * @li #KRB5_PRINCIPAL_PARSE_REQUIRE_REALM - realm must be present in @a name
  3166. * @li #KRB5_PRINCIPAL_PARSE_ENTERPRISE - create single-component enterprise
  3167. * principal
  3168. *
  3169. * Use krb5_free_principal() to free @a nprincipal when it is no longer needed.
  3170. *
  3171. * @retval
  3172. * 0 Success
  3173. * @return
  3174. * Kerberos error codes
  3175. */
  3176. krb5_error_code KRB5_CALLCONV
  3177. krb5_parse_name_flags(krb5_context context, const char *name,
  3178. int flags, krb5_principal *nprincipal);
  3179. /**
  3180. * Convert a krb5_principal structure to a string representation.
  3181. *
  3182. * @param [in] context Library context
  3183. * @param [in] principal Principal
  3184. * @param [out] name String representation of principal name
  3185. *
  3186. * The resulting string representation uses the format and quoting conventions
  3187. * described for krb5_parse_name().
  3188. *
  3189. * Use krb5_free_unparsed_name() to free @a name when it is no longer needed.
  3190. *
  3191. * @retval
  3192. * 0 Success
  3193. * @return
  3194. * Kerberos error codes
  3195. */
  3196. krb5_error_code KRB5_CALLCONV
  3197. krb5_unparse_name(krb5_context context, krb5_const_principal principal,
  3198. register char **name);
  3199. /**
  3200. * Convert krb5_principal structure to string and length.
  3201. *
  3202. * @param [in] context Library context
  3203. * @param [in] principal Principal
  3204. * @param [out] name String representation of principal name
  3205. * @param [out] size Size of unparsed name
  3206. *
  3207. * This function is similar to krb5_unparse_name(), but also returns the length
  3208. * of the string representation.
  3209. *
  3210. * @retval
  3211. * 0 Success
  3212. * @return
  3213. * Kerberos error codes. On failure @a name is set to NULL
  3214. */
  3215. krb5_error_code KRB5_CALLCONV
  3216. krb5_unparse_name_ext(krb5_context context, krb5_const_principal principal,
  3217. char **name, unsigned int *size);
  3218. #define KRB5_PRINCIPAL_UNPARSE_SHORT 0x1 /**< Omit realm if it is the local realm */
  3219. #define KRB5_PRINCIPAL_UNPARSE_NO_REALM 0x2 /**< Omit realm always */
  3220. #define KRB5_PRINCIPAL_UNPARSE_DISPLAY 0x4 /**< Don't escape special characters */
  3221. /**
  3222. * Convert krb5_principal structure to a string with flags.
  3223. *
  3224. * @param [in] context Library context
  3225. * @param [in] principal Principal
  3226. * @param [in] flags Flags
  3227. * @param [out] name String representation of principal name
  3228. *
  3229. * Similar to krb5_unparse_name(), this function converts a krb5_principal
  3230. * structure to a string representation.
  3231. *
  3232. * The following flags are valid:
  3233. * @li #KRB5_PRINCIPAL_UNPARSE_SHORT - omit realm if it is the local realm
  3234. * @li #KRB5_PRINCIPAL_UNPARSE_NO_REALM - omit realm
  3235. * @li #KRB5_PRINCIPAL_UNPARSE_DISPLAY - do not quote special characters
  3236. *
  3237. * Use krb5_free_unparsed_name() to free @a name when it is no longer needed.
  3238. *
  3239. * @retval
  3240. * 0 Success
  3241. * @return
  3242. * Kerberos error codes. On failure @a name is set to NULL
  3243. */
  3244. krb5_error_code KRB5_CALLCONV
  3245. krb5_unparse_name_flags(krb5_context context, krb5_const_principal principal,
  3246. int flags, char **name);
  3247. /**
  3248. * Convert krb5_principal structure to string format with flags.
  3249. *
  3250. * @param [in] context Library context
  3251. * @param [in] principal Principal
  3252. * @param [in] flags Flags
  3253. * @param [out] name Single string format of principal name
  3254. * @param [out] size Size of unparsed name buffer
  3255. *
  3256. * @sa krb5_unparse_name() krb5_unparse_name_flags() krb5_unparse_name_ext()
  3257. *
  3258. * @retval
  3259. * 0 Success
  3260. * @return
  3261. * Kerberos error codes. On failure @a name is set to NULL
  3262. */
  3263. krb5_error_code KRB5_CALLCONV
  3264. krb5_unparse_name_flags_ext(krb5_context context, krb5_const_principal principal,
  3265. int flags, char **name, unsigned int *size);
  3266. /**
  3267. * Set the realm field of a principal
  3268. *
  3269. * @param [in,out] context Library context
  3270. * @param [in] principal Principal name
  3271. * @param [in] realm Realm name
  3272. *
  3273. * Set the realm name part of @a principal to @a realm, overwriting the
  3274. * previous realm.
  3275. *
  3276. * @retval
  3277. * 0 Success
  3278. * @return
  3279. * Kerberos error codes
  3280. */
  3281. krb5_error_code KRB5_CALLCONV
  3282. krb5_set_principal_realm(krb5_context context, krb5_principal principal,
  3283. const char *realm);
  3284. /**
  3285. * Search a list of addresses for a specified address.
  3286. *
  3287. * @param [in] context Library context
  3288. * @param [in] addr Address to search for
  3289. * @param [in] addrlist Address list to be searched (or NULL)
  3290. *
  3291. * @note If @a addrlist contains only a NetBIOS addresses, it will be treated
  3292. * as a null list.
  3293. *
  3294. * @return
  3295. * TRUE if @a addr is listed in @a addrlist, or @c addrlist is NULL; FALSE
  3296. * otherwise
  3297. */
  3298. krb5_boolean KRB5_CALLCONV_WRONG
  3299. krb5_address_search(krb5_context context, const krb5_address *addr,
  3300. krb5_address *const *addrlist);
  3301. /**
  3302. * Compare two Kerberos addresses.
  3303. *
  3304. * @param [in] context Library context
  3305. * @param [in] addr1 First address to be compared
  3306. * @param [in] addr2 Second address to be compared
  3307. *
  3308. * @return
  3309. * TRUE if the addresses are the same, FALSE otherwise
  3310. */
  3311. krb5_boolean KRB5_CALLCONV
  3312. krb5_address_compare(krb5_context context, const krb5_address *addr1,
  3313. const krb5_address *addr2);
  3314. /**
  3315. * Return an ordering of the specified addresses.
  3316. *
  3317. * @param [in] context Library context
  3318. * @param [in] addr1 First address
  3319. * @param [in] addr2 Second address
  3320. *
  3321. * @retval
  3322. * 0 The two addresses are the same
  3323. * @retval
  3324. * \< 0 First address is less than second
  3325. * @retval
  3326. * \> 0 First address is greater than second
  3327. */
  3328. int KRB5_CALLCONV
  3329. krb5_address_order(krb5_context context, const krb5_address *addr1,
  3330. const krb5_address *addr2);
  3331. /**
  3332. * Compare the realms of two principals.
  3333. *
  3334. * @param [in] context Library context
  3335. * @param [in] princ1 First principal
  3336. * @param [in] princ2 Second principal
  3337. *
  3338. * @retval
  3339. * TRUE if the realm names are the same; FALSE otherwise
  3340. */
  3341. krb5_boolean KRB5_CALLCONV
  3342. krb5_realm_compare(krb5_context context, krb5_const_principal princ1,
  3343. krb5_const_principal princ2);
  3344. /**
  3345. * Compare two principals.
  3346. *
  3347. * @param [in] context Library context
  3348. * @param [in] princ1 First principal
  3349. * @param [in] princ2 Second principal
  3350. *
  3351. * @retval
  3352. * TRUE if the principals are the same; FALSE otherwise
  3353. */
  3354. krb5_boolean KRB5_CALLCONV
  3355. krb5_principal_compare(krb5_context context,
  3356. krb5_const_principal princ1,
  3357. krb5_const_principal princ2);
  3358. /**
  3359. * Compare two principals ignoring realm components.
  3360. *
  3361. * @param [in] context Library context
  3362. * @param [in] princ1 First principal
  3363. * @param [in] princ2 Second principal
  3364. *
  3365. * Similar to krb5_principal_compare(), but do not compare the realm
  3366. * components of the principals.
  3367. *
  3368. * @retval
  3369. * TRUE if the principals are the same; FALSE otherwise
  3370. */
  3371. krb5_boolean KRB5_CALLCONV
  3372. krb5_principal_compare_any_realm(krb5_context context,
  3373. krb5_const_principal princ1,
  3374. krb5_const_principal princ2);
  3375. #define KRB5_PRINCIPAL_COMPARE_IGNORE_REALM 1 /**< ignore realm component */
  3376. #define KRB5_PRINCIPAL_COMPARE_ENTERPRISE 2 /**< UPNs as real principals */
  3377. #define KRB5_PRINCIPAL_COMPARE_CASEFOLD 4 /**< case-insensitive */
  3378. #define KRB5_PRINCIPAL_COMPARE_UTF8 8 /**< treat principals as UTF-8 */
  3379. /**
  3380. * Compare two principals with additional flags.
  3381. *
  3382. * @param [in] context Library context
  3383. * @param [in] princ1 First principal
  3384. * @param [in] princ2 Second principal
  3385. * @param [in] flags Flags
  3386. *
  3387. * Valid flags are:
  3388. * @li #KRB5_PRINCIPAL_COMPARE_IGNORE_REALM - ignore realm component
  3389. * @li #KRB5_PRINCIPAL_COMPARE_ENTERPRISE - UPNs as real principals
  3390. * @li #KRB5_PRINCIPAL_COMPARE_CASEFOLD case-insensitive
  3391. * @li #KRB5_PRINCIPAL_COMPARE_UTF8 - treat principals as UTF-8
  3392. *
  3393. * @sa krb5_principal_compare()
  3394. *
  3395. * @retval
  3396. * TRUE if the principal names are the same; FALSE otherwise
  3397. */
  3398. krb5_boolean KRB5_CALLCONV
  3399. krb5_principal_compare_flags(krb5_context context,
  3400. krb5_const_principal princ1,
  3401. krb5_const_principal princ2,
  3402. int flags);
  3403. /**
  3404. * Initialize an empty @c krb5_keyblock.
  3405. *
  3406. * @param [in] context Library context
  3407. * @param [in] enctype Encryption type
  3408. * @param [in] length Length of keyblock (or 0)
  3409. * @param [out] out New keyblock structure
  3410. *
  3411. * Initialize a new keyblock and allocate storage for the contents of the key.
  3412. * It is legal to pass in a length of 0, in which case contents are left
  3413. * unallocated. Use krb5_free_keyblock() to free @a out when it is no longer
  3414. * needed.
  3415. *
  3416. * @note If @a length is set to 0, contents are left unallocated.
  3417. *
  3418. * @retval 0 Success; otherwise - Kerberos error codes
  3419. */
  3420. krb5_error_code KRB5_CALLCONV
  3421. krb5_init_keyblock(krb5_context context, krb5_enctype enctype,
  3422. size_t length, krb5_keyblock **out);
  3423. /**
  3424. * Copy a keyblock.
  3425. *
  3426. * @param [in] context Library context
  3427. * @param [in] from Keyblock to be copied
  3428. * @param [out] to Copy of keyblock @a from
  3429. *
  3430. * This function creates a new keyblock with the same contents as @a from. Use
  3431. * krb5_free_keyblock() to free @a to when it is no longer needed.
  3432. *
  3433. * @retval 0 Success; otherwise - Kerberos error codes
  3434. */
  3435. krb5_error_code KRB5_CALLCONV
  3436. krb5_copy_keyblock(krb5_context context, const krb5_keyblock *from,
  3437. krb5_keyblock **to);
  3438. /**
  3439. * Copy the contents of a keyblock.
  3440. *
  3441. * @param [in] context Library context
  3442. * @param [in] from Key to be copied
  3443. * @param [out] to Output key
  3444. *
  3445. * This function copies the contents of @a from to @a to. Use
  3446. * krb5_free_keyblock_contents() to free @a to when it is no longer needed.
  3447. *
  3448. * @retval 0 Success; otherwise - Kerberos error codes
  3449. */
  3450. krb5_error_code KRB5_CALLCONV
  3451. krb5_copy_keyblock_contents(krb5_context context, const krb5_keyblock *from,
  3452. krb5_keyblock *to);
  3453. /**
  3454. * Copy a krb5_creds structure.
  3455. *
  3456. * @param [in] context Library context
  3457. * @param [in] incred Credentials structure to be copied
  3458. * @param [out] outcred Copy of @a incred
  3459. *
  3460. * This function creates a new credential with the contents of @a incred. Use
  3461. * krb5_free_creds() to free @a outcred when it is no longer needed.
  3462. *
  3463. * @retval 0 Success; otherwise - Kerberos error codes
  3464. */
  3465. krb5_error_code KRB5_CALLCONV
  3466. krb5_copy_creds(krb5_context context, const krb5_creds *incred, krb5_creds **outcred);
  3467. /**
  3468. * Copy a krb5_data object.
  3469. *
  3470. * @param [in] context Library context
  3471. * @param [in] indata Data object to be copied
  3472. * @param [out] outdata Copy of @a indata
  3473. *
  3474. * This function creates a new krb5_data object with the contents of @a indata.
  3475. * Use krb5_free_data() to free @a outdata when it is no longer needed.
  3476. *
  3477. * @retval 0 Success; otherwise - Kerberos error codes
  3478. */
  3479. krb5_error_code KRB5_CALLCONV
  3480. krb5_copy_data(krb5_context context, const krb5_data *indata, krb5_data **outdata);
  3481. /**
  3482. * Copy a principal.
  3483. *
  3484. * @param [in] context Library context
  3485. * @param [in] inprinc Principal to be copied
  3486. * @param [out] outprinc Copy of @a inprinc
  3487. *
  3488. * This function creates a new principal structure with the contents of @a
  3489. * inprinc. Use krb5_free_principal() to free @a outprinc when it is no longer
  3490. * needed.
  3491. *
  3492. * @retval 0 Success; otherwise - Kerberos error codes
  3493. */
  3494. krb5_error_code KRB5_CALLCONV
  3495. krb5_copy_principal(krb5_context context, krb5_const_principal inprinc,
  3496. krb5_principal *outprinc);
  3497. /**
  3498. * Copy an array of addresses.
  3499. *
  3500. * @param [in] context Library context
  3501. * @param [in] inaddr Array of addresses to be copied
  3502. * @param [out] outaddr Copy of array of addresses
  3503. *
  3504. * This function creates a new address array containing a copy of @a inaddr.
  3505. * Use krb5_free_addresses() to free @a outaddr when it is no longer needed.
  3506. *
  3507. * @retval 0 Success; otherwise - Kerberos error codes
  3508. */
  3509. krb5_error_code KRB5_CALLCONV
  3510. krb5_copy_addresses(krb5_context context, krb5_address *const *inaddr,
  3511. krb5_address ***outaddr);
  3512. /**
  3513. * Copy a krb5_ticket structure.
  3514. *
  3515. * @param [in] context Library context
  3516. * @param [in] from Ticket to be copied
  3517. * @param [out] pto Copy of ticket
  3518. *
  3519. * This function creates a new krb5_ticket structure containing the contents of
  3520. * @a from. Use krb5_free_ticket() to free @a pto when it is no longer needed.
  3521. *
  3522. * @retval 0 Success; otherwise - Kerberos error codes
  3523. */
  3524. krb5_error_code KRB5_CALLCONV
  3525. krb5_copy_ticket(krb5_context context, const krb5_ticket *from, krb5_ticket **pto);
  3526. /**
  3527. * Copy an authorization data list.
  3528. *
  3529. * @param [in] context Library context
  3530. * @param [in] in_authdat List of @a krb5_authdata structures
  3531. * @param [out] out New array of @a krb5_authdata structures
  3532. *
  3533. * This function creates a new authorization data list containing a copy of @a
  3534. * in_authdat, which must be null-terminated. Use krb5_free_authdata() to free
  3535. * @a out when it is no longer needed.
  3536. *
  3537. * @note The last array entry in @a in_authdat must be a NULL pointer.
  3538. *
  3539. * @retval 0 Success; otherwise - Kerberos error codes
  3540. */
  3541. krb5_error_code KRB5_CALLCONV
  3542. krb5_copy_authdata(krb5_context context,
  3543. krb5_authdata *const *in_authdat, krb5_authdata ***out);
  3544. /**
  3545. * Find authorization data elements.
  3546. *
  3547. * @param [in] context Library context
  3548. * @param [in] ticket_authdata Authorization data list from ticket
  3549. * @param [in] ap_req_authdata Authorization data list from AP request
  3550. * @param [in] ad_type Authorization data type to find
  3551. * @param [out] results List of matching entries
  3552. *
  3553. * This function searches @a ticket_authdata and @a ap_req_authdata for
  3554. * elements of type @a ad_type. Either input list may be NULL, in which case
  3555. * it will not be searched; otherwise, the input lists must be terminated by
  3556. * NULL entries. This function will search inside AD-IF-RELEVANT containers if
  3557. * found in either list. Use krb5_free_authdata() to free @a results when it
  3558. * is no longer needed.
  3559. */
  3560. krb5_error_code KRB5_CALLCONV
  3561. krb5_find_authdata(krb5_context context, krb5_authdata *const *ticket_authdata,
  3562. krb5_authdata *const *ap_req_authdata,
  3563. krb5_authdatatype ad_type, krb5_authdata ***results);
  3564. /**
  3565. * Merge two authorization data lists into a new list.
  3566. *
  3567. * @param [in] context Library context
  3568. * @param [in] inauthdat1 First list of @a krb5_authdata structures
  3569. * @param [in] inauthdat2 Second list of @a krb5_authdata structures
  3570. * @param [out] outauthdat Merged list of @a krb5_authdata structures
  3571. *
  3572. * Merge two authdata arrays, such as the array from a ticket
  3573. * and authenticator.
  3574. * Use krb5_free_authdata() to free @a outauthdat when it is no longer needed.
  3575. *
  3576. * @note The last array entry in @a inauthdat1 and @a inauthdat2
  3577. * must be a NULL pointer.
  3578. *
  3579. * @retval 0 Success; otherwise - Kerberos error codes
  3580. */
  3581. krb5_error_code KRB5_CALLCONV
  3582. krb5_merge_authdata(krb5_context context,
  3583. krb5_authdata *const *inauthdat1,
  3584. krb5_authdata * const *inauthdat2,
  3585. krb5_authdata ***outauthdat);
  3586. /**
  3587. * Copy a krb5_authenticator structure.
  3588. *
  3589. * @param [in] context Library context
  3590. * @param [in] authfrom krb5_authenticator structure to be copied
  3591. * @param [out] authto Copy of krb5_authenticator structure
  3592. *
  3593. * This function creates a new krb5_authenticator structure with the content of
  3594. * @a authfrom. Use krb5_free_authenticator() to free @a authto when it is no
  3595. * longer needed.
  3596. *
  3597. * @retval 0 Success; otherwise - Kerberos error codes
  3598. */
  3599. krb5_error_code KRB5_CALLCONV
  3600. krb5_copy_authenticator(krb5_context context, const krb5_authenticator *authfrom,
  3601. krb5_authenticator **authto);
  3602. /**
  3603. * Copy a krb5_checksum structure.
  3604. *
  3605. * @param [in] context Library context
  3606. * @param [in] ckfrom Checksum to be copied
  3607. * @param [out] ckto Copy of krb5_checksum structure
  3608. *
  3609. * This function creates a new krb5_checksum structure with the contents of @a
  3610. * ckfrom. Use krb5_free_checksum() to free @a ckto when it is no longer
  3611. * needed.
  3612. *
  3613. * @retval 0 Success; otherwise - Kerberos error codes
  3614. */
  3615. krb5_error_code KRB5_CALLCONV
  3616. krb5_copy_checksum(krb5_context context, const krb5_checksum *ckfrom,
  3617. krb5_checksum **ckto);
  3618. /**
  3619. * Generate a replay cache object for server use and open it.
  3620. *
  3621. * @param [in] context Library context
  3622. * @param [in] piece Unique identifier for replay cache
  3623. * @param [out] rcptr Handle to an open rcache
  3624. *
  3625. * This function generates a replay cache name based on @a piece and opens a
  3626. * handle to it. Typically @a piece is the first component of the service
  3627. * principal name. Use krb5_rc_close() to close @a rcptr when it is no longer
  3628. * needed.
  3629. *
  3630. * @retval 0 Success; otherwise - Kerberos error codes
  3631. */
  3632. krb5_error_code KRB5_CALLCONV
  3633. krb5_get_server_rcache(krb5_context context, const krb5_data *piece,
  3634. krb5_rcache *rcptr);
  3635. /**
  3636. * Build a principal name using length-counted strings.
  3637. *
  3638. * @param [in] context Library context
  3639. * @param [out] princ Principal name
  3640. * @param [in] rlen Realm name length
  3641. * @param [in] realm Realm name
  3642. * @param [in] ... List of unsigned int/char * components, followed by 0
  3643. *
  3644. * This function creates a principal from a length-counted string and a
  3645. * variable-length list of length-counted components. The list of components
  3646. * ends with the first 0 length argument (so it is not possible to specify an
  3647. * empty component with this function). Call krb5_free_principal() to free
  3648. * allocated memory for principal when it is no longer needed.
  3649. *
  3650. * @code
  3651. * Example of how to build principal WELLKNOWN/ANONYMOUS@R
  3652. * krb5_build_principal_ext(context, &principal, strlen("R"), "R",
  3653. * (unsigned int)strlen(KRB5_WELLKNOWN_NAMESTR),
  3654. * KRB5_WELLKNOWN_NAMESTR,
  3655. * (unsigned int)strlen(KRB5_ANONYMOUS_PRINCSTR),
  3656. * KRB5_ANONYMOUS_PRINCSTR, 0);
  3657. * @endcode
  3658. *
  3659. * @retval
  3660. * 0 Success
  3661. * @return
  3662. * Kerberos error codes
  3663. */
  3664. krb5_error_code KRB5_CALLCONV_C
  3665. krb5_build_principal_ext(krb5_context context, krb5_principal * princ,
  3666. unsigned int rlen, const char * realm, ...);
  3667. /**
  3668. * Build a principal name using null-terminated strings.
  3669. *
  3670. * @param [in] context Library context
  3671. * @param [out] princ Principal name
  3672. * @param [in] rlen Realm name length
  3673. * @param [in] realm Realm name
  3674. * @param [in] ... List of char * components, ending with NULL
  3675. *
  3676. * Call krb5_free_principal() to free @a princ when it is no longer needed.
  3677. *
  3678. * @note krb5_build_principal() and krb5_build_principal_alloc_va() perform the
  3679. * same task. krb5_build_principal() takes variadic arguments.
  3680. * krb5_build_principal_alloc_va() takes a pre-computed @a varargs pointer.
  3681. *
  3682. * @code
  3683. * Example of how to build principal H/S@R
  3684. * krb5_build_principal(context, &principal,
  3685. * strlen("R"), "R", "H", "S", (char*)NULL);
  3686. * @endcode
  3687. *
  3688. * @retval
  3689. * 0 Success
  3690. * @return
  3691. * Kerberos error codes
  3692. */
  3693. krb5_error_code KRB5_CALLCONV_C
  3694. krb5_build_principal(krb5_context context,
  3695. krb5_principal * princ,
  3696. unsigned int rlen,
  3697. const char * realm, ...)
  3698. #if __GNUC__ >= 4
  3699. __attribute__ ((sentinel))
  3700. #endif
  3701. ;
  3702. #if KRB5_DEPRECATED
  3703. /** @deprecated Replaced by krb5_build_principal_alloc_va(). */
  3704. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  3705. krb5_build_principal_va(krb5_context context,
  3706. krb5_principal princ,
  3707. unsigned int rlen,
  3708. const char *realm,
  3709. va_list ap);
  3710. #endif
  3711. /**
  3712. * Build a principal name, using a precomputed variable argument list
  3713. *
  3714. * @param [in] context Library context
  3715. * @param [out] princ Principal structure
  3716. * @param [in] rlen Realm name length
  3717. * @param [in] realm Realm name
  3718. * @param [in] ap List of char * components, ending with NULL
  3719. *
  3720. * Similar to krb5_build_principal(), this function builds a principal name,
  3721. * but its name components are specified as a va_list.
  3722. *
  3723. * Use krb5_free_principal() to deallocate @a princ when it is no longer
  3724. * needed.
  3725. *
  3726. * @code
  3727. * Function usage example:
  3728. * va_list ap;
  3729. * va_start(ap, realm);
  3730. * krb5_build_principal_alloc_va(context, princ, rlen, realm, ap);
  3731. * va_end(ap);
  3732. * @endcode
  3733. *
  3734. * @retval
  3735. * 0 Success
  3736. * @return
  3737. * Kerberos error codes
  3738. */
  3739. krb5_error_code KRB5_CALLCONV
  3740. krb5_build_principal_alloc_va(krb5_context context,
  3741. krb5_principal *princ,
  3742. unsigned int rlen,
  3743. const char *realm,
  3744. va_list ap);
  3745. /**
  3746. * Convert a Kerberos V4 principal to a Kerberos V5 principal.
  3747. *
  3748. * @param [in] context Library context
  3749. * @param [in] name V4 name
  3750. * @param [in] instance V4 instance
  3751. * @param [in] realm Realm
  3752. * @param [out] princ V5 principal
  3753. *
  3754. * This function builds a @a princ from V4 specification based on given input
  3755. * @a name.instance\@realm.
  3756. *
  3757. * Use krb5_free_principal() to free @a princ when it is no longer needed.
  3758. *
  3759. * @retval 0 Success; otherwise - Kerberos error codes
  3760. */
  3761. krb5_error_code KRB5_CALLCONV
  3762. krb5_425_conv_principal(krb5_context context, const char *name,
  3763. const char *instance, const char *realm,
  3764. krb5_principal *princ);
  3765. /**
  3766. * Convert a Kerberos V5 principal to a Kerberos V4 principal.
  3767. *
  3768. * @param [in] context Library context
  3769. * @param [in] princ V5 Principal
  3770. * @param [out] name V4 principal's name to be filled in
  3771. * @param [out] inst V4 principal's instance name to be filled in
  3772. * @param [out] realm Principal's realm name to be filled in
  3773. *
  3774. * This function separates a V5 principal @a princ into @a name, @a instance,
  3775. * and @a realm.
  3776. *
  3777. * @retval
  3778. * 0 Success
  3779. * @retval
  3780. * KRB5_INVALID_PRINCIPAL Invalid principal name
  3781. * @retval
  3782. * KRB5_CONFIG_CANTOPEN Can't open or find Kerberos configuration file
  3783. * @return
  3784. * Kerberos error codes
  3785. */
  3786. krb5_error_code KRB5_CALLCONV
  3787. krb5_524_conv_principal(krb5_context context, krb5_const_principal princ,
  3788. char *name, char *inst, char *realm);
  3789. /**
  3790. *@deprecated
  3791. */
  3792. struct credentials;
  3793. /**
  3794. * Convert a Kerberos V5 credentials to a Kerberos V4 credentials
  3795. *
  3796. * @note Not implemented
  3797. *
  3798. * @retval KRB524_KRB4_DISABLED (always)
  3799. */
  3800. int KRB5_CALLCONV
  3801. krb5_524_convert_creds(krb5_context context, krb5_creds *v5creds,
  3802. struct credentials *v4creds);
  3803. #if KRB5_DEPRECATED
  3804. #define krb524_convert_creds_kdc krb5_524_convert_creds
  3805. #define krb524_init_ets(x) (0)
  3806. #endif
  3807. /* libkt.spec */
  3808. /**
  3809. * Get a handle for a key table.
  3810. *
  3811. * @param [in] context Library context
  3812. * @param [in] name Name of the key table
  3813. * @param [out] ktid Key table handle
  3814. *
  3815. * Resolve the key table name @a name and fill in a handle identifying the key
  3816. * table. The key table is not opened.
  3817. *
  3818. * @note @a name must be of the form @c type:residual, where @a type must be a
  3819. * type known to the library and @a residual portion should be specific to the
  3820. * particular keytab type.
  3821. *
  3822. * @sa krb5_kt_close()
  3823. *
  3824. * @code
  3825. * Example: krb5_kt_resolve(context, "FILE:/tmp/filename",&ktid);
  3826. * @endcode
  3827. *
  3828. * @retval
  3829. * 0 Success
  3830. * @return
  3831. * Kerberos error codes
  3832. */
  3833. krb5_error_code KRB5_CALLCONV
  3834. krb5_kt_resolve(krb5_context context, const char *name, krb5_keytab *ktid);
  3835. /**
  3836. * Get default key table name.
  3837. *
  3838. * @param [in] context Library context
  3839. * @param [in,out] name Key table name to be resolved
  3840. * @param [in] name_size Size of @a name to return
  3841. *
  3842. * Fill @a name with the first @a name_size bytes of the name of the default
  3843. * key table for the current user.
  3844. *
  3845. * @sa MAX_KEYTAB_NAME_LEN
  3846. *
  3847. * @retval
  3848. * 0 Success
  3849. * @retval
  3850. * KRB5_CONFIG_NOTENUFSPACE Buffer is too short
  3851. * @return
  3852. * Kerberos error codes
  3853. */
  3854. krb5_error_code KRB5_CALLCONV
  3855. krb5_kt_default_name(krb5_context context, char *name, int name_size);
  3856. /**
  3857. * Resolve default key table.
  3858. *
  3859. * @param [in] context Library context
  3860. * @param [in,out] id Key table handle
  3861. *
  3862. * Fill @a keytab with the default key table's @a handle.
  3863. *
  3864. * @retval
  3865. * 0 Success
  3866. * @return
  3867. * Kerberos error codes
  3868. */
  3869. krb5_error_code KRB5_CALLCONV
  3870. krb5_kt_default(krb5_context context, krb5_keytab *id);
  3871. /**
  3872. * Free the contents of a key table entry.
  3873. *
  3874. * @param [in] context Library context
  3875. * @param [in] entry Key table entry whose contents are to be freed
  3876. *
  3877. * @note The pointer is not freed.
  3878. *
  3879. * @retval 0 Success; otherwise - Kerberos error codes
  3880. */
  3881. krb5_error_code KRB5_CALLCONV
  3882. krb5_free_keytab_entry_contents(krb5_context context, krb5_keytab_entry *entry);
  3883. /** @deprecated Use krb5_free_keytab_entry_contents instead. */
  3884. krb5_error_code KRB5_CALLCONV
  3885. krb5_kt_free_entry(krb5_context context, krb5_keytab_entry *entry);
  3886. /* remove and add are functions, so that they can return NOWRITE
  3887. if not a writable keytab */
  3888. /**
  3889. * Remove an entry from a key table.
  3890. *
  3891. * @param [in] context Library context
  3892. * @param [in] id Key table handle
  3893. * @param [in] entry Entry to remove from key table
  3894. *
  3895. * @retval
  3896. * 0 Success
  3897. * @retval
  3898. * KRB5_KT_NOWRITE Key table is not writable
  3899. * @return
  3900. * Kerberos error codes
  3901. */
  3902. krb5_error_code KRB5_CALLCONV
  3903. krb5_kt_remove_entry(krb5_context context, krb5_keytab id, krb5_keytab_entry *entry);
  3904. /**
  3905. * Add a new entry to a key table.
  3906. *
  3907. * @param [in] context Library context
  3908. * @param [in] id Key table handle
  3909. * @param [in] entry Entry to be added
  3910. *
  3911. * @retval
  3912. * 0 Success
  3913. * @retval
  3914. * ENOMEM Insufficient memory
  3915. * @retval
  3916. * KRB5_KT_NOWRITE Key table is not writeable
  3917. * @return
  3918. * Kerberos error codes
  3919. */
  3920. krb5_error_code KRB5_CALLCONV
  3921. krb5_kt_add_entry(krb5_context context, krb5_keytab id, krb5_keytab_entry *entry);
  3922. /**
  3923. * Convert a principal name into the default salt for that principal.
  3924. *
  3925. * @param [in] context Library context
  3926. * @param [in] pr Principal name
  3927. * @param [out] ret Default salt for @a pr to be filled in
  3928. *
  3929. * @retval 0 Success; otherwise - Kerberos error codes
  3930. */
  3931. krb5_error_code KRB5_CALLCONV_WRONG
  3932. krb5_principal2salt(krb5_context context,
  3933. register krb5_const_principal pr, krb5_data *ret);
  3934. /* librc.spec--see rcache.h */
  3935. /* libcc.spec */
  3936. /**
  3937. * Resolve a credential cache name.
  3938. *
  3939. * @param [in] context Library context
  3940. * @param [in] name Credential cache name to be resolved
  3941. * @param [out] cache Credential cache handle
  3942. *
  3943. * Fills in @a cache with a @a cache handle that corresponds to the name in @a
  3944. * name. @a name should be of the form @c type:residual, and @a type must be a
  3945. * type known to the library. If the @a name does not contain a colon,
  3946. * interpret it as a file name.
  3947. *
  3948. * @code
  3949. * Example: krb5_cc_resolve(context, "MEMORY:C_", &cache);
  3950. * @endcode
  3951. *
  3952. * @retval
  3953. * 0 Success
  3954. * @return
  3955. * Kerberos error codes
  3956. */
  3957. krb5_error_code KRB5_CALLCONV
  3958. krb5_cc_resolve(krb5_context context, const char *name, krb5_ccache *cache);
  3959. /**
  3960. * Duplicate ccache handle.
  3961. *
  3962. * @param [in] context Library context
  3963. * @param [in] in Credential cache handle to be duplicated
  3964. * @param [out] out Credential cache handle
  3965. *
  3966. * Create a new handle referring to the same cache as @a in.
  3967. * The new handle and @a in can be closed independently.
  3968. */
  3969. krb5_error_code KRB5_CALLCONV
  3970. krb5_cc_dup(krb5_context context, krb5_ccache in, krb5_ccache *out);
  3971. /**
  3972. * Return the name of the default credential cache.
  3973. *
  3974. * @param [in] context Library context
  3975. *
  3976. * Try the environment variable KRB5CCNAME first then, if it is not set,
  3977. * fall back on the default ccache name for the OS.
  3978. *
  3979. * @return
  3980. * Name of default credential cache for the current user.
  3981. */
  3982. const char *KRB5_CALLCONV
  3983. krb5_cc_default_name(krb5_context context);
  3984. /**
  3985. * Set the default credential cache name.
  3986. *
  3987. * @param [in,out] context Library context
  3988. * @param [in] name Default credential cache name
  3989. *
  3990. * This function frees the old default credential cache name and then sets it
  3991. * to @a name.
  3992. *
  3993. * @retval
  3994. * 0 Success
  3995. * @retval
  3996. * KV5M_CONTEXT Bad magic number for @c _krb5_context structure
  3997. * @return
  3998. * Kerberos error codes
  3999. */
  4000. krb5_error_code KRB5_CALLCONV
  4001. krb5_cc_set_default_name(krb5_context context, const char *name);
  4002. /**
  4003. * Resolve the default crendentials cache name.
  4004. *
  4005. * @param [in,out] context Library context
  4006. * @param [out] ccache Pointer to credential cache name
  4007. *
  4008. * @retval
  4009. * 0 Success
  4010. * @retval
  4011. * KV5M_CONTEXT Bad magic number for @c _krb5_context structure
  4012. * @retval
  4013. * KRB5_FCC_INTERNAL The name of the default credential cache cannot be
  4014. * obtained
  4015. * @return
  4016. * Kerberos error codes
  4017. */
  4018. krb5_error_code KRB5_CALLCONV
  4019. krb5_cc_default(krb5_context context, krb5_ccache *ccache);
  4020. /**
  4021. * Copy a credential cache.
  4022. *
  4023. * @param [in] context Library context
  4024. * @param [in] incc Credential cache to be copied
  4025. * @param [out] outcc Copy of credential cache to be filled in
  4026. *
  4027. * @retval 0 Success; otherwise - Kerberos error codes
  4028. */
  4029. krb5_error_code KRB5_CALLCONV
  4030. krb5_cc_copy_creds(krb5_context context, krb5_ccache incc, krb5_ccache outcc);
  4031. /**
  4032. * Get a configuration value from a credential cache.
  4033. *
  4034. * @param [in] context Library context
  4035. * @param [in] id Credential cache handle
  4036. * @param [in] principal Configuration for this principal;
  4037. * if NULL, global for the whole cache
  4038. * @param [in] key Name of config variable
  4039. * @param [out] data Data to be fetched
  4040. *
  4041. * Use krb5_free_data_contents() to free @a data when it is no longer needed.
  4042. *
  4043. * @retval
  4044. * 0 Success
  4045. * @return
  4046. * Kerberos error codes
  4047. */
  4048. krb5_error_code KRB5_CALLCONV
  4049. krb5_cc_get_config(krb5_context context, krb5_ccache id,
  4050. krb5_const_principal principal,
  4051. const char *key, krb5_data *data);
  4052. /**
  4053. * Store a configuration value in a credential cache.
  4054. *
  4055. * @param [in] context Library context
  4056. * @param [in] id Credential cache handle
  4057. * @param [in] principal Configuration for a specific principal;
  4058. * if NULL, global for the whole cache
  4059. * @param [in] key Name of config variable
  4060. * @param [in] data Data to store, or NULL to remove
  4061. *
  4062. * @note Existing configuration under the same key is over-written.
  4063. *
  4064. * @warning Before version 1.10 @a data was assumed to be always non-null.
  4065. *
  4066. * @retval
  4067. * 0 Success
  4068. * @return
  4069. * Kerberos error codes
  4070. */
  4071. krb5_error_code KRB5_CALLCONV
  4072. krb5_cc_set_config(krb5_context context, krb5_ccache id,
  4073. krb5_const_principal principal,
  4074. const char *key, krb5_data *data);
  4075. /**
  4076. * Test whether a principal is a configuration principal.
  4077. *
  4078. * @param [in] context Library context
  4079. * @param [in] principal Principal to check
  4080. *
  4081. * @return
  4082. * @c TRUE if the principal is a configuration principal (generated part of
  4083. * krb5_cc_set_config()); @c FALSE otherwise.
  4084. */
  4085. krb5_boolean KRB5_CALLCONV
  4086. krb5_is_config_principal(krb5_context context, krb5_const_principal principal);
  4087. /**
  4088. * Make a credential cache the primary cache for its collection.
  4089. *
  4090. * @param [in] context Library context
  4091. * @param [in] cache Credential cache handle
  4092. *
  4093. * If the type of @a cache supports it, set @a cache to be the primary
  4094. * credential cache for the collection it belongs to.
  4095. *
  4096. * @retval
  4097. * 0 Success, or the type of @a cache doesn't support switching
  4098. * @return
  4099. * Kerberos error codes
  4100. */
  4101. krb5_error_code KRB5_CALLCONV
  4102. krb5_cc_switch(krb5_context context, krb5_ccache cache);
  4103. /**
  4104. * Determine whether a credential cache type supports switching.
  4105. *
  4106. * @param [in] context Library context
  4107. * @param [in] type Credential cache type
  4108. *
  4109. * @retval TRUE if @a type supports switching
  4110. * @retval FALSE if it does not or is not a valid credential cache type.
  4111. */
  4112. krb5_boolean KRB5_CALLCONV
  4113. krb5_cc_support_switch(krb5_context context, const char *type);
  4114. /**
  4115. * Find a credential cache with a specified client principal.
  4116. *
  4117. * @param [in] context Library context
  4118. * @param [in] client Client principal
  4119. * @param [out] cache_out Credential cache handle
  4120. *
  4121. * Find a cache within the collection whose default principal is @a client.
  4122. * Use @a krb5_cc_close to close @a ccache when it is no longer needed.
  4123. *
  4124. * @retval 0 Success
  4125. * @retval KRB5_CC_NOTFOUND
  4126. *
  4127. * @sa krb5_cccol_cursor_new
  4128. */
  4129. krb5_error_code KRB5_CALLCONV
  4130. krb5_cc_cache_match(krb5_context context, krb5_principal client,
  4131. krb5_ccache *cache_out);
  4132. /**
  4133. * Select a credential cache to use with a server principal.
  4134. *
  4135. * @param [in] context Library context
  4136. * @param [in] server Server principal
  4137. * @param [out] cache_out Credential cache handle
  4138. * @param [out] princ_out Client principal
  4139. *
  4140. * Select a cache within the collection containing credentials most appropriate
  4141. * for use with @a server, according to configured rules and heuristics.
  4142. *
  4143. * Use krb5_cc_close() to release @a cache_out when it is no longer needed.
  4144. * Use krb5_free_principal() to release @a princ_out when it is no longer
  4145. * needed. Note that @a princ_out is set in some error conditions.
  4146. *
  4147. * @return
  4148. * If an appropriate cache is found, 0 is returned, @a cache_out is set to the
  4149. * selected cache, and @a princ_out is set to the default principal of that
  4150. * cache.
  4151. *
  4152. * If the appropriate client principal can be authoritatively determined but
  4153. * the cache collection contains no credentials for that principal, then
  4154. * KRB5_CC_NOTFOUND is returned, @a cache_out is set to NULL, and @a princ_out
  4155. * is set to the appropriate client principal.
  4156. *
  4157. * If no configured mechanism can determine the appropriate cache or principal,
  4158. * KRB5_CC_NOTFOUND is returned and @a cache_out and @a princ_out are set to
  4159. * NULL.
  4160. *
  4161. * Any other error code indicates a fatal error in the processing of a cache
  4162. * selection mechanism.
  4163. */
  4164. krb5_error_code KRB5_CALLCONV
  4165. krb5_cc_select(krb5_context context, krb5_principal server,
  4166. krb5_ccache *cache_out, krb5_principal *princ_out);
  4167. /* krb5_free.c */
  4168. /**
  4169. * Free the storage assigned to a principal.
  4170. *
  4171. * @param [in] context Library context
  4172. * @param [in] val Principal to be freed
  4173. */
  4174. void KRB5_CALLCONV
  4175. krb5_free_principal(krb5_context context, krb5_principal val);
  4176. /**
  4177. * Free a krb5_authenticator structure.
  4178. *
  4179. * @param [in] context Library context
  4180. * @param [in] val Authenticator structure to be freed
  4181. *
  4182. * This function frees the contents of @a val and the structure itself.
  4183. */
  4184. void KRB5_CALLCONV
  4185. krb5_free_authenticator(krb5_context context, krb5_authenticator *val);
  4186. /**
  4187. * Free the data stored in array of addresses.
  4188. *
  4189. * @param [in] context Library context
  4190. * @param [in] val Array of addresses to be freed
  4191. *
  4192. * This function frees the contents of @a val and the array itself.
  4193. *
  4194. * @note The last entry in the array must be a NULL pointer.
  4195. */
  4196. void KRB5_CALLCONV
  4197. krb5_free_addresses(krb5_context context, krb5_address **val);
  4198. /**
  4199. * Free the storage assigned to array of authentication data.
  4200. *
  4201. * @param [in] context Library context
  4202. * @param [in] val Array of authentication data to be freed
  4203. *
  4204. * This function frees the contents of @a val and the array itself.
  4205. *
  4206. * @note The last entry in the array must be a NULL pointer.
  4207. */
  4208. void KRB5_CALLCONV
  4209. krb5_free_authdata(krb5_context context, krb5_authdata **val);
  4210. /**
  4211. * Free a ticket.
  4212. *
  4213. * @param [in] context Library context
  4214. * @param [in] val Ticket to be freed
  4215. *
  4216. * This function frees the contents of @a val and the structure itself.
  4217. */
  4218. void KRB5_CALLCONV
  4219. krb5_free_ticket(krb5_context context, krb5_ticket *val);
  4220. /**
  4221. * Free an error allocated by krb5_read_error() or krb5_sendauth().
  4222. *
  4223. * @param [in] context Library context
  4224. * @param [in] val Error data structure to be freed
  4225. *
  4226. * This function frees the contents of @a val and the structure itself.
  4227. */
  4228. void KRB5_CALLCONV
  4229. krb5_free_error(krb5_context context, register krb5_error *val);
  4230. /**
  4231. * Free a krb5_creds structure.
  4232. *
  4233. * @param [in] context Library context
  4234. * @param [in] val Credential structure to be freed.
  4235. *
  4236. * This function frees the contents of @a val and the structure itself.
  4237. */
  4238. void KRB5_CALLCONV
  4239. krb5_free_creds(krb5_context context, krb5_creds *val);
  4240. /**
  4241. * Free the contents of a krb5_creds structure.
  4242. *
  4243. * @param [in] context Library context
  4244. * @param [in] val Credential structure to free contents of
  4245. *
  4246. * This function frees the contents of @a val, but not the structure itself.
  4247. */
  4248. void KRB5_CALLCONV
  4249. krb5_free_cred_contents(krb5_context context, krb5_creds *val);
  4250. /**
  4251. * Free a krb5_checksum structure.
  4252. *
  4253. * @param [in] context Library context
  4254. * @param [in] val Checksum structure to be freed
  4255. *
  4256. * This function frees the contents of @a val and the structure itself.
  4257. */
  4258. void KRB5_CALLCONV
  4259. krb5_free_checksum(krb5_context context, register krb5_checksum *val);
  4260. /**
  4261. * Free the contents of a krb5_checksum structure.
  4262. *
  4263. * @param [in] context Library context
  4264. * @param [in] val Checksum structure to free contents of
  4265. *
  4266. * This function frees the contents of @a val, but not the structure itself.
  4267. */
  4268. void KRB5_CALLCONV
  4269. krb5_free_checksum_contents(krb5_context context, register krb5_checksum *val);
  4270. /**
  4271. * Free a krb5_keyblock structure.
  4272. *
  4273. * @param [in] context Library context
  4274. * @param [in] val Keyblock to be freed
  4275. *
  4276. * This function frees the contents of @a val and the structure itself.
  4277. */
  4278. void KRB5_CALLCONV
  4279. krb5_free_keyblock(krb5_context context, register krb5_keyblock *val);
  4280. /**
  4281. * Free the contents of a krb5_keyblock structure.
  4282. *
  4283. * @param [in] context Library context
  4284. * @param [in] key Keyblock to be freed
  4285. *
  4286. * This function frees the contents of @a key, but not the structure itself.
  4287. */
  4288. void KRB5_CALLCONV
  4289. krb5_free_keyblock_contents(krb5_context context, register krb5_keyblock *key);
  4290. /**
  4291. * Free a krb5_ap_rep_enc_part structure.
  4292. *
  4293. * @param [in] context Library context
  4294. * @param [in] val AP-REP enc part to be freed
  4295. *
  4296. * This function frees the contents of @a val and the structure itself.
  4297. */
  4298. void KRB5_CALLCONV
  4299. krb5_free_ap_rep_enc_part(krb5_context context, krb5_ap_rep_enc_part *val);
  4300. /**
  4301. * Free a krb5_data structure.
  4302. *
  4303. * @param [in] context Library context
  4304. * @param [in] val Data structure to be freed
  4305. *
  4306. * This function frees the contents of @a val and the structure itself.
  4307. */
  4308. void KRB5_CALLCONV
  4309. krb5_free_data(krb5_context context, krb5_data *val);
  4310. /**
  4311. * Free storage associated with a @c krb5_octet_data structure and its pointer.
  4312. *
  4313. * @param [in] context Context structure
  4314. * @param [in] val Data structure to be freed
  4315. *
  4316. * @return
  4317. * None
  4318. */
  4319. void KRB5_CALLCONV
  4320. krb5_free_octet_data(krb5_context context, krb5_octet_data *val);
  4321. /**
  4322. * Free the contents of a krb5_data structure and zero the data field.
  4323. *
  4324. * @param [in] context Library context
  4325. * @param [in] val Data structure to free contents of
  4326. *
  4327. * This function frees the contents of @a val, but not the structure itself.
  4328. */
  4329. void KRB5_CALLCONV
  4330. krb5_free_data_contents(krb5_context context, krb5_data *val);
  4331. /**
  4332. * Free a string representation of a principal.
  4333. *
  4334. * @param [in] context Library context
  4335. * @param [in] val Name string to be freed
  4336. */
  4337. void KRB5_CALLCONV
  4338. krb5_free_unparsed_name(krb5_context context, char *val);
  4339. /**
  4340. * Free a string allocated by a krb5 function.
  4341. *
  4342. * @param [in] context Library context
  4343. * @param [in] val String to be freed
  4344. */
  4345. void KRB5_CALLCONV
  4346. krb5_free_string(krb5_context context, char *val);
  4347. /**
  4348. * Free an array of checksum types.
  4349. *
  4350. * @param [in] context Library context
  4351. * @param [in] val Array of checksum types to be freed
  4352. */
  4353. void KRB5_CALLCONV
  4354. krb5_free_cksumtypes(krb5_context context, krb5_cksumtype *val);
  4355. /* From krb5/os, but needed by the outside world */
  4356. /**
  4357. * Retrieve the system time of day, in sec and ms, since the epoch.
  4358. *
  4359. * @param [in] context Library context
  4360. * @param [out] seconds System timeofday, seconds portion
  4361. * @param [out] microseconds System timeofday, microseconds portion
  4362. *
  4363. * This function retrieves the system time of day with the context
  4364. * specific time offset adjustment.
  4365. *
  4366. * @sa krb5_crypto_us_timeofday()
  4367. *
  4368. * @retval
  4369. * 0 Success
  4370. * @return
  4371. * Kerberos error codes
  4372. */
  4373. krb5_error_code KRB5_CALLCONV
  4374. krb5_us_timeofday(krb5_context context,
  4375. krb5_timestamp *seconds, krb5_int32 *microseconds);
  4376. /**
  4377. * Retrieve the current time with context specific time offset adjustment.
  4378. *
  4379. * @param [in] context Library context
  4380. * @param [in,out] timeret Timestamp to fill in
  4381. *
  4382. * This function retrieves the system time of day with the context specific
  4383. * time offset adjustment.
  4384. *
  4385. * @retval
  4386. * 0 Success
  4387. * @return
  4388. * Kerberos error codes
  4389. */
  4390. krb5_error_code KRB5_CALLCONV
  4391. krb5_timeofday(krb5_context context, register krb5_timestamp *timeret);
  4392. /**
  4393. * Check if a timestamp is within the allowed clock skew of the current time.
  4394. *
  4395. * @param [in] context Library context
  4396. * @param [in] date Timestamp to check
  4397. *
  4398. * This function checks if @a date is close enough to the current time
  4399. * according to the configured allowable clock skew.
  4400. *
  4401. * @retval 0 Success
  4402. * @retval KRB5KRB_AP_ERR_SKEW @a date is not within allowable clock skew
  4403. */
  4404. krb5_error_code KRB5_CALLCONV
  4405. krb5_check_clockskew(krb5_context context, krb5_timestamp date);
  4406. /**
  4407. * Return all interface addresses for this host.
  4408. *
  4409. * @param [in] context Library context
  4410. * @param [out] addr Array of krb5_address pointers, ending with
  4411. * NULL
  4412. *
  4413. * Use krb5_free_addresses() to free @a addr when it is no longer needed.
  4414. *
  4415. * @retval 0 Success; otherwise - Kerberos error codes
  4416. */
  4417. krb5_error_code KRB5_CALLCONV
  4418. krb5_os_localaddr(krb5_context context, krb5_address ***addr);
  4419. /**
  4420. * Retrieve the default realm.
  4421. *
  4422. * @param [in] context Library context
  4423. * @param [out] lrealm Default realm name
  4424. *
  4425. * Retrieves the default realm to be used if no user-specified realm is
  4426. * available.
  4427. *
  4428. * Use krb5_free_default_realm() to free @a lrealm when it is no longer needed.
  4429. *
  4430. * @retval
  4431. * 0 Success
  4432. * @return
  4433. * Kerberos error codes
  4434. */
  4435. krb5_error_code KRB5_CALLCONV
  4436. krb5_get_default_realm(krb5_context context, char **lrealm);
  4437. /**
  4438. * Override the default realm for the specified context.
  4439. *
  4440. * @param [in] context Library context
  4441. * @param [in] lrealm Realm name for the default realm
  4442. *
  4443. * If @a lrealm is NULL, clear the default realm setting.
  4444. *
  4445. * @retval
  4446. * 0 Success
  4447. * @return
  4448. * Kerberos error codes
  4449. */
  4450. krb5_error_code KRB5_CALLCONV
  4451. krb5_set_default_realm(krb5_context context, const char *lrealm);
  4452. /**
  4453. * Free a default realm string returned by krb5_get_default_realm().
  4454. *
  4455. * @param [in] context Library context
  4456. * @param [in] lrealm Realm to be freed
  4457. */
  4458. void KRB5_CALLCONV
  4459. krb5_free_default_realm(krb5_context context, char *lrealm);
  4460. /**
  4461. * Generate a full principal name from a service name.
  4462. *
  4463. * @param [in] context Library context
  4464. * @param [in] hostname Host name, or NULL to use local host
  4465. * @param [in] sname Service name, or NULL to use @c "host"
  4466. * @param [in] type Principal type
  4467. * @param [out] ret_princ Generated principal
  4468. *
  4469. * This function converts a @a hostname and @a sname into @a krb5_principal
  4470. * structure @a ret_princ. The returned principal will be of the form @a
  4471. * sname\/hostname\@REALM where REALM is determined by krb5_get_host_realm().
  4472. * In some cases this may be the referral (empty) realm.
  4473. *
  4474. * The @a type can be one of the following:
  4475. *
  4476. * @li #KRB5_NT_SRV_HOST canonicalizes the host name before looking up the
  4477. * realm and generating the principal.
  4478. *
  4479. * @li #KRB5_NT_UNKNOWN accepts the hostname as given, and does not
  4480. * canonicalize it.
  4481. *
  4482. * Use krb5_free_principal to free @a ret_princ when it is no longer needed.
  4483. *
  4484. * @retval
  4485. * 0 Success
  4486. * @return
  4487. * Kerberos error codes
  4488. */
  4489. krb5_error_code KRB5_CALLCONV
  4490. krb5_sname_to_principal(krb5_context context, const char *hostname, const char *sname,
  4491. krb5_int32 type, krb5_principal *ret_princ);
  4492. /**
  4493. * Test whether a principal matches a matching principal.
  4494. *
  4495. * @param [in] context Library context
  4496. * @param [in] matching Matching principal
  4497. * @param [in] princ Principal to test
  4498. *
  4499. * @note A matching principal is a host-based principal with an empty realm
  4500. * and/or second data component (hostname). Profile configuration may cause
  4501. * the hostname to be ignored even if it is present. A principal matches a
  4502. * matching principal if the former has the same non-empty (and non-ignored)
  4503. * components of the latter.
  4504. *
  4505. * If @a matching is NULL, return TRUE. If @a matching is not a matching
  4506. * principal, return the value of krb5_principal_compare(context, matching,
  4507. * princ).
  4508. *
  4509. * @return
  4510. * TRUE if @a princ matches @a matching, FALSE otherwise.
  4511. */
  4512. krb5_boolean KRB5_CALLCONV
  4513. krb5_sname_match(krb5_context context, krb5_const_principal matching,
  4514. krb5_const_principal princ);
  4515. /**
  4516. * Change a password for an existing Kerberos account.
  4517. *
  4518. * @param [in] context Library context
  4519. * @param [in] creds Credentials for kadmin/changepw service
  4520. * @param [in] newpw New password
  4521. * @param [out] result_code Numeric error code from server
  4522. * @param [out] result_code_string String equivalent to @a result_code
  4523. * @param [out] result_string Change password response from the KDC
  4524. *
  4525. * Change the password for the existing principal identified by @a creds.
  4526. *
  4527. * The possible values of the output @a result_code are:
  4528. *
  4529. * @li #KRB5_KPASSWD_SUCCESS (0) - success
  4530. * @li #KRB5_KPASSWD_MALFORMED (1) - Malformed request error
  4531. * @li #KRB5_KPASSWD_HARDERROR (2) - Server error
  4532. * @li #KRB5_KPASSWD_AUTHERROR (3) - Authentication error
  4533. * @li #KRB5_KPASSWD_SOFTERROR (4) - Password change rejected
  4534. *
  4535. * @retval 0 Success; otherwise - Kerberos error codes
  4536. */
  4537. krb5_error_code KRB5_CALLCONV
  4538. krb5_change_password(krb5_context context, krb5_creds *creds, char *newpw,
  4539. int *result_code, krb5_data *result_code_string,
  4540. krb5_data *result_string);
  4541. /**
  4542. * Set a password for a principal using specified credentials.
  4543. *
  4544. * @param [in] context Library context
  4545. * @param [in] creds Credentials for kadmin/changepw service
  4546. * @param [in] newpw New password
  4547. * @param [in] change_password_for Change the password for this principal
  4548. * @param [out] result_code Numeric error code from server
  4549. * @param [out] result_code_string String equivalent to @a result_code
  4550. * @param [out] result_string Data returned from the remote system
  4551. *
  4552. * This function uses the credentials @a creds to set the password @a newpw for
  4553. * the principal @a change_password_for. It implements the set password
  4554. * operation of RFC 3244, for interoperability with Microsoft Windows
  4555. * implementations.
  4556. *
  4557. * @note If @a change_password_for is NULL, the change is performed on the
  4558. * current principal. If @a change_password_for is non-null, the change is
  4559. * performed on the principal name passed in @a change_password_for.
  4560. *
  4561. * The error code and strings are returned in @a result_code,
  4562. * @a result_code_string and @a result_string.
  4563. *
  4564. * @sa krb5_set_password_using_ccache()
  4565. *
  4566. * @retval
  4567. * 0 Success and result_code is set to #KRB5_KPASSWD_SUCCESS.
  4568. * @return
  4569. * Kerberos error codes.
  4570. */
  4571. krb5_error_code KRB5_CALLCONV
  4572. krb5_set_password(krb5_context context, krb5_creds *creds, char *newpw,
  4573. krb5_principal change_password_for, int *result_code,
  4574. krb5_data *result_code_string, krb5_data *result_string);
  4575. /**
  4576. * Set a password for a principal using cached credentials.
  4577. *
  4578. * @param [in] context Library context
  4579. * @param [in] ccache Credential cache
  4580. * @param [in] newpw New password
  4581. * @param [in] change_password_for Change the password for this principal
  4582. * @param [out] result_code Numeric error code from server
  4583. * @param [out] result_code_string String equivalent to @a result_code
  4584. * @param [out] result_string Data returned from the remote system
  4585. *
  4586. * This function uses the cached credentials from @a ccache to set the password
  4587. * @a newpw for the principal @a change_password_for. It implements RFC 3244
  4588. * set password operation (interoperable with MS Windows implementations) using
  4589. * the credential cache.
  4590. *
  4591. * The error code and strings are returned in @a result_code,
  4592. * @a result_code_string and @a result_string.
  4593. *
  4594. * @note If @a change_password_for is set to NULL, the change is performed on
  4595. * the default principal in @a ccache. If @a change_password_for is non null,
  4596. * the change is performed on the specified principal.
  4597. *
  4598. * @sa krb5_set_password()
  4599. *
  4600. * @retval
  4601. * 0 Success
  4602. * @return
  4603. * Kerberos error codes
  4604. */
  4605. krb5_error_code KRB5_CALLCONV
  4606. krb5_set_password_using_ccache(krb5_context context, krb5_ccache ccache,
  4607. char *newpw, krb5_principal change_password_for,
  4608. int *result_code, krb5_data *result_code_string,
  4609. krb5_data *result_string);
  4610. /**
  4611. * Retrieve configuration profile from the context.
  4612. *
  4613. * @param [in] context Library context
  4614. * @param [out] profile Pointer to data read from a configuration file
  4615. *
  4616. * This function creates a new @a profile object that reflects profile
  4617. * in the supplied @a context.
  4618. *
  4619. * The @a profile object may be freed with profile_release() function.
  4620. * See profile.h and profile API for more details.
  4621. *
  4622. * @retval
  4623. * 0 Success
  4624. * @return
  4625. * Kerberos error codes
  4626. */
  4627. krb5_error_code KRB5_CALLCONV
  4628. krb5_get_profile(krb5_context context, struct _profile_t ** profile);
  4629. #if KRB5_DEPRECATED
  4630. /** @deprecated Replaced by krb5_get_init_creds_password().*/
  4631. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  4632. krb5_get_in_tkt_with_password(krb5_context context, krb5_flags options,
  4633. krb5_address *const *addrs, krb5_enctype *ktypes,
  4634. krb5_preauthtype *pre_auth_types,
  4635. const char *password, krb5_ccache ccache,
  4636. krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
  4637. /** @deprecated Replaced by krb5_get_init_creds(). */
  4638. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  4639. krb5_get_in_tkt_with_skey(krb5_context context, krb5_flags options,
  4640. krb5_address *const *addrs, krb5_enctype *ktypes,
  4641. krb5_preauthtype *pre_auth_types,
  4642. const krb5_keyblock *key, krb5_ccache ccache,
  4643. krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
  4644. /** @deprecated Replaced by krb5_get_init_creds_keytab(). */
  4645. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  4646. krb5_get_in_tkt_with_keytab(krb5_context context, krb5_flags options,
  4647. krb5_address *const *addrs, krb5_enctype *ktypes,
  4648. krb5_preauthtype *pre_auth_types,
  4649. krb5_keytab arg_keytab, krb5_ccache ccache,
  4650. krb5_creds *creds, krb5_kdc_rep **ret_as_reply);
  4651. #endif /* KRB5_DEPRECATED */
  4652. /**
  4653. * Parse and decrypt a @c KRB_AP_REQ message.
  4654. *
  4655. * @param [in] context Library context
  4656. * @param [in,out] auth_context Pre-existing or newly created auth context
  4657. * @param [in] inbuf AP-REQ message to be parsed
  4658. * @param [in] server Matching principal for server, or NULL to
  4659. * allow any principal in keytab
  4660. * @param [in] keytab Key table, or NULL to use the default
  4661. * @param [out] ap_req_options If non-null, the AP-REQ flags on output
  4662. * @param [out] ticket If non-null, ticket from the AP-REQ message
  4663. *
  4664. * This function parses, decrypts and verifies a AP-REQ message from @a inbuf
  4665. * and stores the authenticator in @a auth_context.
  4666. *
  4667. * If a keyblock is present in the @a auth_context, it is used to decrypt the
  4668. * ticket in AP-REQ message. (This is useful for user-to-user authentication.)
  4669. * Otherwise, the decryption key is obtained from the @a keytab. If @a keytab
  4670. * is iterable, all of its key entries it will be tried against the ticket;
  4671. * otherwise, the server principal in the ticket will be looked up in the
  4672. * keytab and that key will be tried.
  4673. *
  4674. * The client specified in the decrypted authenticator must match the client
  4675. * specified in the decrypted ticket. If @a server is non-null, the key in
  4676. * which the ticket is encrypted must correspond to a principal in @a keytab
  4677. * matching @a server according to the rules of krb5_sname_match().
  4678. *
  4679. * If the @a remote_addr field of @a auth_context is set, the request must come
  4680. * from that address.
  4681. *
  4682. * If a replay cache handle is provided in the @a auth_context, the
  4683. * authenticator and ticket are verified against it. If no conflict is found,
  4684. * the new authenticator is then stored in the replay cash of @a auth_context.
  4685. *
  4686. * Various other checks are performed on the decoded data, including
  4687. * cross-realm policy, clockskew, and ticket validation times.
  4688. *
  4689. * On success the authenticator, subkey, and remote sequence number of the
  4690. * request are stored in @a auth_context. If the #AP_OPTS_MUTUAL_REQUIRED
  4691. * bit is set, the local sequence number is XORed with the remote sequence
  4692. * number in the request.
  4693. *
  4694. * Use krb5_free_ticket() to free @a ticket when it is no longer needed.
  4695. *
  4696. * @retval 0 Success; otherwise - Kerberos error codes
  4697. */
  4698. krb5_error_code KRB5_CALLCONV
  4699. krb5_rd_req(krb5_context context, krb5_auth_context *auth_context,
  4700. const krb5_data *inbuf, krb5_const_principal server,
  4701. krb5_keytab keytab, krb5_flags *ap_req_options,
  4702. krb5_ticket **ticket);
  4703. /**
  4704. * Retrieve a service key from a key table.
  4705. *
  4706. * @param [in] context Library context
  4707. * @param [in] keyprocarg Name of a key table (NULL to use default name)
  4708. * @param [in] principal Service principal
  4709. * @param [in] vno Key version number (0 for highest available)
  4710. * @param [in] enctype Encryption type (0 for any type)
  4711. * @param [out] key Service key from key table
  4712. *
  4713. * Open and search the specified key table for the entry identified by @a
  4714. * principal, @a enctype, and @a vno. If no key is found, return an error code.
  4715. *
  4716. * The default key table is used, unless @a keyprocarg is non-null.
  4717. * @a keyprocarg designates a specific key table.
  4718. *
  4719. * Use krb5_free_keyblock() to free @a key when it is no longer needed.
  4720. *
  4721. * @retval
  4722. * 0 Success
  4723. * @return Kerberos error code if not found or @a keyprocarg is invalid.
  4724. */
  4725. krb5_error_code KRB5_CALLCONV
  4726. krb5_kt_read_service_key(krb5_context context, krb5_pointer keyprocarg,
  4727. krb5_principal principal, krb5_kvno vno,
  4728. krb5_enctype enctype, krb5_keyblock **key);
  4729. /**
  4730. * Format a @c KRB-SAFE message.
  4731. *
  4732. * @param [in] context Library context
  4733. * @param [in,out] auth_context Authentication context
  4734. * @param [in] userdata User data in the message
  4735. * @param [out] outbuf Formatted @c KRB-SAFE buffer
  4736. * @param [out] outdata Replay data. Specify NULL if not needed
  4737. *
  4738. * This function creates an integrity protected @c KRB-SAFE message
  4739. * using data supplied by the application.
  4740. *
  4741. * Fields in @a auth_context specify the checksum type, the keyblock that
  4742. * can be used to seed the checksum, full addresses (host and port) for
  4743. * the sender and receiver, and @ref KRB5_AUTH_CONTEXT flags.
  4744. *
  4745. * The local address in @a auth_context must be set, and is used to form the
  4746. * sender address used in the KRB-SAFE message. The remote address is
  4747. * optional; if specified, it will be used to form the receiver address used in
  4748. * the message.
  4749. *
  4750. * If #KRB5_AUTH_CONTEXT_DO_TIME flag is set in the @a auth_context, an entry
  4751. * describing the message is entered in the replay cache @a
  4752. * auth_context->rcache which enables the caller to detect if this message is
  4753. * reflected by an attacker. If #KRB5_AUTH_CONTEXT_DO_TIME is not set, the
  4754. * replay cache is not used.
  4755. *
  4756. * If either #KRB5_AUTH_CONTEXT_DO_SEQUENCE or
  4757. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE is set, the @a auth_context local sequence
  4758. * number will be placed in @a outdata as its sequence number.
  4759. *
  4760. * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
  4761. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.
  4762. *
  4763. * Use krb5_free_data_contents() to free @a outbuf when it is no longer needed.
  4764. *
  4765. * @retval 0 Success; otherwise - Kerberos error codes
  4766. */
  4767. krb5_error_code KRB5_CALLCONV
  4768. krb5_mk_safe(krb5_context context, krb5_auth_context auth_context,
  4769. const krb5_data *userdata, krb5_data *outbuf,
  4770. krb5_replay_data *outdata);
  4771. /**
  4772. * Format a @c KRB-PRIV message.
  4773. *
  4774. * @param [in] context Library context
  4775. * @param [in,out] auth_context Authentication context
  4776. * @param [in] userdata User data for @c KRB-PRIV message
  4777. * @param [out] outbuf Formatted @c KRB-PRIV message
  4778. * @param [out] outdata Replay cache handle (NULL if not needed)
  4779. *
  4780. * This function is similar to krb5_mk_safe(), but the message is encrypted and
  4781. * integrity-protected, not just integrity-protected.
  4782. *
  4783. * The local address in @a auth_context must be set, and is used to form the
  4784. * sender address used in the KRB-SAFE message. The remote address is
  4785. * optional; if specified, it will be used to form the receiver address used in
  4786. * the message.
  4787. *
  4788. * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or
  4789. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in @a auth_context, the @a
  4790. * outdata is required.
  4791. *
  4792. * @note The flags from @a auth_context specify whether sequence numbers or
  4793. * timestamps will be used to identify the message. Valid values are:
  4794. *
  4795. * @li #KRB5_AUTH_CONTEXT_DO_TIME - Use timestamps in @a outdata
  4796. * @li #KRB5_AUTH_CONTEXT_RET_TIME - Copy timestamp to @a outdata.
  4797. * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE - Use local sequence numbers from
  4798. * @a auth_context in replay cache.
  4799. * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE - Use local sequence numbers from
  4800. * @a auth_context as a sequence number
  4801. * in the encrypted message @a outbuf.
  4802. *
  4803. * @retval 0 Success; otherwise - Kerberos error codes
  4804. */
  4805. krb5_error_code KRB5_CALLCONV
  4806. krb5_mk_priv(krb5_context context, krb5_auth_context auth_context,
  4807. const krb5_data *userdata, krb5_data *outbuf,
  4808. krb5_replay_data *outdata);
  4809. /**
  4810. * Client function for @c sendauth protocol.
  4811. *
  4812. * @param [in] context Library context
  4813. * @param [in,out] auth_context Authentication context
  4814. * @param [in] fd File descriptor that describes network socket
  4815. * @param [in] appl_version Application protocol version to be matched
  4816. * with the receiver's application version
  4817. * @param [in] client Client principal
  4818. * @param [in] server Server principal
  4819. * @param [in] ap_req_options @ref AP_OPTS options
  4820. * @param [in] in_data Data to be sent to the server
  4821. * @param [in] in_creds Input credentials, or NULL to use @a ccache
  4822. * @param [in] ccache Credential cache
  4823. * @param [out] error If non-null, contains KRB_ERROR message
  4824. * returned from server
  4825. * @param [out] rep_result If non-null and @a ap_req_options is
  4826. * #AP_OPTS_MUTUAL_REQUIRED, contains the result
  4827. * of mutual authentication exchange
  4828. * @param [out] out_creds If non-null, the retrieved credentials
  4829. *
  4830. * This function performs the client side of a sendauth/recvauth exchange by
  4831. * sending and receiving messages over @a fd.
  4832. *
  4833. * Credentials may be specified in three ways:
  4834. *
  4835. * @li If @a in_creds is NULL, credentials are obtained with
  4836. * krb5_get_credentials() using the principals @a client and @a server. @a
  4837. * server must be non-null; @a client may NULL to use the default principal of
  4838. * @a ccache.
  4839. *
  4840. * @li If @a in_creds is non-null, but does not contain a ticket, credentials
  4841. * for the exchange are obtained with krb5_get_credentials() using @a in_creds.
  4842. * In this case, the values of @a client and @a server are unused.
  4843. *
  4844. * @li If @a in_creds is a complete credentials structure, it used directly.
  4845. * In this case, the values of @a client, @a server, and @a ccache are unused.
  4846. *
  4847. * If the server is using a different application protocol than that specified
  4848. * in @a appl_version, an error will be returned.
  4849. *
  4850. * Use krb5_free_creds() to free @a out_creds, krb5_free_ap_rep_enc_part() to
  4851. * free @a rep_result, and krb5_free_error() to free @a error when they are no
  4852. * longer needed.
  4853. *
  4854. * @sa krb5_recvauth()
  4855. *
  4856. * @retval 0 Success; otherwise - Kerberos error codes
  4857. */
  4858. krb5_error_code KRB5_CALLCONV
  4859. krb5_sendauth(krb5_context context, krb5_auth_context *auth_context,
  4860. krb5_pointer fd, char *appl_version, krb5_principal client,
  4861. krb5_principal server, krb5_flags ap_req_options,
  4862. krb5_data *in_data, krb5_creds *in_creds, krb5_ccache ccache,
  4863. krb5_error **error, krb5_ap_rep_enc_part **rep_result,
  4864. krb5_creds **out_creds);
  4865. /**
  4866. * Server function for @a sendauth protocol.
  4867. *
  4868. * @param [in] context Library context
  4869. * @param [in,out] auth_context Authentication context
  4870. * @param [in] fd File descriptor
  4871. * @param [in] appl_version Application protocol version to be matched
  4872. * against the client's application version
  4873. * @param [in] server Server principal (NULL for any in @a keytab)
  4874. * @param [in] flags Additional specifications
  4875. * @param [in] keytab Key table containing service keys
  4876. * @param [out] ticket Ticket (NULL if not needed)
  4877. *
  4878. * This function performs the srever side of a sendauth/recvauth exchange by
  4879. * sending and receiving messages over @a fd.
  4880. *
  4881. * Use krb5_free_ticket() to free @a ticket when it is no longer needed.
  4882. *
  4883. * @sa krb5_sendauth()
  4884. *
  4885. * @retval 0 Success; otherwise - Kerberos error codes
  4886. */
  4887. krb5_error_code KRB5_CALLCONV
  4888. krb5_recvauth(krb5_context context, krb5_auth_context *auth_context,
  4889. krb5_pointer fd, char *appl_version, krb5_principal server,
  4890. krb5_int32 flags, krb5_keytab keytab, krb5_ticket **ticket);
  4891. /**
  4892. * Server function for @a sendauth protocol with version parameter.
  4893. *
  4894. * @param [in] context Library context
  4895. * @param [in,out] auth_context Authentication context
  4896. * @param [in] fd File descriptor
  4897. * @param [in] server Server principal (NULL for any in @a keytab)
  4898. * @param [in] flags Additional specifications
  4899. * @param [in] keytab Decryption key
  4900. * @param [out] ticket Ticket (NULL if not needed)
  4901. * @param [out] version sendauth protocol version (NULL if not needed)
  4902. *
  4903. * This function is similar to krb5_recvauth() with the additional output
  4904. * information place into @a version.
  4905. *
  4906. * @retval 0 Success; otherwise - Kerberos error codes
  4907. */
  4908. krb5_error_code KRB5_CALLCONV
  4909. krb5_recvauth_version(krb5_context context,
  4910. krb5_auth_context *auth_context,
  4911. krb5_pointer fd,
  4912. krb5_principal server,
  4913. krb5_int32 flags,
  4914. krb5_keytab keytab,
  4915. krb5_ticket **ticket,
  4916. krb5_data *version);
  4917. /**
  4918. * Format a @c KRB-CRED message for an array of credentials.
  4919. *
  4920. * @param [in] context Library context
  4921. * @param [in,out] auth_context Authentication context
  4922. * @param [in] ppcreds Null-terminated array of credentials
  4923. * @param [out] ppdata Encoded credentials
  4924. * @param [out] outdata Replay cache information (NULL if not needed)
  4925. *
  4926. * This function takes an array of credentials @a ppcreds and formats
  4927. * a @c KRB-CRED message @a ppdata to pass to krb5_rd_cred().
  4928. *
  4929. * @note If the #KRB5_AUTH_CONTEXT_RET_TIME or #KRB5_AUTH_CONTEXT_RET_SEQUENCE
  4930. * flag is set in @a auth_context, @a outdata is required.
  4931. *
  4932. * The message will be encrypted using the send subkey of @a auth_context if it
  4933. * is present, or the session key otherwise.
  4934. *
  4935. * @retval
  4936. * 0 Success
  4937. * @retval
  4938. * ENOMEM Insufficient memory
  4939. * @retval
  4940. * KRB5_RC_REQUIRED Message replay detection requires @a rcache parameter
  4941. * @return
  4942. * Kerberos error codes
  4943. */
  4944. krb5_error_code KRB5_CALLCONV
  4945. krb5_mk_ncred(krb5_context context, krb5_auth_context auth_context,
  4946. krb5_creds **ppcreds, krb5_data **ppdata,
  4947. krb5_replay_data *outdata);
  4948. /**
  4949. * Format a @c KRB-CRED message for a single set of credentials.
  4950. *
  4951. * @param [in] context Library context
  4952. * @param [in,out] auth_context Authentication context
  4953. * @param [in] pcreds Pointer to credentials
  4954. * @param [out] ppdata Encoded credentials
  4955. * @param [out] outdata Replay cache data (NULL if not needed)
  4956. *
  4957. * This is a convenience function that calls krb5_mk_ncred() with a single set
  4958. * of credentials.
  4959. *
  4960. * @retval
  4961. * 0 Success
  4962. * @retval
  4963. * ENOMEM Insufficient memory
  4964. * @retval
  4965. * KRB5_RC_REQUIRED Message replay detection requires @a rcache parameter
  4966. * @return
  4967. * Kerberos error codes
  4968. */
  4969. krb5_error_code KRB5_CALLCONV
  4970. krb5_mk_1cred(krb5_context context, krb5_auth_context auth_context,
  4971. krb5_creds *pcreds, krb5_data **ppdata,
  4972. krb5_replay_data *outdata);
  4973. /**
  4974. * Read and validate a @c KRB-CRED message.
  4975. *
  4976. * @param [in] context Library context
  4977. * @param [in,out] auth_context Authentication context
  4978. * @param [in] pcreddata @c KRB-CRED message
  4979. * @param [out] pppcreds Null-terminated array of forwarded credentials
  4980. * @param [out] outdata Replay data (NULL if not needed)
  4981. *
  4982. * @note The @a outdata argument is required if #KRB5_AUTH_CONTEXT_RET_TIME or
  4983. * #KRB5_AUTH_CONTEXT_RET_SEQUENCE flag is set in the @a auth_context.`
  4984. *
  4985. * @a pcreddata will be decrypted using the receiving subkey if it is present
  4986. * in @a auth_context, or the session key if the receiving subkey is not
  4987. * present or fails to decrypt the message.
  4988. *
  4989. * Use krb5_free_tgt_creds() to free @a pppcreds when it is no longer needed.
  4990. *
  4991. * @retval 0 Success; otherwise - Kerberos error codes
  4992. */
  4993. krb5_error_code KRB5_CALLCONV
  4994. krb5_rd_cred(krb5_context context, krb5_auth_context auth_context,
  4995. krb5_data *pcreddata, krb5_creds ***pppcreds,
  4996. krb5_replay_data *outdata);
  4997. /**
  4998. * Get a forwarded TGT and format a @c KRB-CRED message.
  4999. *
  5000. * @param [in] context Library context
  5001. * @param [in] auth_context Authentication context
  5002. * @param [in] rhost Remote host
  5003. * @param [in] client Client principal of TGT
  5004. * @param [in] server Principal of server to receive TGT
  5005. * @param [in] cc Credential cache handle (NULL to use default)
  5006. * @param [in] forwardable Whether TGT should be forwardable
  5007. * @param [out] outbuf KRB-CRED message
  5008. *
  5009. * Get a TGT for use at the remote host @a rhost and format it into a KRB-CRED
  5010. * message. If @a rhost is NULL and @a server is of type #KRB5_NT_SRV_HST,
  5011. * the second component of @a server will be used.
  5012. *
  5013. * @retval
  5014. * 0 Success
  5015. * @retval
  5016. * ENOMEM Insufficient memory
  5017. * @retval
  5018. * KRB5_PRINC_NOMATCH Requested principal and ticket do not match
  5019. * @retval
  5020. * KRB5_NO_TKT_SUPPLIED Request did not supply a ticket
  5021. * @retval
  5022. * KRB5_CC_BADNAME Credential cache name or principal name malformed
  5023. * @return
  5024. * Kerberos error codes
  5025. */
  5026. krb5_error_code KRB5_CALLCONV
  5027. krb5_fwd_tgt_creds(krb5_context context, krb5_auth_context auth_context,
  5028. char *rhost, krb5_principal client, krb5_principal server,
  5029. krb5_ccache cc, int forwardable, krb5_data *outbuf);
  5030. /**
  5031. * Create and initialize an authentication context.
  5032. *
  5033. * @param [in] context Library context
  5034. * @param [out] auth_context Authentication context
  5035. *
  5036. * This function creates an authentication context to hold configuration and
  5037. * state relevant to krb5 functions for authenticating principals and
  5038. * protecting messages once authentication has occurred.
  5039. *
  5040. * By default, flags for the context are set to enable the use of the replay
  5041. * cache (#KRB5_AUTH_CONTEXT_DO_TIME), but not sequence numbers. Use
  5042. * krb5_auth_con_setflags() to change the flags.
  5043. *
  5044. * The allocated @a auth_context must be freed with krb5_auth_con_free() when
  5045. * it is no longer needed.
  5046. *
  5047. * @retval 0 Success; otherwise - Kerberos error codes
  5048. */
  5049. krb5_error_code KRB5_CALLCONV
  5050. krb5_auth_con_init(krb5_context context, krb5_auth_context *auth_context);
  5051. /**
  5052. * Free a krb5_auth_context structure.
  5053. *
  5054. * @param [in] context Library context
  5055. * @param [in] auth_context Authentication context to be freed
  5056. *
  5057. * This function frees an auth context allocated by krb5_auth_con_init().
  5058. *
  5059. * @retval 0 (always)
  5060. */
  5061. krb5_error_code KRB5_CALLCONV
  5062. krb5_auth_con_free(krb5_context context, krb5_auth_context auth_context);
  5063. /**
  5064. * Set a flags field in a krb5_auth_context structure.
  5065. *
  5066. * @param [in] context Library context
  5067. * @param [in,out] auth_context Authentication context
  5068. * @param [in] flags Flags bit mask
  5069. *
  5070. * Valid values for @a flags are:
  5071. * @li #KRB5_AUTH_CONTEXT_DO_TIME Use timestamps
  5072. * @li #KRB5_AUTH_CONTEXT_RET_TIME Save timestamps
  5073. * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE Use sequence numbers
  5074. * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE Save sequence numbers
  5075. *
  5076. * @retval 0 (always)
  5077. */
  5078. krb5_error_code KRB5_CALLCONV
  5079. krb5_auth_con_setflags(krb5_context context, krb5_auth_context auth_context, krb5_int32 flags);
  5080. /**
  5081. * Retrieve flags from a krb5_auth_context structure.
  5082. *
  5083. * @param [in] context Library context
  5084. * @param [in] auth_context Authentication context
  5085. * @param [out] flags Flags bit mask
  5086. *
  5087. * Valid values for @a flags are:
  5088. * @li #KRB5_AUTH_CONTEXT_DO_TIME Use timestamps
  5089. * @li #KRB5_AUTH_CONTEXT_RET_TIME Save timestamps
  5090. * @li #KRB5_AUTH_CONTEXT_DO_SEQUENCE Use sequence numbers
  5091. * @li #KRB5_AUTH_CONTEXT_RET_SEQUENCE Save sequence numbers
  5092. *
  5093. * @retval 0 (always)
  5094. */
  5095. krb5_error_code KRB5_CALLCONV
  5096. krb5_auth_con_getflags(krb5_context context, krb5_auth_context auth_context,
  5097. krb5_int32 *flags);
  5098. /**
  5099. * Set a checksum callback in an auth context.
  5100. *
  5101. * @param [in] context Library context
  5102. * @param [in] auth_context Authentication context
  5103. * @param [in] func Checksum callback
  5104. * @param [in] data Callback argument
  5105. *
  5106. * Set a callback to obtain checksum data in krb5_mk_req(). The callback will
  5107. * be invoked after the subkey and local sequence number are stored in @a
  5108. * auth_context.
  5109. *
  5110. * @retval 0 (always)
  5111. */
  5112. krb5_error_code KRB5_CALLCONV
  5113. krb5_auth_con_set_checksum_func( krb5_context context,
  5114. krb5_auth_context auth_context,
  5115. krb5_mk_req_checksum_func func,
  5116. void *data);
  5117. /**
  5118. * Get the checksum callback from an auth context.
  5119. *
  5120. * @param [in] context Library context
  5121. * @param [in] auth_context Authentication context
  5122. * @param [out] func Checksum callback
  5123. * @param [out] data Callback argument
  5124. *
  5125. * @retval 0 (always)
  5126. */
  5127. krb5_error_code KRB5_CALLCONV
  5128. krb5_auth_con_get_checksum_func( krb5_context context,
  5129. krb5_auth_context auth_context,
  5130. krb5_mk_req_checksum_func *func,
  5131. void **data);
  5132. /**
  5133. * Set the local and remote addresses in an auth context.
  5134. *
  5135. * @param [in] context Library context
  5136. * @param [in] auth_context Authentication context
  5137. * @param [in] local_addr Local address
  5138. * @param [in] remote_addr Remote address
  5139. *
  5140. * This function releases the storage assigned to the contents of the local and
  5141. * remote addresses of @a auth_context and then sets them to @a local_addr and
  5142. * @a remote_addr respectively.
  5143. *
  5144. * @sa krb5_auth_con_genaddrs()
  5145. *
  5146. * @retval 0 Success; otherwise - Kerberos error codes
  5147. */
  5148. krb5_error_code KRB5_CALLCONV_WRONG
  5149. krb5_auth_con_setaddrs(krb5_context context, krb5_auth_context auth_context,
  5150. krb5_address *local_addr, krb5_address *remote_addr);
  5151. /**
  5152. * Retrieve address fields from an auth context.
  5153. *
  5154. * @param [in] context Library context
  5155. * @param [in] auth_context Authentication context
  5156. * @param [out] local_addr Local address (NULL if not needed)
  5157. * @param [out] remote_addr Remote address (NULL if not needed)
  5158. *
  5159. * @retval 0 Success; otherwise - Kerberos error codes
  5160. */
  5161. krb5_error_code KRB5_CALLCONV
  5162. krb5_auth_con_getaddrs(krb5_context context, krb5_auth_context auth_context,
  5163. krb5_address **local_addr, krb5_address **remote_addr);
  5164. /**
  5165. * Set local and remote port fields in an auth context.
  5166. *
  5167. * @param [in] context Library context
  5168. * @param [in] auth_context Authentication context
  5169. * @param [in] local_port Local port
  5170. * @param [in] remote_port Remote port
  5171. *
  5172. * This function releases the storage assigned to the contents of the local and
  5173. * remote ports of @a auth_context and then sets them to @a local_port and @a
  5174. * remote_port respectively.
  5175. *
  5176. * @sa krb5_auth_con_genaddrs()
  5177. *
  5178. * @retval 0 Success; otherwise - Kerberos error codes
  5179. */
  5180. krb5_error_code KRB5_CALLCONV
  5181. krb5_auth_con_setports(krb5_context context, krb5_auth_context auth_context,
  5182. krb5_address *local_port, krb5_address *remote_port);
  5183. /**
  5184. * Set the session key in an auth context.
  5185. *
  5186. * @param [in] context Library context
  5187. * @param [in] auth_context Authentication context
  5188. * @param [in] keyblock User key
  5189. *
  5190. * @retval 0 Success; otherwise - Kerberos error codes
  5191. */
  5192. krb5_error_code KRB5_CALLCONV
  5193. krb5_auth_con_setuseruserkey(krb5_context context, krb5_auth_context auth_context,
  5194. krb5_keyblock *keyblock);
  5195. /**
  5196. * Retrieve the session key from an auth context as a keyblock.
  5197. *
  5198. * @param [in] context Library context
  5199. * @param [in] auth_context Authentication context
  5200. * @param [out] keyblock Session key
  5201. *
  5202. * This function creates a keyblock containing the session key from @a
  5203. * auth_context. Use krb5_free_keyblock() to free @a keyblock when it is no
  5204. * longer needed
  5205. *
  5206. * @retval 0 Success. Otherwise - Kerberos error codes
  5207. */
  5208. krb5_error_code KRB5_CALLCONV
  5209. krb5_auth_con_getkey(krb5_context context, krb5_auth_context auth_context,
  5210. krb5_keyblock **keyblock);
  5211. /**
  5212. * Retrieve the session key from an auth context.
  5213. *
  5214. * @param [in] context Library context
  5215. * @param [in] auth_context Authentication context
  5216. * @param [out] key Session key
  5217. *
  5218. * This function sets @a key to the session key from @a auth_context. Use
  5219. * krb5_k_free_key() to release @a key when it is no longer needed.
  5220. *
  5221. * @retval 0 (always)
  5222. */
  5223. krb5_error_code KRB5_CALLCONV
  5224. krb5_auth_con_getkey_k(krb5_context context, krb5_auth_context auth_context,
  5225. krb5_key *key);
  5226. /**
  5227. * Retrieve the send subkey from an auth context as a keyblock.
  5228. *
  5229. * @param [in] ctx Library context
  5230. * @param [in] ac Authentication context
  5231. * @param [out] keyblock Send subkey
  5232. *
  5233. * This function creates a keyblock containing the send subkey from @a
  5234. * auth_context. Use krb5_free_keyblock() to free @a keyblock when it is no
  5235. * longer needed.
  5236. *
  5237. * @retval 0 Success; otherwise - Kerberos error codes
  5238. */
  5239. krb5_error_code KRB5_CALLCONV
  5240. krb5_auth_con_getsendsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock);
  5241. /**
  5242. * Retrieve the send subkey from an auth context.
  5243. *
  5244. * @param [in] ctx Library context
  5245. * @param [in] ac Authentication context
  5246. * @param [out] key Send subkey
  5247. *
  5248. * This function sets @a key to the send subkey from @a auth_context. Use
  5249. * krb5_k_free_key() to release @a key when it is no longer needed.
  5250. *
  5251. * @retval 0 Success; otherwise - Kerberos error codes
  5252. */
  5253. krb5_error_code KRB5_CALLCONV
  5254. krb5_auth_con_getsendsubkey_k(krb5_context ctx, krb5_auth_context ac,
  5255. krb5_key *key);
  5256. /**
  5257. * Retrieve the receiving subkey from an auth context as a keyblock.
  5258. *
  5259. * @param [in] ctx Library context
  5260. * @param [in] ac Authentication context
  5261. * @param [out] keyblock Receiving subkey
  5262. *
  5263. * This function creates a keyblock containing the receiving subkey from @a
  5264. * auth_context. Use krb5_free_keyblock() to free @a keyblock when it is no
  5265. * longer needed.
  5266. *
  5267. * @retval 0 Success; otherwise - Kerberos error codes
  5268. */
  5269. krb5_error_code KRB5_CALLCONV
  5270. krb5_auth_con_getrecvsubkey(krb5_context ctx, krb5_auth_context ac, krb5_keyblock **keyblock);
  5271. /**
  5272. * Retrieve the receiving subkey from an auth context as a keyblock.
  5273. *
  5274. * @param [in] ctx Library context
  5275. * @param [in] ac Authentication context
  5276. * @param [out] key Receiving subkey
  5277. *
  5278. * This function sets @a key to the receiving subkey from @a auth_context. Use
  5279. * krb5_k_free_key() to release @a key when it is no longer needed.
  5280. *
  5281. * @retval 0 Success; otherwise - Kerberos error codes
  5282. */
  5283. krb5_error_code KRB5_CALLCONV
  5284. krb5_auth_con_getrecvsubkey_k(krb5_context ctx, krb5_auth_context ac, krb5_key *key);
  5285. /**
  5286. * Set the send subkey in an auth context with a keyblock.
  5287. *
  5288. * @param [in] ctx Library context
  5289. * @param [in] ac Authentication context
  5290. * @param [in] keyblock Send subkey
  5291. *
  5292. * This function sets the send subkey in @a ac to a copy of @a keyblock.
  5293. *
  5294. * @retval 0 Success. Otherwise - Kerberos error codes
  5295. */
  5296. krb5_error_code KRB5_CALLCONV
  5297. krb5_auth_con_setsendsubkey(krb5_context ctx, krb5_auth_context ac,
  5298. krb5_keyblock *keyblock);
  5299. /**
  5300. * Set the send subkey in an auth context.
  5301. *
  5302. * @param [in] ctx Library context
  5303. * @param [in] ac Authentication context
  5304. * @param [out] key Send subkey
  5305. *
  5306. * This function sets the send subkey in @a ac to @a key, incrementing its
  5307. * reference count.
  5308. *
  5309. * @retval 0 Success; otherwise - Kerberos error codes
  5310. */
  5311. krb5_error_code KRB5_CALLCONV
  5312. krb5_auth_con_setsendsubkey_k(krb5_context ctx, krb5_auth_context ac, krb5_key key);
  5313. /**
  5314. * Set the receiving subkey in an auth context with a keyblock.
  5315. *
  5316. * @param [in] ctx Library context
  5317. * @param [in] ac Authentication context
  5318. * @param [in] keyblock Receiving subkey
  5319. *
  5320. * This function sets the receiving subkey in @a ac to a copy of @a keyblock.
  5321. *
  5322. * @retval 0 Success; otherwise - Kerberos error codes
  5323. */
  5324. krb5_error_code KRB5_CALLCONV
  5325. krb5_auth_con_setrecvsubkey(krb5_context ctx, krb5_auth_context ac,
  5326. krb5_keyblock *keyblock);
  5327. /**
  5328. * Set the receiving subkey in an auth context.
  5329. *
  5330. * @param [in] ctx Library context
  5331. * @param [in] ac Authentication context
  5332. * @param [in] key Receiving subkey
  5333. *
  5334. * This function sets the receiving subkey in @a ac to @a key, incrementing its
  5335. * reference count.
  5336. *
  5337. * @retval 0 Success; otherwise - Kerberos error codes
  5338. */
  5339. krb5_error_code KRB5_CALLCONV
  5340. krb5_auth_con_setrecvsubkey_k(krb5_context ctx, krb5_auth_context ac,
  5341. krb5_key key);
  5342. #if KRB5_DEPRECATED
  5343. /** @deprecated Replaced by krb5_auth_con_getsendsubkey(). */
  5344. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  5345. krb5_auth_con_getlocalsubkey(krb5_context context, krb5_auth_context auth_context,
  5346. krb5_keyblock **keyblock);
  5347. /** @deprecated Replaced by krb5_auth_con_getrecvsubkey(). */
  5348. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  5349. krb5_auth_con_getremotesubkey(krb5_context context, krb5_auth_context auth_context,
  5350. krb5_keyblock **keyblock);
  5351. #endif
  5352. /**
  5353. * Retrieve the local sequence number from an auth context.
  5354. *
  5355. * @param [in] context Library context
  5356. * @param [in] auth_context Authentication context
  5357. * @param [out] seqnumber Local sequence number
  5358. *
  5359. * Retrieve the local sequence number from @a auth_context and return it in @a
  5360. * seqnumber. The #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag must be set in @a
  5361. * auth_context for this function to be useful.
  5362. *
  5363. * @retval 0 Success; otherwise - Kerberos error codes
  5364. */
  5365. krb5_error_code KRB5_CALLCONV
  5366. krb5_auth_con_getlocalseqnumber(krb5_context context, krb5_auth_context auth_context,
  5367. krb5_int32 *seqnumber);
  5368. /**
  5369. * Retrieve the remote sequence number from an auth context.
  5370. *
  5371. * @param [in] context Library context
  5372. * @param [in] auth_context Authentication context
  5373. * @param [out] seqnumber Remote sequence number
  5374. *
  5375. * Retrieve the remote sequence number from @a auth_context and return it in @a
  5376. * seqnumber. The #KRB5_AUTH_CONTEXT_DO_SEQUENCE flag must be set in @a
  5377. * auth_context for this function to be useful.
  5378. *
  5379. * @retval 0 Success; otherwise - Kerberos error codes
  5380. */
  5381. krb5_error_code KRB5_CALLCONV
  5382. krb5_auth_con_getremoteseqnumber(krb5_context context, krb5_auth_context auth_context,
  5383. krb5_int32 *seqnumber);
  5384. #if KRB5_DEPRECATED
  5385. /** @deprecated Not replaced.
  5386. *
  5387. * RFC 4120 doesn't have anything like the initvector concept;
  5388. * only really old protocols may need this API.
  5389. */
  5390. KRB5_ATTR_DEPRECATED krb5_error_code KRB5_CALLCONV
  5391. krb5_auth_con_initivector(krb5_context context, krb5_auth_context auth_context);
  5392. #endif
  5393. /**
  5394. * Set the replay cache in an auth context.
  5395. *
  5396. * @param [in] context Library context
  5397. * @param [in] auth_context Authentication context
  5398. * @param [in] rcache Replay cache haddle
  5399. *
  5400. * This function sets the replay cache in @a auth_context to @a rcache. @a
  5401. * rcache will be closed when @a auth_context is freed, so the caller should
  5402. * relinguish that responsibility.
  5403. *
  5404. * @retval 0 Success; otherwise - Kerberos error codes
  5405. */
  5406. krb5_error_code KRB5_CALLCONV
  5407. krb5_auth_con_setrcache(krb5_context context, krb5_auth_context auth_context,
  5408. krb5_rcache rcache);
  5409. /**
  5410. * Retrieve the replay cache from an auth context.
  5411. *
  5412. * @param [in] context Library context
  5413. * @param [in] auth_context Authentication context
  5414. * @param [out] rcache Replay cache handle
  5415. *
  5416. * This function fetches the replay cache from @a auth_context. The caller
  5417. * should not close @a rcache.
  5418. *
  5419. * @retval 0 (always)
  5420. */
  5421. krb5_error_code KRB5_CALLCONV_WRONG
  5422. krb5_auth_con_getrcache(krb5_context context, krb5_auth_context auth_context,
  5423. krb5_rcache *rcache);
  5424. /**
  5425. * Retrieve the authenticator from an auth context.
  5426. *
  5427. * @param [in] context Library context
  5428. * @param [in] auth_context Authentication context
  5429. * @param [out] authenticator Authenticator
  5430. *
  5431. * Use krb5_free_authenticator() to free @a authenticator when it is no longer
  5432. * needed.
  5433. *
  5434. * @retval 0 Success. Otherwise - Kerberos error codes
  5435. */
  5436. krb5_error_code KRB5_CALLCONV
  5437. krb5_auth_con_getauthenticator(krb5_context context, krb5_auth_context auth_context,
  5438. krb5_authenticator **authenticator);
  5439. /**
  5440. * Set checksum type in an an auth context.
  5441. *
  5442. * @param [in] context Library context
  5443. * @param [in] auth_context Authentication context
  5444. * @param [in] cksumtype Checksum type
  5445. *
  5446. * This function sets the checksum type in @a auth_context to be used by
  5447. * krb5_mk_req() for the authenticator checksum.
  5448. *
  5449. * @retval 0 Success. Otherwise - Kerberos error codes
  5450. */
  5451. krb5_error_code KRB5_CALLCONV
  5452. krb5_auth_con_set_req_cksumtype(krb5_context context, krb5_auth_context auth_context,
  5453. krb5_cksumtype cksumtype);
  5454. #define KRB5_REALM_BRANCH_CHAR '.'
  5455. /*
  5456. * end "func-proto.h"
  5457. */
  5458. /*
  5459. * begin stuff from libos.h
  5460. */
  5461. /**
  5462. * @brief Read a password from keyboard input.
  5463. *
  5464. * @param [in] context Library context
  5465. * @param [in] prompt First user prompt when reading password
  5466. * @param [in] prompt2 Second user prompt (NULL to prompt only once)
  5467. * @param [out] return_pwd Returned password
  5468. * @param [in,out] size_return On input, maximum size of password; on output,
  5469. * size of password read
  5470. *
  5471. * This function reads a password from keyboard input and stores it in @a
  5472. * return_pwd. @a size_return should be set by the caller to the amount of
  5473. * storage space available in @a return_pwd; on successful return, it will be
  5474. * set to the length of the password read.
  5475. *
  5476. * @a prompt is printed to the terminal, followed by ": ", and then a password
  5477. * is read from the keyboard.
  5478. *
  5479. * If @a prompt2 is NULL, the password is read only once. Otherwise, @a
  5480. * prompt2 is printed to the terminal and a second password is read. If the
  5481. * two passwords entered are not identical, KRB5_LIBOS_BADPWDMATCH is returned.
  5482. *
  5483. * Echoing is turned off when the password is read.
  5484. *
  5485. * @retval
  5486. * 0 Success
  5487. * @return
  5488. * Error in reading or verifying the password
  5489. * @return
  5490. * Kerberos error codes
  5491. */
  5492. krb5_error_code KRB5_CALLCONV
  5493. krb5_read_password(krb5_context context,
  5494. const char *prompt, const char *prompt2,
  5495. char *return_pwd, unsigned int *size_return);
  5496. /**
  5497. * Convert a principal name to a local name.
  5498. *
  5499. * @param [in] context Library context
  5500. * @param [in] aname Principal name
  5501. * @param [in] lnsize_in Space available in @a lname
  5502. * @param [out] lname Local name buffer to be filled in
  5503. *
  5504. * If @a aname does not correspond to any local account, KRB5_LNAME_NOTRANS is
  5505. * returned. If @a lnsize_in is too small for the local name,
  5506. * KRB5_CONFIG_NOTENUFSPACE is returned.
  5507. *
  5508. * Local names, rather than principal names, can be used by programs that
  5509. * translate to an environment-specific name (for example, a user account
  5510. * name).
  5511. *
  5512. * @retval
  5513. * 0 Success
  5514. * @retval
  5515. * System errors
  5516. * @return
  5517. * Kerberos error codes
  5518. */
  5519. krb5_error_code KRB5_CALLCONV
  5520. krb5_aname_to_localname(krb5_context context, krb5_const_principal aname,
  5521. int lnsize_in, char *lname);
  5522. /**
  5523. * Get the Kerberos realm names for a host.
  5524. *
  5525. * @param [in] context Library context
  5526. * @param [in] host Host name (or NULL)
  5527. * @param [out] realmsp Null-terminated list of realm names
  5528. *
  5529. * Fill in @a realmsp with a pointer to a null-terminated list of realm names.
  5530. * If there are no known realms for the host, a list containing the referral
  5531. * (empty) realm is returned.
  5532. *
  5533. * If @a host is NULL, the local host's realms are determined.
  5534. *
  5535. * Use krb5_free_host_realm() to release @a realmsp when it is no longer
  5536. * needed.
  5537. *
  5538. * @retval
  5539. * 0 Success
  5540. * @retval
  5541. * ENOMEM Insufficient memory
  5542. * @return
  5543. * Kerberos error codes
  5544. */
  5545. krb5_error_code KRB5_CALLCONV
  5546. krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp);
  5547. /**
  5548. *
  5549. * @param [in] context Library context
  5550. * @param [in] hdata Host name (or NULL)
  5551. * @param [out] realmsp Null-terminated list of realm names
  5552. *
  5553. * Fill in @a realmsp with a pointer to a null-terminated list of realm names
  5554. * obtained through heuristics or insecure resolution methods which have lower
  5555. * priority than KDC referrals.
  5556. *
  5557. * If @a host is NULL, the local host's realms are determined.
  5558. *
  5559. * Use krb5_free_host_realm() to release @a realmsp when it is no longer
  5560. * needed.
  5561. */
  5562. krb5_error_code KRB5_CALLCONV
  5563. krb5_get_fallback_host_realm(krb5_context context,
  5564. krb5_data *hdata, char ***realmsp);
  5565. /**
  5566. * Free the memory allocated by krb5_get_host_realm().
  5567. *
  5568. * @param [in] context Library context
  5569. * @param [in] realmlist List of realm names to be released
  5570. *
  5571. * @retval
  5572. * 0 Success
  5573. * @return
  5574. * Kerberos error codes
  5575. */
  5576. krb5_error_code KRB5_CALLCONV
  5577. krb5_free_host_realm(krb5_context context, char *const *realmlist);
  5578. /**
  5579. * Determine if a principal is authorized to log in as a local user.
  5580. *
  5581. * @param [in] context Library context
  5582. * @param [in] principal Principal name
  5583. * @param [in] luser Local username
  5584. *
  5585. * Determine whether @a principal is authorized to log in as a local user @a
  5586. * luser.
  5587. *
  5588. * @retval
  5589. * TRUE Principal is authorized to log in as user; FALSE otherwise.
  5590. */
  5591. krb5_boolean KRB5_CALLCONV
  5592. krb5_kuserok(krb5_context context, krb5_principal principal, const char *luser);
  5593. /**
  5594. * Generate auth context addresses from a connected socket.
  5595. *
  5596. * @param [in] context Library context
  5597. * @param [in] auth_context Authentication context
  5598. * @param [in] infd Connected socket descriptor
  5599. * @param [in] flags Flags
  5600. *
  5601. * This function sets the local and/or remote addresses in @a auth_context
  5602. * based on the local and remote endpoints of the socket @a infd. The
  5603. * following flags determine the operations performed:
  5604. *
  5605. * @li #KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR Generate local address.
  5606. * @li #KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR Generate remote address.
  5607. * @li #KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR Generate local address and port.
  5608. * @li #KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR Generate remote address and port.
  5609. *
  5610. * @retval 0 Success; otherwise - Kerberos error codes
  5611. */
  5612. krb5_error_code KRB5_CALLCONV
  5613. krb5_auth_con_genaddrs(krb5_context context, krb5_auth_context auth_context,
  5614. int infd, int flags);
  5615. /**
  5616. * Set time offset field in a krb5_context structure.
  5617. *
  5618. * @param [in] context Library context
  5619. * @param [in] seconds Real time, seconds portion
  5620. * @param [in] microseconds Real time, microseconds portion
  5621. *
  5622. * This function sets the time offset in @a context to the difference between
  5623. * the system time and the real time as determined by @a seconds and @a
  5624. * microseconds.
  5625. *
  5626. * @retval 0 Success; otherwise - Kerberos error codes
  5627. */
  5628. krb5_error_code KRB5_CALLCONV
  5629. krb5_set_real_time(krb5_context context, krb5_timestamp seconds,
  5630. krb5_int32 microseconds);
  5631. /**
  5632. * Return the time offsets from the os context.
  5633. *
  5634. * @param [in] context Library context
  5635. * @param [out] seconds Time offset, seconds portion
  5636. * @param [out] microseconds Time offset, microseconds portion
  5637. *
  5638. * This function returns the time offsets in @a context.
  5639. *
  5640. * @retval 0 Success; otherwise - Kerberos error codes
  5641. */
  5642. krb5_error_code KRB5_CALLCONV
  5643. krb5_get_time_offsets(krb5_context context, krb5_timestamp *seconds, krb5_int32 *microseconds);
  5644. /* str_conv.c */
  5645. /**
  5646. * Convert a string to an encryption type.
  5647. *
  5648. * @param [in] string String to convert to an encryption type
  5649. * @param [out] enctypep Encryption type
  5650. *
  5651. * @retval 0 Success; otherwise - EINVAL
  5652. */
  5653. krb5_error_code KRB5_CALLCONV
  5654. krb5_string_to_enctype(char *string, krb5_enctype *enctypep);
  5655. /**
  5656. * Convert a string to a salt type.
  5657. *
  5658. * @param [in] string String to convert to an encryption type
  5659. * @param [out] salttypep Salt type to be filled in
  5660. *
  5661. * @retval 0 Success; otherwise - EINVAL
  5662. */
  5663. krb5_error_code KRB5_CALLCONV
  5664. krb5_string_to_salttype(char *string, krb5_int32 *salttypep);
  5665. /**
  5666. * Convert a string to a checksum type.
  5667. *
  5668. * @param [in] string String to be converted
  5669. * @param [out] cksumtypep Checksum type to be filled in
  5670. *
  5671. * @retval 0 Success; otherwise - EINVAL
  5672. */
  5673. krb5_error_code KRB5_CALLCONV
  5674. krb5_string_to_cksumtype(char *string, krb5_cksumtype *cksumtypep);
  5675. /**
  5676. * Convert a string to a timestamp.
  5677. *
  5678. * @param [in] string String to be converted
  5679. * @param [out] timestampp Pointer to timestamp
  5680. *
  5681. * @retval 0 Success; otherwise - EINVAL
  5682. */
  5683. krb5_error_code KRB5_CALLCONV
  5684. krb5_string_to_timestamp(char *string, krb5_timestamp *timestampp);
  5685. /**
  5686. * Convert a string to a delta time value.
  5687. *
  5688. * @param [in] string String to be converted
  5689. * @param [out] deltatp Delta time to be filled in
  5690. *
  5691. * @retval 0 Success; otherwise - KRB5_DELTAT_BADFORMAT
  5692. */
  5693. krb5_error_code KRB5_CALLCONV
  5694. krb5_string_to_deltat(char *string, krb5_deltat *deltatp);
  5695. /**
  5696. * Convert an encryption type to a string.
  5697. *
  5698. * @param [in] enctype Encryption type
  5699. * @param [out] buffer Buffer to hold encryption type string
  5700. * @param [in] buflen Storage available in @a buffer
  5701. *
  5702. * @retval 0 Success; otherwise - Kerberos error codes
  5703. */
  5704. krb5_error_code KRB5_CALLCONV
  5705. krb5_enctype_to_string(krb5_enctype enctype, char *buffer, size_t buflen);
  5706. /**
  5707. * Convert an encryption type to a name or alias.
  5708. *
  5709. * @param [in] enctype Encryption type
  5710. * @param [in] shortest Flag
  5711. * @param [out] buffer Buffer to hold encryption type string
  5712. * @param [in] buflen Storage available in @a buffer
  5713. *
  5714. * If @a shortest is FALSE, this function returns the enctype's canonical name
  5715. * (like "aes128-cts-hmac-sha1-96"). If @a shortest is TRUE, it return the
  5716. * enctype's shortest alias (like "aes128-cts").
  5717. *
  5718. * @retval 0 Success; otherwise - Kerberos error codes
  5719. */
  5720. krb5_error_code KRB5_CALLCONV
  5721. krb5_enctype_to_name(krb5_enctype enctype, krb5_boolean shortest,
  5722. char *buffer, size_t buflen);
  5723. /**
  5724. * Convert a salt type to a string.
  5725. *
  5726. * @param [in] salttype Salttype to convert
  5727. * @param [out] buffer Buffer to receive the converted string
  5728. * @param [in] buflen Storage available in @a buffer
  5729. *
  5730. * @retval 0 Success; otherwise - Kerberos error codes
  5731. */
  5732. krb5_error_code KRB5_CALLCONV
  5733. krb5_salttype_to_string(krb5_int32 salttype, char *buffer, size_t buflen);
  5734. /**
  5735. * Convert a checksum type to a string.
  5736. *
  5737. * @param [in] cksumtype Checksum type
  5738. * @param [out] buffer Buffer to hold converted checksum type
  5739. * @param [in] buflen Storage available in @a buffer
  5740. *
  5741. * @retval 0 Success; otherwise - Kerberos error codes
  5742. */
  5743. krb5_error_code KRB5_CALLCONV
  5744. krb5_cksumtype_to_string(krb5_cksumtype cksumtype, char *buffer, size_t buflen);
  5745. /**
  5746. * Convert a timestamp to a string.
  5747. *
  5748. * @param [in] timestamp Timestamp to convert
  5749. * @param [out] buffer Buffer to hold converted timestamp
  5750. * @param [in] buflen Storage available in @a buffer
  5751. *
  5752. * The string is returned in the locale's appropriate date and time
  5753. * representation.
  5754. *
  5755. * @retval 0 Success; otherwise - Kerberos error codes
  5756. */
  5757. krb5_error_code KRB5_CALLCONV
  5758. krb5_timestamp_to_string(krb5_timestamp timestamp, char *buffer, size_t buflen);
  5759. /**
  5760. * Convert a timestamp to a string, with optional output padding
  5761. *
  5762. * @param [in] timestamp Timestamp to convert
  5763. * @param [out] buffer Buffer to hold the converted timestamp
  5764. * @param [in] buflen Length of buffer
  5765. * @param [in] pad Optional value to pad @a buffer if converted
  5766. * timestamp does not fill it
  5767. *
  5768. * If @a pad is not NULL, @a buffer is padded out to @a buflen - 1 characters
  5769. * with the value of *@a pad.
  5770. *
  5771. * @retval 0 Success; otherwise - Kerberos error codes
  5772. */
  5773. krb5_error_code KRB5_CALLCONV
  5774. krb5_timestamp_to_sfstring(krb5_timestamp timestamp, char *buffer,
  5775. size_t buflen, char *pad);
  5776. /**
  5777. * Convert a relative time value to a string.
  5778. *
  5779. * @param [in] deltat Relative time value to convert
  5780. * @param [out] buffer Buffer to hold time string
  5781. * @param [in] buflen Storage available in @a buffer
  5782. *
  5783. * @retval 0 Success; otherwise - Kerberos error codes
  5784. */
  5785. krb5_error_code KRB5_CALLCONV
  5786. krb5_deltat_to_string(krb5_deltat deltat, char *buffer, size_t buflen);
  5787. /* The name of the Kerberos ticket granting service... and its size */
  5788. #define KRB5_TGS_NAME "krbtgt"
  5789. #define KRB5_TGS_NAME_SIZE 6
  5790. /* flags for recvauth */
  5791. #define KRB5_RECVAUTH_SKIP_VERSION 0x0001
  5792. #define KRB5_RECVAUTH_BADAUTHVERS 0x0002
  5793. /* initial ticket api functions */
  5794. /** Text for prompt used in prompter callback function. */
  5795. typedef struct _krb5_prompt {
  5796. char *prompt; /**< The prompt to show to the user */
  5797. int hidden; /**< Boolean; informative prompt or hidden (e.g. PIN) */
  5798. krb5_data *reply; /**< Must be allocated before call to prompt routine */
  5799. } krb5_prompt;
  5800. /** Pointer to a prompter callback function. */
  5801. typedef krb5_error_code
  5802. (KRB5_CALLCONV *krb5_prompter_fct)(krb5_context context, void *data,
  5803. const char *name, const char *banner,
  5804. int num_prompts, krb5_prompt prompts[]);
  5805. /**
  5806. * Prompt user for password.
  5807. *
  5808. * @param [in] context Library context
  5809. * @param data Unused (callback argument)
  5810. * @param [in] name Name to output during prompt
  5811. * @param [in] banner Banner to output during prompt
  5812. * @param [in] num_prompts Number of prompts in @a prompts
  5813. * @param [in,out] prompts Array of output prompts and replies
  5814. *
  5815. * This function is intended to be used as a prompter callback for
  5816. * krb5_get_init_creds_password() or krb5_init_creds_init().
  5817. *
  5818. * Writes @a name and @a banner to stdout, each followed by a newline, then
  5819. * writes each prompt field in the @a prompts array, followed by ": ", and sets
  5820. * the reply field of the entry to a line of input read from stdin. If the
  5821. * hidden flag is set for a prompt, then terminal echoing is turned off when
  5822. * input is read.
  5823. *
  5824. * @retval
  5825. * 0 Success
  5826. * @return
  5827. * Kerberos error codes
  5828. *
  5829. */
  5830. krb5_error_code KRB5_CALLCONV
  5831. krb5_prompter_posix(krb5_context context, void *data, const char *name,
  5832. const char *banner, int num_prompts,
  5833. krb5_prompt prompts[]);
  5834. /** Store options for @c _krb5_get_init_creds */
  5835. typedef struct _krb5_get_init_creds_opt {
  5836. krb5_flags flags;
  5837. krb5_deltat tkt_life;
  5838. krb5_deltat renew_life;
  5839. int forwardable;
  5840. int proxiable;
  5841. krb5_enctype *etype_list;
  5842. int etype_list_length;
  5843. krb5_address **address_list;
  5844. krb5_preauthtype *preauth_list;
  5845. int preauth_list_length;
  5846. krb5_data *salt;
  5847. } krb5_get_init_creds_opt;
  5848. #define KRB5_GET_INIT_CREDS_OPT_TKT_LIFE 0x0001
  5849. #define KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE 0x0002
  5850. #define KRB5_GET_INIT_CREDS_OPT_FORWARDABLE 0x0004
  5851. #define KRB5_GET_INIT_CREDS_OPT_PROXIABLE 0x0008
  5852. #define KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST 0x0010
  5853. #define KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST 0x0020
  5854. #define KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST 0x0040
  5855. #define KRB5_GET_INIT_CREDS_OPT_SALT 0x0080
  5856. #define KRB5_GET_INIT_CREDS_OPT_CHG_PWD_PRMPT 0x0100
  5857. #define KRB5_GET_INIT_CREDS_OPT_CANONICALIZE 0x0200
  5858. #define KRB5_GET_INIT_CREDS_OPT_ANONYMOUS 0x0400
  5859. /**
  5860. * Allocate a new initial credential options structure.
  5861. *
  5862. * @param [in] context Library context
  5863. * @param [out] opt New options structure
  5864. *
  5865. * This function is the preferred way to create an options structure for
  5866. * getting initial credentials, and is required to make use of certain options.
  5867. * Use krb5_get_init_creds_opt_free() to free @a opt when it is no longer
  5868. * needed.
  5869. *
  5870. * @retval 0 - Success; Kerberos errors otherwise.
  5871. */
  5872. krb5_error_code KRB5_CALLCONV
  5873. krb5_get_init_creds_opt_alloc(krb5_context context,
  5874. krb5_get_init_creds_opt **opt);
  5875. /**
  5876. * Free initial credential options.
  5877. *
  5878. * @param [in] context Library context
  5879. * @param [in] opt Options structure to free
  5880. *
  5881. * @sa krb5_get_init_creds_opt_alloc()
  5882. */
  5883. void KRB5_CALLCONV
  5884. krb5_get_init_creds_opt_free(krb5_context context,
  5885. krb5_get_init_creds_opt *opt);
  5886. /** @deprecated Use krb5_get_init_creds_opt_alloc() instead. */
  5887. void KRB5_CALLCONV
  5888. krb5_get_init_creds_opt_init(krb5_get_init_creds_opt *opt);
  5889. /**
  5890. * Set the ticket lifetime in initial credential options.
  5891. *
  5892. * @param [in] opt Options structure
  5893. * @param [in] tkt_life Ticket lifetime
  5894. */
  5895. void KRB5_CALLCONV
  5896. krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt *opt,
  5897. krb5_deltat tkt_life);
  5898. /**
  5899. * Set the ticket renewal lifetime in initial credential options.
  5900. *
  5901. * @param [in] opt Pointer to @a options field
  5902. * @param [in] renew_life Ticket renewal lifetime
  5903. */
  5904. void KRB5_CALLCONV
  5905. krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt *opt,
  5906. krb5_deltat renew_life);
  5907. /**
  5908. * Set or unset the forwardable flag in initial credential options.
  5909. *
  5910. * @param [in] opt Options structure
  5911. * @param [in] forwardable Whether credentials should be forwardable
  5912. */
  5913. void KRB5_CALLCONV
  5914. krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt *opt,
  5915. int forwardable);
  5916. /**
  5917. * Set or unset the proxiable flag in initial credential options.
  5918. *
  5919. * @param [in] opt Options structure
  5920. * @param [in] proxiable Whether credentials should be proxiable
  5921. */
  5922. void KRB5_CALLCONV
  5923. krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt *opt,
  5924. int proxiable);
  5925. /**
  5926. * Set or unset the canonicalize flag in initial credential options.
  5927. *
  5928. * @param [in] opt Options structure
  5929. * @param [in] canonicalize Whether to canonicalize client principal
  5930. */
  5931. void KRB5_CALLCONV
  5932. krb5_get_init_creds_opt_set_canonicalize(krb5_get_init_creds_opt *opt,
  5933. int canonicalize);
  5934. /**
  5935. * Set or unset the anonymous flag in initial credential options.
  5936. *
  5937. * @param [in] opt Options structure
  5938. * @param [in] anonymous Whether to make an anonymous request
  5939. *
  5940. * This function may be used to request anonymous credentials from the KDC by
  5941. * setting @a anonymous to non-zero. Note that anonymous credentials are only
  5942. * a request; clients must verify that credentials are anonymous if that is a
  5943. * requirement.
  5944. */
  5945. void KRB5_CALLCONV
  5946. krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt *opt,
  5947. int anonymous);
  5948. /**
  5949. * Set allowable encryption types in initial credential options.
  5950. *
  5951. * @param [in] opt Options structure
  5952. * @param [in] etype_list Array of encryption types
  5953. * @param [in] etype_list_length Length of @a etype_list
  5954. */
  5955. void KRB5_CALLCONV
  5956. krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt *opt,
  5957. krb5_enctype *etype_list,
  5958. int etype_list_length);
  5959. /**
  5960. * Set address restrictions in initial credential options.
  5961. *
  5962. * @param [in] opt Options structure
  5963. * @param [in] addresses Null-terminated array of addresses
  5964. */
  5965. void KRB5_CALLCONV
  5966. krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt,
  5967. krb5_address **addresses);
  5968. /**
  5969. * Set preauthentication types in initial credential options.
  5970. *
  5971. * @param [in] opt Options structure
  5972. * @param [in] preauth_list Array of preauthentication types
  5973. * @param [in] preauth_list_length Length of @a preauth_list
  5974. *
  5975. * This function can be used to perform optimistic preauthentication when
  5976. * getting initial credentials, in combination with
  5977. * krb5_get_init_creds_opt_set_salt() and krb5_get_init_creds_opt_set_pa().
  5978. */
  5979. void KRB5_CALLCONV
  5980. krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt,
  5981. krb5_preauthtype *preauth_list,
  5982. int preauth_list_length);
  5983. /**
  5984. * Set salt for optimistic preauthentication in initial credential options.
  5985. *
  5986. * @param [in] opt Options structure
  5987. * @param [in] salt Salt data
  5988. *
  5989. * When getting initial credentials with a password, a salt string it used to
  5990. * convert the password to a key. Normally this salt is obtained from the
  5991. * first KDC reply, but when performing optimistic preauthentication, the
  5992. * client may need to supply the salt string with this function.
  5993. */
  5994. void KRB5_CALLCONV
  5995. krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt,
  5996. krb5_data *salt);
  5997. /**
  5998. * Set or unset change-password-prompt flag in initial credential options.
  5999. *
  6000. * @param [in] opt Options structure
  6001. * @param [in] prompt Whether to prompt to change password
  6002. *
  6003. * This flag is on by default. It controls whether
  6004. * krb5_get_init_creds_password() will react to an expired-password error by
  6005. * prompting for a new password and attempting to change the old one.
  6006. */
  6007. void KRB5_CALLCONV
  6008. krb5_get_init_creds_opt_set_change_password_prompt(krb5_get_init_creds_opt *opt,
  6009. int prompt);
  6010. /** Generic preauth option attribute/value pairs */
  6011. typedef struct _krb5_gic_opt_pa_data {
  6012. char *attr;
  6013. char *value;
  6014. } krb5_gic_opt_pa_data;
  6015. /**
  6016. * Supply options for preauthentication in initial credential options.
  6017. *
  6018. * @param [in] context Library context
  6019. * @param [in] opt Options structure
  6020. * @param [in] attr Preauthentication option name
  6021. * @param [in] value Preauthentication option value
  6022. *
  6023. * This function allows the caller to supply options for preauthentication.
  6024. * The values of @a attr and @a value are supplied to each preauthentication
  6025. * module available within @a context.
  6026. */
  6027. krb5_error_code KRB5_CALLCONV
  6028. krb5_get_init_creds_opt_set_pa(krb5_context context,
  6029. krb5_get_init_creds_opt *opt, const char *attr,
  6030. const char *value);
  6031. /**
  6032. * Set location of FAST armor ccache in initial credential options.
  6033. *
  6034. * @param [in] context Library context
  6035. * @param [in] opt Options
  6036. * @param [in] fast_ccache_name Credential cache name
  6037. *
  6038. * Sets the location of a credential cache containing an armor ticket to
  6039. * protect an initial credential exchange using the FAST protocol extension.
  6040. *
  6041. * In version 1.7, setting an armor ccache requires that FAST be used for the
  6042. * exchange. In version 1.8 or later, setting the armor ccache causes FAST to
  6043. * be used if the KDC supports it; krb5_get_init_creds_opt_set_fast_flags()
  6044. * must be used to require that FAST be used.
  6045. */
  6046. krb5_error_code KRB5_CALLCONV
  6047. krb5_get_init_creds_opt_set_fast_ccache_name(krb5_context context,
  6048. krb5_get_init_creds_opt *opt,
  6049. const char *fast_ccache_name);
  6050. /**
  6051. * Set FAST armor cache in initial credential options.
  6052. *
  6053. * @param [in] context Library context
  6054. * @param [in] opt Options
  6055. * @param [in] ccache Credential cache handle
  6056. *
  6057. * This function is similar to krb5_get_init_creds_opt_set_fast_ccache_name(),
  6058. * but uses a credential cache handle instead of a name.
  6059. */
  6060. krb5_error_code KRB5_CALLCONV
  6061. krb5_get_init_creds_opt_set_fast_ccache(krb5_context context,
  6062. krb5_get_init_creds_opt *opt,
  6063. krb5_ccache ccache);
  6064. /**
  6065. * Set an output credential cache in initial credential options.
  6066. *
  6067. * @param [in] context Library context
  6068. * @param [in] opt Options
  6069. * @param [in] ccache Credential cache handle
  6070. *
  6071. * If an output credential cache is set, then the krb5_get_init_creds family of
  6072. * APIs will write credentials to it. Setting an output ccache is desirable
  6073. * both because it simplifies calling code and because it permits the
  6074. * krb5_get_init_creds APIs to write out configuration information about the
  6075. * realm to the ccache.
  6076. */
  6077. krb5_error_code KRB5_CALLCONV
  6078. krb5_get_init_creds_opt_set_out_ccache(krb5_context context,
  6079. krb5_get_init_creds_opt *opt,
  6080. krb5_ccache ccache);
  6081. /**
  6082. * Set FAST flags in initial credential options.
  6083. *
  6084. * @param [in] context Library context
  6085. * @param [in] opt Options
  6086. * @param [in] flags FAST flags
  6087. *
  6088. * The following flag values are valid:
  6089. * @li #KRB5_FAST_REQUIRED - Require FAST to be used
  6090. *
  6091. * @retval
  6092. * 0 - Success; Kerberos errors otherwise.
  6093. */
  6094. krb5_error_code KRB5_CALLCONV
  6095. krb5_get_init_creds_opt_set_fast_flags(krb5_context context,
  6096. krb5_get_init_creds_opt *opt,
  6097. krb5_flags flags);
  6098. /**
  6099. * Retrieve FAST flags from initial credential options.
  6100. *
  6101. * @param [in] context Library context
  6102. * @param [in] opt Options
  6103. * @param [out] out_flags FAST flags
  6104. *
  6105. * @retval
  6106. * 0 - Success; Kerberos errors otherwise.
  6107. */
  6108. krb5_error_code KRB5_CALLCONV
  6109. krb5_get_init_creds_opt_get_fast_flags(krb5_context context,
  6110. krb5_get_init_creds_opt *opt,
  6111. krb5_flags *out_flags);
  6112. /* Fast flags*/
  6113. #define KRB5_FAST_REQUIRED 1l<<0 /**< Require KDC to support FAST*/
  6114. typedef void
  6115. (KRB5_CALLCONV *krb5_expire_callback_func)(krb5_context context, void *data,
  6116. krb5_timestamp password_expiration,
  6117. krb5_timestamp account_expiration,
  6118. krb5_boolean is_last_req);
  6119. /**
  6120. * Set an expiration callback in initial credential options.
  6121. *
  6122. * @param [in] context Library context
  6123. * @param [in] opt Options structure
  6124. * @param [in] cb Callback function
  6125. * @param [in] data Callback argument
  6126. *
  6127. * Set a callback to receive password and account expiration times.
  6128. *
  6129. * This option only applies to krb5_get_init_creds_password(). @a cb will be
  6130. * invoked if and only if credentials are successfully acquired. The callback
  6131. * will receive the @a context from the krb5_get_init_creds_password() call and
  6132. * the @a data argument supplied with this API. The remaining arguments should
  6133. * be interpreted as follows:
  6134. *
  6135. * If @a is_last_req is true, then the KDC reply contained last-req entries
  6136. * which unambiguously indicated the password expiration, account expiration,
  6137. * or both. (If either value was not present, the corresponding argument will
  6138. * be 0.) Furthermore, a non-zero @a password_expiration should be taken as a
  6139. * suggestion from the KDC that a warning be displayed.
  6140. *
  6141. * If @a is_last_req is false, then @a account_expiration will be 0 and @a
  6142. * password_expiration will contain the expiration time of either the password
  6143. * or account, or 0 if no expiration time was indicated in the KDC reply. The
  6144. * callback should independently decide whether to display a password
  6145. * expiration warning.
  6146. *
  6147. * Note that @a cb may be invoked even if credentials are being acquired for
  6148. * the kadmin/changepw service in order to change the password. It is the
  6149. * caller's responsibility to avoid displaying a password expiry warning in
  6150. * this case.
  6151. *
  6152. * @warning Setting an expire callback with this API will cause
  6153. * krb5_get_init_creds_password() not to send password expiry warnings to the
  6154. * prompter, as it ordinarily may.
  6155. */
  6156. krb5_error_code KRB5_CALLCONV
  6157. krb5_get_init_creds_opt_set_expire_callback(krb5_context context,
  6158. krb5_get_init_creds_opt *opt,
  6159. krb5_expire_callback_func cb,
  6160. void *data);
  6161. /**
  6162. * Get initial credentials using a password.
  6163. *
  6164. * @param [in] context Library context
  6165. * @param [out] creds New credentials
  6166. * @param [in] client Client principal
  6167. * @param [in] password Password (or NULL)
  6168. * @param [in] prompter Prompter function
  6169. * @param [in] data Prompter callback data
  6170. * @param [in] start_time Time when ticket becomes valid (0 for now)
  6171. * @param [in] in_tkt_service Service name of initial credentials (or NULL)
  6172. * @param [in] k5_gic_options Initial credential options
  6173. *
  6174. * This function requests KDC for an initial credentials for @a client using @a
  6175. * password. If @a password is NULL, a password will be prompted for using @a
  6176. * prompter if necessary. If @a in_tkt_service is specified, it is parsed as a
  6177. * principal name (with the realm ignored) and used as the service principal
  6178. * for the request; otherwise the ticket-granting service is used.
  6179. *
  6180. * @sa krb5_verify_init_creds()
  6181. *
  6182. * @retval
  6183. * 0 Success
  6184. * @retval
  6185. * EINVAL Invalid argument
  6186. * @retval
  6187. * KRB5_KDC_UNREACH Cannot contact any KDC for requested realm
  6188. * @retval
  6189. * KRB5_PREAUTH_FAILED Generic Pre-athentication failure
  6190. * @retval
  6191. * KRB5_LIBOS_PWDINTR Password read interrupted
  6192. * @retval
  6193. * KRB5_REALM_CANT_RESOLVE Cannot resolve network address for KDC in requested realm
  6194. * @retval
  6195. * KRB5KDC_ERR_KEY_EXP Password has expired
  6196. * @retval
  6197. * KRB5_LIBOS_BADPWDMATCH Password mismatch
  6198. * @retval
  6199. * KRB5_CHPW_PWDNULL New password cannot be zero length
  6200. * @retval
  6201. * KRB5_CHPW_FAIL Password change failed
  6202. * @return
  6203. * Kerberos error codes
  6204. */
  6205. krb5_error_code KRB5_CALLCONV
  6206. krb5_get_init_creds_password(krb5_context context, krb5_creds *creds,
  6207. krb5_principal client, char *password,
  6208. krb5_prompter_fct prompter, void *data,
  6209. krb5_deltat start_time, char *in_tkt_service,
  6210. krb5_get_init_creds_opt *k5_gic_options);
  6211. struct _krb5_init_creds_context;
  6212. typedef struct _krb5_init_creds_context *krb5_init_creds_context;
  6213. #define KRB5_INIT_CREDS_STEP_FLAG_CONTINUE 0x1 /* More responses needed */
  6214. /**
  6215. * Free an initial credentials context.
  6216. *
  6217. * @param [in] context Library context
  6218. * @param [in] ctx Initial credentials context
  6219. */
  6220. void KRB5_CALLCONV
  6221. krb5_init_creds_free(krb5_context context, krb5_init_creds_context ctx);
  6222. /**
  6223. * Acquire credentials using an initial credentials context.
  6224. *
  6225. * @param [in] context Library context
  6226. * @param [in] ctx Initial credentials context
  6227. *
  6228. * This function synchronously obtains credentials using a context created by
  6229. * krb5_init_creds_init(). On successful return, the credentials can be
  6230. * retrieved with krb5_init_creds_get_creds().
  6231. *
  6232. * @retval 0 Success; otherwise - Kerberos error codes
  6233. */
  6234. krb5_error_code KRB5_CALLCONV
  6235. krb5_init_creds_get(krb5_context context, krb5_init_creds_context ctx);
  6236. /**
  6237. * Retrieve acquired credentials from an initial credentials context.
  6238. *
  6239. * @param [in] context Library context
  6240. * @param [in] ctx Initial credentials context
  6241. * @param [out] creds Acquired credentials
  6242. *
  6243. * This function copies the acquired initial credentials from @a ctx into @a
  6244. * creds, after the successful completion of krb5_init_creds_get() or
  6245. * krb5_init_creds_step(). Use krb5_free_cred_contents() to free @a creds when
  6246. * it is no longer needed.
  6247. *
  6248. * @retval 0 Success; otherwise - Kerberos error codes
  6249. */
  6250. krb5_error_code KRB5_CALLCONV
  6251. krb5_init_creds_get_creds(krb5_context context, krb5_init_creds_context ctx,
  6252. krb5_creds *creds);
  6253. /**
  6254. * Get the last error from KDC from an initial credentials context.
  6255. *
  6256. * @param [in] context Library context
  6257. * @param [in] ctx Initial credentials context
  6258. * @param [out] error Error from KDC, or NULL if none was received
  6259. *
  6260. * @retval 0 Success; otherwise - Kerberos error codes
  6261. */
  6262. krb5_error_code KRB5_CALLCONV
  6263. krb5_init_creds_get_error(krb5_context context, krb5_init_creds_context ctx,
  6264. krb5_error **error);
  6265. /**
  6266. * Create a context for acquiring initial credentials.
  6267. *
  6268. * @param [in] context Library context
  6269. * @param [in] client Client principal to get initial creds for
  6270. * @param [in] prompter Prompter callback
  6271. * @param [in] data Prompter callback argument
  6272. * @param [in] start_time Time when credentials become valid (0 for now)
  6273. * @param [in] options Options structure (NULL for default)
  6274. * @param [out] ctx New initial credentials context
  6275. *
  6276. * This function creates a new context for acquiring initial credentials. Use
  6277. * krb5_init_creds_free() to free @a ctx when it is no longer needed.
  6278. *
  6279. * @retval 0 Success; otherwise - Kerberos error codes
  6280. */
  6281. krb5_error_code KRB5_CALLCONV
  6282. krb5_init_creds_init(krb5_context context, krb5_principal client,
  6283. krb5_prompter_fct prompter, void *data,
  6284. krb5_deltat start_time, krb5_get_init_creds_opt *options,
  6285. krb5_init_creds_context *ctx);
  6286. /**
  6287. * Specify a keytab to use for acquiring initial credentials.
  6288. *
  6289. * @param [in] context Library context
  6290. * @param [in] ctx Initial credentials context
  6291. * @param [in] keytab Key table handle
  6292. *
  6293. * This function supplies a keytab containing the client key for an initial
  6294. * credentials request.
  6295. *
  6296. * @retval 0 Success; otherwise - Kerberos error codes
  6297. */
  6298. krb5_error_code KRB5_CALLCONV
  6299. krb5_init_creds_set_keytab(krb5_context context, krb5_init_creds_context ctx,
  6300. krb5_keytab keytab);
  6301. /**
  6302. * Get the next KDC request for acquiring initial credentials.
  6303. *
  6304. * @param [in] context Library context
  6305. * @param [in] ctx Initial credentials context
  6306. * @param [in] in KDC response (empty on the first call)
  6307. * @param [out] out Next KDC request
  6308. * @param [out] realm Realm for next KDC request
  6309. * @param [out] flags Output flags
  6310. *
  6311. * This function constructs the next KDC request in an initial credential
  6312. * exchange, allowing the caller to control the transport of KDC requests and
  6313. * replies. On the first call, @a in should be set to an empty buffer; on
  6314. * subsequent calls, it should be set to the KDC's reply to the previous
  6315. * request.
  6316. *
  6317. * If more requests are needed, @a flags will be set to
  6318. * #KRB5_INIT_CREDS_STEP_FLAG_CONTINUE and the next request will be placed in
  6319. * @a out. If no more requests are needed, @a flags will not contain
  6320. * #KRB5_INIT_CREDS_STEP_FLAG_CONTINUE and @a out will be empty.
  6321. *
  6322. * If this function returns @c KRB5KRB_ERR_RESPONSE_TOO_BIG, the caller should
  6323. * transmit the next request using TCP rather than UDP. If this function
  6324. * returns any other error, the initial credential exchange has failed.
  6325. *
  6326. * @retval 0 Success; otherwise - Kerberos error codes
  6327. */
  6328. krb5_error_code KRB5_CALLCONV
  6329. krb5_init_creds_step(krb5_context context, krb5_init_creds_context ctx,
  6330. krb5_data *in, krb5_data *out, krb5_data *realm,
  6331. unsigned int *flags);
  6332. /**
  6333. * Set a password for acquiring initial credentials.
  6334. *
  6335. * @param [in] context Library context
  6336. * @param [in] ctx Initial credentials context
  6337. * @param [in] password Password
  6338. *
  6339. * This function supplies a password to be used to construct the client key for
  6340. * an initial credentials request.
  6341. *
  6342. * @retval 0 Success; otherwise - Kerberos error codes
  6343. */
  6344. krb5_error_code KRB5_CALLCONV
  6345. krb5_init_creds_set_password(krb5_context context, krb5_init_creds_context ctx,
  6346. const char *password);
  6347. /**
  6348. * Specify a service principal for acquiring initial credentials.
  6349. *
  6350. * @param [in] context Library context
  6351. * @param [in] ctx Initial credentials context
  6352. * @param [in] service Service principal string
  6353. *
  6354. * This function supplies a service principal string to acquire initial
  6355. * credentials for instead of the default krbtgt service. @a service is parsed
  6356. * as a principal name; any realm part is ignored.
  6357. *
  6358. * @retval 0 Success; otherwise - Kerberos error codes
  6359. */
  6360. krb5_error_code KRB5_CALLCONV
  6361. krb5_init_creds_set_service(krb5_context context, krb5_init_creds_context ctx,
  6362. const char *service);
  6363. /**
  6364. * Retrieve ticket times from an initial credentials context.
  6365. *
  6366. * @param [in] context Library context
  6367. * @param [in] ctx Initial credentials context
  6368. * @param [out] times Ticket times for acquired credentials
  6369. *
  6370. * The initial credentials context must have completed obtaining credentials
  6371. * via either krb5_init_creds_get() or krb5_init_creds_step().
  6372. *
  6373. * @retval 0 Success; otherwise - Kerberos error codes
  6374. */
  6375. krb5_error_code KRB5_CALLCONV
  6376. krb5_init_creds_get_times(krb5_context context, krb5_init_creds_context ctx,
  6377. krb5_ticket_times *times);
  6378. struct _krb5_tkt_creds_context;
  6379. typedef struct _krb5_tkt_creds_context *krb5_tkt_creds_context;
  6380. /**
  6381. * Create a context to get credentials from a KDC's Ticket Granting Service.
  6382. *
  6383. * @param[in] context Library context
  6384. * @param[in] ccache Credential cache handle
  6385. * @param[in] creds Input credentials
  6386. * @param[in] options @ref KRB5_GC options for this request.
  6387. * @param[out] ctx New TGS request context
  6388. *
  6389. * This function prepares to obtain credentials matching @a creds, either by
  6390. * retrieving them from @a ccache or by making requests to ticket-granting
  6391. * services beginning with a ticket-granting ticket for the client principal's
  6392. * realm.
  6393. *
  6394. * The resulting TGS acquisition context can be used asynchronously with
  6395. * krb5_tkt_creds_step() or synchronously with krb5_tkt_creds_get(). See also
  6396. * krb5_get_credentials() for synchronous use.
  6397. *
  6398. * Use krb5_tkt_creds_free() to free @a ctx when it is no longer needed.
  6399. *
  6400. * @retval 0 Success; otherwise - Kerberos error codes
  6401. */
  6402. krb5_error_code KRB5_CALLCONV
  6403. krb5_tkt_creds_init(krb5_context context, krb5_ccache ccache,
  6404. krb5_creds *creds, krb5_flags options,
  6405. krb5_tkt_creds_context *ctx);
  6406. /**
  6407. * Synchronously obtain credentials using a TGS request context.
  6408. *
  6409. * @param[in] context Library context
  6410. * @param[in] ctx TGS request context
  6411. *
  6412. * This function synchronously obtains credentials using a context created by
  6413. * krb5_tkt_creds_init(). On successful return, the credentials can be
  6414. * retrieved with krb5_tkt_creds_get_creds().
  6415. *
  6416. * @retval 0 Success; otherwise - Kerberos error codes
  6417. */
  6418. krb5_error_code KRB5_CALLCONV
  6419. krb5_tkt_creds_get(krb5_context context, krb5_tkt_creds_context ctx);
  6420. /**
  6421. * Retrieve acquired credentials from a TGS request context.
  6422. *
  6423. * @param[in] context Library context
  6424. * @param[in] ctx TGS request context
  6425. * @param[out] creds Acquired credentials
  6426. *
  6427. * This function copies the acquired initial credentials from @a ctx into @a
  6428. * creds, after the successful completion of krb5_tkt_creds_get() or
  6429. * krb5_tkt_creds_step(). Use krb5_free_cred_contents() to free @a creds when
  6430. * it is no longer needed.
  6431. *
  6432. * @retval 0 Success; otherwise - Kerberos error codes
  6433. */
  6434. krb5_error_code KRB5_CALLCONV
  6435. krb5_tkt_creds_get_creds(krb5_context context, krb5_tkt_creds_context ctx,
  6436. krb5_creds *creds);
  6437. /**
  6438. * Free a TGS request context.
  6439. *
  6440. * @param[in] context Library context
  6441. * @param[in] ctx TGS request context
  6442. */
  6443. void KRB5_CALLCONV
  6444. krb5_tkt_creds_free(krb5_context context, krb5_tkt_creds_context ctx);
  6445. #define KRB5_TKT_CREDS_STEP_FLAG_CONTINUE 0x1 /* More responses needed. */
  6446. /**
  6447. * Get the next KDC request in a TGS exchange.
  6448. *
  6449. * @param[in] context Library context
  6450. * @param[in] ctx TGS request context
  6451. * @param[in] in KDC response (empty on the first call)
  6452. * @param[out] out Next KDC request
  6453. * @param[out] realm Realm for next KDC request
  6454. * @param[out] flags Output flags
  6455. *
  6456. * This function constructs the next KDC request for a TGS exchange, allowing
  6457. * the caller to control the transport of KDC requests and replies. On the
  6458. * first call, @a in should be set to an empty buffer; on subsequent calls, it
  6459. * should be set to the KDC's reply to the previous request.
  6460. *
  6461. * If more requests are needed, @a flags will be set to
  6462. * #KRB5_TKT_CREDS_STEP_FLAG_CONTINUE and the next request will be placed in @a
  6463. * out. If no more requests are needed, @a flags will not contain
  6464. * #KRB5_TKT_CREDS_STEP_FLAG_CONTINUE and @a out will be empty.
  6465. *
  6466. * If this function returns @c KRB5KRB_ERR_RESPONSE_TOO_BIG, the caller should
  6467. * transmit the next request using TCP rather than UDP. If this function
  6468. * returns any other error, the TGS exchange has failed.
  6469. *
  6470. * @retval 0 Success; otherwise - Kerberos error codes
  6471. */
  6472. krb5_error_code KRB5_CALLCONV
  6473. krb5_tkt_creds_step(krb5_context context, krb5_tkt_creds_context ctx,
  6474. krb5_data *in, krb5_data *out, krb5_data *realm,
  6475. unsigned int *flags);
  6476. /**
  6477. * Retrieve ticket times from a TGS request context.
  6478. *
  6479. * @param[in] context Library context
  6480. * @param[in] ctx TGS request context
  6481. * @param[out] times Ticket times for acquired credentials
  6482. *
  6483. * The TGS request context must have completed obtaining credentials via either
  6484. * krb5_tkt_creds_get() or krb5_tkt_creds_step().
  6485. *
  6486. * @retval 0 Success; otherwise - Kerberos error codes
  6487. */
  6488. krb5_error_code KRB5_CALLCONV
  6489. krb5_tkt_creds_get_times(krb5_context context, krb5_tkt_creds_context ctx,
  6490. krb5_ticket_times *times);
  6491. /**
  6492. * Get initial credentials using a key table.
  6493. *
  6494. * @param [in] context Library context
  6495. * @param [out] creds New credentials
  6496. * @param [in] client Client principal
  6497. * @param [in] arg_keytab Key table handle
  6498. * @param [in] start_time Time when ticket becomes valid (0 for now)
  6499. * @param [in] in_tkt_service Service name of initial credentials (or NLUL)
  6500. * @param [in] k5_gic_options Initial credential options
  6501. *
  6502. * This function requests KDC for an initial credentials for @a client using a
  6503. * client key stored in @a arg_keytab. If @a in_tkt_service is specified, it
  6504. * is parsed as a principal name (with the realm ignored) and used as the
  6505. * service principal for the request; otherwise the ticket-granting service is
  6506. * used.
  6507. *
  6508. * @sa krb5_verify_init_creds()
  6509. *
  6510. * @retval
  6511. * 0 Success
  6512. * @return
  6513. * Kerberos error codes
  6514. */
  6515. krb5_error_code KRB5_CALLCONV
  6516. krb5_get_init_creds_keytab(krb5_context context, krb5_creds *creds,
  6517. krb5_principal client, krb5_keytab arg_keytab,
  6518. krb5_deltat start_time, char *in_tkt_service,
  6519. krb5_get_init_creds_opt *k5_gic_options);
  6520. typedef struct _krb5_verify_init_creds_opt {
  6521. krb5_flags flags;
  6522. int ap_req_nofail; /**< boolean */
  6523. } krb5_verify_init_creds_opt;
  6524. #define KRB5_VERIFY_INIT_CREDS_OPT_AP_REQ_NOFAIL 0x0001
  6525. /**
  6526. * Initialize a credential verification options structure.
  6527. *
  6528. * @param [in] k5_vic_options Verification options structure
  6529. */
  6530. void KRB5_CALLCONV
  6531. krb5_verify_init_creds_opt_init(krb5_verify_init_creds_opt *k5_vic_options);
  6532. /**
  6533. * Set whether credential verification is required.
  6534. *
  6535. * @param [in] k5_vic_options Verification options structure
  6536. * @param [in] ap_req_nofail Whether to require successful verification
  6537. *
  6538. * This function determines how krb5_verify_init_creds() behaves if no keytab
  6539. * information is available. If @a ap_req_nofail is @c FALSE, verification
  6540. * will be skipped in this case and krb5_verify_init_creds() will return
  6541. * successfully. If @a ap_req_nofail is @c TRUE, krb5_verify_init_creds() will
  6542. * not return successfully unless verification can be performed.
  6543. *
  6544. * If this function is not used, the behavior of krb5_verify_init_creds() is
  6545. * determined through configuration.
  6546. */
  6547. void KRB5_CALLCONV
  6548. krb5_verify_init_creds_opt_set_ap_req_nofail(krb5_verify_init_creds_opt * k5_vic_options,
  6549. int ap_req_nofail);
  6550. /**
  6551. * Verify initial credentials against a keytab.
  6552. *
  6553. * @param [in] context Library context
  6554. * @param [in] creds Initial credentials to be verified
  6555. * @param [in] server_arg Server principal (or NULL)
  6556. * @param [in] keytab_arg Key table (NULL to use default keytab)
  6557. * @param [in,out] ccache_arg Credential cache for fetched creds (or NULL)
  6558. * @param [in] options Verification options (NULL for default options)
  6559. *
  6560. * This function attempts to verify that @a creds were obtained from a KDC with
  6561. * knowledge of a key in @a keytab_arg. If @a server_arg is provided, the
  6562. * highest-kvno key entry for that principal name is used to verify the
  6563. * credentials; otherwise, the highest-kvno key entry for the first principal
  6564. * listed in @a keytab_arg is used.
  6565. *
  6566. * If the specified keytab does not exist, or is empty, or cannot be read, or
  6567. * does not contain an entry for @a server_arg, then credential verification
  6568. * may be skipped unless configuration demands that it succeed. The caller can
  6569. * control this behavior by providing a verification options structure; see
  6570. * krb5_verify_init_creds_opt_init() and
  6571. * krb5_verify_init_creds_opt_set_ap_req_nofail().
  6572. *
  6573. * If @a ccache_arg is NULL, any additional credentials fetched during the
  6574. * verification process will be destroyed. If @a ccache_arg points to NULL, a
  6575. * memory ccache will be created for the additional credentials and returned in
  6576. * @a ccache_arg. If @a ccache_arg points to a valid credential cache handle,
  6577. * the additional credentials will be stored in that cache.
  6578. *
  6579. * @retval 0 Success; otherwise - Kerberos error codes
  6580. */
  6581. krb5_error_code KRB5_CALLCONV
  6582. krb5_verify_init_creds(krb5_context context, krb5_creds *creds,
  6583. krb5_principal server_arg, krb5_keytab keytab_arg,
  6584. krb5_ccache *ccache_arg, krb5_verify_init_creds_opt *options);
  6585. /**
  6586. * Get validated credentials from the KDC.
  6587. *
  6588. * @param [in] context Library context
  6589. * @param [out] creds Validated credentials
  6590. * @param [in] client Client principal name
  6591. * @param [in] ccache Credential cache
  6592. * @param [in] in_tkt_service Server principal string (or NULL)
  6593. *
  6594. * This function gets a validated credential using a postdated credential from
  6595. * @a ccache. If @a in_tkt_service is specified, it is parsed (with the realm
  6596. * part ignored) and used as the server principal of the credential;
  6597. * otherwise, the ticket-granting service is used.
  6598. *
  6599. * If successful, the validated credential is placed in @a creds.
  6600. *
  6601. * @sa krb5_get_renewed_creds()
  6602. *
  6603. * @retval
  6604. * 0 Success
  6605. * @retval
  6606. * KRB5_NO_2ND_TKT Request missing second ticket
  6607. * @retval
  6608. * KRB5_NO_TKT_SUPPLIED Request did not supply a ticket
  6609. * @retval
  6610. * KRB5_PRINC_NOMATCH Requested principal and ticket do not match
  6611. * @retval
  6612. * KRB5_KDCREP_MODIFIED KDC reply did not match expectations
  6613. * @retval
  6614. * KRB5_KDCREP_SKEW Clock skew too great in KDC reply
  6615. * @return
  6616. * Kerberos error codes
  6617. */
  6618. krb5_error_code KRB5_CALLCONV
  6619. krb5_get_validated_creds(krb5_context context, krb5_creds *creds,
  6620. krb5_principal client, krb5_ccache ccache,
  6621. char *in_tkt_service);
  6622. /**
  6623. * Get renewed credential from KDC using an existing credential.
  6624. *
  6625. * @param [in] context Library context
  6626. * @param [out] creds Renewed credentials
  6627. * @param [in] client Client principal name
  6628. * @param [in] ccache Credential cache
  6629. * @param [in] in_tkt_service Server principal string (or NULL)
  6630. *
  6631. * This function gets a renewed credential using an existing one from @a
  6632. * ccache. If @a in_tkt_service is specified, it is parsed (with the realm
  6633. * part ignored) and used as the server principal of the credential; otherwise,
  6634. * the ticket-granting service is used.
  6635. *
  6636. * If successful, the renewed credential is placed in @a creds.
  6637. *
  6638. * @retval
  6639. * 0 Success
  6640. * @return
  6641. * Kerberos error codes
  6642. */
  6643. krb5_error_code KRB5_CALLCONV
  6644. krb5_get_renewed_creds(krb5_context context, krb5_creds *creds,
  6645. krb5_principal client, krb5_ccache ccache,
  6646. char *in_tkt_service);
  6647. /**
  6648. * Decode an ASN.1-formatted ticket.
  6649. *
  6650. * @param [in] code ASN.1-formatted ticket
  6651. * @param [out] rep Decoded ticket information
  6652. *
  6653. * @retval 0 Success; otherwise - Kerberos error codes
  6654. */
  6655. krb5_error_code KRB5_CALLCONV
  6656. krb5_decode_ticket(const krb5_data *code, krb5_ticket **rep);
  6657. /**
  6658. * Retrieve a string value from the appdefaults section of krb5.conf.
  6659. *
  6660. * @param [in] context Library context
  6661. * @param [in] appname Application name
  6662. * @param [in] realm Realm name
  6663. * @param [in] option Option to be checked
  6664. * @param [in] default_value Default value to return if no match is found
  6665. * @param [out] ret_value String value of @a option
  6666. *
  6667. * This function gets the application defaults for @a option based on the given
  6668. * @a appname and/or @a realm.
  6669. *
  6670. * @sa krb5_appdefault_boolean()
  6671. */
  6672. void KRB5_CALLCONV
  6673. krb5_appdefault_string(krb5_context context, const char *appname,
  6674. const krb5_data *realm, const char *option,
  6675. const char *default_value, char ** ret_value);
  6676. /**
  6677. * Retrieve a boolean value from the appdefaults section of krb5.conf.
  6678. *
  6679. * @param [in] context Library context
  6680. * @param [in] appname Application name
  6681. * @param [in] realm Realm name
  6682. * @param [in] option Option to be checked
  6683. * @param [in] default_value Default value to return if no match is found
  6684. * @param [out] ret_value Boolean value of @a option
  6685. *
  6686. * This function gets the application defaults for @a option based on the given
  6687. * @a appname and/or @a realm.
  6688. *
  6689. * @sa krb5_appdefault_string()
  6690. */
  6691. void KRB5_CALLCONV
  6692. krb5_appdefault_boolean(krb5_context context, const char *appname,
  6693. const krb5_data *realm, const char *option,
  6694. int default_value, int *ret_value);
  6695. /*
  6696. * Prompter enhancements
  6697. */
  6698. #define KRB5_PROMPT_TYPE_PASSWORD 0x1
  6699. #define KRB5_PROMPT_TYPE_NEW_PASSWORD 0x2
  6700. #define KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN 0x3
  6701. #define KRB5_PROMPT_TYPE_PREAUTH 0x4
  6702. typedef krb5_int32 krb5_prompt_type;
  6703. /**
  6704. * Get prompt types array from a context.
  6705. *
  6706. * @param [in] context Library context
  6707. *
  6708. * @return
  6709. * Pointer to an array of prompt types corresponding to the prompter's @a
  6710. * prompts arguments. Each type has one of the following values:
  6711. * @li #KRB5_PROMPT_TYPE_PASSWORD
  6712. * @li #KRB5_PROMPT_TYPE_NEW_PASSWORD
  6713. * @li #KRB5_PROMPT_TYPE_NEW_PASSWORD_AGAIN
  6714. * @li #KRB5_PROMPT_TYPE_PREAUTH
  6715. */
  6716. krb5_prompt_type* KRB5_CALLCONV
  6717. krb5_get_prompt_types(krb5_context context);
  6718. /* Error reporting */
  6719. /**
  6720. * Set an extended error message for an error code.
  6721. *
  6722. * @param [in] ctx Library context
  6723. * @param [in] code Error code
  6724. * @param [in] fmt Error string for the error code
  6725. * @param [in] ... printf(3) style parameters
  6726. */
  6727. void KRB5_CALLCONV_C
  6728. krb5_set_error_message(krb5_context ctx, krb5_error_code code, const char *fmt, ...)
  6729. #if !defined(__cplusplus) && (__GNUC__ > 2)
  6730. __attribute__((__format__(__printf__, 3, 4)))
  6731. #endif
  6732. ;
  6733. /**
  6734. * Set an extended error message for an error code using a va_list.
  6735. *
  6736. * @param [in] ctx Library context
  6737. * @param [in] code Error code
  6738. * @param [in] fmt Error string for the error code
  6739. * @param [in] args List of vprintf(3) style arguments
  6740. */
  6741. void KRB5_CALLCONV
  6742. krb5_vset_error_message(krb5_context ctx, krb5_error_code code,
  6743. const char *fmt, va_list args)
  6744. #if !defined(__cplusplus) && (__GNUC__ > 2)
  6745. __attribute__((__format__(__printf__, 3, 0)))
  6746. #endif
  6747. ;
  6748. /**
  6749. * Copy the most recent extended error message from one context to another.
  6750. *
  6751. * @param [in] dest_ctx Library context to copy message to
  6752. * @param [in] src_ctx Library context with current message
  6753. */
  6754. void KRB5_CALLCONV
  6755. krb5_copy_error_message(krb5_context dest_ctx, krb5_context src_ctx);
  6756. /**
  6757. * Get the (possibly extended) error message for a code.
  6758. *
  6759. * @param [in] ctx Library context
  6760. * @param [in] code Error code
  6761. *
  6762. * The behavior of krb5_get_error_message() is only defined the first time it
  6763. * is called after a failed call to a krb5 function using the same context, and
  6764. * only when the error code passed in is the same as that returned by the krb5
  6765. * function.
  6766. *
  6767. * This function never returns NULL, so its result may be used unconditionally
  6768. * as a C string.
  6769. *
  6770. * The string returned by this function must be freed using
  6771. * krb5_free_error_message()
  6772. *
  6773. * @note Future versions may return the same string for the second
  6774. * and following calls.
  6775. */
  6776. const char * KRB5_CALLCONV
  6777. krb5_get_error_message(krb5_context ctx, krb5_error_code code);
  6778. /**
  6779. * Free an error message generated by krb5_get_error_message().
  6780. *
  6781. * @param [in] ctx Library context
  6782. * @param [in] msg Pointer to error message
  6783. */
  6784. void KRB5_CALLCONV
  6785. krb5_free_error_message(krb5_context ctx, const char *msg);
  6786. /**
  6787. * Clear the extended error message in a context.
  6788. *
  6789. * @param [in] ctx Library context
  6790. *
  6791. * This function unsets the extended error message in a context, to ensure that
  6792. * it is not mistakenly applied to another occurrence of the same error code.
  6793. */
  6794. void KRB5_CALLCONV
  6795. krb5_clear_error_message(krb5_context ctx);
  6796. /**
  6797. * Unwrap authorization data.
  6798. *
  6799. * @param [in] context Library context
  6800. * @param [in] type @ref KRB5_AUTHDATA type of @a container
  6801. * @param [in] container Authorization data to be decoded
  6802. * @param [out] authdata List of decoded authorization data
  6803. *
  6804. * @sa krb5_encode_authdata_container()
  6805. *
  6806. * @retval 0 Success; otherwise - Kerberos error codes
  6807. */
  6808. krb5_error_code KRB5_CALLCONV
  6809. krb5_decode_authdata_container(krb5_context context,
  6810. krb5_authdatatype type,
  6811. const krb5_authdata *container,
  6812. krb5_authdata ***authdata);
  6813. /**
  6814. * Wrap authorization data in a container.
  6815. *
  6816. * @param [in] context Library context
  6817. * @param [in] type @ref KRB5_AUTHDATA type of @a container
  6818. * @param [in] authdata List of authorization data to be encoded
  6819. * @param [out] container List of encoded authorization data
  6820. *
  6821. * The result is returned in @a container as a single-element list.
  6822. *
  6823. * @sa krb5_decode_authdata_container()
  6824. *
  6825. * @retval 0 Success; otherwise - Kerberos error codes
  6826. */
  6827. krb5_error_code KRB5_CALLCONV
  6828. krb5_encode_authdata_container(krb5_context context,
  6829. krb5_authdatatype type,
  6830. krb5_authdata * const*authdata,
  6831. krb5_authdata ***container);
  6832. /*
  6833. * AD-KDCIssued
  6834. */
  6835. /**
  6836. * Encode and sign AD-KDCIssued authorization data.
  6837. *
  6838. * @param [in] context Library context
  6839. * @param [in] key Session key
  6840. * @param [in] issuer The name of the issuing principal
  6841. * @param [in] authdata List of authorization data to be signed
  6842. * @param [out] ad_kdcissued List containing AD-KDCIssued authdata
  6843. *
  6844. * This function wraps a list of authorization data entries @a authdata in an
  6845. * AD-KDCIssued container (see RFC 4120 section 5.2.6.2) signed with @a key.
  6846. * The result is returned in @a ad_kdcissued as a single-element list.
  6847. */
  6848. krb5_error_code KRB5_CALLCONV
  6849. krb5_make_authdata_kdc_issued(krb5_context context,
  6850. const krb5_keyblock *key,
  6851. krb5_const_principal issuer,
  6852. krb5_authdata *const *authdata,
  6853. krb5_authdata ***ad_kdcissued);
  6854. /**
  6855. * Unwrap and verify AD-KDCIssued authorization data.
  6856. *
  6857. * @param [in] context Library context
  6858. * @param [in] key Session key
  6859. * @param [in] ad_kdcissued AD-KDCIssued authorization data to be unwrapped
  6860. * @param [out] issuer Name of issuing principal (or NULL)
  6861. * @param [out] authdata Unwrapped list of authorization data
  6862. *
  6863. * This function unwraps an AD-KDCIssued authdatum (see RFC 4120 section
  6864. * 5.2.6.2) and verifies its signature against @a key. The issuer field of the
  6865. * authdatum element is returned in @a issuer, and the unwrapped list of
  6866. * authdata is returned in @a authdata.
  6867. */
  6868. krb5_error_code KRB5_CALLCONV
  6869. krb5_verify_authdata_kdc_issued(krb5_context context,
  6870. const krb5_keyblock *key,
  6871. const krb5_authdata *ad_kdcissued,
  6872. krb5_principal *issuer,
  6873. krb5_authdata ***authdata);
  6874. /*
  6875. * Windows PAC
  6876. */
  6877. /* Microsoft defined types of data */
  6878. #define KRB5_PAC_LOGON_INFO 1 /**< Logon information */
  6879. #define KRB5_PAC_CREDENTIALS_INFO 2 /**< Credentials information */
  6880. #define KRB5_PAC_SERVER_CHECKSUM 6 /**< Server checksum */
  6881. #define KRB5_PAC_PRIVSVR_CHECKSUM 7 /**< KDC checksum */
  6882. #define KRB5_PAC_CLIENT_INFO 10 /**< Client name and ticket info */
  6883. #define KRB5_PAC_DELEGATION_INFO 11 /**< Constrained delegation info */
  6884. #define KRB5_PAC_UPN_DNS_INFO 12 /**< User principal name and DNS info */
  6885. struct krb5_pac_data;
  6886. /** PAC data structure to convey authorization information */
  6887. typedef struct krb5_pac_data *krb5_pac;
  6888. /**
  6889. * Add a buffer to a PAC handle.
  6890. *
  6891. * @param [in] context Library context
  6892. * @param [in] pac PAC handle
  6893. * @param [in] type Buffer type
  6894. * @param [in] data contents
  6895. *
  6896. * This function adds a buffer of type @a type and contents @a data to @a pac
  6897. * if there isn't already a buffer of this type present.
  6898. *
  6899. * The valid values of @a type is one of the following:
  6900. * @li #PAC_LOGON_INFO - Logon information
  6901. * @li #PAC_CREDENTIALS_INFO - Credentials information
  6902. * @li #PAC_SERVER_CHECKSUM - Server checksum
  6903. * @li #PAC_PRIVSVR_CHECKSUM - KDC checksum
  6904. * @li #PAC_CLIENT_INFO - Client name and ticket information
  6905. * @li #PAC_DELEGATION_INFO - Constrained delegation information
  6906. * @li #PAC_UPN_DNS_INFO - User principal name and DNS information
  6907. *
  6908. * @retval 0 Success; otherwise - Kerberos error codes
  6909. */
  6910. krb5_error_code KRB5_CALLCONV
  6911. krb5_pac_add_buffer(krb5_context context, krb5_pac pac, krb5_ui_4 type,
  6912. const krb5_data *data);
  6913. /**
  6914. * Free a PAC handle.
  6915. *
  6916. * @param [in] context Library context
  6917. * @param [in] pac PAC to be freed
  6918. *
  6919. * This function frees the contents of @a pac and the structure itself.
  6920. */
  6921. void KRB5_CALLCONV
  6922. krb5_pac_free(krb5_context context, krb5_pac pac);
  6923. /**
  6924. * Retrieve a buffer value from a PAC.
  6925. *
  6926. * @param [in] context Library context
  6927. * @param [in] pac PAC handle
  6928. * @param [in] type Type of buffer to retrieve
  6929. * @param [out] data Buffer value
  6930. *
  6931. * Use krb5_free_data_contents() to free @a data when it is no longer needed.
  6932. *
  6933. * @retval 0 Success; otherwise - Kerberos error codes
  6934. */
  6935. krb5_error_code KRB5_CALLCONV
  6936. krb5_pac_get_buffer(krb5_context context, krb5_pac pac, krb5_ui_4 type,
  6937. krb5_data *data);
  6938. /**
  6939. * Return an array of buffer types in a PAC handle.
  6940. *
  6941. * @param [in] context Library context
  6942. * @param [in] pac PAC handle
  6943. * @param [out] len Number of entries in @a types
  6944. * @param [out] types Array of buffer types
  6945. *
  6946. * @retval 0 Success; otherwise - Kerberos error codes
  6947. */
  6948. krb5_error_code KRB5_CALLCONV
  6949. krb5_pac_get_types(krb5_context context, krb5_pac pac, size_t *len,
  6950. krb5_ui_4 **types);
  6951. /**
  6952. * Create an empty Privilege Attribute Certificate (PAC) handle.
  6953. *
  6954. * @param [in] context Library context
  6955. * @param [out] pac New PAC handle
  6956. *
  6957. * Use krb5_pac_free() to free @a pac when it is no longer needed.
  6958. *
  6959. * @retval 0 Success; otherwise - Kerberos error codes
  6960. */
  6961. krb5_error_code KRB5_CALLCONV
  6962. krb5_pac_init(krb5_context context, krb5_pac *pac);
  6963. /**
  6964. * Unparse an encoded PAC into a new handle.
  6965. *
  6966. * @param [in] context Library context
  6967. * @param [in] ptr PAC buffer
  6968. * @param [in] len Length of @a ptr
  6969. * @param [out] pac PAC handle
  6970. *
  6971. * Use krb5_pac_free() to free @a pac when it is no longer needed.
  6972. *
  6973. * @retval 0 Success; otherwise - Kerberos error codes
  6974. */
  6975. krb5_error_code KRB5_CALLCONV
  6976. krb5_pac_parse(krb5_context context, const void *ptr, size_t len,
  6977. krb5_pac *pac);
  6978. /**
  6979. * Verify a PAC.
  6980. *
  6981. * @param [in] context Library context
  6982. * @param [in] pac PAC handle
  6983. * @param [in] authtime Expected timestamp
  6984. * @param [in] principal Expected principal name (or NULL)
  6985. * @param [in] server Key to validate server checksum (or NULL)
  6986. * @param [in] privsvr Key to validate KDC checksum (or NULL)
  6987. *
  6988. * This function validates @a pac against the supplied @a server, @a privsvr,
  6989. * @a principal and @a authtime. If @a principal is NULL, the principal and
  6990. * authtime are not verified. If @a server or @a privsvr is NULL, the
  6991. * corresponding checksum is not verified.
  6992. *
  6993. * If successful, @a pac is marked as verified.
  6994. *
  6995. * @note A checksum mismatch can occur if the PAC was copied from a cross-realm
  6996. * TGT by an ignorant KDC; also Apple Mac OS X Server Open Directory (as of
  6997. * 10.6) generates PACs with no server checksum at all. One should consider
  6998. * not failing the whole authentication because of this reason, but, instead,
  6999. * treating the ticket as if it did not contain a PAC or marking the PAC
  7000. * information as non-verified.
  7001. *
  7002. * @retval 0 Success; otherwise - Kerberos error codes
  7003. */
  7004. krb5_error_code KRB5_CALLCONV
  7005. krb5_pac_verify(krb5_context context, const krb5_pac pac,
  7006. krb5_timestamp authtime, krb5_const_principal principal,
  7007. const krb5_keyblock *server, const krb5_keyblock *privsvr);
  7008. /**
  7009. * Sign a PAC.
  7010. *
  7011. * @param [in] context Library context
  7012. * @param [in] pac PAC handle
  7013. * @param [in] authtime Expected timestamp
  7014. * @param [in] principal Expected principal name (or NULL)
  7015. * @param [in] server_key Key for server checksum
  7016. * @param [in] privsvr_key Key for KDC checksum
  7017. * @param [out] data Signed PAC encoding
  7018. *
  7019. * This function signs @a pac using the keys @a server_key and @a privsvr_key
  7020. * and returns the signed encoding in @a data. @a pac is modified to include
  7021. * the server and KDC checksum buffers. Use krb5_free_data_contents() to free
  7022. * @a data when it is no longer needed.
  7023. */
  7024. krb5_error_code KRB5_CALLCONV
  7025. krb5_pac_sign(krb5_context context, krb5_pac pac, krb5_timestamp authtime,
  7026. krb5_const_principal principal, const krb5_keyblock *server_key,
  7027. const krb5_keyblock *privsvr_key, krb5_data *data);
  7028. /**
  7029. * Allow the appplication to override the profile's allow_weak_crypto setting.
  7030. *
  7031. * @param [in] context Library context
  7032. * @param [in] enable Boolean flag
  7033. *
  7034. * This function allows an application to override the allow_weak_crypto
  7035. * setting. It is primarily for use by aklog.
  7036. *
  7037. * @retval 0 (always)
  7038. */
  7039. krb5_error_code KRB5_CALLCONV
  7040. krb5_allow_weak_crypto(krb5_context context, krb5_boolean enable);
  7041. /* This structure may be extended to contain more fields in the future. */
  7042. struct krb5_trace_info {
  7043. const char *message;
  7044. };
  7045. typedef void
  7046. (KRB5_CALLCONV *krb5_trace_callback)(krb5_context context,
  7047. const struct krb5_trace_info *info,
  7048. void *cb_data);
  7049. /**
  7050. * Specify a callback function for trace events.
  7051. *
  7052. * @param [in] context Library context
  7053. * @param [in] fn Callback function
  7054. * @param [in] cb_data Callback data
  7055. *
  7056. * Specify a callback for trace events occurring in krb5 operations performed
  7057. * within @a context. @a fn will be invoked with @a context as the first
  7058. * argument, @a cb_data as the last argument, and a pointer to a struct
  7059. * krb5_trace_info as the second argument. If the trace callback is reset via
  7060. * this function or @a context is destroyed, @a fn will be invoked with a NULL
  7061. * second argument so it can clean up @a cb_data. Supply a NULL value for @a
  7062. * fn to disable trace callbacks within @a context.
  7063. *
  7064. * @return Returns KRB5_TRACE_NOSUPP if tracing is not supported in the library
  7065. * (unless @a fn is NULL).
  7066. */
  7067. krb5_error_code KRB5_CALLCONV
  7068. krb5_set_trace_callback(krb5_context context, krb5_trace_callback fn,
  7069. void *cb_data);
  7070. /**
  7071. * Specify a file name for directing trace events.
  7072. *
  7073. * @param [in] context Library context
  7074. * @param [in] filename File name
  7075. *
  7076. * Open @a filename for appending (creating it, if necessary) and set up a
  7077. * callback to write trace events to it.
  7078. *
  7079. * @retval KRB5_TRACE_NOSUPP Tracing is not supported in the library.
  7080. */
  7081. krb5_error_code KRB5_CALLCONV
  7082. krb5_set_trace_filename(krb5_context context, const char *filename);
  7083. #if TARGET_OS_MAC
  7084. # pragma pack(pop)
  7085. #endif
  7086. KRB5INT_END_DECLS
  7087. /* Don't use this! We're going to phase it out. It's just here to keep
  7088. applications from breaking right away. */
  7089. #define krb5_const const
  7090. #undef KRB5_ATTR_DEPRECATED
  7091. #endif /* KRB5_GENERAL__ */
  7092. /*
  7093. * et-h-krb5_err.h:
  7094. * This file is automatically generated; please do not edit it.
  7095. */
  7096. #include <et/com_err.h>
  7097. #define KRB5KDC_ERR_NONE (-1765328384L)
  7098. #define KRB5KDC_ERR_NAME_EXP (-1765328383L)
  7099. #define KRB5KDC_ERR_SERVICE_EXP (-1765328382L)
  7100. #define KRB5KDC_ERR_BAD_PVNO (-1765328381L)
  7101. #define KRB5KDC_ERR_C_OLD_MAST_KVNO (-1765328380L)
  7102. #define KRB5KDC_ERR_S_OLD_MAST_KVNO (-1765328379L)
  7103. #define KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN (-1765328378L)
  7104. #define KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN (-1765328377L)
  7105. #define KRB5KDC_ERR_PRINCIPAL_NOT_UNIQUE (-1765328376L)
  7106. #define KRB5KDC_ERR_NULL_KEY (-1765328375L)
  7107. #define KRB5KDC_ERR_CANNOT_POSTDATE (-1765328374L)
  7108. #define KRB5KDC_ERR_NEVER_VALID (-1765328373L)
  7109. #define KRB5KDC_ERR_POLICY (-1765328372L)
  7110. #define KRB5KDC_ERR_BADOPTION (-1765328371L)
  7111. #define KRB5KDC_ERR_ETYPE_NOSUPP (-1765328370L)
  7112. #define KRB5KDC_ERR_SUMTYPE_NOSUPP (-1765328369L)
  7113. #define KRB5KDC_ERR_PADATA_TYPE_NOSUPP (-1765328368L)
  7114. #define KRB5KDC_ERR_TRTYPE_NOSUPP (-1765328367L)
  7115. #define KRB5KDC_ERR_CLIENT_REVOKED (-1765328366L)
  7116. #define KRB5KDC_ERR_SERVICE_REVOKED (-1765328365L)
  7117. #define KRB5KDC_ERR_TGT_REVOKED (-1765328364L)
  7118. #define KRB5KDC_ERR_CLIENT_NOTYET (-1765328363L)
  7119. #define KRB5KDC_ERR_SERVICE_NOTYET (-1765328362L)
  7120. #define KRB5KDC_ERR_KEY_EXP (-1765328361L)
  7121. #define KRB5KDC_ERR_PREAUTH_FAILED (-1765328360L)
  7122. #define KRB5KDC_ERR_PREAUTH_REQUIRED (-1765328359L)
  7123. #define KRB5KDC_ERR_SERVER_NOMATCH (-1765328358L)
  7124. #define KRB5KDC_ERR_MUST_USE_USER2USER (-1765328357L)
  7125. #define KRB5KDC_ERR_PATH_NOT_ACCEPTED (-1765328356L)
  7126. #define KRB5KDC_ERR_SVC_UNAVAILABLE (-1765328355L)
  7127. #define KRB5PLACEHOLD_30 (-1765328354L)
  7128. #define KRB5KRB_AP_ERR_BAD_INTEGRITY (-1765328353L)
  7129. #define KRB5KRB_AP_ERR_TKT_EXPIRED (-1765328352L)
  7130. #define KRB5KRB_AP_ERR_TKT_NYV (-1765328351L)
  7131. #define KRB5KRB_AP_ERR_REPEAT (-1765328350L)
  7132. #define KRB5KRB_AP_ERR_NOT_US (-1765328349L)
  7133. #define KRB5KRB_AP_ERR_BADMATCH (-1765328348L)
  7134. #define KRB5KRB_AP_ERR_SKEW (-1765328347L)
  7135. #define KRB5KRB_AP_ERR_BADADDR (-1765328346L)
  7136. #define KRB5KRB_AP_ERR_BADVERSION (-1765328345L)
  7137. #define KRB5KRB_AP_ERR_MSG_TYPE (-1765328344L)
  7138. #define KRB5KRB_AP_ERR_MODIFIED (-1765328343L)
  7139. #define KRB5KRB_AP_ERR_BADORDER (-1765328342L)
  7140. #define KRB5KRB_AP_ERR_ILL_CR_TKT (-1765328341L)
  7141. #define KRB5KRB_AP_ERR_BADKEYVER (-1765328340L)
  7142. #define KRB5KRB_AP_ERR_NOKEY (-1765328339L)
  7143. #define KRB5KRB_AP_ERR_MUT_FAIL (-1765328338L)
  7144. #define KRB5KRB_AP_ERR_BADDIRECTION (-1765328337L)
  7145. #define KRB5KRB_AP_ERR_METHOD (-1765328336L)
  7146. #define KRB5KRB_AP_ERR_BADSEQ (-1765328335L)
  7147. #define KRB5KRB_AP_ERR_INAPP_CKSUM (-1765328334L)
  7148. #define KRB5KRB_AP_PATH_NOT_ACCEPTED (-1765328333L)
  7149. #define KRB5KRB_ERR_RESPONSE_TOO_BIG (-1765328332L)
  7150. #define KRB5PLACEHOLD_53 (-1765328331L)
  7151. #define KRB5PLACEHOLD_54 (-1765328330L)
  7152. #define KRB5PLACEHOLD_55 (-1765328329L)
  7153. #define KRB5PLACEHOLD_56 (-1765328328L)
  7154. #define KRB5PLACEHOLD_57 (-1765328327L)
  7155. #define KRB5PLACEHOLD_58 (-1765328326L)
  7156. #define KRB5PLACEHOLD_59 (-1765328325L)
  7157. #define KRB5KRB_ERR_GENERIC (-1765328324L)
  7158. #define KRB5KRB_ERR_FIELD_TOOLONG (-1765328323L)
  7159. #define KRB5KDC_ERR_CLIENT_NOT_TRUSTED (-1765328322L)
  7160. #define KRB5KDC_ERR_KDC_NOT_TRUSTED (-1765328321L)
  7161. #define KRB5KDC_ERR_INVALID_SIG (-1765328320L)
  7162. #define KRB5KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED (-1765328319L)
  7163. #define KRB5KDC_ERR_CERTIFICATE_MISMATCH (-1765328318L)
  7164. #define KRB5KRB_AP_ERR_NO_TGT (-1765328317L)
  7165. #define KRB5KDC_ERR_WRONG_REALM (-1765328316L)
  7166. #define KRB5KRB_AP_ERR_USER_TO_USER_REQUIRED (-1765328315L)
  7167. #define KRB5KDC_ERR_CANT_VERIFY_CERTIFICATE (-1765328314L)
  7168. #define KRB5KDC_ERR_INVALID_CERTIFICATE (-1765328313L)
  7169. #define KRB5KDC_ERR_REVOKED_CERTIFICATE (-1765328312L)
  7170. #define KRB5KDC_ERR_REVOCATION_STATUS_UNKNOWN (-1765328311L)
  7171. #define KRB5KDC_ERR_REVOCATION_STATUS_UNAVAILABLE (-1765328310L)
  7172. #define KRB5KDC_ERR_CLIENT_NAME_MISMATCH (-1765328309L)
  7173. #define KRB5KDC_ERR_KDC_NAME_MISMATCH (-1765328308L)
  7174. #define KRB5KDC_ERR_INCONSISTENT_KEY_PURPOSE (-1765328307L)
  7175. #define KRB5KDC_ERR_DIGEST_IN_CERT_NOT_ACCEPTED (-1765328306L)
  7176. #define KRB5KDC_ERR_PA_CHECKSUM_MUST_BE_INCLUDED (-1765328305L)
  7177. #define KRB5KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED (-1765328304L)
  7178. #define KRB5KDC_ERR_PUBLIC_KEY_ENCRYPTION_NOT_SUPPORTED (-1765328303L)
  7179. #define KRB5KDC_ERR_NO_ACCEPTABLE_KDF (-1765328302L)
  7180. #define KRB5PLACEHOLD_83 (-1765328301L)
  7181. #define KRB5PLACEHOLD_84 (-1765328300L)
  7182. #define KRB5KRB_AP_ERR_IAKERB_KDC_NOT_FOUND (-1765328299L)
  7183. #define KRB5KRB_AP_ERR_IAKERB_KDC_NO_RESPONSE (-1765328298L)
  7184. #define KRB5PLACEHOLD_87 (-1765328297L)
  7185. #define KRB5PLACEHOLD_88 (-1765328296L)
  7186. #define KRB5PLACEHOLD_89 (-1765328295L)
  7187. #define KRB5PLACEHOLD_90 (-1765328294L)
  7188. #define KRB5PLACEHOLD_91 (-1765328293L)
  7189. #define KRB5PLACEHOLD_92 (-1765328292L)
  7190. #define KRB5KDC_ERR_UNKNOWN_CRITICAL_FAST_OPTION (-1765328291L)
  7191. #define KRB5PLACEHOLD_94 (-1765328290L)
  7192. #define KRB5PLACEHOLD_95 (-1765328289L)
  7193. #define KRB5PLACEHOLD_96 (-1765328288L)
  7194. #define KRB5PLACEHOLD_97 (-1765328287L)
  7195. #define KRB5PLACEHOLD_98 (-1765328286L)
  7196. #define KRB5PLACEHOLD_99 (-1765328285L)
  7197. #define KRB5PLACEHOLD_100 (-1765328284L)
  7198. #define KRB5PLACEHOLD_101 (-1765328283L)
  7199. #define KRB5PLACEHOLD_102 (-1765328282L)
  7200. #define KRB5PLACEHOLD_103 (-1765328281L)
  7201. #define KRB5PLACEHOLD_104 (-1765328280L)
  7202. #define KRB5PLACEHOLD_105 (-1765328279L)
  7203. #define KRB5PLACEHOLD_106 (-1765328278L)
  7204. #define KRB5PLACEHOLD_107 (-1765328277L)
  7205. #define KRB5PLACEHOLD_108 (-1765328276L)
  7206. #define KRB5PLACEHOLD_109 (-1765328275L)
  7207. #define KRB5PLACEHOLD_110 (-1765328274L)
  7208. #define KRB5PLACEHOLD_111 (-1765328273L)
  7209. #define KRB5PLACEHOLD_112 (-1765328272L)
  7210. #define KRB5PLACEHOLD_113 (-1765328271L)
  7211. #define KRB5PLACEHOLD_114 (-1765328270L)
  7212. #define KRB5PLACEHOLD_115 (-1765328269L)
  7213. #define KRB5PLACEHOLD_116 (-1765328268L)
  7214. #define KRB5PLACEHOLD_117 (-1765328267L)
  7215. #define KRB5PLACEHOLD_118 (-1765328266L)
  7216. #define KRB5PLACEHOLD_119 (-1765328265L)
  7217. #define KRB5PLACEHOLD_120 (-1765328264L)
  7218. #define KRB5PLACEHOLD_121 (-1765328263L)
  7219. #define KRB5PLACEHOLD_122 (-1765328262L)
  7220. #define KRB5PLACEHOLD_123 (-1765328261L)
  7221. #define KRB5PLACEHOLD_124 (-1765328260L)
  7222. #define KRB5PLACEHOLD_125 (-1765328259L)
  7223. #define KRB5PLACEHOLD_126 (-1765328258L)
  7224. #define KRB5PLACEHOLD_127 (-1765328257L)
  7225. #define KRB5_ERR_RCSID (-1765328256L)
  7226. #define KRB5_LIBOS_BADLOCKFLAG (-1765328255L)
  7227. #define KRB5_LIBOS_CANTREADPWD (-1765328254L)
  7228. #define KRB5_LIBOS_BADPWDMATCH (-1765328253L)
  7229. #define KRB5_LIBOS_PWDINTR (-1765328252L)
  7230. #define KRB5_PARSE_ILLCHAR (-1765328251L)
  7231. #define KRB5_PARSE_MALFORMED (-1765328250L)
  7232. #define KRB5_CONFIG_CANTOPEN (-1765328249L)
  7233. #define KRB5_CONFIG_BADFORMAT (-1765328248L)
  7234. #define KRB5_CONFIG_NOTENUFSPACE (-1765328247L)
  7235. #define KRB5_BADMSGTYPE (-1765328246L)
  7236. #define KRB5_CC_BADNAME (-1765328245L)
  7237. #define KRB5_CC_UNKNOWN_TYPE (-1765328244L)
  7238. #define KRB5_CC_NOTFOUND (-1765328243L)
  7239. #define KRB5_CC_END (-1765328242L)
  7240. #define KRB5_NO_TKT_SUPPLIED (-1765328241L)
  7241. #define KRB5KRB_AP_WRONG_PRINC (-1765328240L)
  7242. #define KRB5KRB_AP_ERR_TKT_INVALID (-1765328239L)
  7243. #define KRB5_PRINC_NOMATCH (-1765328238L)
  7244. #define KRB5_KDCREP_MODIFIED (-1765328237L)
  7245. #define KRB5_KDCREP_SKEW (-1765328236L)
  7246. #define KRB5_IN_TKT_REALM_MISMATCH (-1765328235L)
  7247. #define KRB5_PROG_ETYPE_NOSUPP (-1765328234L)
  7248. #define KRB5_PROG_KEYTYPE_NOSUPP (-1765328233L)
  7249. #define KRB5_WRONG_ETYPE (-1765328232L)
  7250. #define KRB5_PROG_SUMTYPE_NOSUPP (-1765328231L)
  7251. #define KRB5_REALM_UNKNOWN (-1765328230L)
  7252. #define KRB5_SERVICE_UNKNOWN (-1765328229L)
  7253. #define KRB5_KDC_UNREACH (-1765328228L)
  7254. #define KRB5_NO_LOCALNAME (-1765328227L)
  7255. #define KRB5_MUTUAL_FAILED (-1765328226L)
  7256. #define KRB5_RC_TYPE_EXISTS (-1765328225L)
  7257. #define KRB5_RC_MALLOC (-1765328224L)
  7258. #define KRB5_RC_TYPE_NOTFOUND (-1765328223L)
  7259. #define KRB5_RC_UNKNOWN (-1765328222L)
  7260. #define KRB5_RC_REPLAY (-1765328221L)
  7261. #define KRB5_RC_IO (-1765328220L)
  7262. #define KRB5_RC_NOIO (-1765328219L)
  7263. #define KRB5_RC_PARSE (-1765328218L)
  7264. #define KRB5_RC_IO_EOF (-1765328217L)
  7265. #define KRB5_RC_IO_MALLOC (-1765328216L)
  7266. #define KRB5_RC_IO_PERM (-1765328215L)
  7267. #define KRB5_RC_IO_IO (-1765328214L)
  7268. #define KRB5_RC_IO_UNKNOWN (-1765328213L)
  7269. #define KRB5_RC_IO_SPACE (-1765328212L)
  7270. #define KRB5_TRANS_CANTOPEN (-1765328211L)
  7271. #define KRB5_TRANS_BADFORMAT (-1765328210L)
  7272. #define KRB5_LNAME_CANTOPEN (-1765328209L)
  7273. #define KRB5_LNAME_NOTRANS (-1765328208L)
  7274. #define KRB5_LNAME_BADFORMAT (-1765328207L)
  7275. #define KRB5_CRYPTO_INTERNAL (-1765328206L)
  7276. #define KRB5_KT_BADNAME (-1765328205L)
  7277. #define KRB5_KT_UNKNOWN_TYPE (-1765328204L)
  7278. #define KRB5_KT_NOTFOUND (-1765328203L)
  7279. #define KRB5_KT_END (-1765328202L)
  7280. #define KRB5_KT_NOWRITE (-1765328201L)
  7281. #define KRB5_KT_IOERR (-1765328200L)
  7282. #define KRB5_NO_TKT_IN_RLM (-1765328199L)
  7283. #define KRB5DES_BAD_KEYPAR (-1765328198L)
  7284. #define KRB5DES_WEAK_KEY (-1765328197L)
  7285. #define KRB5_BAD_ENCTYPE (-1765328196L)
  7286. #define KRB5_BAD_KEYSIZE (-1765328195L)
  7287. #define KRB5_BAD_MSIZE (-1765328194L)
  7288. #define KRB5_CC_TYPE_EXISTS (-1765328193L)
  7289. #define KRB5_KT_TYPE_EXISTS (-1765328192L)
  7290. #define KRB5_CC_IO (-1765328191L)
  7291. #define KRB5_FCC_PERM (-1765328190L)
  7292. #define KRB5_FCC_NOFILE (-1765328189L)
  7293. #define KRB5_FCC_INTERNAL (-1765328188L)
  7294. #define KRB5_CC_WRITE (-1765328187L)
  7295. #define KRB5_CC_NOMEM (-1765328186L)
  7296. #define KRB5_CC_FORMAT (-1765328185L)
  7297. #define KRB5_CC_NOT_KTYPE (-1765328184L)
  7298. #define KRB5_INVALID_FLAGS (-1765328183L)
  7299. #define KRB5_NO_2ND_TKT (-1765328182L)
  7300. #define KRB5_NOCREDS_SUPPLIED (-1765328181L)
  7301. #define KRB5_SENDAUTH_BADAUTHVERS (-1765328180L)
  7302. #define KRB5_SENDAUTH_BADAPPLVERS (-1765328179L)
  7303. #define KRB5_SENDAUTH_BADRESPONSE (-1765328178L)
  7304. #define KRB5_SENDAUTH_REJECTED (-1765328177L)
  7305. #define KRB5_PREAUTH_BAD_TYPE (-1765328176L)
  7306. #define KRB5_PREAUTH_NO_KEY (-1765328175L)
  7307. #define KRB5_PREAUTH_FAILED (-1765328174L)
  7308. #define KRB5_RCACHE_BADVNO (-1765328173L)
  7309. #define KRB5_CCACHE_BADVNO (-1765328172L)
  7310. #define KRB5_KEYTAB_BADVNO (-1765328171L)
  7311. #define KRB5_PROG_ATYPE_NOSUPP (-1765328170L)
  7312. #define KRB5_RC_REQUIRED (-1765328169L)
  7313. #define KRB5_ERR_BAD_HOSTNAME (-1765328168L)
  7314. #define KRB5_ERR_HOST_REALM_UNKNOWN (-1765328167L)
  7315. #define KRB5_SNAME_UNSUPP_NAMETYPE (-1765328166L)
  7316. #define KRB5KRB_AP_ERR_V4_REPLY (-1765328165L)
  7317. #define KRB5_REALM_CANT_RESOLVE (-1765328164L)
  7318. #define KRB5_TKT_NOT_FORWARDABLE (-1765328163L)
  7319. #define KRB5_FWD_BAD_PRINCIPAL (-1765328162L)
  7320. #define KRB5_GET_IN_TKT_LOOP (-1765328161L)
  7321. #define KRB5_CONFIG_NODEFREALM (-1765328160L)
  7322. #define KRB5_SAM_UNSUPPORTED (-1765328159L)
  7323. #define KRB5_SAM_INVALID_ETYPE (-1765328158L)
  7324. #define KRB5_SAM_NO_CHECKSUM (-1765328157L)
  7325. #define KRB5_SAM_BAD_CHECKSUM (-1765328156L)
  7326. #define KRB5_KT_NAME_TOOLONG (-1765328155L)
  7327. #define KRB5_KT_KVNONOTFOUND (-1765328154L)
  7328. #define KRB5_APPL_EXPIRED (-1765328153L)
  7329. #define KRB5_LIB_EXPIRED (-1765328152L)
  7330. #define KRB5_CHPW_PWDNULL (-1765328151L)
  7331. #define KRB5_CHPW_FAIL (-1765328150L)
  7332. #define KRB5_KT_FORMAT (-1765328149L)
  7333. #define KRB5_NOPERM_ETYPE (-1765328148L)
  7334. #define KRB5_CONFIG_ETYPE_NOSUPP (-1765328147L)
  7335. #define KRB5_OBSOLETE_FN (-1765328146L)
  7336. #define KRB5_EAI_FAIL (-1765328145L)
  7337. #define KRB5_EAI_NODATA (-1765328144L)
  7338. #define KRB5_EAI_NONAME (-1765328143L)
  7339. #define KRB5_EAI_SERVICE (-1765328142L)
  7340. #define KRB5_ERR_NUMERIC_REALM (-1765328141L)
  7341. #define KRB5_ERR_BAD_S2K_PARAMS (-1765328140L)
  7342. #define KRB5_ERR_NO_SERVICE (-1765328139L)
  7343. #define KRB5_CC_READONLY (-1765328138L)
  7344. #define KRB5_CC_NOSUPP (-1765328137L)
  7345. #define KRB5_DELTAT_BADFORMAT (-1765328136L)
  7346. #define KRB5_PLUGIN_NO_HANDLE (-1765328135L)
  7347. #define KRB5_PLUGIN_OP_NOTSUPP (-1765328134L)
  7348. #define KRB5_ERR_INVALID_UTF8 (-1765328133L)
  7349. #define KRB5_ERR_FAST_REQUIRED (-1765328132L)
  7350. #define KRB5_LOCAL_ADDR_REQUIRED (-1765328131L)
  7351. #define KRB5_REMOTE_ADDR_REQUIRED (-1765328130L)
  7352. #define KRB5_TRACE_NOSUPP (-1765328129L)
  7353. extern const struct error_table et_krb5_error_table;
  7354. extern void initialize_krb5_error_table(void);
  7355. /* For compatibility with Heimdal */
  7356. extern void initialize_krb5_error_table_r(struct et_list **list);
  7357. #define ERROR_TABLE_BASE_krb5 (-1765328384L)
  7358. /* for compatibility with older versions... */
  7359. #define init_krb5_err_tbl initialize_krb5_error_table
  7360. #define krb5_err_base ERROR_TABLE_BASE_krb5
  7361. /*
  7362. * et-h-k5e1_err.h:
  7363. * This file is automatically generated; please do not edit it.
  7364. */
  7365. #include <et/com_err.h>
  7366. #define KRB5_PLUGIN_VER_NOTSUPP (-1750600192L)
  7367. #define KRB5_PLUGIN_BAD_MODULE_SPEC (-1750600191L)
  7368. #define KRB5_PLUGIN_NAME_NOTFOUND (-1750600190L)
  7369. #define KRB5KDC_ERR_DISCARD (-1750600189L)
  7370. #define KRB5_DCC_CANNOT_CREATE (-1750600188L)
  7371. extern const struct error_table et_k5e1_error_table;
  7372. extern void initialize_k5e1_error_table(void);
  7373. /* For compatibility with Heimdal */
  7374. extern void initialize_k5e1_error_table_r(struct et_list **list);
  7375. #define ERROR_TABLE_BASE_k5e1 (-1750600192L)
  7376. /* for compatibility with older versions... */
  7377. #define init_k5e1_err_tbl initialize_k5e1_error_table
  7378. #define k5e1_err_base ERROR_TABLE_BASE_k5e1
  7379. /*
  7380. * et-h-kdb5_err.h:
  7381. * This file is automatically generated; please do not edit it.
  7382. */
  7383. #include <et/com_err.h>
  7384. #define KRB5_KDB_RCSID (-1780008448L)
  7385. #define KRB5_KDB_INUSE (-1780008447L)
  7386. #define KRB5_KDB_UK_SERROR (-1780008446L)
  7387. #define KRB5_KDB_UK_RERROR (-1780008445L)
  7388. #define KRB5_KDB_UNAUTH (-1780008444L)
  7389. #define KRB5_KDB_NOENTRY (-1780008443L)
  7390. #define KRB5_KDB_ILL_WILDCARD (-1780008442L)
  7391. #define KRB5_KDB_DB_INUSE (-1780008441L)
  7392. #define KRB5_KDB_DB_CHANGED (-1780008440L)
  7393. #define KRB5_KDB_TRUNCATED_RECORD (-1780008439L)
  7394. #define KRB5_KDB_RECURSIVELOCK (-1780008438L)
  7395. #define KRB5_KDB_NOTLOCKED (-1780008437L)
  7396. #define KRB5_KDB_BADLOCKMODE (-1780008436L)
  7397. #define KRB5_KDB_DBNOTINITED (-1780008435L)
  7398. #define KRB5_KDB_DBINITED (-1780008434L)
  7399. #define KRB5_KDB_ILLDIRECTION (-1780008433L)
  7400. #define KRB5_KDB_NOMASTERKEY (-1780008432L)
  7401. #define KRB5_KDB_BADMASTERKEY (-1780008431L)
  7402. #define KRB5_KDB_INVALIDKEYSIZE (-1780008430L)
  7403. #define KRB5_KDB_CANTREAD_STORED (-1780008429L)
  7404. #define KRB5_KDB_BADSTORED_MKEY (-1780008428L)
  7405. #define KRB5_KDB_NOACTMASTERKEY (-1780008427L)
  7406. #define KRB5_KDB_KVNONOMATCH (-1780008426L)
  7407. #define KRB5_KDB_STORED_MKEY_NOTCURRENT (-1780008425L)
  7408. #define KRB5_KDB_CANTLOCK_DB (-1780008424L)
  7409. #define KRB5_KDB_DB_CORRUPT (-1780008423L)
  7410. #define KRB5_KDB_BAD_VERSION (-1780008422L)
  7411. #define KRB5_KDB_BAD_SALTTYPE (-1780008421L)
  7412. #define KRB5_KDB_BAD_ENCTYPE (-1780008420L)
  7413. #define KRB5_KDB_BAD_CREATEFLAGS (-1780008419L)
  7414. #define KRB5_KDB_NO_PERMITTED_KEY (-1780008418L)
  7415. #define KRB5_KDB_NO_MATCHING_KEY (-1780008417L)
  7416. #define KRB5_KDB_DBTYPE_NOTFOUND (-1780008416L)
  7417. #define KRB5_KDB_DBTYPE_NOSUP (-1780008415L)
  7418. #define KRB5_KDB_DBTYPE_INIT (-1780008414L)
  7419. #define KRB5_KDB_SERVER_INTERNAL_ERR (-1780008413L)
  7420. #define KRB5_KDB_ACCESS_ERROR (-1780008412L)
  7421. #define KRB5_KDB_INTERNAL_ERROR (-1780008411L)
  7422. #define KRB5_KDB_CONSTRAINT_VIOLATION (-1780008410L)
  7423. #define KRB5_LOG_CONV (-1780008409L)
  7424. #define KRB5_LOG_UNSTABLE (-1780008408L)
  7425. #define KRB5_LOG_CORRUPT (-1780008407L)
  7426. #define KRB5_LOG_ERROR (-1780008406L)
  7427. #define KRB5_KDB_DBTYPE_MISMATCH (-1780008405L)
  7428. #define KRB5_KDB_POLICY_REF (-1780008404L)
  7429. #define KRB5_KDB_STRINGS_TOOLONG (-1780008403L)
  7430. extern const struct error_table et_kdb5_error_table;
  7431. extern void initialize_kdb5_error_table(void);
  7432. /* For compatibility with Heimdal */
  7433. extern void initialize_kdb5_error_table_r(struct et_list **list);
  7434. #define ERROR_TABLE_BASE_kdb5 (-1780008448L)
  7435. /* for compatibility with older versions... */
  7436. #define init_kdb5_err_tbl initialize_kdb5_error_table
  7437. #define kdb5_err_base ERROR_TABLE_BASE_kdb5
  7438. /*
  7439. * et-h-kv5m_err.h:
  7440. * This file is automatically generated; please do not edit it.
  7441. */
  7442. #include <et/com_err.h>
  7443. #define KV5M_NONE (-1760647424L)
  7444. #define KV5M_PRINCIPAL (-1760647423L)
  7445. #define KV5M_DATA (-1760647422L)
  7446. #define KV5M_KEYBLOCK (-1760647421L)
  7447. #define KV5M_CHECKSUM (-1760647420L)
  7448. #define KV5M_ENCRYPT_BLOCK (-1760647419L)
  7449. #define KV5M_ENC_DATA (-1760647418L)
  7450. #define KV5M_CRYPTOSYSTEM_ENTRY (-1760647417L)
  7451. #define KV5M_CS_TABLE_ENTRY (-1760647416L)
  7452. #define KV5M_CHECKSUM_ENTRY (-1760647415L)
  7453. #define KV5M_AUTHDATA (-1760647414L)
  7454. #define KV5M_TRANSITED (-1760647413L)
  7455. #define KV5M_ENC_TKT_PART (-1760647412L)
  7456. #define KV5M_TICKET (-1760647411L)
  7457. #define KV5M_AUTHENTICATOR (-1760647410L)
  7458. #define KV5M_TKT_AUTHENT (-1760647409L)
  7459. #define KV5M_CREDS (-1760647408L)
  7460. #define KV5M_LAST_REQ_ENTRY (-1760647407L)
  7461. #define KV5M_PA_DATA (-1760647406L)
  7462. #define KV5M_KDC_REQ (-1760647405L)
  7463. #define KV5M_ENC_KDC_REP_PART (-1760647404L)
  7464. #define KV5M_KDC_REP (-1760647403L)
  7465. #define KV5M_ERROR (-1760647402L)
  7466. #define KV5M_AP_REQ (-1760647401L)
  7467. #define KV5M_AP_REP (-1760647400L)
  7468. #define KV5M_AP_REP_ENC_PART (-1760647399L)
  7469. #define KV5M_RESPONSE (-1760647398L)
  7470. #define KV5M_SAFE (-1760647397L)
  7471. #define KV5M_PRIV (-1760647396L)
  7472. #define KV5M_PRIV_ENC_PART (-1760647395L)
  7473. #define KV5M_CRED (-1760647394L)
  7474. #define KV5M_CRED_INFO (-1760647393L)
  7475. #define KV5M_CRED_ENC_PART (-1760647392L)
  7476. #define KV5M_PWD_DATA (-1760647391L)
  7477. #define KV5M_ADDRESS (-1760647390L)
  7478. #define KV5M_KEYTAB_ENTRY (-1760647389L)
  7479. #define KV5M_CONTEXT (-1760647388L)
  7480. #define KV5M_OS_CONTEXT (-1760647387L)
  7481. #define KV5M_ALT_METHOD (-1760647386L)
  7482. #define KV5M_ETYPE_INFO_ENTRY (-1760647385L)
  7483. #define KV5M_DB_CONTEXT (-1760647384L)
  7484. #define KV5M_AUTH_CONTEXT (-1760647383L)
  7485. #define KV5M_KEYTAB (-1760647382L)
  7486. #define KV5M_RCACHE (-1760647381L)
  7487. #define KV5M_CCACHE (-1760647380L)
  7488. #define KV5M_PREAUTH_OPS (-1760647379L)
  7489. #define KV5M_SAM_CHALLENGE (-1760647378L)
  7490. #define KV5M_SAM_CHALLENGE_2 (-1760647377L)
  7491. #define KV5M_SAM_KEY (-1760647376L)
  7492. #define KV5M_ENC_SAM_RESPONSE_ENC (-1760647375L)
  7493. #define KV5M_ENC_SAM_RESPONSE_ENC_2 (-1760647374L)
  7494. #define KV5M_SAM_RESPONSE (-1760647373L)
  7495. #define KV5M_SAM_RESPONSE_2 (-1760647372L)
  7496. #define KV5M_PREDICTED_SAM_RESPONSE (-1760647371L)
  7497. #define KV5M_PASSWD_PHRASE_ELEMENT (-1760647370L)
  7498. #define KV5M_GSS_OID (-1760647369L)
  7499. #define KV5M_GSS_QUEUE (-1760647368L)
  7500. #define KV5M_FAST_ARMORED_REQ (-1760647367L)
  7501. #define KV5M_FAST_REQ (-1760647366L)
  7502. #define KV5M_FAST_RESPONSE (-1760647365L)
  7503. #define KV5M_AUTHDATA_CONTEXT (-1760647364L)
  7504. extern const struct error_table et_kv5m_error_table;
  7505. extern void initialize_kv5m_error_table(void);
  7506. /* For compatibility with Heimdal */
  7507. extern void initialize_kv5m_error_table_r(struct et_list **list);
  7508. #define ERROR_TABLE_BASE_kv5m (-1760647424L)
  7509. /* for compatibility with older versions... */
  7510. #define init_kv5m_err_tbl initialize_kv5m_error_table
  7511. #define kv5m_err_base ERROR_TABLE_BASE_kv5m
  7512. /*
  7513. * et-h-krb524_err.h:
  7514. * This file is automatically generated; please do not edit it.
  7515. */
  7516. #include <et/com_err.h>
  7517. #define KRB524_BADKEY (-1750206208L)
  7518. #define KRB524_BADADDR (-1750206207L)
  7519. #define KRB524_BADPRINC (-1750206206L)
  7520. #define KRB524_BADREALM (-1750206205L)
  7521. #define KRB524_V4ERR (-1750206204L)
  7522. #define KRB524_ENCFULL (-1750206203L)
  7523. #define KRB524_DECEMPTY (-1750206202L)
  7524. #define KRB524_NOTRESP (-1750206201L)
  7525. #define KRB524_KRB4_DISABLED (-1750206200L)
  7526. extern const struct error_table et_k524_error_table;
  7527. extern void initialize_k524_error_table(void);
  7528. /* For compatibility with Heimdal */
  7529. extern void initialize_k524_error_table_r(struct et_list **list);
  7530. #define ERROR_TABLE_BASE_k524 (-1750206208L)
  7531. /* for compatibility with older versions... */
  7532. #define init_k524_err_tbl initialize_k524_error_table
  7533. #define k524_err_base ERROR_TABLE_BASE_k524
  7534. /*
  7535. * et-h-asn1_err.h:
  7536. * This file is automatically generated; please do not edit it.
  7537. */
  7538. #include <et/com_err.h>
  7539. #define ASN1_BAD_TIMEFORMAT (1859794432L)
  7540. #define ASN1_MISSING_FIELD (1859794433L)
  7541. #define ASN1_MISPLACED_FIELD (1859794434L)
  7542. #define ASN1_TYPE_MISMATCH (1859794435L)
  7543. #define ASN1_OVERFLOW (1859794436L)
  7544. #define ASN1_OVERRUN (1859794437L)
  7545. #define ASN1_BAD_ID (1859794438L)
  7546. #define ASN1_BAD_LENGTH (1859794439L)
  7547. #define ASN1_BAD_FORMAT (1859794440L)
  7548. #define ASN1_PARSE_ERROR (1859794441L)
  7549. #define ASN1_BAD_GMTIME (1859794442L)
  7550. #define ASN1_MISMATCH_INDEF (1859794443L)
  7551. #define ASN1_MISSING_EOC (1859794444L)
  7552. extern const struct error_table et_asn1_error_table;
  7553. extern void initialize_asn1_error_table(void);
  7554. /* For compatibility with Heimdal */
  7555. extern void initialize_asn1_error_table_r(struct et_list **list);
  7556. #define ERROR_TABLE_BASE_asn1 (1859794432L)
  7557. /* for compatibility with older versions... */
  7558. #define init_asn1_err_tbl initialize_asn1_error_table
  7559. #define asn1_err_base ERROR_TABLE_BASE_asn1
  7560. #endif /* KRB5_KRB5_H_INCLUDED */