{ Delphi function declarations for CryptoSys API $Id: diCryptoSys.pas $ Copyright (C) 2010 DI Management Services Pty Limited. All rights reserved. Provided as is with no warranties. Use at your own risk. Last updated: $Date: 2010-03-16 23:09 $ $Revision: 4.3.0 $ } // GENERAL FUNCTIONS function API_Version : Integer; stdcall; external 'diCryptoSys.dll'; function API_ErrorLookup(szOutput : PAnsiChar; nMaxChars : Integer; nErrCode : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function API_CompileTime(szOutput : PAnsiChar; nMaxChars : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function API_ModuleName(szOutput : PAnsiChar; nMaxChars : Integer; reserved : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function API_PowerUpTests(nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function API_LicenceType(nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function API_ErrorCode : Integer; stdcall; external 'diCryptoSys.dll'; // AES-128 PROTOTYPES function AES128_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_Init(lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES128_InitError : Integer; stdcall; external 'diCryptoSys.dll'; // AES-192 PROTOTYPES function AES192_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_Init(lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES192_InitError : Integer; stdcall; external 'diCryptoSys.dll'; // AES-256 PROTOTYPES function AES256_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_Init(lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function AES256_InitError : Integer; stdcall; external 'diCryptoSys.dll'; // BLOWFISH PROTOTYPES function BLF_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; keyBytes : Integer; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; keyBytes : Integer; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; keyBytes : Integer; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; sHexIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_Init(lpKey : PByte; keyBytes : Integer; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; sHexIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function BLF_InitError : Integer; stdcall; external 'diCryptoSys.dll'; // DES PROTOTYPES function DES_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_Init(lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_InitError : Integer; stdcall; external 'diCryptoSys.dll'; function DES_CheckKey(lpKey : PByte; nKeyLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function DES_CheckKeyHex(szHexKey : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; // TRIPLE DES PROTOTYPES function TDEA_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_BytesMode(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_Hex(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_HexMode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_B64Mode(szOutput : PAnsiChar; szInput : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_File(szFileOut : AnsiString; szFileIn : AnsiString; lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_FileHex(szFileOut : AnsiString; szFileIn : AnsiString; szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_Init(lpKey : PByte; fEncrypt : Integer; szMode : AnsiString; lpIV : PByte) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_InitHex(szKey : AnsiString; fEncrypt : Integer; szMode : AnsiString; szIV : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_Update(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_UpdateHex(hContext : Integer; szHexData : PAnsiChar) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_Final(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function TDEA_InitError : Integer; stdcall; external 'diCryptoSys.dll'; // KEY WRAP FUNCTIONS function CIPHER_KeyWrap(lpOutput : PByte; nOutBytes : Integer; lpData : PByte; nDataLen : Integer; lpKEK : PByte; nKekLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function CIPHER_KeyUnwrap(lpOutput : PByte; nOutBytes : Integer; lpData : PByte; nDataLen : Integer; lpKEK : PByte; nKekLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // GCM AUTHENTICATED EN/DECRYPTION FUNCTIONS function GCM_Encrypt(lpOutput : PByte; nOutLen : Integer; lpTagOut : PByte; nTagLen : Integer; lpData : PByte; nDataLen : Integer; lpKey : PByte; nKeyLen : Integer; lpIV : PByte; nIvLen : Integer; lpAAD : PByte; nAadLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function GCM_Decrypt(lpOutput : PByte; nOutLen : Integer; lpData : PByte; nDataLen : Integer; lpKey : PByte; nKeyLen : Integer; lpIV : PByte; nIvLen : Integer; lpAAD : PByte; nAadLen : Integer; lpTag : PByte; nTagLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function GCM_InitKey(lpKey : PByte; nKeyLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function GCM_NextEncrypt(hContext : Integer; lpOutput : PByte; nOutLen : Integer; lpTagOut : PByte; nTagLen : Integer; lpData : PByte; nDataLen : Integer; lpIV : PByte; nIvLen : Integer; lpAAD : PByte; nAadLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function GCM_NextDecrypt(hContext : Integer; lpOutput : PByte; nOutLen : Integer; lpData : PByte; nDataLen : Integer; lpIV : PByte; nIvLen : Integer; lpAAD : PByte; nAadLen : Integer; lpTag : PByte; nTagLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function GCM_FinishKey(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // GENERIC MESSAGE DIGEST HASH FUNCTIONS function HASH_Bytes(lpOutput : PByte; nOutLen : Integer; lpMessage : PByte; nMsgLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function HASH_File(lpOutput : PByte; nOutLen : Integer; szFileName : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function HASH_HexFromBytes(szOutput : PAnsiChar; nMaxChars : Integer; lpMessage : PByte; nMsgLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function HASH_HexFromFile(szOutput : PAnsiChar; nMaxChars : Integer; szFileName : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function HASH_HexFromHex(szOutput : PAnsiChar; nMaxChars : Integer; szMsgHex : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // GENERIC MAC FUNCTIONS (HMAC and CMAC) function MAC_Bytes(lpOutput : PByte; nOutLen : Integer; lpMessage : PByte; nMsgLen : Integer; lpKey : PByte; nKeyLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MAC_HexFromBytes(szOutput : PAnsiChar; nMaxChars : Integer; lpMessage : PByte; nMsgLen : Integer; lpKey : PByte; nKeyLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MAC_HexFromHex(szOutput : PAnsiChar; nMaxChars : Integer; szMsgHex : AnsiString; szKeyHex : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // SHA-1 PROTOTYPES function SHA1_StringHexHash(szDigest : PAnsiChar; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_FileHexHash(szDigest : PAnsiChar; szFileName : AnsiString; szMode : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_BytesHexHash(szDigest : PAnsiChar; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_BytesHash(digest : PByte; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_Init : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_AddString(hContext : Integer; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_AddBytes(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_HexDigest(szDigest : PAnsiChar; hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_Reset(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_Hmac(szDigest : PAnsiChar; textBytes : PByte; textLen : Integer; lpKeyBytes : PByte; keyLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA1_HmacHex(szDigest : PAnsiChar; sHexText : AnsiString; sHexKey : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; // SHA-256 PROTOTYPES function SHA2_StringHexHash(szDigest : PAnsiChar; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_FileHexHash(szDigest : PAnsiChar; szFileName : AnsiString; szMode : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_BytesHexHash(szDigest : PAnsiChar; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_BytesHash(lpDigest : PByte; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_Init : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_AddString(hContext : Integer; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_AddBytes(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_HexDigest(szDigest : PAnsiChar; hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_Reset(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_Hmac(szDigest : PAnsiChar; textBytes : PByte; textLen : Integer; lpKeyBytes : PByte; keyLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function SHA2_HmacHex(szDigest : PAnsiChar; sHexText : AnsiString; sHexKey : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; // MD5 PROTOTYPES function MD5_StringHexHash(szDigest : PAnsiChar; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_FileHexHash(szDigest : PAnsiChar; szFileName : AnsiString; szMode : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_BytesHexHash(szDigest : PAnsiChar; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_BytesHash(digest : PByte; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_Init : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_AddString(hContext : Integer; szMessage : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_AddBytes(hContext : Integer; lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_HexDigest(szDigest : PAnsiChar; hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_Reset(hContext : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_Hmac(szDigest : PAnsiChar; textBytes : PByte; textLen : Integer; lpKeyBytes : PByte; keyLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function MD5_HmacHex(szDigest : PAnsiChar; szHexText : AnsiString; szHexKey : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; // RC4-COMPATIBLE PC1 PROTOTYPES function PC1_Bytes(lpOutput : PByte; lpInput : PByte; nBytes : Integer; lpKey : PByte; nKeyBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PC1_File(szFileOut : PAnsiChar; szFileIn : PAnsiChar; lpKey : PByte; nKeyBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PC1_Hex(szOutput : PAnsiChar; nMaxChars : Integer; szInputHex : AnsiString; szKeyHex : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; // RNG PROTOTYPES function RNG_KeyBytes(lpOutput : PByte; nOutputLen : Integer; lpSeed : PByte; nSeedLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_KeyHex(szOutput : PAnsiChar; nMaxChars : Integer; nBytes : Integer; lpSeed : PByte; nSeedLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_NonceData(lpOutput : PByte; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_NonceDataHex(szOutput : PAnsiChar; nMaxChars : Integer; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_Test(szFileName : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_Number(nLower : Integer; nUpper : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_BytesWithPrompt(lpOutput : PByte; nOutputLen : Integer; szPrompt : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_HexWithPrompt(szOutput : PAnsiChar; nMaxChars : Integer; nBytes : Integer; szPrompt : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_Initialize(szSeedFile : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_MakeSeedFile(szSeedFile : AnsiString; szPrompt : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function RNG_UpdateSeedFile(szSeedFile : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // ZLIB COMPRESSION PROTOTYPES function ZLIB_Deflate(lpOutput : PByte; nOutputLen : Integer; lpInput : PByte; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function ZLIB_Inflate(lpOutput : PByte; nOutputLen : Integer; lpInput : PByte; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // PASSWORD-BASED ENCRYPTION PROTOTYPES function PBE_Kdf2(lpOutput : PByte; nOutputLen : Integer; lpPwd : PByte; nPwdLen : Integer; lpSalt : PByte; nSaltLen : Integer; nCount : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PBE_Kdf2Hex(szOutput : PAnsiChar; nMaxChars : Integer; dkBytes : Integer; szPwd : AnsiString; szSaltHex : AnsiString; nCount : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // HEX CONVERSION PROTOTYPES function CNV_HexStrFromBytes(szOutput : PAnsiChar; nMaxChars : Integer; lpInput : PByte; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function CNV_BytesFromHexStr(lpOutput : PByte; nOutputLen : Integer; szInput : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function CNV_HexFilter(szOutput : PAnsiChar; szInput : AnsiString; nInStrLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // BASE64 CONVERSION PROTOTYPES function CNV_B64StrFromBytes(szOutput : PAnsiChar; nMaxChars : Integer; lpInput : PByte; nBytes : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function CNV_BytesFromB64Str(lpOutput : PByte; nOutputLen : Integer; szInput : AnsiString) : Integer; stdcall; external 'diCryptoSys.dll'; function CNV_B64Filter(szOutput : PAnsiChar; szInput : AnsiString; nInStrLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // CRC-32 CHECKSUM PROTOTYPES function CRC_Bytes(lpInput : PByte; nBytes : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function CRC_String(szInput : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function CRC_File(szFileName : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // WIPE PROTOTYPES function WIPE_Data(lpData : PByte; nDataLen : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function WIPE_File(szFileName : AnsiString; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; // PADDING PROTOTYPES function PAD_BytesBlock(lpOutput : PByte; nOutputLen : Integer; lpInput : PByte; nBytes : Integer; nBlkLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PAD_UnpadBytes(lpOutput : PByte; nOutputLen : Integer; lpInput : PByte; nBytes : Integer; nBlkLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PAD_HexBlock(szOutput : PAnsiChar; nMaxChars : Integer; szInput : AnsiString; nBlkLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; function PAD_UnpadHex(szOutput : PAnsiChar; nMaxChars : Integer; szInput : AnsiString; nBlkLen : Integer; nOptions : Integer) : Integer; stdcall; external 'diCryptoSys.dll'; const //*********** // CONSTANTS //*********** ENCRYPT = 1; DECRYPT = 0; // Maximum number of bytes in hash digest byte array API_MAX_HASH_BYTES = 64; API_SHA1_BYTES = 20; API_SHA224_BYTES = 28; API_SHA256_BYTES = 32; API_SHA384_BYTES = 48; API_SHA512_BYTES = 64; API_MD5_BYTES = 16; API_MD2_BYTES = 16; API_RMD160_BYTES = 20; // Maximum number of hex characters in hash digest API_MAX_HASH_CHARS = (2*API_MAX_HASH_BYTES); API_SHA1_CHARS = (2*API_SHA1_BYTES); API_SHA224_CHARS = (2*API_SHA224_BYTES); API_SHA256_CHARS = (2*API_SHA256_BYTES); API_SHA384_CHARS = (2*API_SHA384_BYTES); API_SHA512_CHARS = (2*API_SHA512_BYTES); API_MD5_CHARS = (2*API_MD5_BYTES); API_MD2_CHARS = (2*API_MD2_BYTES); API_RMD160_CHARS = (2*API_RMD160_BYTES); // Maximum lengths of HMAC, CMAC and GMAC API_MAX_HMAC_BYTES = 64; API_MAX_CMAC_BYTES = 16; API_MAX_GMAC_BYTES = 16; API_MAX_HMAC_CHARS = (2*API_MAX_HMAC_BYTES); API_MAX_CMAC_CHARS = (2*API_MAX_CMAC_BYTES); API_MAX_GMAC_CHARS = (2*API_MAX_GMAC_BYTES); // Synonyms retained for backwards compatibility API_MAX_SHA1_BYTES = 20; API_MAX_SHA2_BYTES = 32; API_MAX_MD5_BYTES = 16; API_MAX_SHA1_CHARS = (2*API_MAX_SHA1_BYTES); API_MAX_SHA2_CHARS = (2*API_MAX_SHA2_BYTES); API_MAX_MD5_CHARS = (2*API_MAX_MD5_BYTES); // Encryption block sizes in bytes API_BLK_DES_BYTES = 8; API_BLK_TDEA_BYTES = 8; API_BLK_BLF_BYTES = 8; API_BLK_AES_BYTES = 16; // Key size in bytes API_KEYSIZE_TDEA_BYTES = 24; // Required size for RNG seed file API_RNG_SEED_BYTES = 64; //********* // OPTIONS //********* // Options for HASH functions API_HASH_SHA1 = 0; API_HASH_MD5 = 1; API_HASH_MD2 = 2; API_HASH_SHA256 = 3; API_HASH_SHA384 = 4; API_HASH_SHA512 = 5; API_HASH_SHA224 = 6; API_HASH_RMD160 = 7; API_HASH_MODE_TEXT = $10000; // Options for MAC functions API_CMAC_TDEA = $100; // ) synonyms API_CMAC_DESEDE = $100; // ) synonyms API_CMAC_AES128 = $101; API_CMAC_AES192 = $102; API_CMAC_AES256 = $103; // Options for RNG functions API_RNG_STRENGTH_112 = $00; API_RNG_STRENGTH_128 = $01; // Block cipher (BC) algorithm options - used for Key Wrap API_BC_TDEA = $10; // ) API_BC_3DES = $10; // ) equiv. synonyms for Triple DES API_BC_DESEDE3 = $10; // ) API_BC_AES128 = $20; API_BC_AES192 = $30; API_BC_AES256 = $40; // General API_GEN_PLATFORM = $40;