ssl.h 257 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796
  1. /* ssl.h
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /*!
  22. \file ../wolfssl/ssl.h
  23. \brief Header file containing key wolfSSL API
  24. */
  25. /* wolfSSL API */
  26. #ifndef WOLFSSL_SSL_H
  27. #define WOLFSSL_SSL_H
  28. /* for users not using preprocessor flags*/
  29. #include <wolfssl/wolfcrypt/settings.h>
  30. #include <wolfssl/version.h>
  31. #include <wolfssl/error-ssl.h>
  32. #include <wolfssl/wolfcrypt/asn_public.h>
  33. #include <wolfssl/wolfcrypt/logging.h>
  34. #include <wolfssl/wolfcrypt/memory.h>
  35. #include <wolfssl/wolfcrypt/types.h>
  36. #include <wolfssl/wolfcrypt/pkcs12.h>
  37. /* For the types */
  38. #include <wolfssl/openssl/compat_types.h>
  39. #ifdef HAVE_WOLF_EVENT
  40. #include <wolfssl/wolfcrypt/wolfevent.h>
  41. #endif
  42. #ifdef WOLF_CRYPTO_CB
  43. #include <wolfssl/wolfcrypt/cryptocb.h>
  44. #endif
  45. /* used internally by wolfSSL while OpenSSL types aren't */
  46. #include <wolfssl/callbacks.h>
  47. #ifdef WOLFSSL_PREFIX
  48. #include "prefix_ssl.h"
  49. #endif
  50. #ifdef LIBWOLFSSL_VERSION_STRING
  51. #define WOLFSSL_VERSION LIBWOLFSSL_VERSION_STRING
  52. #endif
  53. #ifdef _WIN32
  54. /* wincrypt.h clashes */
  55. #undef OCSP_REQUEST
  56. #undef OCSP_RESPONSE
  57. #endif
  58. #ifdef OPENSSL_ALL
  59. #ifndef WOLFSSL_HAVE_BIO_ADDR
  60. #define WOLFSSL_HAVE_BIO_ADDR
  61. #endif
  62. #if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_DTLS_MTU)
  63. #define WOLFSSL_DTLS_MTU
  64. #endif
  65. #endif
  66. #ifdef OPENSSL_COEXIST
  67. /* mode to allow wolfSSL and OpenSSL to exist together */
  68. #ifdef TEST_OPENSSL_COEXIST
  69. /*
  70. ./configure --enable-opensslcoexist \
  71. CFLAGS="-I/usr/local/opt/openssl/include -DTEST_OPENSSL_COEXIST" \
  72. LDFLAGS="-L/usr/local/opt/openssl/lib -lcrypto"
  73. */
  74. #include <openssl/ssl.h>
  75. #include <openssl/rand.h>
  76. #include <openssl/err.h>
  77. #include <openssl/ec.h>
  78. #include <openssl/hmac.h>
  79. #include <openssl/bn.h>
  80. #include <openssl/crypto.h>
  81. #endif
  82. #elif (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL))
  83. #include <wolfssl/openssl/bn.h>
  84. #include <wolfssl/openssl/rsa.h>
  85. #ifndef WOLFCRYPT_ONLY
  86. #include <wolfssl/openssl/hmac.h>
  87. #endif
  88. #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
  89. #include <wolfssl/openssl/cmac.h>
  90. #endif
  91. /* We need the old SSL names */
  92. #ifdef NO_OLD_SSL_NAMES
  93. #undef NO_OLD_SSL_NAMES
  94. #endif
  95. #ifdef NO_OLD_WC_NAMES
  96. #undef NO_OLD_WC_NAMES
  97. #endif
  98. #endif
  99. #ifdef __cplusplus
  100. extern "C" {
  101. #endif
  102. #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(WOLFSSL_WPAS_SMALL)
  103. #ifndef WOLFSSL_LOCAL_X509_STORE
  104. #define WOLFSSL_LOCAL_X509_STORE
  105. #endif
  106. #endif
  107. /* LHASH is implemented as a stack */
  108. typedef struct WOLFSSL_STACK WOLFSSL_LHASH;
  109. #ifndef WOLF_LHASH_OF
  110. #define WOLF_LHASH_OF(x) WOLFSSL_LHASH
  111. #endif
  112. #ifndef WOLF_STACK_OF
  113. #define WOLF_STACK_OF(x) WOLFSSL_STACK
  114. #endif
  115. #ifndef DECLARE_STACK_OF
  116. #define DECLARE_STACK_OF(x) WOLF_STACK_OF(x);
  117. #endif
  118. #ifndef WOLFSSL_WOLFSSL_TYPE_DEFINED
  119. #define WOLFSSL_WOLFSSL_TYPE_DEFINED
  120. typedef struct WOLFSSL WOLFSSL;
  121. #endif
  122. typedef struct WOLFSSL_SESSION WOLFSSL_SESSION;
  123. typedef struct WOLFSSL_METHOD WOLFSSL_METHOD;
  124. #ifndef WOLFSSL_WOLFSSL_CTX_TYPE_DEFINED
  125. #define WOLFSSL_WOLFSSL_CTX_TYPE_DEFINED
  126. typedef struct WOLFSSL_CTX WOLFSSL_CTX;
  127. #endif
  128. typedef struct WOLFSSL_STACK WOLFSSL_STACK;
  129. typedef struct WOLFSSL_X509 WOLFSSL_X509;
  130. typedef struct WOLFSSL_X509_ACERT WOLFSSL_X509_ACERT;
  131. typedef struct WOLFSSL_X509_NAME WOLFSSL_X509_NAME;
  132. typedef struct WOLFSSL_X509_NAME_ENTRY WOLFSSL_X509_NAME_ENTRY;
  133. typedef struct WOLFSSL_X509_PUBKEY WOLFSSL_X509_PUBKEY;
  134. typedef struct WOLFSSL_X509_ALGOR WOLFSSL_X509_ALGOR;
  135. typedef struct WOLFSSL_X509_CHAIN WOLFSSL_X509_CHAIN;
  136. typedef struct WC_PKCS12 WOLFSSL_X509_PKCS12;
  137. typedef struct WOLFSSL_X509_INFO WOLFSSL_X509_INFO;
  138. typedef struct WOLFSSL_CERT_MANAGER WOLFSSL_CERT_MANAGER;
  139. typedef struct WOLFSSL_SOCKADDR WOLFSSL_SOCKADDR;
  140. typedef struct WOLFSSL_CRL WOLFSSL_CRL;
  141. typedef struct WOLFSSL_X509_STORE_CTX WOLFSSL_X509_STORE_CTX;
  142. typedef struct WOLFSSL_BY_DIR_HASH WOLFSSL_BY_DIR_HASH;
  143. typedef struct WOLFSSL_BY_DIR_entry WOLFSSL_BY_DIR_entry;
  144. typedef struct WOLFSSL_BY_DIR WOLFSSL_BY_DIR;
  145. /* redeclare guard */
  146. #define WOLFSSL_TYPES_DEFINED
  147. #include <wolfssl/wolfio.h>
  148. #ifndef WOLFSSL_RSA_TYPE_DEFINED /* guard on redeclaration */
  149. typedef struct WOLFSSL_RSA WOLFSSL_RSA;
  150. #define WOLFSSL_RSA_TYPE_DEFINED
  151. #endif
  152. #ifndef WC_RNG_TYPE_DEFINED /* guard on redeclaration */
  153. typedef struct WC_RNG WC_RNG;
  154. #define WC_RNG_TYPE_DEFINED
  155. #endif
  156. #ifndef WOLFSSL_DSA_TYPE_DEFINED /* guard on redeclaration */
  157. typedef struct WOLFSSL_DSA WOLFSSL_DSA;
  158. #define WOLFSSL_DSA_TYPE_DEFINED
  159. #endif
  160. #ifndef WOLFSSL_EC_TYPE_DEFINED /* guard on redeclaration */
  161. typedef struct WOLFSSL_EC_KEY WOLFSSL_EC_KEY;
  162. typedef struct WOLFSSL_EC_POINT WOLFSSL_EC_POINT;
  163. typedef struct WOLFSSL_EC_GROUP WOLFSSL_EC_GROUP;
  164. typedef struct WOLFSSL_EC_BUILTIN_CURVE WOLFSSL_EC_BUILTIN_CURVE;
  165. /* WOLFSSL_EC_METHOD is just an alias of WOLFSSL_EC_GROUP for now */
  166. typedef struct WOLFSSL_EC_GROUP WOLFSSL_EC_METHOD;
  167. #define WOLFSSL_EC_TYPE_DEFINED
  168. #endif
  169. #ifndef WOLFSSL_ECDSA_TYPE_DEFINED /* guard on redeclaration */
  170. typedef struct WOLFSSL_ECDSA_SIG WOLFSSL_ECDSA_SIG;
  171. #define WOLFSSL_ECDSA_TYPE_DEFINED
  172. #endif
  173. typedef struct WOLFSSL_CIPHER WOLFSSL_CIPHER;
  174. typedef struct WOLFSSL_X509_LOOKUP WOLFSSL_X509_LOOKUP;
  175. typedef struct WOLFSSL_X509_LOOKUP_METHOD WOLFSSL_X509_LOOKUP_METHOD;
  176. typedef struct WOLFSSL_CRL WOLFSSL_X509_CRL;
  177. typedef struct WOLFSSL_X509_STORE WOLFSSL_X509_STORE;
  178. typedef struct WOLFSSL_X509_VERIFY_PARAM WOLFSSL_X509_VERIFY_PARAM;
  179. typedef struct WOLFSSL_BIO_METHOD WOLFSSL_BIO_METHOD;
  180. typedef struct WOLFSSL_X509_EXTENSION WOLFSSL_X509_EXTENSION;
  181. typedef struct WOLFSSL_ASN1_OBJECT WOLFSSL_ASN1_OBJECT;
  182. typedef struct WOLFSSL_ASN1_OTHERNAME WOLFSSL_ASN1_OTHERNAME;
  183. typedef struct WOLFSSL_ASN1_OTHERNAME OTHERNAME;
  184. typedef struct WOLFSSL_X509V3_CTX WOLFSSL_X509V3_CTX;
  185. typedef struct WOLFSSL_v3_ext_method WOLFSSL_v3_ext_method;
  186. typedef struct WOLFSSL_OBJ_NAME WOLFSSL_OBJ_NAME;
  187. typedef struct WOLFSSL_ASN1_STRING WOLFSSL_ASN1_STRING;
  188. typedef struct WOLFSSL_dynlock_value WOLFSSL_dynlock_value;
  189. #ifndef WOLFSSL_DH_TYPE_DEFINED /* guard on redeclaration */
  190. typedef struct WOLFSSL_DH WOLFSSL_DH;
  191. #define WOLFSSL_DH_TYPE_DEFINED /* guard on redeclaration */
  192. #endif
  193. typedef struct WOLFSSL_ASN1_BIT_STRING WOLFSSL_ASN1_BIT_STRING;
  194. typedef struct WOLFSSL_ASN1_TYPE WOLFSSL_ASN1_TYPE;
  195. typedef struct WOLFSSL_X509_ATTRIBUTE WOLFSSL_X509_ATTRIBUTE;
  196. typedef struct WOLFSSL_GENERAL_NAME WOLFSSL_GENERAL_NAME;
  197. typedef struct WOLFSSL_AUTHORITY_KEYID WOLFSSL_AUTHORITY_KEYID;
  198. typedef struct WOLFSSL_BASIC_CONSTRAINTS WOLFSSL_BASIC_CONSTRAINTS;
  199. typedef struct WOLFSSL_ACCESS_DESCRIPTION WOLFSSL_ACCESS_DESCRIPTION;
  200. typedef struct WOLFSSL_DIST_POINT_NAME WOLFSSL_DIST_POINT_NAME;
  201. typedef struct WOLFSSL_DIST_POINT WOLFSSL_DIST_POINT;
  202. typedef struct WOLFSSL_CONF_CTX WOLFSSL_CONF_CTX;
  203. typedef int (*WOLFSSL_X509_STORE_CTX_verify_cb)(int, WOLFSSL_X509_STORE_CTX *);
  204. typedef int (*WOLFSSL_X509_STORE_CTX_get_crl_cb)(WOLFSSL_X509_STORE_CTX *,
  205. WOLFSSL_X509_CRL **, WOLFSSL_X509 *);
  206. typedef int (*WOLFSSL_X509_STORE_CTX_check_crl_cb)(WOLFSSL_X509_STORE_CTX *,
  207. WOLFSSL_X509_CRL *);
  208. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) || defined(HAVE_CURL)
  209. struct WOLFSSL_OBJ_NAME {
  210. int type;
  211. int alias;
  212. const char *name;
  213. const char *data;
  214. };
  215. struct WOLFSSL_AUTHORITY_KEYID {
  216. WOLFSSL_ASN1_STRING *keyid;
  217. WOLFSSL_ASN1_OBJECT *issuer;
  218. WOLFSSL_ASN1_INTEGER *serial;
  219. };
  220. struct WOLFSSL_BASIC_CONSTRAINTS {
  221. int ca;
  222. WOLFSSL_ASN1_INTEGER *pathlen;
  223. };
  224. #endif /* OPENSSL_EXTRA*/
  225. #define WOLFSSL_ASN1_UTCTIME WOLFSSL_ASN1_TIME
  226. #define WOLFSSL_ASN1_GENERALIZEDTIME WOLFSSL_ASN1_TIME
  227. struct WOLFSSL_ASN1_STRING {
  228. char strData[CTC_NAME_SIZE];
  229. int length;
  230. int type; /* type of string i.e. CTC_UTF8 */
  231. int nid;
  232. char* data;
  233. long flags;
  234. unsigned int isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
  235. };
  236. #define WOLFSSL_MAX_SNAME 40
  237. #define WOLFSSL_ASN1_DYNAMIC 0x1
  238. #define WOLFSSL_ASN1_DYNAMIC_DATA 0x2
  239. struct WOLFSSL_ASN1_OTHERNAME {
  240. WOLFSSL_ASN1_OBJECT* type_id;
  241. WOLFSSL_ASN1_TYPE* value;
  242. };
  243. struct WOLFSSL_GENERAL_NAME {
  244. int type;
  245. union {
  246. char* ptr;
  247. WOLFSSL_ASN1_OTHERNAME* otherName;
  248. WOLFSSL_ASN1_STRING* rfc822Name;
  249. WOLFSSL_ASN1_STRING* dNSName;
  250. WOLFSSL_ASN1_TYPE* x400Address;
  251. WOLFSSL_X509_NAME* directoryName;
  252. WOLFSSL_ASN1_STRING* uniformResourceIdentifier;
  253. WOLFSSL_ASN1_STRING* iPAddress;
  254. WOLFSSL_ASN1_OBJECT* registeredID;
  255. WOLFSSL_ASN1_STRING* ip;
  256. WOLFSSL_X509_NAME* dirn;
  257. WOLFSSL_ASN1_STRING* ia5;
  258. WOLFSSL_ASN1_OBJECT* rid;
  259. WOLFSSL_ASN1_TYPE* other;
  260. } d; /* dereference */
  261. };
  262. struct WOLFSSL_DIST_POINT_NAME {
  263. int type;
  264. /* name 'name.fullname' needs to remain the same, in some ports the elements
  265. * of the structure are accessed directly */
  266. union {
  267. WOLF_STACK_OF(WOLFSSL_GENERAL_NAME)* fullname;
  268. } name;
  269. };
  270. struct WOLFSSL_DIST_POINT {
  271. /* name 'distpoint' needs to remain the same, in some ports the elements of
  272. * the structure are accessed directly */
  273. WOLFSSL_DIST_POINT_NAME* distpoint;
  274. };
  275. struct WOLFSSL_ACCESS_DESCRIPTION {
  276. WOLFSSL_ASN1_OBJECT* method;
  277. WOLFSSL_GENERAL_NAME* location;
  278. };
  279. struct WOLFSSL_X509V3_CTX {
  280. WOLFSSL_X509* x509;
  281. };
  282. struct WOLFSSL_ASN1_OBJECT {
  283. void* heap;
  284. const unsigned char* obj;
  285. /* sName is short name i.e sha256 rather than oid (null terminated) */
  286. char sName[WOLFSSL_MAX_SNAME];
  287. int type; /* oid */
  288. int grp; /* type of OID, i.e. oidCertPolicyType */
  289. int nid;
  290. unsigned int objSz;
  291. #if defined(OPENSSL_EXTRA)
  292. int ca;
  293. WOLFSSL_ASN1_INTEGER *pathlen;
  294. #endif
  295. unsigned char dynamic; /* Use WOLFSSL_ASN1_DYNAMIC and WOLFSSL_ASN1_DYNAMIC_DATA
  296. * to determine what needs to be freed. */
  297. #if defined(WOLFSSL_APACHE_HTTPD)
  298. WOLFSSL_GENERAL_NAME* gn;
  299. #endif
  300. struct d { /* dereferenced */
  301. WOLFSSL_ASN1_STRING* dNSName;
  302. WOLFSSL_ASN1_STRING ia5_internal;
  303. WOLFSSL_ASN1_STRING* ia5; /* points to ia5_internal */
  304. #if defined(OPENSSL_ALL)
  305. WOLFSSL_ASN1_STRING* uniformResourceIdentifier;
  306. WOLFSSL_ASN1_STRING iPAddress_internal;
  307. WOLFSSL_ASN1_OTHERNAME* otherName; /* added for Apache httpd */
  308. #endif
  309. WOLFSSL_ASN1_STRING* iPAddress; /* points to iPAddress_internal */
  310. } d;
  311. };
  312. /* wrap ASN1 types */
  313. struct WOLFSSL_ASN1_TYPE {
  314. int type;
  315. union {
  316. char *ptr;
  317. WOLFSSL_ASN1_STRING* asn1_string;
  318. WOLFSSL_ASN1_OBJECT* object;
  319. WOLFSSL_ASN1_INTEGER* integer;
  320. WOLFSSL_ASN1_BIT_STRING* bit_string;
  321. WOLFSSL_ASN1_STRING* octet_string;
  322. WOLFSSL_ASN1_STRING* printablestring;
  323. WOLFSSL_ASN1_STRING* ia5string;
  324. WOLFSSL_ASN1_UTCTIME* utctime;
  325. WOLFSSL_ASN1_GENERALIZEDTIME* generalizedtime;
  326. WOLFSSL_ASN1_STRING* utf8string;
  327. WOLFSSL_ASN1_STRING* set;
  328. WOLFSSL_ASN1_STRING* sequence;
  329. } value;
  330. };
  331. struct WOLFSSL_X509_ATTRIBUTE {
  332. WOLFSSL_ASN1_OBJECT *object;
  333. WOLFSSL_ASN1_TYPE *value;
  334. WOLF_STACK_OF(WOLFSSL_ASN1_TYPE) *set;
  335. };
  336. struct WOLFSSL_EVP_PKEY {
  337. void* heap;
  338. int type; /* openssh dereference */
  339. int save_type; /* openssh dereference */
  340. int pkey_sz;
  341. wolfSSL_Ref ref;
  342. union {
  343. char* ptr; /* der format of key */
  344. } pkey;
  345. #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL))
  346. #ifndef NO_RSA
  347. WOLFSSL_RSA* rsa;
  348. #endif
  349. #ifndef NO_DSA
  350. WOLFSSL_DSA* dsa;
  351. #endif
  352. #ifdef HAVE_ECC
  353. WOLFSSL_EC_KEY* ecc;
  354. #endif
  355. #ifndef NO_DH
  356. WOLFSSL_DH* dh;
  357. #endif
  358. WC_RNG rng;
  359. #ifdef HAVE_HKDF
  360. const WOLFSSL_EVP_MD* hkdfMd;
  361. byte* hkdfSalt;
  362. word32 hkdfSaltSz;
  363. byte* hkdfKey;
  364. word32 hkdfKeySz;
  365. byte* hkdfInfo;
  366. word32 hkdfInfoSz;
  367. int hkdfMode;
  368. #endif
  369. #if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_DIRECT)
  370. WOLFSSL_CMAC_CTX* cmacCtx;
  371. #endif
  372. #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
  373. #ifdef HAVE_ECC
  374. int pkey_curve;
  375. #endif
  376. word16 pkcs8HeaderSz;
  377. /* option bits */
  378. byte ownDh:1; /* if struct owns DH and should free it */
  379. byte ownEcc:1; /* if struct owns ECC and should free it */
  380. byte ownDsa:1; /* if struct owns DSA and should free it */
  381. byte ownRsa:1; /* if struct owns RSA and should free it */
  382. };
  383. struct WOLFSSL_X509_PKEY {
  384. WOLFSSL_EVP_PKEY* dec_pkey; /* dereferenced by Apache */
  385. void* heap;
  386. };
  387. typedef struct WOLFSSL_X509_PKEY WOLFSSL_X509_PKEY;
  388. struct WOLFSSL_X509_INFO {
  389. WOLFSSL_X509 *x509;
  390. WOLFSSL_X509_CRL *crl;
  391. WOLFSSL_X509_PKEY *x_pkey; /* dereferenced by Apache */
  392. EncryptedInfo enc_cipher;
  393. int enc_len;
  394. char *enc_data;
  395. int num;
  396. };
  397. #define WOLFSSL_EVP_PKEY_DEFAULT EVP_PKEY_RSA /* default key type */
  398. #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
  399. #define wolfSSL_SSL_MODE_RELEASE_BUFFERS 0x00000010U
  400. #define wolfSSL_SSL_CTRL_SET_TMP_ECDH 4
  401. #endif
  402. struct WOLFSSL_X509_ALGOR {
  403. WOLFSSL_ASN1_OBJECT* algorithm;
  404. WOLFSSL_ASN1_TYPE* parameter;
  405. };
  406. struct WOLFSSL_X509_PUBKEY {
  407. WOLFSSL_X509_ALGOR* algor;
  408. WOLFSSL_EVP_PKEY* pkey;
  409. int pubKeyOID;
  410. };
  411. enum BIO_TYPE {
  412. WOLFSSL_BIO_UNDEF = 0,
  413. WOLFSSL_BIO_BUFFER = 1,
  414. WOLFSSL_BIO_SOCKET = 2,
  415. WOLFSSL_BIO_SSL = 3,
  416. WOLFSSL_BIO_MEMORY = 4,
  417. WOLFSSL_BIO_BIO = 5,
  418. WOLFSSL_BIO_FILE = 6,
  419. WOLFSSL_BIO_BASE64 = 7,
  420. WOLFSSL_BIO_MD = 8,
  421. WOLFSSL_BIO_DGRAM = 9
  422. };
  423. enum BIO_FLAGS {
  424. WOLFSSL_BIO_FLAG_BASE64_NO_NL = 0x01,
  425. WOLFSSL_BIO_FLAG_READ = 0x02,
  426. WOLFSSL_BIO_FLAG_WRITE = 0x04,
  427. WOLFSSL_BIO_FLAG_IO_SPECIAL = 0x08,
  428. WOLFSSL_BIO_FLAG_RETRY = 0x10
  429. };
  430. enum BIO_CB_OPS {
  431. WOLFSSL_BIO_CB_FREE = 0x01,
  432. WOLFSSL_BIO_CB_READ = 0x02,
  433. WOLFSSL_BIO_CB_WRITE = 0x03,
  434. WOLFSSL_BIO_CB_PUTS = 0x04,
  435. WOLFSSL_BIO_CB_GETS = 0x05,
  436. WOLFSSL_BIO_CB_CTRL = 0x06,
  437. WOLFSSL_BIO_CB_RETURN = 0x80
  438. };
  439. typedef struct WOLFSSL_BUF_MEM {
  440. char* data; /* dereferenced */
  441. size_t length; /* current length */
  442. size_t max; /* maximum length */
  443. } WOLFSSL_BUF_MEM;
  444. /* custom method with user set callbacks */
  445. typedef int (*wolfSSL_BIO_meth_write_cb)(WOLFSSL_BIO*, const char*, int);
  446. typedef int (*wolfSSL_BIO_meth_read_cb)(WOLFSSL_BIO *, char *, int);
  447. typedef int (*wolfSSL_BIO_meth_puts_cb)(WOLFSSL_BIO*, const char*);
  448. typedef int (*wolfSSL_BIO_meth_gets_cb)(WOLFSSL_BIO*, char*, int);
  449. typedef long (*wolfSSL_BIO_meth_ctrl_get_cb)(WOLFSSL_BIO*, int, long, void*);
  450. typedef int (*wolfSSL_BIO_meth_create_cb)(WOLFSSL_BIO*);
  451. typedef int (*wolfSSL_BIO_meth_destroy_cb)(WOLFSSL_BIO*);
  452. typedef int wolfSSL_BIO_info_cb(WOLFSSL_BIO *, int, int);
  453. typedef long (*wolfssl_BIO_meth_ctrl_info_cb)(WOLFSSL_BIO*, int, wolfSSL_BIO_info_cb*);
  454. /* wolfSSL BIO_METHOD type */
  455. #ifndef MAX_BIO_METHOD_NAME
  456. #define MAX_BIO_METHOD_NAME 256
  457. #endif
  458. struct WOLFSSL_BIO_METHOD {
  459. byte type; /* method type */
  460. char name[MAX_BIO_METHOD_NAME];
  461. wolfSSL_BIO_meth_write_cb writeCb;
  462. wolfSSL_BIO_meth_read_cb readCb;
  463. wolfSSL_BIO_meth_puts_cb putsCb;
  464. wolfSSL_BIO_meth_gets_cb getsCb;
  465. wolfSSL_BIO_meth_ctrl_get_cb ctrlCb;
  466. wolfSSL_BIO_meth_create_cb createCb;
  467. wolfSSL_BIO_meth_destroy_cb freeCb;
  468. wolfssl_BIO_meth_ctrl_info_cb ctrlInfoCb;
  469. };
  470. #define WOLFSSL_BIO_METHOD_INIT(bio_type) \
  471. { bio_type, { 0 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
  472. /* wolfSSL BIO type */
  473. typedef long (*wolf_bio_info_cb)(WOLFSSL_BIO *bio, int event, const char *parg,
  474. int iarg, long larg, long return_value);
  475. typedef struct WOLFSSL_COMP_METHOD {
  476. int type; /* stunnel dereference */
  477. } WOLFSSL_COMP_METHOD;
  478. typedef struct WOLFSSL_COMP {
  479. int id;
  480. const char *name;
  481. WOLFSSL_COMP_METHOD *method;
  482. } WOLFSSL_COMP;
  483. #define WOLFSSL_X509_L_FILE_LOAD 0x1
  484. #define WOLFSSL_X509_L_ADD_DIR 0x2
  485. #define WOLFSSL_X509_L_ADD_STORE 0x3
  486. #define WOLFSSL_X509_L_LOAD_STORE 0x4
  487. struct WOLFSSL_X509_LOOKUP_METHOD {
  488. int type;
  489. };
  490. struct WOLFSSL_X509_LOOKUP {
  491. WOLFSSL_X509_STORE *store;
  492. int type;
  493. WOLFSSL_BY_DIR* dirs;
  494. };
  495. struct WOLFSSL_X509_STORE {
  496. int cache; /* stunnel dereference */
  497. WOLFSSL_CERT_MANAGER* cm;
  498. WOLFSSL_X509_LOOKUP lookup;
  499. #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || \
  500. defined(WOLFSSL_WPAS_SMALL)
  501. int isDynamic;
  502. WOLFSSL_X509_VERIFY_PARAM* param; /* certificate validation parameter */
  503. #endif
  504. #ifdef OPENSSL_ALL
  505. WOLF_STACK_OF(WOLFSSL_X509_OBJECT)* objs; /* object stack cache */
  506. #endif
  507. #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT)
  508. WOLFSSL_X509_STORE_CTX_verify_cb verify_cb;
  509. WOLFSSL_X509_STORE_CTX_get_crl_cb get_crl_cb;
  510. #endif
  511. #ifdef HAVE_EX_DATA
  512. WOLFSSL_CRYPTO_EX_DATA ex_data;
  513. #endif
  514. #if (defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || \
  515. defined(WOLFSSL_WPAS_SMALL)) && defined(HAVE_CRL)
  516. WOLFSSL_X509_CRL *crl; /* points to cm->crl */
  517. #endif
  518. wolfSSL_Ref ref;
  519. WOLF_STACK_OF(WOLFSSL_X509)* certs;
  520. WOLF_STACK_OF(WOLFSSL_X509)* trusted;
  521. WOLF_STACK_OF(WOLFSSL_X509)* owned;
  522. word32 numAdded; /* Number of objs in objs that are in certs sk */
  523. };
  524. #define WOLFSSL_ALWAYS_CHECK_SUBJECT 0x1
  525. #define WOLFSSL_NO_WILDCARDS 0x2
  526. #define WOLFSSL_NO_PARTIAL_WILDCARDS 0x4
  527. #define WOLFSSL_MULTI_LABEL_WILDCARDS 0x8
  528. /* Custom to wolfSSL, OpenSSL compat goes up to 0x20 */
  529. #define WOLFSSL_LEFT_MOST_WILDCARD_ONLY 0x40
  530. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
  531. #define WOLFSSL_USE_CHECK_TIME 0x2
  532. #define WOLFSSL_NO_CHECK_TIME 0x200000
  533. #define WOLFSSL_PARTIAL_CHAIN 0x80000
  534. #define WOLFSSL_HOST_NAME_MAX 256
  535. #define WOLFSSL_VPARAM_DEFAULT 0x1
  536. #define WOLFSSL_VPARAM_OVERWRITE 0x2
  537. #define WOLFSSL_VPARAM_RESET_FLAGS 0x4
  538. #define WOLFSSL_VPARAM_LOCKED 0x8
  539. #define WOLFSSL_VPARAM_ONCE 0x10
  540. #ifndef WOLFSSL_MAX_IPSTR
  541. #define WOLFSSL_MAX_IPSTR 46 /* max ip size IPv4 mapped IPv6 */
  542. #endif
  543. struct WOLFSSL_X509_VERIFY_PARAM {
  544. const char *name;
  545. time_t check_time;
  546. unsigned int inherit_flags;
  547. unsigned long flags;
  548. char hostName[WOLFSSL_HOST_NAME_MAX];
  549. unsigned int hostFlags;
  550. char ipasc[WOLFSSL_MAX_IPSTR];
  551. };
  552. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  553. typedef struct WOLFSSL_ALERT {
  554. int code;
  555. int level;
  556. } WOLFSSL_ALERT;
  557. typedef struct WOLFSSL_ALERT_HISTORY {
  558. WOLFSSL_ALERT last_rx;
  559. WOLFSSL_ALERT last_tx;
  560. } WOLFSSL_ALERT_HISTORY;
  561. typedef struct WOLFSSL_X509_REVOKED {
  562. WOLFSSL_ASN1_INTEGER* serialNumber; /* stunnel dereference */
  563. } WOLFSSL_X509_REVOKED;
  564. typedef enum {
  565. WOLFSSL_X509_LU_NONE = 0,
  566. WOLFSSL_X509_LU_X509,
  567. WOLFSSL_X509_LU_CRL
  568. } WOLFSSL_X509_LOOKUP_TYPE;
  569. typedef struct WOLFSSL_X509_OBJECT {
  570. WOLFSSL_X509_LOOKUP_TYPE type;
  571. union {
  572. char* ptr;
  573. WOLFSSL_X509 *x509;
  574. WOLFSSL_X509_CRL* crl; /* stunnel dereference */
  575. } data;
  576. } WOLFSSL_X509_OBJECT;
  577. #define WOLFSSL_ASN1_BOOLEAN int
  578. typedef struct WOLFSSL_BUFFER_INFO {
  579. unsigned char* buffer;
  580. unsigned int length;
  581. } WOLFSSL_BUFFER_INFO;
  582. struct WOLFSSL_X509_STORE_CTX {
  583. WOLFSSL_X509_STORE* store; /* Store full of a CA cert chain */
  584. WOLFSSL_X509* current_cert; /* current X509 (OPENSSL_EXTRA) */
  585. #if defined(WOLFSSL_ASIO) || defined(OPENSSL_EXTRA)
  586. WOLFSSL_X509* current_issuer; /* asio dereference */
  587. #endif
  588. WOLFSSL_X509_CHAIN* sesChain; /* pointer to WOLFSSL_SESSION peer chain */
  589. WOLFSSL_STACK* chain;
  590. #ifdef OPENSSL_EXTRA
  591. WOLFSSL_X509_VERIFY_PARAM* param; /* certificate validation parameter */
  592. #endif
  593. char* domain; /* subject CN domain name */
  594. #ifdef HAVE_EX_DATA
  595. WOLFSSL_CRYPTO_EX_DATA ex_data; /* external data */
  596. #endif
  597. #if defined(WOLFSSL_APACHE_HTTPD) || defined(OPENSSL_EXTRA)
  598. int depth; /* used in X509_STORE_CTX_*_depth */
  599. #endif
  600. void* userCtx; /* user ctx */
  601. int error; /* current error */
  602. int error_depth; /* index of cert depth for this error */
  603. int discardSessionCerts; /* so verify callback can flag for discard */
  604. int totalCerts; /* number of peer cert buffers */
  605. WOLFSSL_BUFFER_INFO* certs; /* peer certs */
  606. WOLFSSL_X509_STORE_CTX_verify_cb verify_cb; /* verify callback */
  607. void* heap;
  608. int flags;
  609. WOLF_STACK_OF(WOLFSSL_X509)* owned; /* Certs owned by this CTX */
  610. WOLF_STACK_OF(WOLFSSL_X509)* ctxIntermediates; /* Intermediates specified
  611. * on store ctx init */
  612. WOLF_STACK_OF(WOLFSSL_X509)* setTrustedSk;/* A trusted stack override
  613. * set with
  614. * X509_STORE_CTX_trusted_stack*/
  615. };
  616. typedef char* WOLFSSL_STRING;
  617. typedef struct WOLFSSL_RAND_METHOD {
  618. /* seed = Data to mix into the random generator.
  619. * len = Number of bytes to mix from seed. */
  620. int (*seed)(const void* seed, int len);
  621. /* buf = Buffer to store random bytes in.
  622. * len = Number of bytes to store in buf. */
  623. int (*bytes)(unsigned char* buf, int len);
  624. void (*cleanup)(void);
  625. /* add = Data to mix into the random generator.
  626. * len = Number of bytes to mix from add.
  627. * entropy = Estimate of randomness contained in seed.
  628. * Should be between 0 and len. */
  629. int (*add)(const void* add, int len, double entropy);
  630. /* buf = Buffer to store pseudorandom bytes in.
  631. * len = Number of bytes to store in buf. */
  632. int (*pseudorand)(unsigned char *buf, int len);
  633. int (*status)(void);
  634. } WOLFSSL_RAND_METHOD;
  635. /* Valid Alert types from page 16/17
  636. * Add alert string to the function wolfSSL_alert_type_string_long in src/ssl.c
  637. */
  638. enum AlertDescription {
  639. invalid_alert = -1,
  640. close_notify = 0,
  641. unexpected_message = 10,
  642. bad_record_mac = 20,
  643. record_overflow = 22,
  644. decompression_failure = 30,
  645. handshake_failure = 40,
  646. no_certificate = 41,
  647. bad_certificate = 42,
  648. unsupported_certificate = 43,
  649. certificate_revoked = 44,
  650. certificate_expired = 45,
  651. certificate_unknown = 46,
  652. illegal_parameter = 47,
  653. unknown_ca = 48,
  654. access_denied = 49,
  655. decode_error = 50,
  656. decrypt_error = 51,
  657. #ifdef WOLFSSL_MYSQL_COMPATIBLE
  658. /* catch name conflict for enum protocol with MYSQL build */
  659. wc_protocol_version = 70,
  660. #else
  661. protocol_version = 70,
  662. #endif
  663. insufficient_security = 71,
  664. internal_error = 80,
  665. inappropriate_fallback = 86,
  666. user_canceled = 90,
  667. no_renegotiation = 100,
  668. missing_extension = 109,
  669. unsupported_extension = 110, /**< RFC 5246, section 7.2.2 */
  670. unrecognized_name = 112, /**< RFC 6066, section 3 */
  671. bad_certificate_status_response = 113, /**< RFC 6066, section 8 */
  672. unknown_psk_identity = 115, /**< RFC 4279, section 2 */
  673. certificate_required = 116, /**< RFC 8446, section 8.2 */
  674. no_application_protocol = 120
  675. };
  676. #ifdef WOLFSSL_MYSQL_COMPATIBLE
  677. #define wolfssl_alert_protocol_version wc_protocol_version
  678. #else
  679. #define wolfssl_alert_protocol_version protocol_version
  680. #endif
  681. enum AlertLevel {
  682. alert_none = 0, /* Used to indicate no alert level is set */
  683. alert_warning = 1,
  684. alert_fatal = 2
  685. };
  686. enum SNICbReturn {
  687. warning_return = alert_warning,
  688. fatal_return = alert_fatal,
  689. noack_return,
  690. };
  691. /* WS_RETURN_CODE macro
  692. * Some OpenSSL APIs specify "0" as the return value when an error occurs.
  693. * However, some corresponding wolfSSL APIs return negative values. Such
  694. * functions should use this macro to fill this gap. Users who want them
  695. * to return the same return value as OpenSSL can define
  696. * WOLFSSL_ERR_CODE_OPENSSL.
  697. * Give rc a variable that contains the potentially negative
  698. * wolfSSL-defined return value or the return value itself, and
  699. * give fail_rc the openSSL-defined return value.
  700. * Note that this macro replaces only negative return values with the
  701. * specified value.
  702. * Since wolfSSL 4.7.0, the following functions use this macro:
  703. * - wolfSSL_CTX_load_verify_locations
  704. * - wolfSSL_X509_LOOKUP_load_file
  705. * - wolfSSL_EVP_PKEY_cmp
  706. */
  707. #if defined(WOLFSSL_ERROR_CODE_OPENSSL)
  708. #define WS_RETURN_CODE(rc, fail_rc) \
  709. (((rc) < 0) ? (int)(fail_rc) : (int)(rc))
  710. #else
  711. #define WS_RETURN_CODE(rc, fail_rc) (rc)
  712. #endif
  713. #define WS_RC(rc) \
  714. (((rc) == 1) ? 1 : 0)
  715. #define WC_TO_WS_RC(ret) \
  716. (((ret) == 0) ? 1 : (ret))
  717. /* Maximum master key length (SECRET_LEN) */
  718. #define WOLFSSL_MAX_MASTER_KEY_LENGTH 48
  719. /* Maximum number of groups that can be set */
  720. #ifdef HAVE_PQC
  721. #define WOLFSSL_MAX_GROUP_COUNT 36
  722. #else
  723. #define WOLFSSL_MAX_GROUP_COUNT 10
  724. #endif
  725. #if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
  726. enum Tls13Secret {
  727. CLIENT_EARLY_TRAFFIC_SECRET,
  728. CLIENT_HANDSHAKE_TRAFFIC_SECRET,
  729. SERVER_HANDSHAKE_TRAFFIC_SECRET,
  730. CLIENT_TRAFFIC_SECRET,
  731. SERVER_TRAFFIC_SECRET,
  732. EARLY_EXPORTER_SECRET,
  733. EXPORTER_SECRET
  734. };
  735. #endif
  736. #ifndef WOLFSSL_MODE_AUTO_RETRY_ATTEMPTS
  737. #define WOLFSSL_MODE_AUTO_RETRY_ATTEMPTS 10
  738. #endif
  739. typedef WOLFSSL_METHOD* (*wolfSSL_method_func)(void* heap);
  740. /* CTX Method Constructor Functions */
  741. #ifndef NO_WOLFSSL_CLIENT
  742. WOLFSSL_API WOLFSSL_METHOD *wolfTLS_client_method_ex(void* heap);
  743. WOLFSSL_API WOLFSSL_METHOD *wolfTLS_client_method(void);
  744. #endif
  745. #ifndef NO_WOLFSSL_SERVER
  746. WOLFSSL_API WOLFSSL_METHOD *wolfTLS_server_method_ex(void* heap);
  747. WOLFSSL_API WOLFSSL_METHOD *wolfTLS_server_method(void);
  748. #endif
  749. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_method_ex(void* heap);
  750. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_method(void);
  751. #ifndef NO_WOLFSSL_CLIENT
  752. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_client_method_ex(void* heap);
  753. WOLFSSL_API WOLFSSL_METHOD* wolfSSLv23_client_method(void);
  754. #endif
  755. #ifndef NO_WOLFSSL_SERVER
  756. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_server_method_ex(void* heap);
  757. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv23_server_method(void);
  758. #endif
  759. #ifndef NO_OLD_TLS
  760. #ifdef OPENSSL_EXTRA
  761. #ifndef NO_WOLFSSL_CLIENT
  762. WOLFSSL_API WOLFSSL_METHOD* wolfSSLv2_client_method(void);
  763. #endif
  764. #ifndef NO_WOLFSSL_SERVER
  765. WOLFSSL_API WOLFSSL_METHOD* wolfSSLv2_server_method(void);
  766. #endif
  767. #endif /* OPENSSL_EXTRA */
  768. #ifdef WOLFSSL_ALLOW_SSLV3
  769. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_method_ex(void* heap);
  770. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_method(void);
  771. #ifndef NO_WOLFSSL_CLIENT
  772. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_client_method_ex(void* heap);
  773. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_client_method(void);
  774. #endif
  775. #ifndef NO_WOLFSSL_SERVER
  776. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_server_method_ex(void* heap);
  777. WOLFSSL_API WOLFSSL_METHOD *wolfSSLv3_server_method(void);
  778. #endif
  779. #endif /* WOLFSSL_ALLOW_SSLV3 */
  780. #ifdef WOLFSSL_ALLOW_TLSV10
  781. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_method_ex(void* heap);
  782. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_method(void);
  783. #ifndef NO_WOLFSSL_CLIENT
  784. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_client_method_ex(void* heap);
  785. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_client_method(void);
  786. #endif
  787. #ifndef NO_WOLFSSL_SERVER
  788. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_server_method_ex(void* heap);
  789. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_server_method(void);
  790. #endif
  791. #endif /* WOLFSSL_ALLOW_TLSV10 */
  792. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_method_ex(void* heap);
  793. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_method(void);
  794. #ifndef NO_WOLFSSL_CLIENT
  795. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_client_method_ex(void* heap);
  796. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_client_method(void);
  797. #endif
  798. #ifndef NO_WOLFSSL_SERVER
  799. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_server_method_ex(void* heap);
  800. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_1_server_method(void);
  801. #endif
  802. #endif /* NO_OLD_TLS */
  803. #ifndef WOLFSSL_NO_TLS12
  804. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_method_ex(void* heap);
  805. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_method(void);
  806. #ifndef NO_WOLFSSL_CLIENT
  807. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_client_method_ex(void* heap);
  808. WOLFSSL_ABI WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_client_method(void);
  809. #endif
  810. #ifndef NO_WOLFSSL_SERVER
  811. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_server_method_ex(void* heap);
  812. WOLFSSL_ABI WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_2_server_method(void);
  813. #endif
  814. #endif /* !WOLFSSL_NO_TLS12 */
  815. #ifdef WOLFSSL_TLS13
  816. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_method_ex(void* heap);
  817. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_method(void);
  818. #ifndef NO_WOLFSSL_CLIENT
  819. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_client_method_ex(void* heap);
  820. WOLFSSL_ABI WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_client_method(void);
  821. #endif
  822. #ifndef NO_WOLFSSL_SERVER
  823. WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_server_method_ex(void* heap);
  824. WOLFSSL_ABI WOLFSSL_API WOLFSSL_METHOD *wolfTLSv1_3_server_method(void);
  825. #endif
  826. #endif /* WOLFSSL_TLS13 */
  827. #ifdef WOLFSSL_DTLS
  828. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_method_ex(void* heap);
  829. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_method(void);
  830. #ifndef NO_WOLFSSL_CLIENT
  831. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_client_method_ex(void* heap);
  832. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_client_method(void);
  833. #endif
  834. #ifndef NO_WOLFSSL_SERVER
  835. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_server_method_ex(void* heap);
  836. WOLFSSL_API WOLFSSL_METHOD *wolfDTLS_server_method(void);
  837. #endif
  838. #ifndef NO_OLD_TLS
  839. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_method_ex(void* heap);
  840. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_method(void);
  841. #ifndef NO_WOLFSSL_CLIENT
  842. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_client_method_ex(void* heap);
  843. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_client_method(void);
  844. #endif
  845. #ifndef NO_WOLFSSL_SERVER
  846. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_server_method_ex(void* heap);
  847. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_server_method(void);
  848. #endif
  849. #endif /* !NO_OLD_TLS */
  850. #ifndef WOLFSSL_NO_TLS12
  851. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_method_ex(void* heap);
  852. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_method(void);
  853. #ifndef NO_WOLFSSL_CLIENT
  854. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_client_method_ex(void* heap);
  855. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_client_method(void);
  856. #endif
  857. #ifndef NO_WOLFSSL_SERVER
  858. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_server_method_ex(void* heap);
  859. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_2_server_method(void);
  860. #endif
  861. #endif /* !WOLFSSL_NO_TLS12 */
  862. #ifdef WOLFSSL_DTLS13
  863. #ifndef NO_WOLFSSL_CLIENT
  864. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_client_method_ex(void* heap);
  865. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_client_method(void);
  866. #endif
  867. #ifndef NO_WOLFSSL_SERVER
  868. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_server_method_ex(void* heap);
  869. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_server_method(void);
  870. #endif
  871. #if defined(WOLFSSL_EITHER_SIDE) || defined(OPENSSL_EXTRA)
  872. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_method_ex(void* heap);
  873. WOLFSSL_API WOLFSSL_METHOD *wolfDTLSv1_3_method(void);
  874. #endif
  875. WOLFSSL_API int wolfSSL_dtls13_has_pending_msg(WOLFSSL *ssl);
  876. #endif /* WOLFSSL_DTLS13 */
  877. #endif /* WOLFSSL_DTLS */
  878. #if defined(WOLFSSL_TLS13) && defined(HAVE_ECH)
  879. WOLFSSL_API int wolfSSL_CTX_GenerateEchConfig(WOLFSSL_CTX* ctx,
  880. const char* publicName, word16 kemId, word16 kdfId, word16 aeadId);
  881. WOLFSSL_API int wolfSSL_CTX_GetEchConfigs(WOLFSSL_CTX* ctx, byte* output,
  882. word32* outputLen);
  883. WOLFSSL_API void wolfSSL_CTX_SetEchEnable(WOLFSSL_CTX* ctx, byte enable);
  884. WOLFSSL_API int wolfSSL_SetEchConfigsBase64(WOLFSSL* ssl, char* echConfigs64,
  885. word32 echConfigs64Len);
  886. WOLFSSL_API int wolfSSL_SetEchConfigs(WOLFSSL* ssl, const byte* echConfigs,
  887. word32 echConfigsLen);
  888. WOLFSSL_API int wolfSSL_GetEchConfigs(WOLFSSL* ssl, byte* echConfigs,
  889. word32* echConfigsLen);
  890. WOLFSSL_API void wolfSSL_SetEchEnable(WOLFSSL* ssl, byte enable);
  891. #endif /* WOLFSSL_TLS13 && HAVE_ECH */
  892. #ifdef HAVE_POLY1305
  893. WOLFSSL_API int wolfSSL_use_old_poly(WOLFSSL* ssl, int value);
  894. #endif
  895. #ifdef WOLFSSL_SESSION_EXPORT
  896. WOLFSSL_API int wolfSSL_tls_import(WOLFSSL* ssl, const unsigned char* buf,
  897. unsigned int sz);
  898. WOLFSSL_API int wolfSSL_tls_export(WOLFSSL* ssl, unsigned char* buf,
  899. unsigned int* sz);
  900. #ifdef WOLFSSL_DTLS
  901. #ifndef WOLFSSL_DTLS_EXPORT_TYPES
  902. typedef int (*wc_dtls_export)(WOLFSSL* ssl,
  903. unsigned char* exportBuffer, unsigned int sz, void* userCtx);
  904. #define WOLFSSL_DTLS_EXPORT_TYPES
  905. #endif /* WOLFSSL_DTLS_EXPORT_TYPES */
  906. WOLFSSL_API int wolfSSL_dtls_import(WOLFSSL* ssl, const unsigned char* buf,
  907. unsigned int sz);
  908. WOLFSSL_API int wolfSSL_CTX_dtls_set_export(WOLFSSL_CTX* ctx,
  909. wc_dtls_export func);
  910. WOLFSSL_API int wolfSSL_dtls_set_export(WOLFSSL* ssl, wc_dtls_export func);
  911. WOLFSSL_API int wolfSSL_dtls_export(WOLFSSL* ssl, unsigned char* buf,
  912. unsigned int* sz);
  913. WOLFSSL_API int wolfSSL_dtls_export_state_only(WOLFSSL* ssl, unsigned char* buf,
  914. unsigned int* sz);
  915. #endif /* WOLFSSL_DTLS */
  916. #endif /* WOLFSSL_SESSION_EXPORT */
  917. #ifdef WOLFSSL_STATIC_MEMORY
  918. #ifndef WOLFSSL_MEM_GUARD
  919. #define WOLFSSL_MEM_GUARD
  920. typedef struct WOLFSSL_MEM_STATS WOLFSSL_MEM_STATS;
  921. typedef struct WOLFSSL_MEM_CONN_STATS WOLFSSL_MEM_CONN_STATS;
  922. #endif
  923. WOLFSSL_API int wolfSSL_CTX_load_static_memory(WOLFSSL_CTX** ctx,
  924. wolfSSL_method_func method,
  925. unsigned char* buf, unsigned int sz,
  926. int flag, int max);
  927. WOLFSSL_API int wolfSSL_CTX_is_static_memory(WOLFSSL_CTX* ctx,
  928. WOLFSSL_MEM_STATS* mem_stats);
  929. WOLFSSL_API int wolfSSL_is_static_memory(WOLFSSL* ssl,
  930. WOLFSSL_MEM_CONN_STATS* mem_stats);
  931. #endif
  932. #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
  933. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_use_certificate_file(
  934. WOLFSSL_CTX* ctx, const char* file, int format);
  935. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_file(
  936. WOLFSSL_CTX* ctx, const char* file, int format);
  937. #ifdef WOLFSSL_DUAL_ALG_CERTS
  938. WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_file(
  939. WOLFSSL_CTX* ctx, const char* file, int format);
  940. #endif /* WOLFSSL_DUAL_ALG_CERTS */
  941. #endif /* !NO_FILESYSTEM && !NO_CERTS */
  942. #ifndef NO_CERTS
  943. #define WOLFSSL_LOAD_FLAG_NONE 0x00000000
  944. #define WOLFSSL_LOAD_FLAG_IGNORE_ERR 0x00000001
  945. #define WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY 0x00000002
  946. #define WOLFSSL_LOAD_FLAG_PEM_CA_ONLY 0x00000004
  947. #if defined(WOLFSSL_QT) || defined(WOLFSSL_IGNORE_BAD_CERT_PATH)
  948. #define WOLFSSL_LOAD_FLAG_IGNORE_BAD_PATH_ERR 0x00000008
  949. #endif
  950. #if defined(WOLFSSL_QT)
  951. #define WOLFSSL_LOAD_FLAG_IGNORE_ZEROFILE 0x00000010
  952. #endif
  953. #ifndef WOLFSSL_LOAD_VERIFY_DEFAULT_FLAGS
  954. #define WOLFSSL_LOAD_VERIFY_DEFAULT_FLAGS WOLFSSL_LOAD_FLAG_NONE
  955. #endif
  956. WOLFSSL_API long wolfSSL_get_verify_depth(WOLFSSL* ssl);
  957. WOLFSSL_API long wolfSSL_CTX_get_verify_depth(WOLFSSL_CTX* ctx);
  958. WOLFSSL_API void wolfSSL_CTX_set_verify_depth(WOLFSSL_CTX *ctx,int depth);
  959. #endif /* !NO_CERTS */
  960. #define WOLFSSL_CIPHER_SUITE_FLAG_NONE 0x0
  961. #define WOLFSSL_CIPHER_SUITE_FLAG_NAMEALIAS 0x1
  962. #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
  963. WOLFSSL_API int wolfSSL_CTX_load_verify_locations_ex(
  964. WOLFSSL_CTX* ctx, const char* file, const char* path, word32 flags);
  965. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_load_verify_locations(
  966. WOLFSSL_CTX* ctx, const char* file, const char* path);
  967. WOLFSSL_API int wolfSSL_CTX_load_verify_locations_compat(
  968. WOLFSSL_CTX* ctx, const char* file, const char* path);
  969. #ifndef _WIN32
  970. WOLFSSL_API const char** wolfSSL_get_system_CA_dirs(word32* num);
  971. #endif /* !_WIN32 */
  972. WOLFSSL_API int wolfSSL_CTX_load_system_CA_certs(WOLFSSL_CTX* ctx);
  973. #ifdef WOLFSSL_TRUST_PEER_CERT
  974. WOLFSSL_API int wolfSSL_CTX_trust_peer_cert(
  975. WOLFSSL_CTX* ctx, const char* file, int type);
  976. WOLFSSL_API int wolfSSL_trust_peer_cert(
  977. WOLFSSL* ssl, const char* file, int type);
  978. #endif
  979. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_file(
  980. WOLFSSL_CTX* ctx, const char* file);
  981. WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_file_format(
  982. WOLFSSL_CTX* ctx, const char* file, int format);
  983. WOLFSSL_API int wolfSSL_CTX_use_RSAPrivateKey_file(
  984. WOLFSSL_CTX* ctx,const char* file, int format);
  985. WOLFSSL_ABI WOLFSSL_API int wolfSSL_use_certificate_file(
  986. WOLFSSL* ssl, const char* file, int format);
  987. WOLFSSL_ABI WOLFSSL_API int wolfSSL_use_PrivateKey_file(
  988. WOLFSSL* ssl, const char* file, int format);
  989. WOLFSSL_ABI WOLFSSL_API int wolfSSL_use_certificate_chain_file(
  990. WOLFSSL* ssl, const char* file);
  991. WOLFSSL_API int wolfSSL_use_certificate_chain_file_format(
  992. WOLFSSL* ssl, const char* file, int format);
  993. WOLFSSL_API int wolfSSL_use_RSAPrivateKey_file(
  994. WOLFSSL* ssl, const char* file, int format);
  995. #ifdef WOLFSSL_DER_LOAD
  996. WOLFSSL_API int wolfSSL_CTX_der_load_verify_locations(
  997. WOLFSSL_CTX* ctx, const char* file, int format);
  998. #endif
  999. #endif /* !NO_FILESYSTEM && !NO_CERTS */
  1000. WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new_ex(WOLFSSL_METHOD* method, void* heap);
  1001. WOLFSSL_ABI WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD* method);
  1002. WOLFSSL_API int wolfSSL_CTX_up_ref(WOLFSSL_CTX* ctx);
  1003. #ifdef OPENSSL_EXTRA
  1004. WOLFSSL_API int wolfSSL_set_ecdh_auto(WOLFSSL* ssl, int onoff);
  1005. WOLFSSL_API int wolfSSL_CTX_set_ecdh_auto(WOLFSSL_CTX* ctx, int onoff);
  1006. WOLFSSL_API int wolfSSL_CTX_set_dh_auto(WOLFSSL_CTX* ctx, int onoff);
  1007. WOLFSSL_API int wolfSSL_get_signature_nid(WOLFSSL* ssl, int* nid);
  1008. WOLFSSL_API int wolfSSL_get_signature_type_nid(const WOLFSSL* ssl, int* nid);
  1009. WOLFSSL_API int wolfSSL_get_peer_signature_nid(WOLFSSL* ssl, int* nid);
  1010. WOLFSSL_API int wolfSSL_get_peer_signature_type_nid(const WOLFSSL* ssl,
  1011. int* nid);
  1012. WOLFSSL_API int wolfSSL_CTX_set1_sigalgs_list(WOLFSSL_CTX* ctx,
  1013. const char* list);
  1014. WOLFSSL_API int wolfSSL_set1_sigalgs_list(WOLFSSL* ssl, const char* list);
  1015. #endif
  1016. WOLFSSL_ABI WOLFSSL_API WOLFSSL* wolfSSL_new(WOLFSSL_CTX* ctx);
  1017. WOLFSSL_API WOLFSSL_CTX* wolfSSL_get_SSL_CTX(const WOLFSSL* ssl);
  1018. WOLFSSL_API WOLFSSL_X509_VERIFY_PARAM* wolfSSL_CTX_get0_param(WOLFSSL_CTX* ctx);
  1019. WOLFSSL_API WOLFSSL_X509_VERIFY_PARAM* wolfSSL_get0_param(WOLFSSL* ssl);
  1020. WOLFSSL_API int wolfSSL_CTX_set1_param(WOLFSSL_CTX* ctx, WOLFSSL_X509_VERIFY_PARAM *vpm);
  1021. WOLFSSL_API int wolfSSL_is_server(WOLFSSL* ssl);
  1022. WOLFSSL_API WOLFSSL* wolfSSL_write_dup(WOLFSSL* ssl);
  1023. WOLFSSL_ABI WOLFSSL_API int wolfSSL_set_fd(WOLFSSL* ssl, int fd);
  1024. #ifdef WOLFSSL_DTLS
  1025. WOLFSSL_API int wolfSSL_set_dtls_fd_connected(WOLFSSL* ssl, int fd);
  1026. #endif
  1027. WOLFSSL_API int wolfSSL_set_write_fd (WOLFSSL* ssl, int fd);
  1028. WOLFSSL_API int wolfSSL_set_read_fd (WOLFSSL* ssl, int fd);
  1029. WOLFSSL_API char* wolfSSL_get_cipher_list(int priority);
  1030. WOLFSSL_API char* wolfSSL_get_cipher_list_ex(WOLFSSL* ssl, int priority);
  1031. WOLFSSL_API int wolfSSL_get_ciphers(char* buf, int len);
  1032. WOLFSSL_API int wolfSSL_get_ciphers_iana(char* buf, int len);
  1033. WOLFSSL_API const char* wolfSSL_get_cipher_name(WOLFSSL* ssl);
  1034. WOLFSSL_API const char* wolfSSL_get_cipher_name_from_suite(
  1035. unsigned char cipherSuite0, unsigned char cipherSuite);
  1036. WOLFSSL_API const char* wolfSSL_get_cipher_name_iana_from_suite(
  1037. unsigned char cipherSuite0, unsigned char cipherSuite);
  1038. WOLFSSL_API int wolfSSL_get_cipher_suite_from_name(const char* name,
  1039. unsigned char* cipherSuite0, unsigned char* cipherSuite, int *flags);
  1040. WOLFSSL_API const char* wolfSSL_get_shared_ciphers(WOLFSSL* ssl, char* buf,
  1041. int len);
  1042. WOLFSSL_API const char* wolfSSL_get_curve_name(WOLFSSL* ssl);
  1043. WOLFSSL_API int wolfSSL_get_fd(const WOLFSSL* ssl);
  1044. /* please see note at top of README if you get an error from connect */
  1045. WOLFSSL_ABI WOLFSSL_API int wolfSSL_connect(WOLFSSL* ssl);
  1046. WOLFSSL_ABI WOLFSSL_API int wolfSSL_write(
  1047. WOLFSSL* ssl, const void* data, int sz);
  1048. WOLFSSL_ABI WOLFSSL_API int wolfSSL_read(WOLFSSL* ssl, void* data, int sz);
  1049. WOLFSSL_API int wolfSSL_peek(WOLFSSL* ssl, void* data, int sz);
  1050. WOLFSSL_ABI WOLFSSL_API int wolfSSL_accept(WOLFSSL* ssl);
  1051. WOLFSSL_API int wolfSSL_CTX_mutual_auth(WOLFSSL_CTX* ctx, int req);
  1052. WOLFSSL_API int wolfSSL_mutual_auth(WOLFSSL* ssl, int req);
  1053. WOLFSSL_API int wolfSSL_CTX_set_groups(WOLFSSL_CTX* ctx, int* groups,
  1054. int count);
  1055. WOLFSSL_API int wolfSSL_set_groups(WOLFSSL* ssl, int* groups, int count);
  1056. #if defined(OPENSSL_EXTRA) && defined(HAVE_SUPPORTED_CURVES)
  1057. WOLFSSL_API int wolfSSL_CTX_set1_groups(WOLFSSL_CTX* ctx, int* groups,
  1058. int count);
  1059. WOLFSSL_API int wolfSSL_set1_groups(WOLFSSL* ssl, int* groups, int count);
  1060. #ifdef HAVE_ECC
  1061. WOLFSSL_API int wolfSSL_CTX_set1_groups_list(WOLFSSL_CTX *ctx, const char *list);
  1062. WOLFSSL_API int wolfSSL_set1_groups_list(WOLFSSL *ssl, const char *list);
  1063. #endif
  1064. #endif
  1065. #ifdef WOLFSSL_TLS13
  1066. WOLFSSL_API int wolfSSL_send_hrr_cookie(WOLFSSL* ssl,
  1067. const unsigned char* secret, unsigned int secretSz);
  1068. WOLFSSL_API int wolfSSL_disable_hrr_cookie(WOLFSSL * ssl);
  1069. WOLFSSL_API int wolfSSL_CTX_no_ticket_TLSv13(WOLFSSL_CTX* ctx);
  1070. WOLFSSL_API int wolfSSL_no_ticket_TLSv13(WOLFSSL* ssl);
  1071. WOLFSSL_API int wolfSSL_CTX_no_dhe_psk(WOLFSSL_CTX* ctx);
  1072. WOLFSSL_API int wolfSSL_no_dhe_psk(WOLFSSL* ssl);
  1073. WOLFSSL_API int wolfSSL_CTX_only_dhe_psk(WOLFSSL_CTX* ctx);
  1074. WOLFSSL_API int wolfSSL_only_dhe_psk(WOLFSSL* ssl);
  1075. WOLFSSL_API int wolfSSL_update_keys(WOLFSSL* ssl);
  1076. WOLFSSL_API int wolfSSL_key_update_response(WOLFSSL* ssl, int* required);
  1077. WOLFSSL_API int wolfSSL_CTX_allow_post_handshake_auth(WOLFSSL_CTX* ctx);
  1078. WOLFSSL_API int wolfSSL_allow_post_handshake_auth(WOLFSSL* ssl);
  1079. WOLFSSL_API int wolfSSL_request_certificate(WOLFSSL* ssl);
  1080. WOLFSSL_API int wolfSSL_preferred_group(WOLFSSL* ssl);
  1081. WOLFSSL_API int wolfSSL_connect_TLSv13(WOLFSSL* ssl);
  1082. WOLFSSL_API int wolfSSL_accept_TLSv13(WOLFSSL* ssl);
  1083. #ifdef WOLFSSL_EARLY_DATA
  1084. #define WOLFSSL_EARLY_DATA_NOT_SENT 0
  1085. #define WOLFSSL_EARLY_DATA_REJECTED 1
  1086. #define WOLFSSL_EARLY_DATA_ACCEPTED 2
  1087. WOLFSSL_API int wolfSSL_CTX_set_max_early_data(WOLFSSL_CTX* ctx,
  1088. unsigned int sz);
  1089. WOLFSSL_API int wolfSSL_set_max_early_data(WOLFSSL* ssl, unsigned int sz);
  1090. WOLFSSL_API int wolfSSL_CTX_get_max_early_data(WOLFSSL_CTX* ctx);
  1091. WOLFSSL_API int wolfSSL_get_max_early_data(WOLFSSL* ssl);
  1092. WOLFSSL_API int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data,
  1093. int sz, int* outSz);
  1094. WOLFSSL_API int wolfSSL_read_early_data(WOLFSSL* ssl, void* data, int sz,
  1095. int* outSz);
  1096. WOLFSSL_API int wolfSSL_get_early_data_status(const WOLFSSL* ssl);
  1097. #ifdef OPENSSL_EXTRA
  1098. WOLFSSL_API unsigned int wolfSSL_SESSION_get_max_early_data(const WOLFSSL_SESSION *s);
  1099. #endif /* OPENSSL_EXTRA */
  1100. #endif /* WOLFSSL_EARLY_DATA */
  1101. #endif /* WOLFSSL_TLS13 */
  1102. WOLFSSL_ABI WOLFSSL_API void wolfSSL_CTX_free(WOLFSSL_CTX* ctx);
  1103. WOLFSSL_ABI WOLFSSL_API void wolfSSL_free(WOLFSSL* ssl);
  1104. WOLFSSL_ABI WOLFSSL_API int wolfSSL_shutdown(WOLFSSL* ssl);
  1105. WOLFSSL_API int wolfSSL_SendUserCanceled(WOLFSSL* ssl);
  1106. WOLFSSL_API int wolfSSL_send(WOLFSSL* ssl, const void* data, int sz, int flags);
  1107. WOLFSSL_API int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags);
  1108. WOLFSSL_API void wolfSSL_CTX_set_quiet_shutdown(WOLFSSL_CTX* ctx, int mode);
  1109. WOLFSSL_API void wolfSSL_set_quiet_shutdown(WOLFSSL* ssl, int mode);
  1110. WOLFSSL_ABI WOLFSSL_API int wolfSSL_get_error(WOLFSSL* ssl, int ret);
  1111. WOLFSSL_API int wolfSSL_get_alert_history(WOLFSSL* ssl, WOLFSSL_ALERT_HISTORY *h);
  1112. WOLFSSL_ABI WOLFSSL_API int wolfSSL_set_session(WOLFSSL* ssl, WOLFSSL_SESSION* session);
  1113. WOLFSSL_API long wolfSSL_SSL_SESSION_set_timeout(WOLFSSL_SESSION* ses, long t);
  1114. WOLFSSL_API long wolfSSL_SESSION_set_time(WOLFSSL_SESSION *ses, long t);
  1115. WOLFSSL_ABI WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get_session(WOLFSSL* ssl);
  1116. WOLFSSL_ABI WOLFSSL_API void wolfSSL_flush_sessions(WOLFSSL_CTX* ctx, long tm);
  1117. WOLFSSL_API void wolfSSL_CTX_flush_sessions(WOLFSSL_CTX* ctx, long tm);
  1118. WOLFSSL_API int wolfSSL_SetServerID(WOLFSSL* ssl, const unsigned char* id, int len, int newSession);
  1119. #if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO) || defined(WOLFSSL_HAPROXY) \
  1120. || defined(WOLFSSL_NGINX)
  1121. WOLFSSL_API int wolfSSL_BIO_new_bio_pair(WOLFSSL_BIO** bio1_p, size_t writebuf1,
  1122. WOLFSSL_BIO** bio2_p, size_t writebuf2);
  1123. WOLFSSL_API int wolfSSL_RSA_padding_add_PKCS1_PSS_mgf1(WOLFSSL_RSA *rsa,
  1124. unsigned char *em, const unsigned char *mHash,
  1125. const WOLFSSL_EVP_MD *hashAlg, const WOLFSSL_EVP_MD *mgf1Hash,
  1126. int saltLen);
  1127. WOLFSSL_API int wolfSSL_RSA_padding_add_PKCS1_PSS(WOLFSSL_RSA *rsa,
  1128. unsigned char *EM,
  1129. const unsigned char *mHash,
  1130. const WOLFSSL_EVP_MD *hashAlg,
  1131. int saltLen);
  1132. WOLFSSL_API int wolfSSL_RSA_verify_PKCS1_PSS_mgf1(WOLFSSL_RSA *rsa,
  1133. const unsigned char *mHash, const WOLFSSL_EVP_MD *hashAlg,
  1134. const WOLFSSL_EVP_MD *mgf1Hash, const unsigned char *em, int saltLen);
  1135. WOLFSSL_API int wolfSSL_RSA_verify_PKCS1_PSS(WOLFSSL_RSA *rsa, const unsigned char *mHash,
  1136. const WOLFSSL_EVP_MD *hashAlg,
  1137. const unsigned char *EM, int saltLen);
  1138. WOLFSSL_API WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO* bio, WOLFSSL_RSA** out);
  1139. WOLFSSL_API int wolfSSL_CTX_use_certificate_ASN1(WOLFSSL_CTX* ctx,
  1140. int derSz, const unsigned char* der);
  1141. WOLFSSL_API int wolfSSL_CTX_use_RSAPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL_RSA* rsa);
  1142. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_bio(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY** pkey);
  1143. #endif /* OPENSSL_ALL || WOLFSSL_ASIO */
  1144. #ifdef SESSION_INDEX
  1145. WOLFSSL_API int wolfSSL_GetSessionIndex(WOLFSSL* ssl);
  1146. WOLFSSL_API int wolfSSL_GetSessionAtIndex(int index, WOLFSSL_SESSION* session);
  1147. #endif /* SESSION_INDEX */
  1148. #if defined(SESSION_CERTS)
  1149. WOLFSSL_API
  1150. WOLFSSL_X509_CHAIN* wolfSSL_SESSION_get_peer_chain(WOLFSSL_SESSION* session);
  1151. WOLFSSL_API WOLFSSL_X509* wolfSSL_SESSION_get0_peer(WOLFSSL_SESSION* session);
  1152. #endif /* SESSION_INDEX && SESSION_CERTS */
  1153. typedef int (*VerifyCallback)(int, WOLFSSL_X509_STORE_CTX*);
  1154. typedef void (CallbackInfoState)(const WOLFSSL* ssl, int, int);
  1155. /* class index for wolfSSL_CRYPTO_get_ex_new_index */
  1156. #define WOLF_CRYPTO_EX_INDEX_SSL 0
  1157. #define WOLF_CRYPTO_EX_INDEX_SSL_CTX 1
  1158. #define WOLF_CRYPTO_EX_INDEX_SSL_SESSION 2
  1159. #define WOLF_CRYPTO_EX_INDEX_X509 3
  1160. #define WOLF_CRYPTO_EX_INDEX_X509_STORE 4
  1161. #define WOLF_CRYPTO_EX_INDEX_X509_STORE_CTX 5
  1162. #define WOLF_CRYPTO_EX_INDEX_DH 6
  1163. #define WOLF_CRYPTO_EX_INDEX_DSA 7
  1164. #define WOLF_CRYPTO_EX_INDEX_EC_KEY 8
  1165. #define WOLF_CRYPTO_EX_INDEX_RSA 9
  1166. #define WOLF_CRYPTO_EX_INDEX_ENGINE 10
  1167. #define WOLF_CRYPTO_EX_INDEX_UI 11
  1168. #define WOLF_CRYPTO_EX_INDEX_BIO 12
  1169. #define WOLF_CRYPTO_EX_INDEX_APP 13
  1170. #define WOLF_CRYPTO_EX_INDEX_UI_METHOD 14
  1171. #define WOLF_CRYPTO_EX_INDEX_DRBG 15
  1172. #define WOLF_CRYPTO_EX_INDEX__COUNT 16
  1173. #ifdef HAVE_EX_DATA
  1174. /* Helper macro to log that input arguments should not be used */
  1175. #define WOLFSSL_CRYPTO_EX_DATA_IGNORE_PARAMS(a1, a2, a3, a4, a5) \
  1176. (void)(a1); \
  1177. (void)(a2); \
  1178. (void)(a3); \
  1179. (void)(a4); \
  1180. (void)(a5); \
  1181. do { \
  1182. if ((a3) != NULL || (a4) != NULL || (a5) != NULL) { \
  1183. WOLFSSL_MSG("get_ex_new_index API does not support " \
  1184. "new, dup, or free callbacks"); \
  1185. } \
  1186. } while(0)
  1187. WOLFSSL_API int wolfSSL_get_ex_new_index(long argValue, void* arg,
  1188. WOLFSSL_CRYPTO_EX_new* a, WOLFSSL_CRYPTO_EX_dup* b,
  1189. WOLFSSL_CRYPTO_EX_free* c);
  1190. #endif
  1191. WOLFSSL_ABI WOLFSSL_API void wolfSSL_CTX_set_verify(WOLFSSL_CTX* ctx, int mode,
  1192. VerifyCallback verify_callback);
  1193. #ifdef OPENSSL_ALL
  1194. typedef int (*CertVerifyCallback)(WOLFSSL_X509_STORE_CTX* store, void* arg);
  1195. WOLFSSL_API void wolfSSL_CTX_set_cert_verify_callback(WOLFSSL_CTX* ctx,
  1196. CertVerifyCallback cb, void* arg);
  1197. #endif
  1198. WOLFSSL_API void wolfSSL_set_verify(WOLFSSL* ssl, int mode, VerifyCallback verify_callback);
  1199. WOLFSSL_API void wolfSSL_set_verify_result(WOLFSSL* ssl, long v);
  1200. #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \
  1201. defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH)
  1202. WOLFSSL_API int wolfSSL_verify_client_post_handshake(WOLFSSL* ssl);
  1203. WOLFSSL_API int wolfSSL_CTX_set_post_handshake_auth(WOLFSSL_CTX* ctx, int val);
  1204. WOLFSSL_API int wolfSSL_set_post_handshake_auth(WOLFSSL* ssl, int val);
  1205. #endif
  1206. WOLFSSL_API void wolfSSL_SetCertCbCtx(WOLFSSL* ssl, void* ctx);
  1207. WOLFSSL_API void wolfSSL_CTX_SetCertCbCtx(WOLFSSL_CTX* ctx, void* userCtx);
  1208. WOLFSSL_ABI WOLFSSL_API int wolfSSL_pending(WOLFSSL* ssl);
  1209. WOLFSSL_API int wolfSSL_has_pending(const WOLFSSL* ssl);
  1210. WOLFSSL_API void wolfSSL_load_error_strings(void);
  1211. WOLFSSL_API int wolfSSL_library_init(void);
  1212. WOLFSSL_ABI WOLFSSL_API long wolfSSL_CTX_set_session_cache_mode(WOLFSSL_CTX* ctx,
  1213. long mode);
  1214. #ifdef HAVE_SECRET_CALLBACK
  1215. typedef int (*SessionSecretCb)(WOLFSSL* ssl, void* secret, int* secretSz,
  1216. void* ctx);
  1217. /* This callback is used to set the master secret during resumption */
  1218. WOLFSSL_API int wolfSSL_set_session_secret_cb(WOLFSSL* ssl, SessionSecretCb cb,
  1219. void* ctx);
  1220. typedef int (*TicketParseCb)(WOLFSSL *ssl, const unsigned char *data,
  1221. int len, void *ctx);
  1222. WOLFSSL_API int wolfSSL_set_session_ticket_ext_cb(WOLFSSL* ssl,
  1223. TicketParseCb cb, void *ctx);
  1224. typedef int (*TlsSecretCb)(WOLFSSL* ssl, void* secret, int secretSz,
  1225. void* ctx);
  1226. /* This callback is used to log the secret for TLS <= 1.2 */
  1227. WOLFSSL_API int wolfSSL_set_secret_cb(WOLFSSL* ssl, TlsSecretCb cb, void* ctx);
  1228. #ifdef WOLFSSL_TLS13
  1229. typedef int (*Tls13SecretCb)(WOLFSSL* ssl, int id, const unsigned char* secret,
  1230. int secretSz, void* ctx);
  1231. WOLFSSL_API int wolfSSL_set_tls13_secret_cb(WOLFSSL* ssl, Tls13SecretCb, void*);
  1232. #endif
  1233. #endif /* HAVE_SECRET_CALLBACK */
  1234. /* session cache persistence */
  1235. WOLFSSL_API int wolfSSL_save_session_cache(const char* fname);
  1236. WOLFSSL_API int wolfSSL_restore_session_cache(const char* fname);
  1237. WOLFSSL_API int wolfSSL_memsave_session_cache(void* mem, int sz);
  1238. WOLFSSL_API int wolfSSL_memrestore_session_cache(const void* mem, int sz);
  1239. WOLFSSL_API int wolfSSL_get_session_cache_memsize(void);
  1240. /* certificate cache persistence, uses ctx since certs are per ctx */
  1241. WOLFSSL_API int wolfSSL_CTX_save_cert_cache(WOLFSSL_CTX* ctx, const char* fname);
  1242. WOLFSSL_API int wolfSSL_CTX_restore_cert_cache(WOLFSSL_CTX* ctx, const char* fname);
  1243. WOLFSSL_API int wolfSSL_CTX_memsave_cert_cache(WOLFSSL_CTX* ctx, void* mem, int sz, int* used);
  1244. WOLFSSL_API int wolfSSL_CTX_memrestore_cert_cache(WOLFSSL_CTX* ctx, const void* mem, int sz);
  1245. WOLFSSL_API int wolfSSL_CTX_get_cert_cache_memsize(WOLFSSL_CTX* ctx);
  1246. /* only supports full name from cipher_name[] delimited by : */
  1247. WOLFSSL_API int wolfSSL_CTX_set_cipher_list(WOLFSSL_CTX* ctx, const char* list);
  1248. WOLFSSL_API int wolfSSL_set_cipher_list(WOLFSSL* ssl, const char* list);
  1249. /* supports 2 byte code from cipher_name[] */
  1250. WOLFSSL_API int wolfSSL_CTX_set_cipher_list_bytes(WOLFSSL_CTX* ctx, const byte* list, const int listSz);
  1251. WOLFSSL_API int wolfSSL_set_cipher_list_bytes(WOLFSSL* ssl, const byte* list, const int listSz);
  1252. #ifdef HAVE_KEYING_MATERIAL
  1253. /* Keying Material Exporter for TLS */
  1254. WOLFSSL_API int wolfSSL_export_keying_material(WOLFSSL *ssl,
  1255. unsigned char *out, size_t outLen,
  1256. const char *label, size_t labelLen,
  1257. const unsigned char *context, size_t contextLen,
  1258. int use_context);
  1259. #endif /* HAVE_KEYING_MATERIAL */
  1260. #ifdef WOLFSSL_WOLFSENTRY_HOOKS
  1261. typedef enum {
  1262. WOLFSSL_NETFILTER_PASS = 0,
  1263. WOLFSSL_NETFILTER_ACCEPT = 1,
  1264. WOLFSSL_NETFILTER_REJECT = 2
  1265. } wolfSSL_netfilter_decision_t;
  1266. typedef int (*NetworkFilterCallback_t)(
  1267. WOLFSSL *ssl,
  1268. void *AcceptFilter_arg,
  1269. wolfSSL_netfilter_decision_t *decision);
  1270. WOLFSSL_API int wolfSSL_CTX_set_AcceptFilter(
  1271. WOLFSSL_CTX *ctx,
  1272. NetworkFilterCallback_t AcceptFilter,
  1273. void *AcceptFilter_arg);
  1274. WOLFSSL_API int wolfSSL_set_AcceptFilter(
  1275. WOLFSSL *ssl,
  1276. NetworkFilterCallback_t AcceptFilter,
  1277. void *AcceptFilter_arg);
  1278. WOLFSSL_API int wolfSSL_CTX_set_ConnectFilter(
  1279. WOLFSSL_CTX *ctx,
  1280. NetworkFilterCallback_t ConnectFilter,
  1281. void *ConnectFilter_arg);
  1282. WOLFSSL_API int wolfSSL_set_ConnectFilter(
  1283. WOLFSSL *ssl,
  1284. NetworkFilterCallback_t ConnectFilter,
  1285. void *ConnectFilter_arg);
  1286. #endif /* WOLFSSL_WOLFSENTRY_HOOKS */
  1287. /* Nonblocking DTLS helper functions */
  1288. WOLFSSL_API void wolfSSL_dtls_set_using_nonblock(WOLFSSL* ssl, int nonblock);
  1289. WOLFSSL_API int wolfSSL_dtls_get_using_nonblock(WOLFSSL* ssl);
  1290. #define wolfSSL_set_using_nonblock wolfSSL_dtls_set_using_nonblock
  1291. #define wolfSSL_get_using_nonblock wolfSSL_dtls_get_using_nonblock
  1292. /* The old names are deprecated. */
  1293. WOLFSSL_API int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl);
  1294. WOLFSSL_API int wolfSSL_dtls13_use_quick_timeout(WOLFSSL* ssl);
  1295. WOLFSSL_API void wolfSSL_dtls13_set_send_more_acks(WOLFSSL* ssl, int value);
  1296. WOLFSSL_API int wolfSSL_DTLSv1_get_timeout(WOLFSSL* ssl,
  1297. WOLFSSL_TIMEVAL* timeleft);
  1298. WOLFSSL_API void wolfSSL_DTLSv1_set_initial_timeout_duration(WOLFSSL* ssl,
  1299. word32 duration_ms);
  1300. WOLFSSL_API int wolfSSL_DTLSv1_handle_timeout(WOLFSSL* ssl);
  1301. WOLFSSL_API int wolfSSL_dtls_set_timeout_init(WOLFSSL* ssl, int timeout);
  1302. WOLFSSL_API int wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int timeout);
  1303. WOLFSSL_API int wolfSSL_dtls_got_timeout(WOLFSSL* ssl);
  1304. WOLFSSL_API int wolfSSL_dtls_retransmit(WOLFSSL* ssl);
  1305. WOLFSSL_API int wolfSSL_dtls(WOLFSSL* ssl);
  1306. WOLFSSL_API void* wolfSSL_dtls_create_peer(int port, char* ip);
  1307. WOLFSSL_API int wolfSSL_dtls_free_peer(void* addr);
  1308. WOLFSSL_API int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz);
  1309. WOLFSSL_API int wolfSSL_dtls_get_peer(WOLFSSL* ssl, void* peer, unsigned int* peerSz);
  1310. #if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS)
  1311. WOLFSSL_API int wolfSSL_CTX_dtls_set_sctp(WOLFSSL_CTX* ctx);
  1312. WOLFSSL_API int wolfSSL_dtls_set_sctp(WOLFSSL* ssl);
  1313. #endif
  1314. #if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
  1315. defined(WOLFSSL_DTLS)
  1316. WOLFSSL_API int wolfSSL_CTX_dtls_set_mtu(WOLFSSL_CTX* ctx, unsigned short mtu);
  1317. WOLFSSL_API int wolfSSL_dtls_set_mtu(WOLFSSL* ssl, unsigned short mtu);
  1318. #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)
  1319. WOLFSSL_API int wolfSSL_set_mtu_compat(WOLFSSL* ssl, unsigned short mtu);
  1320. #endif
  1321. #endif
  1322. #ifdef WOLFSSL_SRTP
  1323. /* SRTP Profile ID's from RFC 5764 and RFC 7714 */
  1324. /* For WebRTC support for profile SRTP_AES128_CM_SHA1_80 is required per
  1325. * draft-ietf-rtcweb-security-arch) */
  1326. #define SRTP_AES128_CM_SHA1_80 0x0001
  1327. #define SRTP_AES128_CM_SHA1_32 0x0002
  1328. #define SRTP_AES128_F8_SHA1_80 0x0003 /* not supported */
  1329. #define SRTP_AES128_F8_SHA1_32 0x0004 /* not supported */
  1330. #define SRTP_NULL_SHA1_80 0x0005
  1331. #define SRTP_NULL_SHA1_32 0x0006
  1332. #define SRTP_AEAD_AES_128_GCM 0x0007
  1333. #define SRTP_AEAD_AES_256_GCM 0x0008
  1334. typedef struct WOLFSSL_SRTP_PROTECTION_PROFILE {
  1335. const char* name;
  1336. unsigned long id;
  1337. int kdfBits;
  1338. } WOLFSSL_SRTP_PROTECTION_PROFILE;
  1339. /* Compatibility API's for SRTP */
  1340. WOLFSSL_API int wolfSSL_CTX_set_tlsext_use_srtp(WOLFSSL_CTX* ctx,
  1341. const char* profile_str);
  1342. WOLFSSL_API int wolfSSL_set_tlsext_use_srtp(WOLFSSL* ssl,
  1343. const char* wolfSSL_set_tlsext_use_srtp);
  1344. WOLFSSL_API const WOLFSSL_SRTP_PROTECTION_PROFILE*
  1345. wolfSSL_get_selected_srtp_profile(WOLFSSL* ssl);
  1346. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_SRTP_PROTECTION_PROFILE)*
  1347. wolfSSL_get_srtp_profiles(WOLFSSL* ssl);
  1348. /* Non standard API for getting the SRTP session keys using KDF */
  1349. WOLFSSL_API int wolfSSL_export_dtls_srtp_keying_material(WOLFSSL* ssl,
  1350. unsigned char* out, size_t* olen);
  1351. #endif /* WOLFSSL_SRTP */
  1352. WOLFSSL_API int wolfSSL_dtls_get_drop_stats(WOLFSSL* ssl,
  1353. unsigned int*, unsigned int*);
  1354. WOLFSSL_API int wolfSSL_CTX_mcast_set_member_id(WOLFSSL_CTX* ctx, unsigned short id);
  1355. WOLFSSL_API int wolfSSL_set_secret(WOLFSSL* ssl, unsigned short epoch,
  1356. const unsigned char* preMasterSecret, unsigned int preMasterSz,
  1357. const unsigned char* clientRandom, const unsigned char* serverRandom,
  1358. const unsigned char* suite);
  1359. WOLFSSL_API int wolfSSL_mcast_read(WOLFSSL* ssl, unsigned short* id, void* data, int sz);
  1360. WOLFSSL_API int wolfSSL_mcast_peer_add(WOLFSSL* ssl, unsigned short peerId, int sub);
  1361. WOLFSSL_API int wolfSSL_mcast_peer_known(WOLFSSL* ssl, unsigned short peerId);
  1362. WOLFSSL_API int wolfSSL_mcast_get_max_peers(void);
  1363. typedef int (*CallbackMcastHighwater)(unsigned short peerId,
  1364. unsigned int maxSeq,
  1365. unsigned int curSeq, void* ctx);
  1366. WOLFSSL_API int wolfSSL_CTX_mcast_set_highwater_cb(WOLFSSL_CTX* ctx,
  1367. unsigned int maxSeq,
  1368. unsigned int first,
  1369. unsigned int second,
  1370. CallbackMcastHighwater cb);
  1371. WOLFSSL_API int wolfSSL_mcast_set_highwater_ctx(WOLFSSL* ssl, void* ctx);
  1372. WOLFSSL_API int wolfSSL_ERR_GET_LIB(unsigned long err);
  1373. WOLFSSL_API int wolfSSL_ERR_GET_REASON(unsigned long err);
  1374. WOLFSSL_API char* wolfSSL_ERR_error_string(unsigned long errNumber,char* data);
  1375. WOLFSSL_API void wolfSSL_ERR_error_string_n(unsigned long e, char* buf,
  1376. unsigned long sz);
  1377. WOLFSSL_API const char* wolfSSL_ERR_reason_error_string(unsigned long e);
  1378. WOLFSSL_API const char* wolfSSL_ERR_func_error_string(unsigned long e);
  1379. WOLFSSL_API const char* wolfSSL_ERR_lib_error_string(unsigned long e);
  1380. /* extras */
  1381. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_new_node(void* heap);
  1382. WOLFSSL_API void wolfSSL_sk_free(WOLFSSL_STACK* sk);
  1383. WOLFSSL_API void wolfSSL_sk_free_node(WOLFSSL_STACK* in);
  1384. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_dup(WOLFSSL_STACK* sk);
  1385. WOLFSSL_API WOLFSSL_STACK* wolfSSL_shallow_sk_dup(WOLFSSL_STACK* sk);
  1386. WOLFSSL_API int wolfSSL_sk_push_node(WOLFSSL_STACK** stack, WOLFSSL_STACK* in);
  1387. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_get_node(WOLFSSL_STACK* sk, int idx);
  1388. WOLFSSL_API int wolfSSL_sk_push(WOLFSSL_STACK *st, const void *data);
  1389. WOLFSSL_API int wolfSSL_sk_insert(WOLFSSL_STACK *sk, const void *data, int idx);
  1390. #if defined(HAVE_OCSP) || defined(HAVE_CRL) || (defined(WOLFSSL_CUSTOM_OID) && \
  1391. defined(WOLFSSL_ASN_TEMPLATE) && defined(HAVE_OID_DECODING))
  1392. #include "wolfssl/wolfcrypt/asn.h"
  1393. #endif
  1394. #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) || defined(WOLFSSL_QT)
  1395. WOLFSSL_API int wolfSSL_sk_ACCESS_DESCRIPTION_push(
  1396. WOLF_STACK_OF(ACCESS_DESCRIPTION)* sk,
  1397. WOLFSSL_ACCESS_DESCRIPTION* a);
  1398. #endif /* defined(OPENSSL_ALL) || OPENSSL_EXTRA || defined(WOLFSSL_QT) */
  1399. typedef WOLF_STACK_OF(WOLFSSL_GENERAL_NAME) WOLFSSL_GENERAL_NAMES;
  1400. typedef WOLF_STACK_OF(WOLFSSL_DIST_POINT) WOLFSSL_DIST_POINTS;
  1401. WOLFSSL_API int wolfSSL_sk_X509_push(WOLF_STACK_OF(WOLFSSL_X509_NAME)* sk,
  1402. WOLFSSL_X509* x509);
  1403. WOLFSSL_API WOLFSSL_X509* wolfSSL_sk_X509_pop(WOLF_STACK_OF(WOLFSSL_X509)* sk);
  1404. WOLFSSL_API void wolfSSL_sk_X509_free(WOLF_STACK_OF(WOLFSSL_X509)* sk);
  1405. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_X509_CRL_new(void);
  1406. WOLFSSL_API void wolfSSL_sk_X509_CRL_pop_free(WOLF_STACK_OF(WOLFSSL_X509_CRL)* sk,
  1407. void (*f) (WOLFSSL_X509_CRL*));
  1408. WOLFSSL_API void wolfSSL_sk_X509_CRL_free(WOLF_STACK_OF(WOLFSSL_X509_CRL)* sk);
  1409. WOLFSSL_API int wolfSSL_sk_X509_CRL_push(WOLF_STACK_OF(WOLFSSL_X509_CRL)* sk,
  1410. WOLFSSL_X509_CRL* crl);
  1411. WOLFSSL_API WOLFSSL_X509_CRL* wolfSSL_sk_X509_CRL_value(
  1412. WOLF_STACK_OF(WOLFSSL_X509)* sk, int i);
  1413. WOLFSSL_API int wolfSSL_sk_X509_CRL_num(WOLF_STACK_OF(WOLFSSL_X509)* sk);
  1414. WOLFSSL_API WOLFSSL_GENERAL_NAME* wolfSSL_GENERAL_NAME_new(void);
  1415. WOLFSSL_API void wolfSSL_GENERAL_NAME_free(WOLFSSL_GENERAL_NAME* gn);
  1416. WOLFSSL_API WOLFSSL_GENERAL_NAME* wolfSSL_GENERAL_NAME_dup(
  1417. WOLFSSL_GENERAL_NAME* gn);
  1418. WOLFSSL_API int wolfSSL_GENERAL_NAME_set_type(WOLFSSL_GENERAL_NAME* name,
  1419. int typ);
  1420. WOLFSSL_API WOLFSSL_GENERAL_NAMES* wolfSSL_GENERAL_NAMES_dup(
  1421. WOLFSSL_GENERAL_NAMES* gns);
  1422. WOLFSSL_API int wolfSSL_GENERAL_NAME_set0_othername(WOLFSSL_GENERAL_NAME* gen,
  1423. WOLFSSL_ASN1_OBJECT* oid,
  1424. WOLFSSL_ASN1_TYPE* value);
  1425. WOLFSSL_API void wolfSSL_GENERAL_NAME_set0_value(WOLFSSL_GENERAL_NAME *a,
  1426. int type, void *value);
  1427. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_GENERAL_NAME_new(void *cmpFunc);
  1428. WOLFSSL_API int wolfSSL_sk_GENERAL_NAME_push(WOLFSSL_GENERAL_NAMES* sk,
  1429. WOLFSSL_GENERAL_NAME* gn);
  1430. WOLFSSL_API WOLFSSL_GENERAL_NAME* wolfSSL_sk_GENERAL_NAME_value(
  1431. WOLFSSL_STACK* sk, int i);
  1432. WOLFSSL_API int wolfSSL_sk_GENERAL_NAME_num(WOLFSSL_STACK* sk);
  1433. WOLFSSL_API void wolfSSL_sk_GENERAL_NAME_pop_free(WOLFSSL_STACK* sk,
  1434. void (*f) (WOLFSSL_GENERAL_NAME*));
  1435. WOLFSSL_API void wolfSSL_sk_GENERAL_NAME_free(WOLFSSL_STACK* sk);
  1436. WOLFSSL_API void wolfSSL_GENERAL_NAMES_free(WOLFSSL_GENERAL_NAMES* name);
  1437. WOLFSSL_API int wolfSSL_GENERAL_NAME_print(WOLFSSL_BIO* out,
  1438. WOLFSSL_GENERAL_NAME* name);
  1439. WOLFSSL_API void wolfSSL_EXTENDED_KEY_USAGE_free(WOLFSSL_STACK * sk);
  1440. WOLFSSL_API WOLFSSL_DIST_POINT* wolfSSL_DIST_POINT_new(void);
  1441. WOLFSSL_API void wolfSSL_DIST_POINT_free(WOLFSSL_DIST_POINT* dp);
  1442. WOLFSSL_API int wolfSSL_sk_DIST_POINT_push(WOLFSSL_DIST_POINTS* sk,
  1443. WOLFSSL_DIST_POINT* dp);
  1444. WOLFSSL_API WOLFSSL_DIST_POINT* wolfSSL_sk_DIST_POINT_value(
  1445. WOLFSSL_STACK* sk, int i);
  1446. WOLFSSL_API int wolfSSL_sk_DIST_POINT_num(WOLFSSL_STACK* sk);
  1447. WOLFSSL_API void wolfSSL_sk_DIST_POINT_pop_free(WOLFSSL_STACK* sk,
  1448. void (*f) (WOLFSSL_DIST_POINT*));
  1449. WOLFSSL_API void wolfSSL_sk_DIST_POINT_free(WOLFSSL_STACK* sk);
  1450. WOLFSSL_API void wolfSSL_DIST_POINTS_free(WOLFSSL_DIST_POINTS* dp);
  1451. WOLFSSL_API int wolfSSL_sk_ACCESS_DESCRIPTION_num(WOLFSSL_STACK* sk);
  1452. WOLFSSL_API void wolfSSL_AUTHORITY_INFO_ACCESS_free(
  1453. WOLF_STACK_OF(WOLFSSL_ACCESS_DESCRIPTION)* sk);
  1454. WOLFSSL_API void wolfSSL_AUTHORITY_INFO_ACCESS_pop_free(
  1455. WOLF_STACK_OF(WOLFSSL_ACCESS_DESCRIPTION)* sk,
  1456. void (*f) (WOLFSSL_ACCESS_DESCRIPTION*));
  1457. WOLFSSL_API WOLFSSL_ACCESS_DESCRIPTION* wolfSSL_sk_ACCESS_DESCRIPTION_value(
  1458. WOLFSSL_STACK* sk, int idx);
  1459. WOLFSSL_API void wolfSSL_sk_ACCESS_DESCRIPTION_free(WOLFSSL_STACK* sk);
  1460. WOLFSSL_API void wolfSSL_sk_ACCESS_DESCRIPTION_pop_free(WOLFSSL_STACK* sk,
  1461. void (*f) (WOLFSSL_ACCESS_DESCRIPTION*));
  1462. WOLFSSL_API void wolfSSL_ACCESS_DESCRIPTION_free(WOLFSSL_ACCESS_DESCRIPTION* a);
  1463. WOLFSSL_API void wolfSSL_sk_X509_EXTENSION_pop_free(
  1464. WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* sk,
  1465. void (*f) (WOLFSSL_X509_EXTENSION*));
  1466. WOLFSSL_API void wolfSSL_sk_X509_EXTENSION_free(
  1467. WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* sk);
  1468. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* wolfSSL_sk_X509_EXTENSION_new_null(void);
  1469. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_ASN1_OBJECT_new(void);
  1470. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_ASN1_OBJECT_dup(WOLFSSL_ASN1_OBJECT* obj);
  1471. WOLFSSL_API void wolfSSL_ASN1_OBJECT_free(WOLFSSL_ASN1_OBJECT* obj);
  1472. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_new_asn1_obj(void);
  1473. WOLFSSL_API int wolfSSL_sk_ASN1_OBJECT_push(WOLF_STACK_OF(WOLFSSL_ASN1_OBJEXT)* sk,
  1474. WOLFSSL_ASN1_OBJECT* obj);
  1475. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_sk_ASN1_OBJECT_pop(
  1476. WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)* sk);
  1477. WOLFSSL_API void wolfSSL_sk_ASN1_OBJECT_free(WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)* sk);
  1478. WOLFSSL_API void wolfSSL_sk_ASN1_OBJECT_pop_free(
  1479. WOLF_STACK_OF(WOLFSSL_ASN1_OBJECT)* sk,
  1480. void (*f)(WOLFSSL_ASN1_OBJECT*));
  1481. WOLFSSL_API int wolfSSL_ASN1_STRING_to_UTF8(unsigned char **out, WOLFSSL_ASN1_STRING *in);
  1482. WOLFSSL_API int wolfSSL_ASN1_UNIVERSALSTRING_to_string(WOLFSSL_ASN1_STRING *s);
  1483. WOLFSSL_API int wolfSSL_sk_X509_EXTENSION_num(WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* sk);
  1484. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_sk_X509_EXTENSION_value(
  1485. const WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* sk, int idx);
  1486. WOLFSSL_API int wolfSSL_set_ex_data(WOLFSSL* ssl, int idx, void* data);
  1487. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  1488. WOLFSSL_API int wolfSSL_set_ex_data_with_cleanup(
  1489. WOLFSSL* ssl,
  1490. int idx,
  1491. void* data,
  1492. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  1493. #endif
  1494. WOLFSSL_API int wolfSSL_get_shutdown(const WOLFSSL* ssl);
  1495. WOLFSSL_API int wolfSSL_set_rfd(WOLFSSL* ssl, int rfd);
  1496. WOLFSSL_API int wolfSSL_set_wfd(WOLFSSL* ssl, int wfd);
  1497. WOLFSSL_API void wolfSSL_set_shutdown(WOLFSSL* ssl, int opt);
  1498. WOLFSSL_API int wolfSSL_set_session_id_context(WOLFSSL* ssl, const unsigned char* id,
  1499. unsigned int len);
  1500. WOLFSSL_API void wolfSSL_set_connect_state(WOLFSSL* ssl);
  1501. WOLFSSL_API void wolfSSL_set_accept_state(WOLFSSL* ssl);
  1502. WOLFSSL_API int wolfSSL_session_reused(WOLFSSL* ssl);
  1503. #ifdef OPENSSL_EXTRA
  1504. /* using unsigned char instead of uint8_t here to avoid stdint include */
  1505. WOLFSSL_API unsigned char wolfSSL_SESSION_get_max_fragment_length(
  1506. WOLFSSL_SESSION* session);
  1507. #endif
  1508. WOLFSSL_API int wolfSSL_SESSION_up_ref(WOLFSSL_SESSION* session);
  1509. WOLFSSL_API WOLFSSL_SESSION* wolfSSL_SESSION_dup(WOLFSSL_SESSION* session);
  1510. WOLFSSL_API WOLFSSL_SESSION* wolfSSL_SESSION_new(void);
  1511. WOLFSSL_API WOLFSSL_SESSION* wolfSSL_SESSION_new_ex(void* heap);
  1512. WOLFSSL_API void wolfSSL_SESSION_free(WOLFSSL_SESSION* session);
  1513. WOLFSSL_API int wolfSSL_CTX_add_session(WOLFSSL_CTX* ctx,
  1514. WOLFSSL_SESSION* session);
  1515. WOLFSSL_API int wolfSSL_SESSION_set_cipher(WOLFSSL_SESSION* session,
  1516. const WOLFSSL_CIPHER* cipher);
  1517. WOLFSSL_API int wolfSSL_is_init_finished(const WOLFSSL* ssl);
  1518. WOLFSSL_API const char* wolfSSL_get_version(const WOLFSSL* ssl);
  1519. WOLFSSL_API int wolfSSL_get_current_cipher_suite(WOLFSSL* ssl);
  1520. WOLFSSL_API WOLFSSL_CIPHER* wolfSSL_get_current_cipher(WOLFSSL* ssl);
  1521. WOLFSSL_API char* wolfSSL_CIPHER_description(const WOLFSSL_CIPHER* cipher, char* in, int len);
  1522. WOLFSSL_API const char* wolfSSL_CIPHER_get_name(const WOLFSSL_CIPHER* cipher);
  1523. WOLFSSL_API const char* wolfSSL_CIPHER_get_version(const WOLFSSL_CIPHER* cipher);
  1524. WOLFSSL_API word32 wolfSSL_CIPHER_get_id(const WOLFSSL_CIPHER* cipher);
  1525. WOLFSSL_API int wolfSSL_CIPHER_get_auth_nid(const WOLFSSL_CIPHER* cipher);
  1526. WOLFSSL_API int wolfSSL_CIPHER_get_cipher_nid(const WOLFSSL_CIPHER* cipher);
  1527. WOLFSSL_API int wolfSSL_CIPHER_get_digest_nid(const WOLFSSL_CIPHER* cipher);
  1528. WOLFSSL_API int wolfSSL_CIPHER_get_kx_nid(const WOLFSSL_CIPHER* cipher);
  1529. WOLFSSL_API int wolfSSL_CIPHER_is_aead(const WOLFSSL_CIPHER* cipher);
  1530. WOLFSSL_API const WOLFSSL_CIPHER* wolfSSL_get_cipher_by_value(word16 value);
  1531. WOLFSSL_API const char* wolfSSL_SESSION_CIPHER_get_name(const WOLFSSL_SESSION* session);
  1532. WOLFSSL_API const char* wolfSSL_get_cipher(WOLFSSL* ssl);
  1533. WOLFSSL_API void wolfSSL_sk_CIPHER_free(WOLF_STACK_OF(WOLFSSL_CIPHER)* sk);
  1534. WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl);
  1535. WOLFSSL_API int wolfSSL_SessionIsSetup(WOLFSSL_SESSION* session);
  1536. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new(void);
  1537. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new_ex(void* heap);
  1538. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_dup(WOLFSSL_X509* x);
  1539. #if defined(OPENSSL_EXTRA_X509_SMALL) || defined(OPENSSL_EXTRA)
  1540. WOLFSSL_API int wolfSSL_RSA_up_ref(WOLFSSL_RSA* rsa);
  1541. WOLFSSL_API int wolfSSL_X509_up_ref(WOLFSSL_X509* x509);
  1542. WOLFSSL_API int wolfSSL_EVP_PKEY_up_ref(WOLFSSL_EVP_PKEY* pkey);
  1543. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509)*
  1544. wolfSSL_X509_chain_up_ref(WOLF_STACK_OF(WOLFSSL_X509)* chain);
  1545. #endif
  1546. WOLFSSL_API int wolfSSL_OCSP_parse_url(const char* url, char** host,
  1547. char** port, char** path, int* ssl);
  1548. #ifndef NO_BIO
  1549. #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
  1550. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new(const WOLFSSL_BIO_METHOD* method);
  1551. #else
  1552. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new(WOLFSSL_BIO_METHOD* method);
  1553. #endif
  1554. WOLFSSL_API int wolfSSL_BIO_free(WOLFSSL_BIO* bio);
  1555. WOLFSSL_API void wolfSSL_BIO_vfree(WOLFSSL_BIO* bio);
  1556. WOLFSSL_API void wolfSSL_BIO_free_all(WOLFSSL_BIO* bio);
  1557. WOLFSSL_API int wolfSSL_BIO_gets(WOLFSSL_BIO* bio, char* buf, int sz);
  1558. WOLFSSL_API int wolfSSL_BIO_puts(WOLFSSL_BIO* bio, const char* buf);
  1559. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_next(WOLFSSL_BIO* bio);
  1560. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_find_type(WOLFSSL_BIO* bio, int type);
  1561. WOLFSSL_API int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len);
  1562. WOLFSSL_API int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len);
  1563. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_push(WOLFSSL_BIO* top, WOLFSSL_BIO* append);
  1564. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_pop(WOLFSSL_BIO* bio);
  1565. WOLFSSL_API int wolfSSL_BIO_flush(WOLFSSL_BIO* bio);
  1566. WOLFSSL_API int wolfSSL_BIO_pending(WOLFSSL_BIO* bio);
  1567. WOLFSSL_API void wolfSSL_BIO_set_callback(WOLFSSL_BIO *bio,
  1568. wolf_bio_info_cb callback_func);
  1569. WOLFSSL_API wolf_bio_info_cb wolfSSL_BIO_get_callback(WOLFSSL_BIO *bio);
  1570. WOLFSSL_API void wolfSSL_BIO_set_callback_arg(WOLFSSL_BIO *bio, char *arg);
  1571. WOLFSSL_API char* wolfSSL_BIO_get_callback_arg(const WOLFSSL_BIO *bio);
  1572. WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_md(void);
  1573. WOLFSSL_API int wolfSSL_BIO_get_md_ctx(WOLFSSL_BIO *bio,
  1574. WOLFSSL_EVP_MD_CTX **mdcp);
  1575. WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_buffer(void);
  1576. WOLFSSL_API long wolfSSL_BIO_set_write_buffer_size(WOLFSSL_BIO* bio, long size);
  1577. WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_ssl(void);
  1578. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_socket(int sfd, int flag);
  1579. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_dgram(int fd, int closeF);
  1580. WOLFSSL_API int wolfSSL_BIO_eof(WOLFSSL_BIO* b);
  1581. WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_s_mem(void);
  1582. WOLFSSL_API WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_base64(void);
  1583. WOLFSSL_API void wolfSSL_BIO_set_flags(WOLFSSL_BIO* bio, int flags);
  1584. WOLFSSL_API void wolfSSL_BIO_clear_flags(WOLFSSL_BIO *bio, int flags);
  1585. WOLFSSL_API int wolfSSL_BIO_get_fd(WOLFSSL_BIO *bio, int* fd);
  1586. WOLFSSL_API int wolfSSL_BIO_set_ex_data(WOLFSSL_BIO *bio, int idx, void *data);
  1587. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  1588. WOLFSSL_API int wolfSSL_BIO_set_ex_data_with_cleanup(
  1589. WOLFSSL_BIO *bio,
  1590. int idx,
  1591. void *data,
  1592. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  1593. #endif
  1594. WOLFSSL_API void *wolfSSL_BIO_get_ex_data(WOLFSSL_BIO *bio, int idx);
  1595. WOLFSSL_API long wolfSSL_BIO_set_nbio(WOLFSSL_BIO* bio, long on);
  1596. WOLFSSL_API int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio,void* p);
  1597. WOLFSSL_API void wolfSSL_BIO_set_init(WOLFSSL_BIO* bio, int init);
  1598. WOLFSSL_API void wolfSSL_BIO_set_data(WOLFSSL_BIO* bio, void* ptr);
  1599. WOLFSSL_API void* wolfSSL_BIO_get_data(WOLFSSL_BIO* bio);
  1600. WOLFSSL_API void wolfSSL_BIO_set_shutdown(WOLFSSL_BIO* bio, int shut);
  1601. WOLFSSL_API int wolfSSL_BIO_get_shutdown(WOLFSSL_BIO* bio);
  1602. WOLFSSL_API void wolfSSL_BIO_clear_retry_flags(WOLFSSL_BIO* bio);
  1603. WOLFSSL_API int wolfSSL_BIO_should_retry(WOLFSSL_BIO *bio);
  1604. WOLFSSL_API int wolfSSL_BIO_should_read(WOLFSSL_BIO *bio);
  1605. WOLFSSL_API int wolfSSL_BIO_should_write(WOLFSSL_BIO *bio);
  1606. WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_meth_new(int type, const char* name);
  1607. WOLFSSL_API void wolfSSL_BIO_meth_free(WOLFSSL_BIO_METHOD* biom);
  1608. WOLFSSL_API int wolfSSL_BIO_meth_set_write(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_write_cb biom_write);
  1609. WOLFSSL_API int wolfSSL_BIO_meth_set_read(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_read_cb biom_read);
  1610. WOLFSSL_API int wolfSSL_BIO_meth_set_puts(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_puts_cb biom_puts);
  1611. WOLFSSL_API int wolfSSL_BIO_meth_set_gets(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_gets_cb biom_gets);
  1612. WOLFSSL_API int wolfSSL_BIO_meth_set_ctrl(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_ctrl_get_cb biom_ctrl);
  1613. WOLFSSL_API int wolfSSL_BIO_meth_set_create(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_create_cb biom_create);
  1614. WOLFSSL_API int wolfSSL_BIO_meth_set_destroy(WOLFSSL_BIO_METHOD* biom, wolfSSL_BIO_meth_destroy_cb biom_destroy);
  1615. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_mem_buf(const void* buf, int len);
  1616. WOLFSSL_API long wolfSSL_BIO_set_ssl(WOLFSSL_BIO* b, WOLFSSL* ssl, int flag);
  1617. WOLFSSL_API long wolfSSL_BIO_get_ssl(WOLFSSL_BIO* bio, WOLFSSL** ssl);
  1618. #ifndef NO_FILESYSTEM
  1619. WOLFSSL_API long wolfSSL_BIO_set_fd(WOLFSSL_BIO* b, int fd, int flag);
  1620. #endif
  1621. WOLFSSL_API int wolfSSL_BIO_set_close(WOLFSSL_BIO *b, long flag);
  1622. WOLFSSL_API void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr);
  1623. WOLFSSL_API void wolfSSL_set_rbio(WOLFSSL* ssl, WOLFSSL_BIO* rd);
  1624. WOLFSSL_API void wolfSSL_set_wbio(WOLFSSL* ssl, WOLFSSL_BIO* wr);
  1625. WOLFSSL_API int wolfSSL_BIO_method_type(const WOLFSSL_BIO *b);
  1626. #ifndef NO_FILESYSTEM
  1627. WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_file(void);
  1628. WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_fd(int fd, int close_flag);
  1629. #endif
  1630. WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_bio(void);
  1631. WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_socket(void);
  1632. WOLFSSL_API WOLFSSL_BIO_METHOD *wolfSSL_BIO_s_datagram(void);
  1633. WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_connect(const char *str);
  1634. WOLFSSL_API WOLFSSL_BIO *wolfSSL_BIO_new_accept(const char *port);
  1635. WOLFSSL_API long wolfSSL_BIO_set_conn_hostname(WOLFSSL_BIO* b, char* name);
  1636. WOLFSSL_API long wolfSSL_BIO_set_conn_port(WOLFSSL_BIO *b, char* port);
  1637. WOLFSSL_API long wolfSSL_BIO_do_connect(WOLFSSL_BIO *b);
  1638. WOLFSSL_API int wolfSSL_BIO_do_accept(WOLFSSL_BIO *b);
  1639. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_ssl(WOLFSSL_CTX* ctx, int client);
  1640. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_ssl_connect(WOLFSSL_CTX* ctx);
  1641. WOLFSSL_API long wolfSSL_BIO_do_handshake(WOLFSSL_BIO *b);
  1642. WOLFSSL_API void wolfSSL_BIO_ssl_shutdown(WOLFSSL_BIO* b);
  1643. WOLFSSL_API long wolfSSL_BIO_ctrl(WOLFSSL_BIO *bp, int cmd, long larg, void *parg);
  1644. WOLFSSL_API long wolfSSL_BIO_int_ctrl(WOLFSSL_BIO *bp, int cmd, long larg, int iarg);
  1645. WOLFSSL_API int wolfSSL_BIO_set_write_buf_size(WOLFSSL_BIO *b, long size);
  1646. WOLFSSL_API int wolfSSL_BIO_make_bio_pair(WOLFSSL_BIO *b1, WOLFSSL_BIO *b2);
  1647. WOLFSSL_API int wolfSSL_BIO_up_ref(WOLFSSL_BIO *b);
  1648. WOLFSSL_API int wolfSSL_BIO_ctrl_reset_read_request(WOLFSSL_BIO *b);
  1649. WOLFSSL_API int wolfSSL_BIO_nread0(WOLFSSL_BIO *bio, char **buf);
  1650. WOLFSSL_API int wolfSSL_BIO_nread(WOLFSSL_BIO *bio, char **buf, int num);
  1651. WOLFSSL_API int wolfSSL_BIO_nwrite(WOLFSSL_BIO *bio, char **buf, int num);
  1652. #if defined(WORD64_AVAILABLE) && !defined(WOLFSSL_BIO_NO_FLOW_STATS)
  1653. WOLFSSL_API word64 wolfSSL_BIO_number_read(WOLFSSL_BIO *bio);
  1654. WOLFSSL_API word64 wolfSSL_BIO_number_written(WOLFSSL_BIO *bio);
  1655. #endif
  1656. WOLFSSL_API int wolfSSL_BIO_reset(WOLFSSL_BIO *bio);
  1657. WOLFSSL_API int wolfSSL_BIO_seek(WOLFSSL_BIO *bio, int ofs);
  1658. WOLFSSL_API int wolfSSL_BIO_tell(WOLFSSL_BIO* bio);
  1659. WOLFSSL_API int wolfSSL_BIO_write_filename(WOLFSSL_BIO *bio, char *name);
  1660. WOLFSSL_API long wolfSSL_BIO_set_mem_eof_return(WOLFSSL_BIO *bio, int v);
  1661. WOLFSSL_API long wolfSSL_BIO_get_mem_ptr(WOLFSSL_BIO *bio, WOLFSSL_BUF_MEM **m);
  1662. #ifdef OPENSSL_ALL
  1663. WOLFSSL_API int wolfSSL_BIO_set_mem_buf(WOLFSSL_BIO* bio, WOLFSSL_BUF_MEM* bufMem,
  1664. int closeFlag);
  1665. #endif
  1666. WOLFSSL_API int wolfSSL_BIO_get_len(WOLFSSL_BIO *bio);
  1667. #ifdef WOLFSSL_HAVE_BIO_ADDR
  1668. WOLFSSL_API WOLFSSL_BIO_ADDR *wolfSSL_BIO_ADDR_new(void);
  1669. WOLFSSL_API void wolfSSL_BIO_ADDR_free(WOLFSSL_BIO_ADDR *addr);
  1670. WOLFSSL_API void wolfSSL_BIO_ADDR_clear(WOLFSSL_BIO_ADDR *addr);
  1671. #endif /* WOLFSSL_HAVE_BIO_ADDR */
  1672. #endif /* !NO_BIO */
  1673. WOLFSSL_API void wolfSSL_RAND_screen(void);
  1674. WOLFSSL_API const char* wolfSSL_RAND_file_name(char* fname, unsigned long len);
  1675. WOLFSSL_API int wolfSSL_RAND_write_file(const char* fname);
  1676. WOLFSSL_API int wolfSSL_RAND_load_file(const char* fname, long len);
  1677. WOLFSSL_API int wolfSSL_RAND_egd(const char* nm);
  1678. WOLFSSL_API int wolfSSL_RAND_seed(const void* seed, int len);
  1679. WOLFSSL_API void wolfSSL_RAND_Cleanup(void);
  1680. WOLFSSL_API void wolfSSL_RAND_add(const void* add, int len, double entropy);
  1681. WOLFSSL_API int wolfSSL_RAND_poll(void);
  1682. #ifndef NO_WOLFSSL_STUB
  1683. WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void);
  1684. WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void);
  1685. WOLFSSL_API int wolfSSL_COMP_add_compression_method(int method, void* data);
  1686. WOLFSSL_API const char *wolfSSL_COMP_get_name(const WOLFSSL_COMP_METHOD *comp);
  1687. WOLFSSL_API const WOLFSSL_COMP_METHOD* wolfSSL_get_current_compression(const WOLFSSL *ssl);
  1688. WOLFSSL_API const WOLFSSL_COMP_METHOD* wolfSSL_get_current_expansion(const WOLFSSL *ssl);
  1689. #endif /* !NO_WOLFSSL_STUB */
  1690. WOLFSSL_API unsigned long wolfSSL_thread_id(void);
  1691. WOLFSSL_API void wolfSSL_set_id_callback(unsigned long (*f)(void));
  1692. #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
  1693. WOLFSSL_API void wolfSSL_set_locking_callback(mutex_cb* f);
  1694. WOLFSSL_API mutex_cb* wolfSSL_get_locking_callback(void);
  1695. #endif
  1696. WOLFSSL_API void wolfSSL_set_dynlock_create_callback(WOLFSSL_dynlock_value* (*f)
  1697. (const char*, int));
  1698. WOLFSSL_API void wolfSSL_set_dynlock_lock_callback(void (*f)(int,
  1699. WOLFSSL_dynlock_value*, const char*, int));
  1700. WOLFSSL_API void wolfSSL_set_dynlock_destroy_callback(void (*f)
  1701. (WOLFSSL_dynlock_value*, const char*, int));
  1702. WOLFSSL_API int wolfSSL_num_locks(void);
  1703. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get_current_cert(
  1704. WOLFSSL_X509_STORE_CTX* ctx);
  1705. WOLFSSL_API int wolfSSL_X509_STORE_CTX_get_error(WOLFSSL_X509_STORE_CTX* ctx);
  1706. WOLFSSL_API int wolfSSL_X509_STORE_CTX_get_error_depth(WOLFSSL_X509_STORE_CTX* ctx);
  1707. WOLFSSL_API void wolfSSL_X509_STORE_CTX_set_verify_cb(WOLFSSL_X509_STORE_CTX *ctx,
  1708. WOLFSSL_X509_STORE_CTX_verify_cb verify_cb);
  1709. WOLFSSL_API void wolfSSL_X509_STORE_set_verify_cb(WOLFSSL_X509_STORE *st,
  1710. WOLFSSL_X509_STORE_CTX_verify_cb verify_cb);
  1711. WOLFSSL_API void wolfSSL_X509_STORE_set_get_crl(WOLFSSL_X509_STORE *st,
  1712. WOLFSSL_X509_STORE_CTX_get_crl_cb get_cb);
  1713. WOLFSSL_API void wolfSSL_X509_STORE_set_check_crl(WOLFSSL_X509_STORE *st,
  1714. WOLFSSL_X509_STORE_CTX_check_crl_cb check_crl);
  1715. WOLFSSL_API int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* n,
  1716. unsigned char** out);
  1717. WOLFSSL_API int wolfSSL_i2d_X509_NAME_canon(WOLFSSL_X509_NAME* name,
  1718. unsigned char** out);
  1719. WOLFSSL_API WOLFSSL_X509_NAME *wolfSSL_d2i_X509_NAME(WOLFSSL_X509_NAME **name,
  1720. unsigned char **in, long length);
  1721. #ifndef NO_RSA
  1722. #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
  1723. WOLFSSL_API int wolfSSL_RSA_print_fp(XFILE fp, WOLFSSL_RSA* rsa, int indent);
  1724. #endif /* !NO_FILESYSTEM && !NO_STDIO_FILESYSTEM */
  1725. #ifndef NO_BIO
  1726. WOLFSSL_API int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int offset);
  1727. #endif /* !NO_BIO */
  1728. #endif /* !NO_RSA */
  1729. WOLFSSL_API int wolfSSL_X509_print_ex(WOLFSSL_BIO* bio, WOLFSSL_X509* x509,
  1730. unsigned long nmflags, unsigned long cflag);
  1731. #ifndef NO_FILESYSTEM
  1732. WOLFSSL_API int wolfSSL_X509_print_fp(XFILE fp, WOLFSSL_X509 *x509);
  1733. #endif
  1734. WOLFSSL_API int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp,
  1735. const WOLFSSL_X509_ALGOR *sigalg, const WOLFSSL_ASN1_STRING *sig);
  1736. WOLFSSL_API void wolfSSL_X509_get0_signature(const WOLFSSL_ASN1_BIT_STRING **psig,
  1737. const WOLFSSL_X509_ALGOR **palg, const WOLFSSL_X509 *x509);
  1738. WOLFSSL_API int wolfSSL_X509_print(WOLFSSL_BIO* bio, WOLFSSL_X509* x509);
  1739. WOLFSSL_API int wolfSSL_X509_REQ_print(WOLFSSL_BIO* bio, WOLFSSL_X509* x509);
  1740. WOLFSSL_ABI WOLFSSL_API char* wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME* name,
  1741. char* in, int sz);
  1742. WOLFSSL_API unsigned long wolfSSL_X509_NAME_hash(WOLFSSL_X509_NAME* name);
  1743. #if defined(OPENSSL_EXTRA) && defined(XSNPRINTF)
  1744. WOLFSSL_API char* wolfSSL_X509_get_name_oneline(WOLFSSL_X509_NAME* name, char* in, int sz);
  1745. #endif
  1746. WOLFSSL_ABI WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_get_issuer_name(
  1747. WOLFSSL_X509* cert);
  1748. WOLFSSL_API unsigned long wolfSSL_X509_issuer_name_hash(const WOLFSSL_X509* x509);
  1749. WOLFSSL_ABI WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_get_subject_name(
  1750. WOLFSSL_X509* cert);
  1751. WOLFSSL_API unsigned long wolfSSL_X509_subject_name_hash(const WOLFSSL_X509* x509);
  1752. WOLFSSL_API int wolfSSL_X509_ext_isSet_by_NID(WOLFSSL_X509* x509, int nid);
  1753. WOLFSSL_API int wolfSSL_X509_ext_get_critical_by_NID(WOLFSSL_X509* x509, int nid);
  1754. WOLFSSL_API int wolfSSL_X509_EXTENSION_set_critical(WOLFSSL_X509_EXTENSION* ex, int crit);
  1755. WOLFSSL_API int wolfSSL_X509_get_isCA(WOLFSSL_X509* x509);
  1756. WOLFSSL_API int wolfSSL_X509_get_isSet_pathLength(WOLFSSL_X509* x509);
  1757. WOLFSSL_API unsigned int wolfSSL_X509_get_pathLength(WOLFSSL_X509* x509);
  1758. WOLFSSL_API unsigned int wolfSSL_X509_get_keyUsage(WOLFSSL_X509* x509);
  1759. WOLFSSL_API unsigned char* wolfSSL_X509_get_authorityKeyID(
  1760. WOLFSSL_X509* x509, unsigned char* dst, int* dstLen);
  1761. WOLFSSL_API unsigned char* wolfSSL_X509_get_subjectKeyID(
  1762. WOLFSSL_X509* x509, unsigned char* dst, int* dstLen);
  1763. WOLFSSL_API const WOLFSSL_ASN1_STRING *wolfSSL_X509_get0_subject_key_id(
  1764. WOLFSSL_X509 *x509);
  1765. WOLFSSL_API int wolfSSL_X509_verify(WOLFSSL_X509* x509, WOLFSSL_EVP_PKEY* pkey);
  1766. #ifdef WOLFSSL_CERT_REQ
  1767. WOLFSSL_API int wolfSSL_X509_REQ_verify(WOLFSSL_X509* x509, WOLFSSL_EVP_PKEY* pkey);
  1768. #endif
  1769. WOLFSSL_API int wolfSSL_X509_set_subject_name(WOLFSSL_X509* cert,
  1770. WOLFSSL_X509_NAME* name);
  1771. WOLFSSL_API int wolfSSL_X509_set_issuer_name(WOLFSSL_X509* cert,
  1772. WOLFSSL_X509_NAME* name);
  1773. WOLFSSL_API int wolfSSL_X509_set_pubkey(WOLFSSL_X509* cert, WOLFSSL_EVP_PKEY* pkey);
  1774. WOLFSSL_API int wolfSSL_X509_set_notAfter(WOLFSSL_X509* x509,
  1775. const WOLFSSL_ASN1_TIME* t);
  1776. WOLFSSL_API int wolfSSL_X509_set1_notAfter(WOLFSSL_X509* x509,
  1777. const WOLFSSL_ASN1_TIME *t);
  1778. WOLFSSL_API int wolfSSL_X509_set_notBefore(WOLFSSL_X509* x509,
  1779. const WOLFSSL_ASN1_TIME* t);
  1780. WOLFSSL_API int wolfSSL_X509_set1_notBefore(WOLFSSL_X509* x509,
  1781. const WOLFSSL_ASN1_TIME *t);
  1782. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_get_notBefore(const WOLFSSL_X509* x509);
  1783. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_get_notAfter(const WOLFSSL_X509* x509);
  1784. WOLFSSL_API int wolfSSL_X509_set_serialNumber(WOLFSSL_X509* x509,
  1785. WOLFSSL_ASN1_INTEGER* s);
  1786. WOLFSSL_API int wolfSSL_X509_set_version(WOLFSSL_X509* x509, long v);
  1787. WOLFSSL_API int wolfSSL_X509_sign(WOLFSSL_X509* x509, WOLFSSL_EVP_PKEY* pkey,
  1788. const WOLFSSL_EVP_MD* md);
  1789. WOLFSSL_API int wolfSSL_X509_sign_ctx(WOLFSSL_X509 *x509, WOLFSSL_EVP_MD_CTX *ctx);
  1790. WOLFSSL_API int wolfSSL_X509_NAME_entry_count(WOLFSSL_X509_NAME* name);
  1791. WOLFSSL_API int wolfSSL_X509_NAME_get_sz(WOLFSSL_X509_NAME* name);
  1792. WOLFSSL_API int wolfSSL_X509_NAME_get_text_by_NID(
  1793. WOLFSSL_X509_NAME* name, int nid, char* buf, int len);
  1794. WOLFSSL_API int wolfSSL_X509_NAME_get_index_by_NID(
  1795. WOLFSSL_X509_NAME* name, int nid, int pos);
  1796. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_X509_NAME_ENTRY_get_data(WOLFSSL_X509_NAME_ENTRY* in);
  1797. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_ASN1_STRING_new(void);
  1798. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_ASN1_STRING_dup(WOLFSSL_ASN1_STRING* asn1);
  1799. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_ASN1_STRING_type_new(int type);
  1800. WOLFSSL_API int wolfSSL_ASN1_STRING_type(const WOLFSSL_ASN1_STRING* asn1);
  1801. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_d2i_DISPLAYTEXT(WOLFSSL_ASN1_STRING **asn, const unsigned char **in, long len);
  1802. WOLFSSL_API int wolfSSL_ASN1_STRING_cmp(const WOLFSSL_ASN1_STRING *a, const WOLFSSL_ASN1_STRING *b);
  1803. WOLFSSL_API void wolfSSL_ASN1_STRING_free(WOLFSSL_ASN1_STRING* asn1);
  1804. WOLFSSL_API int wolfSSL_ASN1_STRING_set(WOLFSSL_ASN1_STRING* asn1,
  1805. const void* data, int dataSz);
  1806. WOLFSSL_API unsigned char* wolfSSL_ASN1_STRING_data(WOLFSSL_ASN1_STRING* asn);
  1807. WOLFSSL_API const unsigned char* wolfSSL_ASN1_STRING_get0_data(
  1808. const WOLFSSL_ASN1_STRING* asn);
  1809. WOLFSSL_API int wolfSSL_ASN1_STRING_length(const WOLFSSL_ASN1_STRING* asn);
  1810. WOLFSSL_API int wolfSSL_ASN1_STRING_copy(WOLFSSL_ASN1_STRING* dst,
  1811. const WOLFSSL_ASN1_STRING* src);
  1812. WOLFSSL_API int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx);
  1813. WOLFSSL_API const char* wolfSSL_X509_verify_cert_error_string(long err);
  1814. WOLFSSL_API int wolfSSL_X509_get_signature_type(WOLFSSL_X509* x509);
  1815. WOLFSSL_API int wolfSSL_X509_get_signature(WOLFSSL_X509* x509, unsigned char* buf, int* bufSz);
  1816. WOLFSSL_API int wolfSSL_X509_get_pubkey_buffer(WOLFSSL_X509* x509, unsigned char* buf,
  1817. int* bufSz);
  1818. WOLFSSL_API int wolfSSL_X509_get_pubkey_type(WOLFSSL_X509* x509);
  1819. WOLFSSL_API int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP* lookup,const char* dir,long type);
  1820. WOLFSSL_API int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup, const char* file,
  1821. long type);
  1822. WOLFSSL_API WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_hash_dir(void);
  1823. WOLFSSL_API WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_file(void);
  1824. WOLFSSL_API int wolfSSL_X509_LOOKUP_ctrl(WOLFSSL_X509_LOOKUP *ctx, int cmd,
  1825. const char *argc, long argl, char **ret);
  1826. WOLFSSL_API WOLFSSL_X509_LOOKUP* wolfSSL_X509_STORE_add_lookup(WOLFSSL_X509_STORE* store,
  1827. WOLFSSL_X509_LOOKUP_METHOD* m);
  1828. WOLFSSL_API WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void);
  1829. WOLFSSL_API void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store);
  1830. WOLFSSL_API int wolfSSL_X509_STORE_up_ref(WOLFSSL_X509_STORE* store);
  1831. WOLFSSL_API int wolfSSL_X509_STORE_add_cert(
  1832. WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509);
  1833. WOLFSSL_API WOLFSSL_X509_VERIFY_PARAM *wolfSSL_X509_STORE_get0_param(
  1834. const WOLFSSL_X509_STORE *ctx);
  1835. WOLFSSL_API int wolfSSL_X509_STORE_set1_param(WOLFSSL_X509_STORE *ctx,
  1836. WOLFSSL_X509_VERIFY_PARAM *param);
  1837. WOLFSSL_API WOLFSSL_STACK* wolfSSL_X509_STORE_CTX_get_chain(
  1838. WOLFSSL_X509_STORE_CTX* ctx);
  1839. WOLFSSL_API WOLFSSL_STACK* wolfSSL_X509_STORE_CTX_get1_chain(
  1840. WOLFSSL_X509_STORE_CTX* ctx);
  1841. WOLFSSL_API WOLFSSL_X509_STORE_CTX *wolfSSL_X509_STORE_CTX_get0_parent_ctx(
  1842. WOLFSSL_X509_STORE_CTX *ctx);
  1843. WOLFSSL_API int wolfSSL_X509_STORE_set_flags(WOLFSSL_X509_STORE* store,
  1844. unsigned long flag);
  1845. WOLFSSL_API int wolfSSL_X509_STORE_set_default_paths(WOLFSSL_X509_STORE* store);
  1846. WOLFSSL_API int wolfSSL_X509_STORE_get_by_subject(WOLFSSL_X509_STORE_CTX* ctx,
  1847. int idx, WOLFSSL_X509_NAME* name, WOLFSSL_X509_OBJECT* obj);
  1848. WOLFSSL_API WOLFSSL_X509_VERIFY_PARAM *wolfSSL_X509_STORE_CTX_get0_param(
  1849. WOLFSSL_X509_STORE_CTX *ctx);
  1850. WOLFSSL_API WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void);
  1851. WOLFSSL_API WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new_ex(void* heap);
  1852. WOLFSSL_API int wolfSSL_X509_STORE_CTX_init(WOLFSSL_X509_STORE_CTX* ctx,
  1853. WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509, WOLF_STACK_OF(WOLFSSL_X509)*);
  1854. WOLFSSL_API void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx);
  1855. WOLFSSL_API void wolfSSL_X509_STORE_CTX_cleanup(WOLFSSL_X509_STORE_CTX* ctx);
  1856. WOLFSSL_API void wolfSSL_X509_STORE_CTX_trusted_stack(WOLFSSL_X509_STORE_CTX *ctx,
  1857. WOLF_STACK_OF(WOLFSSL_X509) *sk);
  1858. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_lastUpdate(WOLFSSL_X509_CRL* crl);
  1859. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_nextUpdate(WOLFSSL_X509_CRL* crl);
  1860. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509* x509);
  1861. WOLFSSL_API int wolfSSL_X509_CRL_verify(WOLFSSL_X509_CRL* crl, WOLFSSL_EVP_PKEY* pkey);
  1862. WOLFSSL_API void wolfSSL_X509_OBJECT_free_contents(WOLFSSL_X509_OBJECT* obj);
  1863. WOLFSSL_API WOLFSSL_PKCS8_PRIV_KEY_INFO* wolfSSL_d2i_PKCS8_PKEY_bio(
  1864. WOLFSSL_BIO* bio, WOLFSSL_PKCS8_PRIV_KEY_INFO** pkey);
  1865. WOLFSSL_API WOLFSSL_PKCS8_PRIV_KEY_INFO* wolfSSL_d2i_PKCS8_PKEY(
  1866. WOLFSSL_PKCS8_PRIV_KEY_INFO** pkey, const unsigned char** keyBuf, long keyLen);
  1867. WOLFSSL_API int wolfSSL_i2d_PKCS8_PKEY(WOLFSSL_PKCS8_PRIV_KEY_INFO* key,
  1868. unsigned char** pp);
  1869. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY_bio(WOLFSSL_BIO* bio,
  1870. WOLFSSL_EVP_PKEY** out);
  1871. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PUBKEY(WOLFSSL_EVP_PKEY** key,
  1872. const unsigned char** in, long inSz);
  1873. WOLFSSL_API int wolfSSL_i2d_PUBKEY(const WOLFSSL_EVP_PKEY *key, unsigned char **der);
  1874. WOLFSSL_API int wolfSSL_i2d_X509_PUBKEY(WOLFSSL_X509_PUBKEY* x509_PubKey,
  1875. unsigned char** der);
  1876. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PublicKey(int type, WOLFSSL_EVP_PKEY** pkey,
  1877. const unsigned char ** in, long inSz);
  1878. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey(int type,
  1879. WOLFSSL_EVP_PKEY** out, const unsigned char **in, long inSz);
  1880. #ifdef WOLF_PRIVATE_KEY_ID
  1881. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_id(int type,
  1882. WOLFSSL_EVP_PKEY** out, void* heap, int devId);
  1883. #endif
  1884. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_EVP(WOLFSSL_EVP_PKEY** key,
  1885. unsigned char** in, long inSz);
  1886. WOLFSSL_API int wolfSSL_i2d_PrivateKey(const WOLFSSL_EVP_PKEY* key,
  1887. unsigned char** der);
  1888. WOLFSSL_API int wolfSSL_i2d_PublicKey(const WOLFSSL_EVP_PKEY* key,
  1889. unsigned char** der);
  1890. #if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
  1891. WOLFSSL_API int wolfSSL_EVP_PKEY_print_public(WOLFSSL_BIO* out,
  1892. const WOLFSSL_EVP_PKEY* pkey,
  1893. int indent, WOLFSSL_ASN1_PCTX* pctx);
  1894. #endif /* OPENSSL_EXTRA && !WOLFCRYPT_ONLY */
  1895. WOLFSSL_API int wolfSSL_X509_cmp_current_time(const WOLFSSL_ASN1_TIME* asnTime);
  1896. #ifdef OPENSSL_EXTRA
  1897. WOLFSSL_API int wolfSSL_X509_cmp_time(const WOLFSSL_ASN1_TIME* asnTime,
  1898. time_t *cmpTime);
  1899. WOLFSSL_API WOLFSSL_ASN1_TIME *wolfSSL_X509_time_adj_ex(WOLFSSL_ASN1_TIME *asnTime,
  1900. int offset_day, long offset_sec, time_t *in_tm);
  1901. WOLFSSL_API WOLFSSL_ASN1_TIME *wolfSSL_X509_time_adj(WOLFSSL_ASN1_TIME *asnTime,
  1902. long offset_sec, time_t *in_tm);
  1903. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_X509_gmtime_adj(WOLFSSL_ASN1_TIME* s,
  1904. long adj);
  1905. WOLFSSL_API int wolfSSL_sk_X509_REVOKED_num(WOLFSSL_X509_REVOKED* revoked);
  1906. WOLFSSL_API void wolfSSL_X509_STORE_CTX_set_time(WOLFSSL_X509_STORE_CTX* ctx,
  1907. unsigned long flags,
  1908. time_t t);
  1909. WOLFSSL_API WOLFSSL_X509_VERIFY_PARAM* wolfSSL_X509_VERIFY_PARAM_new(void);
  1910. WOLFSSL_API void wolfSSL_X509_VERIFY_PARAM_free(WOLFSSL_X509_VERIFY_PARAM *param);
  1911. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set_flags(WOLFSSL_X509_VERIFY_PARAM *param,
  1912. unsigned long flags);
  1913. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_get_flags(WOLFSSL_X509_VERIFY_PARAM *param);
  1914. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_clear_flags(WOLFSSL_X509_VERIFY_PARAM *param,
  1915. unsigned long flags);
  1916. WOLFSSL_API void wolfSSL_X509_VERIFY_PARAM_set_hostflags(
  1917. WOLFSSL_X509_VERIFY_PARAM* param, unsigned int flags);
  1918. WOLFSSL_API int wolfSSL_set1_host(WOLFSSL* ssl, const char * name);
  1919. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1_host(WOLFSSL_X509_VERIFY_PARAM* pParam,
  1920. const char* name,
  1921. unsigned int nameSz);
  1922. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1_ip_asc(
  1923. WOLFSSL_X509_VERIFY_PARAM *param, const char *ipasc);
  1924. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1_ip(
  1925. WOLFSSL_X509_VERIFY_PARAM* param, const unsigned char* ip, size_t iplen);
  1926. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_set1(WOLFSSL_X509_VERIFY_PARAM* to,
  1927. const WOLFSSL_X509_VERIFY_PARAM* from);
  1928. WOLFSSL_API const WOLFSSL_X509_VERIFY_PARAM *wolfSSL_X509_VERIFY_PARAM_lookup(
  1929. const char *name);
  1930. WOLFSSL_API int wolfSSL_X509_VERIFY_PARAM_inherit(WOLFSSL_X509_VERIFY_PARAM *to,
  1931. const WOLFSSL_X509_VERIFY_PARAM *from);
  1932. WOLFSSL_API int wolfSSL_X509_load_crl_file(WOLFSSL_X509_LOOKUP *ctx,
  1933. const char *file, int type);
  1934. WOLFSSL_API int wolfSSL_X509_load_cert_crl_file(WOLFSSL_X509_LOOKUP *ctx,
  1935. const char *file, int type);
  1936. #endif
  1937. WOLFSSL_API WOLFSSL_X509_REVOKED* wolfSSL_X509_CRL_get_REVOKED(WOLFSSL_X509_CRL* crl);
  1938. WOLFSSL_API WOLFSSL_X509_REVOKED* wolfSSL_sk_X509_REVOKED_value(
  1939. WOLFSSL_X509_REVOKED* revoked,int value);
  1940. WOLFSSL_API WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509);
  1941. WOLFSSL_API void wolfSSL_ASN1_INTEGER_free(WOLFSSL_ASN1_INTEGER* in);
  1942. WOLFSSL_API WOLFSSL_ASN1_INTEGER* wolfSSL_ASN1_INTEGER_new(void);
  1943. WOLFSSL_API WOLFSSL_ASN1_INTEGER* wolfSSL_ASN1_INTEGER_dup(
  1944. const WOLFSSL_ASN1_INTEGER* src);
  1945. WOLFSSL_API int wolfSSL_ASN1_INTEGER_set(WOLFSSL_ASN1_INTEGER *a, long v);
  1946. WOLFSSL_API WOLFSSL_ASN1_INTEGER* wolfSSL_d2i_ASN1_INTEGER(
  1947. WOLFSSL_ASN1_INTEGER** a,
  1948. const unsigned char** in,
  1949. long inSz);
  1950. WOLFSSL_API int wolfSSL_i2d_ASN1_INTEGER(const WOLFSSL_ASN1_INTEGER* a,
  1951. unsigned char** pp);
  1952. WOLFSSL_API int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime);
  1953. WOLFSSL_API char* wolfSSL_ASN1_TIME_to_string(WOLFSSL_ASN1_TIME* t,
  1954. char* buf, int len);
  1955. #ifndef NO_ASN_TIME
  1956. WOLFSSL_API int wolfSSL_ASN1_TIME_to_tm(const WOLFSSL_ASN1_TIME* asnTime, struct tm* tm);
  1957. #endif
  1958. WOLFSSL_API int wolfSSL_ASN1_INTEGER_cmp(const WOLFSSL_ASN1_INTEGER* a,
  1959. const WOLFSSL_ASN1_INTEGER* b);
  1960. WOLFSSL_API long wolfSSL_ASN1_INTEGER_get(const WOLFSSL_ASN1_INTEGER* a);
  1961. #ifdef OPENSSL_EXTRA
  1962. WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_ASN1_INTEGER_to_BN(const WOLFSSL_ASN1_INTEGER *ai,
  1963. WOLFSSL_BIGNUM *bn);
  1964. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_adj(WOLFSSL_ASN1_TIME* s, time_t t,
  1965. int offset_day, long offset_sec);
  1966. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_new(void);
  1967. WOLFSSL_API void wolfSSL_ASN1_TIME_free(WOLFSSL_ASN1_TIME* t);
  1968. #endif
  1969. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_load_client_CA_file(const char* fname);
  1970. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_CTX_get_client_CA_list(
  1971. const WOLFSSL_CTX *ctx);
  1972. /* deprecated function name */
  1973. #define wolfSSL_SSL_CTX_get_client_CA_list wolfSSL_CTX_get_client_CA_list
  1974. WOLFSSL_API void wolfSSL_CTX_set_client_CA_list(WOLFSSL_CTX* ctx,
  1975. WOLF_STACK_OF(WOLFSSL_X509_NAME)*);
  1976. WOLFSSL_API void wolfSSL_set_client_CA_list(WOLFSSL* ssl,
  1977. WOLF_STACK_OF(WOLFSSL_X509_NAME)*);
  1978. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_get_client_CA_list(
  1979. const WOLFSSL* ssl);
  1980. typedef int (*client_cert_cb)(WOLFSSL *ssl, WOLFSSL_X509 **x509,
  1981. WOLFSSL_EVP_PKEY **pkey);
  1982. WOLFSSL_API void wolfSSL_CTX_set_client_cert_cb(WOLFSSL_CTX *ctx, client_cert_cb cb);
  1983. typedef int (*CertSetupCallback)(WOLFSSL* ssl, void*);
  1984. WOLFSSL_API void wolfSSL_CTX_set_cert_cb(WOLFSSL_CTX* ctx,
  1985. CertSetupCallback cb, void *arg);
  1986. WOLFSSL_API int wolfSSL_get_client_suites_sigalgs(const WOLFSSL* ssl,
  1987. const byte** suites, word16* suiteSz,
  1988. const byte** hashSigAlgo, word16* hashSigAlgoSz);
  1989. typedef struct WOLFSSL_CIPHERSUITE_INFO {
  1990. byte rsaAuth:1;
  1991. byte eccAuth:1;
  1992. byte eccStatic:1;
  1993. byte psk:1;
  1994. } WOLFSSL_CIPHERSUITE_INFO;
  1995. WOLFSSL_API WOLFSSL_CIPHERSUITE_INFO wolfSSL_get_ciphersuite_info(byte first,
  1996. byte second);
  1997. WOLFSSL_API int wolfSSL_get_sigalg_info(byte first,
  1998. byte second, int* hashAlgo, int* sigAlgo);
  1999. WOLFSSL_LOCAL int CertSetupCbWrapper(WOLFSSL* ssl);
  2000. WOLFSSL_API void* wolfSSL_X509_STORE_CTX_get_ex_data(
  2001. WOLFSSL_X509_STORE_CTX* ctx, int idx);
  2002. WOLFSSL_API int wolfSSL_X509_STORE_CTX_set_ex_data(WOLFSSL_X509_STORE_CTX* ctx,
  2003. int idx, void *data);
  2004. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  2005. WOLFSSL_API int wolfSSL_X509_STORE_CTX_set_ex_data_with_cleanup(
  2006. WOLFSSL_X509_STORE_CTX* ctx,
  2007. int idx,
  2008. void *data,
  2009. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  2010. #endif
  2011. WOLFSSL_API void* wolfSSL_X509_STORE_get_ex_data(
  2012. WOLFSSL_X509_STORE* store, int idx);
  2013. WOLFSSL_API int wolfSSL_X509_STORE_set_ex_data(WOLFSSL_X509_STORE* store,
  2014. int idx, void *data);
  2015. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  2016. WOLFSSL_API int wolfSSL_X509_STORE_set_ex_data_with_cleanup(
  2017. WOLFSSL_X509_STORE* store,
  2018. int idx,
  2019. void *data,
  2020. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  2021. #endif
  2022. WOLFSSL_API void wolfSSL_X509_STORE_CTX_set_depth(WOLFSSL_X509_STORE_CTX* ctx,
  2023. int depth);
  2024. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get0_current_issuer(
  2025. WOLFSSL_X509_STORE_CTX* ctx);
  2026. WOLFSSL_API WOLFSSL_X509_STORE* wolfSSL_X509_STORE_CTX_get0_store(
  2027. WOLFSSL_X509_STORE_CTX* ctx);
  2028. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get0_cert(
  2029. WOLFSSL_X509_STORE_CTX* ctx);
  2030. WOLFSSL_API int wolfSSL_get_ex_data_X509_STORE_CTX_idx(void);
  2031. WOLFSSL_API void wolfSSL_X509_STORE_CTX_set_error(
  2032. WOLFSSL_X509_STORE_CTX* ctx, int er);
  2033. void wolfSSL_X509_STORE_CTX_set_error_depth(WOLFSSL_X509_STORE_CTX* ctx,
  2034. int depth);
  2035. WOLFSSL_API void* wolfSSL_get_ex_data(const WOLFSSL* ssl, int idx);
  2036. WOLFSSL_API void wolfSSL_CTX_set_default_passwd_cb_userdata(WOLFSSL_CTX* ctx,
  2037. void* userdata);
  2038. WOLFSSL_API void wolfSSL_CTX_set_default_passwd_cb(WOLFSSL_CTX* ctx,
  2039. wc_pem_password_cb* cb);
  2040. WOLFSSL_API wc_pem_password_cb* wolfSSL_CTX_get_default_passwd_cb(WOLFSSL_CTX* ctx);
  2041. WOLFSSL_API void *wolfSSL_CTX_get_default_passwd_cb_userdata(WOLFSSL_CTX *ctx);
  2042. WOLFSSL_API void wolfSSL_CTX_set_info_callback(WOLFSSL_CTX* ctx,
  2043. void (*f)(const WOLFSSL* ssl, int type, int val));
  2044. WOLFSSL_API void wolfSSL_set_info_callback(WOLFSSL* ssl,
  2045. void (*f)(const WOLFSSL* ssl, int type, int val));
  2046. WOLFSSL_API unsigned long wolfSSL_ERR_peek_error(void);
  2047. WOLFSSL_API int wolfSSL_GET_REASON(int);
  2048. WOLFSSL_API const char* wolfSSL_alert_type_string_long(int alertID);
  2049. WOLFSSL_API const char* wolfSSL_alert_desc_string_long(int alertID);
  2050. WOLFSSL_API const char* wolfSSL_state_string_long(const WOLFSSL* ssl);
  2051. WOLFSSL_API WOLFSSL_RSA* wolfSSL_RSA_generate_key(int len, unsigned long e,
  2052. void(*f)(int, int, void*), void* data);
  2053. WOLFSSL_API WOLFSSL_RSA *wolfSSL_d2i_RSAPublicKey(WOLFSSL_RSA **r,
  2054. const unsigned char **pp, long len);
  2055. WOLFSSL_API WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA** r,
  2056. const unsigned char** derBuf, long derSz);
  2057. WOLFSSL_API int wolfSSL_i2d_RSAPublicKey(WOLFSSL_RSA *r, unsigned char **pp);
  2058. WOLFSSL_API int wolfSSL_i2d_RSAPrivateKey(WOLFSSL_RSA *r, unsigned char **pp);
  2059. WOLFSSL_API void wolfSSL_CTX_set_tmp_rsa_callback(WOLFSSL_CTX* ctx,
  2060. WOLFSSL_RSA *(*f)(WOLFSSL *, int, int));
  2061. WOLFSSL_API int wolfSSL_PEM_def_callback(char* name, int num, int w, void* key);
  2062. WOLFSSL_API long wolfSSL_CTX_sess_accept(WOLFSSL_CTX* ctx);
  2063. WOLFSSL_API long wolfSSL_CTX_sess_connect(WOLFSSL_CTX* ctx);
  2064. WOLFSSL_API long wolfSSL_CTX_sess_accept_good(WOLFSSL_CTX* ctx);
  2065. WOLFSSL_API long wolfSSL_CTX_sess_connect_good(WOLFSSL_CTX* ctx);
  2066. WOLFSSL_API long wolfSSL_CTX_sess_accept_renegotiate(WOLFSSL_CTX* ctx);
  2067. WOLFSSL_API long wolfSSL_CTX_sess_connect_renegotiate(WOLFSSL_CTX* ctx);
  2068. WOLFSSL_API long wolfSSL_CTX_sess_hits(WOLFSSL_CTX* ctx);
  2069. WOLFSSL_API long wolfSSL_CTX_sess_cb_hits(WOLFSSL_CTX* ctx);
  2070. WOLFSSL_API long wolfSSL_CTX_sess_cache_full(WOLFSSL_CTX* ctx);
  2071. WOLFSSL_API long wolfSSL_CTX_sess_misses(WOLFSSL_CTX* ctx);
  2072. WOLFSSL_API long wolfSSL_CTX_sess_timeouts(WOLFSSL_CTX* ctx);
  2073. WOLFSSL_API long wolfSSL_CTX_sess_number(WOLFSSL_CTX* ctx);
  2074. WOLFSSL_API long wolfSSL_CTX_add_extra_chain_cert(WOLFSSL_CTX* ctx, WOLFSSL_X509* x509);
  2075. WOLFSSL_API long wolfSSL_CTX_sess_set_cache_size(WOLFSSL_CTX* ctx, long sz);
  2076. WOLFSSL_API long wolfSSL_CTX_sess_get_cache_size(WOLFSSL_CTX* ctx);
  2077. WOLFSSL_API long wolfSSL_CTX_get_session_cache_mode(WOLFSSL_CTX* ctx);
  2078. WOLFSSL_API int wolfSSL_get_read_ahead(const WOLFSSL* ssl);
  2079. WOLFSSL_API int wolfSSL_set_read_ahead(WOLFSSL* ssl, int v);
  2080. WOLFSSL_API int wolfSSL_CTX_get_read_ahead(WOLFSSL_CTX* ctx);
  2081. WOLFSSL_API int wolfSSL_CTX_set_read_ahead(WOLFSSL_CTX* ctx, int v);
  2082. WOLFSSL_API long wolfSSL_CTX_set_tlsext_status_arg(WOLFSSL_CTX* ctx, void* arg);
  2083. WOLFSSL_API long wolfSSL_CTX_set_tlsext_opaque_prf_input_callback_arg(
  2084. WOLFSSL_CTX* ctx, void* arg);
  2085. WOLFSSL_API int wolfSSL_CTX_add_client_CA(WOLFSSL_CTX* ctx, WOLFSSL_X509* x509);
  2086. WOLFSSL_API int wolfSSL_CTX_set_srp_password(WOLFSSL_CTX* ctx, char* password);
  2087. WOLFSSL_API int wolfSSL_CTX_set_srp_username(WOLFSSL_CTX* ctx, char* username);
  2088. WOLFSSL_API int wolfSSL_CTX_set_srp_strength(WOLFSSL_CTX *ctx, int strength);
  2089. WOLFSSL_API char* wolfSSL_get_srp_username(WOLFSSL *ssl);
  2090. WOLFSSL_API long wolfSSL_set_options(WOLFSSL *s, long op);
  2091. WOLFSSL_API long wolfSSL_get_options(const WOLFSSL *s);
  2092. WOLFSSL_API long wolfSSL_clear_options(WOLFSSL *s, long op);
  2093. WOLFSSL_API long wolfSSL_clear_num_renegotiations(WOLFSSL *s);
  2094. WOLFSSL_API long wolfSSL_total_renegotiations(WOLFSSL *s);
  2095. WOLFSSL_API long wolfSSL_num_renegotiations(WOLFSSL* s);
  2096. WOLFSSL_API int wolfSSL_SSL_renegotiate_pending(WOLFSSL *s);
  2097. WOLFSSL_API long wolfSSL_set_tmp_dh(WOLFSSL *s, WOLFSSL_DH *dh);
  2098. WOLFSSL_API long wolfSSL_set_tlsext_debug_arg(WOLFSSL *s, void *arg);
  2099. WOLFSSL_API long wolfSSL_set_tlsext_status_type(WOLFSSL *s, int type);
  2100. WOLFSSL_API long wolfSSL_get_tlsext_status_type(WOLFSSL *s);
  2101. WOLFSSL_API long wolfSSL_set_tlsext_status_exts(WOLFSSL *s, void *arg);
  2102. WOLFSSL_API long wolfSSL_get_tlsext_status_ids(WOLFSSL *s, void *arg);
  2103. WOLFSSL_API long wolfSSL_set_tlsext_status_ids(WOLFSSL *s, void *arg);
  2104. WOLFSSL_API long wolfSSL_get_tlsext_status_ocsp_resp(WOLFSSL *s, unsigned char **resp);
  2105. WOLFSSL_API long wolfSSL_set_tlsext_status_ocsp_resp(WOLFSSL *s, unsigned char *resp, int len);
  2106. WOLFSSL_API int wolfSSL_set_tlsext_max_fragment_length
  2107. (WOLFSSL *s, unsigned char mode);
  2108. WOLFSSL_API int wolfSSL_CTX_set_tlsext_max_fragment_length
  2109. (WOLFSSL_CTX *c, unsigned char mode);
  2110. WOLFSSL_API void wolfSSL_CONF_modules_unload(int all);
  2111. WOLFSSL_API char* wolfSSL_CONF_get1_default_config_file(void);
  2112. WOLFSSL_API long wolfSSL_get_tlsext_status_exts(WOLFSSL *s, void *arg);
  2113. WOLFSSL_API long wolfSSL_get_verify_result(const WOLFSSL *ssl);
  2114. #define WOLFSSL_DEFAULT_CIPHER_LIST "" /* default all */
  2115. /* These are bit-masks */
  2116. enum {
  2117. WOLFSSL_OCSP_URL_OVERRIDE = 1,
  2118. WOLFSSL_OCSP_NO_NONCE = 2,
  2119. WOLFSSL_OCSP_CHECKALL = 4,
  2120. WOLFSSL_CRL_CHECKALL = 1,
  2121. WOLFSSL_CRL_CHECK = 2,
  2122. };
  2123. /* Separated out from other enums because of size */
  2124. enum {
  2125. WOLFSSL_OP_MICROSOFT_SESS_ID_BUG = 0x00000001,
  2126. WOLFSSL_OP_NETSCAPE_CHALLENGE_BUG = 0x00000002,
  2127. WOLFSSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 0x00000004,
  2128. WOLFSSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = 0x00000008,
  2129. WOLFSSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = 0x00000010,
  2130. WOLFSSL_OP_MSIE_SSLV2_RSA_PADDING = 0x00000020,
  2131. WOLFSSL_OP_SSLEAY_080_CLIENT_DH_BUG = 0x00000040,
  2132. WOLFSSL_OP_TLS_D5_BUG = 0x00000080,
  2133. WOLFSSL_OP_TLS_BLOCK_PADDING_BUG = 0x00000100,
  2134. WOLFSSL_OP_TLS_ROLLBACK_BUG = 0x00000200,
  2135. WOLFSSL_OP_NO_RENEGOTIATION = 0x00000400,
  2136. WOLFSSL_OP_EPHEMERAL_RSA = 0x00000800,
  2137. WOLFSSL_OP_NO_SSLv3 = 0x00001000,
  2138. WOLFSSL_OP_NO_TLSv1 = 0x00002000,
  2139. WOLFSSL_OP_PKCS1_CHECK_1 = 0x00004000,
  2140. WOLFSSL_OP_PKCS1_CHECK_2 = 0x00008000,
  2141. WOLFSSL_OP_NETSCAPE_CA_DN_BUG = 0x00010000,
  2142. WOLFSSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 0x00020000,
  2143. WOLFSSL_OP_SINGLE_DH_USE = 0x00040000,
  2144. WOLFSSL_OP_NO_TICKET = 0x00080000,
  2145. WOLFSSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 0x00100000,
  2146. WOLFSSL_OP_NO_QUERY_MTU = 0x00200000,
  2147. WOLFSSL_OP_COOKIE_EXCHANGE = 0x00400000,
  2148. WOLFSSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = 0x00800000,
  2149. WOLFSSL_OP_SINGLE_ECDH_USE = 0x01000000,
  2150. WOLFSSL_OP_CIPHER_SERVER_PREFERENCE = 0x02000000,
  2151. WOLFSSL_OP_NO_TLSv1_1 = 0x04000000,
  2152. WOLFSSL_OP_NO_TLSv1_2 = 0x08000000,
  2153. WOLFSSL_OP_NO_COMPRESSION = 0x10000000,
  2154. WOLFSSL_OP_NO_TLSv1_3 = 0x20000000,
  2155. WOLFSSL_OP_NO_SSLv2 = 0x40000000,
  2156. WOLFSSL_OP_ALL =
  2157. (WOLFSSL_OP_MICROSOFT_SESS_ID_BUG
  2158. | WOLFSSL_OP_NETSCAPE_CHALLENGE_BUG
  2159. | WOLFSSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
  2160. | WOLFSSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
  2161. | WOLFSSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
  2162. | WOLFSSL_OP_MSIE_SSLV2_RSA_PADDING
  2163. | WOLFSSL_OP_SSLEAY_080_CLIENT_DH_BUG
  2164. | WOLFSSL_OP_TLS_D5_BUG
  2165. | WOLFSSL_OP_TLS_BLOCK_PADDING_BUG
  2166. | WOLFSSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
  2167. | WOLFSSL_OP_TLS_ROLLBACK_BUG),
  2168. };
  2169. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \
  2170. defined(HAVE_WEBSERVER) || defined(HAVE_MEMCACHED)
  2171. /* for compatibility these must be macros */
  2172. #define SSL_OP_MICROSOFT_SESS_ID_BUG WOLFSSL_OP_MICROSOFT_SESS_ID_BUG
  2173. #define SSL_OP_NETSCAPE_CHALLENGE_BUG WOLFSSL_OP_NETSCAPE_CHALLENGE_BUG
  2174. #define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG WOLFSSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
  2175. #define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG WOLFSSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
  2176. #define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER WOLFSSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
  2177. #define SSL_OP_MSIE_SSLV2_RSA_PADDING WOLFSSL_OP_MSIE_SSLV2_RSA_PADDING
  2178. #define SSL_OP_SSLEAY_080_CLIENT_DH_BUG WOLFSSL_OP_SSLEAY_080_CLIENT_DH_BUG
  2179. #define SSL_OP_TLS_D5_BUG WOLFSSL_OP_TLS_D5_BUG
  2180. #define SSL_OP_TLS_BLOCK_PADDING_BUG WOLFSSL_OP_TLS_BLOCK_PADDING_BUG
  2181. #define SSL_OP_TLS_ROLLBACK_BUG WOLFSSL_OP_TLS_ROLLBACK_BUG
  2182. #define SSL_OP_EPHEMERAL_RSA WOLFSSL_OP_EPHEMERAL_RSA
  2183. #define SSL_OP_PKCS1_CHECK_1 WOLFSSL_OP_PKCS1_CHECK_1
  2184. #define SSL_OP_PKCS1_CHECK_2 WOLFSSL_OP_PKCS1_CHECK_2
  2185. #define SSL_OP_NETSCAPE_CA_DN_BUG WOLFSSL_OP_NETSCAPE_CA_DN_BUG
  2186. #define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG WOLFSSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
  2187. #define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS WOLFSSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
  2188. #define SSL_OP_NO_QUERY_MTU WOLFSSL_OP_NO_QUERY_MTU
  2189. #define SSL_OP_COOKIE_EXCHANGE WOLFSSL_OP_COOKIE_EXCHANGE
  2190. #define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION \
  2191. WOLFSSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
  2192. #define SSL_OP_ALL WOLFSSL_OP_ALL
  2193. #define SSL_OP_NO_SSLv2 WOLFSSL_OP_NO_SSLv2
  2194. #define SSL_OP_NO_SSLv3 WOLFSSL_OP_NO_SSLv3
  2195. #define SSL_OP_NO_TLSv1 WOLFSSL_OP_NO_TLSv1
  2196. #define SSL_OP_NO_TLSv1_1 WOLFSSL_OP_NO_TLSv1_1
  2197. #define SSL_OP_NO_TLSv1_2 WOLFSSL_OP_NO_TLSv1_2
  2198. #define SSL_OP_NO_COMPRESSION WOLFSSL_OP_NO_COMPRESSION
  2199. /* apache uses SSL_OP_NO_TLSv1_3 to determine if TLS 1.3 is enabled */
  2200. #if !(!defined(WOLFSSL_TLS13) && defined(WOLFSSL_APACHE_HTTPD))
  2201. #define SSL_OP_NO_TLSv1_3 WOLFSSL_OP_NO_TLSv1_3
  2202. #endif
  2203. #ifdef HAVE_SESSION_TICKET
  2204. #define SSL_OP_NO_TICKET WOLFSSL_OP_NO_TICKET
  2205. #endif
  2206. #define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | \
  2207. SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3)
  2208. #define SSL_NOTHING 1
  2209. #define SSL_WRITING 2
  2210. #define SSL_READING 3
  2211. #define SSL_MAX_SSL_SESSION_ID_LENGTH 32 /* = ID_LEN */
  2212. enum {
  2213. #ifdef HAVE_OCSP
  2214. /* OCSP Flags */
  2215. OCSP_NOCERTS = 1,
  2216. OCSP_NOINTERN = 2,
  2217. OCSP_NOSIGS = 4,
  2218. OCSP_NOCHAIN = 8,
  2219. OCSP_NOVERIFY = 16,
  2220. OCSP_NOEXPLICIT = 32,
  2221. OCSP_NOCASIGN = 64,
  2222. OCSP_NODELEGATED = 128,
  2223. OCSP_NOCHECKS = 256,
  2224. OCSP_TRUSTOTHER = 512,
  2225. OCSP_RESPID_KEY = 1024,
  2226. OCSP_NOTIME = 2048,
  2227. #endif
  2228. SSL_ST_CONNECT = 0x1000,
  2229. SSL_ST_ACCEPT = 0x2000,
  2230. SSL_ST_MASK = 0x0FFF,
  2231. SSL_CB_LOOP = 0x01,
  2232. SSL_CB_EXIT = 0x02,
  2233. SSL_CB_READ = 0x04,
  2234. SSL_CB_WRITE = 0x08,
  2235. SSL_CB_HANDSHAKE_START = 0x10,
  2236. SSL_CB_HANDSHAKE_DONE = 0x20,
  2237. SSL_CB_ALERT = 0x4000,
  2238. SSL_CB_READ_ALERT = (SSL_CB_ALERT | SSL_CB_READ),
  2239. SSL_CB_WRITE_ALERT = (SSL_CB_ALERT | SSL_CB_WRITE),
  2240. SSL_CB_ACCEPT_LOOP = (SSL_ST_ACCEPT | SSL_CB_LOOP),
  2241. SSL_CB_ACCEPT_EXIT = (SSL_ST_ACCEPT | SSL_CB_EXIT),
  2242. SSL_CB_CONNECT_LOOP = (SSL_ST_CONNECT | SSL_CB_LOOP),
  2243. SSL_CB_CONNECT_EXIT = (SSL_ST_CONNECT | SSL_CB_EXIT),
  2244. SSL_CB_MODE_READ = 1,
  2245. SSL_CB_MODE_WRITE = 2,
  2246. SSL_MODE_ENABLE_PARTIAL_WRITE = 2,
  2247. SSL_MODE_AUTO_RETRY = 3, /* wolfSSL default is to return WANT_{READ|WRITE}
  2248. * to the user. This is set by default with
  2249. * OPENSSL_COMPATIBLE_DEFAULTS. The macro
  2250. * WOLFSSL_MODE_AUTO_RETRY_ATTEMPTS is used to
  2251. * limit the possibility of an infinite retry loop
  2252. */
  2253. SSL_MODE_RELEASE_BUFFERS = -1, /* For libwebsockets build. No current use. */
  2254. /* Errors used in wolfSSL. utilize the values from the defines in
  2255. * wolfssl/openssl/x509.h, but without the WOLFSSL_ prefix.
  2256. */
  2257. WOLFSSL_X509_V_OK = 0,
  2258. WOLFSSL_X509_V_ERR_CERT_SIGNATURE_FAILURE = 7,
  2259. WOLFSSL_X509_V_ERR_CERT_NOT_YET_VALID = 9,
  2260. WOLFSSL_X509_V_ERR_CERT_HAS_EXPIRED = 10,
  2261. WOLFSSL_X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13,
  2262. WOLFSSL_X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14,
  2263. WOLFSSL_X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18,
  2264. WOLFSSL_X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20,
  2265. WOLFSSL_X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21,
  2266. WOLFSSL_X509_V_ERR_CERT_CHAIN_TOO_LONG = 22,
  2267. WOLFSSL_X509_V_ERR_CERT_REVOKED = 23,
  2268. WOLFSSL_X509_V_ERR_INVALID_CA = 24,
  2269. WOLFSSL_X509_V_ERR_PATH_LENGTH_EXCEEDED = 25,
  2270. WOLFSSL_X509_V_ERR_CERT_REJECTED = 28,
  2271. WOLFSSL_X509_V_ERR_SUBJECT_ISSUER_MISMATCH = 29,
  2272. CRYPTO_LOCK = 1,
  2273. CRYPTO_NUM_LOCKS = 10,
  2274. ASN1_STRFLGS_ESC_MSB = 4
  2275. };
  2276. #endif
  2277. /* extras end */
  2278. #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
  2279. /* wolfSSL extension, provide last error from SSL_get_error
  2280. since not using thread storage error queue */
  2281. #ifdef FUSION_RTOS
  2282. #include <fclstdio.h>
  2283. #else
  2284. #include <stdio.h>
  2285. #endif
  2286. WOLFSSL_API void wolfSSL_ERR_print_errors_fp(XFILE fp, int err);
  2287. #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
  2288. WOLFSSL_API void wolfSSL_ERR_dump_errors_fp(XFILE fp);
  2289. WOLFSSL_API void wolfSSL_ERR_print_errors_cb(int (*cb)(const char *str,
  2290. size_t len, void *u), void *u);
  2291. #endif
  2292. #endif
  2293. WOLFSSL_API void wolfSSL_ERR_print_errors(WOLFSSL_BIO *bio);
  2294. #ifndef NO_OLD_SSL_NAMES
  2295. #define SSL_ERROR_NONE WOLFSSL_ERROR_NONE
  2296. #define SSL_FAILURE WOLFSSL_FAILURE
  2297. #define SSL_SUCCESS WOLFSSL_SUCCESS
  2298. #define SSL_SHUTDOWN_NOT_DONE WOLFSSL_SHUTDOWN_NOT_DONE
  2299. #define SSL_ALPN_NOT_FOUND WOLFSSL_ALPN_NOT_FOUND
  2300. #define SSL_BAD_CERTTYPE WOLFSSL_BAD_CERTTYPE
  2301. #define SSL_BAD_STAT WOLFSSL_BAD_STAT
  2302. #define SSL_BAD_PATH WOLFSSL_BAD_PATH
  2303. #define SSL_BAD_FILETYPE WOLFSSL_BAD_FILETYPE
  2304. #define SSL_BAD_FILE WOLFSSL_BAD_FILE
  2305. #define SSL_NOT_IMPLEMENTED WOLFSSL_NOT_IMPLEMENTED
  2306. #define SSL_UNKNOWN WOLFSSL_UNKNOWN
  2307. #define SSL_FATAL_ERROR WOLFSSL_FATAL_ERROR
  2308. #define SSL_FILETYPE_ASN1 WOLFSSL_FILETYPE_ASN1
  2309. #define SSL_FILETYPE_PEM WOLFSSL_FILETYPE_PEM
  2310. #define SSL_FILETYPE_DEFAULT WOLFSSL_FILETYPE_DEFAULT
  2311. #define SSL_VERIFY_NONE WOLFSSL_VERIFY_NONE
  2312. #define SSL_VERIFY_PEER WOLFSSL_VERIFY_PEER
  2313. #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT
  2314. #define SSL_VERIFY_CLIENT_ONCE WOLFSSL_VERIFY_CLIENT_ONCE
  2315. #define SSL_VERIFY_POST_HANDSHAKE WOLFSSL_VERIFY_POST_HANDSHAKE
  2316. #define SSL_VERIFY_FAIL_EXCEPT_PSK WOLFSSL_VERIFY_FAIL_EXCEPT_PSK
  2317. #define SSL_SESS_CACHE_OFF WOLFSSL_SESS_CACHE_OFF
  2318. #define SSL_SESS_CACHE_CLIENT WOLFSSL_SESS_CACHE_CLIENT
  2319. #define SSL_SESS_CACHE_SERVER WOLFSSL_SESS_CACHE_SERVER
  2320. #define SSL_SESS_CACHE_BOTH WOLFSSL_SESS_CACHE_BOTH
  2321. #define SSL_SESS_CACHE_NO_AUTO_CLEAR WOLFSSL_SESS_CACHE_NO_AUTO_CLEAR
  2322. #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP WOLFSSL_SESS_CACHE_NO_INTERNAL_LOOKUP
  2323. #define SSL_SESS_CACHE_NO_INTERNAL_STORE WOLFSSL_SESS_CACHE_NO_INTERNAL_STORE
  2324. #define SSL_SESS_CACHE_NO_INTERNAL WOLFSSL_SESS_CACHE_NO_INTERNAL
  2325. #define SSL_ERROR_WANT_READ WOLFSSL_ERROR_WANT_READ
  2326. #define SSL_ERROR_WANT_WRITE WOLFSSL_ERROR_WANT_WRITE
  2327. #define SSL_ERROR_WANT_CONNECT WOLFSSL_ERROR_WANT_CONNECT
  2328. #define SSL_ERROR_WANT_ACCEPT WOLFSSL_ERROR_WANT_ACCEPT
  2329. #define SSL_ERROR_SYSCALL WOLFSSL_ERROR_SYSCALL
  2330. #define SSL_ERROR_WANT_X509_LOOKUP WOLFSSL_ERROR_WANT_X509_LOOKUP
  2331. #define SSL_ERROR_ZERO_RETURN WOLFSSL_ERROR_ZERO_RETURN
  2332. #define SSL_ERROR_SSL WOLFSSL_ERROR_SSL
  2333. #define SSL_SENT_SHUTDOWN WOLFSSL_SENT_SHUTDOWN
  2334. #define SSL_RECEIVED_SHUTDOWN WOLFSSL_RECEIVED_SHUTDOWN
  2335. #define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER WOLFSSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
  2336. #define SSL_R_SSL_HANDSHAKE_FAILURE WOLFSSL_R_SSL_HANDSHAKE_FAILURE
  2337. #define SSL_R_TLSV1_ALERT_UNKNOWN_CA WOLFSSL_R_TLSV1_ALERT_UNKNOWN_CA
  2338. #define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN WOLFSSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN
  2339. #define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE WOLFSSL_R_SSLV3_ALERT_BAD_CERTIFICATE
  2340. #endif
  2341. enum { /* ssl Constants */
  2342. WOLFSSL_ERROR_NONE = 0, /* for most functions */
  2343. WOLFSSL_FAILURE = 0, /* for some functions */
  2344. #if defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES) && \
  2345. (defined(BUILDING_WOLFSSL) || \
  2346. defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES_ALWAYS))
  2347. #define WOLFSSL_FAILURE WC_ERR_TRACE(WOLFSSL_FAILURE)
  2348. #define CONST_NUM_ERR_WOLFSSL_FAILURE 0
  2349. #endif
  2350. WOLFSSL_SUCCESS = 1,
  2351. /* WOLFSSL_SHUTDOWN_NOT_DONE is returned by wolfSSL_shutdown and
  2352. * wolfSSL_SendUserCanceled when the other end
  2353. * of the connection has yet to send its close notify alert as part of the
  2354. * bidirectional shutdown. To complete the shutdown, either keep calling
  2355. * wolfSSL_shutdown until it returns WOLFSSL_SUCCESS or call wolfSSL_read until
  2356. * it returns <= 0 AND SSL_get_error returns SSL_ERROR_ZERO_RETURN. See OpenSSL
  2357. * docs for more: https://www.openssl.org/docs/man1.1.1/man3/SSL_shutdown.html
  2358. */
  2359. #ifdef WOLFSSL_ERROR_CODE_OPENSSL
  2360. /* SSL_shutdown returns 0 when not done, per OpenSSL documentation. */
  2361. WOLFSSL_SHUTDOWN_NOT_DONE = 0,
  2362. #else
  2363. WOLFSSL_SHUTDOWN_NOT_DONE = 2,
  2364. #endif
  2365. WOLFSSL_FILETYPE_ASN1 = CTC_FILETYPE_ASN1,
  2366. WOLFSSL_FILETYPE_PEM = CTC_FILETYPE_PEM,
  2367. WOLFSSL_FILETYPE_DEFAULT = CTC_FILETYPE_ASN1, /* ASN1 */
  2368. WOLFSSL_VERIFY_NONE = 0,
  2369. WOLFSSL_VERIFY_PEER = 1 << 0,
  2370. WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT = 1 << 1,
  2371. WOLFSSL_VERIFY_CLIENT_ONCE = 1 << 2,
  2372. WOLFSSL_VERIFY_POST_HANDSHAKE = 1 << 3,
  2373. WOLFSSL_VERIFY_FAIL_EXCEPT_PSK = 1 << 4,
  2374. WOLFSSL_VERIFY_DEFAULT = 1 << 9,
  2375. WOLFSSL_SESS_CACHE_OFF = 0x0000,
  2376. WOLFSSL_SESS_CACHE_CLIENT = 0x0001,
  2377. WOLFSSL_SESS_CACHE_SERVER = 0x0002,
  2378. WOLFSSL_SESS_CACHE_BOTH = 0x0003,
  2379. WOLFSSL_SESS_CACHE_NO_AUTO_CLEAR = 0x0008,
  2380. WOLFSSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 0x0100,
  2381. WOLFSSL_SESS_CACHE_NO_INTERNAL_STORE = 0x0200,
  2382. WOLFSSL_SESS_CACHE_NO_INTERNAL =
  2383. (WOLFSSL_SESS_CACHE_NO_INTERNAL_STORE |
  2384. WOLFSSL_SESS_CACHE_NO_INTERNAL_LOOKUP),
  2385. /* These values match OpenSSL values for corresponding names. */
  2386. WOLFSSL_ERROR_SSL = 1,
  2387. WOLFSSL_ERROR_WANT_READ = 2,
  2388. WOLFSSL_ERROR_WANT_WRITE = 3,
  2389. WOLFSSL_ERROR_WANT_X509_LOOKUP = 4,
  2390. WOLFSSL_ERROR_SYSCALL = 5,
  2391. WOLFSSL_ERROR_ZERO_RETURN = 6,
  2392. WOLFSSL_ERROR_WANT_CONNECT = 7,
  2393. WOLFSSL_ERROR_WANT_ACCEPT = 8,
  2394. WOLFSSL_SENT_SHUTDOWN = 1,
  2395. WOLFSSL_RECEIVED_SHUTDOWN = 2,
  2396. WOLFSSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = 4,
  2397. WOLFSSL_R_SSL_HANDSHAKE_FAILURE = 101,
  2398. WOLFSSL_R_TLSV1_ALERT_UNKNOWN_CA = 102,
  2399. WOLFSSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN = 103,
  2400. WOLFSSL_R_SSLV3_ALERT_BAD_CERTIFICATE = 104,
  2401. WOLF_PEM_BUFSIZE = 1024
  2402. };
  2403. #ifndef NO_PSK
  2404. typedef unsigned int (*wc_psk_client_callback)(WOLFSSL* ssl, const char*, char*,
  2405. unsigned int, unsigned char*, unsigned int);
  2406. WOLFSSL_API void wolfSSL_CTX_set_psk_client_callback(WOLFSSL_CTX* ctx,
  2407. wc_psk_client_callback cb);
  2408. WOLFSSL_API void wolfSSL_set_psk_client_callback(WOLFSSL* ssl,
  2409. wc_psk_client_callback cb);
  2410. #ifdef OPENSSL_EXTRA
  2411. typedef int (*wc_psk_use_session_cb_func)(WOLFSSL* ssl,
  2412. const WOLFSSL_EVP_MD* md, const unsigned char **id,
  2413. size_t* idlen, WOLFSSL_SESSION **sess);
  2414. WOLFSSL_API void wolfSSL_set_psk_use_session_callback(WOLFSSL* ssl,
  2415. wc_psk_use_session_cb_func cb);
  2416. #endif
  2417. #ifdef WOLFSSL_TLS13
  2418. typedef unsigned int (*wc_psk_client_cs_callback)(WOLFSSL* ssl, const char*,
  2419. char*, unsigned int, unsigned char*, unsigned int, const char*);
  2420. WOLFSSL_API void wolfSSL_CTX_set_psk_client_cs_callback(WOLFSSL_CTX* ctx,
  2421. wc_psk_client_cs_callback cb);
  2422. WOLFSSL_API void wolfSSL_set_psk_client_cs_callback(WOLFSSL* ssl,
  2423. wc_psk_client_cs_callback cb);
  2424. typedef unsigned int (*wc_psk_client_tls13_callback)(WOLFSSL* ssl, const char*,
  2425. char*, unsigned int, unsigned char*, unsigned int, const char**);
  2426. WOLFSSL_API void wolfSSL_CTX_set_psk_client_tls13_callback(WOLFSSL_CTX* ctx,
  2427. wc_psk_client_tls13_callback cb);
  2428. WOLFSSL_API void wolfSSL_set_psk_client_tls13_callback(WOLFSSL* ssl,
  2429. wc_psk_client_tls13_callback cb);
  2430. #endif
  2431. WOLFSSL_API const char* wolfSSL_get_psk_identity_hint(const WOLFSSL* ssl);
  2432. WOLFSSL_API const char* wolfSSL_get_psk_identity(const WOLFSSL* ssl);
  2433. WOLFSSL_API int wolfSSL_CTX_use_psk_identity_hint(WOLFSSL_CTX* ctx, const char* hint);
  2434. WOLFSSL_API int wolfSSL_use_psk_identity_hint(WOLFSSL* ssl, const char* hint);
  2435. typedef unsigned int (*wc_psk_server_callback)(WOLFSSL* ssl, const char*,
  2436. unsigned char*, unsigned int);
  2437. WOLFSSL_API void wolfSSL_CTX_set_psk_server_callback(WOLFSSL_CTX* ctx,
  2438. wc_psk_server_callback cb);
  2439. WOLFSSL_API void wolfSSL_set_psk_server_callback(WOLFSSL* ssl,
  2440. wc_psk_server_callback cb);
  2441. #ifdef WOLFSSL_TLS13
  2442. typedef unsigned int (*wc_psk_server_tls13_callback)(WOLFSSL* ssl, const char*,
  2443. unsigned char*, unsigned int, const char**);
  2444. WOLFSSL_API void wolfSSL_CTX_set_psk_server_tls13_callback(WOLFSSL_CTX* ctx,
  2445. wc_psk_server_tls13_callback cb);
  2446. WOLFSSL_API void wolfSSL_set_psk_server_tls13_callback(WOLFSSL* ssl,
  2447. wc_psk_server_tls13_callback cb);
  2448. #endif
  2449. WOLFSSL_API void* wolfSSL_get_psk_callback_ctx(WOLFSSL* ssl);
  2450. WOLFSSL_API int wolfSSL_set_psk_callback_ctx(WOLFSSL* ssl, void* psk_ctx);
  2451. WOLFSSL_API void* wolfSSL_CTX_get_psk_callback_ctx(WOLFSSL_CTX* ctx);
  2452. WOLFSSL_API int wolfSSL_CTX_set_psk_callback_ctx(WOLFSSL_CTX* ctx, void* psk_ctx);
  2453. #define PSK_TYPES_DEFINED
  2454. #ifdef WOLFSSL_TLS13
  2455. WOLFSSL_API const char* wolfSSL_get_cipher_name_by_hash(WOLFSSL* ssl,
  2456. const char* hash);
  2457. #endif
  2458. #endif /* NO_PSK */
  2459. #ifdef HAVE_ANON
  2460. WOLFSSL_API int wolfSSL_CTX_allow_anon_cipher(WOLFSSL_CTX* ctx);
  2461. #endif /* HAVE_ANON */
  2462. /* extra begins */
  2463. #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
  2464. enum { /* ERR Constants */
  2465. ERR_TXT_STRING = 1
  2466. };
  2467. #endif
  2468. #ifdef OPENSSL_EXTRA
  2469. /* bio misc */
  2470. enum {
  2471. WOLFSSL_BIO_ERROR = -1,
  2472. WOLFSSL_BIO_UNSET = -2,
  2473. WOLFSSL_BIO_SIZE = 17000 /* default BIO write size if not set */
  2474. };
  2475. #endif
  2476. WOLFSSL_API void wolfSSL_ERR_put_error(int lib, int fun, int err,
  2477. const char* file, int line);
  2478. WOLFSSL_API unsigned long wolfSSL_ERR_get_error_line(const char** file, int* line);
  2479. WOLFSSL_API unsigned long wolfSSL_ERR_get_error_line_data(const char** file, int* line,
  2480. const char** data, int* flags);
  2481. WOLFSSL_API unsigned long wolfSSL_ERR_get_error(void);
  2482. WOLFSSL_API void wolfSSL_ERR_clear_error(void);
  2483. WOLFSSL_API int wolfSSL_RAND_status(void);
  2484. WOLFSSL_API int wolfSSL_RAND_pseudo_bytes(unsigned char* buf, int num);
  2485. WOLFSSL_API int wolfSSL_RAND_bytes(unsigned char* buf, int num);
  2486. WOLFSSL_API long wolfSSL_CTX_set_options(WOLFSSL_CTX* ctx, long opt);
  2487. WOLFSSL_API long wolfSSL_CTX_get_options(WOLFSSL_CTX* ctx);
  2488. WOLFSSL_API long wolfSSL_CTX_clear_options(WOLFSSL_CTX* ctx, long opt);
  2489. #if !defined(NO_CHECK_PRIVATE_KEY)
  2490. WOLFSSL_API int wolfSSL_CTX_check_private_key(const WOLFSSL_CTX* ctx);
  2491. #endif
  2492. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_CTX_get0_privatekey(const WOLFSSL_CTX* ctx);
  2493. WOLFSSL_API void wolfSSL_ERR_free_strings(void);
  2494. WOLFSSL_API void wolfSSL_ERR_remove_state(unsigned long id);
  2495. WOLFSSL_API int wolfSSL_clear(WOLFSSL* ssl);
  2496. WOLFSSL_API int wolfSSL_state(WOLFSSL* ssl);
  2497. WOLFSSL_API void wolfSSL_cleanup_all_ex_data(void);
  2498. WOLFSSL_API long wolfSSL_CTX_set_mode(WOLFSSL_CTX* ctx, long mode);
  2499. WOLFSSL_API long wolfSSL_CTX_clear_mode(WOLFSSL_CTX* ctx, long mode);
  2500. WOLFSSL_API long wolfSSL_CTX_get_mode(WOLFSSL_CTX* ctx);
  2501. WOLFSSL_API void wolfSSL_CTX_set_default_read_ahead(WOLFSSL_CTX* ctx, int m);
  2502. WOLFSSL_API long wolfSSL_SSL_get_mode(WOLFSSL* ssl);
  2503. WOLFSSL_API int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx);
  2504. WOLFSSL_API const char* wolfSSL_X509_get_default_cert_file_env(void);
  2505. WOLFSSL_API const char* wolfSSL_X509_get_default_cert_file(void);
  2506. WOLFSSL_API const char* wolfSSL_X509_get_default_cert_dir_env(void);
  2507. WOLFSSL_API const char* wolfSSL_X509_get_default_cert_dir(void);
  2508. WOLFSSL_API int wolfSSL_CTX_set_session_id_context(WOLFSSL_CTX* ctx,
  2509. const unsigned char* sid_ctx, unsigned int sid_ctx_len);
  2510. WOLFSSL_ABI WOLFSSL_API WOLFSSL_X509* wolfSSL_get_peer_certificate(WOLFSSL* ssl);
  2511. #ifdef OPENSSL_EXTRA
  2512. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_get_peer_cert_chain(const WOLFSSL* ssl);
  2513. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_set_peer_cert_chain(WOLFSSL* ssl);
  2514. #endif
  2515. #ifdef OPENSSL_EXTRA
  2516. WOLFSSL_API int wolfSSL_want(WOLFSSL* ssl);
  2517. #endif
  2518. WOLFSSL_API int wolfSSL_want_read(WOLFSSL* ssl);
  2519. WOLFSSL_API int wolfSSL_want_write(WOLFSSL* ssl);
  2520. #include <stdarg.h> /* var_arg */
  2521. WOLFSSL_API int wolfSSL_BIO_vprintf(WOLFSSL_BIO* bio, const char* format,
  2522. va_list args);
  2523. WOLFSSL_API int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...);
  2524. WOLFSSL_API int wolfSSL_BIO_dump(WOLFSSL_BIO *bio, const char* buf, int length);
  2525. WOLFSSL_API int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO* bio,
  2526. const WOLFSSL_ASN1_UTCTIME* a);
  2527. WOLFSSL_API int wolfSSL_ASN1_GENERALIZEDTIME_print(WOLFSSL_BIO* bio,
  2528. const WOLFSSL_ASN1_GENERALIZEDTIME* asnTime);
  2529. WOLFSSL_API void wolfSSL_ASN1_GENERALIZEDTIME_free(WOLFSSL_ASN1_GENERALIZEDTIME*);
  2530. WOLFSSL_API int wolfSSL_ASN1_TIME_check(const WOLFSSL_ASN1_TIME* a);
  2531. WOLFSSL_API int wolfSSL_ASN1_TIME_diff(int* days, int* secs, const WOLFSSL_ASN1_TIME* from,
  2532. const WOLFSSL_ASN1_TIME* to);
  2533. WOLFSSL_API int wolfSSL_ASN1_TIME_compare(const WOLFSSL_ASN1_TIME *a,
  2534. const WOLFSSL_ASN1_TIME *b);
  2535. #ifdef OPENSSL_EXTRA
  2536. WOLFSSL_API WOLFSSL_ASN1_TIME *wolfSSL_ASN1_TIME_set(WOLFSSL_ASN1_TIME *s, time_t t);
  2537. WOLFSSL_API int wolfSSL_ASN1_TIME_set_string(WOLFSSL_ASN1_TIME *s, const char *str);
  2538. WOLFSSL_API int wolfSSL_ASN1_TIME_set_string_X509(WOLFSSL_ASN1_TIME *t,
  2539. const char *str);
  2540. #endif
  2541. WOLFSSL_API int wolfSSL_sk_num(const WOLFSSL_STACK* sk);
  2542. WOLFSSL_API void* wolfSSL_sk_value(const WOLFSSL_STACK* sk, int i);
  2543. #if defined(HAVE_EX_DATA) || defined(WOLFSSL_WPAS_SMALL)
  2544. WOLFSSL_API void* wolfSSL_CRYPTO_get_ex_data(const WOLFSSL_CRYPTO_EX_DATA* ex_data,
  2545. int idx);
  2546. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  2547. WOLFSSL_API int wolfSSL_CRYPTO_set_ex_data_with_cleanup(
  2548. WOLFSSL_CRYPTO_EX_DATA* ex_data,
  2549. int idx,
  2550. void *data,
  2551. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  2552. #endif
  2553. WOLFSSL_API int wolfSSL_CRYPTO_set_ex_data(WOLFSSL_CRYPTO_EX_DATA* ex_data, int idx,
  2554. void *data);
  2555. #endif
  2556. /* stunnel 4.28 needs */
  2557. WOLFSSL_API void* wolfSSL_CTX_get_ex_data(const WOLFSSL_CTX* ctx, int idx);
  2558. WOLFSSL_API int wolfSSL_CTX_set_ex_data(WOLFSSL_CTX* ctx, int idx, void* data);
  2559. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  2560. WOLFSSL_API int wolfSSL_CTX_set_ex_data_with_cleanup(
  2561. WOLFSSL_CTX* ctx,
  2562. int idx,
  2563. void* data,
  2564. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  2565. #endif
  2566. WOLFSSL_API void wolfSSL_CTX_sess_set_get_cb(WOLFSSL_CTX* ctx,
  2567. WOLFSSL_SESSION*(*f)(WOLFSSL* ssl, const unsigned char*, int, int*));
  2568. WOLFSSL_API void wolfSSL_CTX_sess_set_new_cb(WOLFSSL_CTX* ctx,
  2569. int (*f)(WOLFSSL* ssl, WOLFSSL_SESSION*));
  2570. WOLFSSL_API void wolfSSL_CTX_sess_set_remove_cb(WOLFSSL_CTX* ctx,
  2571. void (*f)(WOLFSSL_CTX* ctx, WOLFSSL_SESSION*));
  2572. WOLFSSL_API int wolfSSL_i2d_SSL_SESSION(WOLFSSL_SESSION* sess,unsigned char** p);
  2573. WOLFSSL_API WOLFSSL_SESSION* wolfSSL_d2i_SSL_SESSION(WOLFSSL_SESSION** sess,
  2574. const unsigned char** p, long i);
  2575. WOLFSSL_API int wolfSSL_SESSION_has_ticket(const WOLFSSL_SESSION* session);
  2576. WOLFSSL_API unsigned long wolfSSL_SESSION_get_ticket_lifetime_hint(
  2577. const WOLFSSL_SESSION* sess);
  2578. WOLFSSL_API long wolfSSL_SESSION_get_timeout(const WOLFSSL_SESSION* session);
  2579. WOLFSSL_API long wolfSSL_SESSION_get_time(const WOLFSSL_SESSION* session);
  2580. #ifdef HAVE_EX_DATA
  2581. WOLFSSL_API int wolfSSL_CTX_get_ex_new_index(long idx, void* arg,
  2582. WOLFSSL_CRYPTO_EX_new* new_func,
  2583. WOLFSSL_CRYPTO_EX_dup* dup_func,
  2584. WOLFSSL_CRYPTO_EX_free* free_func);
  2585. #endif
  2586. /* extra ends */
  2587. /* wolfSSL extensions */
  2588. /* call before SSL_connect, if verifying will add name check to
  2589. date check and signature check */
  2590. WOLFSSL_ABI WOLFSSL_API int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn);
  2591. #if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)
  2592. WOLFSSL_API const char *wolfSSL_get0_peername(WOLFSSL *ssl);
  2593. #endif
  2594. /* need to call once to load library (session cache) */
  2595. WOLFSSL_ABI WOLFSSL_API int wolfSSL_Init(void);
  2596. /* call when done to cleanup/free session cache mutex / resources */
  2597. WOLFSSL_ABI WOLFSSL_API int wolfSSL_Cleanup(void);
  2598. /* which library version do we have */
  2599. WOLFSSL_API const char* wolfSSL_lib_version(void);
  2600. #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
  2601. WOLFSSL_API const char* wolfSSL_OpenSSL_version(int a);
  2602. #else
  2603. WOLFSSL_API const char* wolfSSL_OpenSSL_version(void);
  2604. #endif
  2605. /* which library version do we have in hex */
  2606. WOLFSSL_API word32 wolfSSL_lib_version_hex(void);
  2607. /* do accept or connect depedning on side */
  2608. WOLFSSL_API int wolfSSL_negotiate(WOLFSSL* ssl);
  2609. /* turn on wolfSSL data compression */
  2610. WOLFSSL_API int wolfSSL_set_compression(WOLFSSL* ssl);
  2611. WOLFSSL_ABI WOLFSSL_API int wolfSSL_set_timeout(WOLFSSL* ssl, unsigned int to);
  2612. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_set_timeout(WOLFSSL_CTX* ctx, unsigned int to);
  2613. WOLFSSL_API void wolfSSL_CTX_set_current_time_cb(WOLFSSL_CTX* ctx,
  2614. void (*cb)(const WOLFSSL* ssl, WOLFSSL_TIMEVAL* out_clock));
  2615. /* get wolfSSL peer X509_CHAIN */
  2616. WOLFSSL_API WOLFSSL_X509_CHAIN* wolfSSL_get_peer_chain(WOLFSSL* ssl);
  2617. #ifdef WOLFSSL_ALT_CERT_CHAINS
  2618. WOLFSSL_API int wolfSSL_is_peer_alt_cert_chain(const WOLFSSL* ssl);
  2619. /* get wolfSSL alternate peer X509_CHAIN */
  2620. WOLFSSL_API WOLFSSL_X509_CHAIN* wolfSSL_get_peer_alt_chain(WOLFSSL* ssl);
  2621. #endif
  2622. /* peer chain count */
  2623. WOLFSSL_API int wolfSSL_get_chain_count(WOLFSSL_X509_CHAIN* chain);
  2624. /* index cert length */
  2625. WOLFSSL_API int wolfSSL_get_chain_length(WOLFSSL_X509_CHAIN* chain, int idx);
  2626. /* index cert */
  2627. WOLFSSL_API unsigned char* wolfSSL_get_chain_cert(WOLFSSL_X509_CHAIN* chain, int idx);
  2628. /* index cert in X509 */
  2629. WOLFSSL_API WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx);
  2630. /* free X509 */
  2631. #define wolfSSL_FreeX509(x509) wolfSSL_X509_free((x509))
  2632. WOLFSSL_ABI WOLFSSL_API void wolfSSL_X509_free(WOLFSSL_X509* x509);
  2633. /* get index cert in PEM */
  2634. WOLFSSL_API int wolfSSL_get_chain_cert_pem(WOLFSSL_X509_CHAIN* chain, int idx,
  2635. unsigned char* buf, int inLen, int* outLen);
  2636. WOLFSSL_ABI WOLFSSL_API const unsigned char* wolfSSL_get_sessionID(
  2637. const WOLFSSL_SESSION* s);
  2638. WOLFSSL_API int wolfSSL_X509_get_serial_number(WOLFSSL_X509* x509,unsigned char* in,int* inOutSz);
  2639. WOLFSSL_API char* wolfSSL_X509_get_subjectCN(WOLFSSL_X509* x509);
  2640. WOLFSSL_API const unsigned char* wolfSSL_X509_get_der(WOLFSSL_X509* x509, int* outSz);
  2641. WOLFSSL_API const unsigned char* wolfSSL_X509_get_tbs(WOLFSSL_X509* x509, int* outSz);
  2642. WOLFSSL_ABI WOLFSSL_API const byte* wolfSSL_X509_notBefore(WOLFSSL_X509* x509);
  2643. WOLFSSL_ABI WOLFSSL_API const byte* wolfSSL_X509_notAfter(WOLFSSL_X509* x509);
  2644. WOLFSSL_API int wolfSSL_X509_version(WOLFSSL_X509* x509);
  2645. WOLFSSL_API int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char* fname);
  2646. WOLFSSL_ABI WOLFSSL_API char* wolfSSL_X509_get_next_altname(WOLFSSL_X509* cert);
  2647. WOLFSSL_API int wolfSSL_X509_add_altname_ex(WOLFSSL_X509* x509, const char* name, word32 nameSz, int type);
  2648. WOLFSSL_API int wolfSSL_X509_add_altname(WOLFSSL_X509* x509, const char* name, int type);
  2649. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509(WOLFSSL_X509** x509,
  2650. const unsigned char** in, int len);
  2651. WOLFSSL_API WOLFSSL_X509*
  2652. wolfSSL_X509_d2i(WOLFSSL_X509** x509, const unsigned char* in, int len);
  2653. WOLFSSL_API WOLFSSL_X509*
  2654. wolfSSL_X509_d2i_ex(WOLFSSL_X509** x509, const unsigned char* in, int len,
  2655. void* heap);
  2656. #ifdef WOLFSSL_CERT_REQ
  2657. WOLFSSL_API WOLFSSL_X509*
  2658. wolfSSL_X509_REQ_d2i(WOLFSSL_X509** x509, const unsigned char* in, int len);
  2659. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509_REQ_INFO(WOLFSSL_X509** req,
  2660. const unsigned char** in, int len);
  2661. #endif
  2662. WOLFSSL_API int wolfSSL_i2d_X509(WOLFSSL_X509* x509, unsigned char** out);
  2663. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL(WOLFSSL_X509_CRL **crl,
  2664. const unsigned char *in, int len);
  2665. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_bio(WOLFSSL_BIO *bp,
  2666. WOLFSSL_X509_CRL **crl);
  2667. #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
  2668. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_d2i_X509_CRL_fp(XFILE file, WOLFSSL_X509_CRL **crl);
  2669. #endif
  2670. #if defined(HAVE_CRL) && defined(OPENSSL_EXTRA)
  2671. WOLFSSL_API int wolfSSL_X509_CRL_version(WOLFSSL_X509_CRL *crl);
  2672. WOLFSSL_API int wolfSSL_X509_CRL_get_signature_type(WOLFSSL_X509_CRL* crl);
  2673. WOLFSSL_API int wolfSSL_X509_CRL_get_signature_nid(
  2674. const WOLFSSL_X509_CRL* crl);
  2675. WOLFSSL_API int wolfSSL_X509_CRL_get_signature(WOLFSSL_X509_CRL* crl,
  2676. unsigned char* buf, int* bufSz);
  2677. WOLFSSL_API int wolfSSL_X509_CRL_print(WOLFSSL_BIO* bio,
  2678. WOLFSSL_X509_CRL* crl);
  2679. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_CRL_get_issuer_name(
  2680. WOLFSSL_X509_CRL *crl);
  2681. WOLFSSL_API int wolfSSL_X509_REVOKED_get_serial_number(RevokedCert* rev,
  2682. byte* in, int* inOutSz);
  2683. #endif
  2684. #if defined(HAVE_CRL) && (defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL))
  2685. WOLFSSL_API WOLFSSL_X509_CRL* wolfSSL_X509_CRL_dup(const WOLFSSL_X509_CRL* crl);
  2686. WOLFSSL_API void wolfSSL_X509_CRL_free(WOLFSSL_X509_CRL *crl);
  2687. #endif
  2688. #if defined(WOLFSSL_ACERT) && \
  2689. (defined(OPENSSL_EXTRA_X509_SMALL) || defined(OPENSSL_EXTRA))
  2690. WOLFSSL_API WOLFSSL_X509_ACERT * wolfSSL_X509_ACERT_new_ex(void * heap);
  2691. WOLFSSL_API WOLFSSL_X509_ACERT * wolfSSL_X509_ACERT_new(void);
  2692. WOLFSSL_API void wolfSSL_X509_ACERT_init(WOLFSSL_X509_ACERT * x509,
  2693. int dynamic, void * heap);
  2694. WOLFSSL_API void wolfSSL_X509_ACERT_free(WOLFSSL_X509_ACERT* x509);
  2695. #ifndef NO_WOLFSSL_STUB
  2696. WOLFSSL_API int wolfSSL_X509_ACERT_sign(WOLFSSL_X509_ACERT * x509,
  2697. WOLFSSL_EVP_PKEY * pkey,
  2698. const WOLFSSL_EVP_MD * md);
  2699. #endif /* !NO_WOLFSSL_STUB */
  2700. WOLFSSL_API int wolfSSL_X509_ACERT_verify(WOLFSSL_X509_ACERT* x509,
  2701. WOLFSSL_EVP_PKEY* pkey);
  2702. #if defined(OPENSSL_EXTRA)
  2703. WOLFSSL_API int wolfSSL_X509_ACERT_get_signature_nid(
  2704. const WOLFSSL_X509_ACERT* x);
  2705. WOLFSSL_API int wolfSSL_X509_ACERT_print(WOLFSSL_BIO* bio,
  2706. WOLFSSL_X509_ACERT* x509_acert);
  2707. WOLFSSL_API WOLFSSL_X509_ACERT * wolfSSL_PEM_read_bio_X509_ACERT(
  2708. WOLFSSL_BIO *bp, WOLFSSL_X509_ACERT **x, wc_pem_password_cb *cb, void *u);
  2709. WOLFSSL_API long wolfSSL_X509_ACERT_get_version(const WOLFSSL_X509_ACERT *x);
  2710. #endif /* OPENSSL_EXTRA */
  2711. WOLFSSL_API int wolfSSL_X509_ACERT_get_attr_buf(const WOLFSSL_X509_ACERT* x509,
  2712. const byte ** rawAttr,
  2713. word32 * rawAttrLen);
  2714. WOLFSSL_API int wolfSSL_X509_ACERT_get_serial_number(WOLFSSL_X509_ACERT* x509,
  2715. unsigned char* in,
  2716. int * inOutSz);
  2717. WOLFSSL_API int wolfSSL_X509_ACERT_version(WOLFSSL_X509_ACERT* x509);
  2718. WOLFSSL_API int wolfSSL_X509_ACERT_get_signature(WOLFSSL_X509_ACERT* x509,
  2719. unsigned char* buf,
  2720. int* bufSz);
  2721. WOLFSSL_API WOLFSSL_X509_ACERT * wolfSSL_X509_ACERT_load_certificate_buffer_ex(
  2722. const unsigned char* buf, int sz, int format, void * heap);
  2723. WOLFSSL_API WOLFSSL_X509_ACERT * wolfSSL_X509_ACERT_load_certificate_buffer(
  2724. const unsigned char* buf, int sz, int format);
  2725. #endif /* WOLFSSL_ACERT && (OPENSSL_EXTRA_X509_SMALL || OPENSSL_EXTRA) */
  2726. WOLFSSL_API
  2727. const WOLFSSL_ASN1_INTEGER* wolfSSL_X509_REVOKED_get0_serial_number(const
  2728. WOLFSSL_X509_REVOKED *rev);
  2729. WOLFSSL_API
  2730. const WOLFSSL_ASN1_TIME* wolfSSL_X509_REVOKED_get0_revocation_date(const
  2731. WOLFSSL_X509_REVOKED *rev);
  2732. #ifndef NO_FILESYSTEM
  2733. #ifndef NO_STDIO_FILESYSTEM
  2734. WOLFSSL_API WOLFSSL_X509*
  2735. wolfSSL_X509_d2i_fp(WOLFSSL_X509** x509, XFILE file);
  2736. #endif
  2737. WOLFSSL_ABI WOLFSSL_API WOLFSSL_X509*
  2738. wolfSSL_X509_load_certificate_file(const char* fname, int format);
  2739. #endif
  2740. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_load_certificate_buffer(
  2741. const unsigned char* buf, int sz, int format);
  2742. #ifdef WOLFSSL_CERT_REQ
  2743. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_REQ_load_certificate_buffer(
  2744. const unsigned char* buf, int sz, int format);
  2745. #endif
  2746. #ifdef WOLFSSL_SEP
  2747. WOLFSSL_API unsigned char*
  2748. wolfSSL_X509_get_device_type(WOLFSSL_X509* x509, unsigned char* in, int* inOutSz);
  2749. WOLFSSL_API unsigned char*
  2750. wolfSSL_X509_get_hw_type(WOLFSSL_X509* x509, unsigned char* in, int* inOutSz);
  2751. WOLFSSL_API unsigned char*
  2752. wolfSSL_X509_get_hw_serial_number(WOLFSSL_X509* x509, unsigned char* in, int* inOutSz);
  2753. #endif
  2754. /* connect enough to get peer cert */
  2755. WOLFSSL_API int wolfSSL_connect_cert(WOLFSSL* ssl);
  2756. /* PKCS12 compatibility */
  2757. WOLFSSL_API WC_PKCS12* wolfSSL_d2i_PKCS12_bio(WOLFSSL_BIO* bio,
  2758. WC_PKCS12** pkcs12);
  2759. WOLFSSL_API int wolfSSL_i2d_PKCS12_bio(WOLFSSL_BIO *bio, WC_PKCS12 *pkcs12);
  2760. #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
  2761. WOLFSSL_API WOLFSSL_X509_PKCS12* wolfSSL_d2i_PKCS12_fp(XFILE fp,
  2762. WOLFSSL_X509_PKCS12** pkcs12);
  2763. #endif
  2764. WOLFSSL_API int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw,
  2765. WOLFSSL_EVP_PKEY** pkey, WOLFSSL_X509** cert,
  2766. WOLF_STACK_OF(WOLFSSL_X509)** ca);
  2767. WOLFSSL_API int wolfSSL_PKCS12_verify_mac(WC_PKCS12 *pkcs12, const char *psw,
  2768. int pswLen);
  2769. WOLFSSL_API WC_PKCS12* wolfSSL_PKCS12_create(char* pass, char* name,
  2770. WOLFSSL_EVP_PKEY* pkey, WOLFSSL_X509* cert,
  2771. WOLF_STACK_OF(WOLFSSL_X509)* ca,
  2772. int keyNID, int certNID, int itt, int macItt, int keytype);
  2773. WOLFSSL_API void wolfSSL_PKCS12_PBE_add(void);
  2774. #ifndef NO_DH
  2775. /* server Diffie-Hellman parameters */
  2776. WOLFSSL_API int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz,
  2777. const unsigned char* g, int gSz);
  2778. WOLFSSL_API int wolfSSL_SetTmpDH_buffer(WOLFSSL* ssl, const unsigned char* b, long sz,
  2779. int format);
  2780. WOLFSSL_API int wolfSSL_SetEnableDhKeyTest(WOLFSSL* ssl, int enable);
  2781. #ifndef NO_FILESYSTEM
  2782. WOLFSSL_API int wolfSSL_SetTmpDH_file(WOLFSSL* ssl, const char* f, int format);
  2783. #endif
  2784. /* server ctx Diffie-Hellman parameters */
  2785. WOLFSSL_API int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p,
  2786. int pSz, const unsigned char* g, int gSz);
  2787. WOLFSSL_API int wolfSSL_CTX_SetTmpDH_buffer(WOLFSSL_CTX* ctx, const unsigned char* b,
  2788. long sz, int format);
  2789. #ifndef NO_FILESYSTEM
  2790. WOLFSSL_API int wolfSSL_CTX_SetTmpDH_file(WOLFSSL_CTX* ctx, const char* f,
  2791. int format);
  2792. #endif
  2793. WOLFSSL_API int wolfSSL_CTX_SetMinDhKey_Sz(WOLFSSL_CTX* ctx, word16 keySz_bits);
  2794. WOLFSSL_API int wolfSSL_SetMinDhKey_Sz(WOLFSSL* ssl, word16 keySz_bits);
  2795. WOLFSSL_API int wolfSSL_CTX_SetMaxDhKey_Sz(WOLFSSL_CTX* ctx, word16 keySz_bits);
  2796. WOLFSSL_API int wolfSSL_SetMaxDhKey_Sz(WOLFSSL* ssl, word16 keySz_bits);
  2797. WOLFSSL_API int wolfSSL_GetDhKey_Sz(WOLFSSL* ssl);
  2798. #endif /* NO_DH */
  2799. #ifndef NO_RSA
  2800. WOLFSSL_API int wolfSSL_CTX_SetMinRsaKey_Sz(WOLFSSL_CTX* ctx, short keySz);
  2801. WOLFSSL_API int wolfSSL_SetMinRsaKey_Sz(WOLFSSL* ssl, short keySz);
  2802. #endif /* NO_RSA */
  2803. #ifdef HAVE_ECC
  2804. WOLFSSL_API int wolfSSL_CTX_SetMinEccKey_Sz(WOLFSSL_CTX* ctx, short keySz);
  2805. WOLFSSL_API int wolfSSL_SetMinEccKey_Sz(WOLFSSL* ssl, short keySz);
  2806. #endif /* NO_RSA */
  2807. WOLFSSL_API int wolfSSL_SetTmpEC_DHE_Sz(WOLFSSL* ssl, word16 sz);
  2808. WOLFSSL_API int wolfSSL_CTX_SetTmpEC_DHE_Sz(WOLFSSL_CTX* ctx, word16 sz);
  2809. /* keyblock size in bytes or -1 */
  2810. /* need to call wolfSSL_KeepArrays before handshake to save keys */
  2811. WOLFSSL_API int wolfSSL_get_keyblock_size(WOLFSSL* ssl);
  2812. WOLFSSL_API int wolfSSL_get_keys(WOLFSSL* ssl,unsigned char** ms, unsigned int* msLen,
  2813. unsigned char** sr, unsigned int* srLen,
  2814. unsigned char** cr, unsigned int* crLen);
  2815. /* Computes EAP-TLS and EAP-TTLS keying material from the master_secret. */
  2816. WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
  2817. const char* label);
  2818. #ifndef _WIN32
  2819. #ifndef NO_WRITEV
  2820. #ifdef __PPU
  2821. #include <sys/types.h>
  2822. #include <sys/socket.h>
  2823. #elif defined(ARDUINO)
  2824. /* TODO board specific */
  2825. #elif defined(NUCLEUS_PLUS_2_3)
  2826. #include "services/sys/uio.h"
  2827. #elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \
  2828. !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \
  2829. !defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \
  2830. !defined(WOLFSSL_CHIBIOS) && !defined(WOLFSSL_CONTIKI) && \
  2831. !defined(WOLFSSL_ZEPHYR) && !defined(NETOS) && \
  2832. !defined(WOLFSSL_NDS)
  2833. #include <sys/uio.h>
  2834. #endif
  2835. /* allow writev style writing */
  2836. WOLFSSL_API int wolfSSL_writev(WOLFSSL* ssl, const struct iovec* iov,
  2837. int iovcnt);
  2838. #endif /* !NO_WRITEV */
  2839. #endif /* !_WIN32 */
  2840. #ifndef NO_CERTS
  2841. /* SSL_CTX versions */
  2842. WOLFSSL_API int wolfSSL_CTX_UnloadCAs(WOLFSSL_CTX* ctx);
  2843. WOLFSSL_API int wolfSSL_CTX_UnloadIntermediateCerts(WOLFSSL_CTX* ctx);
  2844. #ifdef WOLFSSL_TRUST_PEER_CERT
  2845. WOLFSSL_API int wolfSSL_CTX_Unload_trust_peers(WOLFSSL_CTX* ctx);
  2846. #ifdef WOLFSSL_LOCAL_X509_STORE
  2847. WOLFSSL_API int wolfSSL_Unload_trust_peers(WOLFSSL* ssl);
  2848. #endif
  2849. WOLFSSL_API int wolfSSL_CTX_trust_peer_buffer(WOLFSSL_CTX* ctx,
  2850. const unsigned char* in,
  2851. long sz, int format);
  2852. #endif
  2853. WOLFSSL_API int wolfSSL_CTX_load_verify_buffer_ex(WOLFSSL_CTX* ctx,
  2854. const unsigned char* in, long sz, int format,
  2855. int userChain, word32 flags);
  2856. WOLFSSL_API int wolfSSL_CTX_load_verify_buffer(WOLFSSL_CTX* ctx,
  2857. const unsigned char* in, long sz, int format);
  2858. WOLFSSL_API int wolfSSL_CTX_load_verify_chain_buffer_format(WOLFSSL_CTX* ctx,
  2859. const unsigned char* in, long sz, int format);
  2860. WOLFSSL_API int wolfSSL_CTX_use_certificate_buffer(WOLFSSL_CTX* ctx,
  2861. const unsigned char* in, long sz, int format);
  2862. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX* ctx,
  2863. const unsigned char* in, long sz, int format);
  2864. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_id(WOLFSSL_CTX* ctx,
  2865. const unsigned char* id, long sz,
  2866. int devId, long keySz);
  2867. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Id(WOLFSSL_CTX* ctx,
  2868. const unsigned char* id, long sz,
  2869. int devId);
  2870. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_Label(WOLFSSL_CTX* ctx, const char* label,
  2871. int devId);
  2872. WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer_format(WOLFSSL_CTX* ctx,
  2873. const unsigned char* in, long sz, int format);
  2874. WOLFSSL_API int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX* ctx,
  2875. const unsigned char* in, long sz);
  2876. #ifdef WOLFSSL_DUAL_ALG_CERTS
  2877. WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_buffer(WOLFSSL_CTX* ctx,
  2878. const unsigned char* in, long sz, int format);
  2879. WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_id(WOLFSSL_CTX* ctx,
  2880. const unsigned char* id, long sz,
  2881. int devId, long keySz);
  2882. WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Id(WOLFSSL_CTX* ctx,
  2883. const unsigned char* id, long sz, int devId);
  2884. WOLFSSL_API int wolfSSL_CTX_use_AltPrivateKey_Label(WOLFSSL_CTX* ctx,
  2885. const char* label, int devId);
  2886. #endif
  2887. /* SSL versions */
  2888. WOLFSSL_API int wolfSSL_use_certificate_buffer(WOLFSSL* ssl, const unsigned char* in,
  2889. long sz, int format);
  2890. WOLFSSL_API int wolfSSL_use_certificate_ASN1(WOLFSSL* ssl,
  2891. const unsigned char* der, int derSz);
  2892. WOLFSSL_API int wolfSSL_use_PrivateKey_buffer(WOLFSSL* ssl, const unsigned char* in,
  2893. long sz, int format);
  2894. WOLFSSL_API int wolfSSL_use_PrivateKey_id(WOLFSSL* ssl, const unsigned char* id,
  2895. long sz, int devId, long keySz);
  2896. WOLFSSL_API int wolfSSL_use_PrivateKey_Id(WOLFSSL* ssl, const unsigned char* id,
  2897. long sz, int devId);
  2898. WOLFSSL_API int wolfSSL_use_PrivateKey_Label(WOLFSSL* ssl, const char* label, int devId);
  2899. WOLFSSL_API int wolfSSL_use_certificate_chain_buffer_format(WOLFSSL* ssl,
  2900. const unsigned char* in, long sz, int format);
  2901. WOLFSSL_API int wolfSSL_use_certificate_chain_buffer(WOLFSSL* ssl,
  2902. const unsigned char* in, long sz);
  2903. WOLFSSL_API int wolfSSL_UnloadCertsKeys(WOLFSSL* ssl);
  2904. #ifdef WOLFSSL_DUAL_ALG_CERTS
  2905. WOLFSSL_API int wolfSSL_use_AltPrivateKey_buffer(WOLFSSL* ssl,
  2906. const unsigned char* in, long sz, int format);
  2907. WOLFSSL_API int wolfSSL_use_AltPrivateKey_id(WOLFSSL* ssl,
  2908. const unsigned char* id, long sz,
  2909. int devId, long keySz);
  2910. WOLFSSL_API int wolfSSL_use_AltPrivateKey_Id(WOLFSSL* ssl,
  2911. const unsigned char* id, long sz, int devId);
  2912. WOLFSSL_API int wolfSSL_use_AltPrivateKey_Label(WOLFSSL* ssl,
  2913. const char* label, int devId);
  2914. #endif
  2915. #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \
  2916. defined(KEEP_OUR_CERT)
  2917. WOLFSSL_API WOLFSSL_X509* wolfSSL_get_certificate(WOLFSSL* ssl);
  2918. WOLFSSL_API WOLFSSL_X509* wolfSSL_CTX_get0_certificate(WOLFSSL_CTX* ctx);
  2919. #endif
  2920. #endif
  2921. WOLFSSL_API int wolfSSL_CTX_set_group_messages(WOLFSSL_CTX* ctx);
  2922. WOLFSSL_API int wolfSSL_set_group_messages(WOLFSSL* ssl);
  2923. #ifdef HAVE_FUZZER
  2924. enum fuzzer_type {
  2925. FUZZ_HMAC = 0,
  2926. FUZZ_ENCRYPT = 1,
  2927. FUZZ_SIGNATURE = 2,
  2928. FUZZ_HASH = 3,
  2929. FUZZ_HEAD = 4
  2930. };
  2931. typedef int (*CallbackFuzzer)(WOLFSSL* ssl, const unsigned char* buf, int sz,
  2932. int type, void* fuzzCtx);
  2933. WOLFSSL_API void wolfSSL_SetFuzzerCb(WOLFSSL* ssl, CallbackFuzzer cbf, void* fCtx);
  2934. #endif
  2935. WOLFSSL_API int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl, const byte* secret, word32 secretSz);
  2936. /* CA cache callbacks */
  2937. enum {
  2938. WOLFSSL_SSLV3 = 0,
  2939. WOLFSSL_TLSV1 = 1,
  2940. WOLFSSL_TLSV1_1 = 2,
  2941. WOLFSSL_TLSV1_2 = 3,
  2942. WOLFSSL_TLSV1_3 = 4,
  2943. WOLFSSL_DTLSV1 = 5,
  2944. WOLFSSL_DTLSV1_2 = 6,
  2945. WOLFSSL_DTLSV1_3 = 7,
  2946. WOLFSSL_USER_CA = 1, /* user added as trusted */
  2947. WOLFSSL_CHAIN_CA = 2, /* added to cache from trusted chain */
  2948. WOLFSSL_TEMP_CA = 3 /* Temp intermediate CA, only for use by
  2949. * X509_STORE */
  2950. };
  2951. WOLFSSL_ABI WOLFSSL_API WC_RNG* wolfSSL_GetRNG(WOLFSSL* ssl);
  2952. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_SetMinVersion(WOLFSSL_CTX* ctx, int version);
  2953. WOLFSSL_API int wolfSSL_SetMinVersion(WOLFSSL* ssl, int version);
  2954. WOLFSSL_API int wolfSSL_GetObjectSize(void); /* object size based on build */
  2955. WOLFSSL_API int wolfSSL_CTX_GetObjectSize(void);
  2956. WOLFSSL_API int wolfSSL_METHOD_GetObjectSize(void);
  2957. WOLFSSL_API int wolfSSL_GetOutputSize(WOLFSSL* ssl, int inSz);
  2958. WOLFSSL_API int wolfSSL_GetMaxOutputSize(WOLFSSL* ssl);
  2959. WOLFSSL_API int wolfSSL_GetVersion(const WOLFSSL* ssl);
  2960. WOLFSSL_API int wolfSSL_SetVersion(WOLFSSL* ssl, int version);
  2961. /* moved to asn.c, old names kept for backwards compatibility */
  2962. #define wolfSSL_KeyPemToDer wc_KeyPemToDer
  2963. #define wolfSSL_CertPemToDer wc_CertPemToDer
  2964. #define wolfSSL_PemPubKeyToDer wc_PemPubKeyToDer
  2965. #define wolfSSL_PubKeyPemToDer wc_PubKeyPemToDer
  2966. #define wolfSSL_PemCertToDer wc_PemCertToDer
  2967. typedef void (*CallbackCACache)(unsigned char* der, int sz, int type);
  2968. typedef void (*CbMissingCRL)(const char* url);
  2969. typedef int (*crlErrorCb)(int ret, WOLFSSL_CRL* crl, WOLFSSL_CERT_MANAGER* cm,
  2970. void* ctx);
  2971. typedef int (*CbOCSPIO)(void*, const char*, int,
  2972. unsigned char*, int, unsigned char**);
  2973. typedef void (*CbOCSPRespFree)(void*,unsigned char*);
  2974. #ifdef HAVE_CRL_IO
  2975. typedef int (*CbCrlIO)(WOLFSSL_CRL* crl, const char* url, int urlSz);
  2976. #endif
  2977. /* User Atomic Record Layer CallBacks */
  2978. typedef int (*CallbackMacEncrypt)(WOLFSSL* ssl, unsigned char* macOut,
  2979. const unsigned char* macIn, unsigned int macInSz, int macContent,
  2980. int macVerify, unsigned char* encOut, const unsigned char* encIn,
  2981. unsigned int encSz, void* ctx);
  2982. WOLFSSL_API void wolfSSL_CTX_SetMacEncryptCb(WOLFSSL_CTX* ctx, CallbackMacEncrypt cb);
  2983. WOLFSSL_API void wolfSSL_SetMacEncryptCtx(WOLFSSL* ssl, void *ctx);
  2984. WOLFSSL_API void* wolfSSL_GetMacEncryptCtx(WOLFSSL* ssl);
  2985. typedef int (*CallbackDecryptVerify)(WOLFSSL* ssl,
  2986. unsigned char* decOut, const unsigned char* decIn,
  2987. unsigned int decSz, int content, int verify, unsigned int* padSz,
  2988. void* ctx);
  2989. WOLFSSL_API void wolfSSL_CTX_SetDecryptVerifyCb(WOLFSSL_CTX* ctx,
  2990. CallbackDecryptVerify cb);
  2991. WOLFSSL_API void wolfSSL_SetDecryptVerifyCtx(WOLFSSL* ssl, void *ctx);
  2992. WOLFSSL_API void* wolfSSL_GetDecryptVerifyCtx(WOLFSSL* ssl);
  2993. typedef int (*CallbackEncryptMac)(WOLFSSL* ssl, unsigned char* macOut,
  2994. int content, int macVerify, unsigned char* encOut,
  2995. const unsigned char* encIn, unsigned int encSz, void* ctx);
  2996. WOLFSSL_API void wolfSSL_CTX_SetEncryptMacCb(WOLFSSL_CTX* ctx, CallbackEncryptMac cb);
  2997. WOLFSSL_API void wolfSSL_SetEncryptMacCtx(WOLFSSL* ssl, void *ctx);
  2998. WOLFSSL_API void* wolfSSL_GetEncryptMacCtx(WOLFSSL* ssl);
  2999. #ifdef WOLFSSL_THREADED_CRYPT
  3000. #ifndef WOLFSSL_THREADED_CRYPT_CNT
  3001. #define WOLFSSL_THREADED_CRYPT_CNT 16
  3002. #endif
  3003. typedef void (*WOLFSSL_THREAD_SIGNAL)(void* ctx, WOLFSSL* ssl);
  3004. WOLFSSL_API int wolfSSL_AsyncEncryptReady(WOLFSSL* ssl, int idx);
  3005. WOLFSSL_API int wolfSSL_AsyncEncryptStop(WOLFSSL* ssl, int idx);
  3006. WOLFSSL_API int wolfSSL_AsyncEncrypt(WOLFSSL* ssl, int idx);
  3007. WOLFSSL_API int wolfSSL_AsyncEncryptSetSignal(WOLFSSL* ssl, int idx,
  3008. WOLFSSL_THREAD_SIGNAL signal, void* ctx);
  3009. #endif
  3010. typedef int (*CallbackVerifyDecrypt)(WOLFSSL* ssl,
  3011. unsigned char* decOut, const unsigned char* decIn,
  3012. unsigned int decSz, int content, int verify, unsigned int* padSz,
  3013. void* ctx);
  3014. WOLFSSL_API void wolfSSL_CTX_SetVerifyDecryptCb(WOLFSSL_CTX* ctx,
  3015. CallbackVerifyDecrypt cb);
  3016. WOLFSSL_API void wolfSSL_SetVerifyDecryptCtx(WOLFSSL* ssl, void *ctx);
  3017. WOLFSSL_API void* wolfSSL_GetVerifyDecryptCtx(WOLFSSL* ssl);
  3018. WOLFSSL_API const unsigned char* wolfSSL_GetMacSecret(WOLFSSL* ssl, int verify);
  3019. WOLFSSL_API const unsigned char* wolfSSL_GetDtlsMacSecret(WOLFSSL* ssl, int verify, int epochOrder);
  3020. WOLFSSL_API const unsigned char* wolfSSL_GetClientWriteKey(WOLFSSL* ssl);
  3021. WOLFSSL_API const unsigned char* wolfSSL_GetClientWriteIV(WOLFSSL* ssl);
  3022. WOLFSSL_API const unsigned char* wolfSSL_GetServerWriteKey(WOLFSSL* ssl);
  3023. WOLFSSL_API const unsigned char* wolfSSL_GetServerWriteIV(WOLFSSL* ssl);
  3024. WOLFSSL_API int wolfSSL_GetKeySize(WOLFSSL* ssl);
  3025. WOLFSSL_API int wolfSSL_GetIVSize(WOLFSSL* ssl);
  3026. WOLFSSL_API int wolfSSL_GetSide(WOLFSSL* ssl);
  3027. WOLFSSL_API int wolfSSL_IsTLSv1_1(WOLFSSL* ssl);
  3028. WOLFSSL_API int wolfSSL_GetBulkCipher(WOLFSSL* ssl);
  3029. WOLFSSL_API int wolfSSL_GetCipherBlockSize(WOLFSSL* ssl);
  3030. WOLFSSL_API int wolfSSL_GetAeadMacSize(WOLFSSL* ssl);
  3031. WOLFSSL_API int wolfSSL_GetHmacSize(WOLFSSL* ssl);
  3032. WOLFSSL_API int wolfSSL_GetHmacType(WOLFSSL* ssl);
  3033. #ifdef WORD64_AVAILABLE
  3034. WOLFSSL_API int wolfSSL_GetPeerSequenceNumber(WOLFSSL* ssl, word64* seq);
  3035. WOLFSSL_API int wolfSSL_GetSequenceNumber(WOLFSSL* ssl, word64* seq);
  3036. #endif
  3037. WOLFSSL_API int wolfSSL_GetCipherType(WOLFSSL* ssl);
  3038. WOLFSSL_API int wolfSSL_SetTlsHmacInner(WOLFSSL* ssl,
  3039. byte* inner, word32 sz, int content, int verify);
  3040. /* Atomic User Needs */
  3041. enum {
  3042. WOLFSSL_SERVER_END = 0,
  3043. WOLFSSL_CLIENT_END = 1,
  3044. WOLFSSL_NEITHER_END = 3,
  3045. WOLFSSL_BLOCK_TYPE = 2,
  3046. WOLFSSL_STREAM_TYPE = 3,
  3047. WOLFSSL_AEAD_TYPE = 4,
  3048. WOLFSSL_TLS_HMAC_INNER_SZ = 13, /* SEQ_SZ + ENUM + VERSION_SZ + LEN_SZ */
  3049. };
  3050. /* for GetBulkCipher and internal use
  3051. * using explicit values to assist with serialization of a TLS session */
  3052. enum BulkCipherAlgorithm {
  3053. wolfssl_cipher_null = 0,
  3054. wolfssl_rc4 = 1,
  3055. wolfssl_rc2 = 2,
  3056. wolfssl_des = 3,
  3057. wolfssl_triple_des = 4,
  3058. wolfssl_des40 = 5,
  3059. wolfssl_aes = 6,
  3060. wolfssl_aes_gcm = 7,
  3061. wolfssl_aes_ccm = 8,
  3062. wolfssl_chacha = 9,
  3063. wolfssl_camellia = 10,
  3064. wolfssl_sm4_cbc = 11,
  3065. wolfssl_sm4_gcm = 12,
  3066. wolfssl_sm4_ccm = 13,
  3067. wolfssl_aria_gcm = 14
  3068. };
  3069. /* for KDF TLS 1.2 mac types */
  3070. enum KDF_MacAlgorithm {
  3071. wolfssl_sha256 = 4, /* needs to match hash.h wc_MACAlgorithm */
  3072. wolfssl_sha384,
  3073. wolfssl_sha512,
  3074. wolfssl_sm3 = 9
  3075. };
  3076. /* Public Key Callback support */
  3077. #ifdef HAVE_PK_CALLBACKS
  3078. #ifdef HAVE_ECC
  3079. struct ecc_key;
  3080. typedef int (*CallbackEccKeyGen)(WOLFSSL* ssl, struct ecc_key* key,
  3081. unsigned int keySz, int ecc_curve, void* ctx);
  3082. WOLFSSL_API void wolfSSL_CTX_SetEccKeyGenCb(WOLFSSL_CTX* ctx, CallbackEccKeyGen cb);
  3083. WOLFSSL_API void wolfSSL_SetEccKeyGenCtx(WOLFSSL* ssl, void *ctx);
  3084. WOLFSSL_API void* wolfSSL_GetEccKeyGenCtx(WOLFSSL* ssl);
  3085. typedef int (*CallbackEccSign)(WOLFSSL* ssl,
  3086. const unsigned char* in, unsigned int inSz,
  3087. unsigned char* out, word32* outSz,
  3088. const unsigned char* keyDer, unsigned int keySz,
  3089. void* ctx);
  3090. WOLFSSL_ABI WOLFSSL_API void wolfSSL_CTX_SetEccSignCb(WOLFSSL_CTX* ctx,
  3091. CallbackEccSign cb);
  3092. WOLFSSL_API void wolfSSL_SetEccSignCtx(WOLFSSL* ssl, void *ctx);
  3093. WOLFSSL_API void* wolfSSL_GetEccSignCtx(WOLFSSL* ssl);
  3094. WOLFSSL_API void wolfSSL_CTX_SetEccSignCtx(WOLFSSL_CTX* ctx, void *userCtx);
  3095. WOLFSSL_API void* wolfSSL_CTX_GetEccSignCtx(WOLFSSL_CTX* ctx);
  3096. typedef int (*CallbackEccVerify)(WOLFSSL* ssl,
  3097. const unsigned char* sig, unsigned int sigSz,
  3098. const unsigned char* hash, unsigned int hashSz,
  3099. const unsigned char* keyDer, unsigned int keySz,
  3100. int* result, void* ctx);
  3101. WOLFSSL_API void wolfSSL_CTX_SetEccVerifyCb(WOLFSSL_CTX* ctx, CallbackEccVerify cb);
  3102. WOLFSSL_API void wolfSSL_SetEccVerifyCtx(WOLFSSL* ssl, void *ctx);
  3103. WOLFSSL_API void* wolfSSL_GetEccVerifyCtx(WOLFSSL* ssl);
  3104. typedef int (*CallbackEccSharedSecret)(WOLFSSL* ssl, struct ecc_key* otherKey,
  3105. unsigned char* pubKeyDer, word32* pubKeySz,
  3106. unsigned char* out, word32* outlen,
  3107. int side, void* ctx); /* side is WOLFSSL_CLIENT_END or WOLFSSL_SERVER_END */
  3108. WOLFSSL_API void wolfSSL_CTX_SetEccSharedSecretCb(WOLFSSL_CTX* ctx, CallbackEccSharedSecret cb);
  3109. WOLFSSL_API void wolfSSL_SetEccSharedSecretCtx(WOLFSSL* ssl, void *ctx);
  3110. WOLFSSL_API void* wolfSSL_GetEccSharedSecretCtx(WOLFSSL* ssl);
  3111. #endif
  3112. #ifdef HAVE_HKDF
  3113. #include <wolfssl/wolfcrypt/kdf.h>
  3114. typedef int (*CallbackHKDFExtract)(byte* prk, const byte* salt, word32 saltLen,
  3115. byte* ikm, word32 ikmLen, int digest, void* ctx);
  3116. WOLFSSL_API void wolfSSL_CTX_SetHKDFExtractCb(WOLFSSL_CTX* ctx, CallbackHKDFExtract cb);
  3117. WOLFSSL_API void* wolfSSL_GetHKDFExtractCtx(WOLFSSL* ssl);
  3118. WOLFSSL_API void wolfSSL_SetHKDFExtractCtx(WOLFSSL* ssl, void *ctx);
  3119. #endif
  3120. #ifndef NO_DH
  3121. /* Public DH Key Callback support */
  3122. struct DhKey;
  3123. typedef int (*CallbackDhGenerateKeyPair)(DhKey* key, WC_RNG* rng,
  3124. byte* priv, word32* privSz,
  3125. byte* pub, word32* pubSz);
  3126. typedef int (*CallbackDhAgree)(WOLFSSL* ssl, struct DhKey* key,
  3127. const unsigned char* priv, unsigned int privSz,
  3128. const unsigned char* otherPubKeyDer, unsigned int otherPubKeySz,
  3129. unsigned char* out, word32* outlen,
  3130. void* ctx);
  3131. WOLFSSL_API void wolfSSL_CTX_SetDhGenerateKeyPair(WOLFSSL_CTX* ctx,
  3132. CallbackDhGenerateKeyPair cb);
  3133. WOLFSSL_API void wolfSSL_CTX_SetDhAgreeCb(WOLFSSL_CTX* ctx,
  3134. CallbackDhAgree cb);
  3135. WOLFSSL_API void wolfSSL_SetDhAgreeCtx(WOLFSSL* ssl, void *ctx);
  3136. WOLFSSL_API void* wolfSSL_GetDhAgreeCtx(WOLFSSL* ssl);
  3137. #endif /* !NO_DH */
  3138. #ifdef HAVE_ED25519
  3139. struct ed25519_key;
  3140. typedef int (*CallbackEd25519Sign)(WOLFSSL* ssl,
  3141. const unsigned char* in, unsigned int inSz,
  3142. unsigned char* out, unsigned int* outSz,
  3143. const unsigned char* keyDer, unsigned int keySz,
  3144. void* ctx);
  3145. WOLFSSL_API void wolfSSL_CTX_SetEd25519SignCb(WOLFSSL_CTX* ctx,
  3146. CallbackEd25519Sign cb);
  3147. WOLFSSL_API void wolfSSL_SetEd25519SignCtx(WOLFSSL* ssl, void *ctx);
  3148. WOLFSSL_API void* wolfSSL_GetEd25519SignCtx(WOLFSSL* ssl);
  3149. typedef int (*CallbackEd25519Verify)(WOLFSSL* ssl,
  3150. const unsigned char* sig, unsigned int sigSz,
  3151. const unsigned char* msg, unsigned int msgSz,
  3152. const unsigned char* keyDer, unsigned int keySz,
  3153. int* result, void* ctx);
  3154. WOLFSSL_API void wolfSSL_CTX_SetEd25519VerifyCb(WOLFSSL_CTX* ctx,
  3155. CallbackEd25519Verify cb);
  3156. WOLFSSL_API void wolfSSL_SetEd25519VerifyCtx(WOLFSSL* ssl, void *ctx);
  3157. WOLFSSL_API void* wolfSSL_GetEd25519VerifyCtx(WOLFSSL* ssl);
  3158. #endif
  3159. #ifdef HAVE_CURVE25519
  3160. struct curve25519_key;
  3161. typedef int (*CallbackX25519KeyGen)(WOLFSSL* ssl, struct curve25519_key* key,
  3162. unsigned int keySz, void* ctx);
  3163. WOLFSSL_API void wolfSSL_CTX_SetX25519KeyGenCb(WOLFSSL_CTX* ctx, CallbackX25519KeyGen cb);
  3164. WOLFSSL_API void wolfSSL_SetX25519KeyGenCtx(WOLFSSL* ssl, void *ctx);
  3165. WOLFSSL_API void* wolfSSL_GetX25519KeyGenCtx(WOLFSSL* ssl);
  3166. typedef int (*CallbackX25519SharedSecret)(WOLFSSL* ssl,
  3167. struct curve25519_key* otherKey,
  3168. unsigned char* pubKeyDer, unsigned int* pubKeySz,
  3169. unsigned char* out, unsigned int* outlen,
  3170. int side, void* ctx);
  3171. /* side is WOLFSSL_CLIENT_END or WOLFSSL_SERVER_END */
  3172. WOLFSSL_API void wolfSSL_CTX_SetX25519SharedSecretCb(WOLFSSL_CTX* ctx,
  3173. CallbackX25519SharedSecret cb);
  3174. WOLFSSL_API void wolfSSL_SetX25519SharedSecretCtx(WOLFSSL* ssl, void *ctx);
  3175. WOLFSSL_API void* wolfSSL_GetX25519SharedSecretCtx(WOLFSSL* ssl);
  3176. #endif
  3177. #ifdef HAVE_ED448
  3178. struct ed448_key;
  3179. typedef int (*CallbackEd448Sign)(WOLFSSL* ssl,
  3180. const unsigned char* in, unsigned int inSz,
  3181. unsigned char* out, unsigned int* outSz,
  3182. const unsigned char* keyDer, unsigned int keySz,
  3183. void* ctx);
  3184. WOLFSSL_API void wolfSSL_CTX_SetEd448SignCb(WOLFSSL_CTX* ctx,
  3185. CallbackEd448Sign cb);
  3186. WOLFSSL_API void wolfSSL_SetEd448SignCtx(WOLFSSL* ssl, void *ctx);
  3187. WOLFSSL_API void* wolfSSL_GetEd448SignCtx(WOLFSSL* ssl);
  3188. typedef int (*CallbackEd448Verify)(WOLFSSL* ssl,
  3189. const unsigned char* sig, unsigned int sigSz,
  3190. const unsigned char* msg, unsigned int msgSz,
  3191. const unsigned char* keyDer, unsigned int keySz,
  3192. int* result, void* ctx);
  3193. WOLFSSL_API void wolfSSL_CTX_SetEd448VerifyCb(WOLFSSL_CTX* ctx,
  3194. CallbackEd448Verify cb);
  3195. WOLFSSL_API void wolfSSL_SetEd448VerifyCtx(WOLFSSL* ssl, void *ctx);
  3196. WOLFSSL_API void* wolfSSL_GetEd448VerifyCtx(WOLFSSL* ssl);
  3197. #endif
  3198. #ifdef HAVE_CURVE448
  3199. struct curve448_key;
  3200. typedef int (*CallbackX448KeyGen)(WOLFSSL* ssl, struct curve448_key* key,
  3201. unsigned int keySz, void* ctx);
  3202. WOLFSSL_API void wolfSSL_CTX_SetX448KeyGenCb(WOLFSSL_CTX* ctx, CallbackX448KeyGen cb);
  3203. WOLFSSL_API void wolfSSL_SetX448KeyGenCtx(WOLFSSL* ssl, void *ctx);
  3204. WOLFSSL_API void* wolfSSL_GetX448KeyGenCtx(WOLFSSL* ssl);
  3205. typedef int (*CallbackX448SharedSecret)(WOLFSSL* ssl,
  3206. struct curve448_key* otherKey,
  3207. unsigned char* pubKeyDer, unsigned int* pubKeySz,
  3208. unsigned char* out, unsigned int* outlen,
  3209. int side, void* ctx);
  3210. /* side is WOLFSSL_CLIENT_END or WOLFSSL_SERVER_END */
  3211. WOLFSSL_API void wolfSSL_CTX_SetX448SharedSecretCb(WOLFSSL_CTX* ctx,
  3212. CallbackX448SharedSecret cb);
  3213. WOLFSSL_API void wolfSSL_SetX448SharedSecretCtx(WOLFSSL* ssl, void *ctx);
  3214. WOLFSSL_API void* wolfSSL_GetX448SharedSecretCtx(WOLFSSL* ssl);
  3215. #endif
  3216. #ifndef NO_RSA
  3217. typedef int (*CallbackRsaSign)(WOLFSSL* ssl,
  3218. const unsigned char* in, unsigned int inSz,
  3219. unsigned char* out, word32* outSz,
  3220. const unsigned char* keyDer, unsigned int keySz,
  3221. void* ctx);
  3222. WOLFSSL_API void wolfSSL_CTX_SetRsaSignCb(WOLFSSL_CTX* ctx, CallbackRsaSign cb);
  3223. WOLFSSL_API void wolfSSL_SetRsaSignCtx(WOLFSSL* ssl, void *ctx);
  3224. WOLFSSL_API void* wolfSSL_GetRsaSignCtx(WOLFSSL* ssl);
  3225. typedef int (*CallbackRsaVerify)(WOLFSSL* ssl,
  3226. unsigned char* sig, unsigned int sigSz,
  3227. unsigned char** out,
  3228. const unsigned char* keyDer, unsigned int keySz,
  3229. void* ctx);
  3230. WOLFSSL_API void wolfSSL_CTX_SetRsaVerifyCb(WOLFSSL_CTX* ctx, CallbackRsaVerify cb);
  3231. WOLFSSL_API void wolfSSL_CTX_SetRsaSignCheckCb(WOLFSSL_CTX* ctx, CallbackRsaVerify cb);
  3232. WOLFSSL_API void wolfSSL_SetRsaVerifyCtx(WOLFSSL* ssl, void *ctx);
  3233. WOLFSSL_API void* wolfSSL_GetRsaVerifyCtx(WOLFSSL* ssl);
  3234. #ifdef WC_RSA_PSS
  3235. typedef int (*CallbackRsaPssSign)(WOLFSSL* ssl,
  3236. const unsigned char* in, unsigned int inSz,
  3237. unsigned char* out, unsigned int* outSz,
  3238. int hash, int mgf,
  3239. const unsigned char* keyDer, unsigned int keySz,
  3240. void* ctx);
  3241. WOLFSSL_API void wolfSSL_CTX_SetRsaPssSignCb(WOLFSSL_CTX* ctx, CallbackRsaPssSign cb);
  3242. WOLFSSL_API void wolfSSL_SetRsaPssSignCtx(WOLFSSL* ssl, void *ctx);
  3243. WOLFSSL_API void* wolfSSL_GetRsaPssSignCtx(WOLFSSL* ssl);
  3244. typedef int (*CallbackRsaPssVerify)(WOLFSSL* ssl,
  3245. unsigned char* sig, unsigned int sigSz,
  3246. unsigned char** out,
  3247. int hash, int mgf,
  3248. const unsigned char* keyDer, unsigned int keySz,
  3249. void* ctx);
  3250. WOLFSSL_API void wolfSSL_CTX_SetRsaPssVerifyCb(WOLFSSL_CTX* ctx,
  3251. CallbackRsaPssVerify cb);
  3252. WOLFSSL_API void wolfSSL_CTX_SetRsaPssSignCheckCb(WOLFSSL_CTX* ctx,
  3253. CallbackRsaPssVerify cb);
  3254. WOLFSSL_API void wolfSSL_SetRsaPssVerifyCtx(WOLFSSL* ssl, void *ctx);
  3255. WOLFSSL_API void* wolfSSL_GetRsaPssVerifyCtx(WOLFSSL* ssl);
  3256. #endif
  3257. /* RSA Public Encrypt cb */
  3258. typedef int (*CallbackRsaEnc)(WOLFSSL* ssl,
  3259. const unsigned char* in, unsigned int inSz,
  3260. unsigned char* out, word32* outSz,
  3261. const unsigned char* keyDer, unsigned int keySz,
  3262. void* ctx);
  3263. WOLFSSL_API void wolfSSL_CTX_SetRsaEncCb(WOLFSSL_CTX* ctx, CallbackRsaEnc cb);
  3264. WOLFSSL_API void wolfSSL_SetRsaEncCtx(WOLFSSL* ssl, void *ctx);
  3265. WOLFSSL_API void* wolfSSL_GetRsaEncCtx(WOLFSSL* ssl);
  3266. /* RSA Private Decrypt cb */
  3267. typedef int (*CallbackRsaDec)(WOLFSSL* ssl,
  3268. unsigned char* in, unsigned int inSz,
  3269. unsigned char** out,
  3270. const unsigned char* keyDer, unsigned int keySz,
  3271. void* ctx);
  3272. WOLFSSL_API void wolfSSL_CTX_SetRsaDecCb(WOLFSSL_CTX* ctx, CallbackRsaDec cb);
  3273. WOLFSSL_API void wolfSSL_SetRsaDecCtx(WOLFSSL* ssl, void *ctx);
  3274. WOLFSSL_API void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl);
  3275. #endif
  3276. /* Protocol Callback */
  3277. typedef int (*CallbackGenMasterSecret)(WOLFSSL* ssl, void* ctx);
  3278. WOLFSSL_API void wolfSSL_CTX_SetGenMasterSecretCb(WOLFSSL_CTX* ctx,
  3279. CallbackGenMasterSecret cb);
  3280. WOLFSSL_API void wolfSSL_SetGenMasterSecretCtx(WOLFSSL* ssl, void *ctx);
  3281. WOLFSSL_API void* wolfSSL_GetGenMasterSecretCtx(WOLFSSL* ssl);
  3282. typedef int (*CallbackGenPreMaster)(WOLFSSL* ssl, byte *premaster,
  3283. word32 preSz, void* ctx);
  3284. WOLFSSL_API void wolfSSL_CTX_SetGenPreMasterCb(WOLFSSL_CTX* ctx,
  3285. CallbackGenPreMaster cb);
  3286. WOLFSSL_API void wolfSSL_SetGenPreMasterCtx(WOLFSSL* ssl, void *ctx);
  3287. WOLFSSL_API void* wolfSSL_GetGenPreMasterCtx(WOLFSSL* ssl);
  3288. typedef int (*CallbackGenSessionKey)(WOLFSSL* ssl, void* ctx);
  3289. WOLFSSL_API void wolfSSL_CTX_SetGenSessionKeyCb(WOLFSSL_CTX* ctx,
  3290. CallbackGenSessionKey cb);
  3291. WOLFSSL_API void wolfSSL_SetGenSessionKeyCtx(WOLFSSL* ssl, void *ctx);
  3292. WOLFSSL_API void* wolfSSL_GetGenSessionKeyCtx(WOLFSSL* ssl);
  3293. typedef int (*CallbackEncryptKeys)(WOLFSSL* ssl, void* ctx);
  3294. WOLFSSL_API void wolfSSL_CTX_SetEncryptKeysCb(WOLFSSL_CTX* ctx,
  3295. CallbackEncryptKeys cb);
  3296. WOLFSSL_API void wolfSSL_SetEncryptKeysCtx(WOLFSSL* ssl, void *ctx);
  3297. WOLFSSL_API void* wolfSSL_GetEncryptKeysCtx(WOLFSSL* ssl);
  3298. typedef int (*CallbackTlsFinished)(WOLFSSL* ssl,
  3299. const byte *side,
  3300. const byte *handshake_hash, word32 hashSz,
  3301. byte *hashes, void* ctx);
  3302. WOLFSSL_API void wolfSSL_CTX_SetTlsFinishedCb(WOLFSSL_CTX* ctx, CallbackTlsFinished cb);
  3303. WOLFSSL_API void wolfSSL_SetTlsFinishedCtx(WOLFSSL* ssl, void *ctx);
  3304. WOLFSSL_API void* wolfSSL_GetTlsFinishedCtx(WOLFSSL* ssl);
  3305. #if !defined(WOLFSSL_NO_TLS12) && !defined(WOLFSSL_AEAD_ONLY)
  3306. typedef int (*CallbackVerifyMac)(WOLFSSL *ssl, const byte* message,
  3307. word32 messageSz, word32 macSz, word32 content, void* ctx);
  3308. WOLFSSL_API void wolfSSL_CTX_SetVerifyMacCb(WOLFSSL_CTX* ctx, CallbackVerifyMac cb);
  3309. WOLFSSL_API void wolfSSL_SetVerifyMacCtx(WOLFSSL* ssl, void *ctx);
  3310. WOLFSSL_API void* wolfSSL_GetVerifyMacCtx(WOLFSSL* ssl);
  3311. #endif
  3312. typedef int (*CallbackHKDFExpandLabel)(byte* okm, word32 okmLen,
  3313. const byte* prk, word32 prkLen,
  3314. const byte* protocol, word32 protocolLen,
  3315. const byte* label, word32 labelLen,
  3316. const byte* info, word32 infoLen,
  3317. int digest, int side);
  3318. WOLFSSL_API void wolfSSL_CTX_SetHKDFExpandLabelCb(WOLFSSL_CTX* ctx,
  3319. CallbackHKDFExpandLabel cb);
  3320. typedef int (*CallbackProcessServerSigKex)(WOLFSSL* ssl, byte p_sig_algo,
  3321. const byte* p_sig, word32 p_sig_len,
  3322. const byte* p_rand, word32 p_rand_len,
  3323. const byte* p_server_params, word32 p_server_params_len);
  3324. WOLFSSL_API void wolfSSL_CTX_SetProcessServerSigKexCb(WOLFSSL_CTX* ctx,
  3325. CallbackProcessServerSigKex cb);
  3326. typedef int (*CallbackPerformTlsRecordProcessing)(WOLFSSL* ssl, int is_encrypt,
  3327. byte* out, const byte* in, word32 sz,
  3328. const byte* iv, word32 ivSz,
  3329. byte* authTag, word32 authTagSz,
  3330. const byte* authIn, word32 authInSz);
  3331. WOLFSSL_API void wolfSSL_CTX_SetPerformTlsRecordProcessingCb(WOLFSSL_CTX* ctx,
  3332. CallbackPerformTlsRecordProcessing cb);
  3333. #endif /* HAVE_PK_CALLBACKS */
  3334. #ifndef NO_CERTS
  3335. WOLFSSL_API void wolfSSL_CTX_SetCACb(WOLFSSL_CTX* ctx, CallbackCACache cb);
  3336. WOLFSSL_API WOLFSSL_CERT_MANAGER* wolfSSL_CTX_GetCertManager(WOLFSSL_CTX* ctx);
  3337. WOLFSSL_API WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew_ex(void* heap);
  3338. WOLFSSL_API WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew(void);
  3339. WOLFSSL_API void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER* cm);
  3340. WOLFSSL_API int wolfSSL_CertManager_up_ref(WOLFSSL_CERT_MANAGER* cm);
  3341. #ifdef WC_ASN_UNKNOWN_EXT_CB
  3342. WOLFSSL_API void wolfSSL_CertManagerSetUnknownExtCallback(
  3343. WOLFSSL_CERT_MANAGER* cm,
  3344. wc_UnknownExtCallback cb);
  3345. #endif
  3346. WOLFSSL_API int wolfSSL_CertManagerLoadCA(WOLFSSL_CERT_MANAGER* cm,
  3347. const char* f, const char* d);
  3348. WOLFSSL_API int wolfSSL_CertManagerLoadCABuffer_ex(WOLFSSL_CERT_MANAGER* cm,
  3349. const unsigned char* buff, long sz, int format, int userChain,
  3350. word32 flags);
  3351. WOLFSSL_API int wolfSSL_CertManagerLoadCABuffer(WOLFSSL_CERT_MANAGER* cm,
  3352. const unsigned char* buff, long sz, int format);
  3353. WOLFSSL_API int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm);
  3354. WOLFSSL_API int wolfSSL_CertManagerUnloadIntermediateCerts(
  3355. WOLFSSL_CERT_MANAGER* cm);
  3356. #ifdef WOLFSSL_TRUST_PEER_CERT
  3357. WOLFSSL_API int wolfSSL_CertManagerUnload_trust_peers(
  3358. WOLFSSL_CERT_MANAGER* cm);
  3359. #endif
  3360. WOLFSSL_API int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm,
  3361. const char* f, int format);
  3362. WOLFSSL_API int wolfSSL_CertManagerVerifyBuffer(WOLFSSL_CERT_MANAGER* cm,
  3363. const unsigned char* buff, long sz, int format);
  3364. WOLFSSL_API int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER* cm,
  3365. const unsigned char* der, int sz);
  3366. WOLFSSL_API int wolfSSL_CertManagerEnableCRL(WOLFSSL_CERT_MANAGER* cm,
  3367. int options);
  3368. WOLFSSL_API int wolfSSL_CertManagerDisableCRL(WOLFSSL_CERT_MANAGER* cm);
  3369. WOLFSSL_API void wolfSSL_CertManagerSetVerify(WOLFSSL_CERT_MANAGER* cm,
  3370. VerifyCallback vc);
  3371. WOLFSSL_API int wolfSSL_CertManagerLoadCRL(WOLFSSL_CERT_MANAGER* cm,
  3372. const char* path, int type, int monitor);
  3373. WOLFSSL_API int wolfSSL_CertManagerLoadCRLFile(WOLFSSL_CERT_MANAGER* cm,
  3374. const char* file, int type);
  3375. WOLFSSL_API int wolfSSL_CertManagerLoadCRLBuffer(WOLFSSL_CERT_MANAGER* cm,
  3376. const unsigned char* buff, long sz, int type);
  3377. WOLFSSL_API int wolfSSL_CertManagerSetCRL_Cb(WOLFSSL_CERT_MANAGER* cm,
  3378. CbMissingCRL cb);
  3379. WOLFSSL_API int wolfSSL_CertManagerSetCRL_ErrorCb(WOLFSSL_CERT_MANAGER* cm,
  3380. crlErrorCb cb, void* ctx);
  3381. WOLFSSL_API int wolfSSL_CertManagerFreeCRL(WOLFSSL_CERT_MANAGER* cm);
  3382. #ifdef HAVE_CRL_IO
  3383. WOLFSSL_API int wolfSSL_CertManagerSetCRL_IOCb(WOLFSSL_CERT_MANAGER* cm,
  3384. CbCrlIO cb);
  3385. #endif
  3386. #if defined(HAVE_OCSP)
  3387. WOLFSSL_API int wolfSSL_CertManagerCheckOCSPResponse(
  3388. WOLFSSL_CERT_MANAGER* cm, unsigned char *response, int responseSz,
  3389. WOLFSSL_BUFFER_INFO *responseBuffer, CertStatus *status,
  3390. OcspEntry *entry, OcspRequest *ocspRequest);
  3391. #endif
  3392. WOLFSSL_API int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER* cm,
  3393. const unsigned char* der, int sz);
  3394. WOLFSSL_API int wolfSSL_CertManagerEnableOCSP(WOLFSSL_CERT_MANAGER* cm,
  3395. int options);
  3396. WOLFSSL_API int wolfSSL_CertManagerDisableOCSP(WOLFSSL_CERT_MANAGER* cm);
  3397. WOLFSSL_API int wolfSSL_CertManagerSetOCSPOverrideURL(
  3398. WOLFSSL_CERT_MANAGER* cm, const char* url);
  3399. WOLFSSL_API int wolfSSL_CertManagerSetOCSP_Cb(WOLFSSL_CERT_MANAGER* cm,
  3400. CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx);
  3401. WOLFSSL_API int wolfSSL_CertManagerEnableOCSPStapling(
  3402. WOLFSSL_CERT_MANAGER* cm);
  3403. WOLFSSL_API int wolfSSL_CertManagerDisableOCSPStapling(
  3404. WOLFSSL_CERT_MANAGER* cm);
  3405. WOLFSSL_API int wolfSSL_CertManagerEnableOCSPMustStaple(
  3406. WOLFSSL_CERT_MANAGER* cm);
  3407. WOLFSSL_API int wolfSSL_CertManagerDisableOCSPMustStaple(
  3408. WOLFSSL_CERT_MANAGER* cm);
  3409. #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_SIGNER_DER_CERT) && \
  3410. !defined(NO_FILESYSTEM)
  3411. WOLFSSL_API WOLFSSL_STACK* wolfSSL_CertManagerGetCerts(
  3412. WOLFSSL_CERT_MANAGER* cm);
  3413. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_X509_STORE_get1_certs(
  3414. WOLFSSL_X509_STORE_CTX* ctx, WOLFSSL_X509_NAME* name);
  3415. #endif /* OPENSSL_EXTRA && WOLFSSL_SIGNER_DER_CERT && !NO_FILESYSTEM */
  3416. WOLFSSL_API int wolfSSL_EnableCRL(WOLFSSL* ssl, int options);
  3417. WOLFSSL_API int wolfSSL_DisableCRL(WOLFSSL* ssl);
  3418. WOLFSSL_API int wolfSSL_LoadCRL(WOLFSSL* ssl, const char* path, int type, int monitor);
  3419. WOLFSSL_API int wolfSSL_LoadCRLFile(WOLFSSL* ssl, const char* file, int type);
  3420. WOLFSSL_API int wolfSSL_LoadCRLBuffer(WOLFSSL* ssl,
  3421. const unsigned char* buff, long sz, int type);
  3422. WOLFSSL_API int wolfSSL_SetCRL_Cb(WOLFSSL* ssl, CbMissingCRL cb);
  3423. WOLFSSL_API int wolfSSL_SetCRL_ErrorCb(WOLFSSL* ssl, crlErrorCb cb,
  3424. void* ctx);
  3425. #ifdef HAVE_CRL_IO
  3426. WOLFSSL_API int wolfSSL_SetCRL_IOCb(WOLFSSL* ssl, CbCrlIO cb);
  3427. #endif
  3428. WOLFSSL_API int wolfSSL_EnableOCSP(WOLFSSL* ssl, int options);
  3429. WOLFSSL_API int wolfSSL_DisableOCSP(WOLFSSL* ssl);
  3430. WOLFSSL_API int wolfSSL_SetOCSP_OverrideURL(WOLFSSL* ssl, const char* url);
  3431. WOLFSSL_API int wolfSSL_SetOCSP_Cb(WOLFSSL* ssl, CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx);
  3432. WOLFSSL_API int wolfSSL_EnableOCSPStapling(WOLFSSL* ssl);
  3433. WOLFSSL_API int wolfSSL_DisableOCSPStapling(WOLFSSL* ssl);
  3434. WOLFSSL_API int wolfSSL_CTX_EnableCRL(WOLFSSL_CTX* ctx, int options);
  3435. WOLFSSL_API int wolfSSL_CTX_DisableCRL(WOLFSSL_CTX* ctx);
  3436. WOLFSSL_API int wolfSSL_CTX_LoadCRL(WOLFSSL_CTX* ctx, const char* path, int type, int monitor);
  3437. WOLFSSL_API int wolfSSL_CTX_LoadCRLFile(WOLFSSL_CTX* ctx, const char* path, int type);
  3438. WOLFSSL_API int wolfSSL_CTX_LoadCRLBuffer(WOLFSSL_CTX* ctx,
  3439. const unsigned char* buff, long sz, int type);
  3440. WOLFSSL_API int wolfSSL_CTX_SetCRL_Cb(WOLFSSL_CTX* ctx, CbMissingCRL cb);
  3441. WOLFSSL_API int wolfSSL_CTX_SetCRL_ErrorCb(WOLFSSL_CTX* ctx, crlErrorCb cb,
  3442. void* cbCtx);
  3443. #ifdef HAVE_CRL_IO
  3444. WOLFSSL_API int wolfSSL_CTX_SetCRL_IOCb(WOLFSSL_CTX* ctx, CbCrlIO cb);
  3445. #endif
  3446. WOLFSSL_API int wolfSSL_CTX_EnableOCSP(WOLFSSL_CTX* ctx, int options);
  3447. WOLFSSL_API int wolfSSL_CTX_DisableOCSP(WOLFSSL_CTX* ctx);
  3448. WOLFSSL_API int wolfSSL_CTX_SetOCSP_OverrideURL(WOLFSSL_CTX* ctx, const char* url);
  3449. WOLFSSL_API int wolfSSL_CTX_SetOCSP_Cb(WOLFSSL_CTX* ctx,
  3450. CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx);
  3451. WOLFSSL_API int wolfSSL_CTX_EnableOCSPStapling(WOLFSSL_CTX* ctx);
  3452. WOLFSSL_API int wolfSSL_CTX_DisableOCSPStapling(WOLFSSL_CTX* ctx);
  3453. WOLFSSL_API int wolfSSL_CTX_EnableOCSPMustStaple(WOLFSSL_CTX* ctx);
  3454. WOLFSSL_API int wolfSSL_CTX_DisableOCSPMustStaple(WOLFSSL_CTX* ctx);
  3455. #endif /* !NO_CERTS */
  3456. #ifdef SINGLE_THREADED
  3457. WOLFSSL_API int wolfSSL_CTX_new_rng(WOLFSSL_CTX* ctx);
  3458. #endif
  3459. /* end of handshake frees temporary arrays, if user needs for get_keys or
  3460. psk hints, call KeepArrays before handshake and then FreeArrays when done
  3461. if don't want to wait for object free */
  3462. WOLFSSL_API void wolfSSL_KeepArrays(WOLFSSL* ssl);
  3463. WOLFSSL_API void wolfSSL_FreeArrays(WOLFSSL* ssl);
  3464. WOLFSSL_API int wolfSSL_KeepHandshakeResources(WOLFSSL* ssl);
  3465. WOLFSSL_API int wolfSSL_FreeHandshakeResources(WOLFSSL* ssl);
  3466. WOLFSSL_API int wolfSSL_CTX_UseClientSuites(WOLFSSL_CTX* ctx);
  3467. WOLFSSL_API int wolfSSL_UseClientSuites(WOLFSSL* ssl);
  3468. /* async additions */
  3469. #define wolfSSL_UseAsync wolfSSL_SetDevId
  3470. #define wolfSSL_CTX_UseAsync wolfSSL_CTX_SetDevId
  3471. WOLFSSL_ABI WOLFSSL_API int wolfSSL_SetDevId(WOLFSSL* ssl, int devId);
  3472. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_SetDevId(WOLFSSL_CTX* ctx, int devId);
  3473. /* helpers to get device id and heap */
  3474. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_GetDevId(WOLFSSL_CTX* ctx, WOLFSSL* ssl);
  3475. WOLFSSL_API void* wolfSSL_CTX_GetHeap(WOLFSSL_CTX* ctx, WOLFSSL* ssl);
  3476. /* TLS Extensions */
  3477. /* Server Name Indication */
  3478. #ifdef HAVE_SNI
  3479. /* SNI types */
  3480. enum {
  3481. WOLFSSL_SNI_HOST_NAME = 0,
  3482. };
  3483. WOLFSSL_ABI WOLFSSL_API int wolfSSL_UseSNI(WOLFSSL* ssl, unsigned char type,
  3484. const void* data, unsigned short size);
  3485. WOLFSSL_ABI WOLFSSL_API int wolfSSL_CTX_UseSNI(WOLFSSL_CTX* ctx, unsigned char type,
  3486. const void* data, unsigned short size);
  3487. #ifndef NO_WOLFSSL_SERVER
  3488. /* SNI options */
  3489. enum {
  3490. /* Do not abort the handshake if the requested SNI didn't match. */
  3491. WOLFSSL_SNI_CONTINUE_ON_MISMATCH = 0x01,
  3492. /* Behave as if the requested SNI matched in a case of mismatch. */
  3493. /* In this case, the status will be set to WOLFSSL_SNI_FAKE_MATCH. */
  3494. WOLFSSL_SNI_ANSWER_ON_MISMATCH = 0x02,
  3495. /* Abort the handshake if the client didn't send a SNI request. */
  3496. WOLFSSL_SNI_ABORT_ON_ABSENCE = 0x04,
  3497. };
  3498. WOLFSSL_API void wolfSSL_SNI_SetOptions(WOLFSSL* ssl, unsigned char type,
  3499. unsigned char options);
  3500. WOLFSSL_API void wolfSSL_CTX_SNI_SetOptions(WOLFSSL_CTX* ctx,
  3501. unsigned char type, unsigned char options);
  3502. WOLFSSL_API int wolfSSL_SNI_GetFromBuffer(
  3503. const unsigned char* clientHello, unsigned int helloSz,
  3504. unsigned char type, unsigned char* sni, unsigned int* inOutSz);
  3505. #endif /* NO_WOLFSSL_SERVER */
  3506. /* SNI status */
  3507. enum {
  3508. WOLFSSL_SNI_NO_MATCH = 0,
  3509. WOLFSSL_SNI_FAKE_MATCH = 1, /**< @see WOLFSSL_SNI_ANSWER_ON_MISMATCH */
  3510. WOLFSSL_SNI_REAL_MATCH = 2,
  3511. WOLFSSL_SNI_FORCE_KEEP = 3 /** Used with -DWOLFSSL_ALWAYS_KEEP_SNI */
  3512. };
  3513. WOLFSSL_API unsigned char wolfSSL_SNI_Status(WOLFSSL* ssl, unsigned char type);
  3514. WOLFSSL_API unsigned short wolfSSL_SNI_GetRequest(WOLFSSL *ssl,
  3515. unsigned char type, void** data);
  3516. #endif /* HAVE_SNI */
  3517. /* Trusted CA Key Indication - RFC 6066 (Section 6) */
  3518. #ifdef HAVE_TRUSTED_CA
  3519. /* TCA Identifier Type */
  3520. enum {
  3521. WOLFSSL_TRUSTED_CA_PRE_AGREED = 0,
  3522. WOLFSSL_TRUSTED_CA_KEY_SHA1 = 1,
  3523. WOLFSSL_TRUSTED_CA_X509_NAME = 2,
  3524. WOLFSSL_TRUSTED_CA_CERT_SHA1 = 3
  3525. };
  3526. WOLFSSL_API int wolfSSL_UseTrustedCA(WOLFSSL* ssl, unsigned char type,
  3527. const unsigned char* certId, unsigned int certIdSz);
  3528. #endif /* HAVE_TRUSTED_CA */
  3529. /* Application-Layer Protocol Negotiation */
  3530. #ifdef HAVE_ALPN
  3531. /* ALPN status code */
  3532. enum {
  3533. WOLFSSL_ALPN_NO_MATCH = 0,
  3534. WOLFSSL_ALPN_MATCH = 1,
  3535. WOLFSSL_ALPN_CONTINUE_ON_MISMATCH = 2,
  3536. WOLFSSL_ALPN_FAILED_ON_MISMATCH = 4,
  3537. };
  3538. enum {
  3539. WOLFSSL_MAX_ALPN_PROTO_NAME_LEN = 255,
  3540. WOLFSSL_MAX_ALPN_NUMBER = 257
  3541. };
  3542. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || \
  3543. defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY) || \
  3544. defined(WOLFSSL_QUIC)
  3545. typedef int (*CallbackALPNSelect)(WOLFSSL* ssl, const unsigned char** out,
  3546. unsigned char* outLen, const unsigned char* in, unsigned int inLen,
  3547. void *arg);
  3548. #endif
  3549. WOLFSSL_ABI WOLFSSL_API int wolfSSL_UseALPN(WOLFSSL* ssl,
  3550. char *protocol_name_list,
  3551. unsigned int protocol_name_listSz,
  3552. unsigned char options);
  3553. WOLFSSL_API int wolfSSL_ALPN_GetProtocol(WOLFSSL* ssl, char **protocol_name,
  3554. unsigned short *size);
  3555. WOLFSSL_API int wolfSSL_ALPN_GetPeerProtocol(WOLFSSL* ssl, char **list,
  3556. unsigned short *listSz);
  3557. WOLFSSL_API int wolfSSL_ALPN_FreePeerProtocol(WOLFSSL* ssl, char **list);
  3558. #endif /* HAVE_ALPN */
  3559. /* Maximum Fragment Length */
  3560. #ifdef HAVE_MAX_FRAGMENT
  3561. /* Fragment lengths */
  3562. enum {
  3563. WOLFSSL_MFL_DISABLED = 0,
  3564. WOLFSSL_MFL_2_9 = 1, /* 512 bytes */
  3565. WOLFSSL_MFL_2_10 = 2, /* 1024 bytes */
  3566. WOLFSSL_MFL_2_11 = 3, /* 2048 bytes */
  3567. WOLFSSL_MFL_2_12 = 4, /* 4096 bytes */
  3568. WOLFSSL_MFL_2_13 = 5, /* 8192 bytes *//* wolfSSL ONLY!!! */
  3569. WOLFSSL_MFL_2_8 = 6, /* 256 bytes *//* wolfSSL ONLY!!! */
  3570. WOLFSSL_MFL_MIN = WOLFSSL_MFL_2_9,
  3571. WOLFSSL_MFL_MAX = WOLFSSL_MFL_2_8,
  3572. };
  3573. #ifndef NO_WOLFSSL_CLIENT
  3574. WOLFSSL_API int wolfSSL_UseMaxFragment(WOLFSSL* ssl, unsigned char mfl);
  3575. WOLFSSL_API int wolfSSL_CTX_UseMaxFragment(WOLFSSL_CTX* ctx, unsigned char mfl);
  3576. #endif
  3577. #endif /* HAVE_MAX_FRAGMENT */
  3578. /* Truncated HMAC */
  3579. #ifdef HAVE_TRUNCATED_HMAC
  3580. #ifndef NO_WOLFSSL_CLIENT
  3581. WOLFSSL_API int wolfSSL_UseTruncatedHMAC(WOLFSSL* ssl);
  3582. WOLFSSL_API int wolfSSL_CTX_UseTruncatedHMAC(WOLFSSL_CTX* ctx);
  3583. #endif
  3584. #endif
  3585. /* Certificate Status Request */
  3586. /* Certificate Status Type */
  3587. enum {
  3588. WOLFSSL_CSR_OCSP = 1
  3589. };
  3590. /* Certificate Status Options (flags) */
  3591. enum {
  3592. WOLFSSL_CSR_OCSP_USE_NONCE = 0x01
  3593. };
  3594. #ifdef HAVE_CERTIFICATE_STATUS_REQUEST
  3595. #ifndef NO_WOLFSSL_CLIENT
  3596. WOLFSSL_API int wolfSSL_UseOCSPStapling(WOLFSSL* ssl,
  3597. unsigned char status_type, unsigned char options);
  3598. WOLFSSL_API int wolfSSL_CTX_UseOCSPStapling(WOLFSSL_CTX* ctx,
  3599. unsigned char status_type, unsigned char options);
  3600. #endif
  3601. #endif
  3602. /* Certificate Status Request v2 */
  3603. /* Certificate Status Type */
  3604. enum {
  3605. WOLFSSL_CSR2_OCSP = 1,
  3606. WOLFSSL_CSR2_OCSP_MULTI = 2
  3607. };
  3608. /* Certificate Status v2 Options (flags) */
  3609. enum {
  3610. WOLFSSL_CSR2_OCSP_USE_NONCE = 0x01
  3611. };
  3612. #ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2
  3613. #ifndef NO_WOLFSSL_CLIENT
  3614. WOLFSSL_API int wolfSSL_UseOCSPStaplingV2(WOLFSSL* ssl,
  3615. unsigned char status_type, unsigned char options);
  3616. WOLFSSL_API int wolfSSL_CTX_UseOCSPStaplingV2(WOLFSSL_CTX* ctx,
  3617. unsigned char status_type, unsigned char options);
  3618. #endif
  3619. #endif
  3620. /* Named Groups */
  3621. enum {
  3622. WOLFSSL_NAMED_GROUP_INVALID = 0,
  3623. #if 0 /* Not Supported */
  3624. WOLFSSL_ECC_SECT163K1 = 1,
  3625. WOLFSSL_ECC_SECT163R1 = 2,
  3626. WOLFSSL_ECC_SECT163R2 = 3,
  3627. WOLFSSL_ECC_SECT193R1 = 4,
  3628. WOLFSSL_ECC_SECT193R2 = 5,
  3629. WOLFSSL_ECC_SECT233K1 = 6,
  3630. WOLFSSL_ECC_SECT233R1 = 7,
  3631. WOLFSSL_ECC_SECT239K1 = 8,
  3632. WOLFSSL_ECC_SECT283K1 = 9,
  3633. WOLFSSL_ECC_SECT283R1 = 10,
  3634. WOLFSSL_ECC_SECT409K1 = 11,
  3635. WOLFSSL_ECC_SECT409R1 = 12,
  3636. WOLFSSL_ECC_SECT571K1 = 13,
  3637. WOLFSSL_ECC_SECT571R1 = 14,
  3638. #endif
  3639. WOLFSSL_ECC_SECP160K1 = 15,
  3640. WOLFSSL_ECC_SECP160R1 = 16,
  3641. WOLFSSL_ECC_SECP160R2 = 17,
  3642. WOLFSSL_ECC_SECP192K1 = 18,
  3643. WOLFSSL_ECC_SECP192R1 = 19,
  3644. WOLFSSL_ECC_SECP224K1 = 20,
  3645. WOLFSSL_ECC_SECP224R1 = 21,
  3646. WOLFSSL_ECC_SECP256K1 = 22,
  3647. WOLFSSL_ECC_SECP256R1 = 23,
  3648. WOLFSSL_ECC_SECP384R1 = 24,
  3649. WOLFSSL_ECC_SECP521R1 = 25,
  3650. WOLFSSL_ECC_BRAINPOOLP256R1 = 26,
  3651. WOLFSSL_ECC_BRAINPOOLP384R1 = 27,
  3652. WOLFSSL_ECC_BRAINPOOLP512R1 = 28,
  3653. WOLFSSL_ECC_X25519 = 29,
  3654. WOLFSSL_ECC_X448 = 30,
  3655. WOLFSSL_ECC_SM2P256V1 = 41,
  3656. WOLFSSL_ECC_MAX = 41,
  3657. WOLFSSL_ECC_MAX_AVAIL = 46,
  3658. /* Update use of disabled curves when adding value greater than 46. */
  3659. WOLFSSL_FFDHE_START = 256,
  3660. WOLFSSL_FFDHE_2048 = 256,
  3661. WOLFSSL_FFDHE_3072 = 257,
  3662. WOLFSSL_FFDHE_4096 = 258,
  3663. WOLFSSL_FFDHE_6144 = 259,
  3664. WOLFSSL_FFDHE_8192 = 260,
  3665. #ifdef HAVE_PQC
  3666. /* These group numbers were taken from OQS's openssl provider, see:
  3667. * https://github.com/open-quantum-safe/oqs-provider/blob/main/oqs-template/
  3668. * oqs-kem-info.md.
  3669. *
  3670. * The levels in the group name refer to the claimed NIST level of each
  3671. * parameter set. The associated parameter set name is listed as a comment
  3672. * beside the group number. Please see the NIST PQC Competition's submitted
  3673. * papers for more details.
  3674. *
  3675. * LEVEL1 means that an attack on that parameter set would require the same
  3676. * or more resources as a key search on AES 128. LEVEL3 would require the
  3677. * same or more resources as a key search on AES 192. LEVEL5 would require
  3678. * the same or more resources as a key search on AES 256. None of the
  3679. * algorithms have LEVEL2 and LEVEL4 because none of these submissions
  3680. * included them. */
  3681. #ifndef WOLFSSL_ML_KEM
  3682. WOLFSSL_PQC_MIN = 570,
  3683. WOLFSSL_PQC_SIMPLE_MIN = 570,
  3684. WOLFSSL_KYBER_LEVEL1 = 570, /* KYBER_512 */
  3685. WOLFSSL_KYBER_LEVEL3 = 572, /* KYBER_768 */
  3686. WOLFSSL_KYBER_LEVEL5 = 573, /* KYBER_1024 */
  3687. WOLFSSL_PQC_SIMPLE_MAX = 573,
  3688. WOLFSSL_PQC_HYBRID_MIN = 12090,
  3689. WOLFSSL_P256_KYBER_LEVEL1 = 12090,
  3690. WOLFSSL_P384_KYBER_LEVEL3 = 12092,
  3691. WOLFSSL_P521_KYBER_LEVEL5 = 12093,
  3692. WOLFSSL_PQC_HYBRID_MAX = 12093,
  3693. WOLFSSL_PQC_MAX = 12093,
  3694. #else
  3695. WOLFSSL_PQC_MIN = 583,
  3696. WOLFSSL_PQC_SIMPLE_MIN = 583,
  3697. WOLFSSL_KYBER_LEVEL1 = 583, /* ML-KEM 512 */
  3698. WOLFSSL_KYBER_LEVEL3 = 584, /* ML-KEM 768 */
  3699. WOLFSSL_KYBER_LEVEL5 = 585, /* ML-KEM 1024 */
  3700. WOLFSSL_PQC_SIMPLE_MAX = 585,
  3701. WOLFSSL_PQC_HYBRID_MIN = 12103,
  3702. WOLFSSL_P256_KYBER_LEVEL1 = 12103,
  3703. WOLFSSL_P384_KYBER_LEVEL3 = 12104,
  3704. WOLFSSL_P521_KYBER_LEVEL5 = 12105,
  3705. WOLFSSL_PQC_HYBRID_MAX = 12105,
  3706. WOLFSSL_PQC_MAX = 12105,
  3707. #endif /* WOLFSSL_ML_KEM */
  3708. #endif /* HAVE_PQC */
  3709. };
  3710. enum {
  3711. WOLFSSL_EC_PF_UNCOMPRESSED = 0,
  3712. #if 0 /* Not Supported */
  3713. WOLFSSL_EC_PF_X962_COMP_PRIME = 1,
  3714. WOLFSSL_EC_PF_X962_COMP_CHAR2 = 2,
  3715. #endif
  3716. };
  3717. #ifdef HAVE_SUPPORTED_CURVES
  3718. WOLFSSL_API int wolfSSL_UseSupportedCurve(WOLFSSL* ssl, word16 name);
  3719. WOLFSSL_API int wolfSSL_CTX_UseSupportedCurve(WOLFSSL_CTX* ctx,
  3720. word16 name);
  3721. #endif
  3722. #ifdef WOLFSSL_TLS13
  3723. WOLFSSL_API int wolfSSL_UseKeyShare(WOLFSSL* ssl, word16 group);
  3724. WOLFSSL_API int wolfSSL_NoKeyShares(WOLFSSL* ssl);
  3725. #endif
  3726. #ifdef WOLFSSL_DUAL_ALG_CERTS
  3727. #define WOLFSSL_CKS_SIGSPEC_NATIVE 0x0001
  3728. #define WOLFSSL_CKS_SIGSPEC_ALTERNATIVE 0x0002
  3729. #define WOLFSSL_CKS_SIGSPEC_BOTH 0x0003
  3730. #define WOLFSSL_CKS_SIGSPEC_EXTERNAL 0x0004
  3731. WOLFSSL_API int wolfSSL_UseCKS(WOLFSSL* ssl, byte *sigSpec, word16 sigSpecSz);
  3732. WOLFSSL_API int wolfSSL_CTX_UseCKS(WOLFSSL_CTX* ctx, byte *sigSpec,
  3733. word16 sigSpecSz);
  3734. #endif /* WOLFSSL_DUAL_ALG_CERTS */
  3735. /* Secure Renegotiation */
  3736. #if defined(HAVE_SECURE_RENEGOTIATION) || defined(HAVE_SERVER_RENEGOTIATION_INFO)
  3737. WOLFSSL_API int wolfSSL_UseSecureRenegotiation(WOLFSSL* ssl);
  3738. WOLFSSL_API int wolfSSL_CTX_UseSecureRenegotiation(WOLFSSL_CTX* ctx);
  3739. #ifdef HAVE_SECURE_RENEGOTIATION
  3740. WOLFSSL_API int wolfSSL_Rehandshake(WOLFSSL* ssl);
  3741. WOLFSSL_API int wolfSSL_SecureResume(WOLFSSL* ssl);
  3742. #endif
  3743. WOLFSSL_API long wolfSSL_SSL_get_secure_renegotiation_support(WOLFSSL* ssl);
  3744. #endif
  3745. #if defined(HAVE_SELFTEST) && \
  3746. (!defined(HAVE_SELFTEST_VERSION) || (HAVE_SELFTEST_VERSION < 2))
  3747. /* Needed by session ticket stuff below */
  3748. #ifndef WOLFSSL_AES_KEY_SIZE_ENUM
  3749. #define WOLFSSL_AES_KEY_SIZE_ENUM
  3750. enum SSL_Misc {
  3751. AES_IV_SIZE = 16,
  3752. AES_128_KEY_SIZE = 16,
  3753. AES_192_KEY_SIZE = 24,
  3754. AES_256_KEY_SIZE = 32
  3755. };
  3756. #endif
  3757. #endif
  3758. /* Session Ticket */
  3759. #ifdef HAVE_SESSION_TICKET
  3760. #if !defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && !defined(NO_WOLFSSL_SERVER)
  3761. #ifdef WOLFSSL_TICKET_ENC_CBC_HMAC
  3762. #if defined(WOLFSSL_TICKET_ENC_HMAC_SHA512)
  3763. #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA512
  3764. #define WOLFSSL_TICKET_HMAC_KEY_SZ 64
  3765. #elif defined(WOLFSSL_TICKET_ENC_HMAC_SHA384)
  3766. #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA384
  3767. #define WOLFSSL_TICKET_HMAC_KEY_SZ 48
  3768. #else
  3769. #define WOLFSSL_TICKET_ENC_HMAC WC_HASH_TYPE_SHA256
  3770. #define WOLFSSL_TICKET_HMAC_KEY_SZ 32
  3771. #endif
  3772. #ifdef WOLFSSL_TICKET_ENC_AES256_CBC
  3773. #define WOLFSSL_TICKET_KEY_SZ \
  3774. (AES_256_KEY_SIZE + WOLFSSL_TICKET_HMAC_KEY_SZ)
  3775. #else
  3776. #define WOLFSSL_TICKET_KEY_SZ \
  3777. (AES_128_KEY_SIZE + WOLFSSL_TICKET_HMAC_KEY_SZ)
  3778. #endif
  3779. #elif defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && \
  3780. !defined(WOLFSSL_TICKET_ENC_AES128_GCM) && \
  3781. !defined(WOLFSSL_TICKET_ENC_AES256_GCM)
  3782. #define WOLFSSL_TICKET_KEY_SZ CHACHA20_POLY1305_AEAD_KEYSIZE
  3783. #elif defined(WOLFSSL_TICKET_ENC_AES256_GCM)
  3784. #define WOLFSSL_TICKET_KEY_SZ AES_256_KEY_SIZE
  3785. #else
  3786. #define WOLFSSL_TICKET_KEY_SZ AES_128_KEY_SIZE
  3787. #endif
  3788. #define WOLFSSL_TICKET_KEYS_SZ (WOLFSSL_TICKET_NAME_SZ + \
  3789. 2 * WOLFSSL_TICKET_KEY_SZ + \
  3790. sizeof(word32) * 2)
  3791. #endif
  3792. #ifndef NO_WOLFSSL_CLIENT
  3793. WOLFSSL_API int wolfSSL_UseSessionTicket(WOLFSSL* ssl);
  3794. WOLFSSL_API int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx);
  3795. WOLFSSL_API int wolfSSL_get_SessionTicket(WOLFSSL* ssl, unsigned char* buf, word32* bufSz);
  3796. WOLFSSL_API int wolfSSL_set_SessionTicket(WOLFSSL* ssl, const unsigned char* buf, word32 bufSz);
  3797. typedef int (*CallbackSessionTicket)(WOLFSSL* ssl, const unsigned char*, int, void*);
  3798. WOLFSSL_API int wolfSSL_set_SessionTicket_cb(WOLFSSL* ssl,
  3799. CallbackSessionTicket cb, void* ctx);
  3800. #endif /* NO_WOLFSSL_CLIENT */
  3801. #ifndef NO_WOLFSSL_SERVER
  3802. WOLFSSL_API int wolfSSL_send_SessionTicket(WOLFSSL* ssl);
  3803. #endif /* !NO_WOLFSSL_SERVER */
  3804. #define WOLFSSL_TICKET_NAME_SZ 16
  3805. #define WOLFSSL_TICKET_IV_SZ 16
  3806. #ifndef WOLFSSL_TICKET_ENC_CBC_HMAC
  3807. #define WOLFSSL_TICKET_MAC_SZ 32
  3808. #else
  3809. #define WOLFSSL_TICKET_MAC_SZ WOLFSSL_TICKET_HMAC_KEY_SZ
  3810. #endif
  3811. enum TicketEncRet {
  3812. WOLFSSL_TICKET_RET_FATAL = -1, /* fatal error, don't use ticket */
  3813. WOLFSSL_TICKET_RET_OK = 0, /* ok, use ticket */
  3814. WOLFSSL_TICKET_RET_REJECT, /* don't use ticket, but not fatal */
  3815. WOLFSSL_TICKET_RET_CREATE /* existing ticket ok and create new one */
  3816. };
  3817. #ifndef NO_WOLFSSL_SERVER
  3818. WOLFSSL_API int wolfSSL_CTX_NoTicketTLSv12(WOLFSSL_CTX* ctx);
  3819. WOLFSSL_API int wolfSSL_NoTicketTLSv12(WOLFSSL* ssl);
  3820. typedef int (*SessionTicketEncCb)(WOLFSSL* ssl,
  3821. unsigned char key_name[WOLFSSL_TICKET_NAME_SZ],
  3822. unsigned char iv[WOLFSSL_TICKET_IV_SZ],
  3823. unsigned char mac[WOLFSSL_TICKET_MAC_SZ],
  3824. int enc, unsigned char*, int, int*, void*);
  3825. WOLFSSL_API int wolfSSL_CTX_set_TicketEncCb(WOLFSSL_CTX* ctx,
  3826. SessionTicketEncCb cb);
  3827. WOLFSSL_API int wolfSSL_CTX_set_TicketHint(WOLFSSL_CTX* ctx, int hint);
  3828. WOLFSSL_API int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void* userCtx);
  3829. WOLFSSL_API void* wolfSSL_CTX_get_TicketEncCtx(WOLFSSL_CTX* ctx);
  3830. WOLFSSL_API size_t wolfSSL_CTX_get_num_tickets(WOLFSSL_CTX* ctx);
  3831. WOLFSSL_API int wolfSSL_CTX_set_num_tickets(WOLFSSL_CTX* ctx, size_t mxTickets);
  3832. #endif /* NO_WOLFSSL_SERVER */
  3833. #endif /* HAVE_SESSION_TICKET */
  3834. /* TLS Extended Master Secret Extension */
  3835. WOLFSSL_API int wolfSSL_DisableExtendedMasterSecret(WOLFSSL* ssl);
  3836. WOLFSSL_API int wolfSSL_CTX_DisableExtendedMasterSecret(WOLFSSL_CTX* ctx);
  3837. #define WOLFSSL_CRL_MONITOR 0x01 /* monitor this dir flag */
  3838. #define WOLFSSL_CRL_START_MON 0x02 /* start monitoring flag */
  3839. #if defined(WOLFSSL_DTLS) && !defined(NO_WOLFSSL_SERVER)
  3840. /* notify user we parsed a verified ClientHello is done. This only has an effect
  3841. * on the server end. */
  3842. typedef int (*ClientHelloGoodCb)(WOLFSSL* ssl, void*);
  3843. WOLFSSL_API int wolfDTLS_SetChGoodCb(WOLFSSL* ssl, ClientHelloGoodCb cb, void* user_ctx);
  3844. #endif
  3845. /* notify user the handshake is done */
  3846. typedef int (*HandShakeDoneCb)(WOLFSSL* ssl, void*);
  3847. WOLFSSL_API int wolfSSL_SetHsDoneCb(WOLFSSL* ssl, HandShakeDoneCb cb, void* user_ctx);
  3848. WOLFSSL_API int wolfSSL_PrintSessionStats(void);
  3849. WOLFSSL_API int wolfSSL_get_session_stats(unsigned int* active,
  3850. unsigned int* total,
  3851. unsigned int* peak,
  3852. unsigned int* maxSessions);
  3853. /* External facing KDF */
  3854. WOLFSSL_API
  3855. int wolfSSL_MakeTlsMasterSecret(unsigned char* ms, word32 msLen,
  3856. const unsigned char* pms, word32 pmsLen,
  3857. const unsigned char* cr, const unsigned char* sr,
  3858. int tls1_2, int hash_type);
  3859. WOLFSSL_API
  3860. int wolfSSL_MakeTlsExtendedMasterSecret(unsigned char* ms, word32 msLen,
  3861. const unsigned char* pms, word32 pmsLen,
  3862. const unsigned char* sHash, word32 sHashLen,
  3863. int tls1_2, int hash_type);
  3864. WOLFSSL_API
  3865. int wolfSSL_DeriveTlsKeys(unsigned char* key_data, word32 keyLen,
  3866. const unsigned char* ms, word32 msLen,
  3867. const unsigned char* sr, const unsigned char* cr,
  3868. int tls1_2, int hash_type);
  3869. #ifdef WOLFSSL_CALLBACKS
  3870. typedef int (*HandShakeCallBack)(HandShakeInfo*);
  3871. typedef int (*TimeoutCallBack)(TimeoutInfo*);
  3872. /* wolfSSL connect extension allowing HandShakeCallBack and/or TimeoutCallBack
  3873. for diagnostics */
  3874. WOLFSSL_API int wolfSSL_connect_ex(WOLFSSL* ssl, HandShakeCallBack hsCb,
  3875. TimeoutCallBack toCb, WOLFSSL_TIMEVAL timeout);
  3876. WOLFSSL_API int wolfSSL_accept_ex(WOLFSSL* ssl, HandShakeCallBack hsCb,
  3877. TimeoutCallBack toCb, WOLFSSL_TIMEVAL timeout);
  3878. #endif /* WOLFSSL_CALLBACKS */
  3879. #ifdef WOLFSSL_HAVE_WOLFSCEP
  3880. WOLFSSL_API void wolfSSL_wolfSCEP(void);
  3881. #endif /* WOLFSSL_HAVE_WOLFSCEP */
  3882. #ifdef WOLFSSL_HAVE_CERT_SERVICE
  3883. WOLFSSL_API void wolfSSL_cert_service(void);
  3884. #endif
  3885. #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
  3886. /* Smaller subset of X509 compatibility functions. Avoid increasing the size of
  3887. * this subset and its memory usage */
  3888. #include <wolfssl/openssl/asn1.h>
  3889. struct WOLFSSL_X509_NAME_ENTRY {
  3890. WOLFSSL_ASN1_OBJECT* object; /* static object just for keeping grp, type */
  3891. WOLFSSL_ASN1_STRING* value; /* points to data, for lighttpd port */
  3892. int nid; /* i.e. ASN_COMMON_NAME */
  3893. int set;
  3894. int size;
  3895. };
  3896. WOLFSSL_API int wolfSSL_X509_NAME_get_index_by_OBJ(WOLFSSL_X509_NAME *name,
  3897. const WOLFSSL_ASN1_OBJECT *obj,
  3898. int idx);
  3899. enum {
  3900. WOLFSSL_SYS_ACCEPT = 0,
  3901. WOLFSSL_SYS_BIND,
  3902. WOLFSSL_SYS_CONNECT,
  3903. WOLFSSL_SYS_FOPEN,
  3904. WOLFSSL_SYS_FREAD,
  3905. WOLFSSL_SYS_GETADDRINFO,
  3906. WOLFSSL_SYS_GETSOCKOPT,
  3907. WOLFSSL_SYS_GETSOCKNAME,
  3908. WOLFSSL_SYS_GETHOSTBYNAME,
  3909. WOLFSSL_SYS_GETNAMEINFO,
  3910. WOLFSSL_SYS_GETSERVBYNAME,
  3911. WOLFSSL_SYS_IOCTLSOCKET,
  3912. WOLFSSL_SYS_LISTEN,
  3913. WOLFSSL_SYS_OPENDIR,
  3914. WOLFSSL_SYS_SETSOCKOPT,
  3915. WOLFSSL_SYS_SOCKET
  3916. };
  3917. /* Object functions */
  3918. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
  3919. /* Do not use - use wolfSSL_OBJ_sn2nid instead. */
  3920. WOLFSSL_LOCAL int wc_OBJ_sn2nid(const char *sn);
  3921. #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
  3922. WOLFSSL_API const char* wolfSSL_OBJ_nid2sn(int n);
  3923. WOLFSSL_API int wolfSSL_OBJ_obj2nid(const WOLFSSL_ASN1_OBJECT *o);
  3924. WOLFSSL_API int wolfSSL_OBJ_get_type(const WOLFSSL_ASN1_OBJECT *o);
  3925. WOLFSSL_API int wolfSSL_OBJ_sn2nid(const char *sn);
  3926. WOLFSSL_API size_t wolfSSL_OBJ_length(const WOLFSSL_ASN1_OBJECT* o);
  3927. WOLFSSL_API const unsigned char* wolfSSL_OBJ_get0_data(
  3928. const WOLFSSL_ASN1_OBJECT* o);
  3929. WOLFSSL_API const char* wolfSSL_OBJ_nid2ln(int n);
  3930. WOLFSSL_API int wolfSSL_OBJ_ln2nid(const char *ln);
  3931. WOLFSSL_API int wolfSSL_OBJ_cmp(const WOLFSSL_ASN1_OBJECT* a,
  3932. const WOLFSSL_ASN1_OBJECT* b);
  3933. WOLFSSL_API int wolfSSL_OBJ_txt2nid(const char *sn);
  3934. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_OBJ_txt2obj(const char* s, int no_name);
  3935. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_OBJ_nid2obj(int n);
  3936. WOLFSSL_LOCAL WOLFSSL_ASN1_OBJECT* wolfSSL_OBJ_nid2obj_ex(int n, WOLFSSL_ASN1_OBJECT *arg_obj);
  3937. WOLFSSL_API int wolfSSL_OBJ_obj2txt(char *buf, int buf_len,
  3938. const WOLFSSL_ASN1_OBJECT *a, int no_name);
  3939. WOLFSSL_API void wolfSSL_OBJ_cleanup(void);
  3940. WOLFSSL_API int wolfSSL_OBJ_create(const char *oid, const char *sn, const char *ln);
  3941. #ifdef HAVE_ECC
  3942. WOLFSSL_LOCAL int NIDToEccEnum(int n);
  3943. #endif
  3944. #define WOLFSSL_OBJ_NAME_TYPE_UNDEF 0x00
  3945. #define WOLFSSL_OBJ_NAME_TYPE_MD_METH 0x01
  3946. #define WOLFSSL_OBJ_NAME_TYPE_CIPHER_METH 0x02
  3947. #define WOLFSSL_OBJ_NAME_TYPE_PKEY_METH 0x03
  3948. #define WOLFSSL_OBJ_NAME_TYPE_COMP_METH 0x04
  3949. #define WOLFSSL_OBJ_NAME_TYPE_NUM 0x05
  3950. #define WOLFSSL_OBJ_NAME_ALIAS 0x8000
  3951. WOLFSSL_API void wolfSSL_OBJ_NAME_do_all(int type,
  3952. void (*fn) (const WOLFSSL_OBJ_NAME* , void *arg),
  3953. void* arg);
  3954. /* end of object functions */
  3955. WOLFSSL_API unsigned long wolfSSL_ERR_peek_last_error_line(const char **file, int *line);
  3956. WOLFSSL_API long wolfSSL_CTX_ctrl(WOLFSSL_CTX* ctx, int cmd, long opt,void* pt);
  3957. WOLFSSL_API long wolfSSL_CTX_callback_ctrl(WOLFSSL_CTX* ctx, int cmd, void (*fp)(void));
  3958. WOLFSSL_API long wolfSSL_CTX_clear_extra_chain_certs(WOLFSSL_CTX* ctx);
  3959. WOLFSSL_API void wolfSSL_certs_clear(WOLFSSL* ssl);
  3960. #ifndef NO_CERTS
  3961. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY* wolfSSL_X509_NAME_ENTRY_create_by_NID(
  3962. WOLFSSL_X509_NAME_ENTRY** out, int nid, int type,
  3963. const unsigned char* data, int dataSz);
  3964. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY* wolfSSL_X509_NAME_ENTRY_create_by_txt(
  3965. WOLFSSL_X509_NAME_ENTRY **neIn, const char *txt, int format,
  3966. const unsigned char *data, int dataSz);
  3967. WOLFSSL_API int wolfSSL_X509_NAME_add_entry(WOLFSSL_X509_NAME* name,
  3968. WOLFSSL_X509_NAME_ENTRY* entry, int idx, int set);
  3969. WOLFSSL_API int wolfSSL_X509_NAME_add_entry_by_txt(WOLFSSL_X509_NAME *name,
  3970. const char *field, int type, const unsigned char *bytes, int len, int loc,
  3971. int set);
  3972. WOLFSSL_API int wolfSSL_X509_NAME_add_entry_by_NID(WOLFSSL_X509_NAME *name, int nid,
  3973. int type, const unsigned char *bytes,
  3974. int len, int loc, int set);
  3975. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY *wolfSSL_X509_NAME_delete_entry(
  3976. WOLFSSL_X509_NAME *name, int loc);
  3977. WOLFSSL_API int wolfSSL_X509_NAME_cmp(const WOLFSSL_X509_NAME* x,
  3978. const WOLFSSL_X509_NAME* y);
  3979. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_NAME_new(void);
  3980. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_NAME_new_ex(void *heap);
  3981. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_X509_NAME_dup(WOLFSSL_X509_NAME* name);
  3982. WOLFSSL_API int wolfSSL_X509_NAME_copy(WOLFSSL_X509_NAME* from, WOLFSSL_X509_NAME* to);
  3983. WOLFSSL_API int wolfSSL_check_private_key(const WOLFSSL* ssl);
  3984. #endif /* !NO_CERTS */
  3985. #endif /* OPENSSL_ALL || OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
  3986. #if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO) || defined(WOLFSSL_HAPROXY) \
  3987. || defined(WOLFSSL_NGINX) || defined(WOLFSSL_QT)
  3988. WOLFSSL_API long wolfSSL_ctrl(WOLFSSL* ssl, int cmd, long opt, void* pt);
  3989. #endif
  3990. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
  3991. WOLFSSL_API void* wolfSSL_X509_get_ext_d2i(const WOLFSSL_X509* x509,
  3992. int nid, int* c, int* idx);
  3993. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  3994. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
  3995. #ifndef NO_CERTS
  3996. WOLFSSL_API unsigned int wolfSSL_X509_get_extension_flags(WOLFSSL_X509* x509);
  3997. WOLFSSL_API unsigned int wolfSSL_X509_get_key_usage(WOLFSSL_X509* x509);
  3998. WOLFSSL_API unsigned int wolfSSL_X509_get_extended_key_usage(WOLFSSL_X509* x509);
  3999. WOLFSSL_API int wolfSSL_X509_get_ext_count(const WOLFSSL_X509* passedCert);
  4000. WOLFSSL_API int wolfSSL_X509_get_ext_by_NID(const WOLFSSL_X509 *x, int nid, int lastpos);
  4001. WOLFSSL_API int wolfSSL_X509_add_ext(WOLFSSL_X509 *x, WOLFSSL_X509_EXTENSION *ex, int loc);
  4002. WOLFSSL_API WOLFSSL_X509_EXTENSION *wolfSSL_X509V3_EXT_i2d(int nid, int crit,
  4003. void *data);
  4004. WOLFSSL_API WOLFSSL_X509_EXTENSION *wolfSSL_X509_delete_ext(WOLFSSL_X509 *x509, int loc);
  4005. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509V3_EXT_conf_nid(
  4006. WOLF_LHASH_OF(CONF_VALUE)* conf, WOLFSSL_X509V3_CTX* ctx, int nid,
  4007. char* value);
  4008. WOLFSSL_API void wolfSSL_X509V3_set_ctx(WOLFSSL_X509V3_CTX* ctx,
  4009. WOLFSSL_X509* issuer, WOLFSSL_X509* subject, WOLFSSL_X509* req,
  4010. WOLFSSL_X509_CRL* crl, int flag);
  4011. WOLFSSL_API void wolfSSL_X509V3_set_ctx_nodb(WOLFSSL_X509V3_CTX* ctx);
  4012. WOLFSSL_API int wolfSSL_X509_digest(const WOLFSSL_X509* x509,
  4013. const WOLFSSL_EVP_MD* digest, unsigned char* buf, unsigned int* len);
  4014. WOLFSSL_API int wolfSSL_X509_pubkey_digest(const WOLFSSL_X509 *x509,
  4015. const WOLFSSL_EVP_MD *digest, unsigned char* buf, unsigned int* len);
  4016. WOLFSSL_API int wolfSSL_use_certificate(WOLFSSL* ssl, WOLFSSL_X509* x509);
  4017. WOLFSSL_API int wolfSSL_use_PrivateKey(WOLFSSL* ssl, WOLFSSL_EVP_PKEY* pkey);
  4018. WOLFSSL_API int wolfSSL_use_PrivateKey_ASN1(int pri, WOLFSSL* ssl,
  4019. const unsigned char* der, long derSz);
  4020. WOLFSSL_API WOLFSSL_EVP_PKEY *wolfSSL_get_privatekey(const WOLFSSL *ssl);
  4021. #ifndef NO_RSA
  4022. WOLFSSL_API int wolfSSL_use_RSAPrivateKey_ASN1(WOLFSSL* ssl, unsigned char* der,
  4023. long derSz);
  4024. #endif
  4025. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey_ASN1(int pri, WOLFSSL_CTX* ctx,
  4026. unsigned char* der, long derSz);
  4027. #if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA)
  4028. WOLFSSL_API int wolfSSL_X509_cmp(const WOLFSSL_X509* a, const WOLFSSL_X509* b);
  4029. WOLFSSL_API const WOLFSSL_STACK *wolfSSL_X509_get0_extensions(const WOLFSSL_X509 *x);
  4030. WOLFSSL_API const WOLFSSL_STACK *wolfSSL_X509_REQ_get_extensions(const WOLFSSL_X509 *x);
  4031. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509_get_ext(const WOLFSSL_X509* x, int loc);
  4032. WOLFSSL_API int wolfSSL_X509_get_ext_by_OBJ(const WOLFSSL_X509 *x,
  4033. const WOLFSSL_ASN1_OBJECT *obj, int lastpos);
  4034. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x, int loc);
  4035. WOLFSSL_API int wolfSSL_X509_EXTENSION_get_critical(const WOLFSSL_X509_EXTENSION* ex);
  4036. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509_EXTENSION_new(void);
  4037. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509_EXTENSION_create_by_OBJ(
  4038. WOLFSSL_X509_EXTENSION* ex, WOLFSSL_ASN1_OBJECT *obj, int crit,
  4039. WOLFSSL_ASN1_STRING *data);
  4040. WOLFSSL_API WOLFSSL_X509_EXTENSION* wolfSSL_X509_EXTENSION_dup(
  4041. WOLFSSL_X509_EXTENSION* src);
  4042. WOLFSSL_API int wolfSSL_sk_X509_EXTENSION_push(WOLFSSL_STACK* sk,
  4043. WOLFSSL_X509_EXTENSION* ext);
  4044. WOLFSSL_API void wolfSSL_X509_EXTENSION_free(WOLFSSL_X509_EXTENSION* ext_to_free);
  4045. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_new_x509_ext(void);
  4046. #endif
  4047. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_X509_EXTENSION_get_object(WOLFSSL_X509_EXTENSION* ext);
  4048. WOLFSSL_API int wolfSSL_X509_EXTENSION_set_object(WOLFSSL_X509_EXTENSION* ext,
  4049. const WOLFSSL_ASN1_OBJECT* obj);
  4050. WOLFSSL_API WOLFSSL_ASN1_STRING* wolfSSL_X509_EXTENSION_get_data(WOLFSSL_X509_EXTENSION* ext);
  4051. WOLFSSL_API int wolfSSL_X509_EXTENSION_set_data(WOLFSSL_X509_EXTENSION* ext,
  4052. WOLFSSL_ASN1_STRING* data);
  4053. #endif /* !NO_CERTS */
  4054. WOLFSSL_API WOLFSSL_DH *wolfSSL_DSA_dup_DH(const WOLFSSL_DSA *r);
  4055. WOLFSSL_API int wolfSSL_SESSION_get_master_key(const WOLFSSL_SESSION* ses,
  4056. unsigned char* out, int outSz);
  4057. WOLFSSL_API int wolfSSL_SESSION_get_master_key_length(const WOLFSSL_SESSION* ses);
  4058. WOLFSSL_API int wolfSSL_i2d_X509_bio(WOLFSSL_BIO* bio, WOLFSSL_X509* x509);
  4059. #ifdef WOLFSSL_CERT_REQ
  4060. WOLFSSL_API int wolfSSL_i2d_X509_REQ_bio(WOLFSSL_BIO* bio, WOLFSSL_X509* x509);
  4061. #endif
  4062. #if !defined(NO_FILESYSTEM)
  4063. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509_fp(XFILE fp,
  4064. WOLFSSL_X509** x509);
  4065. #endif
  4066. WOLFSSL_API WOLFSSL_STACK* wolfSSL_X509_STORE_GetCerts(WOLFSSL_X509_STORE_CTX* s);
  4067. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509_bio(WOLFSSL_BIO* bio,
  4068. WOLFSSL_X509** x509);
  4069. #ifdef WOLFSSL_CERT_REQ
  4070. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509_REQ_bio(WOLFSSL_BIO* bio,
  4071. WOLFSSL_X509** x509);
  4072. #if !defined(NO_FILESYSTEM)
  4073. WOLFSSL_API WOLFSSL_X509* wolfSSL_d2i_X509_REQ_fp(XFILE fp, WOLFSSL_X509 **req);
  4074. #endif
  4075. #endif
  4076. #endif /* OPENSSL_EXTRA || OPENSSL_ALL */
  4077. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
  4078. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509) *wolfSSL_get0_verified_chain(
  4079. const WOLFSSL *ssl);
  4080. WOLFSSL_API void wolfSSL_CTX_set_cert_store(WOLFSSL_CTX* ctx,
  4081. WOLFSSL_X509_STORE* str);
  4082. #ifdef OPENSSL_ALL
  4083. WOLFSSL_API int wolfSSL_CTX_set1_verify_cert_store(WOLFSSL_CTX* ctx,
  4084. WOLFSSL_X509_STORE* str);
  4085. #endif
  4086. WOLFSSL_API int wolfSSL_set0_verify_cert_store(WOLFSSL *ssl,
  4087. WOLFSSL_X509_STORE* str);
  4088. WOLFSSL_API int wolfSSL_set1_verify_cert_store(WOLFSSL *ssl,
  4089. WOLFSSL_X509_STORE* str);
  4090. WOLFSSL_API WOLFSSL_X509_STORE* wolfSSL_CTX_get_cert_store(const WOLFSSL_CTX* ctx);
  4091. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  4092. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) || \
  4093. defined(HAVE_SECRET_CALLBACK)
  4094. WOLFSSL_API size_t wolfSSL_get_server_random(const WOLFSSL *ssl,
  4095. unsigned char *out, size_t outlen);
  4096. WOLFSSL_API size_t wolfSSL_get_client_random(const WOLFSSL* ssl,
  4097. unsigned char* out, size_t outSz);
  4098. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL || HAVE_SECRET_CALLBACK */
  4099. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
  4100. WOLFSSL_API size_t wolfSSL_BIO_wpending(const WOLFSSL_BIO *bio);
  4101. /* non-standard API to determine if BIO supports "pending" */
  4102. WOLFSSL_API int wolfSSL_BIO_supports_pending(const WOLFSSL_BIO *bio);
  4103. WOLFSSL_API size_t wolfSSL_BIO_ctrl_pending(WOLFSSL_BIO *b);
  4104. /* Definition for backwards comaptiblity */
  4105. #define wolfSSL_get_server_tmp_key wolfSSL_get_peer_tmp_key
  4106. WOLFSSL_API int wolfSSL_get_peer_tmp_key(const WOLFSSL* ssl, WOLFSSL_EVP_PKEY** pkey);
  4107. WOLFSSL_API int wolfSSL_CTX_set_min_proto_version(WOLFSSL_CTX* ctx, int version);
  4108. WOLFSSL_API int wolfSSL_CTX_set_max_proto_version(WOLFSSL_CTX* ctx, int version);
  4109. WOLFSSL_API int wolfSSL_set_min_proto_version(WOLFSSL* ssl, int version);
  4110. WOLFSSL_API int wolfSSL_set_max_proto_version(WOLFSSL* ssl, int version);
  4111. WOLFSSL_API int wolfSSL_CTX_get_min_proto_version(WOLFSSL_CTX* ctx);
  4112. WOLFSSL_API int wolfSSL_CTX_get_max_proto_version(WOLFSSL_CTX* ctx);
  4113. WOLFSSL_API int wolfSSL_CTX_use_PrivateKey(WOLFSSL_CTX *ctx,
  4114. WOLFSSL_EVP_PKEY *pkey);
  4115. WOLFSSL_API WOLFSSL_X509 *wolfSSL_PEM_read_bio_X509(WOLFSSL_BIO *bp,
  4116. WOLFSSL_X509 **x, wc_pem_password_cb *cb, void *u);
  4117. #ifdef WOLFSSL_CERT_REQ
  4118. WOLFSSL_API WOLFSSL_X509 *wolfSSL_PEM_read_bio_X509_REQ(WOLFSSL_BIO *bp,
  4119. WOLFSSL_X509 **x, wc_pem_password_cb *cb, void *u);
  4120. #ifndef NO_FILESYSTEM
  4121. WOLFSSL_API WOLFSSL_X509* wolfSSL_PEM_read_X509_REQ(XFILE fp, WOLFSSL_X509** x,
  4122. wc_pem_password_cb* cb, void* u);
  4123. #endif
  4124. #endif
  4125. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_PEM_read_bio_X509_CRL(WOLFSSL_BIO *bp,
  4126. WOLFSSL_X509_CRL **x, wc_pem_password_cb *cb, void *u);
  4127. WOLFSSL_API WOLFSSL_X509 *wolfSSL_PEM_read_bio_X509_AUX
  4128. (WOLFSSL_BIO *bp, WOLFSSL_X509 **x, wc_pem_password_cb *cb, void *u);
  4129. #ifndef NO_FILESYSTEM
  4130. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_INFO)* wolfSSL_PEM_X509_INFO_read(
  4131. XFILE fp, WOLF_STACK_OF(WOLFSSL_X509_INFO)* sk,
  4132. pem_password_cb* cb, void* u);
  4133. #endif
  4134. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_INFO)* wolfSSL_PEM_X509_INFO_read_bio(
  4135. WOLFSSL_BIO* bio, WOLF_STACK_OF(WOLFSSL_X509_INFO)* sk,
  4136. wc_pem_password_cb* cb, void* u);
  4137. #ifndef NO_FILESYSTEM
  4138. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_PEM_read_X509_CRL(XFILE fp,
  4139. WOLFSSL_X509_CRL **x, wc_pem_password_cb *cb, void *u);
  4140. #endif
  4141. WOLFSSL_API int wolfSSL_PEM_get_EVP_CIPHER_INFO(const char* header,
  4142. EncryptedInfo* cipher);
  4143. WOLFSSL_API int wolfSSL_PEM_do_header(EncryptedInfo* cipher,
  4144. unsigned char* data, long* len,
  4145. wc_pem_password_cb* callback, void* ctx);
  4146. #endif /* OPENSSL_EXTRA || OPENSSL_ALL */
  4147. /*lighttp compatibility */
  4148. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) || \
  4149. defined(OPENSSL_EXTRA_X509_SMALL)
  4150. struct WOLFSSL_ASN1_BIT_STRING {
  4151. int length;
  4152. int type;
  4153. byte* data;
  4154. long flags;
  4155. };
  4156. struct WOLFSSL_CONF_CTX {
  4157. unsigned int flags;
  4158. WOLFSSL_CTX* ctx;
  4159. WOLFSSL* ssl;
  4160. };
  4161. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY *wolfSSL_X509_NAME_get_entry(WOLFSSL_X509_NAME *name, int loc);
  4162. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  4163. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)|| \
  4164. defined(OPENSSL_EXTRA_X509_SMALL)
  4165. #if defined(OPENSSL_EXTRA) \
  4166. || defined(OPENSSL_ALL) \
  4167. || defined(HAVE_LIGHTY) \
  4168. || defined(WOLFSSL_MYSQL_COMPATIBLE) \
  4169. || defined(HAVE_STUNNEL) \
  4170. || defined(WOLFSSL_NGINX) \
  4171. || defined(WOLFSSL_HAPROXY) \
  4172. || defined(OPENSSL_EXTRA_X509_SMALL)
  4173. WOLFSSL_API void wolfSSL_X509_NAME_ENTRY_free(WOLFSSL_X509_NAME_ENTRY* ne);
  4174. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY* wolfSSL_X509_NAME_ENTRY_new(void);
  4175. WOLFSSL_API void wolfSSL_X509_NAME_free(WOLFSSL_X509_NAME* name);
  4176. WOLFSSL_API int wolfSSL_CTX_use_certificate(WOLFSSL_CTX* ctx, WOLFSSL_X509* x);
  4177. WOLFSSL_API int wolfSSL_CTX_add0_chain_cert(WOLFSSL_CTX* ctx, WOLFSSL_X509* x509);
  4178. WOLFSSL_API int wolfSSL_CTX_add1_chain_cert(WOLFSSL_CTX* ctx, WOLFSSL_X509* x509);
  4179. WOLFSSL_API int wolfSSL_add0_chain_cert(WOLFSSL* ssl, WOLFSSL_X509* x509);
  4180. WOLFSSL_API int wolfSSL_add1_chain_cert(WOLFSSL* ssl, WOLFSSL_X509* x509);
  4181. WOLFSSL_API int wolfSSL_BIO_read_filename(WOLFSSL_BIO *b, const char *name);
  4182. /* These are to be merged shortly */
  4183. WOLFSSL_API void wolfSSL_set_verify_depth(WOLFSSL *ssl,int depth);
  4184. WOLFSSL_API void* wolfSSL_get_app_data( const WOLFSSL *ssl);
  4185. WOLFSSL_API int wolfSSL_set_app_data(WOLFSSL *ssl, void *arg);
  4186. WOLFSSL_API WOLFSSL_ASN1_OBJECT* wolfSSL_X509_NAME_ENTRY_get_object(WOLFSSL_X509_NAME_ENTRY *ne);
  4187. WOLFSSL_API unsigned char *wolfSSL_SHA1(const unsigned char *d, size_t n, unsigned char *md);
  4188. WOLFSSL_API unsigned char *wolfSSL_SHA224(const unsigned char *d, size_t n, unsigned char *md);
  4189. WOLFSSL_API unsigned char *wolfSSL_SHA256(const unsigned char *d, size_t n, unsigned char *md);
  4190. WOLFSSL_API unsigned char *wolfSSL_SHA384(const unsigned char *d, size_t n, unsigned char *md);
  4191. WOLFSSL_API unsigned char *wolfSSL_SHA512(const unsigned char *d, size_t n, unsigned char *md);
  4192. WOLFSSL_API int wolfSSL_X509_check_private_key(WOLFSSL_X509* x509, WOLFSSL_EVP_PKEY* pkey);
  4193. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME) *wolfSSL_dup_CA_list( WOLF_STACK_OF(WOLFSSL_X509_NAME) *sk );
  4194. WOLFSSL_API int wolfSSL_X509_check_ca(WOLFSSL_X509 *x509);
  4195. #ifndef NO_FILESYSTEM
  4196. WOLFSSL_API long wolfSSL_BIO_set_fp(WOLFSSL_BIO *bio, XFILE fp, int c);
  4197. WOLFSSL_API long wolfSSL_BIO_get_fp(WOLFSSL_BIO *bio, XFILE* fp);
  4198. #endif
  4199. #endif /* OPENSSL_EXTRA || OPENSSL_ALL || HAVE_LIGHTY || WOLFSSL_MYSQL_COMPATIBLE || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
  4200. #endif /* OPENSSL_EXTRA || OPENSSL_ALL */
  4201. #if defined(HAVE_LIGHTY) || defined(HAVE_STUNNEL) \
  4202. || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_EXTRA)
  4203. #ifndef NO_BIO
  4204. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_file(const char *filename,
  4205. const char *mode);
  4206. #ifndef NO_FILESYSTEM
  4207. WOLFSSL_API WOLFSSL_BIO* wolfSSL_BIO_new_fp(XFILE fp, int c);
  4208. #endif /* !NO_FILESYSTEM */
  4209. #endif /* !NO_BIO */
  4210. #endif
  4211. #if defined(OPENSSL_ALL) \
  4212. || defined(HAVE_STUNNEL) \
  4213. || defined(HAVE_LIGHTY) \
  4214. || defined(WOLFSSL_MYSQL_COMPATIBLE) \
  4215. || defined(WOLFSSL_HAPROXY) \
  4216. || defined(OPENSSL_EXTRA)
  4217. #define X509_BUFFER_SZ 8192
  4218. WOLFSSL_API long wolfSSL_CTX_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL_DH* dh);
  4219. WOLFSSL_API WOLFSSL_DH *wolfSSL_PEM_read_bio_DHparams(WOLFSSL_BIO *bp,
  4220. WOLFSSL_DH **x, wc_pem_password_cb *cb, void *u);
  4221. #ifndef NO_FILESYSTEM
  4222. WOLFSSL_API WOLFSSL_DH *wolfSSL_PEM_read_DHparams(XFILE fp, WOLFSSL_DH **x,
  4223. wc_pem_password_cb *cb, void *u);
  4224. #endif
  4225. WOLFSSL_API WOLFSSL_DSA *wolfSSL_PEM_read_bio_DSAparams(WOLFSSL_BIO *bp,
  4226. WOLFSSL_DSA **x, wc_pem_password_cb *cb, void *u);
  4227. WOLFSSL_API int wolfSSL_PEM_write_bio_X509_REQ(WOLFSSL_BIO *bp,WOLFSSL_X509 *x);
  4228. WOLFSSL_API int wolfSSL_PEM_write_bio_X509_AUX(WOLFSSL_BIO *bp,WOLFSSL_X509 *x);
  4229. WOLFSSL_API int wolfSSL_PEM_write_bio_X509(WOLFSSL_BIO *bp, WOLFSSL_X509 *x);
  4230. #endif /* HAVE_STUNNEL || HAVE_LIGHTY */
  4231. #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && \
  4232. defined(WOLFSSL_CERT_REQ)
  4233. WOLFSSL_API int wolfSSL_i2d_X509_REQ(WOLFSSL_X509* req, unsigned char** out);
  4234. WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_REQ_new(void);
  4235. WOLFSSL_API void wolfSSL_X509_REQ_free(WOLFSSL_X509* req);
  4236. WOLFSSL_API int wolfSSL_X509_REQ_sign(WOLFSSL_X509 *req, WOLFSSL_EVP_PKEY *pkey,
  4237. const WOLFSSL_EVP_MD *md);
  4238. WOLFSSL_API int wolfSSL_X509_REQ_sign_ctx(WOLFSSL_X509 *req,
  4239. WOLFSSL_EVP_MD_CTX* md_ctx);
  4240. WOLFSSL_API int wolfSSL_X509_REQ_add_extensions(WOLFSSL_X509* req,
  4241. WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* ext_sk);
  4242. WOLFSSL_API int wolfSSL_X509_REQ_set_subject_name(WOLFSSL_X509 *req,
  4243. WOLFSSL_X509_NAME *name);
  4244. WOLFSSL_API int wolfSSL_X509_REQ_set_pubkey(WOLFSSL_X509 *req,
  4245. WOLFSSL_EVP_PKEY *pkey);
  4246. WOLFSSL_API int wolfSSL_X509_REQ_add1_attr_by_NID(WOLFSSL_X509 *req,
  4247. int nid, int type,
  4248. const unsigned char *bytes,
  4249. int len);
  4250. WOLFSSL_API int wolfSSL_X509_REQ_add1_attr_by_txt(WOLFSSL_X509 *req,
  4251. const char *attrname, int type,
  4252. const unsigned char *bytes, int len);
  4253. WOLFSSL_API WOLFSSL_X509 *wolfSSL_X509_to_X509_REQ(WOLFSSL_X509 *x,
  4254. WOLFSSL_EVP_PKEY *pkey, const WOLFSSL_EVP_MD *md);
  4255. #endif
  4256. #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) || \
  4257. defined(WOLFSSL_CERT_REQ)
  4258. WOLFSSL_API int wolfSSL_X509_REQ_get_attr_count(const WOLFSSL_X509 *req);
  4259. WOLFSSL_API WOLFSSL_X509_ATTRIBUTE *wolfSSL_X509_REQ_get_attr(
  4260. const WOLFSSL_X509 *req, int loc);
  4261. WOLFSSL_API int wolfSSL_X509_REQ_get_attr_by_NID(const WOLFSSL_X509 *req,
  4262. int nid, int lastpos);
  4263. WOLFSSL_API WOLFSSL_X509_ATTRIBUTE* wolfSSL_X509_ATTRIBUTE_new(void);
  4264. WOLFSSL_API void wolfSSL_X509_ATTRIBUTE_free(WOLFSSL_X509_ATTRIBUTE* attr);
  4265. WOLFSSL_API WOLFSSL_ASN1_TYPE *wolfSSL_X509_ATTRIBUTE_get0_type(
  4266. WOLFSSL_X509_ATTRIBUTE *attr, int idx);
  4267. #endif
  4268. #if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) \
  4269. || defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY)
  4270. #include <wolfssl/openssl/crypto.h>
  4271. WOLFSSL_API int wolfSSL_CRYPTO_set_mem_functions(
  4272. wolfSSL_OSSL_Malloc_cb m,
  4273. wolfSSL_OSSL_Realloc_cb r,
  4274. wolfSSL_OSSL_Free_cb f);
  4275. WOLFSSL_API int wolfSSL_CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),
  4276. void *(*r) (void *, size_t, const char *, int), void (*f) (void *));
  4277. WOLFSSL_API void wolfSSL_CRYPTO_cleanup_all_ex_data(void);
  4278. WOLFSSL_API int wolfSSL_CRYPTO_memcmp(const void *a, const void *b, size_t size);
  4279. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_768_prime(WOLFSSL_BIGNUM* bn);
  4280. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_1024_prime(WOLFSSL_BIGNUM* bn);
  4281. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_1536_prime(WOLFSSL_BIGNUM* bn);
  4282. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_2048_prime(WOLFSSL_BIGNUM* bn);
  4283. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_3072_prime(WOLFSSL_BIGNUM* bn);
  4284. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_4096_prime(WOLFSSL_BIGNUM* bn);
  4285. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_6144_prime(WOLFSSL_BIGNUM* bn);
  4286. WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_8192_prime(WOLFSSL_BIGNUM* bn);
  4287. WOLFSSL_API WOLFSSL_DH *wolfSSL_DH_generate_parameters(int prime_len, int generator,
  4288. void (*callback) (int, int, void *), void *cb_arg);
  4289. WOLFSSL_API int wolfSSL_DH_generate_parameters_ex(WOLFSSL_DH* dh, int prime_len, int generator,
  4290. void (*callback) (int, int, void *));
  4291. WOLFSSL_API int wolfSSL_ERR_load_ERR_strings(void);
  4292. WOLFSSL_API void wolfSSL_ERR_load_crypto_strings(void);
  4293. WOLFSSL_API unsigned long wolfSSL_ERR_peek_last_error(void);
  4294. WOLFSSL_API int wolfSSL_FIPS_mode(void);
  4295. WOLFSSL_API int wolfSSL_FIPS_mode_set(int r);
  4296. WOLFSSL_API int wolfSSL_RAND_set_rand_method(const WOLFSSL_RAND_METHOD *methods);
  4297. WOLFSSL_API int wolfSSL_CIPHER_get_bits(const WOLFSSL_CIPHER *c, int *alg_bits);
  4298. #define WOLF_SK_COMPARE_CB(type, arg) \
  4299. int (*(arg)) (const type* const* a, const type* const* b)
  4300. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_X509_new(
  4301. WOLF_SK_COMPARE_CB(WOLFSSL_X509, cb));
  4302. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_X509_new_null(void);
  4303. WOLFSSL_API int wolfSSL_sk_X509_num(const WOLF_STACK_OF(WOLFSSL_X509) *s);
  4304. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_X509_OBJECT_new(void);
  4305. WOLFSSL_API void wolfSSL_sk_X509_OBJECT_free(WOLFSSL_STACK* s);
  4306. WOLFSSL_API void wolfSSL_sk_X509_OBJECT_pop_free(WOLFSSL_STACK* s,
  4307. void (*f) (WOLFSSL_X509_OBJECT*));
  4308. WOLFSSL_API int wolfSSL_sk_X509_OBJECT_push(WOLFSSL_STACK* sk, WOLFSSL_X509_OBJECT* obj);
  4309. WOLFSSL_API WOLFSSL_X509_INFO *wolfSSL_X509_INFO_new(void);
  4310. WOLFSSL_API void wolfSSL_X509_INFO_free(WOLFSSL_X509_INFO* info);
  4311. WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_X509_INFO_new_null(void);
  4312. WOLFSSL_API int wolfSSL_sk_X509_INFO_num(const WOLF_STACK_OF(WOLFSSL_X509_INFO)* sk);
  4313. WOLFSSL_API WOLFSSL_X509_INFO* wolfSSL_sk_X509_INFO_value(
  4314. const WOLF_STACK_OF(WOLFSSL_X509_INFO)* sk, int i);
  4315. WOLFSSL_API int wolfSSL_sk_X509_INFO_push(WOLF_STACK_OF(WOLFSSL_X509_INFO)*,
  4316. WOLFSSL_X509_INFO* in);
  4317. WOLFSSL_API WOLFSSL_X509_INFO* wolfSSL_sk_X509_INFO_pop(WOLF_STACK_OF(WOLFSSL_X509_INFO)*);
  4318. WOLFSSL_API void wolfSSL_sk_X509_INFO_pop_free(WOLF_STACK_OF(WOLFSSL_X509_INFO)*,
  4319. void (*f) (WOLFSSL_X509_INFO*));
  4320. WOLFSSL_API void wolfSSL_sk_X509_INFO_free(WOLF_STACK_OF(WOLFSSL_X509_INFO)*);
  4321. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_sk_X509_NAME_new(
  4322. WOLF_SK_COMPARE_CB(WOLFSSL_X509_NAME, cb));
  4323. WOLFSSL_API int wolfSSL_sk_X509_NAME_push(WOLF_STACK_OF(WOLFSSL_X509_NAME)*,
  4324. WOLFSSL_X509_NAME* name);
  4325. WOLFSSL_API int wolfSSL_sk_X509_NAME_find(const WOLF_STACK_OF(WOLFSSL_X509_NAME)* sk,
  4326. WOLFSSL_X509_NAME* name);
  4327. WOLFSSL_API int wolfSSL_sk_X509_NAME_set_cmp_func(
  4328. WOLF_STACK_OF(WOLFSSL_X509_NAME)*, WOLF_SK_COMPARE_CB(WOLFSSL_X509_NAME, cb));
  4329. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_sk_X509_NAME_value(const WOLF_STACK_OF(WOLFSSL_X509_NAME)* sk, int i);
  4330. WOLFSSL_API int wolfSSL_sk_X509_NAME_num(const WOLF_STACK_OF(WOLFSSL_X509_NAME)* sk);
  4331. WOLFSSL_API WOLFSSL_X509_NAME* wolfSSL_sk_X509_NAME_pop(WOLF_STACK_OF(WOLFSSL_X509_NAME)*);
  4332. WOLFSSL_API void wolfSSL_sk_X509_NAME_pop_free(WOLF_STACK_OF(WOLFSSL_X509_NAME)*,
  4333. void (*f) (WOLFSSL_X509_NAME*));
  4334. WOLFSSL_API void wolfSSL_sk_X509_NAME_free(WOLF_STACK_OF(WOLFSSL_X509_NAME) *);
  4335. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_NAME_ENTRY)*
  4336. wolfSSL_sk_X509_NAME_ENTRY_new(WOLF_SK_COMPARE_CB(WOLFSSL_X509_NAME_ENTRY, cb));
  4337. WOLFSSL_API int wolfSSL_sk_X509_NAME_ENTRY_push(WOLF_STACK_OF(WOLFSSL_X509_NAME_ENTRY)* sk,
  4338. WOLFSSL_X509_NAME_ENTRY* name_entry);
  4339. WOLFSSL_API WOLFSSL_X509_NAME_ENTRY*
  4340. wolfSSL_sk_X509_NAME_ENTRY_value(const WOLF_STACK_OF(WOLFSSL_X509_NAME_ENTRY)* sk, int i);
  4341. WOLFSSL_API int wolfSSL_sk_X509_NAME_ENTRY_num(const WOLF_STACK_OF(WOLFSSL_X509_NAME_ENTRY)* sk);
  4342. WOLFSSL_API void wolfSSL_sk_X509_NAME_ENTRY_free(WOLF_STACK_OF(WOLFSSL_X509_NAME_ENTRY)* sk);
  4343. WOLFSSL_API int wolfSSL_sk_X509_OBJECT_num(const WOLF_STACK_OF(WOLFSSL_X509_OBJECT) *s);
  4344. WOLFSSL_API int wolfSSL_X509_NAME_print_ex(WOLFSSL_BIO* bio,WOLFSSL_X509_NAME* name,int indent,
  4345. unsigned long flags);
  4346. #ifndef NO_FILESYSTEM
  4347. WOLFSSL_API int wolfSSL_X509_NAME_print_ex_fp(XFILE fp,WOLFSSL_X509_NAME* name,int indent,
  4348. unsigned long flags);
  4349. #endif
  4350. WOLFSSL_API WOLFSSL_STACK *wolfSSL_sk_CONF_VALUE_new(WOLF_SK_COMPARE_CB(WOLFSSL_CONF_VALUE, compFunc));
  4351. WOLFSSL_API void wolfSSL_sk_CONF_VALUE_free(struct WOLFSSL_STACK *sk);
  4352. WOLFSSL_API int wolfSSL_sk_CONF_VALUE_num(const WOLFSSL_STACK *sk);
  4353. WOLFSSL_API WOLFSSL_CONF_VALUE *wolfSSL_sk_CONF_VALUE_value(
  4354. const struct WOLFSSL_STACK *sk, int i);
  4355. WOLFSSL_API int wolfSSL_sk_CONF_VALUE_push(WOLF_STACK_OF(WOLFSSL_CONF_VALUE)* sk,
  4356. WOLFSSL_CONF_VALUE* val);
  4357. #endif /* OPENSSL_ALL || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY || OPENSSL_EXTRA || HAVE_LIGHTY */
  4358. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
  4359. WOLFSSL_API WOLFSSL_ASN1_BIT_STRING* wolfSSL_ASN1_BIT_STRING_new(void);
  4360. WOLFSSL_API void wolfSSL_ASN1_BIT_STRING_free(WOLFSSL_ASN1_BIT_STRING* str);
  4361. WOLFSSL_API WOLFSSL_ASN1_BIT_STRING* wolfSSL_X509_get0_pubkey_bitstr(
  4362. const WOLFSSL_X509* x);
  4363. WOLFSSL_API int wolfSSL_ASN1_BIT_STRING_get_bit(
  4364. const WOLFSSL_ASN1_BIT_STRING* str, int i);
  4365. WOLFSSL_API int wolfSSL_ASN1_BIT_STRING_set_bit(
  4366. WOLFSSL_ASN1_BIT_STRING* str, int pos, int val);
  4367. WOLFSSL_API int wolfSSL_i2d_ASN1_BIT_STRING(const WOLFSSL_ASN1_BIT_STRING* bstr,
  4368. unsigned char** pp);
  4369. WOLFSSL_API WOLFSSL_ASN1_BIT_STRING* wolfSSL_d2i_ASN1_BIT_STRING(
  4370. WOLFSSL_ASN1_BIT_STRING** out, const byte** src, long len);
  4371. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  4372. WOLFSSL_API int wolfSSL_version(WOLFSSL* ssl);
  4373. #if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) \
  4374. || defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY)
  4375. WOLFSSL_API int wolfSSL_get_state(const WOLFSSL* ssl);
  4376. WOLFSSL_API WOLFSSL_X509* wolfSSL_sk_X509_value(WOLF_STACK_OF(WOLFSSL_X509)*, int i);
  4377. WOLFSSL_API WOLFSSL_X509* wolfSSL_sk_X509_shift(WOLF_STACK_OF(WOLFSSL_X509)*);
  4378. WOLFSSL_API void* wolfSSL_sk_X509_OBJECT_value(WOLF_STACK_OF(WOLFSSL_X509_OBJECT)*, int i);
  4379. #endif /* OPENSSL_ALL || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY || OPENSSL_EXTRA || HAVE_LIGHTY */
  4380. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL) || defined(HAVE_EX_DATA)
  4381. WOLFSSL_API void* wolfSSL_SESSION_get_ex_data(const WOLFSSL_SESSION* session, int idx);
  4382. WOLFSSL_API int wolfSSL_SESSION_set_ex_data(WOLFSSL_SESSION* session, int idx, void* data);
  4383. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  4384. WOLFSSL_API int wolfSSL_SESSION_set_ex_data_with_cleanup(
  4385. WOLFSSL_SESSION* session,
  4386. int idx,
  4387. void* data,
  4388. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  4389. #endif
  4390. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  4391. #if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) \
  4392. || defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY)
  4393. #ifdef HAVE_EX_DATA
  4394. WOLFSSL_API int wolfSSL_SESSION_get_ex_new_index(long ctx_l,void* ctx_ptr,
  4395. WOLFSSL_CRYPTO_EX_new* new_func, WOLFSSL_CRYPTO_EX_dup* dup_func,
  4396. WOLFSSL_CRYPTO_EX_free* free_func);
  4397. #endif
  4398. WOLFSSL_API const unsigned char* wolfSSL_SESSION_get_id(
  4399. const WOLFSSL_SESSION* sess, unsigned int* idLen);
  4400. WOLFSSL_API int wolfSSL_SESSION_print(WOLFSSL_BIO* bp, const WOLFSSL_SESSION* session);
  4401. WOLFSSL_API int wolfSSL_set_tlsext_host_name(WOLFSSL* ssl, const char* host_name);
  4402. WOLFSSL_API const char* wolfSSL_get_servername(WOLFSSL* ssl, unsigned char type);
  4403. WOLFSSL_API WOLFSSL_CTX* wolfSSL_set_SSL_CTX(WOLFSSL* ssl,WOLFSSL_CTX* ctx);
  4404. WOLFSSL_API VerifyCallback wolfSSL_CTX_get_verify_callback(WOLFSSL_CTX* ctx);
  4405. WOLFSSL_API VerifyCallback wolfSSL_get_verify_callback(WOLFSSL* ssl);
  4406. #endif /* OPENSSL_ALL || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY || HAVE_LIGHTY */
  4407. #ifdef HAVE_SNI
  4408. /* SNI received callback type */
  4409. typedef int (*CallbackSniRecv)(WOLFSSL *ssl, int *ret, void* exArg);
  4410. WOLFSSL_API void wolfSSL_CTX_set_servername_callback(WOLFSSL_CTX* ctx,
  4411. CallbackSniRecv cb);
  4412. WOLFSSL_API int wolfSSL_CTX_set_servername_arg(WOLFSSL_CTX* ctx, void* arg);
  4413. #endif
  4414. #if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || \
  4415. defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY)
  4416. #ifdef HAVE_SNI
  4417. WOLFSSL_API int wolfSSL_CTX_set_tlsext_servername_callback(WOLFSSL_CTX* ctx,
  4418. CallbackSniRecv cb);
  4419. #endif
  4420. WOLFSSL_API void wolfSSL_ERR_remove_thread_state(void* pid);
  4421. /* support for deprecated old name */
  4422. #define WOLFSSL_ERR_remove_thread_state wolfSSL_ERR_remove_thread_state
  4423. #ifndef NO_FILESYSTEM
  4424. WOLFSSL_API void wolfSSL_print_all_errors_fp(XFILE fp);
  4425. #endif
  4426. WOLFSSL_API int wolfSSL_THREADID_set_callback(
  4427. void (*threadid_func)(WOLFSSL_CRYPTO_THREADID*));
  4428. WOLFSSL_API void wolfSSL_THREADID_set_numeric(void* id, unsigned long val);
  4429. WOLFSSL_API void wolfSSL_THREADID_current(WOLFSSL_CRYPTO_THREADID* id);
  4430. WOLFSSL_API unsigned long wolfSSL_THREADID_hash(
  4431. const WOLFSSL_CRYPTO_THREADID* id);
  4432. WOLFSSL_API WOLFSSL_X509_LOOKUP_TYPE wolfSSL_X509_OBJECT_get_type(
  4433. const WOLFSSL_X509_OBJECT* obj);
  4434. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509_OBJECT)*
  4435. wolfSSL_X509_STORE_get0_objects(WOLFSSL_X509_STORE* store);
  4436. WOLFSSL_API WOLFSSL_X509_OBJECT*
  4437. wolfSSL_sk_X509_OBJECT_delete(WOLF_STACK_OF(WOLFSSL_X509_OBJECT)* sk, int i);
  4438. WOLFSSL_API WOLFSSL_X509_OBJECT* wolfSSL_X509_OBJECT_new(void);
  4439. WOLFSSL_API void wolfSSL_X509_OBJECT_free(WOLFSSL_X509_OBJECT *obj);
  4440. WOLFSSL_API WOLFSSL_X509 *wolfSSL_X509_OBJECT_get0_X509(const WOLFSSL_X509_OBJECT *obj);
  4441. WOLFSSL_API WOLFSSL_X509_CRL *wolfSSL_X509_OBJECT_get0_X509_CRL(WOLFSSL_X509_OBJECT *obj);
  4442. WOLFSSL_API WOLFSSL_X509_OBJECT *wolfSSL_X509_OBJECT_retrieve_by_subject(
  4443. WOLF_STACK_OF(WOLFSSL_X509_OBJECT) *sk,
  4444. WOLFSSL_X509_LOOKUP_TYPE type,
  4445. WOLFSSL_X509_NAME *name);
  4446. #endif /* OPENSSL_ALL || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY || HAVE_LIGHTY */
  4447. #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_WPAS_SMALL)
  4448. #include <wolfssl/openssl/stack.h>
  4449. WOLFSSL_API void wolfSSL_sk_X509_pop_free(WOLF_STACK_OF(WOLFSSL_X509)* sk, void (*f) (WOLFSSL_X509*));
  4450. #endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
  4451. #if (defined(OPENSSL_EXTRA) || defined(HAVE_CURL)) && (defined(HAVE_ECC) || \
  4452. defined(HAVE_CURVE25519) || defined(HAVE_CURVE448))
  4453. WOLFSSL_API int wolfSSL_CTX_set1_curves_list(WOLFSSL_CTX* ctx, const char* names);
  4454. WOLFSSL_API int wolfSSL_set1_curves_list(WOLFSSL* ssl, const char* names);
  4455. #endif
  4456. #if defined(OPENSSL_ALL) || \
  4457. defined(HAVE_STUNNEL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \
  4458. defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
  4459. WOLFSSL_API int wolfSSL_get_verify_mode(const WOLFSSL* ssl);
  4460. WOLFSSL_API int wolfSSL_CTX_get_verify_mode(const WOLFSSL_CTX* ctx);
  4461. #endif
  4462. #ifdef WOLFSSL_JNI
  4463. WOLFSSL_API int wolfSSL_set_jobject(WOLFSSL* ssl, void* objPtr);
  4464. WOLFSSL_API void* wolfSSL_get_jobject(WOLFSSL* ssl);
  4465. #endif /* WOLFSSL_JNI */
  4466. #ifdef WOLFSSL_ASYNC_CRYPT
  4467. WOLFSSL_API int wolfSSL_AsyncPoll(WOLFSSL* ssl, WOLF_EVENT_FLAG flags);
  4468. WOLFSSL_API int wolfSSL_CTX_AsyncPoll(WOLFSSL_CTX* ctx, WOLF_EVENT** events, int maxEvents,
  4469. WOLF_EVENT_FLAG flags, int* eventCount);
  4470. #endif /* WOLFSSL_ASYNC_CRYPT */
  4471. typedef void (*Rem_Sess_Cb)(WOLFSSL_CTX*, WOLFSSL_SESSION*);
  4472. #ifdef OPENSSL_EXTRA
  4473. typedef void (*SSL_Msg_Cb)(int write_p, int version, int content_type,
  4474. const void *buf, size_t len, WOLFSSL *ssl, void *arg);
  4475. #if defined(HAVE_SECRET_CALLBACK)
  4476. typedef void (*wolfSSL_CTX_keylog_cb_func)
  4477. (const WOLFSSL* ssl, const char* line);
  4478. WOLFSSL_API void wolfSSL_CTX_set_keylog_callback(WOLFSSL_CTX* ctx,
  4479. wolfSSL_CTX_keylog_cb_func cb);
  4480. WOLFSSL_API wolfSSL_CTX_keylog_cb_func wolfSSL_CTX_get_keylog_callback(
  4481. const WOLFSSL_CTX* ctx);
  4482. #endif /* HAVE_SECRET_CALLBACK */
  4483. WOLFSSL_API int wolfSSL_CTX_set_msg_callback(WOLFSSL_CTX *ctx, SSL_Msg_Cb cb);
  4484. WOLFSSL_API int wolfSSL_set_msg_callback(WOLFSSL *ssl, SSL_Msg_Cb cb);
  4485. WOLFSSL_API int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg);
  4486. WOLFSSL_API int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg);
  4487. WOLFSSL_API unsigned long wolfSSL_ERR_peek_error_line_data(const char **file,
  4488. int *line, const char **data, int *flags);
  4489. WOLFSSL_API int wolfSSL_CTX_set_alpn_protos(WOLFSSL_CTX *ctx,
  4490. const unsigned char *protos, unsigned int protos_len);
  4491. WOLFSSL_API int wolfSSL_set_alpn_protos(WOLFSSL* ssl,
  4492. const unsigned char* protos, unsigned int protos_len);
  4493. WOLFSSL_API void *wolfSSL_OPENSSL_memdup(const void *data,
  4494. size_t siz, const char* file, int line);
  4495. WOLFSSL_API void wolfSSL_OPENSSL_cleanse(void *ptr, size_t len);
  4496. WOLFSSL_API void wolfSSL_ERR_load_BIO_strings(void);
  4497. WOLFSSL_API void wolfSSL_DH_get0_pqg(const WOLFSSL_DH* dh,
  4498. const WOLFSSL_BIGNUM** p, const WOLFSSL_BIGNUM** q,
  4499. const WOLFSSL_BIGNUM** g);
  4500. WOLFSSL_API void wolfSSL_DH_get0_key(const WOLFSSL_DH *dh,
  4501. const WOLFSSL_BIGNUM **pub_key, const WOLFSSL_BIGNUM **priv_key);
  4502. WOLFSSL_API int wolfSSL_DH_set0_key(WOLFSSL_DH *dh, WOLFSSL_BIGNUM *pub_key,
  4503. WOLFSSL_BIGNUM *priv_key);
  4504. #endif
  4505. #if defined(HAVE_OCSP) && !defined(NO_ASN_TIME)
  4506. WOLFSSL_API int wolfSSL_get_ocsp_producedDate(
  4507. WOLFSSL *ssl,
  4508. byte *producedDate,
  4509. size_t producedDate_space,
  4510. int *producedDateFormat);
  4511. WOLFSSL_API int wolfSSL_get_ocsp_producedDate_tm(WOLFSSL *ssl,
  4512. struct tm *produced_tm);
  4513. #endif
  4514. #if defined(OPENSSL_ALL) \
  4515. || defined(WOLFSSL_NGINX) \
  4516. || defined(WOLFSSL_HAPROXY) \
  4517. || defined(OPENSSL_EXTRA) \
  4518. || defined(HAVE_STUNNEL)
  4519. WOLFSSL_API void wolfSSL_OPENSSL_config(char *config_name);
  4520. #endif
  4521. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
  4522. /* Not an OpenSSL API. */
  4523. WOLFSSL_LOCAL int wolfSSL_get_ocsp_response(WOLFSSL* ssl, byte** response);
  4524. /* Not an OpenSSL API. */
  4525. WOLFSSL_LOCAL char* wolfSSL_get_ocsp_url(WOLFSSL* ssl);
  4526. /* Not an OpenSSL API. */
  4527. WOLFSSL_API int wolfSSL_set_ocsp_url(WOLFSSL* ssl, char* url);
  4528. #endif
  4529. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) \
  4530. || defined(WOLFSSL_WPAS_SMALL)
  4531. WOLFSSL_API void *wolfSSL_X509_get_ex_data(WOLFSSL_X509 *x509, int idx);
  4532. WOLFSSL_API int wolfSSL_X509_set_ex_data(WOLFSSL_X509 *x509, int idx,
  4533. void *data);
  4534. #ifdef HAVE_EX_DATA_CLEANUP_HOOKS
  4535. WOLFSSL_API int wolfSSL_X509_set_ex_data_with_cleanup(
  4536. WOLFSSL_X509 *x509,
  4537. int idx,
  4538. void *data,
  4539. wolfSSL_ex_data_cleanup_routine_t cleanup_routine);
  4540. #endif
  4541. #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL || WOLFSSL_WPAS_SMALL */
  4542. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) \
  4543. || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY) || defined(HAVE_SECRET_CALLBACK)
  4544. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_CIPHER) *wolfSSL_get_ciphers_compat(const WOLFSSL *ssl);
  4545. #ifdef HAVE_EX_DATA
  4546. WOLFSSL_API int wolfSSL_X509_get_ex_new_index(int idx, void *arg,
  4547. WOLFSSL_CRYPTO_EX_new* new_func,
  4548. WOLFSSL_CRYPTO_EX_dup* dup_func,
  4549. WOLFSSL_CRYPTO_EX_free* free_func);
  4550. #endif
  4551. WOLFSSL_API int wolfSSL_X509_NAME_digest(const WOLFSSL_X509_NAME *data,
  4552. const WOLFSSL_EVP_MD *type, unsigned char *md, unsigned int *len);
  4553. WOLFSSL_API long wolfSSL_SSL_CTX_get_timeout(const WOLFSSL_CTX *ctx);
  4554. WOLFSSL_API long wolfSSL_get_timeout(WOLFSSL* ssl);
  4555. WOLFSSL_API int wolfSSL_SSL_CTX_set_tmp_ecdh(WOLFSSL_CTX *ctx,
  4556. WOLFSSL_EC_KEY *ecdh);
  4557. WOLFSSL_API WOLFSSL_BIO *wolfSSL_SSL_get_rbio(const WOLFSSL *s);
  4558. WOLFSSL_API WOLFSSL_BIO *wolfSSL_SSL_get_wbio(const WOLFSSL *s);
  4559. WOLFSSL_API int wolfSSL_SSL_do_handshake(WOLFSSL *s);
  4560. #ifdef OPENSSL_EXTRA
  4561. WOLFSSL_API int wolfSSL_OPENSSL_init_ssl(word64 opts,
  4562. const OPENSSL_INIT_SETTINGS *settings);
  4563. WOLFSSL_API OPENSSL_INIT_SETTINGS* wolfSSL_OPENSSL_INIT_new(void);
  4564. WOLFSSL_API void wolfSSL_OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS* init);
  4565. WOLFSSL_API int wolfSSL_OPENSSL_INIT_set_config_appname(
  4566. OPENSSL_INIT_SETTINGS* init, char* appname);
  4567. #endif
  4568. #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
  4569. WOLFSSL_API int wolfSSL_SSL_in_init(const WOLFSSL* ssl);
  4570. #else
  4571. WOLFSSL_API int wolfSSL_SSL_in_init(WOLFSSL* ssl);
  4572. #endif
  4573. WOLFSSL_API int wolfSSL_SSL_in_before(const WOLFSSL* ssl);
  4574. WOLFSSL_API int wolfSSL_SSL_in_connect_init(WOLFSSL* ssl);
  4575. #ifndef NO_SESSION_CACHE
  4576. WOLFSSL_API int wolfSSL_SSL_CTX_remove_session(WOLFSSL_CTX* ctx,
  4577. WOLFSSL_SESSION *c);
  4578. WOLFSSL_API WOLFSSL_SESSION *wolfSSL_SSL_get0_session(const WOLFSSL *s);
  4579. #endif
  4580. WOLFSSL_API int wolfSSL_i2a_ASN1_INTEGER(WOLFSSL_BIO *bp,
  4581. const WOLFSSL_ASN1_INTEGER *a);
  4582. #ifdef HAVE_SESSION_TICKET
  4583. typedef int (*ticketCompatCb)(WOLFSSL *ssl, unsigned char *name, unsigned char *iv,
  4584. WOLFSSL_EVP_CIPHER_CTX *ectx, WOLFSSL_HMAC_CTX *hctx, int enc);
  4585. WOLFSSL_API int wolfSSL_CTX_set_tlsext_ticket_key_cb(WOLFSSL_CTX* ctx, ticketCompatCb cb);
  4586. #endif
  4587. #if defined(HAVE_OCSP) || defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) || \
  4588. defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
  4589. WOLFSSL_API int wolfSSL_CTX_get_extra_chain_certs(WOLFSSL_CTX* ctx,
  4590. WOLF_STACK_OF(X509)** chain);
  4591. typedef int(*tlsextStatusCb)(WOLFSSL* ssl, void*);
  4592. WOLFSSL_API int wolfSSL_CTX_get_tlsext_status_cb(WOLFSSL_CTX* ctx, tlsextStatusCb* cb);
  4593. WOLFSSL_API int wolfSSL_CTX_set_tlsext_status_cb(WOLFSSL_CTX* ctx, tlsextStatusCb cb);
  4594. WOLFSSL_API int wolfSSL_CTX_get0_chain_certs(WOLFSSL_CTX *ctx,
  4595. WOLF_STACK_OF(WOLFSSL_X509) **sk);
  4596. WOLFSSL_API int wolfSSL_get0_chain_certs(WOLFSSL *ssl,
  4597. WOLF_STACK_OF(WOLFSSL_X509) **sk);
  4598. WOLFSSL_API int wolfSSL_X509_STORE_CTX_get1_issuer(WOLFSSL_X509 **issuer,
  4599. WOLFSSL_X509_STORE_CTX *ctx, WOLFSSL_X509 *x);
  4600. WOLFSSL_API void wolfSSL_X509_email_free(WOLF_STACK_OF(WOLFSSL_STRING) *sk);
  4601. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_STRING) *wolfSSL_X509_get1_ocsp(WOLFSSL_X509 *x);
  4602. WOLFSSL_API int wolfSSL_X509_check_issued(WOLFSSL_X509 *issuer,
  4603. WOLFSSL_X509 *subject);
  4604. WOLFSSL_API WOLF_STACK_OF(WOLFSSL_STRING)* wolfSSL_sk_WOLFSSL_STRING_new(void);
  4605. WOLFSSL_API void wolfSSL_WOLFSSL_STRING_free(WOLFSSL_STRING s);
  4606. WOLFSSL_API void wolfSSL_sk_WOLFSSL_STRING_free(WOLF_STACK_OF(WOLFSSL_STRING)* sk);
  4607. WOLFSSL_API WOLFSSL_STRING wolfSSL_sk_WOLFSSL_STRING_value(
  4608. WOLF_STACK_OF(WOLFSSL_STRING)* strings, int idx);
  4609. WOLFSSL_API int wolfSSL_sk_WOLFSSL_STRING_num(
  4610. WOLF_STACK_OF(WOLFSSL_STRING)* strings);
  4611. #endif /* HAVE_OCSP || OPENSSL_EXTRA || OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
  4612. WOLFSSL_API int PEM_write_bio_WOLFSSL_X509(WOLFSSL_BIO *bio,
  4613. WOLFSSL_X509 *cert);
  4614. #endif /* OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY ||
  4615. OPENSSL_EXTRA || HAVE_LIGHTY */
  4616. #if defined(HAVE_SESSION_TICKET) && !defined(WOLFSSL_NO_DEF_TICKET_ENC_CB) && \
  4617. !defined(NO_WOLFSSL_SERVER)
  4618. WOLFSSL_API long wolfSSL_CTX_get_tlsext_ticket_keys(WOLFSSL_CTX *ctx,
  4619. unsigned char *keys, int keylen);
  4620. WOLFSSL_API long wolfSSL_CTX_set_tlsext_ticket_keys(WOLFSSL_CTX *ctx,
  4621. const void *keys_vp, int keylen);
  4622. #endif
  4623. WOLFSSL_API void wolfSSL_get0_alpn_selected(const WOLFSSL *ssl,
  4624. const unsigned char **data, unsigned int *len);
  4625. WOLFSSL_API int wolfSSL_select_next_proto(unsigned char **out,
  4626. unsigned char *outlen,
  4627. const unsigned char *in, unsigned int inlen,
  4628. const unsigned char *client,
  4629. unsigned int client_len);
  4630. WOLFSSL_API void wolfSSL_set_alpn_select_cb(WOLFSSL *ssl,
  4631. int (*cb) (WOLFSSL *ssl,
  4632. const unsigned char **out,
  4633. unsigned char *outlen,
  4634. const unsigned char *in,
  4635. unsigned int inlen,
  4636. void *arg), void *arg);
  4637. WOLFSSL_API void wolfSSL_CTX_set_alpn_select_cb(WOLFSSL_CTX *ctx,
  4638. int (*cb) (WOLFSSL *ssl,
  4639. const unsigned char **out,
  4640. unsigned char *outlen,
  4641. const unsigned char *in,
  4642. unsigned int inlen,
  4643. void *arg), void *arg);
  4644. WOLFSSL_API void wolfSSL_CTX_set_next_protos_advertised_cb(WOLFSSL_CTX *s,
  4645. int (*cb) (WOLFSSL *ssl,
  4646. const unsigned char **out,
  4647. unsigned int *outlen,
  4648. void *arg), void *arg);
  4649. WOLFSSL_API void wolfSSL_CTX_set_next_proto_select_cb(WOLFSSL_CTX *s,
  4650. int (*cb) (WOLFSSL *ssl,
  4651. unsigned char **out,
  4652. unsigned char *outlen,
  4653. const unsigned char *in,
  4654. unsigned int inlen,
  4655. void *arg), void *arg);
  4656. WOLFSSL_API void wolfSSL_get0_next_proto_negotiated(const WOLFSSL *s, const unsigned char **data,
  4657. unsigned *len);
  4658. #ifndef NO_ASN
  4659. WOLFSSL_API int wolfSSL_X509_check_host(WOLFSSL_X509 *x, const char *chk,
  4660. size_t chklen, unsigned int flags, char **peername);
  4661. WOLFSSL_API int wolfSSL_X509_check_ip_asc(WOLFSSL_X509 *x, const char *ipasc,
  4662. unsigned int flags);
  4663. #endif
  4664. #if defined(OPENSSL_EXTRA) && defined(WOLFSSL_CERT_GEN)
  4665. WOLFSSL_API int wolfSSL_X509_check_email(WOLFSSL_X509 *x, const char *chk,
  4666. size_t chkLen, unsigned int flags);
  4667. #endif /* OPENSSL_EXTRA && WOLFSSL_CERT_GEN */
  4668. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
  4669. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_WPAS)
  4670. WOLFSSL_API const unsigned char *wolfSSL_SESSION_get0_id_context(
  4671. const WOLFSSL_SESSION *sess, unsigned int *sid_ctx_length);
  4672. #endif
  4673. #endif
  4674. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
  4675. WOLFSSL_API int wolfSSL_SESSION_set1_id(WOLFSSL_SESSION *s,
  4676. const unsigned char *sid, unsigned int sid_len);
  4677. WOLFSSL_API int wolfSSL_SESSION_set1_id_context(WOLFSSL_SESSION *s,
  4678. const unsigned char *sid_ctx, unsigned int sid_ctx_len);
  4679. WOLFSSL_API WOLFSSL_X509_ALGOR* wolfSSL_X509_ALGOR_new(void);
  4680. WOLFSSL_API void wolfSSL_X509_ALGOR_free(WOLFSSL_X509_ALGOR *alg);
  4681. WOLFSSL_API const WOLFSSL_X509_ALGOR* wolfSSL_X509_get0_tbs_sigalg(const WOLFSSL_X509 *x);
  4682. WOLFSSL_API void wolfSSL_X509_ALGOR_get0(const WOLFSSL_ASN1_OBJECT **paobj, int *pptype, const void **ppval, const WOLFSSL_X509_ALGOR *algor);
  4683. WOLFSSL_API int wolfSSL_X509_ALGOR_set0(WOLFSSL_X509_ALGOR *algor, WOLFSSL_ASN1_OBJECT *aobj, int ptype, void *pval);
  4684. WOLFSSL_API int wolfSSL_i2d_X509_ALGOR(const WOLFSSL_X509_ALGOR* alg,
  4685. unsigned char** pp);
  4686. WOLFSSL_API WOLFSSL_X509_ALGOR* wolfSSL_d2i_X509_ALGOR(WOLFSSL_X509_ALGOR** out,
  4687. const byte** src, long len);
  4688. WOLFSSL_API WOLFSSL_ASN1_TYPE* wolfSSL_ASN1_TYPE_new(void);
  4689. WOLFSSL_API void wolfSSL_ASN1_TYPE_free(WOLFSSL_ASN1_TYPE* at);
  4690. WOLFSSL_API int wolfSSL_i2d_ASN1_TYPE(WOLFSSL_ASN1_TYPE* at,
  4691. unsigned char** pp);
  4692. WOLFSSL_API WOLFSSL_X509_PUBKEY *wolfSSL_X509_PUBKEY_new(void);
  4693. WOLFSSL_API void wolfSSL_X509_PUBKEY_free(WOLFSSL_X509_PUBKEY *x);
  4694. WOLFSSL_API WOLFSSL_X509_PUBKEY *wolfSSL_X509_get_X509_PUBKEY(const WOLFSSL_X509* x509);
  4695. WOLFSSL_API int wolfSSL_X509_PUBKEY_get0_param(WOLFSSL_ASN1_OBJECT **ppkalg, const unsigned char **pk, int *ppklen, WOLFSSL_X509_ALGOR **pa, WOLFSSL_X509_PUBKEY *pub);
  4696. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_X509_PUBKEY_get(WOLFSSL_X509_PUBKEY* key);
  4697. WOLFSSL_API int wolfSSL_X509_PUBKEY_set(WOLFSSL_X509_PUBKEY **x, WOLFSSL_EVP_PKEY *key);
  4698. WOLFSSL_API int wolfSSL_i2t_ASN1_OBJECT(char *buf, int buf_len, WOLFSSL_ASN1_OBJECT *a);
  4699. WOLFSSL_API WOLFSSL_ASN1_OBJECT *wolfSSL_d2i_ASN1_OBJECT(WOLFSSL_ASN1_OBJECT **a,
  4700. const unsigned char **der,
  4701. long length);
  4702. WOLFSSL_API int wolfSSL_i2a_ASN1_OBJECT(WOLFSSL_BIO *bp, WOLFSSL_ASN1_OBJECT *a);
  4703. WOLFSSL_API int wolfSSL_i2d_ASN1_OBJECT(WOLFSSL_ASN1_OBJECT *a, unsigned char **pp);
  4704. WOLFSSL_API void SSL_CTX_set_tmp_dh_callback(WOLFSSL_CTX *ctx, WOLFSSL_DH *(*dh) (WOLFSSL *ssl, int is_export, int keylength));
  4705. WOLFSSL_API WOLF_STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);
  4706. WOLFSSL_API int wolfSSL_X509_STORE_load_locations(WOLFSSL_X509_STORE *str, const char *file, const char *dir);
  4707. WOLFSSL_API int wolfSSL_X509_STORE_add_crl(WOLFSSL_X509_STORE *ctx, WOLFSSL_X509_CRL *x);
  4708. WOLFSSL_API int wolfSSL_sk_SSL_CIPHER_num(const WOLF_STACK_OF(WOLFSSL_CIPHER)* p);
  4709. WOLFSSL_API int wolfSSL_sk_SSL_CIPHER_find(
  4710. WOLF_STACK_OF(WOLFSSL_CIPHER)* sk, const WOLFSSL_CIPHER* toFind);
  4711. WOLFSSL_API void wolfSSL_sk_SSL_CIPHER_free(WOLF_STACK_OF(WOLFSSL_CIPHER)* sk);
  4712. WOLFSSL_API int wolfSSL_sk_SSL_COMP_zero(WOLFSSL_STACK* st);
  4713. WOLFSSL_API int wolfSSL_sk_SSL_COMP_num(WOLF_STACK_OF(WOLFSSL_COMP)* sk);
  4714. WOLFSSL_API WOLFSSL_CIPHER* wolfSSL_sk_SSL_CIPHER_value(WOLFSSL_STACK* sk, int i);
  4715. WOLFSSL_API void ERR_load_SSL_strings(void);
  4716. WOLFSSL_API void wolfSSL_EC_POINT_dump(const char *msg, const WOLFSSL_EC_POINT *p);
  4717. WOLFSSL_API const char *wolfSSL_ASN1_tag2str(int tag);
  4718. WOLFSSL_API int wolfSSL_ASN1_STRING_print_ex(WOLFSSL_BIO *out, WOLFSSL_ASN1_STRING *str, unsigned long flags);
  4719. WOLFSSL_API int wolfSSL_ASN1_STRING_print(WOLFSSL_BIO *out, WOLFSSL_ASN1_STRING *str);
  4720. WOLFSSL_API int wolfSSL_ASN1_TIME_get_length(const WOLFSSL_ASN1_TIME *t);
  4721. WOLFSSL_API unsigned char* wolfSSL_ASN1_TIME_get_data(const WOLFSSL_ASN1_TIME *t);
  4722. WOLFSSL_API WOLFSSL_ASN1_TIME *wolfSSL_ASN1_TIME_to_generalizedtime(WOLFSSL_ASN1_TIME *t,
  4723. WOLFSSL_ASN1_TIME **out);
  4724. WOLFSSL_API WOLFSSL_ASN1_TIME* wolfSSL_ASN1_UTCTIME_set(WOLFSSL_ASN1_TIME *s, time_t t);
  4725. WOLFSSL_API int wolfSSL_i2c_ASN1_INTEGER(WOLFSSL_ASN1_INTEGER *a, unsigned char **pp);
  4726. WOLFSSL_API int wolfSSL_a2i_ASN1_INTEGER(WOLFSSL_BIO *bio, WOLFSSL_ASN1_INTEGER *asn1,
  4727. char *buf, int size);
  4728. WOLFSSL_API int wolfSSL_X509_CA_num(WOLFSSL_X509_STORE *store);
  4729. WOLFSSL_API long wolfSSL_X509_get_version(const WOLFSSL_X509 *x);
  4730. WOLFSSL_API int wolfSSL_X509_get_signature_nid(const WOLFSSL_X509* x);
  4731. #ifndef WOLFCRYPT_ONLY
  4732. WOLFSSL_API int wolfSSL_PEM_write_bio_PKCS8PrivateKey(WOLFSSL_BIO* bio,
  4733. WOLFSSL_EVP_PKEY* pkey, const WOLFSSL_EVP_CIPHER* enc, char* passwd,
  4734. int passwdSz, wc_pem_password_cb* cb, void* ctx);
  4735. WOLFSSL_API int wolfSSL_PEM_write_bio_PKCS8_PRIV_KEY_INFO(WOLFSSL_BIO* bio,
  4736. PKCS8_PRIV_KEY_INFO* keyInfo);
  4737. #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
  4738. WOLFSSL_API int wolfSSL_PEM_write_PKCS8PrivateKey(
  4739. XFILE fp, WOLFSSL_EVP_PKEY* pkey, const WOLFSSL_EVP_CIPHER* enc,
  4740. char* passwd, int passwdSz, wc_pem_password_cb* cb, void* ctx);
  4741. #endif /* !NO_FILESYSTEM && !NO_STDIO_FILESYSTEM */
  4742. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_PKCS8PrivateKey_bio(WOLFSSL_BIO* bio,
  4743. WOLFSSL_EVP_PKEY** pkey, wc_pem_password_cb* cb, void* u);
  4744. WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_d2i_AutoPrivateKey(
  4745. WOLFSSL_EVP_PKEY** pkey, const unsigned char** data, long length);
  4746. #endif /* !WOLFCRYPT_ONLY */
  4747. #endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
  4748. #ifdef WOLFSSL_HAVE_TLS_UNIQUE
  4749. WOLFSSL_API size_t wolfSSL_get_finished(const WOLFSSL *ssl, void *buf, size_t count);
  4750. WOLFSSL_API size_t wolfSSL_get_peer_finished(const WOLFSSL *ssl, void *buf, size_t count);
  4751. #endif /* WOLFSSL_HAVE_TLS_UNIQUE */
  4752. #ifdef HAVE_PK_CALLBACKS
  4753. WOLFSSL_API int wolfSSL_IsPrivatePkSet(WOLFSSL* ssl);
  4754. WOLFSSL_API int wolfSSL_CTX_IsPrivatePkSet(WOLFSSL_CTX* ctx);
  4755. #endif
  4756. #ifdef HAVE_ENCRYPT_THEN_MAC
  4757. WOLFSSL_API int wolfSSL_CTX_AllowEncryptThenMac(WOLFSSL_CTX* ctx, int set);
  4758. WOLFSSL_API int wolfSSL_AllowEncryptThenMac(WOLFSSL *s, int set);
  4759. #endif
  4760. /* This feature is used to set a fixed ephemeral key and is for testing only */
  4761. /* Currently allows ECDHE and DHE only */
  4762. #ifdef WOLFSSL_STATIC_EPHEMERAL
  4763. WOLFSSL_API int wolfSSL_CTX_set_ephemeral_key(WOLFSSL_CTX* ctx, int keyAlgo,
  4764. const char* key, unsigned int keySz, int format);
  4765. WOLFSSL_API int wolfSSL_set_ephemeral_key(WOLFSSL* ssl, int keyAlgo,
  4766. const char* key, unsigned int keySz, int format);
  4767. /* returns pointer to loaded key as ASN.1/DER */
  4768. WOLFSSL_API int wolfSSL_CTX_get_ephemeral_key(WOLFSSL_CTX* ctx, int keyAlgo,
  4769. const unsigned char** key, unsigned int* keySz);
  4770. WOLFSSL_API int wolfSSL_get_ephemeral_key(WOLFSSL* ssl, int keyAlgo,
  4771. const unsigned char** key, unsigned int* keySz);
  4772. #endif
  4773. #ifdef HAVE_RPK
  4774. /* cert type for client_certificate_type/server_certificate_type extensions */
  4775. enum {
  4776. WOLFSSL_CERT_TYPE_UNKNOWN = -1,
  4777. WOLFSSL_CERT_TYPE_X509 = 0,
  4778. WOLFSSL_CERT_TYPE_RPK = 2,
  4779. };
  4780. #define MAX_CLIENT_CERT_TYPE_CNT 2
  4781. #define MAX_SERVER_CERT_TYPE_CNT 2
  4782. WOLFSSL_API int wolfSSL_CTX_set_client_cert_type(WOLFSSL_CTX* ctx,
  4783. const char* buf, int len);
  4784. WOLFSSL_API int wolfSSL_CTX_set_server_cert_type(WOLFSSL_CTX* ctx,
  4785. const char* buf, int len);
  4786. WOLFSSL_API int wolfSSL_set_client_cert_type(WOLFSSL* ssl,
  4787. const char* buf, int len);
  4788. WOLFSSL_API int wolfSSL_set_server_cert_type(WOLFSSL* ssl,
  4789. const char* buf, int len);
  4790. WOLFSSL_API int wolfSSL_get_negotiated_client_cert_type(WOLFSSL* ssl, int* tp);
  4791. WOLFSSL_API int wolfSSL_get_negotiated_server_cert_type(WOLFSSL* ssl, int* tp);
  4792. #endif /* HAVE_RPK */
  4793. #if defined(OPENSSL_EXTRA)
  4794. #ifndef WOLFCRYPT_ONLY
  4795. WOLFSSL_API int wolfSSL_EVP_PKEY_param_check(WOLFSSL_EVP_PKEY_CTX* ctx);
  4796. #endif
  4797. WOLFSSL_API void wolfSSL_CTX_set_security_level(WOLFSSL_CTX* ctx, int level);
  4798. WOLFSSL_API int wolfSSL_CTX_get_security_level(const WOLFSSL_CTX* ctx);
  4799. WOLFSSL_API int wolfSSL_SESSION_is_resumable(const WOLFSSL_SESSION *s);
  4800. WOLFSSL_API void wolfSSL_CRYPTO_free(void *str, const char *file, int line);
  4801. WOLFSSL_API void *wolfSSL_CRYPTO_malloc(size_t num, const char *file, int line);
  4802. WOLFSSL_API WOLFSSL_CONF_CTX* wolfSSL_CONF_CTX_new(void);
  4803. WOLFSSL_API void wolfSSL_CONF_CTX_free(WOLFSSL_CONF_CTX* cctx);
  4804. WOLFSSL_API void wolfSSL_CONF_CTX_set_ssl_ctx(WOLFSSL_CONF_CTX* cctx, WOLFSSL_CTX *ctx);
  4805. WOLFSSL_API unsigned int wolfSSL_CONF_CTX_set_flags(WOLFSSL_CONF_CTX* cctx, unsigned int flags);
  4806. WOLFSSL_API int wolfSSL_CONF_CTX_finish(WOLFSSL_CONF_CTX* cctx);
  4807. #define WOLFSSL_CONF_FLAG_CMDLINE 0x1
  4808. #define WOLFSSL_CONF_FLAG_FILE 0x2
  4809. #define WOLFSSL_CONF_FLAG_CLIENT 0x4
  4810. #define WOLFSSL_CONF_FLAG_SERVER 0x8
  4811. #define WOLFSSL_CONF_FLAG_SHOW_ERRORS 0x10
  4812. #define WOLFSSL_CONF_FLAG_CERTIFICATE 0x20
  4813. #define WOLFSSL_CONF_TYPE_UNKNOWN 0x0
  4814. #define WOLFSSL_CONF_TYPE_STRING 0x1
  4815. #define WOLFSSL_CONF_TYPE_FILE 0x2
  4816. #define WOLFSSL_CONF_TYPE_DIR 0x3
  4817. WOLFSSL_API int wolfSSL_CONF_cmd(WOLFSSL_CONF_CTX* cctx, const char* cmd, const char* value);
  4818. WOLFSSL_API int wolfSSL_CONF_cmd_value_type(WOLFSSL_CONF_CTX *cctx, const char *cmd);
  4819. #endif /* OPENSSL_EXTRA */
  4820. #if defined(HAVE_EX_DATA) || defined(WOLFSSL_WPAS_SMALL)
  4821. WOLFSSL_API int wolfSSL_CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
  4822. WOLFSSL_CRYPTO_EX_new* new_func,
  4823. WOLFSSL_CRYPTO_EX_dup* dup_func,
  4824. WOLFSSL_CRYPTO_EX_free* free_func);
  4825. #endif /* HAVE_EX_DATA || WOLFSSL_WPAS_SMALL */
  4826. #if defined(WOLFSSL_DTLS_CID)
  4827. WOLFSSL_API int wolfSSL_dtls_cid_use(WOLFSSL* ssl);
  4828. WOLFSSL_API int wolfSSL_dtls_cid_is_enabled(WOLFSSL* ssl);
  4829. WOLFSSL_API int wolfSSL_dtls_cid_set(WOLFSSL* ssl, unsigned char* cid,
  4830. unsigned int size);
  4831. WOLFSSL_API int wolfSSL_dtls_cid_get_rx_size(WOLFSSL* ssl,
  4832. unsigned int* size);
  4833. WOLFSSL_API int wolfSSL_dtls_cid_get_rx(WOLFSSL* ssl, unsigned char* buffer,
  4834. unsigned int bufferSz);
  4835. WOLFSSL_API int wolfSSL_dtls_cid_get_tx_size(WOLFSSL* ssl,
  4836. unsigned int* size);
  4837. WOLFSSL_API int wolfSSL_dtls_cid_get_tx(WOLFSSL* ssl, unsigned char* buffer,
  4838. unsigned int bufferSz);
  4839. WOLFSSL_API int wolfSSL_dtls_cid_max_size(void);
  4840. #endif /* defined(WOLFSSL_DTLS_CID) */
  4841. #ifdef WOLFSSL_DTLS_CH_FRAG
  4842. WOLFSSL_API int wolfSSL_dtls13_allow_ch_frag(WOLFSSL *ssl, int enabled);
  4843. #endif
  4844. #ifdef WOLFSSL_DTLS13_NO_HRR_ON_RESUME
  4845. WOLFSSL_API int wolfSSL_dtls13_no_hrr_on_resume(WOLFSSL *ssl, int enabled);
  4846. #endif
  4847. /* */
  4848. #define SSL2_VERSION 0x0002
  4849. #define SSL3_VERSION 0x0300
  4850. #define TLS1_VERSION 0x0301
  4851. #define TLS1_1_VERSION 0x0302
  4852. #define TLS1_2_VERSION 0x0303
  4853. #define TLS1_3_VERSION 0x0304
  4854. #define DTLS1_VERSION 0xFEFF
  4855. #define DTLS1_2_VERSION 0xFEFD
  4856. #define DTLS1_3_VERSION 0xFEFC
  4857. /* These minimums where determined whilst referencing their RFC specs. The
  4858. * values represent the minimum sizes of the data types in the required struct
  4859. * for the `extension_data` field. A length of 0 was assumed when necassary.
  4860. *
  4861. * Documents Used for the respective extension:
  4862. * - https://datatracker.ietf.org/doc/html/rfc6066
  4863. * - Server Name Indication (SNI)
  4864. * - Maximum Fragment Length Negotiation (MFL)
  4865. * - Trusted CA Indication (TCA)
  4866. * - Certificate Status Request (CSR)
  4867. * - Truncate HMAC (THM)
  4868. * - https://datatracker.ietf.org/doc/html/rfc8446
  4869. * - Early Data Indication (EDI)
  4870. * - Pre-Shared Key (PSK)
  4871. * - Pre-Shared Key Exchange Modes (PKM)
  4872. * - Key Share (KS)
  4873. * - Post-Handshake Authentication (PHA)
  4874. * - Signature Algorithms (SA)
  4875. * - Signature Algorithms Certificate (SAC)
  4876. * - Support Groups (EC)
  4877. * - Cookie (CKE)
  4878. * - Supported Versions (SV)
  4879. * - Certificate Authorities (CAN)
  4880. * - https://datatracker.ietf.org/doc/html/rfc6961
  4881. * - Certificate Status Request v2 (CSR2)
  4882. * - https://datatracker.ietf.org/doc/rfc9146/
  4883. * - Connection Identifier (CID)
  4884. * - https://datatracker.ietf.org/doc/rfc7301/
  4885. * - Application-Layer Protocol Negotiation (ALPN)
  4886. * - https://datatracker.ietf.org/doc/html/rfc3711
  4887. * - Secure Real-time Transport Protocol (SRTP)
  4888. * - https://datatracker.ietf.org/doc/html/rfc7366
  4889. * - Encrypt Then Mac (ETM)
  4890. * - https://datatracker.ietf.org/doc/html/rfc7250
  4891. * - Client Certificate Type (CCT)
  4892. * - Server Certificate Type (SCT)
  4893. * - https://datatracker.ietf.org/doc/draft-ietf-tls-esni/
  4894. * - Encrypted Client Hello (ECH)
  4895. * - https://datatracker.ietf.org/doc/html/rfc5746
  4896. * - Secure Renegotiation (SCR)
  4897. * - https://datatracker.ietf.org/doc/rfc4492/
  4898. * - Point Frame (PF)
  4899. * - https://datatracker.ietf.org/doc/rfc9000/
  4900. * - QUIC (QTP)
  4901. * - https://datatracker.ietf.org/doc/html/rfc5077
  4902. * - Session Ticket (STK)
  4903. * Example:
  4904. * For `WOLFSSL_CSR_MIN_SIZE_CLIENT = 5`, 5 was determined by looking at the
  4905. * struct below defined in its respective RFC.
  4906. * The below struct for `CertificateStatusRequest` is made up of the types:
  4907. * `CertificateStatusType` is an enum with a max value of 255, thus its
  4908. * length is 1 byte.
  4909. * `OCSPStatusRequest` is a struct of the following:
  4910. * - `responder_id_list`: which is 2 bytes
  4911. * - `request_extensions`: which is 2 bytes
  4912. * This then gives the minimum size/length of 5 bytes for this extension
  4913. * for the client
  4914. * struct {
  4915. * CertificateStatusType status_type;
  4916. * select (status_type) {
  4917. * case ocsp: OCSPStatusRequest;
  4918. * } request;
  4919. * } CertificateStatusRequest;
  4920. * enum { ocsp(1), (255) } CertificateStatusType;
  4921. * struct {
  4922. * ResponderID responder_id_list<0..2^16-1>;
  4923. * Extensions request_extensions;
  4924. * } OCSPStatusRequest;
  4925. * opaque ResponderID<1..2^16-1>;
  4926. * opaque Extensions<0..2^16-1>;
  4927. */
  4928. #ifndef WOLFSSL_SNI_MIN_SIZE_CLIENT
  4929. #define WOLFSSL_SNI_MIN_SIZE_CLIENT 4
  4930. #endif
  4931. #ifndef WOLFSSL_SNI_MIN_SIZE_SERVER
  4932. #define WOLFSSL_SNI_MIN_SIZE_SERVER 0
  4933. #endif
  4934. #ifndef WOLFSSL_EDI_MIN_SIZE_CLIENT
  4935. #define WOLFSSL_EDI_MIN_SIZE_CLIENT 0
  4936. #endif
  4937. #ifndef WOLFSSL_EDI_MIN_SIZE_SERVER
  4938. #define WOLFSSL_EDI_MIN_SIZE_SERVER 0
  4939. #endif
  4940. #ifndef WOLFSSL_TCA_MIN_SIZE_CLIENT
  4941. #define WOLFSSL_TCA_MIN_SIZE_CLIENT 2
  4942. #endif
  4943. #ifndef WOLFSSL_TCA_MIN_SIZE_SERVER
  4944. #define WOLFSSL_TCA_MIN_SIZE_SERVER 0
  4945. #endif
  4946. #ifndef WOLFSSL_CSR_MIN_SIZE_CLIENT
  4947. #define WOLFSSL_CSR_MIN_SIZE_CLIENT 5
  4948. #endif
  4949. #ifndef WOLFSSL_CSR_MIN_SIZE_SERVER
  4950. #define WOLFSSL_CSR_MIN_SIZE_SERVER 0
  4951. #endif
  4952. #ifndef WOLFSSL_PKM_MIN_SIZE_CLIENT
  4953. #define WOLFSSL_PKM_MIN_SIZE_CLIENT 1
  4954. #endif
  4955. #ifndef WOLFSSL_PKM_MIN_SIZE_SERVER
  4956. #define WOLFSSL_PKM_MIN_SIZE_SERVER 0
  4957. #endif
  4958. #ifndef WOLFSSL_CSR2_MIN_SIZE_CLIENT
  4959. #define WOLFSSL_CSR2_MIN_SIZE_CLIENT 7
  4960. #endif
  4961. #ifndef WOLFSSL_CSR2_MIN_SIZE_SERVER
  4962. #define WOLFSSL_CSR2_MIN_SIZE_SERVER 0
  4963. #endif
  4964. #ifndef WOLFSSL_CID_MIN_SIZE_CLIENT
  4965. #define WOLFSSL_CID_MIN_SIZE_CLIENT 1
  4966. #endif
  4967. #ifndef WOLFSSL_CID_MIN_SIZE_SERVER
  4968. #define WOLFSSL_CID_MIN_SIZE_SERVER 1
  4969. #endif
  4970. #ifndef WOLFSSL_ALPN_MIN_SIZE_CLIENT
  4971. #define WOLFSSL_ALPN_MIN_SIZE_CLIENT 2
  4972. #endif
  4973. #ifndef WOLFSSL_ALPN_MIN_SIZE_SERVER
  4974. #define WOLFSSL_ALPN_MIN_SIZE_SERVER 2
  4975. #endif
  4976. #ifndef WOLFSSL_SRTP_MIN_SIZE_CLIENT
  4977. #define WOLFSSL_SRTP_MIN_SIZE_CLIENT 3
  4978. #endif
  4979. #ifndef WOLFSSL_SRTP_MIN_SIZE_SERVER
  4980. #define WOLFSSL_SRTP_MIN_SIZE_SERVER 3
  4981. #endif
  4982. #ifndef WOLFSSL_KS_MIN_SIZE_CLIENT
  4983. #define WOLFSSL_KS_MIN_SIZE_CLIENT 1
  4984. #endif
  4985. #ifndef WOLFSSL_KS_MIN_SIZE_SERVER
  4986. #define WOLFSSL_KS_MIN_SIZE_SERVER 1
  4987. #endif
  4988. #ifndef WOLFSSL_ETM_MIN_SIZE_CLIENT
  4989. #define WOLFSSL_ETM_MIN_SIZE_CLIENT 0
  4990. #endif
  4991. #ifndef WOLFSSL_ETM_MIN_SIZE_SERVER
  4992. #define WOLFSSL_ETM_MIN_SIZE_SERVER 0
  4993. #endif
  4994. #ifndef WOLFSSL_PSK_MIN_SIZE_CLIENT
  4995. #define WOLFSSL_PSK_MIN_SIZE_CLIENT 2
  4996. #endif
  4997. #ifndef WOLFSSL_PSK_MIN_SIZE_SERVER
  4998. #define WOLFSSL_PSK_MIN_SIZE_SERVER 2
  4999. #endif
  5000. #ifndef WOLFSSL_CCT_MIN_SIZE_CLIENT
  5001. #define WOLFSSL_CCT_MIN_SIZE_CLIENT 1
  5002. #endif
  5003. #ifndef WOLFSSL_CCT_MIN_SIZE_SERVER
  5004. #define WOLFSSL_CCT_MIN_SIZE_SERVER 1
  5005. #endif
  5006. #ifndef WOLFSSL_SCT_MIN_SIZE_CLIENT
  5007. #define WOLFSSL_SCT_MIN_SIZE_CLIENT 1
  5008. #endif
  5009. #ifndef WOLFSSL_SCT_MIN_SIZE_SERVER
  5010. #define WOLFSSL_SCT_MIN_SIZE_SERVER 1
  5011. #endif
  5012. #ifndef WOLFSSL_PHA_MIN_SIZE_CLIENT
  5013. #define WOLFSSL_PHA_MIN_SIZE_CLIENT 0
  5014. #endif
  5015. #ifndef WOLFSSL_PHA_MIN_SIZE_SERVER
  5016. #define WOLFSSL_PHA_MIN_SIZE_SERVER 0
  5017. #endif
  5018. #ifndef WOLFSSL_THM_MIN_SIZE_CLIENT
  5019. #define WOLFSSL_THM_MIN_SIZE_CLIENT 0
  5020. #endif
  5021. #ifndef WOLFSSL_THM_MIN_SIZE_SERVER
  5022. #define WOLFSSL_THM_MIN_SIZE_SERVER 0
  5023. #endif
  5024. #ifndef WOLFSSL_SA_MIN_SIZE_CLIENT
  5025. #define WOLFSSL_SA_MIN_SIZE_CLIENT 2
  5026. #endif
  5027. #ifndef WOLFSSL_SA_MIN_SIZE_SERVER
  5028. #define WOLFSSL_SA_MIN_SIZE_SERVER 2
  5029. #endif
  5030. #ifndef WOLFSSL_SAC_MIN_SIZE_CLIENT
  5031. #define WOLFSSL_SAC_MIN_SIZE_CLIENT 2
  5032. #endif
  5033. #ifndef WOLFSSL_SAC_MIN_SIZE_SERVER
  5034. #define WOLFSSL_SAC_MIN_SIZE_SERVER 2
  5035. #endif
  5036. #ifndef WOLFSSL_EC_MIN_SIZE_CLIENT
  5037. #define WOLFSSL_EC_MIN_SIZE_CLIENT 2
  5038. #endif
  5039. #ifndef WOLFSSL_EC_MIN_SIZE_SERVER
  5040. #define WOLFSSL_EC_MIN_SIZE_SERVER 2
  5041. #endif
  5042. #ifndef WOLFSSL_ECH_MIN_SIZE_CLIENT
  5043. #define WOLFSSL_ECH_MIN_SIZE_CLIENT 1
  5044. #endif
  5045. #ifndef WOLFSSL_ECH_MIN_SIZE_SERVER
  5046. #define WOLFSSL_ECH_MIN_SIZE_SERVER 0
  5047. #endif
  5048. #ifndef WOLFSSL_MFL_MIN_SIZE_CLIENT
  5049. #define WOLFSSL_MFL_MIN_SIZE_CLIENT 1
  5050. #endif
  5051. #ifndef WOLFSSL_MFL_MIN_SIZE_SERVER
  5052. #define WOLFSSL_MFL_MIN_SIZE_SERVER 1
  5053. #endif
  5054. #ifndef WOLFSSL_CKE_MIN_SIZE_CLIENT
  5055. #define WOLFSSL_CKE_MIN_SIZE_CLIENT 3
  5056. #endif
  5057. #ifndef WOLFSSL_CKE_MIN_SIZE_SERVER
  5058. #define WOLFSSL_CKE_MIN_SIZE_SERVER 3
  5059. #endif
  5060. #ifndef WOLFSSL_SV_MIN_SIZE_CLIENT
  5061. #define WOLFSSL_SV_MIN_SIZE_CLIENT 2
  5062. #endif
  5063. #ifndef WOLFSSL_SV_MIN_SIZE_SERVER
  5064. #define WOLFSSL_SV_MIN_SIZE_SERVER 2
  5065. #endif
  5066. #ifndef WOLFSSL_SCR_MIN_SIZE_CLIENT
  5067. #define WOLFSSL_SCR_MIN_SIZE_CLIENT 1
  5068. #endif
  5069. #ifndef WOLFSSL_SCR_MIN_SIZE_SERVER
  5070. #define WOLFSSL_SCR_MIN_SIZE_SERVER 1
  5071. #endif
  5072. #ifndef WOLFSSL_PF_MIN_SIZE_CLIENT
  5073. #define WOLFSSL_PF_MIN_SIZE_CLIENT 1
  5074. #endif
  5075. #ifndef WOLFSSL_PF_MIN_SIZE_SERVER
  5076. #define WOLFSSL_PF_MIN_SIZE_SERVER 1
  5077. #endif
  5078. #ifndef WOLFSSL_CAN_MIN_SIZE_CLIENT
  5079. #define WOLFSSL_CAN_MIN_SIZE_CLIENT 3
  5080. #endif
  5081. #ifndef WOLFSSL_CAN_MIN_SIZE_SERVER
  5082. #define WOLFSSL_CAN_MIN_SIZE_SERVER 3
  5083. #endif
  5084. #ifndef WOLFSSL_QTP_MIN_SIZE_CLIENT
  5085. #define WOLFSSL_QTP_MIN_SIZE_CLIENT 0
  5086. #endif
  5087. #ifndef WOLFSSL_QTP_MIN_SIZE_SERVER
  5088. #define WOLFSSL_QTP_MIN_SIZE_SERVER 0
  5089. #endif
  5090. #ifndef WOLFSSL_STK_MIN_SIZE_CLIENT
  5091. #define WOLFSSL_STK_MIN_SIZE_CLIENT 0
  5092. #endif
  5093. #ifndef WOLFSSL_STK_MIN_SIZE_SERVER
  5094. #define WOLFSSL_STK_MIN_SIZE_SERVER 0
  5095. #endif
  5096. #ifdef __cplusplus
  5097. } /* extern "C" */
  5098. #endif
  5099. #endif /* WOLFSSL_SSL_H */