📄 ssl_openssl_lib.pas
字号:
EntryPoint = 'SSL_read')]
function SslRead(ssl: PSSL; buf: StringBuilder; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_peek')]
function SslPeek(ssl: PSSL; buf: StringBuilder; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_write')]
function SslWrite(ssl: PSSL; buf: String; num: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_pending')]
function SslPending(ssl: PSSL):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_version')]
function SslGetVersion(ssl: PSSL):String; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_peer_certificate')]
function SslGetPeerCertificate(s: PSSL):PX509; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CTX_set_verify')]
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction); external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_current_cipher')]
function SSLGetCurrentCipher(s: PSSL): SslPtr; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CIPHER_get_name')]
function SSLCipherGetName(c: SslPtr):String; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_CIPHER_get_bits')]
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer; external;
[DllImport(DLLSSLName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSL_get_verify_result')]
function SSLGetVerifyResult(ssl: PSSL):Integer;external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_new')]
function X509New: PX509; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_free')]
procedure X509Free(x: PX509); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_oneline')]
function X509NameOneline(a: PX509_NAME; buf: StringBuilder; size: Integer): String; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_subject_name')]
function X509GetSubjectName(a: PX509):PX509_NAME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_issuer_name')]
function X509GetIssuerName(a: PX509):PX509_NAME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_hash')]
function X509NameHash(x: PX509_NAME):Cardinal; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_digest')]
function X509Digest (data: PX509; _type: PEVP_MD; md: StringBuilder; var len: Integer):Integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_version')]
function X509SetVersion(x: PX509; version: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_pubkey')]
function X509SetPubkey(x: PX509; pkey: EVP_PKEY): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_issuer_name')]
function X509SetIssuerName(x: PX509; name: PX509_NAME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_NAME_add_entry_by_txt')]
function X509NameAddEntryByTxt(name: PX509_NAME; field: string; _type: integer;
bytes: string; len, loc, _set: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_sign')]
function X509Sign(x: PX509; pkey: EVP_PKEY; const md: PEVP_MD): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_print')]
function X509print(b: PBIO; a: PX509): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_gmtime_adj')]
function X509GmtimeAdj(s: PASN1_UTCTIME; adj: integer): PASN1_UTCTIME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_notBefore')]
function X509SetNotBefore(x: PX509; tm: PASN1_UTCTIME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_set_notAfter')]
function X509SetNotAfter(x: PX509; tm: PASN1_UTCTIME): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'X509_get_serialNumber')]
function X509GetSerialNumber(x: PX509): PASN1_INTEGER; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_new')]
function EvpPkeyNew: EVP_PKEY; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_free')]
procedure EvpPkeyFree(pk: EVP_PKEY); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_PKEY_assign')]
function EvpPkeyAssign(pkey: EVP_PKEY; _type: integer; key: Prsa): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_get_digestbyname')]
function EvpGetDigestByName(Name: String): PEVP_MD; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'EVP_cleanup')]
procedure EVPcleanup; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'SSLeay_version')]
function SSLeayversion(t: integer): String; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_error_string_n')]
procedure ErrErrorString(e: integer; buf: StringBuilder; len: integer); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_get_error')]
function ErrGetError: integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_clear_error')]
procedure ErrClearError; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_free_strings')]
procedure ErrFreeStrings; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ERR_remove_state')]
procedure ErrRemoveState(pid: integer); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'OPENSSL_add_all_algorithms_noconf')]
procedure OPENSSLaddallalgorithms; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'CRYPTO_cleanup_all_ex_data')]
procedure CRYPTOcleanupAllExData; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'RAND_screen')]
procedure RandScreen; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_new')]
function BioNew(b: PBIO_METHOD): PBIO; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_free_all')]
procedure BioFreeAll(b: PBIO); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_s_mem')]
function BioSMem: PBIO_METHOD; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_ctrl_pending')]
function BioCtrlPending(b: PBIO): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_read')]
function BioRead(b: PBIO; Buf: StringBuilder; Len: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'BIO_write')]
function BioWrite(b: PBIO; var Buf: String; Len: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'd2i_PKCS12_bio')]
function d2iPKCS12bio(b:PBIO; Pkcs12: SslPtr): SslPtr; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'PKCS12_parse')]
function PKCS12parse(p12: SslPtr; pass: string; var pkey, cert, ca: SslPtr): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'PKCS12_free')]
procedure PKCS12free(p12: SslPtr); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'RSA_generate_key')]
function RsaGenerateKey(bits, e: integer; callback: PFunction; cb_arg: SslPtr): PRSA; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_UTCTIME_new')]
function Asn1UtctimeNew: PASN1_UTCTIME; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_UTCTIME_free')]
procedure Asn1UtctimeFree(a: PASN1_UTCTIME); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'ASN1_INTEGER_set')]
function Asn1IntegerSet(a: PASN1_INTEGER; v: integer): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'i2d_X509_bio')]
function i2dX509bio(b: PBIO; x: PX509): integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'i2d_PrivateKey_bio')]
function i2dPrivateKeyBio(b: PBIO; pkey: EVP_PKEY): integer; external;
// 3DES functions
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_set_odd_parity')]
procedure DESsetoddparity(Key: des_cblock); external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_set_key_checked')]
function DESsetkeychecked(key: des_cblock; schedule: des_key_schedule): Integer; external;
[DllImport(DLLUtilName, CharSet = CharSet.Ansi,
SetLastError = False, CallingConvention= CallingConvention.cdecl,
EntryPoint = 'DES_ecb_encrypt')]
procedure DESecbencrypt(Input: des_cblock; output: des_cblock; ks: des_key_schedule; enc: Integer); external;
{$ELSE}
// libssl.dll
function SslGetError(s: PSSL; ret_code: Integer):Integer;
function SslLibraryInit:Integer;
procedure SslLoadErrorStrings;
// function SslCtxSetCipherList(arg0: PSSL_CTX; str: PChar):Integer;
function SslCtxSetCipherList(arg0: PSSL_CTX; var str: String):Integer;
function SslCtxNew(meth: PSSL_METHOD):PSSL_CTX;
procedure SslCtxFree(arg0: PSSL_CTX);
function SslSetFd(s: PSSL; fd: Integer):Integer;
function SslMethodV2:PSSL_METHOD;
function SslMethodV3:PSSL_METHOD;
function SslMethodTLSV1:PSSL_METHOD;
function SslMethodV23:PSSL_METHOD;
function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer;
function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: String; len: integer):Integer;
// function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: PChar; _type: Integer):Integer;
function SslCtxUsePrivateKeyFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
function SslCtxUseCertificate(ctx: PSSL_CTX; x: SslPtr):Integer;
function SslCtxUseCertificateASN1(ctx: PSSL_CTX; len: integer; d: String):Integer;
function SslCtxUseCertificateFile(ctx: PSSL_CTX; const _file: String; _type: Integer):Integer;
// function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: PChar):Integer;
function SslCtxUseCertificateChainFile(ctx: PSSL_CTX; const _file: String):Integer;
function SslCtxCheckPrivateKeyFile(ctx: PSSL_CTX):Integer;
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):Integer;
function SslCtxLoadVerifyLocations(ctx: PSSL_CTX; const CAfile: String; const CApath: String):Integer;
function SslNew(ctx: PSSL_CTX):PSSL;
procedure SslFree(ssl: PSSL);
function SslAccept(ssl: PSSL):Integer;
function SslConnect(ssl: PSSL):Integer;
function SslShutdown(ssl: PSSL):Integer;
function SslRead(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslPeek(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslWrite(ssl: PSSL; buf: SslPtr; num: Integer):Integer;
function SslPending(ssl: PSSL):Integer;
function SslGetVersion(ssl: PSSL):String;
function SslGetPeerCertificate(ssl: PSSL):PX509;
procedure SslCtxSetVerify(ctx: PSSL_CTX; mode: Integer; arg2: PFunction);
function SSLGetCurrentCipher(s: PSSL):SslPtr;
function SSLCipherGetName(c: SslPtr): String;
function SSLCipherGetBits(c: SslPtr; var alg_bits: Integer):Integer;
function SSLGetVerifyResult(ssl: PSSL):Integer;
// libeay.dll
function X509New: PX509;
procedure X509Free(x: PX509);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -