openssl.pas 199 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921
  1. {$IFNDEF FPC_DOTTEDUNITS}
  2. unit openssl;
  3. {$ENDIF FPC_DOTTEDUNITS}
  4. {==============================================================================|
  5. | Project : Ararat Synapse | 003.004.001 |
  6. |==============================================================================|
  7. | Content: SSL support by OpenSSL |
  8. |==============================================================================|
  9. | Copyright (c)1999-2005, Lukas Gebauer |
  10. | All rights reserved. |
  11. | |
  12. | Redistribution and use in source and binary forms, with or without |
  13. | modification, are permitted provided that the following conditions are met: |
  14. | |
  15. | Redistributions of source code must retain the above copyright notice, this |
  16. | list of conditions and the following disclaimer. |
  17. | |
  18. | Redistributions in binary form must reproduce the above copyright notice, |
  19. | this list of conditions and the following disclaimer in the documentation |
  20. | and/or other materials provided with the distribution. |
  21. | |
  22. | Neither the name of Lukas Gebauer nor the names of its contributors may |
  23. | be used to endorse or promote products derived from this software without |
  24. | specific prior written permission. |
  25. | |
  26. | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
  27. | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
  28. | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
  29. | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
  30. | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
  31. | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
  32. | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
  33. | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  34. | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
  35. | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
  36. | DAMAGE. |
  37. |==============================================================================|
  38. | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
  39. | Portions created by Lukas Gebauer are Copyright (c)2002-2005. |
  40. | All Rights Reserved. |
  41. |==============================================================================|
  42. | Contributor(s): |
  43. |==============================================================================|
  44. | FreePascal basic cleanup (original worked too): Ales Katona |
  45. | WARNING: due to reliance on some units, I have removed the ThreadLocks init |
  46. | if need be, it should be re-added, or handled by the |
  47. | OS threading init somehow |
  48. | |
  49. | 2010 - Felipe Monteiro de Carvalho - Added RAND functios |
  50. |==============================================================================|
  51. | 2010-08-24 add fuctions to hash strings based on rsa key PEM format |
  52. | change some type declarationc on x509 type |
  53. | work is not complete. |
  54. | Work made by Alberto Brito based on unit from |
  55. | Marco Ferrante |
  56. | |
  57. | |
  58. | |
  59. |==============================================================================|
  60. | History: see HISTORY.HTM from distribution package |
  61. | (Found at URL: http://www.ararat.cz/synapse/) |
  62. |==============================================================================}
  63. {
  64. Special thanks to Gregor Ibic <[email protected]>
  65. (Intelicom d.o.o., http://www.intelicom.si)
  66. for good inspiration about begin with SSL programming.
  67. }
  68. {$MODE DELPHI}
  69. {$H+}
  70. {$Packrecords C}
  71. {:@abstract(OpenSSL support)
  72. This unit is Pascal interface to OpenSSL library (used by @link(ssl_openssl) unit).
  73. OpenSSL is loaded dynamicly on-demand. If this library is not found in system,
  74. requested OpenSSL function just return errorcode.
  75. }
  76. interface
  77. {$IFDEF FPC_DOTTEDUNITS}
  78. uses
  79. {$IFDEF OS2}
  80. System.Net.Sockets,
  81. {$ENDIF OS2}
  82. System.DynLibs, System.CTypes, System.SysUtils;
  83. {$ELSE FPC_DOTTEDUNITS}
  84. uses
  85. {$IFDEF OS2}
  86. Sockets,
  87. {$ENDIF OS2}
  88. DynLibs, cTypes, SysUtils;
  89. {$ENDIF FPC_DOTTEDUNITS}
  90. Type
  91. TLibreSSLSupport = (lssFirst,lssLast,lssDisabled);
  92. const
  93. // SSL and Crypto DLL arrays must have the same length and contain
  94. // matched pairs of DLL filenames. Place newer versions at the beginning.
  95. {$IF DEFINED(WIN64)}
  96. SSL_DLL_Names: array[1..4] of AnsiString = ('libssl-3-x64', 'libssl-1_1-x64', 'ssleay32', 'libssl32');
  97. Crypto_DLL_Names: array[1..4] of AnsiString = ('libcrypto-3-x64', 'libcrypto-1_1-x64', 'libeay32', 'libeay32');
  98. {$ELSEIF DEFINED(WINDOWS)}
  99. SSL_DLL_Names: array[1..4] of AnsiString = ('libssl-3', 'libssl-1_1', 'ssleay32', 'libssl32');
  100. Crypto_DLL_Names: array[1..4] of AnsiString = ('libcrypto-3', 'libcrypto-1_1', 'libeay32', 'libeay32');
  101. {$ELSEIF DEFINED(OS2GCC)}
  102. SSL_DLL_Names: array[1..2] of AnsiString = ('kssl10', 'kssl');
  103. Crypto_DLL_Names: array[1..2] of AnsiString = ('kcrypt10', 'kcrypto');
  104. {$ELSEIF DEFINED(OS2)}
  105. SSL_DLL_Names: array[1..2] of AnsiString = ('emssl10', 'ssl');
  106. Crypto_DLL_Names: array[1..2] of AnsiString = ('emcrpt10', 'crypto');
  107. {$ELSE}
  108. BaseSSLName: AnsiString = 'libssl';
  109. BaseCryptoName: AnsiString = 'libcrypto';
  110. { ADD NEW ONES WHEN THEY APPEAR!
  111. Always make .so/dylib first, then versions, in descending order!
  112. Add "." .before the version, first is always just "" }
  113. DLLVersions: array[1..20] of AnsiString = ('', '.3', '.1.1', '.11', '.10', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',
  114. '.1.0.2', '.1.0.1','.1.0.0','.0.9.8',
  115. '.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',
  116. '.0.9.3', '.0.9.2', '.0.9.1');
  117. LibreSSLVersions : Array[1..8] of AnsiString =
  118. ('', '.48', '.47', '.46', '.45', '.44', '.43', '.35');
  119. // Mac OS no longer allows you to load the unversioned one. Bug ID 36484.
  120. {$IFDEF DARWIN}
  121. StartVersionOffset = 1;
  122. DefaultLibreSSLSupport = lssFirst;
  123. {$ElSE}
  124. StartVersionOffset = 0;
  125. DefaultLibreSSLSupport = lssLast;
  126. {$ENDIF}
  127. Var
  128. LibreSSLSupport : TLibreSSLSupport = DefaultLibreSSLSupport;
  129. {$ENDIF}
  130. const
  131. // EVP.h Constants
  132. EVP_MAX_MD_SIZE = 64; //* longest known is SHA512 */
  133. EVP_MAX_KEY_LENGTH = 32;
  134. EVP_MAX_IV_LENGTH = 16;
  135. EVP_MAX_BLOCK_LENGTH = 32;
  136. SHA_DIGEST_LENGTH = 20;
  137. type
  138. uint64_t = qword;
  139. SslPtr = Pointer;
  140. PSslPtr = ^SslPtr;
  141. PSSL_CTX = SslPtr;
  142. PSSL = SslPtr;
  143. PSSL_METHOD = SslPtr;
  144. { PX509 = SslPtr;}
  145. { PX509_NAME = SslPtr;}
  146. PEVP_MD = SslPtr;
  147. PBIO_METHOD = SslPtr;
  148. PBIO = SslPtr;
  149. PPBIO = PSslPtr;
  150. { EVP_PKEY = SslPtr;}
  151. PRSA = SslPtr;
  152. PASN1_UTCTIME = SslPtr;
  153. PASN1_INTEGER = SSlPtr;
  154. POPENSSL_INIT_SETTINGS = SSLPtr;
  155. PDH = pointer;
  156. PSTACK_OFX509 = pointer;
  157. X509_NAME = record
  158. entries: pointer;
  159. modified: integer;
  160. bytes: pointer;
  161. hash: cardinal;
  162. end;
  163. PX509_NAME = ^X509_NAME;
  164. PDN = ^X509_NAME;
  165. ASN1_STRING = record
  166. length: integer;
  167. asn1_type: integer;
  168. data: pointer;
  169. flags: longint;
  170. end;
  171. PASN1_STRING = ^ASN1_STRING;
  172. PASN1_TIME = PASN1_STRING;
  173. X509_VAL = record
  174. notBefore: PASN1_TIME;
  175. notAfter: PASN1_TIME;
  176. end;
  177. PX509_VAL = ^X509_VAL;
  178. X509_CINF = record
  179. version: pointer;
  180. serialNumber: pointer;
  181. signature: pointer;
  182. issuer: pointer;
  183. validity: PX509_VAL;
  184. subject: pointer;
  185. key: pointer;
  186. issuerUID: pointer;
  187. subjectUID: pointer;
  188. extensions: pointer;
  189. end;
  190. PX509_CINF = ^X509_CINF;
  191. CRYPTO_EX_DATA = record
  192. sk: pointer;
  193. dummy: integer;
  194. end;
  195. X509 = record
  196. cert_info: PX509_CINF;
  197. sig_alg: pointer; // ^X509_ALGOR
  198. signature: pointer; // ^ASN1_BIT_STRING
  199. valid: integer;
  200. references: integer;
  201. name: PAnsiChar;
  202. ex_data: CRYPTO_EX_DATA;
  203. ex_pathlen: integer;
  204. ex_flags: integer;
  205. ex_kusage: integer;
  206. ex_xkusage: integer;
  207. ex_nscert: integer;
  208. skid: pointer; // ^ASN1_OCTET_STRING
  209. akid: pointer; // ?
  210. sha1_hash: array [0..SHA_DIGEST_LENGTH-1] of AnsiChar;
  211. aux: pointer; // ^X509_CERT_AUX
  212. end;
  213. pX509 = ^X509;
  214. PPX509 = ^PX509;
  215. DSA = record
  216. pad: integer;
  217. version: integer;
  218. write_params: integer;
  219. p: pointer;
  220. q: pointer;
  221. g: pointer;
  222. pub_key: pointer;
  223. priv_key: pointer;
  224. kinv: pointer;
  225. r: pointer;
  226. flags: integer;
  227. method_mont_p: PAnsiChar;
  228. references: integer;
  229. ex_data: record
  230. sk: pointer;
  231. dummy: integer;
  232. end;
  233. meth: pointer;
  234. end;
  235. pDSA = ^DSA;
  236. EVP_PKEY_PKEY = record
  237. case integer of
  238. 0: (ptr: PAnsiChar);
  239. 1: (rsa: pRSA);
  240. 2: (dsa: pDSA);
  241. 3: (dh: pDH);
  242. end;
  243. EVP_PKEY = record
  244. ktype: integer;
  245. save_type: integer;
  246. references: integer;
  247. pkey: EVP_PKEY_PKEY;
  248. save_parameters: integer;
  249. attributes: PSTACK_OFX509;
  250. end;
  251. PEVP_PKEY = ^EVP_PKEY;
  252. PPEVP_PKEY = ^PEVP_PKEY;
  253. PPRSA = ^PRSA;
  254. PASN1_cInt = SslPtr;
  255. PPasswdCb = SslPtr;
  256. PCallbackCb = SslPtr;
  257. PX509_STORE_CTX = SslPtr;
  258. TSSLCTXVerifyCallback = function (ok : cInt; ctx : PX509_STORE_CTX) : Cint; cdecl;
  259. PFunction = procedure;
  260. DES_cblock = array[0..7] of Byte;
  261. PDES_cblock = ^DES_cblock;
  262. des_ks_struct = packed record
  263. ks: DES_cblock;
  264. weak_key: cInt;
  265. end;
  266. des_key_schedule = array[1..16] of des_ks_struct;
  267. MD2_CTX = record
  268. num: integer;
  269. data: array [0..15] of byte;
  270. cksm: array [0..15] of cardinal;
  271. state: array [0..15] of cardinal;
  272. end;
  273. MD4_CTX = record
  274. A, B, C, D: cardinal;
  275. Nl, Nh: cardinal;
  276. data: array [0..15] of cardinal;
  277. num: integer;
  278. end;
  279. MD5_CTX = record
  280. A, B, C, D: cardinal;
  281. Nl, Nh: cardinal;
  282. data: array [0..15] of cardinal;
  283. num: integer;
  284. end;
  285. RIPEMD160_CTX = record
  286. A, B, C, D, E: cardinal;
  287. Nl, Nh: cardinal;
  288. data: array [0..15] of cardinal;
  289. num: integer;
  290. end;
  291. SHA_CTX = record
  292. h0, h1, h2, h3, h4: cardinal;
  293. Nl, Nh: cardinal;
  294. data: array [0..16] of cardinal;
  295. num: integer;
  296. end;
  297. MDC2_CTX = record
  298. num: integer;
  299. data: array [0..7] of byte;
  300. h, hh: des_cblock;
  301. pad_type: integer;
  302. end;
  303. // Rand
  304. RAND_METHOD = record
  305. end;
  306. PRAND_METHOD = ^RAND_METHOD;
  307. // RSA
  308. PENGINE = Pointer;
  309. PBIGNUM = Pointer;
  310. PBN_GENCB = Pointer;
  311. PBN_MONT_CTX = Pointer;
  312. PBN_CTX = Pointer;
  313. PPByte = ^PByte;
  314. Trsa_pub_enc = function(flen: cint;
  315. const from_, to_: PByte; arsa: PRSA; padding: cint): cint;
  316. Trsa_pub_dec = function(flen: cint;
  317. const from_, to_: PByte; arsa: PRSA; padding: cint): cint;
  318. Trsa_priv_enc = function(flen: cint;
  319. const from_, to_: PByte; arsa: PRSA; padding: cint): cint;
  320. Trsa_priv_dec = function(flen: cint;
  321. const from_, to_: PByte; arsa: PRSA; padding: cint): cint;
  322. Trsa_mod_exp = function(r0: PBIGNUM; const l: PBIGNUM; arsa: PRSA; ctx: PBN_CTX): cint;
  323. Tbn_mod_exp = function(r: PBIGNUM; const a, p, m: PBIGNUM; arsa: PRSA;
  324. ctx: PBN_CTX; m_ctx: PBN_MONT_CTX): cint;
  325. Tinit = function(arsa: PRSA): cint;
  326. Tfinish = function(arsa: PRSA): cint;
  327. Trsa_sign = function(type_: cint; const m: PByte; m_length: cuint;
  328. sigret: PByte; siglen: pcuint; arsa: PRSA): cint;
  329. Trsa_verify = function(dtype: cint;
  330. const m: PByte; m_length: cuint;
  331. const sigbuf: PByte; siglen: cuint; arsa: PRSA): cint;
  332. Trsa_keygen = function(arsa: PRSA; bits: cint; e: PBIGNUM; cb: PBN_GENCB): cint;
  333. RSA_METHOD = record
  334. name: PAnsiChar;
  335. rsa_pub_enc: Trsa_pub_enc;
  336. rsa_pub_dec: Trsa_pub_dec;
  337. rsa_priv_enc: Trsa_priv_enc;
  338. rsa_priv_dec: Trsa_priv_dec;
  339. rsa_mod_exp: Trsa_mod_exp; { Can be null }
  340. bn_mod_exp: Tbn_mod_exp; { Can be null }
  341. init: Tinit; { called at new }
  342. finish: Tfinish; { called at free }
  343. flags: cint; { RSA_METHOD_FLAG_* things }
  344. app_data: PAnsiChar; { may be needed! }
  345. { New sign and verify functions: some libraries don't allow arbitrary data
  346. * to be signed/verified: this allows them to be used. Note: for this to work
  347. * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
  348. * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
  349. * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
  350. * option is set in 'flags'.
  351. }
  352. rsa_sign: Trsa_sign;
  353. rsa_verify: Trsa_verify;
  354. { If this callback is NULL, the builtin software RSA key-gen will be used. This
  355. * is for behavioural compatibility whilst the code gets rewired, but one day
  356. * it would be nice to assume there are no such things as "builtin software"
  357. * implementations. }
  358. rsa_keygen: Trsa_keygen;
  359. end;
  360. PRSA_METHOD = ^RSA_METHOD;
  361. // EVP
  362. EVP_MD_CTX = record
  363. digest: pEVP_MD;
  364. case integer of
  365. 0: (base: array [0..3] of byte);
  366. 1: (md2: MD2_CTX);
  367. 8: (md4: MD4_CTX);
  368. 2: (md5: MD5_CTX);
  369. 16: (ripemd160: RIPEMD160_CTX);
  370. 4: (sha: SHA_CTX);
  371. 32: (mdc2: MDC2_CTX);
  372. end;
  373. PEVP_MD_CTX = ^EVP_MD_CTX;
  374. EVP_PKEY_CTX = record
  375. end;
  376. PEVP_PKEY_CTX = ^EVP_PKEY_CTX;
  377. PPEVP_PKEY_CTX = ^PEVP_PKEY_CTX;
  378. PEVP_CIPHER_CTX = ^EVP_CIPHER_CTX;
  379. PASN1_TYPE = Pointer;
  380. EVP_CIPHER_INIT_FUNC = function(ctx: PEVP_CIPHER_CTX; const key, iv: PByte; enc: cint): cint; cdecl;
  381. EVP_CIPHER_DO_CIPHER_FUNC = function(ctx: PEVP_CIPHER_CTX; out_data: PByte; const in_data: PByte; inl: csize_t): cint; cdecl;
  382. EVP_CIPHER_CLEANUP_FUNC = function(ctx: PEVP_CIPHER_CTX): cint; cdecl;
  383. EVP_CIPHER_SET_ASN1_PARAMETERS_FUNC = function(ctx: PEVP_CIPHER_CTX; asn1_type: PASN1_TYPE): cint; cdecl;
  384. EVP_CIPHER_GET_ASN1_PARAMETERS_FUNC = function(ctx: PEVP_CIPHER_CTX; asn1_type: PASN1_TYPE): cint; cdecl;
  385. EVP_CIPHER_CTRL_FUNC = function(ctx: PEVP_CIPHER_CTX; type_, arg: cint; ptr: Pointer): cint; cdecl;
  386. EVP_CIPHER = record // Updated with EVP.h from OpenSSL 1.0.0
  387. nid: cint;
  388. block_size: cint;
  389. key_len: cint; //* Default value for variable length ciphers */
  390. iv_len: cint;
  391. flags: culong; //* Various flags */
  392. init: EVP_CIPHER_INIT_FUNC; //* init key */
  393. do_cipher: EVP_CIPHER_DO_CIPHER_FUNC;//* encrypt/decrypt data */
  394. cleanup: EVP_CIPHER_CLEANUP_FUNC; //* cleanup ctx */
  395. ctx_size: cint; //* how big ctx->cipher_data needs to be */
  396. set_asn1_parameters: EVP_CIPHER_SET_ASN1_PARAMETERS_FUNC; //* Populate a ASN1_TYPE with parameters */
  397. get_asn1_parameters: EVP_CIPHER_GET_ASN1_PARAMETERS_FUNC; //* Get parameters from a ASN1_TYPE */
  398. ctrl: EVP_CIPHER_CTRL_FUNC; //* Miscellaneous operations */
  399. app_data: Pointer; //* Application data */
  400. end;
  401. PEVP_CIPHER = ^EVP_CIPHER;
  402. EVP_CIPHER_CTX = record // Updated with EVP.h from OpenSSL 1.0.0
  403. cipher: PEVP_CIPHER;
  404. engine: PENGINE; //* functional reference if 'cipher' is ENGINE-provided */
  405. encrypt: cint; //* encrypt or decrypt */
  406. buf_len: cint; //* number we have left */
  407. oiv: array[0..EVP_MAX_IV_LENGTH-1] of Byte; //* original iv */
  408. iv: array[0..EVP_MAX_IV_LENGTH-1] of Byte; //* working iv */
  409. buf: array[0..EVP_MAX_IV_LENGTH-1] of Byte; //* saved partial block */
  410. num: cint; //* used by cfb/ofb mode */
  411. app_data: Pointer; //* application stuff */
  412. key_len: cint; //* May change for variable length cipher */
  413. flags: culong; //* Various flags */
  414. cipher_data: Pointer; //* per EVP data */
  415. final_used: cint;
  416. block_mask: cint;
  417. final: array[0..EVP_MAX_BLOCK_LENGTH-1] of Byte; //* possible final block */
  418. final2: array[0..$1FFF] of Byte; // Extra storage space, otherwise an access violation
  419. // in the OpenSSL library will occur
  420. end;
  421. // PEM
  422. Ppem_password_cb = Pointer;
  423. // PKCS7
  424. PPKCS7 = ^PKCS7;
  425. PPKCS7_DIGEST = ^PKCS7_DIGEST;
  426. PPKCS7_ENC_CONTENT = ^PKCS7_ENC_CONTENT;
  427. PPKCS7_ENCRYPT = ^TPKCS7_ENCRYPT;
  428. PPKCS7_ENVELOPE = ^PKCS7_ENVELOPE;
  429. PPKCS7_ISSUER_AND_SERIAL = ^PKCS7_ISSUER_AND_SERIAL;
  430. PPKCS7_RECIP_INFO = ^PKCS7_RECIP_INFO;
  431. PPKCS7_SIGN_ENVELOPE = ^PKCS7_SIGN_ENVELOPE;
  432. PPKCS7_SIGNED = ^PKCS7_SIGNED;
  433. PPKCS7_SIGNER_INFO = ^PKCS7_SIGNER_INFO;
  434. Pstack_st_X509 = Pointer;
  435. Pstack_st_X509_ALGOR = Pointer;
  436. Pstack_st_X509_ATTRIBUTE = Pointer;
  437. ppkcs7_st = ^pkcs7_st;
  438. pkcs7_issuer_and_serial_st = record
  439. issuer : ^X509_NAME;
  440. serial : PASN1_INTEGER;
  441. end;
  442. PKCS7_ISSUER_AND_SERIAL = pkcs7_issuer_and_serial_st;
  443. pkcs7_signer_info_st = record
  444. version : PASN1_INTEGER;
  445. issuer_and_serial : PPKCS7_ISSUER_AND_SERIAL;
  446. digest_alg : pointer;
  447. auth_attr : pointer;
  448. digest_enc_alg : pointer;
  449. enc_digest : pointer;
  450. unauth_attr : pointer;
  451. pkey : ^EVP_PKEY;
  452. end;
  453. PKCS7_SIGNER_INFO = pkcs7_signer_info_st;
  454. stack_st_PKCS7_SIGNER_INFO = record
  455. stack : Pointer;
  456. end;
  457. pkcs7_recip_info_st = record
  458. version : PASN1_INTEGER;
  459. issuer_and_serial : PPKCS7_ISSUER_AND_SERIAL;
  460. key_enc_algor : Pointer;
  461. enc_key : Pointer;
  462. cert : PX509;
  463. end;
  464. PKCS7_RECIP_INFO = pkcs7_recip_info_st;
  465. stack_st_PKCS7_RECIP_INFO = record
  466. stack : Pointer;
  467. end;
  468. pkcs7_signed_st = record
  469. version : PASN1_INTEGER;
  470. md_algs : Pointer;
  471. cert : pointer;
  472. crl : pointer;
  473. signer_info : pointer;
  474. contents : Pointer;
  475. end;
  476. PKCS7_SIGNED = pkcs7_signed_st;
  477. (* Const before type ignored *)
  478. pkcs7_enc_content_st = record
  479. content_type : Pointer;
  480. algorithm : Pointer;
  481. enc_data : Pointer;
  482. cipher : PEVP_CIPHER;
  483. end;
  484. PKCS7_ENC_CONTENT = pkcs7_enc_content_st;
  485. pkcs7_enveloped_st = record
  486. version : PASN1_INTEGER;
  487. recipientinfo : ^stack_st_PKCS7_RECIP_INFO;
  488. enc_data : ^PKCS7_ENC_CONTENT;
  489. end;
  490. PKCS7_ENVELOPE = pkcs7_enveloped_st;
  491. pkcs7_signedandenveloped_st = record
  492. version : PASN1_INTEGER;
  493. md_algs : Pstack_st_X509_ALGOR;
  494. cert : Pstack_st_X509;
  495. crl : Pointer;
  496. signer_info : pointer;
  497. enc_data : PPKCS7_ENC_CONTENT;
  498. recipientinfo : ^stack_st_PKCS7_RECIP_INFO;
  499. end;
  500. PKCS7_SIGN_ENVELOPE = pkcs7_signedandenveloped_st;
  501. pkcs7_digest_st = record
  502. version : PASN1_INTEGER;
  503. md : POinter;
  504. contents : ppkcs7_st;
  505. digest : Pointer;
  506. end;
  507. PKCS7_DIGEST = pkcs7_digest_st;
  508. pkcs7_encrypted_st = record
  509. version : PASN1_INTEGER;
  510. enc_data : ^PKCS7_ENC_CONTENT;
  511. end;
  512. TPKCS7_ENCRYPT = pkcs7_encrypted_st;
  513. pkcs7_st = record
  514. asn1 : ^byte;
  515. length : longint;
  516. state : longint;
  517. detached : longint;
  518. _type : Pointer;
  519. d : record
  520. case longint of
  521. 0 : ( ptr : PAnsiChar );
  522. 1 : ( data : Pointer);
  523. 2 : ( sign : PPKCS7_SIGNED );
  524. 3 : ( enveloped : ^PKCS7_ENVELOPE );
  525. 4 : ( signed_and_enveloped : ^PKCS7_SIGN_ENVELOPE );
  526. 5 : ( digest : ^PKCS7_DIGEST );
  527. 6 : ( encrypted : ^TPKCS7_ENCRYPT );
  528. 7 : ( other : PASN1_TYPE );
  529. end;
  530. end;
  531. pkcs7 = pkcs7_st;
  532. stack_st_PKCS7 = record
  533. stack : Pointer;
  534. end;
  535. PPPKCS7_ISSUER_AND_SERIAL = ^PPKCS7_ISSUER_AND_SERIAL;
  536. const
  537. SSL_ERROR_NONE = 0;
  538. SSL_ERROR_SSL = 1;
  539. SSL_ERROR_WANT_READ = 2;
  540. SSL_ERROR_WANT_WRITE = 3;
  541. SSL_ERROR_WANT_X509_LOOKUP = 4;
  542. SSL_ERROR_SYSCALL = 5; //look at error stack/return value/errno
  543. SSL_ERROR_ZERO_RETURN = 6;
  544. SSL_ERROR_WANT_CONNECT = 7;
  545. SSL_ERROR_WANT_ACCEPT = 8;
  546. SSL_ERROR_WANT_CHANNEL_ID_LOOKUP = 9;
  547. SSL_ERROR_PENDING_SESSION = 11;
  548. OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS = $00000001;
  549. OPENSSL_INIT_LOAD_CRYPTO_STRINGS = $00000002;
  550. OPENSSL_INIT_ADD_ALL_CIPHERS = $00000004;
  551. OPENSSL_INIT_ADD_ALL_DIGESTS = $00000008;
  552. OPENSSL_INIT_NO_ADD_ALL_CIPHERS = $00000010;
  553. OPENSSL_INIT_NO_ADD_ALL_DIGESTS = $00000020;
  554. OPENSSL_INIT_LOAD_CONFIG = $00000040;
  555. OPENSSL_INIT_NO_LOAD_CONFIG = $00000080;
  556. OPENSSL_INIT_ASYNC = $00000100;
  557. OPENSSL_INIT_ENGINE_RDRAND = $00000200;
  558. OPENSSL_INIT_ENGINE_DYNAMIC = $00000400;
  559. OPENSSL_INIT_ENGINE_OPENSSL = $00000800;
  560. OPENSSL_INIT_ENGINE_CRYPTODEV = $00001000;
  561. OPENSSL_INIT_ENGINE_CAPI = $00002000;
  562. OPENSSL_INIT_ENGINE_PADLOCK = $00004000;
  563. OPENSSL_INIT_ENGINE_AFALG = $00008000;
  564. OPENSSL_INIT_ATFORK = $00020000;
  565. OPENSSL_INIT_NO_LOAD_SSL_STRINGS = $00100000;
  566. OPENSSL_INIT_LOAD_SSL_STRINGS = $00200000;
  567. OPENSSL_INIT_SSL_DEFAULT = (OPENSSL_INIT_LOAD_SSL_STRINGS or OPENSSL_INIT_LOAD_CRYPTO_STRINGS);
  568. OPENSSL_INIT_ENGINE_ALL_BUILTIN =
  569. OPENSSL_INIT_ENGINE_RDRAND or
  570. OPENSSL_INIT_ENGINE_DYNAMIC or
  571. OPENSSL_INIT_ENGINE_CRYPTODEV or
  572. OPENSSL_INIT_ENGINE_CAPI or
  573. OPENSSL_INIT_ENGINE_PADLOCK;
  574. SSL_CTRL_NEED_TMP_RSA = 1;
  575. SSL_CTRL_SET_TMP_RSA = 2;
  576. SSL_CTRL_SET_TMP_DH = 3;
  577. SSL_CTRL_SET_TMP_ECDH = 4;
  578. SSL_CTRL_SET_TMP_RSA_CB = 5;
  579. SSL_CTRL_SET_TMP_DH_CB = 6;
  580. SSL_CTRL_SET_TMP_ECDH_CB = 7;
  581. SSL_CTRL_GET_SESSION_REUSED = 8;
  582. SSL_CTRL_GET_CLIENT_CERT_REQUEST = 9;
  583. SSL_CTRL_GET_NUM_RENEGOTIATIONS = 10;
  584. SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS = 11;
  585. SSL_CTRL_GET_TOTAL_RENEGOTIATIONS = 12;
  586. SSL_CTRL_GET_FLAGS = 13;
  587. SSL_CTRL_EXTRA_CHAIN_CERT = 14;
  588. SSL_CTRL_SET_MSG_CALLBACK = 15;
  589. SSL_CTRL_SET_MSG_CALLBACK_ARG = 16;
  590. SSL_CTRL_SET_MTU = 17;
  591. SSL_CTRL_SESS_NUMBER = 20;
  592. SSL_CTRL_SESS_CONNECT = 21;
  593. SSL_CTRL_SESS_CONNECT_GOOD = 22;
  594. SSL_CTRL_SESS_CONNECT_RENEGOTIATE = 23;
  595. SSL_CTRL_SESS_ACCEPT = 24;
  596. SSL_CTRL_SESS_ACCEPT_GOOD = 25;
  597. SSL_CTRL_SESS_ACCEPT_RENEGOTIATE = 26;
  598. SSL_CTRL_SESS_HIT = 27;
  599. SSL_CTRL_SESS_CB_HIT = 28;
  600. SSL_CTRL_SESS_MISSES = 29;
  601. SSL_CTRL_SESS_TIMEOUTS = 30;
  602. SSL_CTRL_SESS_CACHE_FULL = 31;
  603. SSL_CTRL_OPTIONS = 32;
  604. SSL_CTRL_MODE = 33;
  605. SSL_CTRL_GET_READ_AHEAD = 40;
  606. SSL_CTRL_SET_READ_AHEAD = 41;
  607. SSL_CTRL_SET_SESS_CACHE_SIZE = 42;
  608. SSL_CTRL_GET_SESS_CACHE_SIZE = 43;
  609. SSL_CTRL_SET_SESS_CACHE_MODE = 44;
  610. SSL_CTRL_GET_SESS_CACHE_MODE = 45;
  611. SSL_CTRL_GET_MAX_CERT_LIST = 50;
  612. SSL_CTRL_SET_MAX_CERT_LIST = 51;
  613. SSL_CTRL_SET_MAX_SEND_FRAGMENT = 52;
  614. SSL_CTRL_SET_TLSEXT_SERVERNAME_CB = 53;
  615. SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG = 54;
  616. SSL_CTRL_SET_TLSEXT_HOSTNAME = 55;
  617. SSL_CTRL_SET_TLSEXT_DEBUG_CB = 56;
  618. SSL_CTRL_SET_TLSEXT_DEBUG_ARG = 57;
  619. SSL_CTRL_GET_TLSEXT_TICKET_KEYS = 58;
  620. SSL_CTRL_SET_TLSEXT_TICKET_KEYS = 59;
  621. SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT = 60;
  622. SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB = 61;
  623. SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG = 62;
  624. SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB = 63;
  625. SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG = 64;
  626. SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE = 65;
  627. SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS = 66;
  628. SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS = 67;
  629. SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS = 68;
  630. SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS = 69;
  631. SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP = 70;
  632. SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP = 71;
  633. SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB = 72;
  634. SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB = 75;
  635. SSL_CTRL_SET_SRP_VERIFY_PARAM_CB = 76;
  636. SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB = 77;
  637. SSL_CTRL_SET_SRP_ARG = 78;
  638. SSL_CTRL_SET_TLS_EXT_SRP_USERNAME = 79;
  639. SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH = 80;
  640. SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD = 81;
  641. SSL_CTRL_GET_EXTRA_CHAIN_CERTS = 82;
  642. SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS = 83;
  643. SSL_CTRL_TLS_EXT_SEND_HEARTBEAT = 85;
  644. SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING = 86;
  645. SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS = 87;
  646. SSL_CTRL_CHAIN = 88;
  647. SSL_CTRL_CHAIN_CERT = 89;
  648. SSL_CTRL_GET_CURVES = 90;
  649. SSL_CTRL_SET_CURVES = 91;
  650. SSL_CTRL_SET_CURVES_LIST = 92;
  651. SSL_CTRL_GET_SHARED_CURVE = 93;
  652. SSL_CTRL_SET_ECDH_AUTO = 94;
  653. SSL_CTRL_SET_SIGALGS = 97;
  654. SSL_CTRL_SET_SIGALGS_LIST = 98;
  655. SSL_CTRL_CERT_FLAGS = 99;
  656. SSL_CTRL_CLEAR_CERT_FLAGS = 100;
  657. SSL_CTRL_SET_CLIENT_SIGALGS = 101;
  658. SSL_CTRL_SET_CLIENT_SIGALGS_LIST = 102;
  659. SSL_CTRL_GET_CLIENT_CERT_TYPES = 103;
  660. SSL_CTRL_SET_CLIENT_CERT_TYPES = 104;
  661. SSL_CTRL_BUILD_CERT_CHAIN = 105;
  662. SSL_CTRL_SET_VERIFY_CERT_STORE = 106;
  663. SSL_CTRL_SET_CHAIN_CERT_STORE = 107;
  664. SSL_CTRL_GET_PEER_SIGNATURE_NID = 108;
  665. SSL_CTRL_GET_SERVER_TMP_KEY = 109;
  666. SSL_CTRL_GET_RAW_CIPHERLIST = 110;
  667. SSL_CTRL_GET_EC_POINT_FORMATS = 111;
  668. SSL_CTRL_GET_TLSA_RECORD = 112;
  669. SSL_CTRL_SET_TLSA_RECORD = 113;
  670. SSL_CTRL_PULL_TLSA_RECORD = 114;
  671. SSL_CTRL_GET_CHAIN_CERTS = 115;
  672. SSL_CTRL_SELECT_CURRENT_CERT = 116;
  673. SSL_CTRL_CHANNEL_ID = 117;
  674. SSL_CTRL_GET_CHANNEL_ID = 118;
  675. SSL_CTRL_SET_CHANNEL_ID = 119;
  676. DTLS_CTRL_GET_TIMEOUT = 73;
  677. DTLS_CTRL_HANDLE_TIMEOUT = 74;
  678. DTLS_CTRL_LISTEN = 75;
  679. SSL_CTRL_GET_RI_SUPPORT = 76;
  680. SSL_CTRL_CLEAR_OPTIONS = 77;
  681. SSL_CTRL_CLEAR_MODE = 78;
  682. TLSEXT_TYPE_server_name = 0;
  683. TLSEXT_TYPE_max_fragment_length = 1;
  684. TLSEXT_TYPE_client_certificate_url = 2;
  685. TLSEXT_TYPE_trusted_ca_keys = 3;
  686. TLSEXT_TYPE_truncated_hmac = 4;
  687. TLSEXT_TYPE_status_request = 5;
  688. TLSEXT_TYPE_user_mapping = 6;
  689. TLSEXT_TYPE_client_authz = 7;
  690. TLSEXT_TYPE_server_authz = 8;
  691. TLSEXT_TYPE_cert_type = 9;
  692. TLSEXT_TYPE_elliptic_curves = 10;
  693. TLSEXT_TYPE_ec_point_formats = 11;
  694. TLSEXT_TYPE_srp = 12;
  695. TLSEXT_TYPE_signature_algorithms = 13;
  696. TLSEXT_TYPE_use_srtp = 14;
  697. TLSEXT_TYPE_heartbeat = 15;
  698. TLSEXT_TYPE_session_ticket = 35;
  699. TLSEXT_TYPE_renegotiate = $ff01;
  700. TLSEXT_TYPE_next_proto_neg = 13172;
  701. TLSEXT_NAMETYPE_host_name = 0;
  702. TLSEXT_STATUSTYPE_ocsp = 1;
  703. TLSEXT_ECPOINTFORMAT_first = 0;
  704. TLSEXT_ECPOINTFORMAT_uncompressed = 0;
  705. TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime = 1;
  706. TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 = 2;
  707. TLSEXT_ECPOINTFORMAT_last = 2;
  708. TLSEXT_signature_anonymous = 0;
  709. TLSEXT_signature_rsa = 1;
  710. TLSEXT_signature_dsa = 2;
  711. TLSEXT_signature_ecdsa = 3;
  712. TLSEXT_hash_none = 0;
  713. TLSEXT_hash_md5 = 1;
  714. TLSEXT_hash_sha1 = 2;
  715. TLSEXT_hash_sha224 = 3;
  716. TLSEXT_hash_sha256 = 4;
  717. TLSEXT_hash_sha384 = 5;
  718. TLSEXT_hash_sha512 = 6;
  719. TLSEXT_MAXLEN_host_name = 255;
  720. SSL_TLSEXT_ERR_OK = 0;
  721. SSL_TLSEXT_ERR_ALERT_WARNING = 1;
  722. SSL_TLSEXT_ERR_ALERT_FATAL = 2;
  723. SSL_TLSEXT_ERR_NOACK = 3;
  724. SSL_MODE_ENABLE_PARTIAL_WRITE = $00000001;
  725. SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = $00000002;
  726. SSL_MODE_AUTO_RETRY = $00000004;
  727. SSL_MODE_NO_AUTO_CHAIN = $00000008;
  728. SSL_MODE_RELEASE_BUFFERS = $00000010;
  729. SSL_OP_MICROSOFT_SESS_ID_BUG = $00000001;
  730. SSL_OP_NETSCAPE_CHALLENGE_BUG = $00000002;
  731. SSL_OP_LEGACY_SERVER_CONNECT = $00000004;
  732. SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = $00000008;
  733. SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG = $00000010;
  734. SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = $00000020;
  735. SSL_OP_MSIE_SSLV2_RSA_PADDING = $00000040;
  736. SSL_OP_SAFARI_ECDHE_ECDSA_BUG = $00000040;
  737. SSL_OP_SSLEAY_080_CLIENT_DH_BUG = $00000080;
  738. SSL_OP_TLS_D5_BUG = $00000100;
  739. SSL_OP_TLS_BLOCK_PADDING_BUG = $00000200;
  740. SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = $00000800;
  741. SSL_OP_NO_QUERY_MTU = $00001000;
  742. SSL_OP_COOKIE_EXCHANGE = $00002000;
  743. SSL_OP_NO_TICKET = $00004000;
  744. SSL_OP_CISCO_ANYCONNECT = $00008000;
  745. SSL_OP_ALL = $000FFFFF;
  746. SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = $00010000;
  747. SSL_OP_NO_COMPRESSION = $00020000;
  748. SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION = $00040000;
  749. SSL_OP_SINGLE_ECDH_USE = $00080000;
  750. SSL_OP_SINGLE_DH_USE = $00100000;
  751. SSL_OP_EPHEMERAL_RSA = $00200000;
  752. SSL_OP_CIPHER_SERVER_PREFERENCE = $00400000;
  753. SSL_OP_TLS_ROLLBACK_BUG = $00800000;
  754. SSL_OP_NO_SSLv2 = $01000000;
  755. SSL_OP_NO_SSLv3 = $02000000;
  756. SSL_OP_NO_TLSv1 = $04000000;
  757. SSL_OP_NO_TLSv1_2 = $08000000;
  758. SSL_OP_NO_TLSv1_1 = $10000000;
  759. SSL_OP_NETSCAPE_CA_DN_BUG = $20000000;
  760. SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = $40000000;
  761. SSL_OP_CRYPTOPRO_TLSEXT_BUG = $80000000;
  762. SSL_VERIFY_NONE = $00;
  763. SSL_VERIFY_PEER = $01;
  764. SSL_CERT_FLAG_TLS_STRICT = $00000001;
  765. // Used in SSL_set_shutdown()/SSL_get_shutdown();
  766. SSL_SENT_SHUTDOWN = 1;
  767. SSL_RECEIVED_SHUTDOWN = 2;
  768. OPENSSL_DES_DECRYPT = 0;
  769. OPENSSL_DES_ENCRYPT = 1;
  770. X509_V_OK = 0;
  771. X509_V_ILLEGAL = 1;
  772. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2;
  773. X509_V_ERR_UNABLE_TO_GET_CRL = 3;
  774. X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4;
  775. X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5;
  776. X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6;
  777. X509_V_ERR_CERT_SIGNATURE_FAILURE = 7;
  778. X509_V_ERR_CRL_SIGNATURE_FAILURE = 8;
  779. X509_V_ERR_CERT_NOT_YET_VALID = 9;
  780. X509_V_ERR_CERT_HAS_EXPIRED = 10;
  781. X509_V_ERR_CRL_NOT_YET_VALID = 11;
  782. X509_V_ERR_CRL_HAS_EXPIRED = 12;
  783. X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13;
  784. X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14;
  785. X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15;
  786. X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16;
  787. X509_V_ERR_OUT_OF_MEM = 17;
  788. X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18;
  789. X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19;
  790. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20;
  791. X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21;
  792. X509_V_ERR_CERT_CHAIN_TOO_LONG = 22;
  793. X509_V_ERR_CERT_REVOKED = 23;
  794. X509_V_ERR_INVALID_CA = 24;
  795. X509_V_ERR_PATH_LENGTH_EXCEEDED = 25;
  796. X509_V_ERR_INVALID_PURPOSE = 26;
  797. X509_V_ERR_CERT_UNTRUSTED = 27;
  798. X509_V_ERR_CERT_REJECTED = 28;
  799. //These are 'informational' when looking for issuer cert
  800. X509_V_ERR_SUBJECT_ISSUER_MISMATCH = 29;
  801. X509_V_ERR_AKID_SKID_MISMATCH = 30;
  802. X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = 31;
  803. X509_V_ERR_KEYUSAGE_NO_CERTSIGN = 32;
  804. X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER = 33;
  805. X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION = 34;
  806. //The application is not happy
  807. X509_V_ERR_APPLICATION_VERIFICATION = 50;
  808. SSL_FILETYPE_ASN1 = 2;
  809. SSL_FILETYPE_PEM = 1;
  810. EVP_PKEY_RSA = 6;
  811. // RSA
  812. RSA_PKCS1_PADDING = 1;
  813. RSA_SSLV23_PADDING = 2;
  814. RSA_NO_PADDING = 3;
  815. RSA_PKCS1_OAEP_PADDING = 4;
  816. // ASN1 values
  817. V_ASN1_EOC = 0;
  818. V_ASN1_BOOLEAN = 1;
  819. V_ASN1_INTEGER = 2;
  820. V_ASN1_BIT_STRING = 3;
  821. V_ASN1_OCTET_STRING = 4;
  822. V_ASN1_NULL = 5;
  823. V_ASN1_OBJECT = 6;
  824. V_ASN1_OBJECT_DESCRIPTOR = 7;
  825. V_ASN1_EXTERNAL = 8;
  826. V_ASN1_REAL = 9;
  827. V_ASN1_ENUMERATED = 10;
  828. V_ASN1_UTF8STRING = 12;
  829. V_ASN1_SEQUENCE = 16;
  830. V_ASN1_SET = 17;
  831. V_ASN1_NUMERICSTRING = 18;
  832. V_ASN1_PRINTABLESTRING = 19;
  833. V_ASN1_T61STRING = 20;
  834. V_ASN1_TELETEXSTRING = 20;
  835. V_ASN1_VIDEOTEXSTRING = 21;
  836. V_ASN1_IA5STRING = 22;
  837. V_ASN1_UTCTIME = 23;
  838. V_ASN1_GENERALIZEDTIME = 24;
  839. V_ASN1_GRAPHICSTRING = 25;
  840. V_ASN1_ISO64STRING = 26;
  841. V_ASN1_VISIBLESTRING = 26;
  842. V_ASN1_GENERALSTRING = 27;
  843. V_ASN1_UNIVERSALSTRING = 28;
  844. V_ASN1_BMPSTRING = 30;
  845. // BN
  846. {$ifdef cpu64}
  847. // * 64-bit processor with LP64 ABI
  848. type
  849. BN_ULONG = culong;
  850. const
  851. BN_BYTES = 8;
  852. {$else}
  853. {$ifdef SIXTY_FOUR_BIT}
  854. // * 64-bit processor other than LP64 ABI
  855. type
  856. BN_ULONG = culonglong;
  857. const
  858. BN_BYTES = 8;
  859. {$else}
  860. type
  861. BN_ULONG = cuint;
  862. const
  863. BN_BYTES = 4;
  864. {$endif}
  865. {$endif}
  866. // BIO
  867. BIO_NOCLOSE = $00;
  868. BIO_CLOSE = $01;
  869. //* modifiers */
  870. BIO_FP_READ = $02;
  871. BIO_FP_WRITE = $04;
  872. BIO_FP_APPEND = $08;
  873. BIO_FP_TEXT = $10;
  874. BIO_C_SET_CONNECT = 100;
  875. BIO_C_DO_STATE_MACHINE = 101;
  876. BIO_C_SET_NBIO = 102;
  877. BIO_C_SET_PROXY_PARAM = 103;
  878. BIO_C_SET_FD = 104;
  879. BIO_C_GET_FD = 105;
  880. BIO_C_SET_FILE_PTR = 106;
  881. BIO_C_GET_FILE_PTR = 107;
  882. BIO_C_SET_FILENAME = 108;
  883. BIO_C_SET_SSL = 109;
  884. BIO_C_GET_SSL = 110;
  885. BIO_C_SET_MD = 111;
  886. BIO_C_GET_MD = 112;
  887. BIO_C_GET_CIPHER_STATUS = 113;
  888. BIO_C_SET_BUF_MEM = 114;
  889. BIO_C_GET_BUF_MEM_PTR = 115;
  890. BIO_C_GET_BUFF_NUM_LINES = 116;
  891. BIO_C_SET_BUFF_SIZE = 117;
  892. BIO_C_SET_ACCEPT = 118;
  893. BIO_C_SSL_MODE = 119;
  894. BIO_C_GET_MD_CTX = 120;
  895. BIO_C_GET_PROXY_PARAM = 121;
  896. BIO_C_SET_BUFF_READ_DATA = 122; // data to read first */
  897. BIO_C_GET_CONNECT = 123;
  898. BIO_C_GET_ACCEPT = 124;
  899. BIO_C_SET_SSL_RENEGOTIATE_BYTES = 125;
  900. BIO_C_GET_SSL_NUM_RENEGOTIATES = 126;
  901. BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT = 127;
  902. BIO_C_FILE_SEEK = 128;
  903. BIO_C_GET_CIPHER_CTX = 129;
  904. BIO_C_SET_BUF_MEM_EOF_RETURN = 130;//*return end of input value*/
  905. BIO_C_SET_BIND_MODE = 131;
  906. BIO_C_GET_BIND_MODE = 132;
  907. BIO_C_FILE_TELL = 133;
  908. BIO_C_GET_SOCKS = 134;
  909. BIO_C_SET_SOCKS = 135;
  910. BIO_C_SET_WRITE_BUF_SIZE = 136;//* for BIO_s_bio */
  911. BIO_C_GET_WRITE_BUF_SIZE = 137;
  912. BIO_C_MAKE_BIO_PAIR = 138;
  913. BIO_C_DESTROY_BIO_PAIR = 139;
  914. BIO_C_GET_WRITE_GUARANTEE = 140;
  915. BIO_C_GET_READ_REQUEST = 141;
  916. BIO_C_SHUTDOWN_WR = 142;
  917. BIO_C_NREAD0 = 143;
  918. BIO_C_NREAD = 144;
  919. BIO_C_NWRITE0 = 145;
  920. BIO_C_NWRITE = 146;
  921. BIO_C_RESET_READ_REQUEST = 147;
  922. BIO_C_SET_MD_CTX = 148;
  923. BIO_C_SET_PREFIX = 149;
  924. BIO_C_GET_PREFIX = 150;
  925. BIO_C_SET_SUFFIX = 151;
  926. BIO_C_GET_SUFFIX = 152;
  927. BIO_C_SET_EX_ARG = 153;
  928. BIO_C_GET_EX_ARG = 154;
  929. BIO_CTRL_RESET = 1 ; { opt - rewind/zero etc }
  930. BIO_CTRL_EOF = 2 ; { opt - are we at the eof }
  931. BIO_CTRL_INFO = 3 ; { opt - extra tit-bits }
  932. BIO_CTRL_SET = 4 ; { man - set the 'IO' type }
  933. BIO_CTRL_GET = 5 ; { man - get the 'IO' type }
  934. BIO_CTRL_PUSH = 6 ; { opt - internal, used to signify change }
  935. BIO_CTRL_POP = 7 ; { opt - internal, used to signify change }
  936. BIO_CTRL_GET_CLOSE = 8 ; { man - set the 'close' on free }
  937. BIO_CTRL_SET_CLOSE = 9 ; { man - set the 'close' on free }
  938. BIO_CTRL_PENDING = 10 ; { opt - is their more data buffered }
  939. BIO_CTRL_FLUSH = 11 ; { opt - 'flush' buffered output }
  940. BIO_CTRL_DUP = 12 ; { man - extra stuff for 'duped' BIO }
  941. BIO_CTRL_WPENDING = 13 ; { opt - number of bytes still to write }
  942. BIO_CTRL_SET_CALLBACK = 14 ; { opt - set callback function }
  943. BIO_CTRL_GET_CALLBACK = 15 ; { opt - set callback function }
  944. BIO_CTRL_SET_FILENAME = 30 ; { BIO_s_file special }
  945. BIO_CTRL_DGRAM_CONNECT = 31 ; { BIO dgram special }
  946. BIO_CTRL_DGRAM_SET_CONNECTED = 32 ; { allow for an externally }
  947. BIO_CTRL_DGRAM_SET_RECV_TIMEOUT = 33 ; { setsockopt, essentially }
  948. BIO_CTRL_DGRAM_GET_RECV_TIMEOUT = 34 ; { getsockopt, essentially }
  949. BIO_CTRL_DGRAM_SET_SEND_TIMEOUT = 35 ; { setsockopt, essentially }
  950. BIO_CTRL_DGRAM_GET_SEND_TIMEOUT = 36 ; { getsockopt, essentially }
  951. BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP = 37 ; { flag whether the last }
  952. BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP = 38 ; { I/O operation tiemd out }
  953. BIO_CTRL_DGRAM_MTU_DISCOVER = 39 ; { set DF bit on egress packets }
  954. BIO_CTRL_DGRAM_QUERY_MTU = 40 ; { as kernel for current MTU }
  955. BIO_CTRL_DGRAM_GET_FALLBACK_MTU = 47 ;
  956. BIO_CTRL_DGRAM_GET_MTU = 41 ; { get cached value for MTU }
  957. BIO_CTRL_DGRAM_SET_MTU = 42 ; { set cached value for }
  958. BIO_CTRL_DGRAM_MTU_EXCEEDED = 43 ; { check whether the MTU }
  959. BIO_CTRL_DGRAM_GET_PEER = 46 ;
  960. BIO_CTRL_DGRAM_SET_PEER = 44 ; { Destination for the data }
  961. BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT = 45 ; { Next DTLS handshake timeout to }
  962. BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE = 50;
  963. BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY = 51;
  964. BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY = 52;
  965. BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD = 53;
  966. BIO_CTRL_DGRAM_SCTP_GET_SNDINFO = 60;
  967. BIO_CTRL_DGRAM_SCTP_SET_SNDINFO = 61;
  968. BIO_CTRL_DGRAM_SCTP_GET_RCVINFO = 62;
  969. BIO_CTRL_DGRAM_SCTP_SET_RCVINFO = 63;
  970. BIO_CTRL_DGRAM_SCTP_GET_PRINFO = 64;
  971. BIO_CTRL_DGRAM_SCTP_SET_PRINFO = 65;
  972. BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN = 70;
  973. //DES modes
  974. DES_ENCRYPT = 1;
  975. DES_DECRYPT = 0;
  976. // Error codes for ECDH Function
  977. ECDH_F_ECDH_COMPUTE_KEY = 100;
  978. ECDH_F_ECDH_DATA_NEW_METHOD = 101;
  979. // Error codes for ECDH Reason
  980. ECDH_R_NO_PRIVATE_VALUE = 100;
  981. ECDH_R_POINT_ARITHMETIC_FAILURE = 101;
  982. ECDH_R_KDF_FAILED = 102;
  983. var
  984. SSLLibHandle: TLibHandle = 0;
  985. SSLUtilHandle: TLibHandle = 0;
  986. SSLLibFile: AnsiString = '';
  987. SSLUtilFile: AnsiString = '';
  988. // libssl.dll
  989. function OpenSSLGetVersion(t: cint):AnsiString;
  990. function SslGetError(s: PSSL; ret_code: cInt):cInt;
  991. Function OPENSSL_init_ssl(opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
  992. function SslLibraryInit:cInt;
  993. procedure SslLoadErrorStrings;
  994. // function SslCtxSetCipherList(arg0: PSSL_CTX; str: PAnsiChar):cInt;
  995. function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):cInt;
  996. function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
  997. procedure SslCtxFree(arg0: PSSL_CTX);
  998. function SslSetFd(s: PSSL; fd: cInt):cInt;
  999. function SslCtrl(ssl: PSSL; cmd: cInt; larg: clong; parg: Pointer): cLong;
  1000. function SslCTXCtrl(ctx: PSSL_CTX; cmd: cInt; larg: clong; parg: Pointer): cLong;
  1001. function SSLCTXSetMode(ctx: PSSL_CTX; mode: cLong): cLong;
  1002. function SSLSetMode(s: PSSL; mode: cLong): cLong;
  1003. function SSLCTXGetMode(ctx: PSSL_CTX): cLong;
  1004. function SSLGetMode(s: PSSL): cLong;
  1005. function SslMethodV2:PSSL_METHOD;
  1006. function SslMethodV3:PSSL_METHOD;
  1007. function SslMethodTLSV1:PSSL_METHOD;
  1008. function SslMethodTLSV1_1:PSSL_METHOD;
  1009. function SslMethodTLSV1_2:PSSL_METHOD;
  1010. function SslMethodV23:PSSL_METHOD;
  1011. function SslTLSMethod:PSSL_METHOD;
  1012. function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):cInt;
  1013. function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: AnsiString; len: cLong):cInt;overload;
  1014. function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; b: TBytes; len: cLong):cInt;overload;
  1015. // function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt;
  1016. function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
  1017. function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):cInt;
  1018. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: AnsiString):cInt; overload;
  1019. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; Buf: TBytes):cInt; overload;
  1020. function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
  1021. // function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PAnsiChar):cInt;
  1022. function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):cInt;
  1023. function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):cInt;
  1024. procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
  1025. procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
  1026. // function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):cInt;
  1027. function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):cInt;
  1028. function SslNew(ctx: PSSL_CTX):PSSL;
  1029. procedure SslFree(ssl: PSSL);
  1030. function SslAccept(ssl: PSSL):cInt;
  1031. function SslConnect(ssl: PSSL):cInt;
  1032. function SslShutdown(ssl: PSSL):cInt;
  1033. function SslRead(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  1034. function SslPeek(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  1035. function SslWrite(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  1036. function SslPending(ssl: PSSL):cInt;
  1037. function SslGetVersion(ssl: PSSL):AnsiString;
  1038. function SslGetPeerCertificate(ssl: PSSL):PX509;
  1039. procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: cInt; arg2: TSSLCTXVerifyCallback);
  1040. function SSLGetCurrentCipher(s: PSSL):SslPtr;
  1041. function SSLCipherGetName(c: SslPtr): AnsiString;
  1042. function SSLCipherGetBits(c: SslPtr; var alg_bits: cInt):cInt;
  1043. function SSLGetVerifyResult(ssl: PSSL):cLong;
  1044. function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): AnsiString;
  1045. procedure SslCtxCallbackCtrl(ssl: PSSL; _type: cInt; cb: PCallbackCb);
  1046. function SslSetSslCtx(ssl: PSSL; ctx: PSSL_CTX): PSSL;
  1047. function SslSet1Host(ssl: PSSL; hostname: string): cInt;
  1048. // libeay.dll
  1049. function OPENSSL_INIT_new : POPENSSL_INIT_SETTINGS;
  1050. Procedure OPENSSL_INIT_free(aSettings : POPENSSL_INIT_SETTINGS);
  1051. function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint;
  1052. Function OPENSSL_init_crypto ( opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
  1053. Procedure OPENSSL_cleanup;
  1054. procedure ERR_load_crypto_strings;
  1055. function X509New: PX509;
  1056. procedure X509Free(x: PX509);
  1057. function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: cInt):AnsiString;
  1058. function X509GetSubjectName(a: PX509):PX509_NAME;
  1059. function X509GetIssuerName(a: PX509):PX509_NAME;
  1060. function X509NameHash(x: PX509_NAME):cuLong;
  1061. // function SslX509Digest(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PcInt):cInt;
  1062. function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: cInt):cInt;
  1063. function X509print(b: PBIO; a: PX509): cInt;
  1064. function X509SetVersion(x: PX509; version: cInt): cInt;
  1065. function X509SetPubkey(x: PX509; pkey: PEVP_PKEY): cInt;
  1066. function X509GetPubkey(x: PX509): PEVP_PKEY;
  1067. function X509SetIssuerName(x: PX509; name: PX509_NAME): cInt;
  1068. function X509NameAddEntryByTxt(name: PX509_NAME; field: AnsiString; _type: cInt;
  1069. bytes: AnsiString; len, loc, _set: cInt): cInt;
  1070. function X509Sign(x: PX509; pkey: PEVP_PKEY; const md: PEVP_MD): cInt;
  1071. function X509GmtimeAdj(s: PASN1_UTCTIME; adj: cLong): PASN1_UTCTIME;
  1072. function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): cInt;
  1073. function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): cInt;
  1074. function X509GetSerialNumber(x: PX509): PASN1_cInt;
  1075. function EvpPkeyNew: PEVP_PKEY;
  1076. procedure EvpPkeyFree(pk: PEVP_PKEY);
  1077. function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
  1078. function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
  1079. procedure EVPcleanup;
  1080. function SSLeayversion(t: cInt): AnsiString; deprecated 'For 1.1+ use OpenSSLGetVersion';
  1081. procedure ErrErrorString(e: cInt; var buf: AnsiString; len: cInt);
  1082. function ErrGetError: cInt;
  1083. procedure ErrClearError;
  1084. procedure ErrFreeStrings;
  1085. procedure ErrRemoveState(pid: cInt);
  1086. procedure RandScreen; deprecated 'Deprecated as of 1.1+';
  1087. function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
  1088. function PKCS12parse(p12: SslPtr; pass: AnsiString; var pkey, cert, ca: SslPtr): cInt;
  1089. procedure PKCS12free(p12: SslPtr);
  1090. function Asn1StringTypeNew(aType : cint): PASN1_STRING;
  1091. Function Asn1UtctimePrint(b : PBio; a: PASN1_UTCTIME) : integer;
  1092. Function ASN1UtcTimeSetString(t : PASN1_UTCTIME; s : PAnsichar) : cint;
  1093. function Asn1UtctimeNew: PASN1_UTCTIME;
  1094. procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
  1095. function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
  1096. function Asn1IntegerGet(a: PASN1_INTEGER): integer;
  1097. function i2dX509bio(b: PBIO; x: PX509): cInt;
  1098. function i2dPrivateKeyBio(b: PBIO; pkey: PEVP_PKEY): cInt;
  1099. function d2iX509bio(b:PBIO; x:PX509): PX509;
  1100. function PEMReadBioX509(b:PBIO; x:PSslPtr; callback:PFunction; cb_arg: SslPtr): PX509;
  1101. procedure SkX509PopFree(st: SslPtr);
  1102. // 3DES functions
  1103. procedure DESsetoddparity(Key: des_cblock);
  1104. function DESsetkey(key: des_cblock; schedule: des_key_schedule): cInt;
  1105. function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): cInt;
  1106. procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: cInt);
  1107. // RAND functions
  1108. function RAND_set_rand_method(const meth: PRAND_METHOD): cint;
  1109. function RAND_get_rand_method: PRAND_METHOD;
  1110. function RAND_SSLeay: PRAND_METHOD; deprecated 'No longer in OpenSSL';
  1111. procedure RAND_cleanup; deprecated 'deprecated as of 1.1';
  1112. function RAND_bytes(buf: PByte; num: cint): cint;
  1113. function RAND_pseudo_bytes(buf: PByte; num: cint): cint;
  1114. procedure RAND_seed(const buf: Pointer; num: cint);
  1115. procedure RAND_add(const buf: Pointer; num: cint; entropy: cdouble);
  1116. function RAND_load_file(const file_name: PAnsiChar; max_bytes: clong): cint;
  1117. function RAND_write_file(const file_name: PAnsiChar): cint;
  1118. function RAND_file_name(file_name: PAnsiChar; num: csize_t): PAnsiChar;
  1119. function RAND_status: cint;
  1120. function RAND_query_egd_bytes(const path: PAnsiChar; buf: PByte; bytes: cint): cint;
  1121. function RAND_egd(const path: PAnsiChar): cint;
  1122. function RAND_egd_bytes(const path: PAnsiChar; bytes: cint): cint;
  1123. procedure ERR_load_RAND_strings;
  1124. function RAND_poll: cint;
  1125. // RSA Functions
  1126. function RSA_new(): PRSA;
  1127. function RSA_new_method(method: PENGINE): PRSA;
  1128. function RSA_size(arsa: PRSA): cint;
  1129. // Deprecated Function: Don't use!
  1130. // For compatibility with previous versions of this file
  1131. function RsaGenerateKey(bits, e: cInt; callback: PFunction; cb_arg: SslPtr): PRSA;
  1132. // New version of the previous deprecated routine
  1133. function RSA_generate_key_ex(arsa: PRSA; bits: cInt; e: PBIGNUM; cb: PBN_GENCB): cint;
  1134. //
  1135. function RSA_check_key(arsa: PRSA): cint;
  1136. // Next 4 return -1 on error
  1137. function RSA_public_encrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  1138. function RSA_private_encrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  1139. function RSA_public_decrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  1140. function RSA_private_decrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  1141. procedure RSA_free(arsa: PRSA);
  1142. //
  1143. // RSA_up_flags
  1144. function RSA_flags(arsa: PRSA): Integer;
  1145. //
  1146. procedure RSA_set_default_method(method: PRSA_METHOD);
  1147. function RSA_get_default_method: PRSA_METHOD;
  1148. function RSA_get_method(arsa: PRSA): PRSA_METHOD;
  1149. function RSA_set_method(arsa: PRSA; method: PRSA_METHOD): PRSA_METHOD;
  1150. //
  1151. // RSA_memory_lock
  1152. // X509 Functions
  1153. function d2i_RSAPublicKey(arsa: PPRSA; pp: PPByte; len: cint): PRSA;
  1154. function i2d_RSAPublicKey(arsa: PRSA; pp: PPByte): cint;
  1155. function d2i_RSAPrivateKey(arsa: PPRSA; pp: PPByte; len: cint): PRSA;
  1156. function i2d_RSAPrivateKey(arsa: PRSA; pp: PPByte): cint;
  1157. function d2i_PubKey(a: PPEVP_PKEY; pp: PPByte; len: clong): PEVP_PKEY;
  1158. function d2i_AutoPrivateKey(a: PPEVP_PKEY; pp: PPByte; len: clong): PEVP_PKEY;
  1159. // ERR Functions
  1160. function Err_Error_String(e: cInt; buf: PAnsiChar): PAnsiChar;
  1161. // Crypto Functions
  1162. function SSLeay_version(t: cint): PAnsiChar; deprecated 'For 1.1+ use OpenSSLGetVersion';
  1163. // EVP Functions - evp.h
  1164. function EVP_des_ede3_cbc : PEVP_CIPHER;
  1165. Function EVP_enc_null : PEVP_CIPHER;
  1166. Function EVP_rc2_cbc : PEVP_CIPHER;
  1167. Function EVP_rc2_40_cbc : PEVP_CIPHER;
  1168. Function EVP_rc2_64_cbc : PEVP_CIPHER;
  1169. Function EVP_rc4 : PEVP_CIPHER;
  1170. Function EVP_rc4_40 : PEVP_CIPHER;
  1171. Function EVP_des_cbc : PEVP_CIPHER;
  1172. Function EVP_aes_128_cbc : PEVP_CIPHER;
  1173. Function EVP_aes_192_cbc : PEVP_CIPHER;
  1174. Function EVP_aes_256_cbc : PEVP_CIPHER;
  1175. Function EVP_aes_128_cfb8 : PEVP_CIPHER;
  1176. Function EVP_aes_192_cfb8 : PEVP_CIPHER;
  1177. Function EVP_aes_256_cfb8 : PEVP_CIPHER;
  1178. Function EVP_camellia_128_cbc : PEVP_CIPHER;
  1179. Function EVP_camellia_192_cbc : PEVP_CIPHER;
  1180. Function EVP_camellia_256_cbc : PEVP_CIPHER;
  1181. function EVP_sha256: PEVP_CIPHER;
  1182. procedure OpenSSL_add_all_algorithms;
  1183. procedure OpenSSL_add_all_ciphers;
  1184. procedure OpenSSL_add_all_digests;
  1185. //
  1186. function EVP_DigestInit(ctx: PEVP_MD_CTX; type_: PEVP_MD): cint;
  1187. function EVP_DigestUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  1188. function EVP_DigestFinal(ctx: PEVP_MD_CTX; md: PByte; s: pcuint): cint;
  1189. function EVP_SignFinal(ctx: pEVP_MD_CTX; sig: pointer; var s: cardinal;
  1190. key: pEVP_PKEY): integer;
  1191. function EVP_PKEY_size(key: pEVP_PKEY): integer;
  1192. procedure EVP_PKEY_free(key: pEVP_PKEY);
  1193. function EVP_VerifyFinal(ctx: pEVP_MD_CTX; sigbuf: pointer;
  1194. siglen: cardinal; pkey: pEVP_PKEY): integer;
  1195. //
  1196. function EVP_get_cipherbyname(const name: PAnsiChar): PEVP_CIPHER;
  1197. function EVP_get_digestbyname(const name: PAnsiChar): PEVP_MD;
  1198. //
  1199. procedure EVP_CIPHER_CTX_init(a: PEVP_CIPHER_CTX);
  1200. function EVP_CIPHER_CTX_cleanup(a: PEVP_CIPHER_CTX): cint;
  1201. function EVP_CIPHER_CTX_set_key_length(x: PEVP_CIPHER_CTX; keylen: cint): cint;
  1202. function EVP_CIPHER_CTX_ctrl(ctx: PEVP_CIPHER_CTX; type_, arg: cint; ptr: Pointer): cint;
  1203. //
  1204. function EVP_EncryptInit(ctx: PEVP_CIPHER_CTX; const chipher_: PEVP_CIPHER;
  1205. const key, iv: PByte): cint;
  1206. function EVP_EncryptUpdate(ctx: PEVP_CIPHER_CTX; out_: pcuchar;
  1207. outlen: pcint; const in_: pcuchar; inlen: cint): cint;
  1208. function EVP_EncryptFinal(ctx: PEVP_CIPHER_CTX; out_data: PByte; outlen: pcint): cint;
  1209. //
  1210. function EVP_DecryptInit(ctx: PEVP_CIPHER_CTX; chiphir_type: PEVP_CIPHER;
  1211. const key, iv: PByte): cint;
  1212. function EVP_DecryptUpdate(ctx: PEVP_CIPHER_CTX; out_data: PByte;
  1213. outl: pcint; const in_: PByte; inl: cint): cint;
  1214. function EVP_DecryptFinal(ctx: PEVP_CIPHER_CTX; outm: PByte; outlen: pcint): cint;
  1215. //
  1216. function EVP_MD_CTX_new: PEVP_MD_CTX;
  1217. function EVP_MD_CTX_create: PEVP_MD_CTX;
  1218. procedure EVP_MD_CTX_destroy(ctx: PEVP_MD_CTX);
  1219. procedure EVP_MD_CTX_free(ctx: PEVP_MD_CTX);
  1220. function EVP_DigestSignInit(ctx: PEVP_MD_CTX; pctx: PPEVP_PKEY_CTX; const evptype: PEVP_MD; e: PENGINE; pkey: PEVP_PKEY): cint;
  1221. function EVP_DigestSignUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  1222. function EVP_DigestSignFinal(ctx: PEVP_MD_CTX; sigret: PByte; siglen: pcsize_t): cint;
  1223. function EVP_DigestSign(ctx: PEVP_MD_CTX; sigret:Pbyte; siglen:pcsize_t; const tbs : pointer; tbslen: csize_t): cint;
  1224. function EVP_DigestVerifyInit(ctx: PEVP_MD_CTX; pctx: PPEVP_PKEY_CTX; const evptype: PEVP_MD; e: PENGINE; pkey: PEVP_PKEY): cint;
  1225. function EVP_DigestVerifyUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  1226. function EVP_DigestVerifyFinal(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t): cint;
  1227. function EVP_DigestVerify(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t; const tbs : pointer; tbslen: csize_t): cint;
  1228. //function
  1229. //
  1230. // PEM Functions - pem.h
  1231. //
  1232. function PEM_read_bio_PrivateKey(bp: PBIO; X: PPEVP_PKEY;
  1233. cb: Ppem_password_cb; u: Pointer): PEVP_PKEY;
  1234. function PEM_read_bio_PUBKEY(bp: pBIO; var x: pEVP_PKEY;
  1235. cb: Ppem_password_cb; u: pointer): pEVP_PKEY;
  1236. function PEM_write_bio_PrivateKey(bp: pBIO; x: pEVP_PKEY;
  1237. const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
  1238. u: pointer): integer;
  1239. function PEM_write_bio_PUBKEY(bp: pBIO; x: pEVP_PKEY): integer;
  1240. function PEM_read_bio_X509(bp: PBIO; x: PPX509; cb: ppem_password_cb; u: pointer): PX509;
  1241. function PEM_write_bio_X509(bp: pBIO; x: px509): integer;
  1242. function PEM_write_bio_PKCS7(bp : PBIO; x : PPKCS7) : cint;
  1243. // BIO Functions - bio.h
  1244. function BioNew(b: PBIO_METHOD): PBIO;
  1245. procedure BioFreeAll(b: PBIO);
  1246. function BioSMem: PBIO_METHOD;
  1247. function BioCtrlPending(b: PBIO): cInt;
  1248. function BioRead(b: PBIO; var Buf: AnsiString; Len: cInt): cInt;
  1249. function BioRead(b: PBIO; Buf: TBytes; Len: cInt): cInt;
  1250. function BioWrite(b: PBIO; Buf: AnsiString; Len: cInt): cInt; overload;
  1251. function BioWrite(b: PBIO; Buf: TBytes; Len: cInt): cInt; overload;
  1252. function BIO_ctrl(bp: PBIO; cmd: cint; larg: clong; parg: Pointer): clong;
  1253. function BIO_read_filename(b: PBIO; const name: PAnsiChar): cint;
  1254. function BIO_push(b: PBIO; append: PBIO): PBIO;
  1255. function BIO_pop(b: PBIO): PBIO;
  1256. function BIO_gets(b: PBIO; buf: PAnsiChar; size: cint): cint;
  1257. function BIO_puts(b: PBIO; const buf: PAnsiChar): cint;
  1258. procedure BIO_set_mem_eof_return(b: PBIO; v: cint);
  1259. procedure BIO_set_mem_buf(b: PBIO; bm: pointer; c: cint);
  1260. procedure BIO_get_mem_ptr(b: PBIO; var pp: pointer);
  1261. function BIO_s_file: pBIO_METHOD;
  1262. function BIO_new_file(const filename: PAnsiChar; const mode: PAnsiChar): pBIO;
  1263. function BIO_new_mem_buf(buf: pointer; len: integer): pBIO;
  1264. procedure CRYPTOcleanupAllExData;
  1265. procedure OPENSSLaddallalgorithms;
  1266. // PKCS7 functions
  1267. function PKCS7_ISSUER_AND_SERIAL_new : PPKCS7_ISSUER_AND_SERIAL;
  1268. procedure PKCS7_ISSUER_AND_SERIAL_free (a:PPKCS7_ISSUER_AND_SERIAL);
  1269. function PKCS7_ISSUER_AND_SERIAL_digest(data:PPKCS7_ISSUER_AND_SERIAL; _type:PEVP_MD; md:Pbyte; len:Pdword):longint;
  1270. function PKCS7_dup(p7:PPKCS7):PPKCS7;
  1271. function PEM_write_bio_PKCS7_stream(_out:PBIO; p7:PPKCS7; _in:PBIO; flags:longint):longint;
  1272. function PKCS7_SIGNER_INFO_new:PPKCS7_SIGNER_INFO;
  1273. procedure PKCS7_SIGNER_INFO_free(a:PPKCS7_SIGNER_INFO);
  1274. function PKCS7_RECIP_INFO_new:PPKCS7_RECIP_INFO;
  1275. procedure PKCS7_RECIP_INFO_free(a:PPKCS7_RECIP_INFO);
  1276. function PKCS7_SIGNED_new:PPKCS7_SIGNED;
  1277. procedure PKCS7_SIGNED_free(a:PPKCS7_SIGNED);
  1278. function PKCS7_ENC_CONTENT_new:PPKCS7_ENC_CONTENT;
  1279. procedure PKCS7_ENC_CONTENT_free(a:PPKCS7_ENC_CONTENT);
  1280. function PKCS7_ENVELOPE_new:PPKCS7_ENVELOPE;
  1281. procedure PKCS7_ENVELOPE_free(a:PPKCS7_ENVELOPE);
  1282. function PKCS7_SIGN_ENVELOPE_new:PPKCS7_SIGN_ENVELOPE;
  1283. procedure PKCS7_SIGN_ENVELOPE_free(a:PPKCS7_SIGN_ENVELOPE);
  1284. function PKCS7_DIGEST_new:PPKCS7_DIGEST;
  1285. procedure PKCS7_DIGEST_free(a:PPKCS7_DIGEST);
  1286. function PKCS7_ENCRYPT_new:PPKCS7_ENCRYPT;
  1287. procedure PKCS7_ENCRYPT_free(a:PPKCS7_ENCRYPT);
  1288. function PKCS7_new:PPKCS7;
  1289. procedure PKCS7_free(a:PPKCS7);
  1290. function PKCS7_print_ctx(_out:PBIO; x:PPKCS7; indent:longint; pctx:Pointer):longint;
  1291. function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;
  1292. function PKCS7_set_type(p7:PPKCS7; _type:longint):longint;
  1293. function PKCS7_set0_type_other(p7:PPKCS7; _type:longint; other:PASN1_TYPE):longint;
  1294. function PKCS7_set_content(p7:PPKCS7; p7_data:PPKCS7):longint;
  1295. function PKCS7_SIGNER_INFO_set(p7i:PPKCS7_SIGNER_INFO; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):longint;
  1296. function PKCS7_SIGNER_INFO_sign(si:PPKCS7_SIGNER_INFO):longint;
  1297. function PKCS7_add_signer(p7:PPKCS7; p7i:PPKCS7_SIGNER_INFO):longint;
  1298. function PKCS7_add_certificate(p7:PPKCS7; x509:PX509):longint;
  1299. function PKCS7_add_crl(p7:PPKCS7; x509: Pointer):longint;
  1300. function PKCS7_content_new(p7:PPKCS7; nid:longint):longint;
  1301. function PKCS7_add_signature(p7:PPKCS7; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):PPKCS7_SIGNER_INFO;
  1302. function PKCS7_cert_from_signer_info(p7:PPKCS7; si:PPKCS7_SIGNER_INFO):PX509;
  1303. function PKCS7_set_digest(p7:PPKCS7; md:PEVP_MD):longint;
  1304. function PKCS7_add_recipient(p7:PPKCS7; x509:PX509):PPKCS7_RECIP_INFO;
  1305. function PKCS7_add_recipient_info(p7:PPKCS7; ri:PPKCS7_RECIP_INFO):longint;
  1306. function PKCS7_RECIP_INFO_set(p7i:PPKCS7_RECIP_INFO; x509:PX509):longint;
  1307. function PKCS7_set_cipher(p7:PPKCS7; cipher:PEVP_CIPHER):longint;
  1308. function PKCS7_get_issuer_and_serial(p7:PPKCS7; idx:longint):PPKCS7_ISSUER_AND_SERIAL;
  1309. function PKCS7_digest_from_attributes(sk:Pstack_st_X509_ATTRIBUTE):Pointer;
  1310. function PKCS7_add_signed_attribute(p7si:PPKCS7_SIGNER_INFO; nid:longint; _type:longint; data:pointer):longint;
  1311. function PKCS7_add_attribute(p7si:PPKCS7_SIGNER_INFO; nid:longint; atrtype:longint; value:pointer):longint;
  1312. function PKCS7_get_attribute(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;
  1313. function PKCS7_get_signed_attribute(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;
  1314. function PKCS7_set_signed_attributes(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;
  1315. function PKCS7_set_attributes(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;
  1316. function PKCS7_sign(signcert:PX509; pkey:PEVP_PKEY; certs:Pstack_st_X509; data:PBIO; flags:longint):PPKCS7;
  1317. function PKCS7_sign_add_signer(p7:PPKCS7; signcert:PX509; pkey:PEVP_PKEY; md:PEVP_MD; flags:longint):PPKCS7_SIGNER_INFO;
  1318. function PKCS7_final(p7:PPKCS7; data:PBIO; flags:longint):longint;
  1319. function PKCS7_verify(p7:PPKCS7; certs:Pstack_st_X509; store: Pointer; indata:PBIO; _out:PBIO; flags:longint):longint;
  1320. function PKCS7_encrypt(certs:Pstack_st_X509; _in:PBIO; cipher:PEVP_CIPHER; flags:longint):PPKCS7;
  1321. function PKCS7_decrypt(p7:PPKCS7; pkey:PEVP_PKEY; cert:PX509; data:PBIO; flags:longint):longint;
  1322. function PKCS7_add_attrib_smimecap(si:PPKCS7_SIGNER_INFO; cap:Pstack_st_X509_ALGOR):longint;
  1323. function PKCS7_simple_smimecap(sk:Pstack_st_X509_ALGOR; nid:longint; arg:longint):longint;
  1324. function PKCS7_add_attrib_content_type(si:PPKCS7_SIGNER_INFO; coid:Pointer):longint;
  1325. function PKCS7_add0_attrib_signing_time(si:PPKCS7_SIGNER_INFO; t:PASN1_TIME):longint;
  1326. function PKCS7_add1_attrib_digest(si:PPKCS7_SIGNER_INFO; md:Pbyte; mdlen:longint):longint;
  1327. function BIO_new_PKCS7(_out:PBIO; p7:PPKCS7):PBIO;
  1328. procedure ERR_load_PKCS7_strings;
  1329. // SMIME functions
  1330. function SMIME_write_PKCS7(_out: PBIO; p7: PPKCS7; data: PBIO; flags: longint): longint;
  1331. function SMIME_read_PKCS7(_in: PBIO; bcont: PPBIO): PPKCS7;
  1332. // BN functions
  1333. function BN_new:PBIGNUM;
  1334. function BN_secure_new:PBIGNUM;
  1335. procedure BN_clear_free(a:PBIGNUM);
  1336. function BN_copy(a:PBIGNUM; b:PBIGNUM):PBIGNUM;
  1337. procedure BN_swap(a:PBIGNUM; b:PBIGNUM);
  1338. function BN_bin2bn(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM;
  1339. function BN_bn2bin(a:PBIGNUM; _to:pcuchar):cint;
  1340. function BN_bn2binpad(a:PBIGNUM; _to:pcuchar; tolen:cint):cint;
  1341. function BN_lebin2bn(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM;
  1342. function BN_bn2lebinpad(a:PBIGNUM; _to:pcuchar; tolen:cint):cint;
  1343. function BN_mpi2bn(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM;
  1344. function BN_bn2mpi(a:PBIGNUM; _to:pcuchar):cint;
  1345. function BN_sub(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint;
  1346. function BN_usub(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint;
  1347. function BN_uadd(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint;
  1348. function BN_add(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint;
  1349. function BN_mul(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; ctx:PBN_CTX):cint;
  1350. function BN_sqr(r:PBIGNUM; a:PBIGNUM; ctx:PBN_CTX):cint;
  1351. // BN_set_negative sets sign of a BIGNUM
  1352. // \param b pointer to the BIGNUM object
  1353. // \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
  1354. procedure BN_set_negative(b:PBIGNUM; n:cint);
  1355. // BN_is_negative returns 1 if the BIGNUM is negative
  1356. // \param b pointer to the BIGNUM object
  1357. // \return 1 if a < 0 and 0 otherwise
  1358. function BN_is_negative(b:PBIGNUM):cint;
  1359. function BN_div(dv:PBIGNUM; rem:PBIGNUM; m:PBIGNUM; d:PBIGNUM; ctx:PBN_CTX):cint;
  1360. function BN_mod(rem: PBIGNUM; a:PBIGNUM; m: PBIGNUM; ctx : PBN_CTX) : cint;
  1361. function BN_nnmod(r:PBIGNUM; m:PBIGNUM; d:PBIGNUM; ctx:PBN_CTX):cint;
  1362. function BN_mod_add(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint;
  1363. function BN_mod_add_quick(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM):cint;
  1364. function BN_mod_sub(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint;
  1365. function BN_mod_sub_quick(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM):cint;
  1366. function BN_mod_mul(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint;
  1367. function BN_mod_sqr(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint;
  1368. function BN_mod_lshift1(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint;
  1369. function BN_mod_lshift1_quick(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM):cint;
  1370. function BN_mod_lshift(r:PBIGNUM; a:PBIGNUM; n:cint; m:PBIGNUM; ctx:PBN_CTX):cint;
  1371. function BN_mod_lshift_quick(r:PBIGNUM; a:PBIGNUM; n:cint; m:PBIGNUM):cint;
  1372. function BN_mod_word(a:PBIGNUM; w:BN_ULONG):BN_ULONG;
  1373. function BN_div_word(a:PBIGNUM; w:BN_ULONG):BN_ULONG;
  1374. function BN_mul_word(a:PBIGNUM; w:BN_ULONG):cint;
  1375. function BN_add_word(a:PBIGNUM; w:BN_ULONG):cint;
  1376. function BN_sub_word(a:PBIGNUM; w:BN_ULONG):cint;
  1377. function BN_set_word(a:PBIGNUM; w:BN_ULONG):cint;
  1378. function BN_get_word(a:PBIGNUM):BN_ULONG;
  1379. function BN_cmp(a:PBIGNUM; b:PBIGNUM):cint;
  1380. procedure BN_free(a:PBIGNUM);
  1381. function IsSSLloaded: Boolean;
  1382. function InitSSLInterface(Const aSSLName, acryptoName : AnsiString) : Boolean; overload;
  1383. function InitSSLInterface: Boolean; overload;
  1384. function DestroySSLInterface: Boolean;
  1385. // compatibility with old versions.
  1386. function Islibealoaded: Boolean; deprecated;
  1387. function InitSSLInterface(AVerboseLoading: Boolean): Boolean ; overload; deprecated;
  1388. function InitSSLEAInterface(AVerboseLoading: Boolean): Boolean; deprecated;
  1389. function InitLibeaInterface(AVerboseLoading: Boolean = false): Boolean; deprecated;
  1390. function DestroySSLEAInterface: Boolean; deprecated;
  1391. function DestroyLibeaInterface: Boolean; deprecated;
  1392. var
  1393. OpenSSL_unavailable_functions: AnsiString;
  1394. implementation
  1395. {
  1396. Compatibility functions
  1397. }
  1398. Var
  1399. SSLloaded: boolean = false;
  1400. LoadVerbose : Boolean;
  1401. SSLCS : TRTLCriticalSection;
  1402. Locks: Array of TRTLCriticalSection;
  1403. resourcestring
  1404. SFailedToLoadOpenSSL = 'Failed to load OpenSSL library';
  1405. function Islibealoaded: Boolean; deprecated;
  1406. begin
  1407. Result:=isSSLLoaded;
  1408. end;
  1409. function InitSSLInterface(AVerboseLoading: Boolean): Boolean ; deprecated;
  1410. Var
  1411. B : Boolean;
  1412. begin
  1413. B:=LoadVerbose;
  1414. LoadVerbose:=AVerboseLoading;
  1415. try
  1416. Result:=InitSSLInterface;
  1417. finally
  1418. LoadVerbose:=B;
  1419. end;
  1420. end;
  1421. function InitSSLEAInterface(AVerboseLoading: Boolean): Boolean; deprecated;
  1422. Var
  1423. B : Boolean;
  1424. begin
  1425. B:=LoadVerbose;
  1426. LoadVerbose:=AVerboseLoading;
  1427. try
  1428. Result:=InitSSLInterface;
  1429. finally
  1430. LoadVerbose:=B;
  1431. end;
  1432. end;
  1433. function InitLibeaInterface(AVerboseLoading: Boolean = false): Boolean; deprecated;
  1434. Var
  1435. B : Boolean;
  1436. begin
  1437. B:=LoadVerbose;
  1438. LoadVerbose:=AVerboseLoading;
  1439. try
  1440. Result:=InitSSLInterface;
  1441. finally
  1442. LoadVerbose:=B;
  1443. end;
  1444. end;
  1445. function DestroySSLEAInterface: Boolean; deprecated;
  1446. begin
  1447. Result:=DestroySSLInterface;
  1448. end;
  1449. function DestroyLibeaInterface: Boolean; deprecated;
  1450. begin
  1451. Result:=DestroySSLInterface;
  1452. end;
  1453. type
  1454. // libssl.dll
  1455. TSslGetError = function(s: PSSL; ret_code: cInt):cInt; cdecl;
  1456. TSslLibraryInit = function:cInt; cdecl;
  1457. TOPENSSL_INIT_new = function : POPENSSL_INIT_SETTINGS; cdecl;
  1458. TOPENSSL_INIT_free = procedure(settings : POPENSSL_INIT_SETTINGS); cdecl;
  1459. TOPENSSL_INIT_set_config_appname = function (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint; cdecl;
  1460. TOPENSSL_init_ssl = function ( opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint; cdecl;
  1461. TOPENSSL_cleanup = procedure; cdecl;
  1462. TSslLoadErrorStrings = procedure; cdecl;
  1463. TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PAnsiChar):cInt; cdecl;
  1464. TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
  1465. TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
  1466. TSslSetFd = function(s: PSSL; fd: cInt):cInt; cdecl;
  1467. TSslCtrl = function(ssl: PSSL; cmd: cInt; larg: clong; parg: Pointer): cLong; cdecl;
  1468. TSslCTXCtrl = function(ctx: PSSL_CTX; cmd: cInt; larg: clong; parg: Pointer): cLong; cdecl;
  1469. TSslMethodV2 = function:PSSL_METHOD; cdecl;
  1470. TSslMethodV3 = function:PSSL_METHOD; cdecl;
  1471. TSslMethodTLSV1 = function:PSSL_METHOD; cdecl;
  1472. TSslMethodTLSV1_1 = function:PSSL_METHOD; cdecl;
  1473. TSslMethodTLSV1_2 = function:PSSL_METHOD; cdecl;
  1474. TSslMethodV23 = function:PSSL_METHOD; cdecl;
  1475. TSslTLSMethod = function:PSSL_METHOD; cdecl;
  1476. TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):cInt; cdecl;
  1477. TSslCtxUsePrivateKeyASN1 = function(pk: cInt; ctx: PSSL_CTX; d: sslptr; len: cInt):cInt; cdecl;
  1478. TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt; cdecl;
  1479. TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):cInt; cdecl;
  1480. TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: cInt; d: SslPtr):cInt; cdecl;
  1481. TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt; cdecl;
  1482. TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PAnsiChar):cInt; cdecl;
  1483. TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):cInt; cdecl;
  1484. TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
  1485. TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
  1486. TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):cInt; cdecl;
  1487. TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
  1488. TSslFree = procedure(ssl: PSSL); cdecl;
  1489. TSslAccept = function(ssl: PSSL):cInt; cdecl;
  1490. TSslConnect = function(ssl: PSSL):cInt; cdecl;
  1491. TSslShutdown = function(ssl: PSSL):cInt; cdecl;
  1492. TSslRead = function(ssl: PSSL; buf: PAnsiChar; num: cInt):cInt; cdecl;
  1493. TSslPeek = function(ssl: PSSL; buf: PAnsiChar; num: cInt):cInt; cdecl;
  1494. TSslWrite = function(ssl: PSSL; const buf: PAnsiChar; num: cInt):cInt; cdecl;
  1495. TSslPending = function(ssl: PSSL):cInt; cdecl;
  1496. TSslGetVersion = function(ssl: PSSL):PAnsiChar; cdecl;
  1497. TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
  1498. TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: cInt; arg2: SslPtr); cdecl;
  1499. TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
  1500. TSSLCipherGetName = function(c: Sslptr):PAnsiChar; cdecl;
  1501. TSSLCipherGetBits = function(c: SslPtr; alg_bits: PcInt):cInt; cdecl;
  1502. TSSLGetVerifyResult = function(ssl: PSSL):cInt; cdecl;
  1503. TSSLGetServername = function(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): PAnsiChar; cdecl;
  1504. TSSLCtxCallbackCtrl = procedure(ctx: PSSL_CTX; _type: cInt; cb: PCallbackCb); cdecl;
  1505. TSSLSetSslCtx = function(ssl: PSSL; ctx: PSSL_CTX): PSSL; cdecl;
  1506. TSslSet1Host = function(ssl: PSSL; hostname: string): cInt; cdecl;
  1507. // libeay.dll
  1508. TERR_load_crypto_strings = procedure; cdecl;
  1509. TX509New = function: PX509; cdecl;
  1510. TX509Free = procedure(x: PX509); cdecl;
  1511. TX509NameOneline = function(a: PX509_NAME; buf: PAnsiChar; size: cInt):PAnsiChar; cdecl;
  1512. TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
  1513. TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
  1514. TX509NameHash = function(x: PX509_NAME):cuLong; cdecl;
  1515. TX509Digest = function(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PcInt):cInt; cdecl;
  1516. TX509print = function(b: PBIO; a: PX509): cInt; cdecl;
  1517. TX509SetVersion = function(x: PX509; version: cInt): cInt; cdecl;
  1518. TX509SetPubkey = function(x: PX509; pkey: PEVP_PKEY): cInt; cdecl;
  1519. TX509GetPubkey = function(x: PX509): PEVP_PKEY; cdecl;
  1520. TX509SetIssuerName = function(x: PX509; name: PX509_NAME): cInt; cdecl;
  1521. TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PAnsiChar; _type: cInt;
  1522. bytes: PAnsiChar; len, loc, _set: cInt): cInt; cdecl;
  1523. TX509Sign = function(x: PX509; pkey: PEVP_PKEY; const md: PEVP_MD): cInt; cdecl;
  1524. TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: cLong): PASN1_UTCTIME; cdecl;
  1525. TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): cInt; cdecl;
  1526. TX509SetNotAfter = function(x: PX509; tm: PASN1_UTCTIME): cInt; cdecl;
  1527. TX509GetSerialNumber = function(x: PX509): PASN1_cInt; cdecl;
  1528. TEvpPkeyNew = function: PEVP_PKEY; cdecl;
  1529. TEvpPkeyFree = procedure(pk: PEVP_PKEY); cdecl;
  1530. TEvpPkeyAssign = function(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt; cdecl;
  1531. TEvpGetDigestByName = function(Name: PAnsiChar): PEVP_MD; cdecl;
  1532. TEVPcleanup = procedure; cdecl;
  1533. TOpenSSLversion = function (arg : cint) : PAnsiChar; cdecl;
  1534. TSSLeayversion = function(t: cInt): PAnsiChar; cdecl;
  1535. TErrErrorString = procedure(e: cInt; buf: PAnsiChar; len: cInt); cdecl;
  1536. TErrGetError = function: cInt; cdecl;
  1537. TErrClearError = procedure; cdecl;
  1538. TErrFreeStrings = procedure; cdecl;
  1539. TErrRemoveState = procedure(pid: cInt); cdecl;
  1540. TRandScreen = procedure; cdecl;
  1541. TBioNew = function(b: PBIO_METHOD): PBIO; cdecl;
  1542. TBioFreeAll = procedure(b: PBIO); cdecl;
  1543. TBioSMem = function: PBIO_METHOD; cdecl;
  1544. TBioCtrlPending = function(b: PBIO): cInt; cdecl;
  1545. TBioRead = function(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt; cdecl;
  1546. TBioWrite = function(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt; cdecl;
  1547. Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
  1548. TPKCS12parse = function(p12: SslPtr; pass: PAnsiChar; var pkey, cert, ca: SslPtr): cInt; cdecl;
  1549. TPKCS12free = procedure(p12: SslPtr); cdecl;
  1550. TAsn1StringTypeNew = function(aype : cint): SSlPtr; cdecl;
  1551. TAsn1UtcTimeSetString = function(t : PASN1_UTCTIME; S : PAnsiChar): cint; cdecl;
  1552. TAsn1UtctimePrint = Function(b : PBio;a: PASN1_UTCTIME) : cint; cdecl;
  1553. TAsn1UtctimeFree = procedure(a: PASN1_UTCTIME); cdecl;
  1554. TAsn1IntegerSet = function(a: PASN1_INTEGER; v: integer): integer; cdecl;
  1555. TAsn1IntegerGet = function(a: PASN1_INTEGER): integer; cdecl;
  1556. Ti2dX509bio = function(b: PBIO; x: PX509): cInt; cdecl;
  1557. Td2iX509bio = function(b:PBIO; x:PX509): PX509; cdecl;
  1558. TPEMReadBioX509 = function(b:PBIO; x:PSslPtr; callback:PFunction; cb_arg:SslPtr): PX509; cdecl;
  1559. TSkX509PopFree = procedure(st: PSslPtr; func: TX509Free); cdecl;
  1560. Ti2dPrivateKeyBio= function(b: PBIO; pkey: PEVP_PKEY): cInt; cdecl;
  1561. // 3DES functions
  1562. TDESsetoddparity = procedure(Key: des_cblock); cdecl;
  1563. TDESsetkeychecked = function(key: des_cblock; schedule: des_key_schedule): cInt; cdecl;
  1564. TDESsetkey = TDESsetkeychecked;
  1565. TDESecbencrypt = procedure(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: cInt); cdecl;
  1566. //thread lock functions
  1567. TCRYPTOnumlocks = function: cInt; cdecl;
  1568. TCRYPTOSetLockingCallback = procedure(cb: Sslptr); cdecl;
  1569. // RAND functions
  1570. TRAND_set_rand_method = function(const meth: PRAND_METHOD): cint; cdecl;
  1571. TRAND_get_rand_method = function(): PRAND_METHOD; cdecl;
  1572. TRAND_SSLeay = function(): PRAND_METHOD; cdecl;
  1573. TRAND_cleanup = procedure(); cdecl;
  1574. TRAND_bytes = function(buf: PByte; num: cint): cint; cdecl;
  1575. TRAND_pseudo_bytes = function(buf: PByte; num: cint): cint; cdecl;
  1576. TRAND_seed = procedure(const buf: Pointer; num: cint); cdecl;
  1577. TRAND_add = procedure(const buf: Pointer; num: cint; entropy: cdouble); cdecl;
  1578. TRAND_load_file = function(const file_name: PAnsiChar; max_bytes: clong): cint; cdecl;
  1579. TRAND_write_file = function(const file_name: PAnsiChar): cint; cdecl;
  1580. TRAND_file_name = function(file_name: PAnsiChar; num: csize_t): PAnsiChar; cdecl;
  1581. TRAND_status = function(): cint; cdecl;
  1582. TRAND_query_egd_bytes = function(const path: PAnsiChar; buf: PByte; bytes: cint): cint; cdecl;
  1583. TRAND_egd = function(const path: PAnsiChar): cint; cdecl;
  1584. TRAND_egd_bytes = function(const path: PAnsiChar; bytes: cint): cint; cdecl;
  1585. TERR_load_RAND_strings = procedure(); cdecl;
  1586. TRAND_poll = function(): cint; cdecl;
  1587. // RSA Functions
  1588. TRSA_new = function (): PRSA; cdecl;
  1589. TRSA_new_method = function (method: PENGINE): PRSA; cdecl;
  1590. TRSA_size = function (arsa: PRSA): cint; cdecl;
  1591. TRsaGenerateKey = function(bits, e: cInt; callback: PFunction; cb_arg: SslPtr): PRSA; cdecl;
  1592. TRSA_generate_key_ex = function (arsa: PRSA; bits: cInt; e: PBIGNUM; cb: PBN_GENCB): cint; cdecl;
  1593. TRSA_check_key = function (arsa: PRSA): cint; cdecl;
  1594. TRSA_public_encrypt = function (flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint; cdecl;
  1595. TRSA_private_encrypt = function (flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint; cdecl;
  1596. TRSA_public_decrypt = function (flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint; cdecl;
  1597. TRSA_private_decrypt = function (flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint; cdecl;
  1598. TRSA_free = procedure (arsa: PRSA); cdecl;
  1599. TRSA_flags = function (arsa: PRSA): Integer; cdecl;
  1600. TRSA_set_default_method = procedure (method: PRSA_METHOD); cdecl;
  1601. TRSA_get_default_method = function : PRSA_METHOD; cdecl;
  1602. TRSA_get_method = function (prsa: PRSA): PRSA_METHOD; cdecl;
  1603. TRSA_set_method = function (arsa: PRSA; method: PRSA_METHOD): PRSA_METHOD; cdecl;
  1604. // X509 Functions
  1605. Td2i_RSAPublicKey = function (arsa: PPRSA; pp: PPByte; len: cint): PRSA; cdecl;
  1606. Ti2d_RSAPublicKey = function (arsa: PRSA; pp: PPByte): cint; cdecl;
  1607. Td2i_RSAPrivateKey = function (arsa: PPRSA; pp: PPByte; len: cint): PRSA; cdecl;
  1608. Ti2d_RSAPrivateKey = function (arsa: PRSA; pp: PPByte): cint; cdecl;
  1609. Td2i_Key = function (a: PPEVP_PKEY; pp: PPByte; len: clong): PRSA; cdecl;
  1610. // ERR Functions
  1611. TErr_Error_String = function (e: cInt; buf: PAnsiChar): PAnsiChar; cdecl;
  1612. // Crypto Functions
  1613. TCRYPTOcleanupAllExData = procedure; cdecl;
  1614. TOPENSSLaddallalgorithms = procedure; cdecl;
  1615. // EVP Functions
  1616. TOpenSSL_add_all_algorithms = procedure(); cdecl;
  1617. TOpenSSL_add_all_ciphers = procedure(); cdecl;
  1618. TOpenSSL_add_all_digests = procedure(); cdecl;
  1619. //
  1620. TEVP_DigestInit = function(ctx: PEVP_MD_CTX; type_: PEVP_MD): cint; cdecl;
  1621. TEVP_DigestUpdate = function(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint; cdecl;
  1622. TEVP_DigestFinal = function(ctx: PEVP_MD_CTX; md: PByte; s: pcuint): cint; cdecl;
  1623. TEVP_SignFinal = function(ctx: pEVP_MD_CTX; sig: pointer; var s: cardinal;
  1624. key: pEVP_PKEY): integer; cdecl;
  1625. TEVP_PKEY_size = function(key: pEVP_PKEY): integer; cdecl;
  1626. TEVP_PKEY_free = Procedure(key: pEVP_PKEY); cdecl;
  1627. TEVP_VerifyFinal = function(ctx: pEVP_MD_CTX; sigbuf: pointer;
  1628. siglen: cardinal; pkey: pEVP_PKEY): integer; cdecl;
  1629. //
  1630. TEVP_CIPHERFunction = function() : PEVP_CIPHER; cdecl;
  1631. TEVP_get_cipherbyname = function(const name: PAnsiChar): PEVP_CIPHER; cdecl;
  1632. TEVP_get_digestbyname = function(const name: PAnsiChar): PEVP_MD; cdecl;
  1633. //
  1634. TEVP_CIPHER_CTX_init = procedure(a: PEVP_CIPHER_CTX); cdecl;
  1635. TEVP_CIPHER_CTX_cleanup = function(a: PEVP_CIPHER_CTX): cint; cdecl;
  1636. TEVP_CIPHER_CTX_reset = function(a: PEVP_CIPHER_CTX): cint; cdecl;
  1637. TEVP_CIPHER_CTX_set_key_length = function(x: PEVP_CIPHER_CTX; keylen: cint): cint; cdecl;
  1638. TEVP_CIPHER_CTX_ctrl = function(ctx: PEVP_CIPHER_CTX; type_, arg: cint; ptr: Pointer): cint; cdecl;
  1639. //
  1640. TEVP_EncryptInit = function(ctx: PEVP_CIPHER_CTX; const chipher_: PEVP_CIPHER;
  1641. const key, iv: PByte): cint; cdecl;
  1642. TEVP_EncryptUpdate = function(ctx: PEVP_CIPHER_CTX; out_: pcuchar;
  1643. outlen: pcint; const in_: pcuchar; inlen: cint): cint; cdecl;
  1644. TEVP_EncryptFinal = function(ctx: PEVP_CIPHER_CTX; out_data: PByte; outlen: pcint): cint; cdecl;
  1645. //
  1646. TEVP_DecryptInit = function(ctx: PEVP_CIPHER_CTX; chiphir_type: PEVP_CIPHER;
  1647. const key, iv: PByte): cint; cdecl;
  1648. TEVP_DecryptUpdate = function(ctx: PEVP_CIPHER_CTX; out_data: PByte;
  1649. outl: pcint; const in_: PByte; inl: cint): cint; cdecl;
  1650. TEVP_DecryptFinal = function(ctx: PEVP_CIPHER_CTX; outm: PByte; outlen: pcint): cint; cdecl;
  1651. //
  1652. TEVP_MD_CTX_new = function(): PEVP_MD_CTX; cdecl;
  1653. TEVP_MD_CTX_free = procedure(ctx: PEVP_MD_CTX); cdecl;
  1654. TEVP_DigestSignVerifyInit = function(ctx: PEVP_MD_CTX; pctx: PPEVP_PKEY_CTX; const evptype: PEVP_MD; e: PENGINE; pkey: PEVP_PKEY): cint; cdecl;
  1655. TEVP_DigestSignFinal = function(ctx: PEVP_MD_CTX; sigret: PByte; siglen: pcsize_t): cint; cdecl;
  1656. TEVP_DigestSign = function(ctx: PEVP_MD_CTX; sigret : Pbyte; siglen : pcsize_t; const tbs : Pbyte; tbslen : csize_t) : cint; cdecl;
  1657. TEVP_DigestVerifyFinal = function(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t): cint; cdecl;
  1658. TEVP_DigestVerify = function(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t; tbs : PByte; tbslen: csize_t): cint; cdecl;
  1659. // PEM functions
  1660. TPEM_read_bio_PrivateKey = function(bp: PBIO; X: PPEVP_PKEY;
  1661. cb: Ppem_password_cb; u: Pointer): PEVP_PKEY; cdecl;
  1662. TPEM_read_bio_PUBKEY = function(bp: pBIO; var x: pEVP_PKEY;
  1663. cb: Ppem_password_cb; u: pointer): pEVP_PKEY; cdecl;
  1664. TPEM_write_bio_PrivateKey = function(bp: pBIO; x: pEVP_PKEY;
  1665. const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
  1666. u: pointer): integer; cdecl;
  1667. TPEM_write_bio_PUBKEY = function(bp: pBIO; x: pEVP_PKEY): integer; cdecl;
  1668. TPEM_read_bio_X509 = function(bp: pBIO; x: PPX509; cb: Ppem_password_cb; u: pointer): px509; cdecl;
  1669. TPEM_write_bio_X509 = function(bp: pBIO; x: PX509): integer; cdecl;
  1670. TPEM_write_bio_PKCS7 = function(bp: pBIO; x: PPKCS7): integer; cdecl;
  1671. // BIO Functions
  1672. TBIO_ctrl = function(bp: PBIO; cmd: cint; larg: clong; parg: Pointer): clong; cdecl;
  1673. TBIO_push = function(b: PBIO; append: PBIO): PBIO;cdecl;
  1674. TBIO_pop = function(b: PBIO): PBIO;cdecl;
  1675. TBIO_gets = function(b: PBIO; buf: PAnsiChar; size: cint): cint;cdecl;
  1676. TBIO_puts = function(b: PBIO; const buf: PAnsiChar): cint;cdecl;
  1677. TBIO_set_mem_eof_return = procedure(b: PBIO; v: cint);cdecl;
  1678. TBIO_set_mem_buf = procedure(b: PBIO; bm: pointer; c: cint);cdecl;
  1679. TBIO_get_mem_ptr = procedure (b: PBIO; var pp: pointer);cdecl;
  1680. TBIO_s_file = function: pBIO_METHOD; cdecl;
  1681. TBIO_new_file = function(const filename: PAnsiChar; const mode: PAnsiChar): pBIO; cdecl;
  1682. TBIO_new_mem_buf = function(buf: pointer; len: integer): pBIO; cdecl;
  1683. var
  1684. // libssl.dll
  1685. _SslGetError: TSslGetError = nil;
  1686. _SslLibraryInit: TSslLibraryInit = nil;
  1687. _OPENSSL_init_ssl : TOPENSSL_init_ssl = Nil;
  1688. _SslLoadErrorStrings: TSslLoadErrorStrings = nil;
  1689. _SslCtxSetCipherList: TSslCtxSetCipherList = nil;
  1690. _SslCtxNew: TSslCtxNew = nil;
  1691. _SslCtxFree: TSslCtxFree = nil;
  1692. _SslSetFd: TSslSetFd = nil;
  1693. _SslCtrl: TSslCtrl = nil;
  1694. _SslCTXCtrl: TSslCTXCtrl = nil;
  1695. _SslMethodV2: TSslMethodV2 = nil;
  1696. _SslMethodV3: TSslMethodV3 = nil;
  1697. _SslMethodTLSV1: TSslMethodTLSV1 = nil;
  1698. _SslMethodTLSV1_1: TSslMethodTLSV1_1 = nil;
  1699. _SslMethodTLSV1_2: TSslMethodTLSV1_2 = nil;
  1700. _SslMethodV23: TSslMethodV23 = nil;
  1701. _SslTLSMethod: TSslTLSMethod = nil;
  1702. _SslCtxUsePrivateKey: TSslCtxUsePrivateKey = nil;
  1703. _SslCtxUsePrivateKeyASN1: TSslCtxUsePrivateKeyASN1 = nil;
  1704. _SslCtxUsePrivateKeyFile: TSslCtxUsePrivateKeyFile = nil;
  1705. _SslCtxUseCertificate: TSslCtxUseCertificate = nil;
  1706. _SslCtxUseCertificateASN1: TSslCtxUseCertificateASN1 = nil;
  1707. _SslCtxUseCertificateFile: TSslCtxUseCertificateFile = nil;
  1708. _SslCtxUseCertificateChainFile: TSslCtxUseCertificateChainFile = nil;
  1709. _SslCtxCheckPrivateKeyFile: TSslCtxCheckPrivateKeyFile = nil;
  1710. _SslCtxSetDefaultPasswdCb: TSslCtxSetDefaultPasswdCb = nil;
  1711. _SslCtxSetDefaultPasswdCbUserdata: TSslCtxSetDefaultPasswdCbUserdata = nil;
  1712. _SslCtxLoadVerifyLocations: TSslCtxLoadVerifyLocations = nil;
  1713. _SslNew: TSslNew = nil;
  1714. _SslFree: TSslFree = nil;
  1715. _SslAccept: TSslAccept = nil;
  1716. _SslConnect: TSslConnect = nil;
  1717. _SslShutdown: TSslShutdown = nil;
  1718. _SslRead: TSslRead = nil;
  1719. _SslPeek: TSslPeek = nil;
  1720. _SslWrite: TSslWrite = nil;
  1721. _SslPending: TSslPending = nil;
  1722. _SslGetVersion: TSslGetVersion = nil;
  1723. _SslGetPeerCertificate: TSslGetPeerCertificate = nil;
  1724. _SslCtxSetVerify: TSslCtxSetVerify = nil;
  1725. _SSLGetCurrentCipher: TSSLGetCurrentCipher = nil;
  1726. _SSLCipherGetName: TSSLCipherGetName = nil;
  1727. _SSLCipherGetBits: TSSLCipherGetBits = nil;
  1728. _SSLGetVerifyResult: TSSLGetVerifyResult = nil;
  1729. _SSLGetServername: TSSLGetServername = nil;
  1730. _SslCtxCallbackCtrl: TSSLCtxCallbackCtrl = nil;
  1731. _SslSetSslCtx: TSSLSetSslCtx = nil;
  1732. _SslSet1Host: TSslSet1Host = nil;
  1733. // libeay.dll
  1734. _OPENSSL_cleanup : TOPENSSL_cleanup = Nil;
  1735. _OPENSSL_INIT_new : TOPENSSL_INIT_new = nil;
  1736. _OPENSSL_INIT_free : TOPENSSL_INIT_free = nil;
  1737. _OPENSSL_INIT_set_config_appname : TOPENSSL_INIT_set_config_appname = Nil;
  1738. _OPENSSL_init_crypto : TOPENSSL_init_ssl = Nil;
  1739. _ERR_load_crypto_strings: TERR_load_crypto_strings = nil;
  1740. _X509New: TX509New = nil;
  1741. _X509Free: TX509Free = nil;
  1742. _X509NameOneline: TX509NameOneline = nil;
  1743. _X509GetSubjectName: TX509GetSubjectName = nil;
  1744. _X509GetIssuerName: TX509GetIssuerName = nil;
  1745. _X509NameHash: TX509NameHash = nil;
  1746. _X509Digest: TX509Digest = nil;
  1747. _X509print: TX509print = nil;
  1748. _X509SetVersion: TX509SetVersion = nil;
  1749. _X509SetPubkey: TX509SetPubkey = nil;
  1750. _X509GetPubkey: TX509GetPubkey = nil;
  1751. _X509SetIssuerName: TX509SetIssuerName = nil;
  1752. _X509NameAddEntryByTxt: TX509NameAddEntryByTxt = nil;
  1753. _X509Sign: TX509Sign = nil;
  1754. _X509GmtimeAdj: TX509GmtimeAdj = nil;
  1755. _X509SetNotBefore: TX509SetNotBefore = nil;
  1756. _X509SetNotAfter: TX509SetNotAfter = nil;
  1757. _X509GetSerialNumber: TX509GetSerialNumber = nil;
  1758. _EvpPkeyNew: TEvpPkeyNew = nil;
  1759. _EvpPkeyFree: TEvpPkeyFree = nil;
  1760. _EvpPkeyAssign: TEvpPkeyAssign = nil;
  1761. _EvpGetDigestByName: TEvpGetDigestByName = nil;
  1762. _EVPcleanup: TEVPcleanup = nil;
  1763. _OpenSSLVersion : TOpenSSLversion = Nil;
  1764. _SSLeayversion: TSSLeayversion = nil;
  1765. _ErrErrorString: TErrErrorString = nil;
  1766. _ErrGetError: TErrGetError = nil;
  1767. _ErrClearError: TErrClearError = nil;
  1768. _ErrFreeStrings: TErrFreeStrings = nil;
  1769. _ErrRemoveState: TErrRemoveState = nil;
  1770. _RandScreen: TRandScreen = nil;
  1771. _BioNew: TBioNew = nil;
  1772. _BioFreeAll: TBioFreeAll = nil;
  1773. _BioSMem: TBioSMem = nil;
  1774. _BioCtrlPending: TBioCtrlPending = nil;
  1775. _BioRead: TBioRead = nil;
  1776. _BioWrite: TBioWrite = nil;
  1777. _d2iPKCS12bio: Td2iPKCS12bio = nil;
  1778. _PKCS12parse: TPKCS12parse = nil;
  1779. _PKCS12free: TPKCS12free = nil;
  1780. _Asn1StringTypeNew: TAsn1StringTypeNew = nil;
  1781. _Asn1UtctimeSetString : TAsn1UtctimeSetString = Nil;
  1782. _Asn1UtctimePrint: TAsn1UtctimePrint = nil;
  1783. _Asn1UtctimeFree: TAsn1UtctimeFree = nil;
  1784. _Asn1IntegerSet: TAsn1IntegerSet = nil;
  1785. _Asn1IntegerGet: TAsn1IntegerGet = nil;
  1786. _i2dX509bio: Ti2dX509bio = nil;
  1787. _d2iX509bio: Td2iX509bio = nil;
  1788. _PEMReadBioX509: TPEMReadBioX509 = nil;
  1789. _SkX509PopFree: TSkX509PopFree = nil;
  1790. _i2dPrivateKeyBio: Ti2dPrivateKeyBio = nil;
  1791. _EVP_enc_null : TEVP_CIPHERFunction = nil;
  1792. _EVP_rc2_cbc : TEVP_CIPHERFunction = nil;
  1793. _EVP_rc2_40_cbc : TEVP_CIPHERFunction = nil;
  1794. _EVP_rc2_64_cbc : TEVP_CIPHERFunction = nil;
  1795. _EVP_rc4 : TEVP_CIPHERFunction = nil;
  1796. _EVP_rc4_40 : TEVP_CIPHERFunction = nil;
  1797. _EVP_des_cbc : TEVP_CIPHERFunction = nil;
  1798. _EVP_des_ede3_cbc : TEVP_CIPHERFunction = nil;
  1799. _EVP_aes_128_cbc : TEVP_CIPHERFunction = nil;
  1800. _EVP_aes_192_cbc : TEVP_CIPHERFunction = nil;
  1801. _EVP_aes_256_cbc : TEVP_CIPHERFunction = nil;
  1802. _EVP_aes_128_cfb8 : TEVP_CIPHERFunction = nil;
  1803. _EVP_aes_192_cfb8 : TEVP_CIPHERFunction = nil;
  1804. _EVP_aes_256_cfb8 : TEVP_CIPHERFunction = nil;
  1805. _EVP_camellia_128_cbc : TEVP_CIPHERFunction = nil;
  1806. _EVP_camellia_192_cbc : TEVP_CIPHERFunction = nil;
  1807. _EVP_camellia_256_cbc : TEVP_CIPHERFunction = nil;
  1808. _EVP_sha256 : TEVP_CIPHERFunction = nil;
  1809. // 3DES functions
  1810. _DESsetoddparity: TDESsetoddparity = nil;
  1811. _DESsetkey : TDESsetkey = nil;
  1812. _DESsetkeychecked: TDESsetkeychecked = nil;
  1813. _DESecbencrypt: TDESecbencrypt = nil;
  1814. //thread lock functions
  1815. _CRYPTOnumlocks: TCRYPTOnumlocks = nil;
  1816. _CRYPTOSetLockingCallback: TCRYPTOSetLockingCallback = nil;
  1817. // RAND functions
  1818. _RAND_set_rand_method: TRAND_set_rand_method = nil;
  1819. _RAND_get_rand_method: TRAND_get_rand_method = nil;
  1820. _RAND_SSLeay: TRAND_SSLeay = nil;
  1821. _RAND_cleanup: TRAND_cleanup = nil;
  1822. _RAND_bytes: TRAND_bytes = nil;
  1823. _RAND_pseudo_bytes: TRAND_pseudo_bytes = nil;
  1824. _RAND_seed: TRAND_seed = nil;
  1825. _RAND_add: TRAND_add = nil;
  1826. _RAND_load_file: TRAND_load_file = nil;
  1827. _RAND_write_file: TRAND_write_file = nil;
  1828. _RAND_file_name: TRAND_file_name = nil;
  1829. _RAND_status: TRAND_status = nil;
  1830. _RAND_query_egd_bytes: TRAND_query_egd_bytes = nil;
  1831. _RAND_egd: TRAND_egd = nil;
  1832. _RAND_egd_bytes: TRAND_egd_bytes = nil;
  1833. _ERR_load_RAND_strings: TERR_load_RAND_strings = nil;
  1834. _RAND_poll: TRAND_poll = nil;
  1835. // RSA Functions
  1836. _RSA_new: TRSA_new = nil;
  1837. _RSA_new_method: TRSA_new_method = nil;
  1838. _RSA_size: TRSA_size = nil;
  1839. _RsaGenerateKey: TRsaGenerateKey = nil;
  1840. _RSA_generate_key_ex: TRSA_generate_key_ex = nil;
  1841. _RSA_check_key: TRSA_check_key = nil;
  1842. _RSA_public_encrypt: TRSA_public_encrypt = nil;
  1843. _RSA_private_encrypt: TRSA_private_encrypt = nil;
  1844. _RSA_public_decrypt: TRSA_public_decrypt = nil;
  1845. _RSA_private_decrypt: TRSA_private_decrypt = nil;
  1846. _RSA_free: TRSA_free = nil;
  1847. _RSA_flags: TRSA_flags = nil;
  1848. _RSA_set_default_method: TRSA_set_default_method = nil;
  1849. _RSA_get_default_method: TRSA_get_default_method = nil;
  1850. _RSA_get_method: TRSA_get_method = nil;
  1851. _RSA_set_method: TRSA_set_method = nil;
  1852. // X509 Functions
  1853. _d2i_RSAPublicKey: Td2i_RSAPublicKey = nil;
  1854. _i2d_RSAPublicKey: Ti2d_RSAPublicKey = nil;
  1855. _d2i_RSAPrivateKey: Td2i_RSAPrivateKey = nil;
  1856. _i2d_RSAPrivateKey: Ti2d_RSAPrivateKey = nil;
  1857. _d2i_PubKey: Td2i_Key = nil;
  1858. _d2i_AutoPrivateKey: Td2i_Key = nil;
  1859. // ERR Functions
  1860. _Err_Error_String: TErr_Error_String = nil;
  1861. // Crypto Functions
  1862. _CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
  1863. _OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
  1864. // EVP Functions
  1865. _OpenSSL_add_all_algorithms: TOpenSSL_add_all_algorithms = nil;
  1866. _OpenSSL_add_all_ciphers: TOpenSSL_add_all_ciphers = nil;
  1867. _OpenSSL_add_all_digests: TOpenSSL_add_all_digests = nil;
  1868. //
  1869. _EVP_DigestInit: TEVP_DigestInit = nil;
  1870. _EVP_DigestUpdate: TEVP_DigestUpdate = nil;
  1871. _EVP_DigestFinal: TEVP_DigestFinal = nil;
  1872. _EVP_SignFinal: TEVP_SignFinal = nil;
  1873. _EVP_PKEY_size: TEVP_PKEY_size = nil;
  1874. _EVP_PKEY_free: TEVP_PKEY_free = nil;
  1875. _EVP_VerifyFinal: TEVP_VerifyFinal = nil;
  1876. //
  1877. _EVP_get_cipherbyname: TEVP_get_cipherbyname = nil;
  1878. _EVP_get_digestbyname: TEVP_get_digestbyname = nil;
  1879. //
  1880. _EVP_CIPHER_CTX_reset: TEVP_CIPHER_CTX_reset = nil;
  1881. _EVP_CIPHER_CTX_init: TEVP_CIPHER_CTX_init = nil;
  1882. _EVP_CIPHER_CTX_cleanup: TEVP_CIPHER_CTX_cleanup = nil;
  1883. _EVP_CIPHER_CTX_set_key_length: TEVP_CIPHER_CTX_set_key_length = nil;
  1884. _EVP_CIPHER_CTX_ctrl: TEVP_CIPHER_CTX_ctrl = nil;
  1885. //
  1886. _EVP_EncryptInit: TEVP_EncryptInit = nil;
  1887. _EVP_EncryptUpdate: TEVP_EncryptUpdate = nil;
  1888. _EVP_EncryptFinal: TEVP_EncryptFinal = nil;
  1889. //
  1890. _EVP_DecryptInit: TEVP_DecryptInit = nil;
  1891. _EVP_DecryptUpdate: TEVP_DecryptUpdate = nil;
  1892. _EVP_DecryptFinal: TEVP_DecryptFinal = nil;
  1893. //
  1894. _EVP_MD_CTX_new : TEVP_MD_CTX_new = nil;
  1895. _EVP_MD_CTX_free : TEVP_MD_CTX_free = nil;
  1896. _EVP_DigestSignInit: TEVP_DigestSignVerifyInit = nil;
  1897. _EVP_DigestSignFinal: TEVP_DigestSignFinal = nil;
  1898. _EVP_DigestSign: TEVP_DigestSign = nil;
  1899. _EVP_DigestVerifyInit: TEVP_DigestSignVerifyInit = nil;
  1900. _EVP_DigestVerifyFinal: TEVP_DigestVerifyFinal = nil;
  1901. _EVP_DigestVerify: TEVP_DigestVerify = nil;
  1902. // PEM
  1903. _PEM_read_bio_PrivateKey: TPEM_read_bio_PrivateKey = nil;
  1904. _PEM_read_bio_PUBKEY: TPEM_read_bio_PUBKEY = nil;
  1905. _PEM_write_bio_PrivateKey: TPEM_write_bio_PrivateKey = nil;
  1906. _PEM_write_bio_PUBKEY: TPEM_write_bio_PUBKEY = nil;
  1907. _PEM_read_bio_X509: TPEM_read_bio_X509 = nil;
  1908. _PEM_write_bio_X509: TPEM_write_bio_X509 = nil;
  1909. _PEM_write_bio_PKCS7 : TPEM_write_bio_PKCS7 = Nil;
  1910. // BIO Functions
  1911. _BIO_ctrl: TBIO_ctrl = nil;
  1912. _BIO_push: TBIO_push = nil;
  1913. _BIO_pop: TBIO_pop = nil;
  1914. _BIO_gets: TBIO_gets = nil;
  1915. _BIO_puts: TBIO_puts = nil;
  1916. _BIO_set_mem_eof_return: TBIO_set_mem_eof_return = nil;
  1917. _BIO_set_mem_buf: TBIO_set_mem_buf = nil;
  1918. _BIO_get_mem_ptr: TBIO_get_mem_ptr = nil;
  1919. _BIO_s_file: TBIO_s_file = nil;
  1920. _BIO_new_file: TBIO_new_file = nil;
  1921. _BIO_new_mem_buf: TBIO_new_mem_buf = nil;
  1922. // PKCS7 functions
  1923. { PKCS7_ISSUER_AND_SERIAL_it : ASN1_ITEM;cvar;external;
  1924. PKCS7_SIGNER_INFO_it : ASN1_ITEM;cvar;external;
  1925. PKCS7_RECIP_INFO_it : ASN1_ITEM;cvar;external;
  1926. PKCS7_SIGNED_it : ASN1_ITEM;cvar;external;
  1927. PKCS7_ENC_CONTENT_it : ASN1_ITEM;cvar;external;
  1928. PKCS7_ENVELOPE_it : ASN1_ITEM;cvar;external;
  1929. PKCS7_SIGN_ENVELOPE_it : ASN1_ITEM;cvar;external;
  1930. PKCS7_DIGEST_it : ASN1_ITEM;cvar;external;
  1931. PKCS7_ENCRYPT_it : ASN1_ITEM;cvar;external;
  1932. PKCS7_it : ASN1_ITEM;cvar;external;
  1933. PKCS7_ATTR_SIGN_it : ASN1_ITEM;cvar;external;
  1934. PKCS7_ATTR_VERIFY_it : ASN1_ITEM;cvar;external;
  1935. }
  1936. _PKCS7_ISSUER_AND_SERIAL_new : function: PPKCS7_ISSUER_AND_SERIAL;cdecl;
  1937. _PKCS7_ISSUER_AND_SERIAL_free : procedure(a:PPKCS7_ISSUER_AND_SERIAL);cdecl;
  1938. _PKCS7_ISSUER_AND_SERIAL_digest : function(data:PPKCS7_ISSUER_AND_SERIAL; _type:PEVP_MD; md:Pbyte; len:Pdword):longint;cdecl;
  1939. _PKCS7_dup : function(p7:PPKCS7):PPKCS7;cdecl;
  1940. _PEM_write_bio_PKCS7_stream : function(_out:PBIO; p7:PPKCS7; _in:PBIO; flags:longint):longint;cdecl;
  1941. _PKCS7_SIGNER_INFO_new : function:PPKCS7_SIGNER_INFO;cdecl;
  1942. _PKCS7_SIGNER_INFO_free : procedure(a:PPKCS7_SIGNER_INFO);cdecl;
  1943. _PKCS7_RECIP_INFO_new : function:PPKCS7_RECIP_INFO;cdecl;
  1944. _PKCS7_RECIP_INFO_free : procedure(a:PPKCS7_RECIP_INFO);cdecl;
  1945. _PKCS7_SIGNED_new : function:PPKCS7_SIGNED;cdecl;
  1946. _PKCS7_SIGNED_free : procedure(a:PPKCS7_SIGNED);cdecl;
  1947. _PKCS7_ENC_CONTENT_new : function:PPKCS7_ENC_CONTENT;cdecl;
  1948. _PKCS7_ENC_CONTENT_free : procedure(a:PPKCS7_ENC_CONTENT);cdecl;
  1949. _PKCS7_ENVELOPE_new : function:PPKCS7_ENVELOPE;cdecl;
  1950. _PKCS7_ENVELOPE_free : procedure(a:PPKCS7_ENVELOPE);cdecl;
  1951. _PKCS7_SIGN_ENVELOPE_new : function:PPKCS7_SIGN_ENVELOPE;cdecl;
  1952. _PKCS7_SIGN_ENVELOPE_free : procedure(a:PPKCS7_SIGN_ENVELOPE);cdecl;
  1953. _PKCS7_DIGEST_new : function:PPKCS7_DIGEST;cdecl;
  1954. _PKCS7_DIGEST_free : procedure(a:PPKCS7_DIGEST);cdecl;
  1955. _PKCS7_ENCRYPT_new : function:PPKCS7_ENCRYPT;cdecl;
  1956. _PKCS7_ENCRYPT_free : procedure(a:PPKCS7_ENCRYPT);cdecl;
  1957. _PKCS7_new : function:PPKCS7;cdecl;
  1958. _PKCS7_free : procedure(a:PPKCS7);cdecl;
  1959. _PKCS7_print_ctx : function(_out:PBIO; x:PPKCS7; indent:longint; pctx:Pointer):longint;cdecl;
  1960. _PKCS7_ctrl : function(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;cdecl;
  1961. _PKCS7_set_type : function(p7:PPKCS7; _type:longint):longint;cdecl;
  1962. _PKCS7_set0_type_other : function(p7:PPKCS7; _type:longint; other:PASN1_TYPE):longint;cdecl;
  1963. _PKCS7_set_content : function(p7:PPKCS7; p7_data:PPKCS7):longint;cdecl;
  1964. _PKCS7_SIGNER_INFO_set : function(p7i:PPKCS7_SIGNER_INFO; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):longint;cdecl;
  1965. _PKCS7_SIGNER_INFO_sign : function(si:PPKCS7_SIGNER_INFO):longint;cdecl;
  1966. _PKCS7_add_signer : function(p7:PPKCS7; p7i:PPKCS7_SIGNER_INFO):longint;cdecl;
  1967. _PKCS7_add_certificate : function(p7:PPKCS7; x509:PX509):longint;cdecl;
  1968. _PKCS7_add_crl : function(p7:PPKCS7; x509: Pointer):longint;cdecl;
  1969. _PKCS7_content_new : function(p7:PPKCS7; nid:longint):longint;cdecl;
  1970. _PKCS7_add_signature : function(p7:PPKCS7; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):PPKCS7_SIGNER_INFO;cdecl;
  1971. _PKCS7_cert_from_signer_info : function(p7:PPKCS7; si:PPKCS7_SIGNER_INFO):PX509;cdecl;
  1972. _PKCS7_set_digest : function(p7:PPKCS7; md:PEVP_MD):longint;cdecl;
  1973. _PKCS7_add_recipient : function(p7:PPKCS7; x509:PX509):PPKCS7_RECIP_INFO;cdecl;
  1974. _PKCS7_add_recipient_info : function(p7:PPKCS7; ri:PPKCS7_RECIP_INFO):longint;cdecl;
  1975. _PKCS7_RECIP_INFO_set : function(p7i:PPKCS7_RECIP_INFO; x509:PX509):longint;cdecl;
  1976. _PKCS7_set_cipher : function(p7:PPKCS7; cipher:PEVP_CIPHER):longint;cdecl;
  1977. _PKCS7_get_issuer_and_serial : function(p7:PPKCS7; idx:longint):PPKCS7_ISSUER_AND_SERIAL;cdecl;
  1978. _PKCS7_digest_from_attributes : function(sk:Pstack_st_X509_ATTRIBUTE):Pointer;cdecl;
  1979. _PKCS7_add_signed_attribute : function(p7si:PPKCS7_SIGNER_INFO; nid:longint; _type:longint; data:pointer):longint;cdecl;
  1980. _PKCS7_add_attribute : function(p7si:PPKCS7_SIGNER_INFO; nid:longint; atrtype:longint; value:pointer):longint;cdecl;
  1981. _PKCS7_get_attribute : function(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;cdecl;
  1982. _PKCS7_get_signed_attribute : function(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;cdecl;
  1983. _PKCS7_set_signed_attributes : function(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;cdecl;
  1984. _PKCS7_set_attributes : function(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;cdecl;
  1985. _PKCS7_sign : function(signcert:PX509; pkey:PEVP_PKEY; certs:Pstack_st_X509; data:PBIO; flags:longint):PPKCS7;cdecl;
  1986. _PKCS7_sign_add_signer : function(p7:PPKCS7; signcert:PX509; pkey:PEVP_PKEY; md:PEVP_MD; flags:longint):PPKCS7_SIGNER_INFO;cdecl;
  1987. _PKCS7_final : function(p7:PPKCS7; data:PBIO; flags:longint):longint;cdecl;
  1988. _PKCS7_verify : function(p7:PPKCS7; certs:Pstack_st_X509; store: Pointer; indata:PBIO; _out:PBIO; flags:longint):longint;cdecl;
  1989. _PKCS7_encrypt : function(certs:Pstack_st_X509; _in:PBIO; cipher:PEVP_CIPHER; flags:longint):PPKCS7;cdecl;
  1990. _PKCS7_decrypt : function(p7:PPKCS7; pkey:PEVP_PKEY; cert:PX509; data:PBIO; flags:longint):longint;cdecl;
  1991. _PKCS7_add_attrib_smimecap : function(si:PPKCS7_SIGNER_INFO; cap:Pstack_st_X509_ALGOR):longint;cdecl;
  1992. _PKCS7_simple_smimecap : function(sk:Pstack_st_X509_ALGOR; nid:longint; arg:longint):longint;cdecl;
  1993. _PKCS7_add_attrib_content_type : function(si:PPKCS7_SIGNER_INFO; coid:Pointer):longint;cdecl;
  1994. _PKCS7_add0_attrib_signing_time : function(si:PPKCS7_SIGNER_INFO; t:PASN1_TIME):longint;cdecl;
  1995. _PKCS7_add1_attrib_digest : function(si:PPKCS7_SIGNER_INFO; md:Pbyte; mdlen:longint):longint;cdecl;
  1996. _BIO_new_PKCS7 : function(_out:PBIO; p7:PPKCS7):PBIO;cdecl;
  1997. _ERR_load_PKCS7_strings : procedure;cdecl;
  1998. // SMIME
  1999. _SMIME_write_PKCS7: function(_out: PBIO; p7: PPKCS7; data: PBIO; flags: longint): longint; cdecl;
  2000. _SMIME_read_PKCS7: function(_in: PBIO; bcont: PPBIO): PPKCS7; cdecl;
  2001. // BN
  2002. _BN_new : function():PBIGNUM; cdecl;
  2003. _BN_secure_new : function():PBIGNUM; cdecl;
  2004. _BN_clear_free : procedure(a:PBIGNUM); cdecl;
  2005. _BN_copy : function(a:PBIGNUM; b:PBIGNUM):PBIGNUM; cdecl;
  2006. _BN_swap : procedure(a:PBIGNUM; b:PBIGNUM); cdecl;
  2007. _BN_bin2bn : function(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM; cdecl;
  2008. _BN_bn2bin : function(a:PBIGNUM; _to:pcuchar):cint; cdecl;
  2009. _BN_bn2binpad : function(a:PBIGNUM; _to:pcuchar; tolen:cint):cint; cdecl;
  2010. _BN_lebin2bn : function(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM; cdecl;
  2011. _BN_bn2lebinpad : function(a:PBIGNUM; _to:pcuchar; tolen:cint):cint; cdecl;
  2012. _BN_mpi2bn : function(s:pcuchar; len:cint; ret:PBIGNUM):PBIGNUM; cdecl;
  2013. _BN_bn2mpi : function(a:PBIGNUM; _to:pcuchar):cint;cdecl;
  2014. _BN_sub : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint; cdecl;
  2015. _BN_usub : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint; cdecl;
  2016. _BN_uadd : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint; cdecl;
  2017. _BN_add : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM):cint; cdecl;
  2018. _BN_mul : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2019. _BN_sqr : function(r:PBIGNUM; a:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2020. _BN_set_negative : procedure(b:PBIGNUM; n:cint);cdecl;
  2021. _BN_is_negative : function(b:PBIGNUM):cint;cdecl;
  2022. _BN_div : function(dv:PBIGNUM; rem:PBIGNUM; m:PBIGNUM; d:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2023. _BN_mod : function(rem: PBIGNUM; a:PBIGNUM; m: PBIGNUM; ctx : PBN_CTX) : cint; cdecl;
  2024. _BN_nnmod : function(r:PBIGNUM; m:PBIGNUM; d:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2025. _BN_mod_add : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2026. _BN_mod_add_quick : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM):cint; cdecl;
  2027. _BN_mod_sub : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2028. _BN_mod_sub_quick : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM):cint; cdecl;
  2029. _BN_mod_mul : function(r:PBIGNUM; a:PBIGNUM; b:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2030. _BN_mod_sqr : function(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2031. _BN_mod_lshift1 : function(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2032. _BN_mod_lshift1_quick : function(r:PBIGNUM; a:PBIGNUM; m:PBIGNUM):cint; cdecl;
  2033. _BN_mod_lshift : function(r:PBIGNUM; a:PBIGNUM; n:cint; m:PBIGNUM; ctx:PBN_CTX):cint; cdecl;
  2034. _BN_mod_lshift_quick : function(r:PBIGNUM; a:PBIGNUM; n:cint; m:PBIGNUM):cint; cdecl;
  2035. _BN_mod_word : function(a:PBIGNUM; w:BN_ULONG):BN_ULONG; cdecl;
  2036. _BN_div_word : function(a:PBIGNUM; w:BN_ULONG):BN_ULONG; cdecl;
  2037. _BN_mul_word : function(a:PBIGNUM; w:BN_ULONG):cint; cdecl;
  2038. _BN_add_word : function(a:PBIGNUM; w:BN_ULONG):cint; cdecl;
  2039. _BN_sub_word : function(a:PBIGNUM; w:BN_ULONG):cint; cdecl;
  2040. _BN_set_word : function(a:PBIGNUM; w:BN_ULONG):cint; cdecl;
  2041. _BN_get_word : function(a:PBIGNUM):BN_ULONG; cdecl;
  2042. _BN_cmp : function(a:PBIGNUM; b:PBIGNUM):cint; cdecl;
  2043. _BN_free : procedure(a:PBIGNUM); cdecl;
  2044. // libssl.dll
  2045. function SslGetError(s: PSSL; ret_code: cInt):cInt;
  2046. begin
  2047. if InitSSLInterface and Assigned(_SslGetError) then
  2048. Result := _SslGetError(s, ret_code)
  2049. else
  2050. Result := SSL_ERROR_SSL;
  2051. end;
  2052. Function OPENSSL_init_ssl(opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
  2053. begin
  2054. Result := 1;
  2055. if InitSSLInterface and Assigned(_OPENSSL_init_ssl) then
  2056. Result:=_OPENSSL_init_ssl(opts,settings);
  2057. end;
  2058. function SslLibraryInit:cInt;
  2059. begin
  2060. Result := 1;
  2061. if InitSSLInterface then
  2062. if Assigned(_SslLibraryInit) then
  2063. Result := _SslLibraryInit
  2064. else if Assigned(_OPENSSL_init_ssl) then
  2065. Result:=_OPENSSL_init_ssl(0,Nil)
  2066. end;
  2067. procedure SslLoadErrorStrings;
  2068. begin
  2069. if InitSSLInterface then
  2070. if Assigned(_SslLoadErrorStrings) then
  2071. _SslLoadErrorStrings
  2072. else if Assigned(_OpenSSl_init_ssl) then
  2073. _OpenSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS or OPENSSL_INIT_LOAD_CRYPTO_STRINGS,Nil)
  2074. end;
  2075. function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):cInt;
  2076. begin
  2077. if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
  2078. Result := _SslCtxSetCipherList(arg0, PAnsiChar(str))
  2079. else
  2080. Result := 0;
  2081. end;
  2082. function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
  2083. begin
  2084. if InitSSLInterface and Assigned(_SslCtxNew) then
  2085. Result := _SslCtxNew(meth)
  2086. else
  2087. Result := nil;
  2088. end;
  2089. procedure SslCtxFree(arg0: PSSL_CTX);
  2090. begin
  2091. if InitSSLInterface and Assigned(_SslCtxFree) then
  2092. _SslCtxFree(arg0);
  2093. end;
  2094. function SslSetFd(s: PSSL; fd: cInt):cInt;
  2095. begin
  2096. if InitSSLInterface and Assigned(_SslSetFd) then
  2097. Result := _SslSetFd(s, fd)
  2098. else
  2099. Result := 0;
  2100. end;
  2101. function SslCtrl(ssl: PSSL; cmd: cInt; larg: clong; parg: Pointer): cLong;
  2102. begin
  2103. if InitSSLInterface and Assigned(_SslCtrl) then
  2104. Result := _SslCtrl(ssl, cmd, larg, parg)
  2105. else
  2106. Result := 0;
  2107. end;
  2108. function SslCTXCtrl(ctx: PSSL_CTX; cmd: cInt; larg: clong; parg: Pointer
  2109. ): cLong;
  2110. begin
  2111. if InitSSLInterface and Assigned(_SslCTXCtrl) then
  2112. Result := _SslCTXCtrl(ctx, cmd, larg, parg)
  2113. else
  2114. Result := 0;
  2115. end;
  2116. function SSLCTXSetMode(ctx: PSSL_CTX; mode: cLong): cLong;
  2117. begin
  2118. Result := SslCTXCtrl(ctx, SSL_CTRL_MODE, mode, nil);
  2119. end;
  2120. function SSLSetMode(s: PSSL; mode: cLong): cLong;
  2121. begin
  2122. Result := SSLctrl(s, SSL_CTRL_MODE, mode, nil);
  2123. end;
  2124. function SSLCTXGetMode(ctx: PSSL_CTX): cLong;
  2125. begin
  2126. Result := SSLCTXctrl(ctx, SSL_CTRL_MODE, 0, nil);
  2127. end;
  2128. function SSLGetMode(s: PSSL): cLong;
  2129. begin
  2130. Result := SSLctrl(s, SSL_CTRL_MODE, 0, nil);
  2131. end;
  2132. function SslMethodV2:PSSL_METHOD;
  2133. begin
  2134. if InitSSLInterface and Assigned(_SslMethodV2) then
  2135. Result := _SslMethodV2
  2136. else
  2137. Result := nil;
  2138. end;
  2139. function SslMethodV3:PSSL_METHOD;
  2140. begin
  2141. if InitSSLInterface and Assigned(_SslMethodV3) then
  2142. Result := _SslMethodV3
  2143. else
  2144. Result := nil;
  2145. end;
  2146. function SslMethodTLSV1:PSSL_METHOD;
  2147. begin
  2148. if InitSSLInterface and Assigned(_SslMethodTLSV1) then
  2149. Result := _SslMethodTLSV1
  2150. else
  2151. Result := nil;
  2152. end;
  2153. function SslMethodTLSV1_1:PSSL_METHOD;
  2154. begin
  2155. if InitSSLInterface and Assigned(_SslMethodTLSV1_1) then
  2156. Result := _SslMethodTLSV1_1
  2157. else
  2158. Result := nil;
  2159. end;
  2160. function SslMethodTLSV1_2:PSSL_METHOD;
  2161. begin
  2162. if InitSSLInterface and Assigned(_SslMethodTLSV1_2) then
  2163. Result := _SslMethodTLSV1_2
  2164. else
  2165. Result := nil;
  2166. end;
  2167. function SslMethodV23:PSSL_METHOD;
  2168. begin
  2169. if InitSSLInterface and Assigned(_SslMethodV23) then
  2170. Result := _SslMethodV23
  2171. else
  2172. Result := nil;
  2173. end;
  2174. function SslTLSMethod:PSSL_METHOD;
  2175. begin
  2176. if InitSSLInterface and Assigned(_SslTLSMethod) then
  2177. Result := _SslTLSMethod
  2178. else
  2179. Result := nil;
  2180. end;
  2181. function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):cInt;
  2182. begin
  2183. if InitSSLInterface and Assigned(_SslCtxUsePrivateKey) then
  2184. Result := _SslCtxUsePrivateKey(ctx, pkey)
  2185. else
  2186. Result := 0;
  2187. end;
  2188. function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: AnsiString; len: cLong):cInt; overload;
  2189. begin
  2190. if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
  2191. Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
  2192. else
  2193. Result := 0;
  2194. end;
  2195. function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; b: TBytes; len: cLong): cInt;overload;
  2196. begin
  2197. if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
  2198. Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(b), len)
  2199. else
  2200. Result := 0;
  2201. end;
  2202. function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
  2203. begin
  2204. if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
  2205. Result := _SslCtxUsePrivateKeyFile(ctx, PAnsiChar(_file), _type)
  2206. else
  2207. Result := 0;
  2208. end;
  2209. function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):cInt;
  2210. begin
  2211. if InitSSLInterface and Assigned(_SslCtxUseCertificate) then
  2212. Result := _SslCtxUseCertificate(ctx, x)
  2213. else
  2214. Result := 0;
  2215. end;
  2216. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: AnsiString):cInt;
  2217. begin
  2218. if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
  2219. Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
  2220. else
  2221. Result := 0;
  2222. end;
  2223. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; Buf: TBytes): cInt;
  2224. begin
  2225. if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
  2226. Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(Buf))
  2227. else
  2228. Result := 0;
  2229. end;
  2230. function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
  2231. begin
  2232. if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
  2233. Result := _SslCtxUseCertificateFile(ctx, PAnsiChar(_file), _type)
  2234. else
  2235. Result := 0;
  2236. end;
  2237. function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):cInt;
  2238. begin
  2239. if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
  2240. Result := _SslCtxUseCertificateChainFile(ctx, PAnsiChar(_file))
  2241. else
  2242. Result := 0;
  2243. end;
  2244. function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):cInt;
  2245. begin
  2246. if InitSSLInterface and Assigned(_SslCtxCheckPrivateKeyFile) then
  2247. Result := _SslCtxCheckPrivateKeyFile(ctx)
  2248. else
  2249. Result := 0;
  2250. end;
  2251. procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
  2252. begin
  2253. if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCb) then
  2254. _SslCtxSetDefaultPasswdCb(ctx, cb);
  2255. end;
  2256. procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
  2257. begin
  2258. if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCbUserdata) then
  2259. _SslCtxSetDefaultPasswdCbUserdata(ctx, u);
  2260. end;
  2261. function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):cInt;
  2262. begin
  2263. if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
  2264. Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
  2265. else
  2266. Result := 0;
  2267. end;
  2268. function SslNew(ctx: PSSL_CTX):PSSL;
  2269. begin
  2270. if InitSSLInterface and Assigned(_SslNew) then
  2271. Result := _SslNew(ctx)
  2272. else
  2273. Result := nil;
  2274. end;
  2275. procedure SslFree(ssl: PSSL);
  2276. begin
  2277. if InitSSLInterface and Assigned(_SslFree) then
  2278. _SslFree(ssl);
  2279. end;
  2280. function SslAccept(ssl: PSSL):cInt;
  2281. begin
  2282. if InitSSLInterface and Assigned(_SslAccept) then
  2283. Result := _SslAccept(ssl)
  2284. else
  2285. Result := -1;
  2286. end;
  2287. function SslConnect(ssl: PSSL):cInt;
  2288. begin
  2289. if InitSSLInterface and Assigned(_SslConnect) then
  2290. Result := _SslConnect(ssl)
  2291. else
  2292. Result := -1;
  2293. end;
  2294. function SslShutdown(ssl: PSSL):cInt;
  2295. begin
  2296. if InitSSLInterface and Assigned(_SslShutdown) then
  2297. Result := _SslShutdown(ssl)
  2298. else
  2299. Result := -1;
  2300. end;
  2301. function SslRead(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  2302. begin
  2303. if InitSSLInterface and Assigned(_SslRead) then
  2304. Result := _SslRead(ssl, PAnsiChar(buf), num)
  2305. else
  2306. Result := -1;
  2307. end;
  2308. function SslPeek(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  2309. begin
  2310. if InitSSLInterface and Assigned(_SslPeek) then
  2311. Result := _SslPeek(ssl, PAnsiChar(buf), num)
  2312. else
  2313. Result := -1;
  2314. end;
  2315. function SslWrite(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
  2316. begin
  2317. if InitSSLInterface and Assigned(_SslWrite) then
  2318. Result := _SslWrite(ssl, PAnsiChar(buf), num)
  2319. else
  2320. Result := -1;
  2321. end;
  2322. function SslPending(ssl: PSSL):cInt;
  2323. begin
  2324. if InitSSLInterface and Assigned(_SslPending) then
  2325. Result := _SslPending(ssl)
  2326. else
  2327. Result := 0;
  2328. end;
  2329. function OpenSSLGetVersion(t: cint):AnsiString;
  2330. begin
  2331. if InitSSLInterface and Assigned(_OpenSSLVersion) then
  2332. Result := _OpenSSLVersion(t)
  2333. else
  2334. Result := '';
  2335. end;
  2336. //function SslGetVersion(ssl: PSSL):PAnsiChar;
  2337. function SslGetVersion(ssl: PSSL):AnsiString;
  2338. begin
  2339. if InitSSLInterface and Assigned(_SslGetVersion) then
  2340. Result := _SslGetVersion(ssl)
  2341. else
  2342. Result := '';
  2343. end;
  2344. function SslGetPeerCertificate(ssl: PSSL):PX509;
  2345. begin
  2346. if InitSSLInterface and Assigned(_SslGetPeerCertificate) then
  2347. Result := _SslGetPeerCertificate(ssl)
  2348. else
  2349. Result := nil;
  2350. end;
  2351. procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: cInt; arg2: TSSLCTXVerifyCallback);
  2352. begin
  2353. if InitSSLInterface and Assigned(_SslCtxSetVerify) then
  2354. _SslCtxSetVerify(ctx, mode, @arg2);
  2355. end;
  2356. function SSLGetCurrentCipher(s: PSSL):SslPtr;
  2357. begin
  2358. if InitSSLInterface and Assigned(_SSLGetCurrentCipher) then
  2359. {$IFDEF CIL}
  2360. {$ELSE}
  2361. Result := _SSLGetCurrentCipher(s)
  2362. {$ENDIF}
  2363. else
  2364. Result := nil;
  2365. end;
  2366. function SSLCipherGetName(c: SslPtr):AnsiString;
  2367. begin
  2368. if InitSSLInterface and Assigned(_SSLCipherGetName) then
  2369. Result := _SSLCipherGetName(c)
  2370. else
  2371. Result := '';
  2372. end;
  2373. function SSLCipherGetBits(c: SslPtr; var alg_bits: cInt):cInt;
  2374. begin
  2375. if InitSSLInterface and Assigned(_SSLCipherGetBits) then
  2376. Result := _SSLCipherGetBits(c, @alg_bits)
  2377. else
  2378. Result := 0;
  2379. end;
  2380. function SSLGetVerifyResult(ssl: PSSL):cLong;
  2381. begin
  2382. if InitSSLInterface and Assigned(_SSLGetVerifyResult) then
  2383. Result := _SSLGetVerifyResult(ssl)
  2384. else
  2385. Result := X509_V_ERR_APPLICATION_VERIFICATION;
  2386. end;
  2387. function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): AnsiString;
  2388. begin
  2389. if InitSSLInterface and Assigned(_SSLGetServername) then
  2390. result := PAnsiChar(_SSLGetServername(ssl, _type))
  2391. else
  2392. result := '';
  2393. end;
  2394. procedure SslCtxCallbackCtrl(ssl: PSSL; _type: cInt; cb: PCallbackCb);
  2395. begin
  2396. if InitSSLInterface and Assigned(_SslCtxCallbackCtrl) then
  2397. _SslCtxCallbackCtrl(ssl, _type, cb);
  2398. end;
  2399. function SslSetSslCtx(ssl: PSSL; ctx: PSSL_CTX): PSSL;
  2400. begin
  2401. if InitSSLInterface and Assigned(_SslSetSslCtx) then
  2402. result := _SslSetSslCtx(ssl, ctx)
  2403. else
  2404. result := nil;
  2405. end;
  2406. function SslSet1Host(ssl: PSSL; hostname: string): cInt;
  2407. begin
  2408. if InitSSLInterface and Assigned(_SslSet1Host) then
  2409. result := _SslSet1Host(ssl, hostname)
  2410. else
  2411. result := 0;
  2412. end;
  2413. // libeay.dll
  2414. function SSLeayversion(t: cInt): AnsiString;
  2415. begin
  2416. if InitSSLInterface and Assigned(_SSLeayversion) then
  2417. Result := PAnsiChar(_SSLeayversion(t))
  2418. else
  2419. Result := '';
  2420. end;
  2421. Procedure OPENSSL_cleanup;
  2422. begin
  2423. if InitSSLInterface and Assigned(_OPENSSL_cleanup) then
  2424. _OPENSSL_cleanup();
  2425. end;
  2426. function OPENSSL_INIT_new : POPENSSL_INIT_SETTINGS;
  2427. begin
  2428. if InitsslInterface and assigned(_OPENSSL_INIT_new) then
  2429. Result:=_OPENSSL_INIT_new()
  2430. else
  2431. result:=nil;
  2432. end;
  2433. procedure OPENSSL_INIT_free(aSettings : POPENSSL_INIT_SETTINGS);
  2434. begin
  2435. if InitsslInterface and assigned(_OPENSSL_INIT_free) then
  2436. _OPENSSL_INIT_free(aSettings);
  2437. end;
  2438. function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint;
  2439. begin
  2440. if InitsslInterface and assigned(_OPENSSL_INIT_set_config_appname) then
  2441. Result:=_OPENSSL_INIT_set_config_appname(Settings,config_file)
  2442. else
  2443. Result:=1;
  2444. end;
  2445. Function OPENSSL_init_crypto ( opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
  2446. begin
  2447. if InitSSLInterface and Assigned(_OPENSSL_init_crypto) then
  2448. Result:=_OPENSSL_init_crypto(opts,Settings)
  2449. else
  2450. Result:=1;
  2451. end;
  2452. procedure ERR_load_crypto_strings;
  2453. Begin
  2454. if InitSSLInterface then
  2455. if Assigned(_ERR_load_crypto_strings) then
  2456. _ERR_load_crypto_strings
  2457. else if Assigned(_OPENSSL_init_crypto) then
  2458. _OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS,Nil);
  2459. end;
  2460. function X509New: PX509;
  2461. begin
  2462. if InitSSLInterface and Assigned(_X509New) then
  2463. Result := _X509New
  2464. else
  2465. Result := nil;
  2466. end;
  2467. procedure X509Free(x: PX509);
  2468. begin
  2469. if InitSSLInterface and Assigned(_X509Free) then
  2470. _X509Free(x);
  2471. end;
  2472. function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: cInt):AnsiString;
  2473. begin
  2474. if InitSSLInterface and Assigned(_X509NameOneline) then
  2475. Result := _X509NameOneline(a, PAnsiChar(buf),size)
  2476. else
  2477. Result := '';
  2478. end;
  2479. function X509GetSubjectName(a: PX509):PX509_NAME;
  2480. begin
  2481. if InitSSLInterface and Assigned(_X509GetSubjectName) then
  2482. Result := _X509GetSubjectName(a)
  2483. else
  2484. Result := nil;
  2485. end;
  2486. function X509GetIssuerName(a: PX509):PX509_NAME;
  2487. begin
  2488. if InitSSLInterface and Assigned(_X509GetIssuerName) then
  2489. Result := _X509GetIssuerName(a)
  2490. else
  2491. Result := nil;
  2492. end;
  2493. function X509NameHash(x: PX509_NAME):cuLong;
  2494. begin
  2495. if InitSSLInterface and Assigned(_X509NameHash) then
  2496. Result := _X509NameHash(x)
  2497. else
  2498. Result := 0;
  2499. end;
  2500. function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: cInt):cInt;
  2501. begin
  2502. if InitSSLInterface and Assigned(_X509Digest) then
  2503. Result := _X509Digest(data, _type, PAnsiChar(md), @len)
  2504. else
  2505. Result := 0;
  2506. end;
  2507. function EvpPkeyNew: PEVP_PKEY;
  2508. begin
  2509. if InitSSLInterface and Assigned(_EvpPkeyNew) then
  2510. Result := _EvpPkeyNew
  2511. else
  2512. Result := nil;
  2513. end;
  2514. procedure EvpPkeyFree(pk: PEVP_PKEY);
  2515. begin
  2516. if InitSSLInterface and Assigned(_EvpPkeyFree) then
  2517. _EvpPkeyFree(pk);
  2518. end;
  2519. procedure ErrErrorString(e: cInt; var buf: AnsiString; len: cInt);
  2520. begin
  2521. if InitSSLInterface and Assigned(_ErrErrorString) then
  2522. _ErrErrorString(e, @buf[1], len)
  2523. else
  2524. buf := SFailedToLoadOpenSSL;
  2525. buf := PAnsiChar(Buf);
  2526. end;
  2527. function ErrGetError: cInt;
  2528. begin
  2529. if InitSSLInterface and Assigned(_ErrGetError) then
  2530. Result := _ErrGetError
  2531. else
  2532. Result := SSL_ERROR_SSL;
  2533. end;
  2534. procedure ErrClearError;
  2535. begin
  2536. if InitSSLInterface and Assigned(_ErrClearError) then
  2537. _ErrClearError;
  2538. end;
  2539. procedure ErrFreeStrings;
  2540. begin
  2541. if InitSSLInterface and Assigned(_ErrFreeStrings) then
  2542. _ErrFreeStrings;
  2543. end;
  2544. procedure ErrRemoveState(pid: cInt);
  2545. begin
  2546. if InitSSLInterface and Assigned(_ErrRemoveState) then
  2547. _ErrRemoveState(pid);
  2548. end;
  2549. procedure EVPcleanup;
  2550. begin
  2551. if InitSSLInterface and Assigned(_EVPcleanup) then
  2552. _EVPcleanup;
  2553. end;
  2554. procedure RandScreen;
  2555. begin
  2556. if InitSSLInterface and Assigned(_RandScreen) then
  2557. _RandScreen;
  2558. end;
  2559. function BioNew(b: PBIO_METHOD): PBIO;
  2560. begin
  2561. if InitSSLInterface and Assigned(_BioNew) then
  2562. Result := _BioNew(b)
  2563. else
  2564. Result := nil;
  2565. end;
  2566. procedure BioFreeAll(b: PBIO);
  2567. begin
  2568. if InitSSLInterface and Assigned(_BioFreeAll) then
  2569. _BioFreeAll(b);
  2570. end;
  2571. function BioSMem: PBIO_METHOD;
  2572. begin
  2573. if InitSSLInterface and Assigned(_BioSMem) then
  2574. Result := _BioSMem
  2575. else
  2576. Result := nil;
  2577. end;
  2578. function BioCtrlPending(b: PBIO): cInt;
  2579. begin
  2580. if InitSSLInterface and Assigned(_BioCtrlPending) then
  2581. Result := _BioCtrlPending(b)
  2582. else
  2583. Result := 0;
  2584. end;
  2585. function BioRead(b: PBIO; Buf: TBytes; Len: cInt): cInt;
  2586. begin
  2587. if InitSSLInterface and Assigned(_BioRead) then
  2588. Result := _BioRead(b, PAnsiChar(Buf), Len)
  2589. else
  2590. Result := -2;
  2591. end;
  2592. function BioRead(b: PBIO; var Buf: AnsiString; Len: cInt): cInt;
  2593. begin
  2594. if InitSSLInterface and Assigned(_BioRead) then
  2595. Result := _BioRead(b, PAnsiChar(Buf), Len)
  2596. else
  2597. Result := -2;
  2598. end;
  2599. //function BioWrite(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt;
  2600. function BioWrite(b: PBIO; Buf: AnsiString; Len: cInt): cInt;
  2601. begin
  2602. if InitSSLInterface and Assigned(_BioWrite) then
  2603. Result := _BioWrite(b, PAnsiChar(Buf), Len)
  2604. else
  2605. Result := -2;
  2606. end;
  2607. function BioWrite(b: PBIO; Buf: TBytes; Len: cInt): cInt;
  2608. begin
  2609. if InitSSLInterface and Assigned(_BioWrite) then
  2610. Result := _BioWrite(b, PAnsiChar(Buf), Len)
  2611. else
  2612. Result := -2;
  2613. end;
  2614. function X509print(b: PBIO; a: PX509): cInt;
  2615. begin
  2616. if InitSSLInterface and Assigned(_X509print) then
  2617. Result := _X509print(b, a)
  2618. else
  2619. Result := 0;
  2620. end;
  2621. function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
  2622. begin
  2623. if InitSSLInterface and Assigned(_d2iPKCS12bio) then
  2624. Result := _d2iPKCS12bio(b, Pkcs12)
  2625. else
  2626. Result := nil;
  2627. end;
  2628. function PKCS12parse(p12: SslPtr; pass: AnsiString; var pkey, cert, ca: SslPtr): cInt;
  2629. begin
  2630. if InitSSLInterface and Assigned(_PKCS12parse) then
  2631. Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
  2632. else
  2633. Result := 0;
  2634. end;
  2635. procedure PKCS12free(p12: SslPtr);
  2636. begin
  2637. if InitSSLInterface and Assigned(_PKCS12free) then
  2638. _PKCS12free(p12);
  2639. end;
  2640. function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
  2641. begin
  2642. if InitSSLInterface and Assigned(_EvpPkeyAssign) then
  2643. Result := _EvpPkeyAssign(pkey, _type, key)
  2644. else
  2645. Result := 0;
  2646. end;
  2647. function X509SetVersion(x: PX509; version: cInt): cInt;
  2648. begin
  2649. if InitSSLInterface and Assigned(_X509SetVersion) then
  2650. Result := _X509SetVersion(x, version)
  2651. else
  2652. Result := 0;
  2653. end;
  2654. function X509SetPubkey(x: PX509; pkey: PEVP_PKEY): cInt;
  2655. begin
  2656. if InitSSLInterface and Assigned(_X509SetPubkey) then
  2657. Result := _X509SetPubkey(x, pkey)
  2658. else
  2659. Result := 0;
  2660. end;
  2661. function X509GetPubkey(x: PX509): PEVP_PKEY;
  2662. begin
  2663. if InitSSLInterface and Assigned(_X509GetPubkey) then
  2664. Result := _X509GetPubkey(x)
  2665. else
  2666. Result := Nil;
  2667. end;
  2668. function X509SetIssuerName(x: PX509; name: PX509_NAME): cInt;
  2669. begin
  2670. if InitSSLInterface and Assigned(_X509SetIssuerName) then
  2671. Result := _X509SetIssuerName(x, name)
  2672. else
  2673. Result := 0;
  2674. end;
  2675. function X509NameAddEntryByTxt(name: PX509_NAME; field: AnsiString; _type: cInt;
  2676. bytes: AnsiString; len, loc, _set: cInt): cInt;
  2677. begin
  2678. if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
  2679. Result := _X509NameAddEntryByTxt(name, PAnsiChar(field), _type, PAnsiChar(Bytes), len, loc, _set)
  2680. else
  2681. Result := 0;
  2682. end;
  2683. function X509Sign(x: PX509; pkey: PEVP_PKEY; const md: PEVP_MD): cInt;
  2684. begin
  2685. if InitSSLInterface and Assigned(_X509Sign) then
  2686. Result := _X509Sign(x, pkey, md)
  2687. else
  2688. Result := 0;
  2689. end;
  2690. function Asn1UtctimeNew: PASN1_UTCTIME;
  2691. begin
  2692. Result:=PASN1_UTCTIME(Asn1StringTypeNew(V_ASN1_UTCTIME));
  2693. end;
  2694. function Asn1StringTypeNew(aType : cint): PASN1_STRING;
  2695. begin
  2696. if InitSSLInterface and Assigned(_Asn1StringTypeNew) then
  2697. Result := _Asn1StringTypeNew(aType)
  2698. else
  2699. Result := nil;
  2700. end;
  2701. procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
  2702. begin
  2703. if InitSSLInterface and Assigned(_Asn1UtctimeFree) then
  2704. _Asn1UtctimeFree(a);
  2705. end;
  2706. function Asn1UtctimePrint(b: PBio; a: PASN1_UTCTIME): integer;
  2707. begin
  2708. if InitSSLInterface and Assigned(_Asn1UtctimePrint) then
  2709. Result:=_Asn1UtctimePrint(b,a)
  2710. else
  2711. Result:=0;
  2712. end;
  2713. function ASN1UtcTimeSetString(t: PASN1_UTCTIME; s: PAnsichar): cint;
  2714. begin
  2715. if InitSSLInterface and Assigned(_Asn1UtctimeSetString) then
  2716. Result:=_Asn1UtctimeSetString(t,s)
  2717. else
  2718. Result:=0;
  2719. end;
  2720. function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
  2721. begin
  2722. if InitSSLInterface and Assigned(_Asn1IntegerSet) then
  2723. Result := _Asn1IntegerSet(a, v)
  2724. else
  2725. Result := 0;
  2726. end;
  2727. function Asn1IntegerGet(a: PASN1_INTEGER): integer;
  2728. begin
  2729. if InitSSLInterface and Assigned(_Asn1IntegerGet) then
  2730. Result := _Asn1IntegerGet(a)
  2731. else
  2732. Result := 0;
  2733. end;
  2734. function X509GmtimeAdj(s: PASN1_UTCTIME; adj: cLong): PASN1_UTCTIME;
  2735. begin
  2736. if InitSSLInterface and Assigned(_X509GmtimeAdj) then
  2737. Result := _X509GmtimeAdj(s, adj)
  2738. else
  2739. Result := nil;
  2740. end;
  2741. function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): cInt;
  2742. begin
  2743. if InitSSLInterface and Assigned(_X509SetNotBefore) then
  2744. Result := _X509SetNotBefore(x, tm)
  2745. else
  2746. Result := 0;
  2747. end;
  2748. function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): cInt;
  2749. begin
  2750. if InitSSLInterface and Assigned(_X509SetNotAfter) then
  2751. Result := _X509SetNotAfter(x, tm)
  2752. else
  2753. Result := 0;
  2754. end;
  2755. function i2dX509bio(b: PBIO; x: PX509): cInt;
  2756. begin
  2757. if InitSSLInterface and Assigned(_i2dX509bio) then
  2758. Result := _i2dX509bio(b, x)
  2759. else
  2760. Result := 0;
  2761. end;
  2762. function i2dPrivateKeyBio(b: PBIO; pkey: PEVP_PKEY): cInt;
  2763. begin
  2764. if InitSSLInterface and Assigned(_i2dPrivateKeyBio) then
  2765. Result := _i2dPrivateKeyBio(b, pkey)
  2766. else
  2767. Result := 0;
  2768. end;
  2769. function d2iX509bio(b:PBIO; x:PX509): PX509;
  2770. begin
  2771. if InitSSLInterface and Assigned(_d2iX509bio) then
  2772. Result := _d2iX509bio(x,b)
  2773. else
  2774. Result := nil;
  2775. end;
  2776. function PEMReadBioX509(b:PBIO; x:PSslPtr; callback:PFunction; cb_arg: SslPtr): PX509;
  2777. begin
  2778. if InitSSLInterface and Assigned(_PEMReadBioX509) then
  2779. Result := _PEMReadBioX509(b,x,callback,cb_arg)
  2780. else
  2781. Result := nil;
  2782. end;
  2783. procedure SkX509PopFree(st: SslPtr);
  2784. begin
  2785. if InitSSLInterface and Assigned(_SkX509PopFree) then
  2786. _SkX509PopFree(st,_X509Free);
  2787. end;
  2788. function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
  2789. begin
  2790. if InitSSLInterface and Assigned(_EvpGetDigestByName) then
  2791. Result := _EvpGetDigestByName(PAnsiChar(Name))
  2792. else
  2793. Result := nil;
  2794. end;
  2795. function X509GetSerialNumber(x: PX509): PASN1_cInt;
  2796. begin
  2797. if InitSSLInterface and Assigned(_X509GetSerialNumber) then
  2798. Result := _X509GetSerialNumber(x)
  2799. else
  2800. Result := nil;
  2801. end;
  2802. // 3DES functions
  2803. procedure DESsetoddparity(Key: des_cblock);
  2804. begin
  2805. if InitSSLInterface and Assigned(_DESsetoddparity) then
  2806. _DESsetoddparity(Key);
  2807. end;
  2808. function DESsetkey(key: des_cblock; schedule: des_key_schedule): cInt;
  2809. begin
  2810. if InitSSLInterface and Assigned(_DESsetkey) then
  2811. Result := _DESsetkey(key, schedule)
  2812. else
  2813. Result := -1;
  2814. end;
  2815. function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): cInt;
  2816. begin
  2817. if InitSSLInterface and Assigned(_DESsetkeychecked) then
  2818. Result := _DESsetkeychecked(key, schedule)
  2819. else
  2820. Result := -1;
  2821. end;
  2822. procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: cInt);
  2823. begin
  2824. if InitSSLInterface and Assigned(_DESecbencrypt) then
  2825. _DESecbencrypt(Input, output, ks, enc);
  2826. end;
  2827. // RAND functions
  2828. function RAND_set_rand_method(const meth: PRAND_METHOD): cint;
  2829. begin
  2830. if InitSSLInterface and Assigned(_RAND_set_rand_method) then
  2831. Result := _RAND_set_rand_method(meth)
  2832. else
  2833. Result := -1;
  2834. end;
  2835. function RAND_get_rand_method: PRAND_METHOD;
  2836. begin
  2837. if InitSSLInterface and Assigned(_RAND_get_rand_method) then
  2838. Result := _RAND_get_rand_method()
  2839. else
  2840. Result := nil;
  2841. end;
  2842. function RAND_SSLeay: PRAND_METHOD;
  2843. begin
  2844. if InitSSLInterface and Assigned(_RAND_SSLeay) then
  2845. Result := _RAND_SSLeay()
  2846. else
  2847. Result := nil;
  2848. end;
  2849. procedure RAND_cleanup;
  2850. begin
  2851. if InitSSLInterface and Assigned(_RAND_cleanup) then
  2852. _RAND_cleanup(); // OK if it does not exit;
  2853. end;
  2854. function RAND_bytes(buf: PByte; num: cint): cint;
  2855. begin
  2856. if InitSSLInterface and Assigned(_RAND_bytes) then
  2857. Result := _RAND_bytes(buf, num)
  2858. else
  2859. Result := -1;
  2860. end;
  2861. function RAND_pseudo_bytes(buf: PByte; num: cint): cint;
  2862. begin
  2863. if InitSSLInterface and Assigned(_RAND_pseudo_bytes) then
  2864. Result := _RAND_pseudo_bytes(buf, num)
  2865. else
  2866. Result := -1;
  2867. end;
  2868. procedure RAND_seed(const buf: Pointer; num: cint);
  2869. begin
  2870. if InitSSLInterface and Assigned(_RAND_seed) then
  2871. _RAND_seed(buf, num);
  2872. end;
  2873. procedure RAND_add(const buf: Pointer; num: cint; entropy: cdouble);
  2874. begin
  2875. if InitSSLInterface and Assigned(_RAND_add) then
  2876. _RAND_add(buf, num, entropy);
  2877. end;
  2878. function RAND_load_file(const file_name: PAnsiChar; max_bytes: clong): cint;
  2879. begin
  2880. if InitSSLInterface and Assigned(_RAND_load_file) then
  2881. Result := _RAND_load_file(file_name, max_bytes)
  2882. else
  2883. Result := -1;
  2884. end;
  2885. function RAND_write_file(const file_name: PAnsiChar): cint;
  2886. begin
  2887. if InitSSLInterface and Assigned(_RAND_write_file) then
  2888. Result := _RAND_write_file(file_name)
  2889. else
  2890. Result := -1;
  2891. end;
  2892. function RAND_file_name(file_name: PAnsiChar; num: csize_t): PAnsiChar;
  2893. begin
  2894. if InitSSLInterface and Assigned(_RAND_file_name) then
  2895. Result := _RAND_file_name(file_name, num)
  2896. else
  2897. Result := nil;
  2898. end;
  2899. function RAND_status: cint;
  2900. begin
  2901. if InitSSLInterface and Assigned(_RAND_status) then
  2902. Result := _RAND_status()
  2903. else
  2904. Result := -1;
  2905. end;
  2906. function RAND_query_egd_bytes(const path: PAnsiChar; buf: PByte; bytes: cint): cint;
  2907. begin
  2908. if InitSSLInterface and Assigned(_RAND_query_egd_bytes) then
  2909. Result := _RAND_query_egd_bytes(path, buf, bytes)
  2910. else
  2911. Result := -1;
  2912. end;
  2913. function RAND_egd(const path: PAnsiChar): cint;
  2914. begin
  2915. if InitSSLInterface and Assigned(_RAND_egd) then
  2916. Result := _RAND_egd(path)
  2917. else
  2918. Result := -1;
  2919. end;
  2920. function RAND_egd_bytes(const path: PAnsiChar; bytes: cint): cint;
  2921. begin
  2922. if InitSSLInterface and Assigned(_RAND_egd_bytes) then
  2923. Result := _RAND_egd_bytes(path, bytes)
  2924. else
  2925. Result := -1;
  2926. end;
  2927. procedure ERR_load_RAND_strings;
  2928. begin
  2929. if InitSSLInterface and Assigned(_ERR_load_RAND_strings) then
  2930. _ERR_load_RAND_strings();
  2931. end;
  2932. function RAND_poll: cint;
  2933. begin
  2934. if InitSSLInterface and Assigned(_RAND_poll) then
  2935. Result := _RAND_poll()
  2936. else
  2937. Result := -1;
  2938. end;
  2939. // RSA Functions
  2940. function RSA_new(): PRSA;
  2941. begin
  2942. if InitSSLInterface and Assigned(_RSA_new) then
  2943. Result := _RSA_new()
  2944. else
  2945. Result := nil;
  2946. end;
  2947. function RSA_new_method(method: PENGINE): PRSA;
  2948. begin
  2949. if InitSSLInterface and Assigned(_RSA_new_method) then
  2950. Result := _RSA_new_method(method)
  2951. else
  2952. Result := nil;
  2953. end;
  2954. function RSA_size(arsa: PRSA): cint;
  2955. begin
  2956. if InitSSLInterface and Assigned(_RSA_size) then
  2957. Result := _RSA_size(arsa)
  2958. else
  2959. Result := -1;
  2960. end;
  2961. function RsaGenerateKey(bits, e: cInt; callback: PFunction; cb_arg: SslPtr): PRSA;
  2962. begin
  2963. if InitSSLInterface and Assigned(_RsaGenerateKey) then
  2964. Result := _RsaGenerateKey(bits, e, callback, cb_arg)
  2965. else
  2966. Result := nil;
  2967. end;
  2968. function RSA_generate_key_ex(arsa: PRSA; bits: cInt; e: PBIGNUM; cb: PBN_GENCB): cint;
  2969. begin
  2970. if InitSSLInterface and Assigned(_RSA_generate_key_ex) then
  2971. Result := _RSA_generate_key_ex(arsa, bits, e, cb)
  2972. else
  2973. Result := 0;
  2974. end;
  2975. function RSA_check_key(arsa: PRSA): cint;
  2976. begin
  2977. if InitSSLInterface and Assigned(_RSA_check_key) then
  2978. Result := _RSA_check_key(arsa)
  2979. else
  2980. Result := -1;
  2981. end;
  2982. function RSA_public_encrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  2983. begin
  2984. if InitSSLInterface and Assigned(_RSA_public_encrypt) then
  2985. Result := _RSA_public_encrypt(flen, from_buf, to_buf, arsa, padding)
  2986. else
  2987. Result := -1;
  2988. end;
  2989. function RSA_private_encrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  2990. begin
  2991. if InitSSLInterface and Assigned(_RSA_private_encrypt) then
  2992. Result := _RSA_private_encrypt(flen, from_buf, to_buf, arsa, padding)
  2993. else
  2994. Result := -1;
  2995. end;
  2996. function RSA_public_decrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  2997. begin
  2998. if InitSSLInterface and Assigned(_RSA_public_decrypt) then
  2999. Result := _RSA_public_decrypt(flen, from_buf, to_buf, arsa, padding)
  3000. else
  3001. Result := -1;
  3002. end;
  3003. function RSA_private_decrypt(flen: cint; from_buf, to_buf: PByte; arsa: PRSA; padding: cint): cint;
  3004. begin
  3005. if InitSSLInterface and Assigned(_RSA_private_decrypt) then
  3006. Result := _RSA_private_decrypt(flen, from_buf, to_buf, arsa, padding)
  3007. else
  3008. Result := -1;
  3009. end;
  3010. procedure RSA_free(arsa: PRSA);
  3011. begin
  3012. if InitSSLInterface and Assigned(_RSA_free) then
  3013. _RSA_free(arsa);
  3014. end;
  3015. function RSA_flags(arsa: PRSA): Integer;
  3016. begin
  3017. if InitSSLInterface and Assigned(_RSA_flags) then
  3018. Result := _RSA_flags(arsa)
  3019. else
  3020. Result := -1;
  3021. end;
  3022. procedure RSA_set_default_method(method: PRSA_METHOD);
  3023. begin
  3024. if InitSSLInterface and Assigned(_RSA_set_default_method) then
  3025. _RSA_set_default_method(method);
  3026. end;
  3027. function RSA_get_default_method: PRSA_METHOD;
  3028. begin
  3029. if InitSSLInterface and Assigned(_RSA_get_default_method) then
  3030. Result := _RSA_get_default_method()
  3031. else
  3032. Result := nil;
  3033. end;
  3034. function RSA_get_method(arsa: PRSA): PRSA_METHOD;
  3035. begin
  3036. if InitSSLInterface and Assigned(_RSA_get_method) then
  3037. Result := _RSA_get_method(arsa)
  3038. else
  3039. Result := nil;
  3040. end;
  3041. function RSA_set_method(arsa: PRSA; method: PRSA_METHOD): PRSA_METHOD;
  3042. begin
  3043. if InitSSLInterface and Assigned(_RSA_set_method) then
  3044. Result := _RSA_set_method(arsa, method)
  3045. else
  3046. Result := nil;
  3047. end;
  3048. function d2i_RSAPublicKey(arsa: PPRSA; pp: PPByte; len: cint): PRSA;
  3049. begin
  3050. if InitSSLInterface and Assigned(_d2i_RSAPublicKey) then
  3051. Result := _d2i_RSAPublicKey(arsa, pp, len)
  3052. else
  3053. Result := nil;
  3054. end;
  3055. function i2d_RSAPublicKey(arsa: PRSA; pp: PPByte): cint;
  3056. begin
  3057. if InitSSLInterface and Assigned(_i2d_RSAPublicKey) then
  3058. Result := _i2d_RSAPublicKey(arsa, pp)
  3059. else
  3060. Result := -1;
  3061. end;
  3062. function d2i_RSAPrivateKey(arsa: PPRSA; pp: PPByte; len: cint): PRSA;
  3063. begin
  3064. if InitSSLInterface and Assigned(_d2i_RSAPrivateKey) then
  3065. Result := _d2i_RSAPrivateKey(arsa, pp, len)
  3066. else
  3067. Result := nil;
  3068. end;
  3069. function i2d_RSAPrivateKey(arsa: PRSA; pp: PPByte): cint;
  3070. begin
  3071. if InitSSLInterface and Assigned(_i2d_RSAPrivateKey) then
  3072. Result := _i2d_RSAPrivateKey(arsa, pp)
  3073. else
  3074. Result := -1;
  3075. end;
  3076. function d2i_PubKey(a: PPEVP_PKEY; pp: PPByte; len: clong): PEVP_PKEY;
  3077. begin
  3078. if InitSSLInterface and Assigned(_d2i_PubKey) then
  3079. Result := _d2i_PubKey(a, pp, len)
  3080. else
  3081. Result := nil;
  3082. end;
  3083. function d2i_AutoPrivateKey(a: PPEVP_PKEY; pp: PPByte; len: clong): PEVP_PKEY;
  3084. begin
  3085. if InitSSLInterface and Assigned(_d2i_AutoPrivateKey) then
  3086. Result := _d2i_AutoPrivateKey(a, pp, len)
  3087. else
  3088. Result := nil;
  3089. end;
  3090. // ERR Functions
  3091. function Err_Error_String(e: cInt; buf: PAnsiChar): PAnsiChar;
  3092. begin
  3093. if InitSSLInterface and Assigned(_Err_Error_String) then
  3094. Result := _Err_Error_String(e, buf)
  3095. else
  3096. Result := nil;
  3097. end;
  3098. // Crypto Functions
  3099. function SSLeay_version(t: cint): PAnsiChar;
  3100. begin
  3101. if InitSSLInterface and Assigned(_SSLeayversion) then
  3102. Result := _SSLeayversion(t)
  3103. else
  3104. Result := nil;
  3105. end;
  3106. // EVP Functions
  3107. function EVP_des_ede3_cbc: PEVP_CIPHER;
  3108. begin
  3109. if InitSSLInterface and Assigned(_EVP_des_ede3_cbc) then
  3110. Result := _EVP_des_ede3_cbc()
  3111. else
  3112. Result := Nil;
  3113. end;
  3114. function EVP_enc_null: PEVP_CIPHER;
  3115. begin
  3116. if InitSSLInterface and Assigned(_EVP_enc_null) then
  3117. Result := _EVP_enc_null()
  3118. else
  3119. Result := Nil;
  3120. end;
  3121. function EVP_rc2_cbc: PEVP_CIPHER;
  3122. begin
  3123. if InitSSLInterface and Assigned(_EVP_rc2_cbc) then
  3124. Result := _EVP_rc2_cbc()
  3125. else
  3126. Result := Nil;
  3127. end;
  3128. function EVP_rc2_40_cbc: PEVP_CIPHER;
  3129. begin
  3130. if InitSSLInterface and Assigned(_EVP_rc2_40_cbc) then
  3131. Result := _EVP_rc2_40_cbc()
  3132. else
  3133. Result := Nil;
  3134. end;
  3135. function EVP_rc2_64_cbc: PEVP_CIPHER;
  3136. begin
  3137. if InitSSLInterface and Assigned(_EVP_rc2_64_cbc) then
  3138. Result := _EVP_rc2_64_cbc()
  3139. else
  3140. Result := Nil;
  3141. end;
  3142. function EVP_rc4: PEVP_CIPHER;
  3143. begin
  3144. if InitSSLInterface and Assigned(_EVP_rc4) then
  3145. Result := _EVP_rc4()
  3146. else
  3147. Result := Nil;
  3148. end;
  3149. function EVP_rc4_40: PEVP_CIPHER;
  3150. begin
  3151. if InitSSLInterface and Assigned(_EVP_rc4_40) then
  3152. Result := _EVP_rc4_40()
  3153. else
  3154. Result := Nil;
  3155. end;
  3156. function EVP_des_cbc: PEVP_CIPHER;
  3157. begin
  3158. if InitSSLInterface and Assigned(_EVP_des_cbc) then
  3159. Result := _EVP_des_cbc()
  3160. else
  3161. Result := Nil;
  3162. end;
  3163. function EVP_aes_128_cbc: PEVP_CIPHER;
  3164. begin
  3165. if InitSSLInterface and Assigned(_EVP_aes_128_cbc) then
  3166. Result := _EVP_aes_128_cbc()
  3167. else
  3168. Result := Nil;
  3169. end;
  3170. function EVP_aes_192_cbc: PEVP_CIPHER;
  3171. begin
  3172. if InitSSLInterface and Assigned(_EVP_aes_192_cbc) then
  3173. Result := _EVP_aes_192_cbc()
  3174. else
  3175. Result := Nil;
  3176. end;
  3177. function EVP_aes_256_cbc: PEVP_CIPHER;
  3178. begin
  3179. if InitSSLInterface and Assigned(_EVP_aes_256_cbc) then
  3180. Result := _EVP_aes_256_cbc()
  3181. else
  3182. Result := Nil;
  3183. end;
  3184. function EVP_aes_128_cfb8: PEVP_CIPHER;
  3185. begin
  3186. if InitSSLInterface and Assigned(_EVP_aes_128_cfb8) then
  3187. Result := _EVP_aes_128_cfb8()
  3188. else
  3189. Result := Nil;
  3190. end;
  3191. function EVP_aes_192_cfb8: PEVP_CIPHER;
  3192. begin
  3193. if InitSSLInterface and Assigned(_EVP_aes_192_cfb8) then
  3194. Result := _EVP_aes_192_cfb8()
  3195. else
  3196. Result := Nil;
  3197. end;
  3198. function EVP_aes_256_cfb8: PEVP_CIPHER;
  3199. begin
  3200. if InitSSLInterface and Assigned(_EVP_aes_256_cfb8) then
  3201. Result := _EVP_aes_256_cfb8()
  3202. else
  3203. Result := Nil;
  3204. end;
  3205. function EVP_camellia_128_cbc: PEVP_CIPHER;
  3206. begin
  3207. if InitSSLInterface and Assigned(_EVP_camellia_128_cbc) then
  3208. Result := _EVP_camellia_128_cbc()
  3209. else
  3210. Result := Nil;
  3211. end;
  3212. function EVP_camellia_192_cbc: PEVP_CIPHER;
  3213. begin
  3214. if InitSSLInterface and Assigned(_EVP_camellia_192_cbc) then
  3215. Result := _EVP_camellia_192_cbc()
  3216. else
  3217. Result := Nil;
  3218. end;
  3219. function EVP_camellia_256_cbc: PEVP_CIPHER;
  3220. begin
  3221. if InitSSLInterface and Assigned(_EVP_camellia_256_cbc) then
  3222. Result := _EVP_camellia_256_cbc()
  3223. else
  3224. Result := Nil;
  3225. end;
  3226. function EVP_sha256: PEVP_CIPHER;
  3227. begin
  3228. if InitSSLInterface and Assigned(_EVP_sha256) then
  3229. Result := _EVP_sha256()
  3230. else
  3231. Result := Nil;
  3232. end;
  3233. procedure OpenSSL_add_all_algorithms;
  3234. begin
  3235. if InitSSLInterface then
  3236. if Assigned(_OpenSSL_add_all_algorithms) then
  3237. _OpenSSL_add_all_algorithms()
  3238. else if assigned(_OPENSSL_init_crypto) then
  3239. _OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS or OPENSSL_INIT_ADD_ALL_DIGESTS or OPENSSL_INIT_LOAD_CONFIG, Nil)
  3240. end;
  3241. procedure OpenSSL_add_all_ciphers;
  3242. begin
  3243. if InitSSLInterface then
  3244. if Assigned(_OpenSSL_add_all_ciphers) then
  3245. _OpenSSL_add_all_ciphers()
  3246. else if assigned(_OPENSSL_init_crypto) then
  3247. _OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, Nil)
  3248. end;
  3249. procedure OpenSSL_add_all_digests;
  3250. begin
  3251. if InitSSLInterface then
  3252. if Assigned(_OpenSSL_add_all_digests) then
  3253. _OpenSSL_add_all_digests()
  3254. else if assigned(_OPENSSL_init_crypto) then
  3255. _OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, Nil)
  3256. end;
  3257. //
  3258. function EVP_DigestInit(ctx: PEVP_MD_CTX; type_: PEVP_MD): cint;
  3259. begin
  3260. if InitSSLInterface and Assigned(_EVP_DigestInit) then
  3261. Result := _EVP_DigestInit(ctx, type_)
  3262. else
  3263. Result := -1;
  3264. end;
  3265. function EVP_DigestUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  3266. begin
  3267. if InitSSLInterface and Assigned(_EVP_DigestUpdate) then
  3268. Result := _EVP_DigestUpdate(ctx, data, cnt)
  3269. else
  3270. Result := -1;
  3271. end;
  3272. function EVP_DigestFinal(ctx: PEVP_MD_CTX; md: PByte; s: pcuint): cint;
  3273. begin
  3274. if InitSSLInterface and Assigned(_EVP_DigestFinal) then
  3275. Result := _EVP_DigestFinal(ctx, md, s)
  3276. else
  3277. Result := -1;
  3278. end;
  3279. function EVP_SignFinal(ctx: pEVP_MD_CTX; sig: pointer; var s: cardinal;
  3280. key: pEVP_PKEY): integer;
  3281. begin
  3282. if InitSSLInterface and Assigned(_EVP_SignFinal) then
  3283. Result := _EVP_SignFinal(ctx, sig, s, key)
  3284. else
  3285. Result := -1;
  3286. end;
  3287. function EVP_DigestVerify(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t; const tbs : pointer; tbslen: csize_t): cint;
  3288. begin
  3289. if InitSSLInterface and Assigned(_EVP_DigestVerify) then
  3290. Result := _EVP_DigestVerify(ctx, sig, siglen, tbs, tbslen)
  3291. else
  3292. Result := -1;
  3293. end;
  3294. function EVP_PKEY_size(key: pEVP_PKEY): integer;
  3295. begin
  3296. if InitSSLInterface and Assigned(_EVP_PKEY_size) then
  3297. Result := _EVP_PKEY_size(key)
  3298. else
  3299. Result := -1;
  3300. end;
  3301. procedure EVP_PKEY_free(key: pEVP_PKEY);
  3302. begin
  3303. if InitSSLInterface and Assigned(_EVP_PKEY_free) then
  3304. _EVP_PKEY_free(key);
  3305. end;
  3306. function EVP_VerifyFinal(ctx: pEVP_MD_CTX; sigbuf: pointer;
  3307. siglen: cardinal; pkey: pEVP_PKEY): integer;
  3308. begin
  3309. if InitSSLInterface and Assigned(_EVP_VerifyFinal) then
  3310. Result := _EVP_VerifyFinal(ctx, sigbuf, siglen, pkey)
  3311. else
  3312. Result := -1;
  3313. end;
  3314. //
  3315. function EVP_get_cipherbyname(const name: PAnsiChar): PEVP_CIPHER;
  3316. begin
  3317. if InitSSLInterface and Assigned(_EVP_get_cipherbyname) then
  3318. Result := _EVP_get_cipherbyname(name)
  3319. else
  3320. Result := nil;
  3321. end;
  3322. function EVP_get_digestbyname(const name: PAnsiChar): PEVP_MD;
  3323. begin
  3324. if InitSSLInterface and Assigned(_EVP_get_digestbyname) then
  3325. Result := _EVP_get_digestbyname(name)
  3326. else
  3327. Result := nil;
  3328. end;
  3329. //
  3330. procedure EVP_CIPHER_CTX_init(a: PEVP_CIPHER_CTX);
  3331. begin
  3332. if InitSSLInterface then
  3333. if Assigned(_EVP_CIPHER_CTX_init) then
  3334. _EVP_CIPHER_CTX_init(a)
  3335. else if Assigned(_EVP_CIPHER_CTX_reset) then
  3336. _EVP_CIPHER_CTX_reset(a);
  3337. end;
  3338. function EVP_CIPHER_CTX_cleanup(a: PEVP_CIPHER_CTX): cint;
  3339. begin
  3340. if InitSSLInterface then
  3341. if Assigned(_EVP_CIPHER_CTX_cleanup) then
  3342. Result := _EVP_CIPHER_CTX_cleanup(a)
  3343. else if Assigned(_EVP_CIPHER_CTX_reset) then
  3344. Result := _EVP_CIPHER_CTX_reset(a)
  3345. else
  3346. Result := -1;
  3347. end;
  3348. function EVP_CIPHER_CTX_set_key_length(x: PEVP_CIPHER_CTX; keylen: cint): cint;
  3349. begin
  3350. if InitSSLInterface and Assigned(_EVP_CIPHER_CTX_set_key_length) then
  3351. Result := _EVP_CIPHER_CTX_set_key_length(x, keylen)
  3352. else
  3353. Result := -1;
  3354. end;
  3355. function EVP_CIPHER_CTX_ctrl(ctx: PEVP_CIPHER_CTX; type_, arg: cint; ptr: Pointer): cint;
  3356. begin
  3357. if InitSSLInterface and Assigned(_EVP_CIPHER_CTX_ctrl) then
  3358. Result := _EVP_CIPHER_CTX_ctrl(ctx, type_, arg, ptr)
  3359. else
  3360. Result := -1;
  3361. end;
  3362. //
  3363. function EVP_EncryptInit(ctx: PEVP_CIPHER_CTX; const chipher_: PEVP_CIPHER;
  3364. const key, iv: PByte): cint;
  3365. begin
  3366. if InitSSLInterface and Assigned(_EVP_EncryptInit) then
  3367. Result := _EVP_EncryptInit(ctx, chipher_, key, iv)
  3368. else
  3369. Result := -1;
  3370. end;
  3371. function EVP_EncryptUpdate(ctx: PEVP_CIPHER_CTX; out_: pcuchar;
  3372. outlen: pcint; const in_: pcuchar; inlen: cint): cint;
  3373. begin
  3374. if InitSSLInterface and Assigned(_EVP_EncryptUpdate) then
  3375. Result := _EVP_EncryptUpdate(ctx, out_, outlen, in_, inlen)
  3376. else
  3377. Result := -1;
  3378. end;
  3379. function EVP_EncryptFinal(ctx: PEVP_CIPHER_CTX; out_data: PByte; outlen: pcint): cint;
  3380. begin
  3381. if InitSSLInterface and Assigned(_EVP_EncryptFinal) then
  3382. Result := _EVP_EncryptFinal(ctx, out_data, outlen)
  3383. else
  3384. Result := -1;
  3385. end;
  3386. //
  3387. function EVP_DecryptInit(ctx: PEVP_CIPHER_CTX; chiphir_type: PEVP_CIPHER;
  3388. const key, iv: PByte): cint;
  3389. begin
  3390. if InitSSLInterface and Assigned(_EVP_DecryptInit) then
  3391. Result := _EVP_DecryptInit(ctx, chiphir_type, key, iv)
  3392. else
  3393. Result := -1;
  3394. end;
  3395. function EVP_DecryptUpdate(ctx: PEVP_CIPHER_CTX; out_data: PByte;
  3396. outl: pcint; const in_: PByte; inl: cint): cint;
  3397. begin
  3398. if InitSSLInterface and Assigned(_EVP_DecryptUpdate) then
  3399. Result := _EVP_DecryptUpdate(ctx, out_data, outl, in_, inl)
  3400. else
  3401. Result := -1;
  3402. end;
  3403. function EVP_DecryptFinal(ctx: PEVP_CIPHER_CTX; outm: PByte; outlen: pcint): cint;
  3404. begin
  3405. if InitSSLInterface and Assigned(_EVP_DecryptFinal) then
  3406. Result := _EVP_DecryptFinal(ctx, outm, outlen)
  3407. else
  3408. Result := -1;
  3409. end;
  3410. function EVP_MD_CTX_new: PEVP_MD_CTX;
  3411. begin
  3412. if InitSSLInterface and Assigned(_EVP_MD_CTX_new) then
  3413. Result := _EVP_MD_CTX_new
  3414. else
  3415. Result := Nil;
  3416. end;
  3417. function EVP_MD_CTX_create: PEVP_MD_CTX;
  3418. begin
  3419. if InitSSLInterface and Assigned(_EVP_MD_CTX_new) then
  3420. Result := _EVP_MD_CTX_new
  3421. else
  3422. Result := Nil;
  3423. end;
  3424. procedure EVP_MD_CTX_destroy(ctx: PEVP_MD_CTX);
  3425. begin
  3426. EVP_MD_CTX_free(ctx);
  3427. end;
  3428. procedure EVP_MD_CTX_free(ctx: PEVP_MD_CTX);
  3429. begin
  3430. if InitSSLInterface and Assigned(_EVP_MD_CTX_free) then
  3431. _EVP_MD_CTX_free(ctx)
  3432. end;
  3433. function EVP_DigestSignInit(ctx: PEVP_MD_CTX; pctx: PPEVP_PKEY_CTX; const evptype: PEVP_MD; e: PENGINE; pkey: PEVP_PKEY): cint;
  3434. begin
  3435. if InitSSLInterface and Assigned(_EVP_DigestSignInit) then
  3436. Result := _EVP_DigestSignInit(ctx, pctx, evptype, e, pkey)
  3437. else
  3438. Result := -1;
  3439. end;
  3440. function EVP_DigestSignUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  3441. begin
  3442. Result := EVP_DigestUpdate(ctx, data, cnt);
  3443. end;
  3444. function EVP_DigestSignFinal(ctx: PEVP_MD_CTX; sigret: PByte; siglen: pcsize_t): cint;
  3445. begin
  3446. if InitSSLInterface and Assigned(_EVP_DigestSignFinal) then
  3447. Result := _EVP_DigestSignFinal(ctx, sigret, siglen)
  3448. else
  3449. Result := -1;
  3450. end;
  3451. function EVP_DigestSign(ctx: PEVP_MD_CTX; sigret:Pbyte; siglen:pcsize_t; const tbs : pointer; tbslen: csize_t): cint;
  3452. begin
  3453. if InitSSLInterface and Assigned(_EVP_DigestSign) then
  3454. Result := _EVP_DigestSign(ctx, sigret, siglen,tbs,tbslen)
  3455. else
  3456. Result := -1;
  3457. end;
  3458. function EVP_DigestVerifyInit(ctx: PEVP_MD_CTX; pctx: PPEVP_PKEY_CTX; const evptype: PEVP_MD; e: PENGINE; pkey: PEVP_PKEY): cint;
  3459. begin
  3460. if InitSSLInterface and Assigned(_EVP_DigestVerifyInit) then
  3461. Result := _EVP_DigestVerifyInit(ctx, pctx, evptype, e, pkey)
  3462. else
  3463. Result := -1;
  3464. end;
  3465. function EVP_DigestVerifyUpdate(ctx: PEVP_MD_CTX; const data: Pointer; cnt: csize_t): cint;
  3466. begin
  3467. Result := EVP_DigestUpdate(ctx, data, cnt);
  3468. end;
  3469. function EVP_DigestVerifyFinal(ctx: PEVP_MD_CTX; sig: PByte; siglen: csize_t): cint;
  3470. begin
  3471. if InitSSLInterface and Assigned(_EVP_DigestVerifyFinal) then
  3472. Result := _EVP_DigestVerifyFinal(ctx, sig, siglen)
  3473. else
  3474. Result := -1;
  3475. end;
  3476. { PEM }
  3477. function PEM_read_bio_PrivateKey(bp: PBIO; X: PPEVP_PKEY;
  3478. cb: Ppem_password_cb; u: Pointer): PEVP_PKEY;
  3479. begin
  3480. if InitSSLInterface and Assigned(_PEM_read_bio_PrivateKey) then
  3481. Result := _PEM_read_bio_PrivateKey(bp, x, cb, u)
  3482. else
  3483. Result := nil;
  3484. end;
  3485. function PEM_read_bio_PUBKEY(bp: pBIO; var x: pEVP_PKEY;
  3486. cb: Ppem_password_cb; u: pointer): pEVP_PKEY;
  3487. begin
  3488. if InitSSLInterface and Assigned(_PEM_read_bio_PUBKEY) then
  3489. Result := _PEM_read_bio_PUBKEY(bp, x, cb, u)
  3490. else
  3491. Result := nil;
  3492. end;
  3493. function PEM_write_bio_PrivateKey(bp: pBIO; x: pEVP_PKEY;
  3494. const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
  3495. u: pointer): integer;
  3496. Begin
  3497. if InitSSLInterface and Assigned(_PEM_write_bio_PrivateKey) then
  3498. Result := _PEM_write_bio_PrivateKey(bp, x, enc ,kstr ,klen ,cb, u)
  3499. else
  3500. Result := -1;
  3501. end;
  3502. function PEM_write_bio_PUBKEY(bp: pBIO; x: pEVP_PKEY): integer;
  3503. Begin
  3504. if InitSSLInterface and Assigned(_PEM_write_bio_PUBKEY) then
  3505. Result := _PEM_write_bio_PUBKEY(bp, x)
  3506. else
  3507. Result := -1;
  3508. end;
  3509. function PEM_read_bio_X509(bp: PBIO; x: PPX509; cb: ppem_password_cb; u: pointer): PX509;
  3510. begin
  3511. if InitSSLInterface and Assigned(_PEM_read_bio_X509) then
  3512. Result := _PEM_read_bio_X509(bp, x, cb, u)
  3513. else
  3514. Result := nil;
  3515. end;
  3516. function PEM_write_bio_X509(bp: pBIO; x: px509): integer;
  3517. begin
  3518. if InitSSLInterface and Assigned(_PEM_write_bio_X509) then
  3519. Result := _PEM_write_bio_X509(bp, x)
  3520. else
  3521. Result := 0;
  3522. end;
  3523. function PEM_write_bio_PKCS7(bp : PBIO; x : PPKCS7) : cint;
  3524. begin
  3525. if InitSSLInterface and Assigned(_PEM_write_bio_PKCS7) then
  3526. Result := _PEM_write_bio_PKCS7(bp, x)
  3527. else
  3528. Result := 0;
  3529. end;
  3530. // BIO Functions
  3531. function BIO_ctrl(bp: PBIO; cmd: cint; larg: clong; parg: Pointer): clong;
  3532. begin
  3533. if InitSSLInterface and Assigned(_BIO_ctrl) then
  3534. Result := _BIO_ctrl(bp, cmd, larg, parg)
  3535. else
  3536. Result := -1;
  3537. end;
  3538. function BIO_push(b: PBIO; append: PBIO): PBIO;
  3539. begin
  3540. if InitSSLInterface and Assigned(_BIO_push) then
  3541. Result := _BIO_push(b,append)
  3542. else
  3543. Result := nil;
  3544. end;
  3545. function BIO_pop(b: PBIO): PBIO;
  3546. begin
  3547. if InitSSLInterface and Assigned(_BIO_pop) then
  3548. Result := _BIO_pop(b)
  3549. else
  3550. Result := nil;
  3551. end;
  3552. function BIO_gets(b: PBIO; buf: PAnsiChar; size: cint): cint;
  3553. begin
  3554. if InitSSLInterface and Assigned(_BIO_gets) then
  3555. Result := _BIO_gets(b,buf,size)
  3556. else
  3557. Result := -1;
  3558. end;
  3559. function BIO_puts(b: PBIO; const buf: PAnsiChar): cint;
  3560. begin
  3561. if InitSSLInterface and Assigned(_BIO_puts) then
  3562. Result := _BIO_puts(b,buf)
  3563. else
  3564. Result := -1;
  3565. end;
  3566. procedure BIO_set_mem_eof_return(b: PBIO; v: cint);
  3567. begin
  3568. if InitSSLInterface and Assigned(_BIO_set_mem_eof_return) then
  3569. _BIO_set_mem_eof_return(b,v);
  3570. end;
  3571. procedure BIO_set_mem_buf(b: PBIO; bm: pointer; c: cint);
  3572. begin
  3573. if InitSSLInterface and Assigned(_BIO_set_mem_buf) then
  3574. _BIO_set_mem_buf(b,bm,c);
  3575. end;
  3576. procedure BIO_get_mem_ptr(b: PBIO; var pp: pointer);
  3577. begin
  3578. if InitSSLInterface and Assigned(_BIO_get_mem_ptr) then
  3579. _BIO_get_mem_ptr(b,pp);
  3580. end;
  3581. function BIO_read_filename(b: PBIO; const name: PAnsiChar): cint;
  3582. begin
  3583. Result := BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE or BIO_FP_READ, name);
  3584. end;
  3585. function BIO_s_file: pBIO_METHOD;
  3586. begin
  3587. if InitSSLInterface and Assigned(_BIO_s_file) then
  3588. Result := _BIO_s_file
  3589. else
  3590. Result := nil;
  3591. end;
  3592. function BIO_new_file(const filename: PAnsiChar; const mode: PAnsiChar): pBIO;
  3593. begin
  3594. if InitSSLInterface and Assigned(_BIO_new_file) then
  3595. Result := _BIO_new_file(filename, mode)
  3596. else
  3597. Result := nil;
  3598. end;
  3599. function BIO_new_mem_buf(buf: pointer; len: integer): pBIO;
  3600. begin
  3601. if InitSSLInterface and Assigned(_BIO_new_mem_buf) then
  3602. Result := _BIO_new_mem_buf(buf, len)
  3603. else
  3604. Result := nil;
  3605. end;
  3606. // PKCS7 Functions
  3607. function PKCS7_ISSUER_AND_SERIAL_new : PPKCS7_ISSUER_AND_SERIAL;
  3608. begin
  3609. if InitSSLInterface and Assigned(_PKCS7_ISSUER_AND_SERIAL_new) then
  3610. Result := _PKCS7_ISSUER_AND_SERIAL_new
  3611. else
  3612. Result := nil;
  3613. end;
  3614. procedure PKCS7_ISSUER_AND_SERIAL_free (a:PPKCS7_ISSUER_AND_SERIAL);
  3615. begin
  3616. if InitSSLInterface and Assigned(_PKCS7_ISSUER_AND_SERIAL_free) then
  3617. _PKCS7_ISSUER_AND_SERIAL_free(a)
  3618. end;
  3619. function PKCS7_ISSUER_AND_SERIAL_digest(data:PPKCS7_ISSUER_AND_SERIAL; _type:PEVP_MD; md:Pbyte; len:Pdword):longint;
  3620. begin
  3621. if InitSSLInterface and Assigned(_PKCS7_ISSUER_AND_SERIAL_digest) then
  3622. Result:=_PKCS7_ISSUER_AND_SERIAL_digest(data,_type,md,len)
  3623. else
  3624. Result:=-1;
  3625. end;
  3626. function PKCS7_dup(p7:PPKCS7):PPKCS7;
  3627. begin
  3628. if InitSSLInterface and Assigned(_PKCS7_dup) then
  3629. Result:=_PKCS7_dup(p7)
  3630. else
  3631. Result:=Nil;
  3632. end;
  3633. function PEM_write_bio_PKCS7_stream(_out:PBIO; p7:PPKCS7; _in:PBIO; flags:longint):longint;
  3634. begin
  3635. if InitSSLInterface and Assigned(_PEM_write_bio_PKCS7_stream) then
  3636. Result:=_PEM_write_bio_PKCS7_stream(_out,p7,_in,flags)
  3637. else
  3638. Result:=-1;
  3639. end;
  3640. function PKCS7_SIGNER_INFO_new:PPKCS7_SIGNER_INFO;
  3641. begin
  3642. if InitSSLInterface and Assigned(_PKCS7_SIGNER_INFO_new) then
  3643. Result:=_PKCS7_SIGNER_INFO_new
  3644. else
  3645. Result:=Nil;
  3646. end;
  3647. procedure PKCS7_SIGNER_INFO_free(a:PPKCS7_SIGNER_INFO);
  3648. begin
  3649. if InitSSLInterface and Assigned(_PKCS7_SIGNER_INFO_free) then
  3650. _PKCS7_SIGNER_INFO_free(a);
  3651. end;
  3652. function PKCS7_RECIP_INFO_new:PPKCS7_RECIP_INFO;
  3653. begin
  3654. if InitSSLInterface and Assigned(_PKCS7_RECIP_INFO_new) then
  3655. Result:=_PKCS7_RECIP_INFO_new
  3656. else
  3657. Result:=Nil;
  3658. end;
  3659. procedure PKCS7_RECIP_INFO_free(a:PPKCS7_RECIP_INFO);
  3660. begin
  3661. if InitSSLInterface and Assigned(_PKCS7_RECIP_INFO_free) then
  3662. _PKCS7_RECIP_INFO_free(a);
  3663. end;
  3664. function PKCS7_SIGNED_new:PPKCS7_SIGNED;
  3665. begin
  3666. if InitSSLInterface and Assigned(_PKCS7_SIGNED_new) then
  3667. Result:=_PKCS7_SIGNED_new
  3668. else
  3669. Result:=Nil;
  3670. end;
  3671. procedure PKCS7_SIGNED_free(a:PPKCS7_SIGNED);
  3672. begin
  3673. if InitSSLInterface and Assigned(_PKCS7_SIGNED_free) then
  3674. _PKCS7_SIGNED_free(a)
  3675. end;
  3676. function PKCS7_ENC_CONTENT_new:PPKCS7_ENC_CONTENT;
  3677. begin
  3678. if InitSSLInterface and Assigned(_PKCS7_ENC_CONTENT_new) then
  3679. Result:=_PKCS7_ENC_CONTENT_new
  3680. else
  3681. Result:=Nil;
  3682. end;
  3683. procedure PKCS7_ENC_CONTENT_free(a:PPKCS7_ENC_CONTENT);
  3684. begin
  3685. if InitSSLInterface and Assigned(_PKCS7_ENC_CONTENT_free) then
  3686. _PKCS7_ENC_CONTENT_free(a)
  3687. end;
  3688. function PKCS7_ENVELOPE_new:PPKCS7_ENVELOPE;
  3689. begin
  3690. if InitSSLInterface and Assigned(_PKCS7_ENVELOPE_new) then
  3691. Result:=_PKCS7_ENVELOPE_new
  3692. else
  3693. Result:=Nil;
  3694. end;
  3695. procedure PKCS7_ENVELOPE_free(a:PPKCS7_ENVELOPE);
  3696. begin
  3697. if InitSSLInterface and Assigned(_PKCS7_ENVELOPE_free) then
  3698. _PKCS7_ENVELOPE_free(a)
  3699. end;
  3700. function PKCS7_SIGN_ENVELOPE_new:PPKCS7_SIGN_ENVELOPE;
  3701. begin
  3702. if InitSSLInterface and Assigned(_PKCS7_SIGN_ENVELOPE_new) then
  3703. Result:=_PKCS7_SIGN_ENVELOPE_new
  3704. else
  3705. Result:=Nil;
  3706. end;
  3707. procedure PKCS7_SIGN_ENVELOPE_free(a:PPKCS7_SIGN_ENVELOPE);
  3708. begin
  3709. if InitSSLInterface and Assigned(_PKCS7_SIGN_ENVELOPE_free) then
  3710. _PKCS7_SIGN_ENVELOPE_free(a)
  3711. end;
  3712. function PKCS7_DIGEST_new:PPKCS7_DIGEST;
  3713. begin
  3714. if InitSSLInterface and Assigned(_PKCS7_DIGEST_new) then
  3715. Result:=_PKCS7_DIGEST_new
  3716. else
  3717. Result:=Nil;
  3718. end;
  3719. procedure PKCS7_DIGEST_free(a:PPKCS7_DIGEST);
  3720. begin
  3721. if InitSSLInterface and Assigned(_PKCS7_DIGEST_free) then
  3722. _PKCS7_DIGEST_free(a)
  3723. end;
  3724. function PKCS7_ENCRYPT_new:PPKCS7_ENCRYPT;
  3725. begin
  3726. if InitSSLInterface and Assigned(_PKCS7_ENCRYPT_new) then
  3727. Result:=_PKCS7_ENCRYPT_new
  3728. else
  3729. Result:=Nil;
  3730. end;
  3731. procedure PKCS7_ENCRYPT_free(a:PPKCS7_ENCRYPT);
  3732. begin
  3733. if InitSSLInterface and Assigned(_PKCS7_ENCRYPT_free) then
  3734. _PKCS7_ENCRYPT_free(a)
  3735. end;
  3736. function PKCS7_new:PPKCS7;
  3737. begin
  3738. if InitSSLInterface and Assigned(_PKCS7_new) then
  3739. Result:=_PKCS7_new
  3740. else
  3741. Result:=Nil;
  3742. end;
  3743. procedure PKCS7_free(a:PPKCS7);
  3744. begin
  3745. if InitSSLInterface and Assigned(_PKCS7_free) then
  3746. _PKCS7_free(a)
  3747. end;
  3748. function PKCS7_print_ctx(_out:PBIO; x:PPKCS7; indent:longint; pctx:Pointer):longint;
  3749. begin
  3750. if InitSSLInterface and Assigned(_PKCS7_print_ctx) then
  3751. Result:=PKCS7_print_ctx(_out,x,indent,pctx)
  3752. else
  3753. Result:=-1;
  3754. end;
  3755. function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;
  3756. begin
  3757. if InitSSLInterface and Assigned(_PKCS7_ctrl) then
  3758. Result:=_PKCS7_ctrl(p7,cmd,larg,parg)
  3759. else
  3760. Result:=-1;
  3761. end;
  3762. function PKCS7_set_type(p7:PPKCS7; _type:longint):longint;
  3763. begin
  3764. if InitSSLInterface and Assigned(_PKCS7_set_type) then
  3765. Result:=_PKCS7_set_type(p7,_type)
  3766. else
  3767. Result:=-1;
  3768. end;
  3769. function PKCS7_set0_type_other(p7:PPKCS7; _type:longint; other:PASN1_TYPE):longint;
  3770. begin
  3771. if InitSSLInterface and Assigned(_PKCS7_set0_type_other) then
  3772. Result:=_PKCS7_set0_type_other(p7,_type,other)
  3773. else
  3774. Result:=-1;
  3775. end;
  3776. function PKCS7_set_content(p7:PPKCS7; p7_data:PPKCS7):longint;
  3777. begin
  3778. if InitSSLInterface and Assigned(_PKCS7_set_content) then
  3779. Result:=_PKCS7_set_content(p7,p7_Data)
  3780. else
  3781. Result:=-1;
  3782. end;
  3783. function PKCS7_SIGNER_INFO_set(p7i:PPKCS7_SIGNER_INFO; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):longint;
  3784. begin
  3785. if InitSSLInterface and Assigned(_PKCS7_SIGNER_INFO_set) then
  3786. Result:=_PKCS7_SIGNER_INFO_set(p7i,x509,pkey,dgst)
  3787. else
  3788. Result:=-1;
  3789. end;
  3790. function PKCS7_SIGNER_INFO_sign(si:PPKCS7_SIGNER_INFO):longint;
  3791. begin
  3792. if InitSSLInterface and Assigned(_PKCS7_SIGNER_INFO_sign) then
  3793. Result:=_PKCS7_SIGNER_INFO_sign(si)
  3794. else
  3795. Result:=-1;
  3796. end;
  3797. function PKCS7_add_signer(p7:PPKCS7; p7i:PPKCS7_SIGNER_INFO):longint;
  3798. begin
  3799. if InitSSLInterface and Assigned(_PKCS7_add_signer) then
  3800. Result:=_PKCS7_add_signer(p7,p7i)
  3801. else
  3802. Result:=-1;
  3803. end;
  3804. function PKCS7_add_certificate(p7:PPKCS7; x509:PX509):longint;
  3805. begin
  3806. if InitSSLInterface and Assigned(_PKCS7_add_certificate) then
  3807. Result:=_PKCS7_add_certificate(p7,x509)
  3808. else
  3809. Result:=-1;
  3810. end;
  3811. function PKCS7_add_crl(p7:PPKCS7; x509: Pointer):longint;
  3812. begin
  3813. if InitSSLInterface and Assigned(_PKCS7_add_crl) then
  3814. Result:=PKCS7_add_crl(p7,x509)
  3815. else
  3816. Result:=-1;
  3817. end;
  3818. function PKCS7_content_new(p7:PPKCS7; nid:longint):longint;
  3819. begin
  3820. if InitSSLInterface and Assigned(_PKCS7_content_new) then
  3821. Result:=_PKCS7_content_new(p7,nid)
  3822. else
  3823. Result:=-1;
  3824. end;
  3825. function PKCS7_add_signature(p7:PPKCS7; x509:PX509; pkey:PEVP_PKEY; dgst:PEVP_MD):PPKCS7_SIGNER_INFO;
  3826. begin
  3827. if InitSSLInterface and Assigned(_PKCS7_add_signature) then
  3828. Result:=PKCS7_add_signature(p7,x509,pkey,dgst)
  3829. else
  3830. Result:=Nil;
  3831. end;
  3832. function PKCS7_cert_from_signer_info(p7:PPKCS7; si:PPKCS7_SIGNER_INFO):PX509;
  3833. begin
  3834. if InitSSLInterface and Assigned(_PKCS7_cert_from_signer_info) then
  3835. Result:=_PKCS7_cert_from_signer_info(p7,si)
  3836. else
  3837. Result:=Nil;
  3838. end;
  3839. function PKCS7_set_digest(p7:PPKCS7; md:PEVP_MD):longint;
  3840. begin
  3841. if InitSSLInterface and Assigned(_PKCS7_set_digest) then
  3842. Result:=_PKCS7_set_digest(p7,md)
  3843. else
  3844. Result:=-1;
  3845. end;
  3846. function PKCS7_add_recipient(p7:PPKCS7; x509:PX509):PPKCS7_RECIP_INFO;
  3847. begin
  3848. if InitSSLInterface and Assigned(_PKCS7_add_recipient) then
  3849. Result:=_PKCS7_add_recipient(p7,x509)
  3850. else
  3851. Result:=Nil;
  3852. end;
  3853. function PKCS7_add_recipient_info(p7:PPKCS7; ri:PPKCS7_RECIP_INFO):longint;
  3854. begin
  3855. if InitSSLInterface and Assigned(_PKCS7_add_recipient_info) then
  3856. Result:=_PKCS7_add_recipient_info(p7,ri)
  3857. else
  3858. Result:=-1;
  3859. end;
  3860. function PKCS7_RECIP_INFO_set(p7i:PPKCS7_RECIP_INFO; x509:PX509):longint;
  3861. begin
  3862. if InitSSLInterface and Assigned(_PKCS7_RECIP_INFO_set) then
  3863. Result:=_PKCS7_RECIP_INFO_set(p7i,x509)
  3864. else
  3865. Result:=-1;
  3866. end;
  3867. function PKCS7_set_cipher(p7:PPKCS7; cipher:PEVP_CIPHER):longint;
  3868. begin
  3869. if InitSSLInterface and Assigned(_PKCS7_set_cipher) then
  3870. Result:=_PKCS7_set_cipher(p7,cipher)
  3871. else
  3872. Result:=-1;
  3873. end;
  3874. function PKCS7_get_issuer_and_serial(p7:PPKCS7; idx:longint):PPKCS7_ISSUER_AND_SERIAL;
  3875. begin
  3876. if InitSSLInterface and Assigned(_PKCS7_get_issuer_and_serial) then
  3877. Result:=_PKCS7_get_issuer_and_serial(P7,idx)
  3878. else
  3879. Result:=Nil;
  3880. end;
  3881. function PKCS7_digest_from_attributes(sk:Pstack_st_X509_ATTRIBUTE):Pointer;
  3882. begin
  3883. if InitSSLInterface and Assigned(_PKCS7_digest_from_attributes) then
  3884. Result:=_PKCS7_digest_from_attributes(sk)
  3885. else
  3886. Result:=Nil;
  3887. end;
  3888. function PKCS7_add_signed_attribute(p7si:PPKCS7_SIGNER_INFO; nid:longint; _type:longint; data:pointer):longint;
  3889. begin
  3890. if InitSSLInterface and Assigned(_PKCS7_add_signed_attribute) then
  3891. Result:=_PKCS7_add_signed_attribute(p7si,nid,_type,data)
  3892. else
  3893. Result:=-1;
  3894. end;
  3895. function PKCS7_add_attribute(p7si:PPKCS7_SIGNER_INFO; nid:longint; atrtype:longint; value:pointer):longint;
  3896. begin
  3897. if InitSSLInterface and Assigned(_PKCS7_add_attribute) then
  3898. Result:=_PKCS7_add_attribute(p7si,nid,atrtype,value)
  3899. else
  3900. Result:=-1;
  3901. end;
  3902. function PKCS7_get_attribute(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;
  3903. begin
  3904. if InitSSLInterface and Assigned(_PKCS7_get_attribute) then
  3905. Result:=_PKCS7_get_attribute(si,nid)
  3906. else
  3907. Result:=Nil;
  3908. end;
  3909. function PKCS7_get_signed_attribute(si:PPKCS7_SIGNER_INFO; nid:longint):PASN1_TYPE;
  3910. begin
  3911. if InitSSLInterface and Assigned(_PKCS7_get_signed_attribute) then
  3912. Result:=_PKCS7_get_signed_attribute(si,nid)
  3913. else
  3914. Result:=Nil;
  3915. end;
  3916. function PKCS7_set_signed_attributes(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;
  3917. begin
  3918. if InitSSLInterface and Assigned(_PKCS7_set_signed_attributes) then
  3919. Result:=_PKCS7_set_signed_attributes(p7si,sk)
  3920. else
  3921. Result:=-1;
  3922. end;
  3923. function PKCS7_set_attributes(p7si:PPKCS7_SIGNER_INFO; sk:Pstack_st_X509_ATTRIBUTE):longint;
  3924. begin
  3925. if InitSSLInterface and Assigned(_PKCS7_set_attributes) then
  3926. Result:=_PKCS7_set_attributes(p7si,sk)
  3927. else
  3928. Result:=-1;
  3929. end;
  3930. function PKCS7_sign(signcert:PX509; pkey:PEVP_PKEY; certs:Pstack_st_X509; data:PBIO; flags:longint):PPKCS7;
  3931. begin
  3932. if InitSSLInterface and Assigned(_PKCS7_sign) then
  3933. Result:=_PKCS7_sign(signcert,pkey,certs,data,flags)
  3934. else
  3935. Result:=Nil;
  3936. end;
  3937. function PKCS7_sign_add_signer(p7:PPKCS7; signcert:PX509; pkey:PEVP_PKEY; md:PEVP_MD; flags:longint):PPKCS7_SIGNER_INFO;
  3938. begin
  3939. if InitSSLInterface and Assigned(_PKCS7_sign_add_signer) then
  3940. Result:=_PKCS7_sign_add_signer(p7,signcert,pkey,md,flags)
  3941. else
  3942. Result:=Nil;
  3943. end;
  3944. function PKCS7_final(p7:PPKCS7; data:PBIO; flags:longint):longint;
  3945. begin
  3946. if InitSSLInterface and Assigned(_PKCS7_final) then
  3947. Result:=_PKCS7_final(p7,data,Flags)
  3948. else
  3949. Result:=-1;
  3950. end;
  3951. function PKCS7_verify(p7:PPKCS7; certs:Pstack_st_X509; store: Pointer; indata:PBIO; _out:PBIO; flags:longint):longint;
  3952. begin
  3953. if InitSSLInterface and Assigned(_PKCS7_verify) then
  3954. Result:=_PKCS7_verify(p7,certs,store,indata,_out,flags)
  3955. else
  3956. Result:=-1;
  3957. end;
  3958. function PKCS7_encrypt(certs:Pstack_st_X509; _in:PBIO; cipher:PEVP_CIPHER; flags:longint):PPKCS7;
  3959. begin
  3960. if InitSSLInterface and Assigned(_PKCS7_encrypt) then
  3961. Result:=_PKCS7_encrypt(certs,_in,cipher,flags)
  3962. else
  3963. Result:=Nil;
  3964. end;
  3965. function PKCS7_decrypt(p7:PPKCS7; pkey:PEVP_PKEY; cert:PX509; data:PBIO; flags:longint):longint;
  3966. begin
  3967. if InitSSLInterface and Assigned(_PKCS7_decrypt) then
  3968. Result:=_PKCS7_decrypt(P7,pkey,cert,data,flags)
  3969. else
  3970. Result:=-1;
  3971. end;
  3972. function PKCS7_add_attrib_smimecap(si:PPKCS7_SIGNER_INFO; cap:Pstack_st_X509_ALGOR):longint;
  3973. begin
  3974. if InitSSLInterface and Assigned(_PKCS7_add_attrib_smimecap) then
  3975. Result:=_PKCS7_add_attrib_smimecap(si,cap)
  3976. else
  3977. Result:=-1;
  3978. end;
  3979. function PKCS7_simple_smimecap(sk:Pstack_st_X509_ALGOR; nid:longint; arg:longint):longint;
  3980. begin
  3981. if InitSSLInterface and Assigned(_PKCS7_simple_smimecap) then
  3982. Result:=_PKCS7_simple_smimecap(sk,nid,arg)
  3983. else
  3984. Result:=-1;
  3985. end;
  3986. function PKCS7_add_attrib_content_type(si:PPKCS7_SIGNER_INFO; coid:Pointer):longint;
  3987. begin
  3988. if InitSSLInterface and Assigned(_PKCS7_add_attrib_content_type) then
  3989. Result:=_PKCS7_add_attrib_content_type(si,coid)
  3990. else
  3991. Result:=-1;
  3992. end;
  3993. function PKCS7_add0_attrib_signing_time(si:PPKCS7_SIGNER_INFO; t:PASN1_TIME):longint;
  3994. begin
  3995. if InitSSLInterface and Assigned(_PKCS7_add0_attrib_signing_time) then
  3996. Result:=_PKCS7_add0_attrib_signing_time(si,t)
  3997. else
  3998. Result:=-1;
  3999. end;
  4000. function PKCS7_add1_attrib_digest(si:PPKCS7_SIGNER_INFO; md:Pbyte; mdlen:longint):longint;
  4001. begin
  4002. if InitSSLInterface and Assigned(_PKCS7_add1_attrib_digest) then
  4003. Result:=_PKCS7_add1_attrib_digest(si,md,mdlen)
  4004. else
  4005. Result:=-1;
  4006. end;
  4007. function BIO_new_PKCS7(_out:PBIO; p7:PPKCS7):PBIO;
  4008. begin
  4009. if InitSSLInterface and Assigned(_BIO_new_PKCS7) then
  4010. Result:=_BIO_new_PKCS7(_out,p7)
  4011. else
  4012. Result:=Nil;
  4013. end;
  4014. procedure ERR_load_PKCS7_strings;
  4015. begin
  4016. if InitSSLInterface and Assigned(_ERR_load_PKCS7_strings) then
  4017. _ERR_load_PKCS7_strings
  4018. end;
  4019. // SMIME
  4020. function SMIME_write_PKCS7(_out: PBIO; p7: PPKCS7; data: PBIO; flags: longint): longint;
  4021. begin
  4022. if InitSSLInterface and Assigned(_SMIME_write_PKCS7) then
  4023. Result := _SMIME_write_PKCS7(_out, p7, data, flags)
  4024. else
  4025. Result := -1;
  4026. end;
  4027. function SMIME_read_PKCS7(_in: PBIO; bcont: PPBIO): PPKCS7;
  4028. begin
  4029. if InitSSLInterface and Assigned(_SMIME_read_PKCS7) then
  4030. Result := _SMIME_read_PKCS7(_in, bcont)
  4031. else
  4032. Result := nil;
  4033. end;
  4034. // BN
  4035. function BN_new: PBIGNUM;
  4036. begin
  4037. if InitSSLInterface and Assigned(_BN_new) then
  4038. Result:=_BN_new()
  4039. else
  4040. Result:=Nil;
  4041. end;
  4042. function BN_secure_new: PBIGNUM;
  4043. begin
  4044. if InitSSLInterface and Assigned(_BIO_new_PKCS7) then
  4045. Result:=_BN_secure_new()
  4046. else
  4047. Result:=Nil;
  4048. end;
  4049. procedure BN_clear_free(a: PBIGNUM);
  4050. begin
  4051. if InitSSLInterface and Assigned(_BN_clear_free) then
  4052. _BN_clear_free(a)
  4053. end;
  4054. function BN_copy(a: PBIGNUM; b: PBIGNUM): PBIGNUM;
  4055. begin
  4056. if InitSSLInterface and Assigned(_BN_copy) then
  4057. Result:=_BN_copy(a, b)
  4058. else
  4059. Result:=Nil;
  4060. end;
  4061. procedure BN_swap(a: PBIGNUM; b: PBIGNUM);
  4062. begin
  4063. if InitSSLInterface and Assigned(_BN_swap) then
  4064. _BN_swap(a, b);
  4065. end;
  4066. function BN_bin2bn(s: pcuchar; len: cint; ret: PBIGNUM): PBIGNUM;
  4067. begin
  4068. if InitSSLInterface and Assigned(_BN_bin2bn) then
  4069. Result:=_BN_bin2bn(s, len, ret)
  4070. else
  4071. Result:=Nil;
  4072. end;
  4073. function BN_bn2bin(a: PBIGNUM; _to: pcuchar): cint;
  4074. begin
  4075. if InitSSLInterface and Assigned(_BN_bn2bin) then
  4076. Result:=_BN_bn2bin(a, _to)
  4077. else
  4078. Result:=-1;
  4079. end;
  4080. function BN_bn2binpad(a: PBIGNUM; _to: pcuchar; tolen: cint): cint;
  4081. begin
  4082. if InitSSLInterface and Assigned(_BN_bn2binpad) then
  4083. Result:=_BN_bn2binpad(a, _to, tolen)
  4084. else
  4085. Result:=-1;
  4086. end;
  4087. function BN_lebin2bn(s: pcuchar; len: cint; ret: PBIGNUM): PBIGNUM;
  4088. begin
  4089. if InitSSLInterface and Assigned(_BN_lebin2bn) then
  4090. Result:=_BN_lebin2bn(s, len, ret)
  4091. else
  4092. Result:=Nil;
  4093. end;
  4094. function BN_bn2lebinpad(a: PBIGNUM; _to: pcuchar; tolen: cint): cint;
  4095. begin
  4096. if InitSSLInterface and Assigned(_BN_bn2lebinpad) then
  4097. Result:=_BN_bn2lebinpad(a, _to, tolen)
  4098. else
  4099. Result:=-1;
  4100. end;
  4101. function BN_mpi2bn(s: pcuchar; len: cint; ret: PBIGNUM): PBIGNUM;
  4102. begin
  4103. if InitSSLInterface and Assigned(_BN_mpi2bn) then
  4104. Result:=_BN_mpi2bn(s, len, ret)
  4105. else
  4106. Result:=Nil;
  4107. end;
  4108. function BN_bn2mpi(a: PBIGNUM; _to: pcuchar): cint;
  4109. begin
  4110. if InitSSLInterface and Assigned(_BN_bn2mpi) then
  4111. Result:=_BN_bn2mpi(a, _to)
  4112. else
  4113. Result:=-1;
  4114. end;
  4115. function BN_sub(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM): cint;
  4116. begin
  4117. if InitSSLInterface and Assigned(_BN_sub) then
  4118. Result:=_BN_sub(r, a, b)
  4119. else
  4120. Result:=-1;
  4121. end;
  4122. function BN_usub(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM): cint;
  4123. begin
  4124. if InitSSLInterface and Assigned(_BN_usub) then
  4125. Result:=_BN_usub(r, a, b)
  4126. else
  4127. Result:=-1;
  4128. end;
  4129. function BN_uadd(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM): cint;
  4130. begin
  4131. if InitSSLInterface and Assigned(_BN_uadd) then
  4132. Result:=_BN_uadd(r, a, b)
  4133. else
  4134. Result:=-1;
  4135. end;
  4136. function BN_add(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM): cint;
  4137. begin
  4138. if InitSSLInterface and Assigned(_BN_add) then
  4139. Result:=_BN_add(r, a, b)
  4140. else
  4141. Result:=-1;
  4142. end;
  4143. function BN_mul(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; ctx: PBN_CTX): cint;
  4144. begin
  4145. if InitSSLInterface and Assigned(_BN_mul) then
  4146. Result:=_BN_mul(r, a, b, ctx)
  4147. else
  4148. Result:=-1;
  4149. end;
  4150. function BN_sqr(r: PBIGNUM; a: PBIGNUM; ctx: PBN_CTX): cint;
  4151. begin
  4152. if InitSSLInterface and Assigned(_BN_sqr) then
  4153. Result:=_BN_sqr(r, a, ctx)
  4154. else
  4155. Result:=-1;
  4156. end;
  4157. procedure BN_set_negative(b: PBIGNUM; n: cint);
  4158. begin
  4159. if InitSSLInterface and Assigned(_BN_set_negative) then
  4160. _BN_set_negative(b, n);
  4161. end;
  4162. function BN_is_negative(b: PBIGNUM): cint;
  4163. begin
  4164. if InitSSLInterface and Assigned(_BN_is_negative) then
  4165. Result:=_BN_is_negative(b)
  4166. else
  4167. Result:=-1;
  4168. end;
  4169. function BN_div(dv: PBIGNUM; rem: PBIGNUM; m: PBIGNUM; d: PBIGNUM; ctx: PBN_CTX): cint;
  4170. begin
  4171. if InitSSLInterface and Assigned(_BN_div) then
  4172. Result:=_BN_div(dv, rem, m, d, ctx)
  4173. else
  4174. Result:=-1;
  4175. end;
  4176. function BN_mod(rem: PBIGNUM; a: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4177. begin
  4178. Result:=-1;
  4179. if InitSSLInterface then
  4180. if Assigned(_BN_mod) then
  4181. Result:=_BN_mod(rem, a, m, ctx)
  4182. else if assigned(_BN_div) then
  4183. Result:=_BN_div(nil,rem, a, m, ctx)
  4184. end;
  4185. function BN_nnmod(r: PBIGNUM; m: PBIGNUM; d: PBIGNUM; ctx: PBN_CTX): cint;
  4186. begin
  4187. if InitSSLInterface and Assigned(_BN_nnmod) then
  4188. Result:=_BN_nnmod(r, m, d, ctx)
  4189. else
  4190. Result:=-1;
  4191. end;
  4192. function BN_mod_add(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4193. begin
  4194. if InitSSLInterface and Assigned(_BN_mod_add) then
  4195. Result:=_BN_mod_add(r, a, b, m, ctx)
  4196. else
  4197. Result:=-1;
  4198. end;
  4199. function BN_mod_add_quick(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; m: PBIGNUM): cint;
  4200. begin
  4201. if InitSSLInterface and Assigned(_BN_mod_add_quick) then
  4202. Result:=_BN_mod_add_quick(r, a, b, m)
  4203. else
  4204. Result:=-1;
  4205. end;
  4206. function BN_mod_sub(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4207. begin
  4208. if InitSSLInterface and Assigned(_BN_mod_sub) then
  4209. Result:=_BN_mod_sub(r, a, b, m, ctx)
  4210. else
  4211. Result:=-1;
  4212. end;
  4213. function BN_mod_sub_quick(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; m: PBIGNUM): cint;
  4214. begin
  4215. if InitSSLInterface and Assigned(_BN_mod_sub_quick) then
  4216. Result:=_BN_mod_sub_quick(r, a, b, m)
  4217. else
  4218. Result:=-1;
  4219. end;
  4220. function BN_mod_mul(r: PBIGNUM; a: PBIGNUM; b: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4221. begin
  4222. if InitSSLInterface and Assigned(_BN_mod_mul) then
  4223. Result:=_BN_mod_mul(r, a, b, m, ctx)
  4224. else
  4225. Result:=-1;
  4226. end;
  4227. function BN_mod_sqr(r: PBIGNUM; a: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4228. begin
  4229. if InitSSLInterface and Assigned(_BN_mod_sqr) then
  4230. Result:=_BN_mod_sqr(r, a, m, ctx)
  4231. else
  4232. Result:=-1;
  4233. end;
  4234. function BN_mod_lshift1(r: PBIGNUM; a: PBIGNUM; m: PBIGNUM; ctx: PBN_CTX): cint;
  4235. begin
  4236. if InitSSLInterface and Assigned(_BN_mod_lshift1) then
  4237. Result:=_BN_mod_lshift1(r, a, m, ctx)
  4238. else
  4239. Result:=-1;
  4240. end;
  4241. function BN_mod_lshift1_quick(r: PBIGNUM; a: PBIGNUM; m: PBIGNUM): cint;
  4242. begin
  4243. if InitSSLInterface and Assigned(_BN_mod_lshift1_quick) then
  4244. Result:=_BN_mod_lshift1_quick(r, a, m)
  4245. else
  4246. Result:=-1;
  4247. end;
  4248. function BN_mod_lshift(r: PBIGNUM; a: PBIGNUM; n: cint; m: PBIGNUM; ctx: PBN_CTX): cint;
  4249. begin
  4250. if InitSSLInterface and Assigned(_BN_mod_lshift) then
  4251. Result:=_BN_mod_lshift(r, a, n, m, ctx)
  4252. else
  4253. Result:=-1;
  4254. end;
  4255. function BN_mod_lshift_quick(r: PBIGNUM; a: PBIGNUM; n: cint; m: PBIGNUM): cint;
  4256. begin
  4257. if InitSSLInterface and Assigned(_BN_mod_lshift_quick) then
  4258. Result:=_BN_mod_lshift_quick(r, a, n, m)
  4259. else
  4260. Result:=-1;
  4261. end;
  4262. function BN_mod_word(a: PBIGNUM; w: BN_ULONG): BN_ULONG;
  4263. begin
  4264. if InitSSLInterface and Assigned(_BN_mod_word) then
  4265. Result:=_BN_mod_word(a, w)
  4266. else
  4267. Result:=0;
  4268. end;
  4269. function BN_div_word(a: PBIGNUM; w: BN_ULONG): BN_ULONG;
  4270. begin
  4271. if InitSSLInterface and Assigned(_BN_div_word) then
  4272. Result:=_BN_div_word(a, w)
  4273. else
  4274. Result:=0;
  4275. end;
  4276. function BN_mul_word(a: PBIGNUM; w: BN_ULONG): cint;
  4277. begin
  4278. if InitSSLInterface and Assigned(_BN_mul_word) then
  4279. Result:=_BN_mul_word(a, w)
  4280. else
  4281. Result:=-1;
  4282. end;
  4283. function BN_add_word(a: PBIGNUM; w: BN_ULONG): cint;
  4284. begin
  4285. if InitSSLInterface and Assigned(_BN_add_word) then
  4286. Result:=_BN_add_word(a, w)
  4287. else
  4288. Result:=-1;
  4289. end;
  4290. function BN_sub_word(a: PBIGNUM; w: BN_ULONG): cint;
  4291. begin
  4292. if InitSSLInterface and Assigned(_BN_sub_word) then
  4293. Result:=_BN_sub_word(a, w)
  4294. else
  4295. Result:=-1;
  4296. end;
  4297. function BN_set_word(a: PBIGNUM; w: BN_ULONG): cint;
  4298. begin
  4299. if InitSSLInterface and Assigned(_BN_set_word) then
  4300. Result:=_BN_set_word(a, w)
  4301. else
  4302. Result:=-1;
  4303. end;
  4304. function BN_get_word(a: PBIGNUM): BN_ULONG;
  4305. begin
  4306. if InitSSLInterface and Assigned(_BN_get_word) then
  4307. Result:=_BN_get_word(a)
  4308. else
  4309. Result:=0;
  4310. end;
  4311. function BN_cmp(a: PBIGNUM; b: PBIGNUM): cint;
  4312. begin
  4313. if InitSSLInterface and Assigned(_BN_cmp) then
  4314. Result:=_BN_cmp(a, b)
  4315. else
  4316. Result:=-1;
  4317. end;
  4318. procedure BN_free(a: PBIGNUM);
  4319. begin
  4320. if InitSSLInterface and Assigned(_BN_free) then
  4321. _BN_free(a);
  4322. end;
  4323. procedure CRYPTOcleanupAllExData;
  4324. begin
  4325. if InitSSLInterface and Assigned(_CRYPTOcleanupAllExData) then
  4326. _CRYPTOcleanupAllExData;
  4327. end;
  4328. procedure OPENSSLaddallalgorithms;
  4329. begin
  4330. if InitSSLInterface and Assigned(_OPENSSLaddallalgorithms) then
  4331. _OPENSSLaddallalgorithms;
  4332. end;
  4333. Function CheckOK(ProcName : AnsiString ) : AnsiString;
  4334. begin
  4335. Result:=ProcName;
  4336. if (ProcName='SSL_library_init')
  4337. or (ProcName='SSL_load_error_strings')
  4338. or (ProcName='ERR_load_crypto_strings')
  4339. or (ProcName='ERR_load_CRYPTOlib_strings')
  4340. or (ProcName='OpenSSL_add_all_algorithms')
  4341. or (ProcName='OpenSSL_add_all_ciphers')
  4342. or (ProcName='OpenSSL_add_all_digests')
  4343. or (ProcName='EVP_CIPHER_CTX_init')
  4344. or (ProcName='EVP_CIPHER_CTX_reset')
  4345. or (ProcName='EVP_CIPHER_CTX_cleanup')
  4346. or (ProcName='EVP_cleanup')
  4347. or (ProcName='OPENSSL_cleanup')
  4348. or (ProcName='OPENSSL_init_crypto')
  4349. or (ProcName='OPENSSL_INIT_new')
  4350. or (ProcName='OPENSSL_INIT_free')
  4351. or (ProcName='OPENSSL_INIT_set_config_appname')
  4352. or (ProcName='OPENSSL_init_ssl')
  4353. or (ProcName='SSLeay_version')
  4354. or (ProcName='ERR_free_strings')
  4355. or (ProcName='X509_set_notBefore')
  4356. or (ProcName='X509_set1_notBefore')
  4357. or (ProcName='X509_set_notAfter')
  4358. or (ProcName='X509_set1_notAfter')
  4359. or (ProcName='RAND_screen')
  4360. or (ProcName='RAND_cleanup')
  4361. or (ProcName='RAND_SSLeay')
  4362. or (ProcName='CRYPTO_num_locks')
  4363. or (ProcName='CRYPTO_set_locking_callback')
  4364. or (ProcName='BN_mod')
  4365. or (ProcName='OpenSSL_version') then
  4366. Result:=Result+' (handled in unit)';
  4367. if (ProcName='SSLv2_method')
  4368. or (ProcName='SSLv3_method')
  4369. or (ProcName='SSLv23_method')
  4370. or (ProcName='RAND_query_egd_bytes')
  4371. or (ProcName='RAND_egd')
  4372. or (ProcName='RAND_egd_bytes')
  4373. then
  4374. Result:=Result+' (method not supported by lib)';
  4375. end;
  4376. function GetProcAddr(module: HModule; const ProcName: AnsiString): SslPtr;
  4377. begin
  4378. Result := GetProcAddress(module, PAnsiChar(ProcName));
  4379. if LoadVerbose and (Result = nil) then
  4380. OpenSSL_unavailable_functions := OpenSSL_unavailable_functions + CheckOK(ProcName) + LineEnding;
  4381. end;
  4382. // The AVerboseLoading parameter can be used to check which particular
  4383. // functions weren't loaded correctly. They will be available in the
  4384. // global variable OpenSSL_unavailable_functions
  4385. function IsSSLloaded: Boolean;
  4386. begin
  4387. Result := SSLLoaded;
  4388. end;
  4389. Procedure LoadSSLEntryPoints;
  4390. begin
  4391. _SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
  4392. _SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
  4393. _OPENSSL_init_ssl := GetProcAddr(SSLLibHandle, 'OPENSSL_init_ssl');
  4394. _SslLoadErrorStrings := GetProcAddr(SSLLibHandle, 'SSL_load_error_strings');
  4395. _SslCtxSetCipherList := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_cipher_list');
  4396. _SslCtxNew := GetProcAddr(SSLLibHandle, 'SSL_CTX_new');
  4397. _SslCtxFree := GetProcAddr(SSLLibHandle, 'SSL_CTX_free');
  4398. _SslSetFd := GetProcAddr(SSLLibHandle, 'SSL_set_fd');
  4399. _SslCtrl := GetProcAddr(SSLLibHandle, 'SSL_ctrl');
  4400. _SslCTXCtrl := GetProcAddr(SSLLibHandle, 'SSL_CTX_ctrl');
  4401. _SslMethodV2 := GetProcAddr(SSLLibHandle, 'SSLv2_method');
  4402. _SslMethodV3 := GetProcAddr(SSLLibHandle, 'SSLv3_method');
  4403. _SslMethodTLSV1 := GetProcAddr(SSLLibHandle, 'TLSv1_method');
  4404. _SslMethodTLSV1_1 := GetProcAddr(SSLLibHandle, 'TLSv1_1_method');
  4405. _SslMethodTLSV1_2 := GetProcAddr(SSLLibHandle, 'TLSv1_2_method');
  4406. _SslMethodV23 := GetProcAddr(SSLLibHandle, 'SSLv23_method');
  4407. _SslTLSMethod := GetProcAddr(SSLLibHandle, 'TLS_method');
  4408. _SslCtxUsePrivateKey := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey');
  4409. _SslCtxUsePrivateKeyASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey_ASN1');
  4410. //use SSL_CTX_use_RSAPrivateKey_file instead SSL_CTX_use_PrivateKey_file,
  4411. //because SSL_CTX_use_PrivateKey_file not support DER format. :-O
  4412. _SslCtxUsePrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_RSAPrivateKey_file');
  4413. _SslCtxUseCertificate := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate');
  4414. _SslCtxUseCertificateASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_ASN1');
  4415. _SslCtxUseCertificateFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_file');
  4416. _SslCtxUseCertificateChainFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_chain_file');
  4417. _SslCtxCheckPrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_check_private_key');
  4418. _SslCtxSetDefaultPasswdCb := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb');
  4419. _SslCtxSetDefaultPasswdCbUserdata := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb_userdata');
  4420. _SslCtxLoadVerifyLocations := GetProcAddr(SSLLibHandle, 'SSL_CTX_load_verify_locations');
  4421. _SslNew := GetProcAddr(SSLLibHandle, 'SSL_new');
  4422. _SslFree := GetProcAddr(SSLLibHandle, 'SSL_free');
  4423. _SslAccept := GetProcAddr(SSLLibHandle, 'SSL_accept');
  4424. _SslConnect := GetProcAddr(SSLLibHandle, 'SSL_connect');
  4425. _SslShutdown := GetProcAddr(SSLLibHandle, 'SSL_shutdown');
  4426. _SslRead := GetProcAddr(SSLLibHandle, 'SSL_read');
  4427. _SslPeek := GetProcAddr(SSLLibHandle, 'SSL_peek');
  4428. _SslWrite := GetProcAddr(SSLLibHandle, 'SSL_write');
  4429. _SslPending := GetProcAddr(SSLLibHandle, 'SSL_pending');
  4430. _SslGetPeerCertificate := GetProcAddr(SSLLibHandle, 'SSL_get_peer_certificate');
  4431. if not Assigned(_SslGetPeerCertificate)
  4432. then _SslGetPeerCertificate := GetProcAddr(SSLLibHandle, 'SSL_get1_peer_certificate');
  4433. _SslGetVersion := GetProcAddr(SSLLibHandle, 'SSL_get_version');
  4434. _SslCtxSetVerify := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_verify');
  4435. _SslGetCurrentCipher := GetProcAddr(SSLLibHandle, 'SSL_get_current_cipher');
  4436. _SslCipherGetName := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_name');
  4437. _SslCipherGetBits := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_bits');
  4438. _SslGetVerifyResult := GetProcAddr(SSLLibHandle, 'SSL_get_verify_result');
  4439. _SslGetServername := GetProcAddr(SSLLibHandle, 'SSL_get_servername');
  4440. _SslCtxCallbackCtrl := GetProcAddr(SSLLibHandle, 'SSL_CTX_callback_ctrl');
  4441. _SslSetSslCtx := GetProcAddr(SSLLibHandle, 'SSL_set_SSL_CTX');
  4442. _SslSet1Host := GetProcAddr(SSLLibHandle, 'SSL_set1_host');
  4443. end;
  4444. Procedure LoadUtilEntryPoints;
  4445. begin
  4446. _ERR_load_crypto_strings := GetProcAddr(SSLUtilHandle, 'ERR_load_crypto_strings');
  4447. // aliases used over time
  4448. if (@_ERR_load_crypto_strings=Nil) then
  4449. _ERR_load_crypto_strings:=GetProcAddr(SSLUtilHandle, 'ERR_load_CRYPTOlib_strings');
  4450. if (@_ERR_load_crypto_strings=Nil) then
  4451. _ERR_load_crypto_strings:=GetProcAddr(SSLUtilHandle, 'ERR_load_CRYPTO_strings');
  4452. _OPENSSL_init_crypto := GetProcAddr(SSLUtilHandle, 'OPENSSL_init_crypto');
  4453. _OPENSSL_INIT_new := GetProcAddr(SSLUtilHandle, 'OPENSSL_INIT_new');
  4454. _OPENSSL_INIT_free := GetProcAddr(SSLUtilHandle, 'OPENSSL_INIT_free');
  4455. _OPENSSL_INIT_set_config_appname :=GetProcAddr(SSLUtilHandle, 'OPENSSL_INIT_set_config_appname');
  4456. _X509New := GetProcAddr(SSLUtilHandle, 'X509_new');
  4457. _X509Free := GetProcAddr(SSLUtilHandle, 'X509_free');
  4458. _X509NameOneline := GetProcAddr(SSLUtilHandle, 'X509_NAME_oneline');
  4459. _X509GetSubjectName := GetProcAddr(SSLUtilHandle, 'X509_get_subject_name');
  4460. _X509GetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_get_issuer_name');
  4461. _X509NameHash := GetProcAddr(SSLUtilHandle, 'X509_NAME_hash');
  4462. _X509Digest := GetProcAddr(SSLUtilHandle, 'X509_digest');
  4463. _X509print := GetProcAddr(SSLUtilHandle, 'X509_print');
  4464. _X509SetVersion := GetProcAddr(SSLUtilHandle, 'X509_set_version');
  4465. _X509SetPubkey := GetProcAddr(SSLUtilHandle, 'X509_set_pubkey');
  4466. _X509GetPubkey := GetProcAddr(SSLUtilHandle, 'X509_get_pubkey');
  4467. _X509SetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_set_issuer_name');
  4468. _X509NameAddEntryByTxt := GetProcAddr(SSLUtilHandle, 'X509_NAME_add_entry_by_txt');
  4469. _X509Sign := GetProcAddr(SSLUtilHandle, 'X509_sign');
  4470. _X509GmtimeAdj := GetProcAddr(SSLUtilHandle, 'X509_gmtime_adj');
  4471. _X509SetNotBefore := GetProcAddr(SSLUtilHandle, 'X509_set_notBefore');
  4472. if (@_X509SetNotBefore=nil) then
  4473. _X509SetNotBefore:=GetProcAddr(SSLUtilHandle, 'X509_set1_notBefore');
  4474. _X509SetNotAfter := GetProcAddr(SSLUtilHandle, 'X509_set_notAfter');
  4475. if (@_X509SetNotAfter=nil) then
  4476. _X509SetNotAfter:=GetProcAddr(SSLUtilHandle, 'X509_set1_notAfter');
  4477. _X509GetSerialNumber := GetProcAddr(SSLUtilHandle, 'X509_get_serialNumber');
  4478. _EvpPkeyNew := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_new');
  4479. _EvpPkeyFree := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_free');
  4480. _EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
  4481. _EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
  4482. _EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
  4483. _OpenSSLVersion := GetProcAddr(SSLUtilHandle, 'OpenSSL_version');
  4484. _SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
  4485. if @_SSLeayversion=Nil then
  4486. _SSLeayversion := _OpenSSLVersion;
  4487. _ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
  4488. _ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
  4489. _ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
  4490. _ErrFreeStrings := GetProcAddr(SSLUtilHandle, 'ERR_free_strings');
  4491. _ErrRemoveState := GetProcAddr(SSLUtilHandle, 'ERR_remove_state');
  4492. _RandScreen := GetProcAddr(SSLUtilHandle, 'RAND_screen');
  4493. _BioNew := GetProcAddr(SSLUtilHandle, 'BIO_new');
  4494. _BioFreeAll := GetProcAddr(SSLUtilHandle, 'BIO_free_all');
  4495. _BioSMem := GetProcAddr(SSLUtilHandle, 'BIO_s_mem');
  4496. _BioCtrlPending := GetProcAddr(SSLUtilHandle, 'BIO_ctrl_pending');
  4497. _BioRead := GetProcAddr(SSLUtilHandle, 'BIO_read');
  4498. _BioWrite := GetProcAddr(SSLUtilHandle, 'BIO_write');
  4499. _d2iPKCS12bio := GetProcAddr(SSLUtilHandle, 'd2i_PKCS12_bio');
  4500. _PKCS12parse := GetProcAddr(SSLUtilHandle, 'PKCS12_parse');
  4501. _PKCS12free := GetProcAddr(SSLUtilHandle, 'PKCS12_free');
  4502. _Asn1UtctimeSetString := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_set_string');
  4503. _Asn1StringTypeNew := GetProcAddr(SSLUtilHandle, 'ASN1_STRING_type_new');
  4504. _Asn1UtctimePrint := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_print');
  4505. _Asn1UtctimeFree := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_free');
  4506. _Asn1IntegerSet := GetProcAddr(SSLUtilHandle, 'ASN1_INTEGER_set');
  4507. _Asn1IntegerGet := GetProcAddr(SSLUtilHandle, 'ASN1_INTEGER_get');
  4508. _i2dX509bio := GetProcAddr(SSLUtilHandle, 'i2d_X509_bio');
  4509. _d2iX509bio := GetProcAddr(SSLUtilHandle, 'd2i_X509_bio');
  4510. _PEMReadBioX509 := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_X509');
  4511. _SkX509PopFree := GetProcAddr(SSLUtilHandle, 'SK_X509_POP_FREE');
  4512. _i2dPrivateKeyBio := GetProcAddr(SSLUtilHandle, 'i2d_PrivateKey_bio');
  4513. _EVP_enc_null := GetProcAddr(SSLUtilHandle, 'EVP_enc_null');
  4514. _EVP_rc2_cbc := GetProcAddr(SSLUtilHandle, 'EVP_rc2_cbc');
  4515. _EVP_rc2_40_cbc := GetProcAddr(SSLUtilHandle, 'EVP_rc2_40_cbc');
  4516. _EVP_rc2_64_cbc := GetProcAddr(SSLUtilHandle, 'EVP_rc2_64_cbc');
  4517. _EVP_rc4 := GetProcAddr(SSLUtilHandle, 'EVP_rc4');
  4518. _EVP_rc4_40 := GetProcAddr(SSLUtilHandle, 'EVP_rc4_40');
  4519. _EVP_des_cbc := GetProcAddr(SSLUtilHandle, 'EVP_des_cbc');
  4520. _EVP_des_ede3_cbc := GetProcAddr(SSLUtilHandle, 'EVP_des_ede3_cbc');
  4521. _EVP_aes_128_cbc := GetProcAddr(SSLUtilHandle, 'EVP_aes_128_cbc');
  4522. _EVP_aes_192_cbc := GetProcAddr(SSLUtilHandle, 'EVP_aes_192_cbc');
  4523. _EVP_aes_256_cbc := GetProcAddr(SSLUtilHandle, 'EVP_aes_256_cbc');
  4524. _EVP_aes_128_cfb8 := GetProcAddr(SSLUtilHandle, 'EVP_aes_128_cfb8');
  4525. _EVP_aes_192_cfb8 := GetProcAddr(SSLUtilHandle, 'EVP_aes_192_cfb8');
  4526. _EVP_aes_256_cfb8 := GetProcAddr(SSLUtilHandle, 'EVP_aes_256_cfb8');
  4527. _EVP_camellia_128_cbc := GetProcAddr(SSLUtilHandle, 'EVP_camellia_128_cbc');
  4528. _EVP_camellia_192_cbc := GetProcAddr(SSLUtilHandle, 'EVP_camellia_192_cbc');
  4529. _EVP_camellia_256_cbc := GetProcAddr(SSLUtilHandle, 'EVP_camellia_256_cbc');
  4530. _EVP_sha256 := GetProcAddr(SSLUtilHandle, 'EVP_sha256');
  4531. _EVP_MD_CTX_new := GetProcAddr(SSLUtilHandle, 'EVP_MD_CTX_new');
  4532. _EVP_MD_CTX_free := GetProcAddr(SSLUtilHandle, 'EVP_MD_CTX_free');
  4533. _EVP_DigestSignInit := GetProcAddr(SSLUtilHandle, 'EVP_DigestSignInit');
  4534. _EVP_DigestSignFinal := GetProcAddr(SSLUtilHandle, 'EVP_DigestSignFinal');
  4535. _EVP_DigestSign := GetProcAddr(SSLUtilHandle, 'EVP_DigestSign');
  4536. _EVP_DigestVerifyInit := GetProcAddr(SSLUtilHandle, 'EVP_DigestVerifyInit');
  4537. _EVP_DigestVerifyFinal := GetProcAddr(SSLUtilHandle, 'EVP_DigestVerifyFinal');
  4538. _EVP_DigestVerify := GetProcAddr(SSLUtilHandle, 'EVP_DigestVerify');
  4539. // 3DES functions
  4540. _DESsetoddparity := GetProcAddr(SSLUtilHandle, 'DES_set_odd_parity');
  4541. _DESsetkeychecked := GetProcAddr(SSLUtilHandle, 'DES_set_key_checked');
  4542. _DESsetkey := GetProcAddr(SSLUtilHandle, 'DES_set_key');
  4543. _DESecbencrypt := GetProcAddr(SSLUtilHandle, 'DES_ecb_encrypt');
  4544. //
  4545. _CRYPTOnumlocks := GetProcAddr(SSLUtilHandle, 'CRYPTO_num_locks');
  4546. _CRYPTOsetlockingcallback := GetProcAddr(SSLUtilHandle, 'CRYPTO_set_locking_callback');
  4547. // RAND functions
  4548. _RAND_set_rand_method := GetProcAddr(SSLUtilHandle, 'RAND_set_rand_method');
  4549. _RAND_get_rand_method := GetProcAddr(SSLUtilHandle, 'RAND_get_rand_method');
  4550. _RAND_SSLeay := GetProcAddr(SSLUtilHandle, 'RAND_SSLeay');
  4551. _RAND_cleanup := GetProcAddr(SSLUtilHandle, 'RAND_cleanup');
  4552. _RAND_bytes := GetProcAddr(SSLUtilHandle, 'RAND_bytes');
  4553. _RAND_pseudo_bytes := GetProcAddr(SSLUtilHandle, 'RAND_pseudo_bytes');
  4554. _RAND_seed := GetProcAddr(SSLUtilHandle, 'RAND_seed');
  4555. _RAND_add := GetProcAddr(SSLUtilHandle, 'RAND_add');
  4556. _RAND_load_file := GetProcAddr(SSLUtilHandle, 'RAND_load_file');
  4557. _RAND_write_file := GetProcAddr(SSLUtilHandle, 'RAND_write_file');
  4558. _RAND_file_name := GetProcAddr(SSLUtilHandle, 'RAND_file_name');
  4559. _RAND_status := GetProcAddr(SSLUtilHandle, 'RAND_status');
  4560. _RAND_query_egd_bytes := GetProcAddr(SSLUtilHandle, 'RAND_query_egd_bytes'); // 0.9.7+
  4561. _RAND_egd := GetProcAddr(SSLUtilHandle, 'RAND_egd');
  4562. _RAND_egd_bytes := GetProcAddr(SSLUtilHandle, 'RAND_egd_bytes');
  4563. _ERR_load_RAND_strings := GetProcAddr(SSLUtilHandle, 'ERR_load_RAND_strings');
  4564. _RAND_poll := GetProcAddr(SSLUtilHandle, 'RAND_poll');
  4565. // RSA Functions
  4566. _RSA_new := GetProcAddr(SSLUtilHandle, 'RSA_new');
  4567. _RSA_new_method := GetProcAddr(SSLUtilHandle, 'RSA_new_method');
  4568. _RSA_size := GetProcAddr(SSLUtilHandle, 'RSA_size');
  4569. _RsaGenerateKey := GetProcAddr(SSLUtilHandle, 'RSA_generate_key');
  4570. _RSA_generate_key_ex := GetProcAddr(SSLUtilHandle, 'RSA_generate_key_ex');
  4571. _RSA_check_key := GetProcAddr(SSLUtilHandle, 'RSA_check_key');
  4572. _RSA_public_encrypt := GetProcAddr(SSLUtilHandle, 'RSA_public_encrypt');
  4573. _RSA_private_encrypt := GetProcAddr(SSLUtilHandle, 'RSA_private_encrypt');
  4574. _RSA_public_decrypt := GetProcAddr(SSLUtilHandle, 'RSA_public_decrypt');
  4575. _RSA_private_decrypt := GetProcAddr(SSLUtilHandle, 'RSA_private_decrypt');
  4576. _RSA_free := GetProcAddr(SSLUtilHandle, 'RSA_free');
  4577. _RSA_flags := GetProcAddr(SSLUtilHandle, 'RSA_flags');
  4578. _RSA_set_default_method := GetProcAddr(SSLUtilHandle, 'RSA_set_default_method');
  4579. _RSA_get_default_method := GetProcAddr(SSLUtilHandle, 'RSA_get_default_method');
  4580. _RSA_get_method := GetProcAddr(SSLUtilHandle, 'RSA_get_method');
  4581. _RSA_set_method := GetProcAddr(SSLUtilHandle, 'RSA_set_method');
  4582. // X509 Functions
  4583. _d2i_RSAPublicKey := GetProcAddr(SSLUtilHandle, 'd2i_RSAPublicKey');
  4584. _i2d_RSAPublicKey := GetProcAddr(SSLUtilHandle, 'i2d_RSAPublicKey');
  4585. _d2i_RSAPrivateKey := GetProcAddr(SSLUtilHandle, 'd2i_RSAPrivateKey');
  4586. _i2d_RSAPrivateKey := GetProcAddr(SSLUtilHandle, 'i2d_RSAPrivateKey');
  4587. _d2i_PubKey := GetProcAddr(SSLUtilHandle, 'd2i_PUBKEY');
  4588. _d2i_AutoPrivateKey := GetProcAddr(SSLUtilHandle, 'd2i_AutoPrivateKey');
  4589. // ERR Functions
  4590. _ERR_error_string := GetProcAddr(SSLUtilHandle, 'ERR_error_string');
  4591. // EVP Functions
  4592. _OpenSSL_add_all_algorithms := GetProcAddr(SSLUtilHandle, 'OpenSSL_add_all_algorithms');
  4593. _OpenSSL_add_all_ciphers := GetProcAddr(SSLUtilHandle, 'OpenSSL_add_all_ciphers');
  4594. _OpenSSL_add_all_digests := GetProcAddr(SSLUtilHandle, 'OpenSSL_add_all_digests');
  4595. _EVP_DigestInit := GetProcAddr(SSLUtilHandle, 'EVP_DigestInit');
  4596. _EVP_DigestUpdate := GetProcAddr(SSLUtilHandle, 'EVP_DigestUpdate');
  4597. _EVP_DigestFinal := GetProcAddr(SSLUtilHandle, 'EVP_DigestFinal');
  4598. _EVP_SignFinal := GetProcAddr(SSLUtilHandle, 'EVP_SignFinal');
  4599. _EVP_PKEY_size := GetProcAddr(SSLUtilHandle,'EVP_PKEY_size');
  4600. _EVP_PKEY_free := GetProcAddr(SSLUtilHandle,'EVP_PKEY_free');
  4601. _EVP_VerifyFinal := GetProcAddr(SSLUtilHandle,'EVP_VerifyFinal');
  4602. _EVP_get_cipherbyname := GetProcAddr(SSLUtilHandle, 'EVP_get_cipherbyname');
  4603. _EVP_get_digestbyname := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
  4604. _EVP_CIPHER_CTX_init := GetProcAddr(SSLUtilHandle, 'EVP_CIPHER_CTX_init');
  4605. _EVP_CIPHER_CTX_reset := GetProcAddr(SSLUtilHandle, 'EVP_CIPHER_CTX_reset');
  4606. _EVP_CIPHER_CTX_cleanup := GetProcAddr(SSLUtilHandle, 'EVP_CIPHER_CTX_cleanup');
  4607. _EVP_CIPHER_CTX_set_key_length := GetProcAddr(SSLUtilHandle, 'EVP_CIPHER_CTX_set_key_length');
  4608. _EVP_CIPHER_CTX_ctrl := GetProcAddr(SSLUtilHandle, 'EVP_CIPHER_CTX_ctrl');
  4609. _EVP_EncryptInit := GetProcAddr(SSLUtilHandle, 'EVP_EncryptInit');
  4610. _EVP_EncryptUpdate := GetProcAddr(SSLUtilHandle, 'EVP_EncryptUpdate');
  4611. _EVP_EncryptFinal := GetProcAddr(SSLUtilHandle, 'EVP_EncryptFinal');
  4612. _EVP_DecryptInit := GetProcAddr(SSLUtilHandle, 'EVP_DecryptInit');
  4613. _EVP_DecryptUpdate := GetProcAddr(SSLUtilHandle, 'EVP_DecryptUpdate');
  4614. _EVP_DecryptFinal := GetProcAddr(SSLUtilHandle, 'EVP_DecryptFinal');
  4615. // PEM
  4616. _PEM_read_bio_PrivateKey := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_PrivateKey');
  4617. _PEM_read_bio_PUBKEY := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_PUBKEY');
  4618. _PEM_write_bio_PrivateKey := GetProcAddr(SSLUtilHandle, 'PEM_write_bio_PrivateKey');
  4619. _PEM_write_bio_PUBKEY := GetProcAddr(SSLUtilHandle, 'PEM_write_bio_PUBKEY');
  4620. _PEM_read_bio_X509 := GetProcAddr(SSLUtilHandle, 'PEM_read_bio_X509');
  4621. _PEM_write_bio_X509 := GetProcAddr(SSLUtilHandle,'PEM_write_bio_X509');
  4622. _PEM_write_bio_PKCS7 := GetProcAddr(SSLUtilHandle,'PEM_write_bio_PKCS7');
  4623. // BIO
  4624. _BIO_ctrl := GetProcAddr(SSLUtilHandle, 'BIO_ctrl');
  4625. _BIO_push:= GetProcAddr(SSLUtilHandle, 'BIO_push');
  4626. _BIO_pop:= GetProcAddr(SSLUtilHandle, 'BIO_pop');
  4627. _BIO_gets:= GetProcAddr(SSLUtilHandle, 'BIO_gets');
  4628. _BIO_puts:= GetProcAddr(SSLUtilHandle, 'BIO_puts');
  4629. _BIO_set_mem_eof_return:= GetProcAddr(SSLUtilHandle, 'BIO_set_mem_eof_return');
  4630. _BIO_set_mem_buf:= GetProcAddr(SSLUtilHandle, 'BIO_set_mem_buf');
  4631. _BIO_get_mem_ptr:= GetProcAddr(SSLUtilHandle, 'BIO_get_mem_ptr');
  4632. _BIO_s_file := GetProcAddr(SSLUtilHandle, 'BIO_s_file');
  4633. _BIO_new_file := GetProcAddr(SSLUtilHandle, 'BIO_new_file');
  4634. _BIO_new_mem_buf := GetProcAddr(SSLUtilHandle, 'BIO_new_mem_buf');
  4635. // PKCS7
  4636. _PKCS7_ISSUER_AND_SERIAL_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_new');
  4637. _PKCS7_ISSUER_AND_SERIAL_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_free');
  4638. _PKCS7_ISSUER_AND_SERIAL_digest:=GetProcAddr(SSLUtilHandle,'PKCS7_ISSUER_AND_SERIAL_digest');
  4639. _PKCS7_dup:=GetProcAddr(SSLUtilHandle,'PKCS7_dup');
  4640. _PEM_write_bio_PKCS7_stream:=GetProcAddr(SSLUtilHandle,'PEM_write_bio_PKCS7_stream');
  4641. _PKCS7_SIGNER_INFO_new:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNER_INFO_new');
  4642. _PKCS7_SIGNER_INFO_free:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNER_INFO_free');
  4643. _PKCS7_RECIP_INFO_new:=GetProcAddr(SSLUtilHandle,'PKCS7_RECIP_INFO_new');
  4644. _PKCS7_RECIP_INFO_free:=GetProcAddr(SSLUtilHandle,'PKCS7_RECIP_INFO_free');
  4645. _PKCS7_SIGNED_new:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNED_new');
  4646. _PKCS7_SIGNED_free:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNED_free');
  4647. _PKCS7_ENC_CONTENT_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ENC_CONTENT_new');
  4648. _PKCS7_ENC_CONTENT_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ENC_CONTENT_free');
  4649. _PKCS7_ENVELOPE_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ENVELOPE_new');
  4650. _PKCS7_ENVELOPE_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ENVELOPE_free');
  4651. _PKCS7_SIGN_ENVELOPE_new:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGN_ENVELOPE_new');
  4652. _PKCS7_SIGN_ENVELOPE_free:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGN_ENVELOPE_free');
  4653. _PKCS7_DIGEST_new:=GetProcAddr(SSLUtilHandle,'PKCS7_DIGEST_new');
  4654. _PKCS7_DIGEST_free:=GetProcAddr(SSLUtilHandle,'PKCS7_DIGEST_free');
  4655. _PKCS7_ENCRYPT_new:=GetProcAddr(SSLUtilHandle,'PKCS7_ENCRYPT_new');
  4656. _PKCS7_ENCRYPT_free:=GetProcAddr(SSLUtilHandle,'PKCS7_ENCRYPT_free');
  4657. _PKCS7_new:=GetProcAddr(SSLUtilHandle,'PKCS7_new');
  4658. _PKCS7_free:=GetProcAddr(SSLUtilHandle,'PKCS7_free');
  4659. _PKCS7_print_ctx:=GetProcAddr(SSLUtilHandle,'PKCS7_print_ctx');
  4660. _PKCS7_ctrl:=GetProcAddr(SSLUtilHandle,'PKCS7_ctrl');
  4661. _PKCS7_set_type:=GetProcAddr(SSLUtilHandle,'PKCS7_set_type');
  4662. _PKCS7_set0_type_other:=GetProcAddr(SSLUtilHandle,'PKCS7_set0_type_other');
  4663. _PKCS7_set_content:=GetProcAddr(SSLUtilHandle,'PKCS7_set_content');
  4664. _PKCS7_SIGNER_INFO_set:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNER_INFO_set');
  4665. _PKCS7_SIGNER_INFO_sign:=GetProcAddr(SSLUtilHandle,'PKCS7_SIGNER_INFO_sign');
  4666. _PKCS7_add_signer:=GetProcAddr(SSLUtilHandle,'PKCS7_add_signer');
  4667. _PKCS7_add_certificate:=GetProcAddr(SSLUtilHandle,'PKCS7_add_certificate');
  4668. _PKCS7_add_crl:=GetProcAddr(SSLUtilHandle,'PKCS7_add_crl');
  4669. _PKCS7_content_new:=GetProcAddr(SSLUtilHandle,'PKCS7_content_new');
  4670. _PKCS7_add_signature:=GetProcAddr(SSLUtilHandle,'PKCS7_add_signature');
  4671. _PKCS7_cert_from_signer_info:=GetProcAddr(SSLUtilHandle,'PKCS7_cert_from_signer_info');
  4672. _PKCS7_set_digest:=GetProcAddr(SSLUtilHandle,'PKCS7_set_digest');
  4673. _PKCS7_add_recipient:=GetProcAddr(SSLUtilHandle,'PKCS7_add_recipient');
  4674. _PKCS7_add_recipient_info:=GetProcAddr(SSLUtilHandle,'PKCS7_add_recipient_info');
  4675. _PKCS7_RECIP_INFO_set:=GetProcAddr(SSLUtilHandle,'PKCS7_RECIP_INFO_set');
  4676. _PKCS7_set_cipher:=GetProcAddr(SSLUtilHandle,'PKCS7_set_cipher');
  4677. _PKCS7_get_issuer_and_serial:=GetProcAddr(SSLUtilHandle,'PKCS7_get_issuer_and_serial');
  4678. _PKCS7_digest_from_attributes:=GetProcAddr(SSLUtilHandle,'PKCS7_digest_from_attributes');
  4679. _PKCS7_add_signed_attribute:=GetProcAddr(SSLUtilHandle,'PKCS7_add_signed_attribute');
  4680. _PKCS7_add_attribute:=GetProcAddr(SSLUtilHandle,'PKCS7_add_attribute');
  4681. _PKCS7_get_attribute:=GetProcAddr(SSLUtilHandle,'PKCS7_get_attribute');
  4682. _PKCS7_get_signed_attribute:=GetProcAddr(SSLUtilHandle,'PKCS7_get_signed_attribute');
  4683. _PKCS7_set_signed_attributes:=GetProcAddr(SSLUtilHandle,'PKCS7_set_signed_attributes');
  4684. _PKCS7_set_attributes:=GetProcAddr(SSLUtilHandle,'PKCS7_set_attributes');
  4685. _PKCS7_sign:=GetProcAddr(SSLUtilHandle,'PKCS7_sign');
  4686. _PKCS7_sign_add_signer:=GetProcAddr(SSLUtilHandle,'PKCS7_sign_add_signer');
  4687. _PKCS7_final:=GetProcAddr(SSLUtilHandle,'PKCS7_final');
  4688. _PKCS7_verify:=GetProcAddr(SSLUtilHandle,'PKCS7_verify');
  4689. _PKCS7_encrypt:=GetProcAddr(SSLUtilHandle,'PKCS7_encrypt');
  4690. _PKCS7_decrypt:=GetProcAddr(SSLUtilHandle,'PKCS7_decrypt');
  4691. _PKCS7_add_attrib_smimecap:=GetProcAddr(SSLUtilHandle,'PKCS7_add_attrib_smimecap');
  4692. _PKCS7_simple_smimecap:=GetProcAddr(SSLUtilHandle,'PKCS7_simple_smimecap');
  4693. _PKCS7_add_attrib_content_type:=GetProcAddr(SSLUtilHandle,'PKCS7_add_attrib_content_type');
  4694. _PKCS7_add0_attrib_signing_time:=GetProcAddr(SSLUtilHandle,'PKCS7_add0_attrib_signing_time');
  4695. _PKCS7_add1_attrib_digest:=GetProcAddr(SSLUtilHandle,'PKCS7_add1_attrib_digest');
  4696. _BIO_new_PKCS7:=GetProcAddr(SSLUtilHandle,'BIO_new_PKCS7');
  4697. _ERR_load_PKCS7_strings:=GetProcAddr(SSLUtilHandle,'ERR_load_PKCS7_strings');
  4698. // SMIME
  4699. _SMIME_write_PKCS7 := GetProcAddr(SSLUtilHandle, 'SMIME_write_PKCS7');
  4700. _SMIME_read_PKCS7 := GetProcAddr(SSLUtilHandle, 'SMIME_read_PKCS7');
  4701. // BN
  4702. _BN_new:=GetProcAddr(SSLUtilHandle,'BN_new');
  4703. _BN_secure_new:=GetProcAddr(SSLUtilHandle,'BN_secure_new');
  4704. _BN_clear_free:=GetProcAddr(SSLUtilHandle,'BN_clear_free');
  4705. _BN_copy:=GetProcAddr(SSLUtilHandle,'BN_copy');
  4706. _BN_swap:=GetProcAddr(SSLUtilHandle,'BN_swap');
  4707. _BN_bin2bn:=GetProcAddr(SSLUtilHandle,'BN_bin2bn');
  4708. _BN_bn2bin:=GetProcAddr(SSLUtilHandle,'BN_bn2bin');
  4709. _BN_bn2binpad:=GetProcAddr(SSLUtilHandle,'BN_bn2binpad');
  4710. _BN_lebin2bn:=GetProcAddr(SSLUtilHandle,'BN_lebin2bn');
  4711. _BN_bn2lebinpad:=GetProcAddr(SSLUtilHandle,'BN_bn2lebinpad');
  4712. _BN_mpi2bn:=GetProcAddr(SSLUtilHandle,'BN_mpi2bn');
  4713. _BN_bn2mpi:=GetProcAddr(SSLUtilHandle,'BN_bn2mpi');
  4714. _BN_sub:=GetProcAddr(SSLUtilHandle,'BN_sub');
  4715. _BN_usub:=GetProcAddr(SSLUtilHandle,'BN_usub');
  4716. _BN_uadd:=GetProcAddr(SSLUtilHandle,'BN_uadd');
  4717. _BN_add:=GetProcAddr(SSLUtilHandle,'BN_add');
  4718. _BN_mul:=GetProcAddr(SSLUtilHandle,'BN_mul');
  4719. _BN_sqr:=GetProcAddr(SSLUtilHandle,'BN_sqr');
  4720. _BN_set_negative:=GetProcAddr(SSLUtilHandle,'BN_set_negative');
  4721. _BN_is_negative:=GetProcAddr(SSLUtilHandle,'BN_is_negative');
  4722. _BN_div:=GetProcAddr(SSLUtilHandle,'BN_div');
  4723. _BN_mod:=GetProcAddr(SSLUtilHandle,'BN_mod');
  4724. _BN_nnmod:=GetProcAddr(SSLUtilHandle,'BN_nnmod');
  4725. _BN_mod_add:=GetProcAddr(SSLUtilHandle,'BN_mod_add');
  4726. _BN_mod_add_quick:=GetProcAddr(SSLUtilHandle,'BN_mod_add_quick');
  4727. _BN_mod_sub:=GetProcAddr(SSLUtilHandle,'BN_mod_sub');
  4728. _BN_mod_sub_quick:=GetProcAddr(SSLUtilHandle,'BN_mod_sub_quick');
  4729. _BN_mod_mul:=GetProcAddr(SSLUtilHandle,'BN_mod_mul');
  4730. _BN_mod_sqr:=GetProcAddr(SSLUtilHandle,'BN_mod_sqr');
  4731. _BN_mod_lshift1:=GetProcAddr(SSLUtilHandle,'BN_mod_lshift1');
  4732. _BN_mod_lshift1_quick:=GetProcAddr(SSLUtilHandle,'BN_mod_lshift1_quick');
  4733. _BN_mod_lshift:=GetProcAddr(SSLUtilHandle,'BN_mod_lshift');
  4734. _BN_mod_lshift_quick:=GetProcAddr(SSLUtilHandle,'BN_mod_lshift_quick');
  4735. _BN_mod_word:=GetProcAddr(SSLUtilHandle,'BN_mod_word');
  4736. _BN_div_word:=GetProcAddr(SSLUtilHandle,'BN_div_word');
  4737. _BN_mul_word:=GetProcAddr(SSLUtilHandle,'BN_mul_word');
  4738. _BN_add_word:=GetProcAddr(SSLUtilHandle,'BN_add_word');
  4739. _BN_sub_word:=GetProcAddr(SSLUtilHandle,'BN_sub_word');
  4740. _BN_set_word:=GetProcAddr(SSLUtilHandle,'BN_set_word');
  4741. _BN_get_word:=GetProcAddr(SSLUtilHandle,'BN_get_word');
  4742. _BN_cmp:=GetProcAddr(SSLUtilHandle,'BN_cmp');
  4743. _BN_free:=GetProcAddr(SSLUtilHandle,'BN_free');
  4744. end;
  4745. Procedure ClearSSLEntryPoints;
  4746. begin
  4747. _SslGetError := nil;
  4748. _SslLibraryInit := nil;
  4749. _OPENSSL_init_ssl:=Nil;
  4750. _SslLoadErrorStrings := nil;
  4751. _SslCtxSetCipherList := nil;
  4752. _SslCtxNew := nil;
  4753. _SslCtxFree := nil;
  4754. _SslSetFd := nil;
  4755. _SslCtrl := nil;
  4756. _SslCTXCtrl := nil;
  4757. _SslMethodV2 := nil;
  4758. _SslMethodV3 := nil;
  4759. _SslMethodTLSV1 := nil;
  4760. _SslMethodTLSV1_1 := nil;
  4761. _SslMethodTLSV1_2 := nil;
  4762. _SslMethodV23 := nil;
  4763. _SslTLSMethod := nil;
  4764. _SslCtxUsePrivateKey := nil;
  4765. _SslCtxUsePrivateKeyASN1 := nil;
  4766. _SslCtxUsePrivateKeyFile := nil;
  4767. _SslCtxUseCertificate := nil;
  4768. _SslCtxUseCertificateASN1 := nil;
  4769. _SslCtxUseCertificateFile := nil;
  4770. _SslCtxUseCertificateChainFile := nil;
  4771. _SslCtxCheckPrivateKeyFile := nil;
  4772. _SslCtxSetDefaultPasswdCb := nil;
  4773. _SslCtxSetDefaultPasswdCbUserdata := nil;
  4774. _SslCtxLoadVerifyLocations := nil;
  4775. _SslNew := nil;
  4776. _SslFree := nil;
  4777. _SslAccept := nil;
  4778. _SslConnect := nil;
  4779. _SslShutdown := nil;
  4780. _SslRead := nil;
  4781. _SslPeek := nil;
  4782. _SslWrite := nil;
  4783. _SslPending := nil;
  4784. _SslGetPeerCertificate := nil;
  4785. _SslGetVersion := nil;
  4786. _SslCtxSetVerify := nil;
  4787. _SslGetCurrentCipher := nil;
  4788. _SslCipherGetName := nil;
  4789. _SslCipherGetBits := nil;
  4790. _SslGetVerifyResult := nil;
  4791. _SslGetServername := nil;
  4792. _SslCtxCallbackCtrl := nil;
  4793. _SslSetSslCtx := nil;
  4794. _SslSet1Host := nil;
  4795. _PKCS7_ISSUER_AND_SERIAL_new:=nil;
  4796. _PKCS7_ISSUER_AND_SERIAL_free:=nil;
  4797. _PKCS7_ISSUER_AND_SERIAL_digest:=nil;
  4798. _PKCS7_dup:=nil;
  4799. _PEM_write_bio_PKCS7_stream:=nil;
  4800. _PKCS7_SIGNER_INFO_new:=nil;
  4801. _PKCS7_SIGNER_INFO_free:=nil;
  4802. _PKCS7_RECIP_INFO_new:=nil;
  4803. _PKCS7_RECIP_INFO_free:=nil;
  4804. _PKCS7_SIGNED_new:=nil;
  4805. _PKCS7_SIGNED_free:=nil;
  4806. _PKCS7_ENC_CONTENT_new:=nil;
  4807. _PKCS7_ENC_CONTENT_free:=nil;
  4808. _PKCS7_ENVELOPE_new:=nil;
  4809. _PKCS7_ENVELOPE_free:=nil;
  4810. _PKCS7_SIGN_ENVELOPE_new:=nil;
  4811. _PKCS7_SIGN_ENVELOPE_free:=nil;
  4812. _PKCS7_DIGEST_new:=nil;
  4813. _PKCS7_DIGEST_free:=nil;
  4814. _PKCS7_ENCRYPT_new:=nil;
  4815. _PKCS7_ENCRYPT_free:=nil;
  4816. _PKCS7_new:=nil;
  4817. _PKCS7_free:=nil;
  4818. _PKCS7_print_ctx:=nil;
  4819. _PKCS7_ctrl:=nil;
  4820. _PKCS7_set_type:=nil;
  4821. _PKCS7_set0_type_other:=nil;
  4822. _PKCS7_set_content:=nil;
  4823. _PKCS7_SIGNER_INFO_set:=nil;
  4824. _PKCS7_SIGNER_INFO_sign:=nil;
  4825. _PKCS7_add_signer:=nil;
  4826. _PKCS7_add_certificate:=nil;
  4827. _PKCS7_add_crl:=nil;
  4828. _PKCS7_content_new:=nil;
  4829. _PKCS7_add_signature:=nil;
  4830. _PKCS7_cert_from_signer_info:=nil;
  4831. _PKCS7_set_digest:=nil;
  4832. _PKCS7_add_recipient:=nil;
  4833. _PKCS7_add_recipient_info:=nil;
  4834. _PKCS7_RECIP_INFO_set:=nil;
  4835. _PKCS7_set_cipher:=nil;
  4836. _PKCS7_get_issuer_and_serial:=nil;
  4837. _PKCS7_digest_from_attributes:=nil;
  4838. _PKCS7_add_signed_attribute:=nil;
  4839. _PKCS7_add_attribute:=nil;
  4840. _PKCS7_get_attribute:=nil;
  4841. _PKCS7_get_signed_attribute:=nil;
  4842. _PKCS7_set_signed_attributes:=nil;
  4843. _PKCS7_set_attributes:=nil;
  4844. _PKCS7_sign:=nil;
  4845. _PKCS7_sign_add_signer:=nil;
  4846. _PKCS7_final:=nil;
  4847. _PKCS7_verify:=nil;
  4848. _PKCS7_encrypt:=nil;
  4849. _PKCS7_decrypt:=nil;
  4850. _PKCS7_add_attrib_smimecap:=nil;
  4851. _PKCS7_simple_smimecap:=nil;
  4852. _PKCS7_add_attrib_content_type:=nil;
  4853. _PKCS7_add0_attrib_signing_time:=nil;
  4854. _PKCS7_add1_attrib_digest:=nil;
  4855. _BIO_new_PKCS7:=nil;
  4856. _ERR_load_PKCS7_strings:=nil;
  4857. // SMIME
  4858. _SMIME_write_PKCS7 := nil;
  4859. _SMIME_read_PKCS7 := nil;
  4860. // BN
  4861. _BN_new:=nil;
  4862. _BN_secure_new:=nil;
  4863. _BN_clear_free:=nil;
  4864. _BN_copy:=nil;
  4865. _BN_swap:=nil;
  4866. _BN_bin2bn:=nil;
  4867. _BN_bn2bin:=nil;
  4868. _BN_bn2binpad:=nil;
  4869. _BN_lebin2bn:=nil;
  4870. _BN_bn2lebinpad:=nil;
  4871. _BN_mpi2bn:=nil;
  4872. _BN_bn2mpi:=nil;
  4873. _BN_sub:=nil;
  4874. _BN_usub:=nil;
  4875. _BN_uadd:=nil;
  4876. _BN_add:=nil;
  4877. _BN_mul:=nil;
  4878. _BN_sqr:=nil;
  4879. _BN_set_negative:=nil;
  4880. _BN_is_negative:=nil;
  4881. _BN_div:=nil;
  4882. _BN_mod:=nil;
  4883. _BN_nnmod:=nil;
  4884. _BN_mod_add:=nil;
  4885. _BN_mod_add_quick:=nil;
  4886. _BN_mod_sub:=nil;
  4887. _BN_mod_sub_quick:=nil;
  4888. _BN_mod_mul:=nil;
  4889. _BN_mod_sqr:=nil;
  4890. _BN_mod_lshift1:=nil;
  4891. _BN_mod_lshift1_quick:=nil;
  4892. _BN_mod_lshift:=nil;
  4893. _BN_mod_lshift_quick:=nil;
  4894. _BN_mod_word:=nil;
  4895. _BN_div_word:=nil;
  4896. _BN_mul_word:=nil;
  4897. _BN_add_word:=nil;
  4898. _BN_sub_word:=nil;
  4899. _BN_set_word:=nil;
  4900. _BN_get_word:=nil;
  4901. _BN_cmp:=nil;
  4902. _BN_free:=nil;
  4903. end;
  4904. Procedure ClearUtilEntryPoints;
  4905. begin
  4906. _OpenSSLVersion := Nil;
  4907. _SSLeayversion := nil;
  4908. _ERR_load_crypto_strings := nil;
  4909. _OPENSSL_init_crypto:=Nil;
  4910. _OPENSSL_INIT_free:=nil;
  4911. _OPENSSL_INIT_set_config_appname:=Nil;
  4912. _OPENSSL_INIT_new:=nil;
  4913. _OPENSSL_cleanup:=Nil;
  4914. _X509New := nil;
  4915. _X509Free := nil;
  4916. _X509NameOneline := nil;
  4917. _X509GetSubjectName := nil;
  4918. _X509GetIssuerName := nil;
  4919. _X509NameHash := nil;
  4920. _X509Digest := nil;
  4921. _X509print := nil;
  4922. _X509SetVersion := nil;
  4923. _X509SetPubkey := nil;
  4924. _X509GetPubkey := nil;
  4925. _X509SetIssuerName := nil;
  4926. _X509NameAddEntryByTxt := nil;
  4927. _X509Sign := nil;
  4928. _X509GmtimeAdj := nil;
  4929. _X509SetNotBefore := nil;
  4930. _X509SetNotAfter := nil;
  4931. _X509GetSerialNumber := nil;
  4932. _EvpPkeyNew := nil;
  4933. _EvpPkeyFree := nil;
  4934. _EvpPkeyAssign := nil;
  4935. _EVPCleanup := nil;
  4936. _EvpGetDigestByName := nil;
  4937. _ErrErrorString := nil;
  4938. _ErrGetError := nil;
  4939. _ErrClearError := nil;
  4940. _ErrFreeStrings := nil;
  4941. _ErrRemoveState := nil;
  4942. _RandScreen := nil;
  4943. _BioNew := nil;
  4944. _BioFreeAll := nil;
  4945. _BioSMem := nil;
  4946. _BioCtrlPending := nil;
  4947. _BioRead := nil;
  4948. _BioWrite := nil;
  4949. _d2iPKCS12bio := nil;
  4950. _PKCS12parse := nil;
  4951. _PKCS12free := nil;
  4952. _Asn1UtctimeSetString := nil;
  4953. _Asn1StringTypeNew := nil;
  4954. _Asn1UtctimePrint := nil;
  4955. _Asn1UtctimeFree := nil;
  4956. _Asn1IntegerSet:= nil;
  4957. _Asn1IntegerGet:= nil;
  4958. _i2dX509bio := nil;
  4959. _d2iX509bio := nil;
  4960. _PEMReadBioX509 := nil;
  4961. _SkX509PopFree := nil;
  4962. _i2dPrivateKeyBio := nil;
  4963. // 3DES functions
  4964. _DESsetoddparity := nil;
  4965. _DESsetkeychecked := nil;
  4966. _DESecbencrypt := nil;
  4967. //
  4968. _CRYPTOnumlocks := nil;
  4969. _CRYPTOsetlockingcallback := nil;
  4970. // RAND functions
  4971. _RAND_set_rand_method := nil;
  4972. _RAND_get_rand_method := nil;
  4973. _RAND_SSLeay := nil;
  4974. _RAND_cleanup := nil;
  4975. _RAND_bytes := nil;
  4976. _RAND_pseudo_bytes := nil;
  4977. _RAND_seed := nil;
  4978. _RAND_add := nil;
  4979. _RAND_load_file := nil;
  4980. _RAND_write_file := nil;
  4981. _RAND_file_name := nil;
  4982. _RAND_status := nil;
  4983. _RAND_query_egd_bytes := nil;
  4984. _RAND_egd := nil;
  4985. _RAND_egd_bytes := nil;
  4986. _ERR_load_RAND_strings := nil;
  4987. _RAND_poll := nil;
  4988. // RSA Functions
  4989. _RSA_new := nil;
  4990. _RSA_new_method := nil;
  4991. _RSA_size := nil;
  4992. _RsaGenerateKey := nil;
  4993. _RSA_generate_key_ex := nil;
  4994. _RSA_check_key := nil;
  4995. _RSA_public_encrypt := nil;
  4996. _RSA_private_encrypt := nil;
  4997. _RSA_public_decrypt := nil;
  4998. _RSA_private_decrypt := nil;
  4999. _RSA_free := nil;
  5000. _RSA_flags := nil;
  5001. _RSA_set_default_method := nil;
  5002. _RSA_get_default_method := nil;
  5003. _RSA_get_method := nil;
  5004. _RSA_set_method := nil;
  5005. // X509 Functions
  5006. _d2i_RSAPublicKey := nil;
  5007. _i2d_RSAPublicKey := nil;
  5008. _d2i_RSAPrivateKey := nil;
  5009. _i2d_RSAPrivateKey := nil;
  5010. _d2i_PubKey := nil;
  5011. _d2i_AutoPrivateKey := nil;
  5012. // ERR Functions
  5013. _ERR_error_string := nil;
  5014. // EVP Functions
  5015. _OpenSSL_add_all_algorithms := nil;
  5016. _OpenSSL_add_all_ciphers := nil;
  5017. _OpenSSL_add_all_digests := nil;
  5018. //
  5019. _EVP_DigestInit := nil;
  5020. _EVP_DigestUpdate := nil;
  5021. _EVP_DigestFinal := nil;
  5022. _EVP_SignFinal := nil;
  5023. _EVP_PKEY_size := nil;
  5024. _EVP_PKEY_free := nil;
  5025. _EVP_VerifyFinal := nil;
  5026. //
  5027. _EVP_get_cipherbyname := nil;
  5028. _EVP_get_digestbyname := nil;
  5029. //
  5030. _EVP_CIPHER_CTX_reset := nil;
  5031. _EVP_CIPHER_CTX_init := nil;
  5032. _EVP_CIPHER_CTX_cleanup := nil;
  5033. _EVP_CIPHER_CTX_set_key_length := nil;
  5034. _EVP_CIPHER_CTX_ctrl := nil;
  5035. //
  5036. _EVP_EncryptInit := nil;
  5037. _EVP_EncryptUpdate := nil;
  5038. _EVP_EncryptFinal := nil;
  5039. //
  5040. _EVP_DecryptInit := nil;
  5041. _EVP_DecryptUpdate := nil;
  5042. _EVP_DecryptFinal := nil;
  5043. //
  5044. _EVP_sha256 := nil;
  5045. _EVP_MD_CTX_new := nil;
  5046. _EVP_MD_CTX_free := nil;
  5047. _EVP_DigestSignInit := nil;
  5048. _EVP_DigestSignFinal := nil;
  5049. _EVP_DigestSign := nil;
  5050. _EVP_DigestVerifyInit := nil;
  5051. _EVP_DigestVerifyFinal := nil;
  5052. _EVP_DigestVerify := nil;
  5053. // PEM
  5054. _PEM_read_bio_PrivateKey := nil;
  5055. _PEM_read_bio_PrivateKey := nil;
  5056. _PEM_read_bio_PUBKEY := nil;
  5057. _PEM_write_bio_PrivateKey := nil;
  5058. _PEM_read_bio_X509 := nil;
  5059. _PEM_write_bio_X509 := nil;
  5060. _PEM_write_bio_PKCS7 := nil;
  5061. // BIO
  5062. _BIO_ctrl := nil;
  5063. _BIO_s_file := nil;
  5064. _BIO_new_file := nil;
  5065. _BIO_new_mem_buf := nil;
  5066. end;
  5067. procedure locking_callback(mode, ltype: integer; lfile: PAnsiChar; line: integer); cdecl;
  5068. begin
  5069. if (mode and 1) > 0 then
  5070. EnterCriticalSection(Locks[ltype])
  5071. else
  5072. LeaveCriticalSection(Locks[ltype]);
  5073. end;
  5074. procedure InitLocks;
  5075. var
  5076. n: integer;
  5077. max: integer;
  5078. begin
  5079. if (@_CRYPTOnumlocks<>nil) then
  5080. max:=_CRYPTOnumlocks
  5081. else
  5082. max:=1; // hardcoded in header
  5083. SetLength(Locks,Max);
  5084. for n := 0 to max-1 do
  5085. InitCriticalSection(Locks[n]);
  5086. if (@_CRYPTOsetlockingcallback<>Nil) then
  5087. _CRYPTOsetlockingcallback(@locking_callback);
  5088. end;
  5089. procedure FreeLocks;
  5090. var
  5091. n: integer;
  5092. begin
  5093. if (@_CRYPTOsetlockingcallback<>Nil) then
  5094. _CRYPTOsetlockingcallback(nil);
  5095. for n := 0 to Length(Locks)-1 do
  5096. DoneCriticalSection(Locks[n]);
  5097. SetLength(Locks,0);
  5098. end;
  5099. Procedure UnloadLibraries;
  5100. begin
  5101. SSLloaded := false;
  5102. if SSLLibHandle <> 0 then
  5103. begin
  5104. FreeLibrary(SSLLibHandle);
  5105. SSLLibHandle := 0;
  5106. end;
  5107. if SSLUtilHandle <> 0 then
  5108. begin
  5109. FreeLibrary(SSLUtilHandle);
  5110. SSLUtilHandle := 0;
  5111. end;
  5112. end;
  5113. function TryLoadLibPair(const SSL_DLL_Name, Crypto_DLL_Name: AnsiString):boolean;
  5114. begin
  5115. Assert((SSLUtilHandle = 0) and (SSLLibHandle = 0),
  5116. 'LoadTryLoadLibPair: Handle is not zero');
  5117. SSLUtilHandle := LoadLibrary(Crypto_DLL_Name);
  5118. if (SSLUtilHandle <> 0) then
  5119. SSLLibHandle := LoadLibrary(SSL_DLL_Name);
  5120. Result := (SSLUtilHandle <> 0) and (SSLLibHandle <> 0);
  5121. if not Result then UnloadLibraries;
  5122. end;
  5123. Function MakeLibName(Const aBase,aVersion : AnsiString) : AnsiString;
  5124. begin
  5125. {$IF DEFINED(WINDOWS) OR DEFINED(OS2)}
  5126. Result:=aBase+aVersion+'.dll';
  5127. {$ELSE}
  5128. {$IFNDEF DARWIN}
  5129. Result:=aBase+'.so'+aVersion;
  5130. {$ELSE}
  5131. Result:=aBase+aVersion+'.dylib';
  5132. {$ENDIF}
  5133. {$ENDIF}
  5134. end;
  5135. {$IF NOT(DEFINED(WINDOWS) OR DEFINED(OS2))}
  5136. Function LoadOpenSSl : Boolean;
  5137. var
  5138. Idx: Integer;
  5139. begin
  5140. Result:=False;
  5141. Idx := Low(DLLVersions)+StartVersionOffset;
  5142. While (not Result) and (Idx<=High(DLLVersions)) do
  5143. begin
  5144. Result := TryLoadLibPair(MakeLibName(BaseSSLName,DLLVersions[Idx]),
  5145. MakeLibName(BaseCryptoName,DLLVersions[Idx]));
  5146. Inc(Idx);
  5147. end;
  5148. end;
  5149. Function LoadLibreSSl : Boolean;
  5150. var
  5151. Idx: Integer;
  5152. begin
  5153. Result:=False;
  5154. Idx := Low(LibreSSLVersions)+StartVersionOffset;
  5155. While (not Result) and (Idx<=High(LibreSSLVersions)) do
  5156. begin
  5157. Result := TryLoadLibPair(MakeLibName(BaseSSLName,LibreSSLVersions[Idx]),
  5158. MakeLibName(BaseCryptoName,LibreSSLVersions[Idx]));
  5159. Inc(Idx);
  5160. end;
  5161. end;
  5162. {$ENDIF}
  5163. Function LoadLibraries(Const aSSLName, aCryptoName : AnsiString) : Boolean;
  5164. var
  5165. Idx: Integer;
  5166. begin
  5167. Result:=False;
  5168. if (aSSLName<>'') and (aCryptoName<>'') then
  5169. Exit(TryLoadLibPair(aSSLName,aCryptoName));
  5170. {$IF DEFINED(WINDOWS) OR DEFINED(OS2)}
  5171. Assert(Low(SSL_DLL_Names) = Low(Crypto_DLL_Names));
  5172. Assert(High(SSL_DLL_Names) = High(Crypto_DLL_Names));
  5173. Idx:=Low(SSL_DLL_Names);
  5174. While (not Result) and (Idx<=High(SSL_DLL_Names)) do
  5175. begin
  5176. Result := TryLoadLibPair(MakeLibName(SSL_DLL_Names[Idx],''), MakeLibName(Crypto_DLL_Names[Idx],''));
  5177. Inc(Idx);
  5178. end;
  5179. {$ELSE}
  5180. if LibreSSLSupport=lssFirst then
  5181. Result:=LoadLibreSSL;
  5182. if not Result then
  5183. Result:=LoadOpenSSL;
  5184. if (Not Result) and (LibreSSLSupport=lssLast) then
  5185. Result:=LoadLibreSSL;
  5186. {$ENDIF}
  5187. end;
  5188. function InitSSLInterface: Boolean;
  5189. begin
  5190. Result:=InitSSLInterface('','');
  5191. end;
  5192. function InitSSLInterface(Const aSSLName, acryptoName : AnsiString) : Boolean;
  5193. begin
  5194. Result:=SSLLoaded;
  5195. if Result then
  5196. exit;
  5197. EnterCriticalSection(SSLCS);
  5198. try
  5199. if SSLloaded then
  5200. Exit(True);
  5201. Result:=LoadLibraries(aSSLName,aCryptoName);
  5202. if Not Result then
  5203. begin
  5204. UnloadLibraries;
  5205. Exit;
  5206. end;
  5207. LoadSSLEntryPoints;
  5208. LoadUtilEntryPoints;
  5209. //init library
  5210. if assigned(_SslLibraryInit) then
  5211. _SslLibraryInit;
  5212. if assigned(_SslLoadErrorStrings) then
  5213. _SslLoadErrorStrings;
  5214. if assigned(_OPENSSLaddallalgorithms) then
  5215. _OPENSSLaddallalgorithms;
  5216. if assigned(_CRYPTOnumlocks) and assigned(_CRYPTOsetlockingcallback) then
  5217. InitLocks;
  5218. SSLloaded := True;
  5219. {$IFDEF OS2}
  5220. Result := InitEMXHandles;
  5221. {$ELSE OS2}
  5222. Result := True;
  5223. {$ENDIF OS2}
  5224. finally
  5225. LeaveCriticalSection(SSLCS);
  5226. end;
  5227. end;
  5228. function DestroySSLInterface: Boolean;
  5229. begin
  5230. Result:=Not isSSLLoaded;
  5231. if Result then
  5232. exit;
  5233. EnterCriticalSection(SSLCS);
  5234. try
  5235. if assigned(_CRYPTOnumlocks) and assigned(_CRYPTOsetlockingcallback) then
  5236. FreeLocks;
  5237. EVPCleanup;
  5238. CRYPTOcleanupAllExData;
  5239. ErrRemoveState(0);
  5240. ClearUtilEntryPoints;
  5241. ClearSSLEntryPoints;
  5242. UnloadLibraries;
  5243. Result := True;
  5244. finally
  5245. LeaveCriticalSection(SSLCS);
  5246. end;
  5247. end;
  5248. initialization
  5249. InitCriticalSection(SSLCS);
  5250. finalization
  5251. DestroySSLInterface;
  5252. DoneCriticalSection(SSLCS);
  5253. end.