* PChar -> PAnsiChar

This commit is contained in:
Michaël Van Canneyt 2023-01-14 12:36:44 +01:00
parent 0c7d351c8f
commit e05c612139
2 changed files with 178 additions and 175 deletions

View File

@ -53,7 +53,7 @@ Type
Constructor Create(AContext : PSSL_CTX = Nil); overload;
Constructor Create(AType : TSSLType); overload;
Destructor Destroy; override;
Function SetCipherList(Var ACipherList : String) : Integer;
Function SetCipherList(Var ACipherList : AnsiString) : Integer;
procedure SetVerify(mode: Integer; arg2: TSSLCTXVerifyCallback);
procedure SetDefaultPasswdCb(cb: PPasswdCb);
procedure SetDefaultPasswdCbUserdata(u: SslPtr);
@ -63,7 +63,7 @@ Type
function UseCertificateASN1(len: cLong; d: String):cInt; overload; deprecated 'use TBytes overload';
function UseCertificateASN1(len: cLong; buf: TBytes):cInt; overload;
function UseCertificateFile(const Afile: String; Atype: cInt):cInt;
function UseCertificateChainFile(const Afile: PChar):cInt;
function UseCertificateChainFile(const Afile: PAnsiChar):cInt;
function UseCertificate(x: SslPtr):cInt;
function LoadVerifyLocations(const CAfile: String; const CApath: String):cInt;
function LoadPFX(Const S,APassword : AnsiString) : cint; deprecated 'use TBytes overload';
@ -341,7 +341,8 @@ begin
inherited Destroy;
end;
Function TSSLContext.SetCipherList(Var ACipherList: String): Integer;
Function TSSLContext.SetCipherList(Var ACipherList: AnsiString): Integer;
begin
Result:=SSLCTxSetCipherList(FCTX,ACipherList);
end;
@ -416,7 +417,7 @@ begin
else if (Data.FileName<>'') then
begin
FN:=Data.FileName;
Result:=UseCertificateChainFile(PChar(FN));
Result:=UseCertificateChainFile(PAnsiChar(FN));
if Result<>1 then
begin
Result:=UseCertificateFile(FN,SSL_FILETYPE_PEM);
@ -441,7 +442,7 @@ begin
Result:=sslctxUseCertificateFile(FCTX,Afile,Atype);
end;
function TSSLContext.UseCertificateChainFile(const Afile: PChar): cInt;
function TSSLContext.UseCertificateChainFile(const Afile: PAnsiChar): cInt;
begin
Result:=sslctxUseCertificateChainFile(FCTX,Afile);
end;

View File

