openssl.pas 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. unit OpenSSL;
  2. {==============================================================================|
  3. | Project : Ararat Synapse | 003.004.001 |
  4. |==============================================================================|
  5. | Content: SSL support by OpenSSL |
  6. |==============================================================================|
  7. | Copyright (c)1999-2005, Lukas Gebauer |
  8. | All rights reserved. |
  9. | |
  10. | Redistribution and use in source and binary forms, with or without |
  11. | modification, are permitted provided that the following conditions are met: |
  12. | |
  13. | Redistributions of source code must retain the above copyright notice, this |
  14. | list of conditions and the following disclaimer. |
  15. | |
  16. | Redistributions in binary form must reproduce the above copyright notice, |
  17. | this list of conditions and the following disclaimer in the documentation |
  18. | and/or other materials provided with the distribution. |
  19. | |
  20. | Neither the name of Lukas Gebauer nor the names of its contributors may |
  21. | be used to endorse or promote products derived from this software without |
  22. | specific prior written permission. |
  23. | |
  24. | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
  25. | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
  26. | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
  27. | ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
  28. | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
  29. | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
  30. | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
  31. | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  32. | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
  33. | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
  34. | DAMAGE. |
  35. |==============================================================================|
  36. | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
  37. | Portions created by Lukas Gebauer are Copyright (c)2002-2005. |
  38. | All Rights Reserved. |
  39. |==============================================================================|
  40. | Contributor(s): |
  41. |==============================================================================|
  42. | FreePascal basic cleanup (original worked too): Ales Katona |
  43. | WARNING: due to reliance on some units, I have removed the ThreadLocks init |
  44. | if need be, it should be re-added, or handled by the |
  45. | OS threading init somehow |
  46. |==============================================================================|
  47. | History: see HISTORY.HTM from distribution package |
  48. | (Found at URL: http://www.ararat.cz/synapse/) |
  49. |==============================================================================}
  50. {
  51. Special thanks to Gregor Ibic <[email protected]>
  52. (Intelicom d.o.o., http://www.intelicom.si)
  53. for good inspiration about begin with SSL programming.
  54. }
  55. {$MODE DELPHI}{$H+}
  56. {:@abstract(OpenSSL support)
  57. This unit is Pascal interface to OpenSSL library (used by @link(ssl_openssl) unit).
  58. OpenSSL is loaded dynamicly on-demand. If this library is not found in system,
  59. requested OpenSSL function just return errorcode.
  60. }
  61. interface
  62. uses
  63. DynLibs;
  64. var
  65. {$IFDEF WINDOWS}
  66. DLLSSLName: string = 'ssleay32.dll';
  67. DLLSSLName2: string = 'libssl32.dll';
  68. DLLUtilName: string = 'libeay32.dll';
  69. {$ELSE}
  70. DLLSSLName: string = 'libssl.so';
  71. DLLUtilName: string = 'libcrypto.so';
  72. {$ENDIF}
  73. type
  74. SslPtr = Pointer;
  75. PSslPtr = ^SslPtr;
  76. PSSL_CTX = SslPtr;
  77. PSSL = SslPtr;
  78. PSSL_METHOD = SslPtr;
  79. PX509 = SslPtr;
  80. PX509_NAME = SslPtr;
  81. PEVP_MD = SslPtr;
  82. PInteger = ^Integer;
  83. PBIO_METHOD = SslPtr;
  84. PBIO = SslPtr;
  85. EVP_PKEY = SslPtr;
  86. PRSA = SslPtr;
  87. PASN1_UTCTIME = SslPtr;
  88. PASN1_INTEGER = SslPtr;
  89. PPasswdCb = SslPtr;
  90. PFunction = procedure;
  91. DES_cblock = array[0..7] of Byte;
  92. PDES_cblock = ^DES_cblock;
  93. des_ks_struct = packed record
  94. ks: DES_cblock;
  95. weak_key: Integer;
  96. end;
  97. des_key_schedule = array[1..16] of des_ks_struct;
  98. const
  99. EVP_MAX_MD_SIZE = 16 + 20;
  100. SSL_ERROR_NONE = 0;
  101. SSL_ERROR_SSL = 1;
  102. SSL_ERROR_WANT_READ = 2;
  103. SSL_ERROR_WANT_WRITE = 3;
  104. SSL_ERROR_WANT_X509_LOOKUP = 4;
  105. SSL_ERROR_SYSCALL = 5; //look at error stack/return value/errno
  106. SSL_ERROR_ZERO_RETURN = 6;
  107. SSL_ERROR_WANT_CONNECT = 7;
  108. SSL_ERROR_WANT_ACCEPT = 8;
  109. SSL_OP_NO_SSLv2 = $01000000;
  110. SSL_OP_NO_SSLv3 = $02000000;
  111. SSL_OP_NO_TLSv1 = $04000000;
  112. SSL_OP_ALL = $000FFFFF;
  113. SSL_VERIFY_NONE = $00;
  114. SSL_VERIFY_PEER = $01;
  115. OPENSSL_DES_DECRYPT = 0;
  116. OPENSSL_DES_ENCRYPT = 1;
  117. X509_V_OK = 0;
  118. X509_V_ILLEGAL = 1;
  119. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2;
  120. X509_V_ERR_UNABLE_TO_GET_CRL = 3;
  121. X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4;
  122. X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5;
  123. X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6;
  124. X509_V_ERR_CERT_SIGNATURE_FAILURE = 7;
  125. X509_V_ERR_CRL_SIGNATURE_FAILURE = 8;
  126. X509_V_ERR_CERT_NOT_YET_VALID = 9;
  127. X509_V_ERR_CERT_HAS_EXPIRED = 10;
  128. X509_V_ERR_CRL_NOT_YET_VALID = 11;
  129. X509_V_ERR_CRL_HAS_EXPIRED = 12;
  130. X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13;
  131. X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14;
  132. X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15;
  133. X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16;
  134. X509_V_ERR_OUT_OF_MEM = 17;
  135. X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18;
  136. X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19;
  137. X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20;
  138. X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21;
  139. X509_V_ERR_CERT_CHAIN_TOO_LONG = 22;
  140. X509_V_ERR_CERT_REVOKED = 23;
  141. X509_V_ERR_INVALID_CA = 24;
  142. X509_V_ERR_PATH_LENGTH_EXCEEDED = 25;
  143. X509_V_ERR_INVALID_PURPOSE = 26;
  144. X509_V_ERR_CERT_UNTRUSTED = 27;
  145. X509_V_ERR_CERT_REJECTED = 28;
  146. //These are 'informational' when looking for issuer cert
  147. X509_V_ERR_SUBJECT_ISSUER_MISMATCH = 29;
  148. X509_V_ERR_AKID_SKID_MISMATCH = 30;
  149. X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH = 31;
  150. X509_V_ERR_KEYUSAGE_NO_CERTSIGN = 32;
  151. X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER = 33;
  152. X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION = 34;
  153. //The application is not happy
  154. X509_V_ERR_APPLICATION_VERIFICATION = 50;
  155. SSL_FILETYPE_ASN1 = 2;
  156. SSL_FILETYPE_PEM = 1;
  157. EVP_PKEY_RSA = 6;
  158. var
  159. SSLLibHandle: TLibHandle = 0;
  160. SSLUtilHandle: TLibHandle = 0;
  161. SSLLibFile: string = '';
  162. SSLUtilFile: string = '';
  163. // libssl.dll
  164. function SslGetError(s: PSSL; ret_code: Integer):Integer;
  165. function SslLibraryInit:Integer;
  166. procedure SslLoadErrorStrings;
  167. // function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
  168. function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):Integer;
  169. function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
  170. procedure SslCtxFree(arg0: PSSL_CTX);
  171. function SslSetFd(s: PSSL; fd: Integer):Integer;
  172. function SslMethodV2:PSSL_METHOD;
  173. function SslMethodV3:PSSL_METHOD;
  174. function SslMethodTLSV1:PSSL_METHOD;
  175. function SslMethodV23:PSSL_METHOD;
  176. function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
  177. function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer;
  178. // function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
  179. function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
  180. function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
  181. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer;
  182. function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
  183. // function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
  184. function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;
  185. function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
  186. procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
  187. procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
  188. // function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer;
  189. function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):Integer;
  190. function SslNew(ctx: PSSL_CTX):PSSL;
  191. procedure SslFree(ssl: PSSL);
  192. function SslAccept(ssl: PSSL):Integer;
  193. function SslConnect(ssl: PSSL):Integer;
  194. function SslShutdown(ssl: PSSL):Integer;
  195. function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  196. function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  197. function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  198. function SslPending(ssl: PSSL):Integer;
  199. function SslGetVersion(ssl: PSSL):String;
  200. function SslGetPeerCertificate(ssl: PSSL):PX509;
  201. procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
  202. function SSLGetCurrentCipher(s: PSSL):SslPtr;
  203. function SSLCipherGetName(c: SslPtr): String;
  204. function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
  205. function SSLGetVerifyResult(ssl: PSSL):Integer;
  206. // libeay.dll
  207. function X509New: PX509;
  208. procedure X509Free(x: PX509);
  209. function X509NameOneline(a: PX509_NAME; var buf: String; size: Integer):String;
  210. function X509GetSubjectName(a: PX509):PX509_NAME;
  211. function X509GetIssuerName(a: PX509):PX509_NAME;
  212. function X509NameHash(x: PX509_NAME):Cardinal;
  213. // function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer;
  214. function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: Integer):Integer;
  215. function X509print(b: PBIO; a: PX509): integer;
  216. function X509SetVersion(x: PX509; version: integer): integer;
  217. function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
  218. function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
  219. function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
  220. bytes: string; len, loc, _set: integer): integer;
  221. function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
  222. function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
  223. function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
  224. function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer;
  225. function X509GetSerialNumber(x: PX509): PASN1_INTEGER;
  226. function EvpPkeyNew: EVP_PKEY;
  227. procedure EvpPkeyFree(pk: EVP_PKEY);
  228. function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
  229. function EvpGetDigestByName(Name: String): PEVP_MD;
  230. procedure EVPcleanup;
  231. // function ErrErrorString(e: integer; buf: PChar): PChar;
  232. function SSLeayversion(t: integer): string;
  233. procedure ErrErrorString(e: integer; var buf: string; len: integer);
  234. function ErrGetError: integer;
  235. procedure ErrClearError;
  236. procedure ErrFreeStrings;
  237. procedure ErrRemoveState(pid: integer);
  238. procedure OPENSSLaddallalgorithms;
  239. procedure CRYPTOcleanupAllExData;
  240. procedure RandScreen;
  241. function BioNew(b: PBIO_METHOD): PBIO;
  242. procedure BioFreeAll(b: PBIO);
  243. function BioSMem: PBIO_METHOD;
  244. function BioCtrlPending(b: PBIO): integer;
  245. function BioRead(b: PBIO; var Buf: String; Len: integer): integer;
  246. function BioWrite(b: PBIO; Buf: String; Len: integer): integer;
  247. function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
  248. function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer;
  249. procedure PKCS12free(p12: SslPtr);
  250. function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
  251. function Asn1UtctimeNew: PASN1_UTCTIME;
  252. procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
  253. function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
  254. function i2dX509bio(b: PBIO; x: PX509): integer;
  255. function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer;
  256. // 3DES functions
  257. procedure DESsetoddparity(Key: des_cblock);
  258. function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer;
  259. procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer);
  260. function IsSSLloaded: Boolean;
  261. function InitSSLInterface: Boolean;
  262. function DestroySSLInterface: Boolean;
  263. implementation
  264. type
  265. // libssl.dll
  266. TSslGetError = function(s: PSSL; ret_code: Integer):Integer; cdecl;
  267. TSslLibraryInit = function:Integer; cdecl;
  268. TSslLoadErrorStrings = procedure; cdecl;
  269. TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PChar):Integer; cdecl;
  270. TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
  271. TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
  272. TSslSetFd = function(s: PSSL; fd: Integer):Integer; cdecl;
  273. TSslMethodV2 = function:PSSL_METHOD; cdecl;
  274. TSslMethodV3 = function:PSSL_METHOD; cdecl;
  275. TSslMethodTLSV1 = function:PSSL_METHOD; cdecl;
  276. TSslMethodV23 = function:PSSL_METHOD; cdecl;
  277. TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):Integer; cdecl;
  278. TSslCtxUsePrivateKeyASN1 = function(pk: integer; ctx: PSSL_CTX; d: sslptr; len: integer):Integer; cdecl;
  279. TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer; cdecl;
  280. TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):Integer; cdecl;
  281. TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: Integer; d: SslPtr):Integer; cdecl;
  282. TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer; cdecl;
  283. TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PChar):Integer; cdecl;
  284. TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):Integer; cdecl;
  285. TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
  286. TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
  287. TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):Integer; cdecl;
  288. TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
  289. TSslFree = procedure(ssl: PSSL); cdecl;
  290. TSslAccept = function(ssl: PSSL):Integer; cdecl;
  291. TSslConnect = function(ssl: PSSL):Integer; cdecl;
  292. TSslShutdown = function(ssl: PSSL):Integer; cdecl;
  293. TSslRead = function(ssl: PSSL; buf: PChar; num: Integer):Integer; cdecl;
  294. TSslPeek = function(ssl: PSSL; buf: PChar; num: Integer):Integer; cdecl;
  295. TSslWrite = function(ssl: PSSL; const buf: PChar; num: Integer):Integer; cdecl;
  296. TSslPending = function(ssl: PSSL):Integer; cdecl;
  297. TSslGetVersion = function(ssl: PSSL):PChar; cdecl;
  298. TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
  299. TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: Integer; arg2: SslPtr); cdecl;
  300. TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
  301. TSSLCipherGetName = function(c: Sslptr):PChar; cdecl;
  302. TSSLCipherGetBits = function(c: SslPtr; alg_bits: PInteger):Integer; cdecl;
  303. TSSLGetVerifyResult = function(ssl: PSSL):Integer; cdecl;
  304. // libeay.dll
  305. TX509New = function: PX509; cdecl;
  306. TX509Free = procedure(x: PX509); cdecl;
  307. TX509NameOneline = function(a: PX509_NAME; buf: PChar; size: Integer):PChar; cdecl;
  308. TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
  309. TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
  310. TX509NameHash = function(x: PX509_NAME):Cardinal; cdecl;
  311. TX509Digest = function(data: PX509; _type: PEVP_MD; md: PChar; len: PInteger):Integer; cdecl;
  312. TX509print = function(b: PBIO; a: PX509): integer; cdecl;
  313. TX509SetVersion = function(x: PX509; version: integer): integer; cdecl;
  314. TX509SetPubkey = function(x: PX509; pkey: EVP_PKEY): integer; cdecl;
  315. TX509SetIssuerName = function(x: PX509; name: PX509_NAME): integer; cdecl;
  316. TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PChar; _type: integer;
  317. bytes: PChar; len, loc, _set: integer): integer; cdecl;
  318. TX509Sign = function(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; cdecl;
  319. TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; cdecl;
  320. TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
  321. TX509SetNotAfter = function(x: PX509; tm: PASN1_UTCTIME): integer; cdecl;
  322. TX509GetSerialNumber = function(x: PX509): PASN1_INTEGER; cdecl;
  323. TEvpPkeyNew = function: EVP_PKEY; cdecl;
  324. TEvpPkeyFree = procedure(pk: EVP_PKEY); cdecl;
  325. TEvpPkeyAssign = function(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; cdecl;
  326. TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
  327. TEVPcleanup = procedure; cdecl;
  328. TSSLeayversion = function(t: integer): PChar; cdecl;
  329. TErrErrorString = procedure(e: integer; buf: PChar; len: integer); cdecl;
  330. TErrGetError = function: integer; cdecl;
  331. TErrClearError = procedure; cdecl;
  332. TErrFreeStrings = procedure; cdecl;
  333. TErrRemoveState = procedure(pid: integer); cdecl;
  334. TOPENSSLaddallalgorithms = procedure; cdecl;
  335. TCRYPTOcleanupAllExData = procedure; cdecl;
  336. TRandScreen = procedure; cdecl;
  337. TBioNew = function(b: PBIO_METHOD): PBIO; cdecl;
  338. TBioFreeAll = procedure(b: PBIO); cdecl;
  339. TBioSMem = function: PBIO_METHOD; cdecl;
  340. TBioCtrlPending = function(b: PBIO): integer; cdecl;
  341. TBioRead = function(b: PBIO; Buf: PChar; Len: integer): integer; cdecl;
  342. TBioWrite = function(b: PBIO; Buf: PChar; Len: integer): integer; cdecl;
  343. Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
  344. TPKCS12parse = function(p12: SslPtr; pass: PChar; var pkey, cert, ca: SslPtr): integer; cdecl;
  345. TPKCS12free = procedure(p12: SslPtr); cdecl;
  346. TRsaGenerateKey = function(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; cdecl;
  347. TAsn1UtctimeNew = function: PASN1_UTCTIME; cdecl;
  348. TAsn1UtctimeFree = procedure(a: PASN1_UTCTIME); cdecl;
  349. TAsn1IntegerSet = function(a: PASN1_INTEGER; v: integer): integer; cdecl;
  350. Ti2dX509bio = function(b: PBIO; x: PX509): integer; cdecl;
  351. Ti2dPrivateKeyBio= function(b: PBIO; pkey: EVP_PKEY): integer; cdecl;
  352. // 3DES functions
  353. TDESsetoddparity = procedure(Key: des_cblock); cdecl;
  354. TDESsetkeychecked = function(key: des_cblock; schedule: des_key_schedule): Integer; cdecl;
  355. TDESecbencrypt = procedure(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer); cdecl;
  356. //thread lock functions
  357. TCRYPTOnumlocks = function: integer; cdecl;
  358. TCRYPTOSetLockingCallback = procedure(cb: Sslptr); cdecl;
  359. var
  360. // libssl.dll
  361. _SslGetError: TSslGetError = nil;
  362. _SslLibraryInit: TSslLibraryInit = nil;
  363. _SslLoadErrorStrings: TSslLoadErrorStrings = nil;
  364. _SslCtxSetCipherList: TSslCtxSetCipherList = nil;
  365. _SslCtxNew: TSslCtxNew = nil;
  366. _SslCtxFree: TSslCtxFree = nil;
  367. _SslSetFd: TSslSetFd = nil;
  368. _SslMethodV2: TSslMethodV2 = nil;
  369. _SslMethodV3: TSslMethodV3 = nil;
  370. _SslMethodTLSV1: TSslMethodTLSV1 = nil;
  371. _SslMethodV23: TSslMethodV23 = nil;
  372. _SslCtxUsePrivateKey: TSslCtxUsePrivateKey = nil;
  373. _SslCtxUsePrivateKeyASN1: TSslCtxUsePrivateKeyASN1 = nil;
  374. _SslCtxUsePrivateKeyFile: TSslCtxUsePrivateKeyFile = nil;
  375. _SslCtxUseCertificate: TSslCtxUseCertificate = nil;
  376. _SslCtxUseCertificateASN1: TSslCtxUseCertificateASN1 = nil;
  377. _SslCtxUseCertificateFile: TSslCtxUseCertificateFile = nil;
  378. _SslCtxUseCertificateChainFile: TSslCtxUseCertificateChainFile = nil;
  379. _SslCtxCheckPrivateKeyFile: TSslCtxCheckPrivateKeyFile = nil;
  380. _SslCtxSetDefaultPasswdCb: TSslCtxSetDefaultPasswdCb = nil;
  381. _SslCtxSetDefaultPasswdCbUserdata: TSslCtxSetDefaultPasswdCbUserdata = nil;
  382. _SslCtxLoadVerifyLocations: TSslCtxLoadVerifyLocations = nil;
  383. _SslNew: TSslNew = nil;
  384. _SslFree: TSslFree = nil;
  385. _SslAccept: TSslAccept = nil;
  386. _SslConnect: TSslConnect = nil;
  387. _SslShutdown: TSslShutdown = nil;
  388. _SslRead: TSslRead = nil;
  389. _SslPeek: TSslPeek = nil;
  390. _SslWrite: TSslWrite = nil;
  391. _SslPending: TSslPending = nil;
  392. _SslGetVersion: TSslGetVersion = nil;
  393. _SslGetPeerCertificate: TSslGetPeerCertificate = nil;
  394. _SslCtxSetVerify: TSslCtxSetVerify = nil;
  395. _SSLGetCurrentCipher: TSSLGetCurrentCipher = nil;
  396. _SSLCipherGetName: TSSLCipherGetName = nil;
  397. _SSLCipherGetBits: TSSLCipherGetBits = nil;
  398. _SSLGetVerifyResult: TSSLGetVerifyResult = nil;
  399. // libeay.dll
  400. _X509New: TX509New = nil;
  401. _X509Free: TX509Free = nil;
  402. _X509NameOneline: TX509NameOneline = nil;
  403. _X509GetSubjectName: TX509GetSubjectName = nil;
  404. _X509GetIssuerName: TX509GetIssuerName = nil;
  405. _X509NameHash: TX509NameHash = nil;
  406. _X509Digest: TX509Digest = nil;
  407. _X509print: TX509print = nil;
  408. _X509SetVersion: TX509SetVersion = nil;
  409. _X509SetPubkey: TX509SetPubkey = nil;
  410. _X509SetIssuerName: TX509SetIssuerName = nil;
  411. _X509NameAddEntryByTxt: TX509NameAddEntryByTxt = nil;
  412. _X509Sign: TX509Sign = nil;
  413. _X509GmtimeAdj: TX509GmtimeAdj = nil;
  414. _X509SetNotBefore: TX509SetNotBefore = nil;
  415. _X509SetNotAfter: TX509SetNotAfter = nil;
  416. _X509GetSerialNumber: TX509GetSerialNumber = nil;
  417. _EvpPkeyNew: TEvpPkeyNew = nil;
  418. _EvpPkeyFree: TEvpPkeyFree = nil;
  419. _EvpPkeyAssign: TEvpPkeyAssign = nil;
  420. _EvpGetDigestByName: TEvpGetDigestByName = nil;
  421. _EVPcleanup: TEVPcleanup = nil;
  422. _SSLeayversion: TSSLeayversion = nil;
  423. _ErrErrorString: TErrErrorString = nil;
  424. _ErrGetError: TErrGetError = nil;
  425. _ErrClearError: TErrClearError = nil;
  426. _ErrFreeStrings: TErrFreeStrings = nil;
  427. _ErrRemoveState: TErrRemoveState = nil;
  428. _OPENSSLaddallalgorithms: TOPENSSLaddallalgorithms = nil;
  429. _CRYPTOcleanupAllExData: TCRYPTOcleanupAllExData = nil;
  430. _RandScreen: TRandScreen = nil;
  431. _BioNew: TBioNew = nil;
  432. _BioFreeAll: TBioFreeAll = nil;
  433. _BioSMem: TBioSMem = nil;
  434. _BioCtrlPending: TBioCtrlPending = nil;
  435. _BioRead: TBioRead = nil;
  436. _BioWrite: TBioWrite = nil;
  437. _d2iPKCS12bio: Td2iPKCS12bio = nil;
  438. _PKCS12parse: TPKCS12parse = nil;
  439. _PKCS12free: TPKCS12free = nil;
  440. _RsaGenerateKey: TRsaGenerateKey = nil;
  441. _Asn1UtctimeNew: TAsn1UtctimeNew = nil;
  442. _Asn1UtctimeFree: TAsn1UtctimeFree = nil;
  443. _Asn1IntegerSet: TAsn1IntegerSet = nil;
  444. _i2dX509bio: Ti2dX509bio = nil;
  445. _i2dPrivateKeyBio: Ti2dPrivateKeyBio = nil;
  446. // 3DES functions
  447. _DESsetoddparity: TDESsetoddparity = nil;
  448. _DESsetkeychecked: TDESsetkeychecked = nil;
  449. _DESecbencrypt: TDESecbencrypt = nil;
  450. //thread lock functions
  451. _CRYPTOnumlocks: TCRYPTOnumlocks = nil;
  452. _CRYPTOSetLockingCallback: TCRYPTOSetLockingCallback = nil;
  453. var
  454. SSLloaded: boolean = false;
  455. // libssl.dll
  456. function SslGetError(s: PSSL; ret_code: Integer):Integer;
  457. begin
  458. if InitSSLInterface and Assigned(_SslGetError) then
  459. Result := _SslGetError(s, ret_code)
  460. else
  461. Result := SSL_ERROR_SSL;
  462. end;
  463. function SslLibraryInit:Integer;
  464. begin
  465. if InitSSLInterface and Assigned(_SslLibraryInit) then
  466. Result := _SslLibraryInit
  467. else
  468. Result := 1;
  469. end;
  470. procedure SslLoadErrorStrings;
  471. begin
  472. if InitSSLInterface and Assigned(_SslLoadErrorStrings) then
  473. _SslLoadErrorStrings;
  474. end;
  475. function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):Integer;
  476. begin
  477. if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
  478. Result := _SslCtxSetCipherList(arg0, PChar(str))
  479. else
  480. Result := 0;
  481. end;
  482. function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
  483. begin
  484. if InitSSLInterface and Assigned(_SslCtxNew) then
  485. Result := _SslCtxNew(meth)
  486. else
  487. Result := nil;
  488. end;
  489. procedure SslCtxFree(arg0: PSSL_CTX);
  490. begin
  491. if InitSSLInterface and Assigned(_SslCtxFree) then
  492. _SslCtxFree(arg0);
  493. end;
  494. function SslSetFd(s: PSSL; fd: Integer):Integer;
  495. begin
  496. if InitSSLInterface and Assigned(_SslSetFd) then
  497. Result := _SslSetFd(s, fd)
  498. else
  499. Result := 0;
  500. end;
  501. function SslMethodV2:PSSL_METHOD;
  502. begin
  503. if InitSSLInterface and Assigned(_SslMethodV2) then
  504. Result := _SslMethodV2
  505. else
  506. Result := nil;
  507. end;
  508. function SslMethodV3:PSSL_METHOD;
  509. begin
  510. if InitSSLInterface and Assigned(_SslMethodV3) then
  511. Result := _SslMethodV3
  512. else
  513. Result := nil;
  514. end;
  515. function SslMethodTLSV1:PSSL_METHOD;
  516. begin
  517. if InitSSLInterface and Assigned(_SslMethodTLSV1) then
  518. Result := _SslMethodTLSV1
  519. else
  520. Result := nil;
  521. end;
  522. function SslMethodV23:PSSL_METHOD;
  523. begin
  524. if InitSSLInterface and Assigned(_SslMethodV23) then
  525. Result := _SslMethodV23
  526. else
  527. Result := nil;
  528. end;
  529. function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
  530. begin
  531. if InitSSLInterface and Assigned(_SslCtxUsePrivateKey) then
  532. Result := _SslCtxUsePrivateKey(ctx, pkey)
  533. else
  534. Result := 0;
  535. end;
  536. function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer;
  537. begin
  538. if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
  539. Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
  540. else
  541. Result := 0;
  542. end;
  543. function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
  544. begin
  545. if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
  546. Result := _SslCtxUsePrivateKeyFile(ctx, PChar(_file), _type)
  547. else
  548. Result := 0;
  549. end;
  550. function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
  551. begin
  552. if InitSSLInterface and Assigned(_SslCtxUseCertificate) then
  553. Result := _SslCtxUseCertificate(ctx, x)
  554. else
  555. Result := 0;
  556. end;
  557. function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer;
  558. begin
  559. if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
  560. Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
  561. else
  562. Result := 0;
  563. end;
  564. function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
  565. begin
  566. if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
  567. Result := _SslCtxUseCertificateFile(ctx, PChar(_file), _type)
  568. else
  569. Result := 0;
  570. end;
  571. function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;
  572. begin
  573. if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
  574. Result := _SslCtxUseCertificateChainFile(ctx, PChar(_file))
  575. else
  576. Result := 0;
  577. end;
  578. function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
  579. begin
  580. if InitSSLInterface and Assigned(_SslCtxCheckPrivateKeyFile) then
  581. Result := _SslCtxCheckPrivateKeyFile(ctx)
  582. else
  583. Result := 0;
  584. end;
  585. procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
  586. begin
  587. if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCb) then
  588. _SslCtxSetDefaultPasswdCb(ctx, cb);
  589. end;
  590. procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
  591. begin
  592. if InitSSLInterface and Assigned(_SslCtxSetDefaultPasswdCbUserdata) then
  593. _SslCtxSetDefaultPasswdCbUserdata(ctx, u);
  594. end;
  595. function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):Integer;
  596. begin
  597. if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
  598. Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
  599. else
  600. Result := 0;
  601. end;
  602. function SslNew(ctx: PSSL_CTX):PSSL;
  603. begin
  604. if InitSSLInterface and Assigned(_SslNew) then
  605. Result := _SslNew(ctx)
  606. else
  607. Result := nil;
  608. end;
  609. procedure SslFree(ssl: PSSL);
  610. begin
  611. if InitSSLInterface and Assigned(_SslFree) then
  612. _SslFree(ssl);
  613. end;
  614. function SslAccept(ssl: PSSL):Integer;
  615. begin
  616. if InitSSLInterface and Assigned(_SslAccept) then
  617. Result := _SslAccept(ssl)
  618. else
  619. Result := -1;
  620. end;
  621. function SslConnect(ssl: PSSL):Integer;
  622. begin
  623. if InitSSLInterface and Assigned(_SslConnect) then
  624. Result := _SslConnect(ssl)
  625. else
  626. Result := -1;
  627. end;
  628. function SslShutdown(ssl: PSSL):Integer;
  629. begin
  630. if InitSSLInterface and Assigned(_SslShutdown) then
  631. Result := _SslShutdown(ssl)
  632. else
  633. Result := -1;
  634. end;
  635. function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  636. begin
  637. if InitSSLInterface and Assigned(_SslRead) then
  638. Result := _SslRead(ssl, PChar(buf), num)
  639. else
  640. Result := -1;
  641. end;
  642. function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  643. begin
  644. if InitSSLInterface and Assigned(_SslPeek) then
  645. Result := _SslPeek(ssl, PChar(buf), num)
  646. else
  647. Result := -1;
  648. end;
  649. function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
  650. begin
  651. if InitSSLInterface and Assigned(_SslWrite) then
  652. Result := _SslWrite(ssl, PChar(buf), num)
  653. else
  654. Result := -1;
  655. end;
  656. function SslPending(ssl: PSSL):Integer;
  657. begin
  658. if InitSSLInterface and Assigned(_SslPending) then
  659. Result := _SslPending(ssl)
  660. else
  661. Result := 0;
  662. end;
  663. //function SslGetVersion(ssl: PSSL):PChar;
  664. function SslGetVersion(ssl: PSSL):String;
  665. begin
  666. if InitSSLInterface and Assigned(_SslGetVersion) then
  667. Result := _SslGetVersion(ssl)
  668. else
  669. Result := '';
  670. end;
  671. function SslGetPeerCertificate(ssl: PSSL):PX509;
  672. begin
  673. if InitSSLInterface and Assigned(_SslGetPeerCertificate) then
  674. Result := _SslGetPeerCertificate(ssl)
  675. else
  676. Result := nil;
  677. end;
  678. procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
  679. begin
  680. if InitSSLInterface and Assigned(_SslCtxSetVerify) then
  681. _SslCtxSetVerify(ctx, mode, @arg2);
  682. end;
  683. function SSLGetCurrentCipher(s: PSSL):SslPtr;
  684. begin
  685. if InitSSLInterface and Assigned(_SSLGetCurrentCipher) then
  686. {$IFDEF CIL}
  687. {$ELSE}
  688. Result := _SSLGetCurrentCipher(s)
  689. {$ENDIF}
  690. else
  691. Result := nil;
  692. end;
  693. function SSLCipherGetName(c: SslPtr):String;
  694. begin
  695. if InitSSLInterface and Assigned(_SSLCipherGetName) then
  696. Result := _SSLCipherGetName(c)
  697. else
  698. Result := '';
  699. end;
  700. function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
  701. begin
  702. if InitSSLInterface and Assigned(_SSLCipherGetBits) then
  703. Result := _SSLCipherGetBits(c, @alg_bits)
  704. else
  705. Result := 0;
  706. end;
  707. function SSLGetVerifyResult(ssl: PSSL):Integer;
  708. begin
  709. if InitSSLInterface and Assigned(_SSLGetVerifyResult) then
  710. Result := _SSLGetVerifyResult(ssl)
  711. else
  712. Result := X509_V_ERR_APPLICATION_VERIFICATION;
  713. end;
  714. // libeay.dll
  715. function X509New: PX509;
  716. begin
  717. if InitSSLInterface and Assigned(_X509New) then
  718. Result := _X509New
  719. else
  720. Result := nil;
  721. end;
  722. procedure X509Free(x: PX509);
  723. begin
  724. if InitSSLInterface and Assigned(_X509Free) then
  725. _X509Free(x);
  726. end;
  727. function X509NameOneline(a: PX509_NAME; var buf: String; size: Integer):String;
  728. begin
  729. if InitSSLInterface and Assigned(_X509NameOneline) then
  730. Result := _X509NameOneline(a, PChar(buf),size)
  731. else
  732. Result := '';
  733. end;
  734. function X509GetSubjectName(a: PX509):PX509_NAME;
  735. begin
  736. if InitSSLInterface and Assigned(_X509GetSubjectName) then
  737. Result := _X509GetSubjectName(a)
  738. else
  739. Result := nil;
  740. end;
  741. function X509GetIssuerName(a: PX509):PX509_NAME;
  742. begin
  743. if InitSSLInterface and Assigned(_X509GetIssuerName) then
  744. Result := _X509GetIssuerName(a)
  745. else
  746. Result := nil;
  747. end;
  748. function X509NameHash(x: PX509_NAME):Cardinal;
  749. begin
  750. if InitSSLInterface and Assigned(_X509NameHash) then
  751. Result := _X509NameHash(x)
  752. else
  753. Result := 0;
  754. end;
  755. function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: Integer):Integer;
  756. begin
  757. if InitSSLInterface and Assigned(_X509Digest) then
  758. Result := _X509Digest(data, _type, PChar(md), @len)
  759. else
  760. Result := 0;
  761. end;
  762. function EvpPkeyNew: EVP_PKEY;
  763. begin
  764. if InitSSLInterface and Assigned(_EvpPkeyNew) then
  765. Result := _EvpPkeyNew
  766. else
  767. Result := nil;
  768. end;
  769. procedure EvpPkeyFree(pk: EVP_PKEY);
  770. begin
  771. if InitSSLInterface and Assigned(_EvpPkeyFree) then
  772. _EvpPkeyFree(pk);
  773. end;
  774. function SSLeayversion(t: integer): string;
  775. begin
  776. if InitSSLInterface and Assigned(_SSLeayversion) then
  777. Result := PChar(_SSLeayversion(t))
  778. else
  779. Result := '';
  780. end;
  781. procedure ErrErrorString(e: integer; var buf: string; len: integer);
  782. begin
  783. if InitSSLInterface and Assigned(_ErrErrorString) then
  784. _ErrErrorString(e, Pointer(buf), len);
  785. buf := PChar(Buf);
  786. end;
  787. function ErrGetError: integer;
  788. begin
  789. if InitSSLInterface and Assigned(_ErrGetError) then
  790. Result := _ErrGetError
  791. else
  792. Result := SSL_ERROR_SSL;
  793. end;
  794. procedure ErrClearError;
  795. begin
  796. if InitSSLInterface and Assigned(_ErrClearError) then
  797. _ErrClearError;
  798. end;
  799. procedure ErrFreeStrings;
  800. begin
  801. if InitSSLInterface and Assigned(_ErrFreeStrings) then
  802. _ErrFreeStrings;
  803. end;
  804. procedure ErrRemoveState(pid: integer);
  805. begin
  806. if InitSSLInterface and Assigned(_ErrRemoveState) then
  807. _ErrRemoveState(pid);
  808. end;
  809. procedure OPENSSLaddallalgorithms;
  810. begin
  811. if InitSSLInterface and Assigned(_OPENSSLaddallalgorithms) then
  812. _OPENSSLaddallalgorithms;
  813. end;
  814. procedure EVPcleanup;
  815. begin
  816. if InitSSLInterface and Assigned(_EVPcleanup) then
  817. _EVPcleanup;
  818. end;
  819. procedure CRYPTOcleanupAllExData;
  820. begin
  821. if InitSSLInterface and Assigned(_CRYPTOcleanupAllExData) then
  822. _CRYPTOcleanupAllExData;
  823. end;
  824. procedure RandScreen;
  825. begin
  826. if InitSSLInterface and Assigned(_RandScreen) then
  827. _RandScreen;
  828. end;
  829. function BioNew(b: PBIO_METHOD): PBIO;
  830. begin
  831. if InitSSLInterface and Assigned(_BioNew) then
  832. Result := _BioNew(b)
  833. else
  834. Result := nil;
  835. end;
  836. procedure BioFreeAll(b: PBIO);
  837. begin
  838. if InitSSLInterface and Assigned(_BioFreeAll) then
  839. _BioFreeAll(b);
  840. end;
  841. function BioSMem: PBIO_METHOD;
  842. begin
  843. if InitSSLInterface and Assigned(_BioSMem) then
  844. Result := _BioSMem
  845. else
  846. Result := nil;
  847. end;
  848. function BioCtrlPending(b: PBIO): integer;
  849. begin
  850. if InitSSLInterface and Assigned(_BioCtrlPending) then
  851. Result := _BioCtrlPending(b)
  852. else
  853. Result := 0;
  854. end;
  855. function BioRead(b: PBIO; var Buf: String; Len: integer): integer;
  856. begin
  857. if InitSSLInterface and Assigned(_BioRead) then
  858. Result := _BioRead(b, PChar(Buf), Len)
  859. else
  860. Result := -2;
  861. end;
  862. //function BioWrite(b: PBIO; Buf: PChar; Len: integer): integer;
  863. function BioWrite(b: PBIO; Buf: String; Len: integer): integer;
  864. begin
  865. if InitSSLInterface and Assigned(_BioWrite) then
  866. Result := _BioWrite(b, PChar(Buf), Len)
  867. else
  868. Result := -2;
  869. end;
  870. function X509print(b: PBIO; a: PX509): integer;
  871. begin
  872. if InitSSLInterface and Assigned(_X509print) then
  873. Result := _X509print(b, a)
  874. else
  875. Result := 0;
  876. end;
  877. function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
  878. begin
  879. if InitSSLInterface and Assigned(_d2iPKCS12bio) then
  880. Result := _d2iPKCS12bio(b, Pkcs12)
  881. else
  882. Result := nil;
  883. end;
  884. function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer;
  885. begin
  886. if InitSSLInterface and Assigned(_PKCS12parse) then
  887. Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
  888. else
  889. Result := 0;
  890. end;
  891. procedure PKCS12free(p12: SslPtr);
  892. begin
  893. if InitSSLInterface and Assigned(_PKCS12free) then
  894. _PKCS12free(p12);
  895. end;
  896. function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA;
  897. begin
  898. if InitSSLInterface and Assigned(_RsaGenerateKey) then
  899. Result := _RsaGenerateKey(bits, e, callback, cb_arg)
  900. else
  901. Result := nil;
  902. end;
  903. function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer;
  904. begin
  905. if InitSSLInterface and Assigned(_EvpPkeyAssign) then
  906. Result := _EvpPkeyAssign(pkey, _type, key)
  907. else
  908. Result := 0;
  909. end;
  910. function X509SetVersion(x: PX509; version: integer): integer;
  911. begin
  912. if InitSSLInterface and Assigned(_X509SetVersion) then
  913. Result := _X509SetVersion(x, version)
  914. else
  915. Result := 0;
  916. end;
  917. function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer;
  918. begin
  919. if InitSSLInterface and Assigned(_X509SetPubkey) then
  920. Result := _X509SetPubkey(x, pkey)
  921. else
  922. Result := 0;
  923. end;
  924. function X509SetIssuerName(x: PX509; name: PX509_NAME): integer;
  925. begin
  926. if InitSSLInterface and Assigned(_X509SetIssuerName) then
  927. Result := _X509SetIssuerName(x, name)
  928. else
  929. Result := 0;
  930. end;
  931. function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
  932. bytes: string; len, loc, _set: integer): integer;
  933. begin
  934. if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
  935. Result := _X509NameAddEntryByTxt(name, PChar(field), _type, PChar(Bytes), len, loc, _set)
  936. else
  937. Result := 0;
  938. end;
  939. function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer;
  940. begin
  941. if InitSSLInterface and Assigned(_X509Sign) then
  942. Result := _X509Sign(x, pkey, md)
  943. else
  944. Result := 0;
  945. end;
  946. function Asn1UtctimeNew: PASN1_UTCTIME;
  947. begin
  948. if InitSSLInterface and Assigned(_Asn1UtctimeNew) then
  949. Result := _Asn1UtctimeNew
  950. else
  951. Result := nil;
  952. end;
  953. procedure Asn1UtctimeFree(a: PASN1_UTCTIME);
  954. begin
  955. if InitSSLInterface and Assigned(_Asn1UtctimeFree) then
  956. _Asn1UtctimeFree(a);
  957. end;
  958. function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME;
  959. begin
  960. if InitSSLInterface and Assigned(_X509GmtimeAdj) then
  961. Result := _X509GmtimeAdj(s, adj)
  962. else
  963. Result := nil;
  964. end;
  965. function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer;
  966. begin
  967. if InitSSLInterface and Assigned(_X509SetNotBefore) then
  968. Result := _X509SetNotBefore(x, tm)
  969. else
  970. Result := 0;
  971. end;
  972. function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer;
  973. begin
  974. if InitSSLInterface and Assigned(_X509SetNotAfter) then
  975. Result := _X509SetNotAfter(x, tm)
  976. else
  977. Result := 0;
  978. end;
  979. function i2dX509bio(b: PBIO; x: PX509): integer;
  980. begin
  981. if InitSSLInterface and Assigned(_i2dX509bio) then
  982. Result := _i2dX509bio(b, x)
  983. else
  984. Result := 0;
  985. end;
  986. function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer;
  987. begin
  988. if InitSSLInterface and Assigned(_i2dPrivateKeyBio) then
  989. Result := _i2dPrivateKeyBio(b, pkey)
  990. else
  991. Result := 0;
  992. end;
  993. function EvpGetDigestByName(Name: String): PEVP_MD;
  994. begin
  995. if InitSSLInterface and Assigned(_EvpGetDigestByName) then
  996. Result := _EvpGetDigestByName(PChar(Name))
  997. else
  998. Result := nil;
  999. end;
  1000. function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer;
  1001. begin
  1002. if InitSSLInterface and Assigned(_Asn1IntegerSet) then
  1003. Result := _Asn1IntegerSet(a, v)
  1004. else
  1005. Result := 0;
  1006. end;
  1007. function X509GetSerialNumber(x: PX509): PASN1_INTEGER;
  1008. begin
  1009. if InitSSLInterface and Assigned(_X509GetSerialNumber) then
  1010. Result := _X509GetSerialNumber(x)
  1011. else
  1012. Result := nil;
  1013. end;
  1014. // 3DES functions
  1015. procedure DESsetoddparity(Key: des_cblock);
  1016. begin
  1017. if InitSSLInterface and Assigned(_DESsetoddparity) then
  1018. _DESsetoddparity(Key);
  1019. end;
  1020. function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer;
  1021. begin
  1022. if InitSSLInterface and Assigned(_DESsetkeychecked) then
  1023. Result := _DESsetkeychecked(key, schedule)
  1024. else
  1025. Result := -1;
  1026. end;
  1027. procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer);
  1028. begin
  1029. if InitSSLInterface and Assigned(_DESecbencrypt) then
  1030. _DESecbencrypt(Input, output, ks, enc);
  1031. end;
  1032. function LoadLib(const Value: String): HModule;
  1033. begin
  1034. Result := LoadLibrary(Value);
  1035. end;
  1036. function GetProcAddr(module: HModule; const ProcName: string): SslPtr;
  1037. begin
  1038. Result := GetProcAddress(module, PChar(ProcName));
  1039. end;
  1040. function InitSSLInterface: Boolean;
  1041. begin
  1042. if not IsSSLloaded then
  1043. begin
  1044. SSLLibHandle := LoadLib(DLLSSLName);
  1045. SSLUtilHandle := LoadLib(DLLUtilName);
  1046. {$IFNDEF UNIX}
  1047. if (SSLLibHandle = 0) then
  1048. SSLLibHandle := LoadLib(DLLSSLName2);
  1049. {$ENDIF}
  1050. if (SSLLibHandle <> 0) and (SSLUtilHandle <> 0) then
  1051. begin
  1052. _SslGetError := GetProcAddr(SSLLibHandle, 'SSL_get_error');
  1053. _SslLibraryInit := GetProcAddr(SSLLibHandle, 'SSL_library_init');
  1054. _SslLoadErrorStrings := GetProcAddr(SSLLibHandle, 'SSL_load_error_strings');
  1055. _SslCtxSetCipherList := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_cipher_list');
  1056. _SslCtxNew := GetProcAddr(SSLLibHandle, 'SSL_CTX_new');
  1057. _SslCtxFree := GetProcAddr(SSLLibHandle, 'SSL_CTX_free');
  1058. _SslSetFd := GetProcAddr(SSLLibHandle, 'SSL_set_fd');
  1059. _SslMethodV2 := GetProcAddr(SSLLibHandle, 'SSLv2_method');
  1060. _SslMethodV3 := GetProcAddr(SSLLibHandle, 'SSLv3_method');
  1061. _SslMethodTLSV1 := GetProcAddr(SSLLibHandle, 'TLSv1_method');
  1062. _SslMethodV23 := GetProcAddr(SSLLibHandle, 'SSLv23_method');
  1063. _SslCtxUsePrivateKey := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey');
  1064. _SslCtxUsePrivateKeyASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey_ASN1');
  1065. //use SSL_CTX_use_RSAPrivateKey_file instead SSL_CTX_use_PrivateKey_file,
  1066. //because SSL_CTX_use_PrivateKey_file not support DER format. :-O
  1067. _SslCtxUsePrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_RSAPrivateKey_file');
  1068. _SslCtxUseCertificate := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate');
  1069. _SslCtxUseCertificateASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_ASN1');
  1070. _SslCtxUseCertificateFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_file');
  1071. _SslCtxUseCertificateChainFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_certificate_chain_file');
  1072. _SslCtxCheckPrivateKeyFile := GetProcAddr(SSLLibHandle, 'SSL_CTX_check_private_key');
  1073. _SslCtxSetDefaultPasswdCb := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb');
  1074. _SslCtxSetDefaultPasswdCbUserdata := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_default_passwd_cb_userdata');
  1075. _SslCtxLoadVerifyLocations := GetProcAddr(SSLLibHandle, 'SSL_CTX_load_verify_locations');
  1076. _SslNew := GetProcAddr(SSLLibHandle, 'SSL_new');
  1077. _SslFree := GetProcAddr(SSLLibHandle, 'SSL_free');
  1078. _SslAccept := GetProcAddr(SSLLibHandle, 'SSL_accept');
  1079. _SslConnect := GetProcAddr(SSLLibHandle, 'SSL_connect');
  1080. _SslShutdown := GetProcAddr(SSLLibHandle, 'SSL_shutdown');
  1081. _SslRead := GetProcAddr(SSLLibHandle, 'SSL_read');
  1082. _SslPeek := GetProcAddr(SSLLibHandle, 'SSL_peek');
  1083. _SslWrite := GetProcAddr(SSLLibHandle, 'SSL_write');
  1084. _SslPending := GetProcAddr(SSLLibHandle, 'SSL_pending');
  1085. _SslGetPeerCertificate := GetProcAddr(SSLLibHandle, 'SSL_get_peer_certificate');
  1086. _SslGetVersion := GetProcAddr(SSLLibHandle, 'SSL_get_version');
  1087. _SslCtxSetVerify := GetProcAddr(SSLLibHandle, 'SSL_CTX_set_verify');
  1088. _SslGetCurrentCipher := GetProcAddr(SSLLibHandle, 'SSL_get_current_cipher');
  1089. _SslCipherGetName := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_name');
  1090. _SslCipherGetBits := GetProcAddr(SSLLibHandle, 'SSL_CIPHER_get_bits');
  1091. _SslGetVerifyResult := GetProcAddr(SSLLibHandle, 'SSL_get_verify_result');
  1092. _X509New := GetProcAddr(SSLUtilHandle, 'X509_new');
  1093. _X509Free := GetProcAddr(SSLUtilHandle, 'X509_free');
  1094. _X509NameOneline := GetProcAddr(SSLUtilHandle, 'X509_NAME_oneline');
  1095. _X509GetSubjectName := GetProcAddr(SSLUtilHandle, 'X509_get_subject_name');
  1096. _X509GetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_get_issuer_name');
  1097. _X509NameHash := GetProcAddr(SSLUtilHandle, 'X509_NAME_hash');
  1098. _X509Digest := GetProcAddr(SSLUtilHandle, 'X509_digest');
  1099. _X509print := GetProcAddr(SSLUtilHandle, 'X509_print');
  1100. _X509SetVersion := GetProcAddr(SSLUtilHandle, 'X509_set_version');
  1101. _X509SetPubkey := GetProcAddr(SSLUtilHandle, 'X509_set_pubkey');
  1102. _X509SetIssuerName := GetProcAddr(SSLUtilHandle, 'X509_set_issuer_name');
  1103. _X509NameAddEntryByTxt := GetProcAddr(SSLUtilHandle, 'X509_NAME_add_entry_by_txt');
  1104. _X509Sign := GetProcAddr(SSLUtilHandle, 'X509_sign');
  1105. _X509GmtimeAdj := GetProcAddr(SSLUtilHandle, 'X509_gmtime_adj');
  1106. _X509SetNotBefore := GetProcAddr(SSLUtilHandle, 'X509_set_notBefore');
  1107. _X509SetNotAfter := GetProcAddr(SSLUtilHandle, 'X509_set_notAfter');
  1108. _X509GetSerialNumber := GetProcAddr(SSLUtilHandle, 'X509_get_serialNumber');
  1109. _EvpPkeyNew := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_new');
  1110. _EvpPkeyFree := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_free');
  1111. _EvpPkeyAssign := GetProcAddr(SSLUtilHandle, 'EVP_PKEY_assign');
  1112. _EVPCleanup := GetProcAddr(SSLUtilHandle, 'EVP_cleanup');
  1113. _EvpGetDigestByName := GetProcAddr(SSLUtilHandle, 'EVP_get_digestbyname');
  1114. _SSLeayversion := GetProcAddr(SSLUtilHandle, 'SSLeay_version');
  1115. _ErrErrorString := GetProcAddr(SSLUtilHandle, 'ERR_error_string_n');
  1116. _ErrGetError := GetProcAddr(SSLUtilHandle, 'ERR_get_error');
  1117. _ErrClearError := GetProcAddr(SSLUtilHandle, 'ERR_clear_error');
  1118. _ErrFreeStrings := GetProcAddr(SSLUtilHandle, 'ERR_free_strings');
  1119. _ErrRemoveState := GetProcAddr(SSLUtilHandle, 'ERR_remove_state');
  1120. _OPENSSLaddallalgorithms := GetProcAddr(SSLUtilHandle, 'OPENSSL_add_all_algorithms_noconf');
  1121. _CRYPTOcleanupAllExData := GetProcAddr(SSLUtilHandle, 'CRYPTO_cleanup_all_ex_data');
  1122. _RandScreen := GetProcAddr(SSLUtilHandle, 'RAND_screen');
  1123. _BioNew := GetProcAddr(SSLUtilHandle, 'BIO_new');
  1124. _BioFreeAll := GetProcAddr(SSLUtilHandle, 'BIO_free_all');
  1125. _BioSMem := GetProcAddr(SSLUtilHandle, 'BIO_s_mem');
  1126. _BioCtrlPending := GetProcAddr(SSLUtilHandle, 'BIO_ctrl_pending');
  1127. _BioRead := GetProcAddr(SSLUtilHandle, 'BIO_read');
  1128. _BioWrite := GetProcAddr(SSLUtilHandle, 'BIO_write');
  1129. _d2iPKCS12bio := GetProcAddr(SSLUtilHandle, 'd2i_PKCS12_bio');
  1130. _PKCS12parse := GetProcAddr(SSLUtilHandle, 'PKCS12_parse');
  1131. _PKCS12free := GetProcAddr(SSLUtilHandle, 'PKCS12_free');
  1132. _RsaGenerateKey := GetProcAddr(SSLUtilHandle, 'RSA_generate_key');
  1133. _Asn1UtctimeNew := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_new');
  1134. _Asn1UtctimeFree := GetProcAddr(SSLUtilHandle, 'ASN1_UTCTIME_free');
  1135. _Asn1IntegerSet := GetProcAddr(SSLUtilHandle, 'ASN1_INTEGER_set');
  1136. _i2dX509bio := GetProcAddr(SSLUtilHandle, 'i2d_X509_bio');
  1137. _i2dPrivateKeyBio := GetProcAddr(SSLUtilHandle, 'i2d_PrivateKey_bio');
  1138. // 3DES functions
  1139. _DESsetoddparity := GetProcAddr(SSLUtilHandle, 'DES_set_odd_parity');
  1140. _DESsetkeychecked := GetProcAddr(SSLUtilHandle, 'DES_set_key_checked');
  1141. _DESecbencrypt := GetProcAddr(SSLUtilHandle, 'DES_ecb_encrypt');
  1142. //
  1143. _CRYPTOnumlocks := GetProcAddr(SSLUtilHandle, 'CRYPTO_num_locks');
  1144. _CRYPTOsetlockingcallback := GetProcAddr(SSLUtilHandle, 'CRYPTO_set_locking_callback');
  1145. //init library
  1146. if assigned(_SslLibraryInit) then
  1147. _SslLibraryInit;
  1148. if assigned(_SslLoadErrorStrings) then
  1149. _SslLoadErrorStrings;
  1150. if assigned(_OPENSSLaddallalgorithms) then
  1151. _OPENSSLaddallalgorithms;
  1152. if assigned(_RandScreen) then
  1153. _RandScreen;
  1154. Result := True;
  1155. SSLloaded := True;
  1156. end
  1157. else
  1158. begin
  1159. //load failed!
  1160. if SSLLibHandle <> 0 then
  1161. begin
  1162. FreeLibrary(SSLLibHandle);
  1163. SSLLibHandle := 0;
  1164. end;
  1165. if SSLUtilHandle <> 0 then
  1166. begin
  1167. FreeLibrary(SSLUtilHandle);
  1168. SSLLibHandle := 0;
  1169. end;
  1170. Result := False;
  1171. end;
  1172. end
  1173. else
  1174. //loaded before...
  1175. Result := true;
  1176. end;
  1177. function DestroySSLInterface: Boolean;
  1178. begin
  1179. if IsSSLLoaded then
  1180. begin
  1181. //deinit library
  1182. EVPCleanup;
  1183. CRYPTOcleanupAllExData;
  1184. ErrRemoveState(0);
  1185. end;
  1186. SSLloaded := false;
  1187. if SSLLibHandle <> 0 then
  1188. begin
  1189. FreeLibrary(SSLLibHandle);
  1190. SSLLibHandle := 0;
  1191. end;
  1192. if SSLUtilHandle <> 0 then
  1193. begin
  1194. FreeLibrary(SSLUtilHandle);
  1195. SSLLibHandle := 0;
  1196. end;
  1197. _SslGetError := nil;
  1198. _SslLibraryInit := nil;
  1199. _SslLoadErrorStrings := nil;
  1200. _SslCtxSetCipherList := nil;
  1201. _SslCtxNew := nil;
  1202. _SslCtxFree := nil;
  1203. _SslSetFd := nil;
  1204. _SslMethodV2 := nil;
  1205. _SslMethodV3 := nil;
  1206. _SslMethodTLSV1 := nil;
  1207. _SslMethodV23 := nil;
  1208. _SslCtxUsePrivateKey := nil;
  1209. _SslCtxUsePrivateKeyASN1 := nil;
  1210. _SslCtxUsePrivateKeyFile := nil;
  1211. _SslCtxUseCertificate := nil;
  1212. _SslCtxUseCertificateASN1 := nil;
  1213. _SslCtxUseCertificateFile := nil;
  1214. _SslCtxUseCertificateChainFile := nil;
  1215. _SslCtxCheckPrivateKeyFile := nil;
  1216. _SslCtxSetDefaultPasswdCb := nil;
  1217. _SslCtxSetDefaultPasswdCbUserdata := nil;
  1218. _SslCtxLoadVerifyLocations := nil;
  1219. _SslNew := nil;
  1220. _SslFree := nil;
  1221. _SslAccept := nil;
  1222. _SslConnect := nil;
  1223. _SslShutdown := nil;
  1224. _SslRead := nil;
  1225. _SslPeek := nil;
  1226. _SslWrite := nil;
  1227. _SslPending := nil;
  1228. _SslGetPeerCertificate := nil;
  1229. _SslGetVersion := nil;
  1230. _SslCtxSetVerify := nil;
  1231. _SslGetCurrentCipher := nil;
  1232. _SslCipherGetName := nil;
  1233. _SslCipherGetBits := nil;
  1234. _SslGetVerifyResult := nil;
  1235. _X509New := nil;
  1236. _X509Free := nil;
  1237. _X509NameOneline := nil;
  1238. _X509GetSubjectName := nil;
  1239. _X509GetIssuerName := nil;
  1240. _X509NameHash := nil;
  1241. _X509Digest := nil;
  1242. _X509print := nil;
  1243. _X509SetVersion := nil;
  1244. _X509SetPubkey := nil;
  1245. _X509SetIssuerName := nil;
  1246. _X509NameAddEntryByTxt := nil;
  1247. _X509Sign := nil;
  1248. _X509GmtimeAdj := nil;
  1249. _X509SetNotBefore := nil;
  1250. _X509SetNotAfter := nil;
  1251. _X509GetSerialNumber := nil;
  1252. _EvpPkeyNew := nil;
  1253. _EvpPkeyFree := nil;
  1254. _EvpPkeyAssign := nil;
  1255. _EVPCleanup := nil;
  1256. _EvpGetDigestByName := nil;
  1257. _SSLeayversion := nil;
  1258. _ErrErrorString := nil;
  1259. _ErrGetError := nil;
  1260. _ErrClearError := nil;
  1261. _ErrFreeStrings := nil;
  1262. _ErrRemoveState := nil;
  1263. _OPENSSLaddallalgorithms := nil;
  1264. _CRYPTOcleanupAllExData := nil;
  1265. _RandScreen := nil;
  1266. _BioNew := nil;
  1267. _BioFreeAll := nil;
  1268. _BioSMem := nil;
  1269. _BioCtrlPending := nil;
  1270. _BioRead := nil;
  1271. _BioWrite := nil;
  1272. _d2iPKCS12bio := nil;
  1273. _PKCS12parse := nil;
  1274. _PKCS12free := nil;
  1275. _RsaGenerateKey := nil;
  1276. _Asn1UtctimeNew := nil;
  1277. _Asn1UtctimeFree := nil;
  1278. _Asn1IntegerSet := nil;
  1279. _i2dX509bio := nil;
  1280. _i2dPrivateKeyBio := nil;
  1281. // 3DES functions
  1282. _DESsetoddparity := nil;
  1283. _DESsetkeychecked := nil;
  1284. _DESecbencrypt := nil;
  1285. //
  1286. _CRYPTOnumlocks := nil;
  1287. _CRYPTOsetlockingcallback := nil;
  1288. Result := True;
  1289. end;
  1290. function IsSSLloaded: Boolean;
  1291. begin
  1292. Result := SSLLoaded;
  1293. end;
  1294. finalization
  1295. DestroySSLInterface;
  1296. end.