openssl.pas 210 KB

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