@ -66,7 +66,8 @@ Special thanks to Gregor Ibic <gregor.ibic@intelicom.si>
for good inspiration about begin with SSL programming.
}
{$MODE DELPHI}{$H+}
{$MODE DELPHI}
{$H+}
{$Packrecords C}
{:@abstract(OpenSSL support)
@ -91,28 +92,28 @@ const
// SSL and Crypto DLL arrays must have the same length and contain
// matched pairs of DLL filenames. Place newer versions at the beginning.
{$IF DEFINED(WIN64)}
SSL_DLL_Names: array[1..4] of string = ('libssl-3-x64', 'libssl-1_1-x64', 'ssleay32', 'libssl32');
Crypto_DLL_Names: array[1..4] of string = ('libcrypto-3-x64', 'libcrypto-1_1-x64', 'libeay32', 'libeay32');
SSL_DLL_Names: array[1..4] of AnsiString = ('libssl-3-x64', 'libssl-1_1-x64', 'ssleay32', 'libssl32');
Crypto_DLL_Names: array[1..4] of AnsiString = ('libcrypto-3-x64', 'libcrypto-1_1-x64', 'libeay32', 'libeay32');
{$ELSEIF DEFINED(WINDOWS)}
SSL_DLL_Names: array[1..4] of string = ('libssl-3', 'libssl-1_1', 'ssleay32', 'libssl32');
Crypto_DLL_Names: array[1..4] of string = ('libcrypto-3', 'libcrypto-1_1', 'libeay32', 'libeay32');
SSL_DLL_Names: array[1..4] of AnsiString = ('libssl-3', 'libssl-1_1', 'ssleay32', 'libssl32');
Crypto_DLL_Names: array[1..4] of AnsiString = ('libcrypto-3', 'libcrypto-1_1', 'libeay32', 'libeay32');
{$ELSEIF DEFINED(OS2GCC)}
SSL_DLL_Names: array[1..2] of string = ('kssl10', 'kssl');
Crypto_DLL_Names: array[1..2] of string = ('kcrypt10', 'kcrypto');
SSL_DLL_Names: array[1..2] of AnsiString = ('kssl10', 'kssl');
Crypto_DLL_Names: array[1..2] of AnsiString = ('kcrypt10', 'kcrypto');
{$ELSEIF DEFINED(OS2)}
SSL_DLL_Names: array[1..2] of string = ('emssl10', 'ssl');
Crypto_DLL_Names: array[1..2] of string = ('emcrpt10', 'crypto');
SSL_DLL_Names: array[1..2] of AnsiString = ('emssl10', 'ssl');
Crypto_DLL_Names: array[1..2] of AnsiString = ('emcrpt10', 'crypto');
{$ELSE}
BaseSSLName: string = 'libssl';
BaseCryptoName: string = 'libcrypto';
BaseSSLName: AnsiString = 'libssl';
BaseCryptoName: AnsiString = 'libcrypto';
{ ADD NEW ONES WHEN THEY APPEAR!
Always make .so/dylib first, then versions, in descending order!
Add "." .before the version, first is always just "" }
DLLVersions: array[1..20] of string = ('', '.3', '.1.1', '.11', '.10', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',
DLLVersions: array[1..20] of AnsiString = ('', '.3', '.1.1', '.11', '.10', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',
'.1.0.2', '.1.0.1','.1.0.0','.0.9.8',
'.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',
'.0.9.3', '.0.9.2', '.0.9.1');
LibreSSLVersions : Array[1..8] of string =
LibreSSLVersions : Array[1..8] of AnsiString =
('', '.48', '.47', '.46', '.45', '.44', '.43', '.35');
// Mac OS no longer allows you to load the unversioned one. Bug ID 36484.
@ -209,7 +210,7 @@ type
signature: pointer; // ^ASN1_BIT_STRING
valid: integer;
references: integer;
name: PChar;
name: PAnsiChar;
ex_data: CRYPTO_EX_DATA;
ex_pathlen: integer;
ex_flags: integer;
@ -218,7 +219,7 @@ type
ex_nscert: integer;
skid: pointer; // ^ASN1_OCTET_STRING
akid: pointer; // ?
sha1_hash: array [0..SHA_DIGEST_LENGTH-1] of char;
sha1_hash: array [0..SHA_DIGEST_LENGTH-1] of AnsiChar;
aux: pointer; // ^X509_CERT_AUX
end;
pX509 = ^X509;
@ -236,7 +237,7 @@ type
kinv: pointer;
r: pointer;
flags: integer;
method_mont_p: PChar;
method_mont_p: PAnsiChar;
references: integer;
ex_data: record
sk: pointer;
@ -248,7 +249,7 @@ type
EVP_PKEY_PKEY = record
case integer of
0: (ptr: PChar);
0: (ptr: PAnsiChar);
1: (rsa: pRSA);
2: (dsa: pDSA);
3: (dh: pDH);
@ -353,7 +354,7 @@ type
Trsa_keygen = function(arsa: PRSA; bits: cint; e: PBIGNUM; cb: PBN_GENCB): cint;
RSA_METHOD = record
name: PChar;
name: PAnsiChar;
rsa_pub_enc: Trsa_pub_enc;
rsa_pub_dec: Trsa_pub_dec;
rsa_priv_enc: Trsa_priv_enc;
@ -363,7 +364,7 @@ type
init: Tinit; { called at new }
finish: Tfinish; { called at free }
flags: cint; { RSA_METHOD_FLAG_* things }
app_data: PChar; { may be needed! }
app_data: PAnsiChar; { may be needed! }
{ New sign and verify functions: some libraries don't allow arbitrary data
* to be signed/verified: this allows them to be used. Note: for this to work
* the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
@ -567,7 +568,7 @@ type
_type : Pointer;
d : record
case longint of
0 : ( ptr : pchar );
0 : ( ptr : PAnsiChar );
1 : ( data : Pointer);
2 : ( sign : PPKCS7_SIGNED );
3 : ( enveloped : ^PKCS7_ENVELOPE );
@ -1065,17 +1066,17 @@ const
var
SSLLibHandle: TLibHandle = 0;
SSLUtilHandle: TLibHandle = 0;
SSLLibFile: string = '';
SSLUtilFile: string = '';
SSLLibFile: AnsiString = '';
SSLUtilFile: AnsiString = '';
// libssl.dll
function OpenSSLGetVersion(t: cint):String;
function OpenSSLGetVersion(t: cint):AnsiString;
function SslGetError(s: PSSL; ret_code: cInt):cInt;
Function OPENSSL_init_ssl(opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
function SslLibraryInit:cInt;
procedure SslLoadErrorStrings;
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):cInt;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):cInt;
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PAnsiChar):cInt;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):cInt;
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
procedure SslCtxFree(arg0: PSSL_CTX);
function SslSetFd(s: PSSL; fd: cInt):cInt;
@ -1096,21 +1097,21 @@ var
function SslMethodV23:PSSL_METHOD;
function SslTLSMethod:PSSL_METHOD;
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):cInt;
function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: String; len: cLong):cInt;overload;
function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: AnsiString; len: cLong):cInt;overload;
function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; b: TBytes; len: cLong):cInt;overload;
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: cInt):cInt;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: cInt):cInt;
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):cInt;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: String):cInt; overload;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: AnsiString):cInt; overload;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; Buf: TBytes):cInt; overload;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: cInt):cInt;
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):cInt;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):cInt;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PAnsiChar):cInt;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):cInt;
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):cInt;
procedure SslCtxSetDefaultPasswdCb(ctx: PSSL_CTX; cb: PPasswdCb);
procedure SslCtxSetDefaultPasswdCbUserdata(ctx: PSSL_CTX; u: SslPtr);
// function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):cInt;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):cInt;
// function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):cInt;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):cInt;
function SslNew(ctx: PSSL_CTX):PSSL;
procedure SslFree(ssl: PSSL);
function SslAccept(ssl: PSSL):cInt;
@ -1120,39 +1121,39 @@ var
function SslPeek(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
function SslWrite(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
function SslPending(ssl: PSSL):cInt;
function SslGetVersion(ssl: PSSL):String;
function SslGetVersion(ssl: PSSL):AnsiString;
function SslGetPeerCertificate(ssl: PSSL):PX509;
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: cInt; arg2: TSSLCTXVerifyCallback);
function SSLGetCurrentCipher(s: PSSL):SslPtr;
function SSLCipherGetName(c: SslPtr): String;
function SSLCipherGetName(c: SslPtr): AnsiString;
function SSLCipherGetBits(c: SslPtr; var alg_bits: cInt):cInt;
function SSLGetVerifyResult(ssl: PSSL):cLong;
function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): string;
function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): AnsiString;
procedure SslCtxCallbackCtrl(ssl: PSSL; _type: cInt; cb: PCallbackCb);
function SslSetSslCtx(ssl: PSSL; ctx: PSSL_CTX): PSSL;
// libeay.dll
function OPENSSL_INIT_new : POPENSSL_INIT_SETTINGS;
Procedure OPENSSL_INIT_free(aSettings : POPENSSL_INIT_SETTINGS);
function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : Pchar) : cint;
function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint;
Function OPENSSL_init_crypto ( opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint;
Procedure OPENSSL_cleanup;
procedure ERR_load_crypto_strings;
function X509New: PX509;
procedure X509Free(x: PX509);
function X509NameOneline(a: PX509_NAME; var buf: String; size: cInt):String;
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: cInt):AnsiString;
function X509GetSubjectName(a: PX509):PX509_NAME;
function X509GetIssuerName(a: PX509):PX509_NAME;
function X509NameHash(x: PX509_NAME):cuLong;
// function SslX509Digest(data: PX509; _type: PEVP_MD; md: PChar; len: PcInt):cInt;
function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: cInt):cInt;
// function SslX509Digest(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PcInt):cInt;
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: cInt):cInt;
function X509print(b: PBIO; a: PX509): cInt;
function X509SetVersion(x: PX509; version: cInt): cInt;
function X509SetPubkey(x: PX509; pkey: PEVP_PKEY): cInt;
function X509GetPubkey(x: PX509): PEVP_PKEY;
function X509SetIssuerName(x: PX509; name: PX509_NAME): cInt;
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: cInt;
bytes: string; len, loc, _set: cInt): cInt;
function X509NameAddEntryByTxt(name: PX509_NAME; field: AnsiString; _type: cInt;
bytes: AnsiString; len, loc, _set: cInt): cInt;
function X509Sign(x: PX509; pkey: PEVP_PKEY; const md: PEVP_MD): cInt;
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: cInt): PASN1_UTCTIME;
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): cInt;
@ -1161,17 +1162,17 @@ var
function EvpPkeyNew: PEVP_PKEY;
procedure EvpPkeyFree(pk: PEVP_PKEY);
function EvpPkeyAssign(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt;
function EvpGetDigestByName(Name: String): PEVP_MD;
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
procedure EVPcleanup;
function SSLeayversion(t: cInt): string; deprecated 'For 1.1+ use OpenSSLGetVersion';
procedure ErrErrorString(e: cInt; var buf: string; len: cInt);
function SSLeayversion(t: cInt): AnsiString; deprecated 'For 1.1+ use OpenSSLGetVersion';
procedure ErrErrorString(e: cInt; var buf: AnsiString; len: cInt);
function ErrGetError: cInt;
procedure ErrClearError;
procedure ErrFreeStrings;
procedure ErrRemoveState(pid: cInt);
procedure RandScreen; deprecated 'Deprecated as of 1.1+';
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr;
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): cInt;
function PKCS12parse(p12: SslPtr; pass: AnsiString; var pkey, cert, ca: SslPtr): cInt;
procedure PKCS12free(p12: SslPtr);
function Asn1StringTypeNew(aType : cint): PASN1_STRING;
Function Asn1UtctimePrint(b : PBio; a: PASN1_UTCTIME) : integer;
@ -1202,13 +1203,13 @@ var
function RAND_pseudo_bytes(buf: PByte; num: cint): cint;
procedure RAND_seed(const buf: Pointer; num: cint);
procedure RAND_add(const buf: Pointer; num: cint; entropy: cdouble);
function RAND_load_file(const file_name: PChar; max_bytes: clong): cint;
function RAND_write_file(const file_name: PChar): cint;
function RAND_file_name(file_name: PChar; num: csize_t): PChar;
function RAND_load_file(const file_name: PAnsiChar; max_bytes: clong): cint;
function RAND_write_file(const file_name: PAnsiChar): cint;
function RAND_file_name(file_name: PAnsiChar; num: csize_t): PAnsiChar;
function RAND_status: cint;
function RAND_query_egd_bytes(const path: PChar; buf: PByte; bytes: cint): cint;
function RAND_egd(const path: PChar): cint;
function RAND_egd_bytes(const path: PChar; bytes: cint): cint;
function RAND_query_egd_bytes(const path: PAnsiChar; buf: PByte; bytes: cint): cint;
function RAND_egd(const path: PAnsiChar): cint;
function RAND_egd_bytes(const path: PAnsiChar; bytes: cint): cint;
procedure ERR_load_RAND_strings;
function RAND_poll: cint;
@ -1253,11 +1254,11 @@ var
// ERR Functions
function Err_Error_String(e: cInt; buf: PChar): PChar;
function Err_Error_String(e: cInt; buf: PAnsiChar): PAnsiChar;
// Crypto Functions
function SSLeay_version(t: cint): PChar; deprecated 'For 1.1+ use OpenSSLGetVersion';
function SSLeay_version(t: cint): PAnsiChar; deprecated 'For 1.1+ use OpenSSLGetVersion';
// EVP Functions - evp.h
function EVP_des_ede3_cbc : PEVP_CIPHER;
@ -1293,8 +1294,8 @@ var
function EVP_VerifyFinal(ctx: pEVP_MD_CTX; sigbuf: pointer;
siglen: cardinal; pkey: pEVP_PKEY): integer;
//
function EVP_get_cipherbyname(const name: PChar): PEVP_CIPHER;
function EVP_get_digestbyname(const name: PChar): PEVP_MD;
function EVP_get_cipherbyname(const name: PAnsiChar): PEVP_CIPHER;
function EVP_get_digestbyname(const name: PAnsiChar): PEVP_MD;
//
procedure EVP_CIPHER_CTX_init(a: PEVP_CIPHER_CTX);
function EVP_CIPHER_CTX_cleanup(a: PEVP_CIPHER_CTX): cint;
@ -1332,7 +1333,7 @@ var
function PEM_read_bio_PUBKEY(bp: pBIO; var x: pEVP_PKEY;
cb: Ppem_password_cb; u: pointer): pEVP_PKEY;
function PEM_write_bio_PrivateKey(bp: pBIO; x: pEVP_PKEY;
const enc: pEVP_CIPHER; kstr: PChar; klen: Integer; cb: Ppem_password_cb;
const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
u: pointer): integer;
function PEM_write_bio_PUBKEY(bp: pBIO; x: pEVP_PKEY): integer;
function PEM_read_bio_X509(bp: PBIO; x: PPX509; cb: ppem_password_cb; u: pointer): PX509;
@ -1343,23 +1344,23 @@ var
procedure BioFreeAll(b: PBIO);
function BioSMem: PBIO_METHOD;
function BioCtrlPending(b: PBIO): cInt;
function BioRead(b: PBIO; var Buf: String; Len: cInt): cInt;
function BioRead(b: PBIO; var Buf: AnsiString; Len: cInt): cInt;
function BioRead(b: PBIO; Buf: TBytes; Len: cInt): cInt;
function BioWrite(b: PBIO; Buf: String; Len: cInt): cInt; overload;
function BioWrite(b: PBIO; Buf: AnsiString; Len: cInt): cInt; overload;
function BioWrite(b: PBIO; Buf: TBytes; Len: cInt): cInt; overload;
function BIO_ctrl(bp: PBIO; cmd: cint; larg: clong; parg: Pointer): clong;
function BIO_read_filename(b: PBIO; const name: PChar): cint;
function BIO_read_filename(b: PBIO; const name: PAnsiChar): cint;
function BIO_push(b: PBIO; append: PBIO): PBIO;
function BIO_pop(b: PBIO): PBIO;
function BIO_gets(b: PBIO; buf: PChar; size: cint): cint;
function BIO_puts(b: PBIO; const buf: PChar): cint;
function BIO_gets(b: PBIO; buf: PAnsiChar; size: cint): cint;
function BIO_puts(b: PBIO; const buf: PAnsiChar): cint;
procedure BIO_set_mem_eof_return(b: PBIO; v: cint);
procedure BIO_set_mem_buf(b: PBIO; bm: pointer; c: cint);
procedure BIO_get_mem_ptr(b: PBIO; var pp: pointer);
function BIO_s_file: pBIO_METHOD;
function BIO_new_file(const filename: PChar; const mode: PChar): pBIO;
function BIO_new_file(const filename: PAnsiChar; const mode: PAnsiChar): pBIO;
function BIO_new_mem_buf(buf: pointer; len: integer): pBIO;
procedure CRYPTOcleanupAllExData;
procedure OPENSSLaddallalgorithms;
@ -1389,7 +1390,7 @@ var
function PKCS7_new:PPKCS7;
procedure PKCS7_free(a:PPKCS7);
function PKCS7_print_ctx(_out:PBIO; x:PPKCS7; indent:longint; pctx:Pointer):longint;
function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:Pchar):longint;
function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;
function PKCS7_set_type(p7:PPKCS7; _type:longint):longint;
function PKCS7_set0_type_other(p7:PPKCS7; _type:longint; other:PASN1_TYPE):longint;
function PKCS7_set_content(p7:PPKCS7; p7_data:PPKCS7):longint;
@ -1483,7 +1484,7 @@ var
procedure BN_free(a:PBIGNUM);
function IsSSLloaded: Boolean;
function InitSSLInterface(Const aSSLName, acryptoName : String) : Boolean; overload;
function InitSSLInterface(Const aSSLName, acryptoName : AnsiString) : Boolean; overload;
function InitSSLInterface: Boolean; overload;
function DestroySSLInterface: Boolean;
@ -1497,7 +1498,7 @@ function DestroyLibeaInterface: Boolean; deprecated;
var
OpenSSL_unavailable_functions: string;
OpenSSL_unavailable_functions: AnsiString;
implementation
@ -1582,12 +1583,12 @@ type
TSslLibraryInit = function:cInt; cdecl;
TOPENSSL_INIT_new = function : POPENSSL_INIT_SETTINGS; cdecl;
TOPENSSL_INIT_free = procedure(settings : POPENSSL_INIT_SETTINGS); cdecl;
TOPENSSL_INIT_set_config_appname = function (settings:POPENSSL_INIT_SETTINGS; config_file : Pchar) : cint;
TOPENSSL_INIT_set_config_appname = function (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint;
TOPENSSL_init_ssl = function ( opts: uint64_t ; settings : POPENSSL_INIT_SETTINGS) : cint; cdecl;
TOPENSSL_cleanup = procedure; cdecl;
TSslLoadErrorStrings = procedure; cdecl;
TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PChar):cInt; cdecl;
TSslCtxSetCipherList = function(arg0: PSSL_CTX; str: PAnsiChar):cInt; cdecl;
TSslCtxNew = function(meth: PSSL_METHOD):PSSL_CTX; cdecl;
TSslCtxFree = procedure(arg0: PSSL_CTX); cdecl;
TSslSetFd = function(s: PSSL; fd: cInt):cInt; cdecl;
@ -1602,32 +1603,32 @@ type
TSslTLSMethod = function:PSSL_METHOD; cdecl;
TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):cInt; cdecl;
TSslCtxUsePrivateKeyASN1 = function(pk: cInt; ctx: PSSL_CTX; d: sslptr; len: cInt):cInt; cdecl;
TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PChar; _type: cInt):cInt; cdecl;
TSslCtxUsePrivateKeyFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt; cdecl;
TSslCtxUseCertificate = function(ctx: PSSL_CTX; x: SslPtr):cInt; cdecl;
TSslCtxUseCertificateASN1 = function(ctx: PSSL_CTX; len: cInt; d: SslPtr):cInt; cdecl;
TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PChar; _type: cInt):cInt; cdecl;
TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PChar):cInt; cdecl;
TSslCtxUseCertificateFile = function(ctx: PSSL_CTX; const _file: PAnsiChar; _type: cInt):cInt; cdecl;
TSslCtxUseCertificateChainFile = function(ctx: PSSL_CTX; const _file: PAnsiChar):cInt; cdecl;
TSslCtxCheckPrivateKeyFile = function(ctx: PSSL_CTX):cInt; cdecl;
TSslCtxSetDefaultPasswdCb = procedure(ctx: PSSL_CTX; cb: SslPtr); cdecl;
TSslCtxSetDefaultPasswdCbUserdata = procedure(ctx: PSSL_CTX; u: SslPtr); cdecl;
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PChar; const CApath: PChar):cInt; cdecl;
TSslCtxLoadVerifyLocations = function(ctx: PSSL_CTX; const CAfile: PAnsiChar; const CApath: PAnsiChar):cInt; cdecl;
TSslNew = function(ctx: PSSL_CTX):PSSL; cdecl;
TSslFree = procedure(ssl: PSSL); cdecl;
TSslAccept = function(ssl: PSSL):cInt; cdecl;
TSslConnect = function(ssl: PSSL):cInt; cdecl;
TSslShutdown = function(ssl: PSSL):cInt; cdecl;
TSslRead = function(ssl: PSSL; buf: PChar; num: cInt):cInt; cdecl;
TSslPeek = function(ssl: PSSL; buf: PChar; num: cInt):cInt; cdecl;
TSslWrite = function(ssl: PSSL; const buf: PChar; num: cInt):cInt; cdecl;
TSslRead = function(ssl: PSSL; buf: PAnsiChar; num: cInt):cInt; cdecl;
TSslPeek = function(ssl: PSSL; buf: PAnsiChar; num: cInt):cInt; cdecl;
TSslWrite = function(ssl: PSSL; const buf: PAnsiChar; num: cInt):cInt; cdecl;
TSslPending = function(ssl: PSSL):cInt; cdecl;
TSslGetVersion = function(ssl: PSSL):PChar; cdecl;
TSslGetVersion = function(ssl: PSSL):PAnsiChar; cdecl;
TSslGetPeerCertificate = function(ssl: PSSL):PX509; cdecl;
TSslCtxSetVerify = procedure(ctx: PSSL_CTX; mode: cInt; arg2: SslPtr); cdecl;
TSSLGetCurrentCipher = function(s: PSSL):SslPtr; cdecl;
TSSLCipherGetName = function(c: Sslptr):PChar; cdecl;
TSSLCipherGetName = function(c: Sslptr):PAnsiChar; cdecl;
TSSLCipherGetBits = function(c: SslPtr; alg_bits: PcInt):cInt; cdecl;
TSSLGetVerifyResult = function(ssl: PSSL):cInt; cdecl;
TSSLGetServername = function(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): PChar; cdecl;
TSSLGetServername = function(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): PAnsiChar; cdecl;
TSSLCtxCallbackCtrl = procedure(ctx: PSSL_CTX; _type: cInt; cb: PCallbackCb); cdecl;
TSSLSetSslCtx = function(ssl: PSSL; ctx: PSSL_CTX): PSSL; cdecl;
@ -1635,18 +1636,18 @@ type
TERR_load_crypto_strings = procedure; cdecl;
TX509New = function: PX509; cdecl;
TX509Free = procedure(x: PX509); cdecl;
TX509NameOneline = function(a: PX509_NAME; buf: PChar; size: cInt):PChar; cdecl;
TX509NameOneline = function(a: PX509_NAME; buf: PAnsiChar; size: cInt):PAnsiChar; cdecl;
TX509GetSubjectName = function(a: PX509):PX509_NAME; cdecl;
TX509GetIssuerName = function(a: PX509):PX509_NAME; cdecl;
TX509NameHash = function(x: PX509_NAME):cuLong; cdecl;
TX509Digest = function(data: PX509; _type: PEVP_MD; md: PChar; len: PcInt):cInt; cdecl;
TX509Digest = function(data: PX509; _type: PEVP_MD; md: PAnsiChar; len: PcInt):cInt; cdecl;
TX509print = function(b: PBIO; a: PX509): cInt; cdecl;
TX509SetVersion = function(x: PX509; version: cInt): cInt; cdecl;
TX509SetPubkey = function(x: PX509; pkey: PEVP_PKEY): cInt; cdecl;
TX509GetPubkey = function(x: PX509): PEVP_PKEY; cdecl;
TX509SetIssuerName = function(x: PX509; name: PX509_NAME): cInt; cdecl;
TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PChar; _type: cInt;
bytes: PChar; len, loc, _set: cInt): cInt; cdecl;
TX509NameAddEntryByTxt = function(name: PX509_NAME; field: PAnsiChar; _type: cInt;
bytes: PAnsiChar; len, loc, _set: cInt): cInt; cdecl;
TX509Sign = function(x: PX509; pkey: PEVP_PKEY; const md: PEVP_MD): cInt; cdecl;
TX509GmtimeAdj = function(s: PASN1_UTCTIME; adj: cInt): PASN1_UTCTIME; cdecl;
TX509SetNotBefore = function(x: PX509; tm: PASN1_UTCTIME): cInt; cdecl;
@ -1655,11 +1656,11 @@ type
TEvpPkeyNew = function: PEVP_PKEY; cdecl;
TEvpPkeyFree = procedure(pk: PEVP_PKEY); cdecl;
TEvpPkeyAssign = function(pkey: PEVP_PKEY; _type: cInt; key: Prsa): cInt; cdecl;
TEvpGetDigestByName = function(Name: PChar): PEVP_MD; cdecl;
TEvpGetDigestByName = function(Name: PAnsiChar): PEVP_MD; cdecl;
TEVPcleanup = procedure; cdecl;
TOpenSSLversion = function (arg : cint) : pchar; cdecl;
TSSLeayversion = function(t: cInt): PChar; cdecl;
TErrErrorString = procedure(e: cInt; buf: PChar; len: cInt); cdecl;
TOpenSSLversion = function (arg : cint) : PAnsiChar; cdecl;
TSSLeayversion = function(t: cInt): PAnsiChar; cdecl;
TErrErrorString = procedure(e: cInt; buf: PAnsiChar; len: cInt); cdecl;
TErrGetError = function: cInt; cdecl;
TErrClearError = procedure; cdecl;
TErrFreeStrings = procedure; cdecl;
@ -1669,10 +1670,10 @@ type
TBioFreeAll = procedure(b: PBIO); cdecl;
TBioSMem = function: PBIO_METHOD; cdecl;
TBioCtrlPending = function(b: PBIO): cInt; cdecl;
TBioRead = function(b: PBIO; Buf: PChar; Len: cInt): cInt; cdecl;
TBioWrite = function(b: PBIO; Buf: PChar; Len: cInt): cInt; cdecl;
TBioRead = function(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt; cdecl;
TBioWrite = function(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt; cdecl;
Td2iPKCS12bio = function(b:PBIO; Pkcs12: SslPtr): SslPtr; cdecl;
TPKCS12parse = function(p12: SslPtr; pass: PChar; var pkey, cert, ca: SslPtr): cInt; cdecl;
TPKCS12parse = function(p12: SslPtr; pass: PAnsiChar; var pkey, cert, ca: SslPtr): cInt; cdecl;
TPKCS12free = procedure(p12: SslPtr); cdecl;
TAsn1StringTypeNew = function(aype : cint): SSlPtr; cdecl;
TAsn1UtcTimeSetString = function(t : PASN1_UTCTIME; S : PAnsiChar): cint; cdecl;
@ -1704,13 +1705,13 @@ type
TRAND_pseudo_bytes = function(buf: PByte; num: cint): cint; cdecl;
TRAND_seed = procedure(const buf: Pointer; num: cint); cdecl;
TRAND_add = procedure(const buf: Pointer; num: cint; entropy: cdouble); cdecl;
TRAND_load_file = function(const file_name: PChar; max_bytes: clong): cint; cdecl;
TRAND_write_file = function(const file_name: PChar): cint; cdecl;
TRAND_file_name = function(file_name: PChar; num: csize_t): PChar; cdecl;
TRAND_load_file = function(const file_name: PAnsiChar; max_bytes: clong): cint; cdecl;
TRAND_write_file = function(const file_name: PAnsiChar): cint; cdecl;
TRAND_file_name = function(file_name: PAnsiChar; num: csize_t): PAnsiChar; cdecl;
TRAND_status = function(): cint; cdecl;
TRAND_query_egd_bytes = function(const path: PChar; buf: PByte; bytes: cint): cint; cdecl;
TRAND_egd = function(const path: PChar): cint; cdecl;
TRAND_egd_bytes = function(const path: PChar; bytes: cint): cint; cdecl;
TRAND_query_egd_bytes = function(const path: PAnsiChar; buf: PByte; bytes: cint): cint; cdecl;
TRAND_egd = function(const path: PAnsiChar): cint; cdecl;
TRAND_egd_bytes = function(const path: PAnsiChar; bytes: cint): cint; cdecl;
TERR_load_RAND_strings = procedure(); cdecl;
TRAND_poll = function(): cint; cdecl;
@ -1742,7 +1743,7 @@ type
// ERR Functions
TErr_Error_String = function (e: cInt; buf: PChar): PChar; cdecl;
TErr_Error_String = function (e: cInt; buf: PAnsiChar): PAnsiChar; cdecl;
// Crypto Functions
@ -1767,8 +1768,8 @@ type
siglen: cardinal; pkey: pEVP_PKEY): integer; cdecl;
//
TEVP_CIPHERFunction = function() : PEVP_CIPHER; cdecl;
TEVP_get_cipherbyname = function(const name: PChar): PEVP_CIPHER; cdecl;
TEVP_get_digestbyname = function(const name: PChar): PEVP_MD; cdecl;
TEVP_get_cipherbyname = function(const name: PAnsiChar): PEVP_CIPHER; cdecl;
TEVP_get_digestbyname = function(const name: PAnsiChar): PEVP_MD; cdecl;
//
TEVP_CIPHER_CTX_init = procedure(a: PEVP_CIPHER_CTX); cdecl;
TEVP_CIPHER_CTX_cleanup = function(a: PEVP_CIPHER_CTX): cint; cdecl;
@ -1801,7 +1802,7 @@ type
TPEM_read_bio_PUBKEY = function(bp: pBIO; var x: pEVP_PKEY;
cb: Ppem_password_cb; u: pointer): pEVP_PKEY; cdecl;
TPEM_write_bio_PrivateKey = function(bp: pBIO; x: pEVP_PKEY;
const enc: pEVP_CIPHER; kstr: PChar; klen: Integer; cb: Ppem_password_cb;
const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
u: pointer): integer; cdecl;
TPEM_write_bio_PUBKEY = function(bp: pBIO; x: pEVP_PKEY): integer; cdecl;
TPEM_read_bio_X509 = function(bp: pBIO; x: PPX509; cb: Ppem_password_cb; u: pointer): px509; cdecl;
@ -1814,14 +1815,14 @@ type
TBIO_push = function(b: PBIO; append: PBIO): PBIO;cdecl;
TBIO_pop = function(b: PBIO): PBIO;cdecl;
TBIO_gets = function(b: PBIO; buf: PChar; size: cint): cint;cdecl;
TBIO_puts = function(b: PBIO; const buf: PChar): cint;cdecl;
TBIO_gets = function(b: PBIO; buf: PAnsiChar; size: cint): cint;cdecl;
TBIO_puts = function(b: PBIO; const buf: PAnsiChar): cint;cdecl;
TBIO_set_mem_eof_return = procedure(b: PBIO; v: cint);cdecl;
TBIO_set_mem_buf = procedure(b: PBIO; bm: pointer; c: cint);cdecl;
TBIO_get_mem_ptr = procedure (b: PBIO; var pp: pointer);cdecl;
TBIO_s_file = function: pBIO_METHOD; cdecl;
TBIO_new_file = function(const filename: PChar; const mode: PChar): pBIO; cdecl;
TBIO_new_file = function(const filename: PAnsiChar; const mode: PAnsiChar): pBIO; cdecl;
TBIO_new_mem_buf = function(buf: pointer; len: integer): pBIO; cdecl;
var
@ -2115,7 +2116,7 @@ var
_PKCS7_new : function:PPKCS7;cdecl;
_PKCS7_free : procedure(a:PPKCS7);cdecl;
_PKCS7_print_ctx : function(_out:PBIO; x:PPKCS7; indent:longint; pctx:Pointer):longint;cdecl;
_PKCS7_ctrl : function(p7:PPKCS7; cmd:longint; larg:longint; parg:Pchar):longint;cdecl;
_PKCS7_ctrl : function(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;cdecl;
_PKCS7_set_type : function(p7:PPKCS7; _type:longint):longint;cdecl;
_PKCS7_set0_type_other : function(p7:PPKCS7; _type:longint; other:PASN1_TYPE):longint;cdecl;
_PKCS7_set_content : function(p7:PPKCS7; p7_data:PPKCS7):longint;cdecl;
@ -2237,10 +2238,10 @@ begin
_OpenSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS or OPENSSL_INIT_LOAD_CRYPTO_STRINGS,Nil)
end;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):cInt;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: AnsiString):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxSetCipherList) then
Result := _SslCtxSetCipherList(arg0, PChar(str))
Result := _SslCtxSetCipherList(arg0, PAnsiChar(str))
else
Result := 0;
end;
@ -2368,7 +2369,7 @@ begin
Result := 0;
end;
function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: String; len: cLong):cInt; overload;
function SslCtxUsePrivateKeyASN1(pk: cInt; ctx: PSSL_CTX; d: AnsiString; len: cLong):cInt; overload;
begin
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyASN1) then
Result := _SslCtxUsePrivateKeyASN1(pk, ctx, Sslptr(d), len)
@ -2384,10 +2385,10 @@ begin
Result := 0;
end;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: cInt):cInt;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxUsePrivateKeyFile) then
Result := _SslCtxUsePrivateKeyFile(ctx, PChar(_file), _type)
Result := _SslCtxUsePrivateKeyFile(ctx, PAnsiChar(_file), _type)
else
Result := 0;
end;
@ -2400,7 +2401,7 @@ begin
Result := 0;
end;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: String):cInt;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: cLong; d: AnsiString):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateASN1) then
Result := _SslCtxUseCertificateASN1(ctx, len, SslPtr(d))
@ -2416,18 +2417,18 @@ begin
Result := 0;
end;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: cInt):cInt;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: AnsiString; _type: cInt):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateFile) then
Result := _SslCtxUseCertificateFile(ctx, PChar(_file), _type)
Result := _SslCtxUseCertificateFile(ctx, PAnsiChar(_file), _type)
else
Result := 0;
end;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):cInt;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: AnsiString):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxUseCertificateChainFile) then
Result := _SslCtxUseCertificateChainFile(ctx, PChar(_file))
Result := _SslCtxUseCertificateChainFile(ctx, PAnsiChar(_file))
else
Result := 0;
end;
@ -2452,7 +2453,7 @@ begin
_SslCtxSetDefaultPasswdCbUserdata(ctx, u);
end;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):cInt;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: AnsiString; const CApath: AnsiString):cInt;
begin
if InitSSLInterface and Assigned(_SslCtxLoadVerifyLocations) then
Result := _SslCtxLoadVerifyLocations(ctx, SslPtr(CAfile), SslPtr(CApath))
@ -2501,7 +2502,7 @@ end;
function SslRead(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
begin
if InitSSLInterface and Assigned(_SslRead) then
Result := _SslRead(ssl, PChar(buf), num)
Result := _SslRead(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
@ -2509,7 +2510,7 @@ end;
function SslPeek(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
begin
if InitSSLInterface and Assigned(_SslPeek) then
Result := _SslPeek(ssl, PChar(buf), num)
Result := _SslPeek(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
@ -2517,7 +2518,7 @@ end;
function SslWrite(ssl: PSSL; buf: SslPtr; num: cInt):cInt;
begin
if InitSSLInterface and Assigned(_SslWrite) then
Result := _SslWrite(ssl, PChar(buf), num)
Result := _SslWrite(ssl, PAnsiChar(buf), num)
else
Result := -1;
end;
@ -2530,7 +2531,7 @@ begin
Result := 0;
end;
function OpenSSLGetVersion(t: cint):String;
function OpenSSLGetVersion(t: cint):AnsiString;
begin
if InitSSLInterface and Assigned(_OpenSSLVersion) then
Result := _OpenSSLVersion(t)
@ -2538,8 +2539,8 @@ begin
Result := '';
end;
//function SslGetVersion(ssl: PSSL):PChar;
function SslGetVersion(ssl: PSSL):String;
//function SslGetVersion(ssl: PSSL):PAnsiChar;
function SslGetVersion(ssl: PSSL):AnsiString;
begin
if InitSSLInterface and Assigned(_SslGetVersion) then
Result := _SslGetVersion(ssl)
@ -2572,7 +2573,7 @@ begin
Result := nil;
end;
function SSLCipherGetName(c: SslPtr):String;
function SSLCipherGetName(c: SslPtr):AnsiString;
begin
if InitSSLInterface and Assigned(_SSLCipherGetName) then
Result := _SSLCipherGetName(c)
@ -2596,10 +2597,10 @@ begin
Result := X509_V_ERR_APPLICATION_VERIFICATION;
end;
function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): string;
function SSLGetServername(ssl: PSSL; _type: cInt = TLSEXT_NAMETYPE_host_name): AnsiString;
begin
if InitSSLInterface and Assigned(_SSLGetServername) then
result := PChar(_SSLGetServername(ssl, _type))
result := PAnsiChar(_SSLGetServername(ssl, _type))
else
result := '';
end;
@ -2619,10 +2620,10 @@ begin
end;
// libeay.dll
function SSLeayversion(t: cInt): string;
function SSLeayversion(t: cInt): AnsiString;
begin
if InitSSLInterface and Assigned(_SSLeayversion) then
Result := PChar(_SSLeayversion(t))
Result := PAnsiChar(_SSLeayversion(t))
else
Result := '';
end;
@ -2650,7 +2651,7 @@ begin
_OPENSSL_INIT_free(aSettings);
end;
function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : Pchar) : cint;
function OPENSSL_INIT_set_config_appname (settings:POPENSSL_INIT_SETTINGS; config_file : PAnsiChar) : cint;
begin
if InitsslInterface and assigned(_OPENSSL_INIT_set_config_appname) then
@ -2690,10 +2691,10 @@ begin
_X509Free(x);
end;
function X509NameOneline(a: PX509_NAME; var buf: String; size: cInt):String;
function X509NameOneline(a: PX509_NAME; var buf: AnsiString; size: cInt):AnsiString;
begin
if InitSSLInterface and Assigned(_X509NameOneline) then
Result := _X509NameOneline(a, PChar(buf),size)
Result := _X509NameOneline(a, PAnsiChar(buf),size)
else
Result := '';
end;
@ -2722,10 +2723,10 @@ begin
Result := 0;
end;
function X509Digest(data: PX509; _type: PEVP_MD; md: String; var len: cInt):cInt;
function X509Digest(data: PX509; _type: PEVP_MD; md: AnsiString; var len: cInt):cInt;
begin
if InitSSLInterface and Assigned(_X509Digest) then
Result := _X509Digest(data, _type, PChar(md), @len)
Result := _X509Digest(data, _type, PAnsiChar(md), @len)
else
Result := 0;
end;
@ -2744,13 +2745,13 @@ begin
_EvpPkeyFree(pk);
end;
procedure ErrErrorString(e: cInt; var buf: string; len: cInt);
procedure ErrErrorString(e: cInt; var buf: AnsiString; len: cInt);
begin
if InitSSLInterface and Assigned(_ErrErrorString) then
_ErrErrorString(e, @buf[1], len)
else
buf := SFailedToLoadOpenSSL;
buf := PChar(Buf);
buf := PAnsiChar(Buf);
end;
function ErrGetError: cInt;
@ -2825,24 +2826,24 @@ end;
function BioRead(b: PBIO; Buf: TBytes; Len: cInt): cInt;
begin
if InitSSLInterface and Assigned(_BioRead) then
Result := _BioRead(b, PChar(Buf), Len)
Result := _BioRead(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
function BioRead(b: PBIO; var Buf: String; Len: cInt): cInt;
function BioRead(b: PBIO; var Buf: AnsiString; Len: cInt): cInt;
begin
if InitSSLInterface and Assigned(_BioRead) then
Result := _BioRead(b, PChar(Buf), Len)
Result := _BioRead(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
//function BioWrite(b: PBIO; Buf: PChar; Len: cInt): cInt;
function BioWrite(b: PBIO; Buf: String; Len: cInt): cInt;
//function BioWrite(b: PBIO; Buf: PAnsiChar; Len: cInt): cInt;
function BioWrite(b: PBIO; Buf: AnsiString; Len: cInt): cInt;
begin
if InitSSLInterface and Assigned(_BioWrite) then
Result := _BioWrite(b, PChar(Buf), Len)
Result := _BioWrite(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
@ -2851,7 +2852,7 @@ function BioWrite(b: PBIO; Buf: TBytes; Len: cInt): cInt;
begin
if InitSSLInterface and Assigned(_BioWrite) then
Result := _BioWrite(b, PChar(Buf), Len)
Result := _BioWrite(b, PAnsiChar(Buf), Len)
else
Result := -2;
end;
@ -2873,7 +2874,7 @@ begin
Result := nil;
end;
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): cInt;
function PKCS12parse(p12: SslPtr; pass: AnsiString; var pkey, cert, ca: SslPtr): cInt;
begin
if InitSSLInterface and Assigned(_PKCS12parse) then
Result := _PKCS12parse(p12, SslPtr(pass), pkey, cert, ca)
@ -2928,11 +2929,11 @@ begin
Result := 0;
end;
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: cInt;
bytes: string; len, loc, _set: cInt): cInt;
function X509NameAddEntryByTxt(name: PX509_NAME; field: AnsiString; _type: cInt;
bytes: AnsiString; len, loc, _set: cInt): cInt;
begin
if InitSSLInterface and Assigned(_X509NameAddEntryByTxt) then
Result := _X509NameAddEntryByTxt(name, PChar(field), _type, PChar(Bytes), len, loc, _set)
Result := _X509NameAddEntryByTxt(name, PAnsiChar(field), _type, PAnsiChar(Bytes), len, loc, _set)
else
Result := 0;
end;
@ -3059,10 +3060,11 @@ begin
_SkX509PopFree(st,_X509Free);
end;
function EvpGetDigestByName(Name: String): PEVP_MD;
function EvpGetDigestByName(Name: AnsiString): PEVP_MD;
begin
if InitSSLInterface and Assigned(_EvpGetDigestByName) then
Result := _EvpGetDigestByName(PChar(Name))
Result := _EvpGetDigestByName(PAnsiChar(Name))
else
Result := nil;
end;
@ -3163,7 +3165,7 @@ begin
_RAND_add(buf, num, entropy);
end;
function RAND_load_file(const file_name: PChar; max_bytes: clong): cint;
function RAND_load_file(const file_name: PAnsiChar; max_bytes: clong): cint;
begin
if InitSSLInterface and Assigned(_RAND_load_file) then
Result := _RAND_load_file(file_name, max_bytes)
@ -3171,7 +3173,7 @@ begin
Result := -1;
end;
function RAND_write_file(const file_name: PChar): cint;
function RAND_write_file(const file_name: PAnsiChar): cint;
begin
if InitSSLInterface and Assigned(_RAND_write_file) then
Result := _RAND_write_file(file_name)
@ -3179,7 +3181,7 @@ begin
Result := -1;
end;
function RAND_file_name(file_name: PChar; num: csize_t): PChar;
function RAND_file_name(file_name: PAnsiChar; num: csize_t): PAnsiChar;
begin
if InitSSLInterface and Assigned(_RAND_file_name) then
Result := _RAND_file_name(file_name, num)
@ -3195,7 +3197,7 @@ begin
Result := -1;
end;
function RAND_query_egd_bytes(const path: PChar; buf: PByte; bytes: cint): cint;
function RAND_query_egd_bytes(const path: PAnsiChar; buf: PByte; bytes: cint): cint;
begin
if InitSSLInterface and Assigned(_RAND_query_egd_bytes) then
Result := _RAND_query_egd_bytes(path, buf, bytes)
@ -3203,7 +3205,7 @@ begin
Result := -1;
end;
function RAND_egd(const path: PChar): cint;
function RAND_egd(const path: PAnsiChar): cint;
begin
if InitSSLInterface and Assigned(_RAND_egd) then
Result := _RAND_egd(path)
@ -3211,7 +3213,7 @@ begin
Result := -1;
end;
function RAND_egd_bytes(const path: PChar; bytes: cint): cint;
function RAND_egd_bytes(const path: PAnsiChar; bytes: cint): cint;
begin
if InitSSLInterface and Assigned(_RAND_egd_bytes) then
Result := _RAND_egd_bytes(path, bytes)
@ -3409,7 +3411,7 @@ end;
// ERR Functions
function Err_Error_String(e: cInt; buf: PChar): PChar;
function Err_Error_String(e: cInt; buf: PAnsiChar): PAnsiChar;
begin
if InitSSLInterface and Assigned(_Err_Error_String) then
Result := _Err_Error_String(e, buf)
@ -3419,7 +3421,7 @@ end;
// Crypto Functions
function SSLeay_version(t: cint): PChar;
function SSLeay_version(t: cint): PAnsiChar;
begin
if InitSSLInterface and Assigned(_SSLeayversion) then
Result := _SSLeayversion(t)
@ -3660,7 +3662,7 @@ end;
//
function EVP_get_cipherbyname(const name: PChar): PEVP_CIPHER;
function EVP_get_cipherbyname(const name: PAnsiChar): PEVP_CIPHER;
begin
if InitSSLInterface and Assigned(_EVP_get_cipherbyname) then
Result := _EVP_get_cipherbyname(name)
@ -3668,7 +3670,7 @@ begin
Result := nil;
end;
function EVP_get_digestbyname(const name: PChar): PEVP_MD;
function EVP_get_digestbyname(const name: PAnsiChar): PEVP_MD;
begin
if InitSSLInterface and Assigned(_EVP_get_digestbyname) then
Result := _EVP_get_digestbyname(name)
@ -3854,7 +3856,7 @@ begin
end;
function PEM_write_bio_PrivateKey(bp: pBIO; x: pEVP_PKEY;
const enc: pEVP_CIPHER; kstr: PChar; klen: Integer; cb: Ppem_password_cb;
const enc: pEVP_CIPHER; kstr: PAnsiChar; klen: Integer; cb: Ppem_password_cb;
u: pointer): integer;
Begin
if InitSSLInterface and Assigned(_PEM_write_bio_PrivateKey) then
@ -3923,7 +3925,7 @@ begin
Result := nil;
end;
function BIO_gets(b: PBIO; buf: PChar; size: cint): cint;
function BIO_gets(b: PBIO; buf: PAnsiChar; size: cint): cint;
begin
if InitSSLInterface and Assigned(_BIO_gets) then
Result := _BIO_gets(b,buf,size)
@ -3931,7 +3933,7 @@ begin
Result := -1;
end;
function BIO_puts(b: PBIO; const buf: PChar): cint;
function BIO_puts(b: PBIO; const buf: PAnsiChar): cint;
begin
if InitSSLInterface and Assigned(_BIO_puts) then
Result := _BIO_puts(b,buf)
@ -3957,7 +3959,7 @@ begin
_BIO_get_mem_ptr(b,pp);
end;
function BIO_read_filename(b: PBIO; const name: PChar): cint;
function BIO_read_filename(b: PBIO; const name: PAnsiChar): cint;
begin
Result := BIO_ctrl(b, BIO_C_SET_FILENAME, BIO_CLOSE or BIO_FP_READ, name);
end;
@ -3970,7 +3972,7 @@ begin
Result := nil;
end;
function BIO_new_file(const filename: PChar; const mode: PChar): pBIO;
function BIO_new_file(const filename: PAnsiChar; const mode: PAnsiChar): pBIO;
begin
if InitSSLInterface and Assigned(_BIO_new_file) then
Result := _BIO_new_file(filename, mode)
@ -4191,7 +4193,7 @@ begin
Result:=-1;
end;
function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:Pchar):longint;
function PKCS7_ctrl(p7:PPKCS7; cmd:longint; larg:longint; parg:PAnsiChar):longint;
begin
if InitSSLInterface and Assigned(_PKCS7_ctrl) then
@ -4893,7 +4895,7 @@ begin
_OPENSSLaddallalgorithms;
end;
Function CheckOK(ProcName : string ) : string;
Function CheckOK(ProcName : AnsiString ) : AnsiString;
begin
@ -4940,9 +4942,9 @@ begin
Result:=Result+' (method not supported by lib)';
end;
function GetProcAddr(module: HModule; const ProcName: string): SslPtr;
function GetProcAddr(module: HModule; const ProcName: AnsiString): SslPtr;
begin
Result := GetProcAddress(module, PChar(ProcName));
Result := GetProcAddress(module, PAnsiChar(ProcName));
if LoadVerbose and (Result = nil) then
OpenSSL_unavailable_functions := OpenSSL_unavailable_functions + CheckOK(ProcName) + LineEnding;
end;
@ -5650,7 +5652,7 @@ begin
_BIO_new_mem_buf := nil;
end;
procedure locking_callback(mode, ltype: integer; lfile: PChar; line: integer); cdecl;
procedure locking_callback(mode, ltype: integer; lfile: PAnsiChar; line: integer); cdecl;
begin
if (mode and 1) > 0 then
EnterCriticalSection(Locks[ltype])
@ -5701,7 +5703,7 @@ begin
end;
end;
function TryLoadLibPair(const SSL_DLL_Name, Crypto_DLL_Name: string):boolean;
function TryLoadLibPair(const SSL_DLL_Name, Crypto_DLL_Name: AnsiString):boolean;
begin
Assert((SSLUtilHandle = 0) and (SSLLibHandle = 0),
'LoadTryLoadLibPair: Handle is not zero');
@ -5714,7 +5716,7 @@ begin
if not Result then UnloadLibraries;
end;
Function MakeLibName(Const aBase,aVersion : String) : string;
Function MakeLibName(Const aBase,aVersion : AnsiString) : AnsiString;
begin
{$IF DEFINED(WINDOWS) OR DEFINED(OS2)}
@ -5760,7 +5762,7 @@ begin
end;
{$ENDIF}
Function LoadLibraries(Const aSSLName, aCryptoName : String) : Boolean;
Function LoadLibraries(Const aSSLName, aCryptoName : AnsiString) : Boolean;
var
Idx: Integer;
@ -5794,7 +5796,7 @@ begin
Result:=InitSSLInterface('','');
end;
function InitSSLInterface(Const aSSLName, acryptoName : String) : Boolean;
function InitSSLInterface(Const aSSLName, acryptoName : AnsiString) : Boolean;
begin
Result:=SSLLoaded;