CryptoSys API
6.22.1
|
The C/C++ interface to the diCryptoSys library. More...
Typedefs | |
typedef int | int32_t |
Default for signed 32-bit integer type if int32_t not defined. | |
Functions | |
long | AEAD_AddAAD (long hContext, const unsigned char *lpAAD, long nAadLen) |
Add a chunk of additional authenticated data (in incremental mode). More... | |
long | AEAD_Decrypt (unsigned char *lpOutput, long nOutLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpNonce, long nNonceLen, const unsigned char *lpAAD, long nAadLen, const unsigned char *lpTag, long nTagLen, long nOptions) |
Decrypt and authenticate input using specified AEAD algorithm in one-off operation. More... | |
long | AEAD_DecryptWithTag (unsigned char *lpOutput, long nOutLen, const unsigned char *lpInput, long nInputLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpNonce, long nNonceLen, const unsigned char *lpAAD, long nAadLen, long nOptions) |
Decrypt and authenticate input using specified AEAD algorithm in one-off operation. More... | |
long | AEAD_Destroy (long hContext) |
Closes the AEAD context and destroys the key (in incremental mode). More... | |
long | AEAD_Encrypt (unsigned char *lpOutput, long nOutLen, unsigned char *lpTagOut, long nTagLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpNonce, long nNonceLen, const unsigned char *lpAAD, long nAadLen, long nOptions) |
Encrypt input using specified AEAD algorithm in one-off operation. More... | |
long | AEAD_EncryptWithTag (unsigned char *lpOutput, long nOutLen, const unsigned char *lpInput, long nInputLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpNonce, long nNonceLen, const unsigned char *lpAAD, long nAadLen, long nOptions) |
Encrypt input using specified AEAD algorithm in one-off operation with the authentication tag appended to output. More... | |
long | AEAD_FinishDecrypt (long hContext) |
Finishes the authenticated decryption (in incremental mode) . More... | |
long | AEAD_FinishEncrypt (long hContext, unsigned char *lpTagOut, long nTagLen) |
Finishes the authenticated encryption (in incremental mode) . More... | |
long | AEAD_InitKey (const unsigned char *lpKey, long nKeyLen, long nOptions) |
Initializes the context with the key and algorithm ready for repeated incremental operations. More... | |
long | AEAD_SetNonce (long hContext, const unsigned char *lpNonce, long nNonceLen) |
Set the nonce (in incremental mode). More... | |
long | AEAD_StartDecrypt (long hContext, const unsigned char *lpTagToCheck, long nTagLen) |
Start authenticated decryption (in incremental mode). More... | |
long | AEAD_StartEncrypt (long hContext) |
Start authenticated encryption (in incremental mode). More... | |
long | AEAD_Update (long hContext, unsigned char *lpOutput, long nOutLen, const unsigned char *lpData, long nDataLen) |
Encrypts or decrypts a chunk of input (in incremental mode). More... | |
long | AES128_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | AES128_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | AES128_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes using a specified mode. More... | |
long | AES128_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES128_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES128_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES128_Final (long hContext) |
Closes and clears the AES context. More... | |
long | AES128_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | AES128_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | AES128_Init (const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES128_InitError (void) |
Returns the error code after an unsuccessful call to AES128_Init or AES128_InitHex. More... | |
long | AES128_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES128_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES128_Init() or AES128_InitHex(). More... | |
long | AES128_UpdateHex (long hContext, char *szHexData) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES128_Init() or AES128_InitHex(). More... | |
long | AES192_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | AES192_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | AES192_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes using a specified mode. More... | |
long | AES192_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES192_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode with extended options. More... | |
long | AES192_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES192_Final (long hContext) |
Closes and clears the AES context. More... | |
long | AES192_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | AES192_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | AES192_Init (const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES192_InitError (void) |
Returns the error code after an unsuccessful call to AES192_Init or AES192_InitHex. More... | |
long | AES192_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES192_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES192_Init() or AES192_InitHex(). More... | |
long | AES192_UpdateHex (long hContext, char *szHexData) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES192_Init() or AES192_InitHex(). More... | |
long | AES256_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | AES256_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | AES256_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes using a specified mode. More... | |
long | AES256_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES256_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode with extended options. More... | |
long | AES256_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | AES256_Final (long hContext) |
Closes and clears the AES context. More... | |
long | AES256_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | AES256_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | AES256_Init (const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES256_InitError (void) |
Returns the error code after an unsuccessful call to AES256_Init or AES256_InitHex. More... | |
long | AES256_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function. More... | |
long | AES256_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES256_Init() or AES256_InitHex(). More... | |
long | AES256_UpdateHex (long hContext, char *szHexData) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES256_Init() or AES256_InitHex(). More... | |
long | API_CompileTime (char *szOutput, long nMaxChars) |
Retrieves the date and time the core library executable was last compiled. More... | |
long | API_ErrorCode (void) |
Returns the error code of the error that occurred when calling the last function. More... | |
long | API_ErrorLookup (char *szOutput, long nMaxChars, long nErrCode) |
Retrieves the error message associated with a given error code. More... | |
long | API_LicenceType (long nOptions) |
Returns the ASCII value of the licence type. More... | |
long | API_ModuleInfo (char *szOutput, long nOutChars, long nOptions) |
Get additional information about the core DLL module. More... | |
long | API_ModuleName (char *szOutput, long nMaxChars, long nOptions) |
Retrieves the name of the current process's module. More... | |
long | API_Platform (char *szOutput, long nOutChars) |
Gets the platform the core DLL was compiled for. More... | |
long | API_PowerUpTests (long nOptions) |
Carries out on demand the full set of power-up tests automatically performed by the toolkit when first powered up (i.e. More... | |
long | API_Version (void) |
Retrieves the release version number. More... | |
long | BLF_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | BLF_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, long keyBytes, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | BLF_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, long keyBytes, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes using a specified mode. More... | |
long | BLF_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long keyBytes, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | BLF_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long keyBytes, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode with extended options. More... | |
long | BLF_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *sHexIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | BLF_Final (long hContext) |
Closes and clears the BLF context. More... | |
long | BLF_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | BLF_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | BLF_Init (const unsigned char *lpKey, long keyBytes, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the BLF_Update or BLF_UpdateHex functions. More... | |
long | BLF_InitError (void) |
Returns the error code after an unsuccessful call to BLF_Init or BLF_InitHex. More... | |
long | BLF_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *sHexIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the BLF_Update or BLF_UpdateHex functions. More... | |
long | BLF_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the Blowfish transformation function on a byte array according to the direction and mode set up by an earlier call to BLF_Init() or BLF_InitHex(). More... | |
long | BLF_UpdateHex (long hContext, char *szHexData) |
Carries out the Blowfish transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to BLF_Init() or BLF_InitHex(). More... | |
long | CIPHER_DecryptBytes (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nInputLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const char *szAlgModePad, long nOptions) |
Decrypts data in a byte array using the specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_DecryptHex (char *szOutput, long nOutChars, const char *szInputHex, const char *szKeyHex, const char *szIvHex, const char *szAlgModePad, long nOptions) |
Decrypt data using the specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_EncryptBytes (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nInputLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const char *szAlgModePad, long nOptions) |
Encrypts data in a byte array using the specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_EncryptHex (char *szOutput, long nOutChars, const char *szInputHex, const char *szKeyHex, const char *szIvHex, const char *szAlgModePad, long nOptions) |
Encrypt data using the specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_FileDecrypt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const char *szAlgModePad, long nOptions) |
Decrypts a file using specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_FileEncrypt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const char *szAlgModePad, long nOptions) |
Encrypts a file using specified block cipher algorithm, mode and padding. More... | |
long | CIPHER_Final (long hContext) |
Closes and clears the CIPHER context. More... | |
long | CIPHER_Init (int fEncrypt, const char *szAlgAndMode, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, long nOptions) |
Initialize the CIPHER context with the key, iv, algorithm and mode ready for repeated update operations. More... | |
long | CIPHER_InitHex (int fEncrypt, const char *szAlgAndMode, const char *szKeyHex, const char *szIvHex, long nOptions) |
Initialize the CIPHER context with hex-encoded key, iv, algorithm and mode ready for repeated update operations. More... | |
long | CIPHER_KeyUnwrap (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpData, long nDataLen, const unsigned char *lpKEK, long nKekLen, long nOptions) |
Unwraps (decrypts) a content-encryption key with a key-encryption key. More... | |
long | CIPHER_KeyWrap (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpData, long nDataLen, const unsigned char *lpKEK, long nKekLen, long nOptions) |
Wraps a content-encryption key with a key-encryption key. More... | |
long | CIPHER_StreamBytes (unsigned char *lpOutput, unsigned char *lpData, long nDataLen, unsigned char *lpKey, long nKeyLen, unsigned char *lpIV, long nIvLen, long nCounter, long nOptions) |
Enciphers data in array of bytes using specified stream cipher. More... | |
long | CIPHER_StreamFile (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, long nKeyLen, unsigned char *lpIV, long nIvLen, long nCounter, long nOptions) |
Enciphers data in a file using specified stream cipher. More... | |
long | CIPHER_StreamFinal (long hContext) |
Closes the CIPHERSTREAM context and destroys the key. More... | |
long | CIPHER_StreamHex (char *szOutput, long nOutChars, const char *szInputHex, const char *szKeyHex, const char *szIvHex, long nCounter, long nOptions) |
Enciphers data in a hex-encoded string using specified stream cipher. More... | |
long | CIPHER_StreamInit (const unsigned char *lpKey, long nKeyLen, unsigned char *lpIV, long nIvLen, long nCounter, long nOptions) |
Initializes the CIPHERSTREAM context ready for repeated operations of CIPHER_StreamUpdate() More... | |
long | CIPHER_StreamUpdate (long hContext, unsigned char *lpOutput, unsigned char *lpData, long nDataLen) |
Encrypts input using current CIPHERSTREAM context. More... | |
long | CIPHER_Update (long hContext, unsigned char *lpOutput, long nOutBytes, const unsigned char *lpData, long nDataLen) |
Encrypts or decrypts a chunk of input (in incremental mode). More... | |
long | CIPHER_UpdateHex (long hContext, char *szOutput, long nOutChars, const char *szDataHex) |
Encrypts or decrypts a chunk of hexadecimal-encoded input (in incremental mode). More... | |
long | CNV_B64Filter (char *szOutput, const char *szInput, long nInStrLen) |
Removes non-base64 characters from a string. More... | |
long | CNV_B64StrFromBytes (char *szOutput, long nMaxChars, const unsigned char *lpInput, long nBytes) |
Encodes an array of bytes into a base64-encoded string. More... | |
long | CNV_BytesFromB64Str (unsigned char *lpOutput, long nOutputLen, const char *szInput) |
Decodes a base64-encoded string into an array of Bytes. More... | |
long | CNV_BytesFromHexStr (unsigned char *lpOutput, long nOutputLen, const char *szInput) |
Decodes a hexadecimal-encoded string into an array of Bytes. More... | |
long | CNV_HexFilter (char *szOutput, const char *szInput, long nInStrLen) |
Removes non-hexadecimal characters from a string. More... | |
long | CNV_HexStrFromBytes (char *szOutput, long nMaxChars, const unsigned char *lpInput, long nBytes) |
Encodes an array of bytes into a hexadecimal-encoded string. More... | |
long | CNV_ShortPathName (char *szOut, long nOutChars, const wchar_t *szwFilePath) |
Retrieve the Windows short path form of the specified path. More... | |
long | COMPR_Compress (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nInputLen, long nOptions) |
Compress data using compression algorithm. More... | |
long | COMPR_Uncompress (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nInputLen, long nOptions) |
Uncompress data using compression algorithm. More... | |
int32_t | CRC_Bytes (const unsigned char *lpInput, long nBytes, long nOptions) |
Computes the CRC-32 checksum of an array of bytes. More... | |
int32_t | CRC_File (const char *szFileName, long nOptions) |
Computes the CRC-32 checksum of a file. More... | |
int32_t | CRC_String (const char *szInput, long nOptions) |
Computes the CRC-32 checksum of an ANSI string. More... | |
long | DES_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | DES_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | DES_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes in one step using a specified mode. More... | |
long | DES_CheckKey (const unsigned char *lpKey, long nKeyLen) |
Checks for weak or invalid-length DES or TDEA keys. More... | |
long | DES_CheckKeyHex (const char *szHexKey) |
Checks for weak or invalid-length DES or TDEA keys in hexadecimal format. More... | |
long | DES_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | DES_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode with extended options. More... | |
long | DES_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | DES_Final (long hContext) |
Closes and clears the DES context. More... | |
long | DES_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | DES_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | DES_Init (const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the DES function. More... | |
long | DES_InitError (void) |
Returns the error code after an unsuccessful call to DES_Init or DES_InitHex. More... | |
long | DES_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the DES function. More... | |
long | DES_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the DES transformation function on a byte array according to the direction and mode set up by an earlier call to DES_Init() or DES_InitHex(). More... | |
long | DES_UpdateHex (long hContext, char *szHexData) |
Carries out the DES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to DES_Init() or DES_InitHex(). More... | |
long | GCM_Decrypt (unsigned char *lpOutput, long nOutLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const unsigned char *lpAAD, long nAadLen, const unsigned char *lpTag, long nTagLen, long nOptions) |
Decrypts authenticated ciphertext using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM). More... | |
long | GCM_Encrypt (unsigned char *lpOutput, long nOutLen, unsigned char *lpTagOut, long nTagLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpKey, long nKeyLen, const unsigned char *lpIV, long nIvLen, const unsigned char *lpAAD, long nAadLen, long nOptions) |
Provides authenticated encryption using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM). More... | |
long | GCM_FinishKey (long hContext) |
Closes the GCM context and destroys the key. More... | |
long | GCM_InitKey (const unsigned char *lpKey, long nKeyLen, long nOptions) |
Initializes the context with the key ready for repeated operations of GCM_NextEncrypt and GCM_NextDecrypt. More... | |
long | GCM_NextDecrypt (long hContext, unsigned char *lpOutput, long nOutLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpIV, long nIvLen, const unsigned char *lpAAD, long nAadLen, const unsigned char *lpTag, long nTagLen) |
Carries out the GCM authenticated decryption operation using the key set up by an earlier call to GCM_InitKey. More... | |
long | GCM_NextEncrypt (long hContext, unsigned char *lpOutput, long nOutLen, unsigned char *lpTagOut, long nTagLen, const unsigned char *lpData, long nDataLen, const unsigned char *lpIV, long nIvLen, const unsigned char *lpAAD, long nAadLen) |
Carries out the GCM authenticated encryption operation using the key set up by an earlier call to GCM_InitKey. More... | |
long | HASH_AddBytes (long hContext, const void *lpData, long nDataLen) |
Adds an array of bytes to be digested in the HASH context. More... | |
long | HASH_Bytes (unsigned char *lpOutput, long nOutLen, const void *lpMessage, long nMsgLen, long nOptions) |
Creates a message digest hash as a byte array from byte data. More... | |
long | HASH_DigestLength (long hContext) |
Returns the number of bytes in the hash output for the algorithm defined in the current HASH context. More... | |
long | HASH_File (unsigned char *lpOutput, long nOutLen, const char *szFileName, long nOptions) |
Creates a message digest hash in byte format for a file. More... | |
long | HASH_Final (unsigned char *lpOutput, long nOutLen, long hContext) |
Returns the final message digest value from the HASH context. More... | |
long | HASH_HexFromBits (char *szOutput, long nMaxChars, const unsigned char *lpData, long nDataBitLen, long nOptions) |
Creates a message digest hash in hexadecimal format from bit-oriented input. More... | |
long | HASH_HexFromBytes (char *szOutput, long nMaxChars, const void *lpMessage, long nMsgLen, long nOptions) |
Creates a message digest hash in hexadecimal format from byte (or string) data. More... | |
long | HASH_HexFromFile (char *szOutput, long nMaxChars, const char *szFileName, long nOptions) |
Creates a message digest hash in hexadecimal format for a file. More... | |
long | HASH_HexFromHex (char *szOutput, long nMaxChars, const char *szMsgHex, long nOptions) |
Creates a message digest hash in hexadecimal format from data in a hexadecimal-encoded string. More... | |
long | HASH_Init (long nAlg) |
Initialises the HASH context ready for subsequent calls with HASH_AddBytes and HASH_Final. More... | |
long | HASH_Length (long nAlgId) |
Return length of message digest output in bytes. More... | |
long | HASH_Reset (long hContext) |
Resets the HASH context. More... | |
long | MAC_AddBytes (long hContext, const void *lpData, long nDataLen) |
Adds an array of bytes to be authenticated in the MAC context. More... | |
long | MAC_Bytes (unsigned char *lpOutput, long nOutBytes, const void *lpMessage, long nMsgLen, const void *lpKey, long nKeyLen, long nOptions) |
Creates a keyed message authentication code (MAC) as a byte array from byte data. More... | |
long | MAC_CodeLength (long hContext) |
Returns the number of bytes in the output for the algorithm defined in the current MAC context. More... | |
long | MAC_Final (unsigned char *lpOutput, long nOutLen, long hContext) |
Returns the final message digest value from the MAC context. More... | |
long | MAC_HexFromBytes (char *szOutput, long nMaxChars, const void *lpMessage, long nMsgLen, const void *lpKey, long nKeyLen, long nOptions) |
Creates a keyed-hash based message authentication code (HMAC) in hexadecimal format from byte data. More... | |
long | MAC_HexFromHex (char *szOutput, long nMaxChars, const char *szMsgHex, const char *szKeyHex, long nOptions) |
Creates a message authentication code (MAC) in hexadecimal format from hex-encoded data and a hex-encoded key. More... | |
long | MAC_Init (const void *lpKey, long nKeyLen, long nAlg) |
Initialises the MAC context ready for subsequent calls with MAC_AddBytes and MAC_Final. More... | |
long | MAC_Reset (long hContext) |
Resets the MAC context. More... | |
long | MD5_AddBytes (long hContext, const unsigned char *lpData, long nDataLen) |
Adds an array of bytes to the digest. More... | |
long | MD5_AddString (long hContext, const char *szMessage) |
Adds a string of ascii characters to the digest. More... | |
long | MD5_BytesHash (unsigned char *digest, const unsigned char *lpData, long nDataLen) |
Creates an MD5 message digest in Byte array format from a message in Byte array format. More... | |
long | MD5_BytesHexHash (char *szDigest, const unsigned char *lpData, long nDataLen) |
Creates an MD5 message digest in hexadecimal format from a message in Byte array format. More... | |
long | MD5_FileHexHash (char *szDigest, const char *szFileName, const char *szMode) |
Creates an MD5 message digest in hexadecimal format from a file. More... | |
long | MD5_HexDigest (char *szDigest, long hContext) |
Returns the final message digest value as a hex string. More... | |
long | MD5_Hmac (char *szDigest, const unsigned char *textBytes, long textLen, const unsigned char *lpKeyBytes, long keyLen) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the MD5 hash function. More... | |
long | MD5_HmacHex (char *szDigest, const char *szHexText, const char *szHexKey) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the MD5 hash function, passing its arguments in hexadecimal format. More... | |
long | MD5_Init (void) |
Initialises the MD5 context ready for subsequent calls with MD5_AddString, MD5_AddBytes, and MD5_HexDigest. More... | |
long | MD5_Reset (long hContext) |
Resets the context. More... | |
long | MD5_StringHexHash (char *szDigest, const char *szMessage) |
Creates an MD5 message digest in hexadecimal format from a message of String type. More... | |
long | PAD_BytesBlock (unsigned char *lpOutput, long nOutputLen, const unsigned char *lpInput, long nBytes, long nBlkLen, long nOptions) |
Creates an input block suitably padded for encryption by a block cipher in ECB or CBC mode. More... | |
long | PAD_HexBlock (char *szOutput, long nMaxChars, const char *szInput, long nBlkLen, long nOptions) |
Creates a hex-encoded input block suitably padded for encryption by a block cipher in ECB or CBC mode. More... | |
long | PAD_UnpadBytes (unsigned char *lpOutput, long nOutputLen, const unsigned char *lpInput, long nBytes, long nBlkLen, long nOptions) |
Removes the padding from an encryption block. More... | |
long | PAD_UnpadHex (char *szOutput, long nMaxChars, const char *szInput, long nBlkLen, long nOptions) |
Removes the padding from a hex-encoded encryption block. More... | |
long | PBE_Kdf2 (unsigned char *lpDerivedKey, long nKeyLen, const unsigned char *lpPwd, long nPwdLen, const unsigned char *lpSalt, long nSaltLen, long nCount, long nOptions) |
Derives a key of any length from a password using the PBKDF2 algorithm from PKCS#5 v2.1. More... | |
long | PBE_Kdf2Hex (char *szOutput, long nMaxChars, long dkBytes, const char *szPwd, const char *szSaltHex, long nCount, long nOptions) |
Derives a key of any length from a password using the PBKDF2 algorithm from PKCS#5 v2.1 with the salt and derived key encoded in hexadecimal. More... | |
long | PBE_Scrypt (unsigned char *lpDerivedKey, long nKeyLen, const unsigned char *lpPwd, long nPwdLen, const unsigned char *lpSalt, long nSaltLen, long nParamN, long nParamR, long nParamP, long nOptions) |
Derives a key of any length from a password using the SCRYPT algorithm. More... | |
long | PBE_ScryptHex (char *szOutput, long nMaxChars, long dkBytes, const char *szPwd, const char *szSaltHex, long nParamN, long nParamR, long nParamP, long nOptions) |
Derives a key of any length from a password using the SCRYPT algorithm with the salt and derived key encoded in hexadecimal. More... | |
long | PC1_Bytes (unsigned char *lpOutput, unsigned char *lpInput, long nBytes, unsigned char *lpKey, long nKeyBytes) |
Enciphers an array of Bytes in one step using the RC4-compatible 'PC1' algorithm. More... | |
long | PC1_File (char *szFileOut, char *szFileIn, unsigned char *lpKey, long nKeyBytes) |
Enciphers a file using the RC4-compatible 'PC1' algorithm. More... | |
long | PC1_Hex (char *szOutput, long nMaxChars, const char *szInputHex, const char *szKeyHex) |
Enciphers data encoded in hex format in one step using the RC4-compatible 'PC1' algorithm. More... | |
long | PRF_Bytes (unsigned char *lpOutput, long nOutBytes, const void *lpMessage, long nMsgLen, const void *lpKey, long nKeyLen, const char *szCustom, long nOptions) |
Generate output bytes using a pseudorandom function (PRF). More... | |
long | RNG_BytesWithPrompt (unsigned char *lpOutput, long nOutputLen, const char *szPrompt, long nOptions) |
Generates a random set of byte data suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements. More... | |
long | RNG_HexWithPrompt (char *szOutput, long nMaxChars, long nBytes, const char *szPrompt, long nOptions) |
Generates a random set of data in hexadecimal format suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements. More... | |
long | RNG_Initialize (const char *szSeedFile, long nOptions) |
Initializes the RNG generator with a seed file. More... | |
long | RNG_KeyBytes (unsigned char *lpOutput, long nOutputLen, const void *lpSeed, long nSeedLen) |
Generates a random set of byte data suitable for cryptographic keys. More... | |
long | RNG_KeyHex (char *szOutput, long nMaxChars, long nBytes, const void *lpSeed, long nSeedLen) |
Generates a random set of data in hexadecimal format suitable for cryptographic keys. More... | |
long | RNG_MakeSeedFile (const char *szSeedFile, const char *szPrompt, long nOptions) |
Creates a new seed file suitable for use with RNG_Initialize. More... | |
long | RNG_NonceData (unsigned char *lpOutput, long nBytes) |
Returns a random nonce (number used once) as a specified-length byte array. More... | |
long | RNG_NonceDataHex (char *szOutput, long nMaxChars, long nBytes) |
Returns a specified-length random nonce (number used once) as a hexadecimal string. More... | |
int32_t | RNG_Number (int32_t nLower, int32_t nUpper) |
Returns a random 32-bit number between specified limits. More... | |
long | RNG_Test (const char *szFileName) |
Carries out a NIST SP800-90 health check and FIPS140-2 statistical tests on the random number generator. More... | |
long | RNG_TestDRBGVS (char *szOutput, long nMaxChars, long nReturnedBitsLen, const char *szEntropyInput, const char *szNonce, const char *szPersonalizationString, const char *szAdditionalInput1, const char *szEntropyReseed, const char *szAdditionalInputReseed, const char *szAdditionalInput2, long nOptions) |
Tests the random number generator for conformance to NIST SP 800-90A using the relevant test specified in the Deterministic Random Bit Generator Validation System (DRBGVS). More... | |
long | RNG_UpdateSeedFile (const char *szSeedFile, long nOptions) |
Updates an RNG seed file. More... | |
long | SHA1_AddBytes (long hContext, const unsigned char *lpData, long nDataLen) |
Adds an array of bytes to the digest. More... | |
long | SHA1_AddString (long hContext, const char *szMessage) |
Adds a string of ascii characters to the digest. More... | |
long | SHA1_BytesHash (unsigned char *digest, const unsigned char *lpData, long nDataLen) |
Creates a SHA-1 message digest in Byte array format from a message in Byte array format. More... | |
long | SHA1_BytesHexHash (char *szDigest, const unsigned char *lpData, long nDataLen) |
Creates a SHA-1 message digest in hexadecimal format from a message in Byte array format. More... | |
long | SHA1_FileHexHash (char *szDigest, const char *szFileName, const char *szMode) |
Creates a SHA-1 message digest in hexadecimal format from a file. More... | |
long | SHA1_HexDigest (char *szDigest, long hContext) |
Returns the final message digest value as a hex string. More... | |
long | SHA1_Hmac (char *szDigest, const unsigned char *textBytes, long textLen, const unsigned char *lpKeyBytes, long keyLen) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-1 hash function. More... | |
long | SHA1_HmacHex (char *szDigest, const char *sHexText, const char *sHexKey) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-1 hash function, passing its arguments in hexadecimal format. More... | |
long | SHA1_Init (void) |
Initialises the SHA-1 context ready for subsequent calls with SHA1_AddString, SHA1_AddBytes, and SHA1_HexDigest. More... | |
long | SHA1_Reset (long hContext) |
Resets the context. More... | |
long | SHA1_StringHexHash (char *szDigest, const char *szMessage) |
Creates a SHA-1 message digest in hexadecimal format from a message of String type. More... | |
long | SHA2_AddBytes (long hContext, const unsigned char *lpData, long nDataLen) |
Adds an array of bytes to the digest. More... | |
long | SHA2_AddString (long hContext, const char *szMessage) |
Adds a string of ascii characters to the digest. More... | |
long | SHA2_BytesHash (unsigned char *lpDigest, const unsigned char *lpData, long nDataLen) |
Creates a SHA-256 message digest in Byte array format from a message in Byte array format. More... | |
long | SHA2_BytesHexHash (char *szDigest, const unsigned char *lpData, long nDataLen) |
Creates a SHA-256 message digest in hexadecimal format from a message in Byte array format. More... | |
long | SHA2_FileHexHash (char *szDigest, const char *szFileName, const char *szMode) |
Creates a SHA-256 message digest in hexadecimal format from a file. More... | |
long | SHA2_HexDigest (char *szDigest, long hContext) |
Returns the final message digest value as a hex string. More... | |
long | SHA2_Hmac (char *szDigest, const unsigned char *textBytes, long textLen, const unsigned char *lpKeyBytes, long keyLen) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-256 hash function. More... | |
long | SHA2_HmacHex (char *szDigest, const char *sHexText, const char *sHexKey) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-256 hash function, passing its arguments in hexadecimal format. More... | |
long | SHA2_Init (void) |
Initialises the SHA-256 context ready for subsequent calls with SHA2_AddString, SHA2_AddBytes, and SHA2_HexDigest. More... | |
long | SHA2_Reset (long hContext) |
Resets the context. More... | |
long | SHA2_StringHexHash (char *szDigest, const char *szMessage) |
Creates a SHA-256 message digest in hexadecimal format from a message of String type. More... | |
long | SHA3_AddBytes (long hContext, const unsigned char *lpData, long nDataLen) |
Adds an array of bytes to the digest. More... | |
long | SHA3_AddString (long hContext, const char *szMessage) |
Adds a string of ascii characters to the digest. More... | |
long | SHA3_HexDigest (char *szOutput, long nMaxChars, long hContext) |
Returns the final message digest value as a hex string. More... | |
long | SHA3_Init (long nHashBitLen) |
Initialises the SHA-3 context ready for subsequent calls with SHA3_AddString, SHA3_AddBytes, and SHA3_HexDigest. More... | |
long | SHA3_LengthInBytes (long hContext) |
Returns the number of bytes in the hash output for the algorithm defined in the current SHA-3 context. More... | |
long | SHA3_Reset (long hContext) |
Resets the context. More... | |
long | TDEA_B64Mode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a base64 string using a specified mode. More... | |
long | TDEA_Bytes (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode. More... | |
long | TDEA_BytesMode (unsigned char *lpOutput, const unsigned char *lpInput, long nBytes, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts an array of Bytes in one step using a specified mode. More... | |
long | TDEA_File (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | TDEA_FileExt (const char *szFileOut, const char *szFileIn, const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV, long nOptions) |
Encrypts or decrypts a file using a specified mode with extended options. More... | |
long | TDEA_FileHex (const char *szFileOut, const char *szFileIn, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts a file using a specified mode. More... | |
long | TDEA_Final (long hContext) |
Closes and clears the TDEA context. More... | |
long | TDEA_Hex (char *szOutput, const char *szInput, const char *szKey, int fEncrypt) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. More... | |
long | TDEA_HexMode (char *szOutput, const char *szInput, const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode. More... | |
long | TDEA_Init (const unsigned char *lpKey, int fEncrypt, const char *szMode, const unsigned char *lpIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the TDEA function. More... | |
long | TDEA_InitError (void) |
Returns the error code after an unsuccessful call to TDEA_Init or TDEA_InitHex. More... | |
long | TDEA_InitHex (const char *szKey, int fEncrypt, const char *szMode, const char *szIV) |
Initialises the context with the key, direction and mode ready for repeated operations of the TDEA function. More... | |
long | TDEA_Update (long hContext, unsigned char *lpData, long nDataLen) |
Carries out the TDEA transformation function on a byte array according to the direction and mode set up by an earlier call to TDEA_Init() or TDEA_InitHex(). More... | |
long | TDEA_UpdateHex (long hContext, char *szHexData) |
Carries out the TDEA transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to TDEA_Init() or TDEA_InitHex(). More... | |
long | WIPE_Data (void *lpData, long nDataLen) |
Zeroises data in memory. More... | |
long | WIPE_File (const char *szFileName, long nOptions) |
Securely wipes and deletes a file using 7-pass DOD standards. More... | |
long | XOF_Bytes (unsigned char *lpOutput, long nOutBytes, const void *lpMessage, long nMsgLen, long nOptions) |
Generate bytes using an eXtendable Output Function (XOF). More... | |
long | ZLIB_Deflate (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nBytes) |
Compresses data using the ZLIB deflate algorithm. More... | |
long | ZLIB_Inflate (unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nBytes) |
Inflates compressed data using the ZLIB uncompress algorithm. More... | |
The C/C++ interface to the diCryptoSys library.
char
type for null-terminated strings, denoted szFoo
, and the unsigned char
for byte arrays, denoted lpBar
. Byte arrays must have their length specified in a separate variable. 0 = OK, success, no error (SUCCESS_NO_ERROR) 1 = Cannot open input file (OPEN_ERROR) 2 = Cannot create output file (CREATE_ERROR) 3 = File read error (READ_ERROR) 4 = File write error (WRITE_ERROR) 5 = Not enough memory (MEMORY_ERROR) 6 = Parameter is wrong or missing (BAD_PARAM_ERROR) 7 = Data is in wrong format (BAD_FORMAT_ERROR) 8 = Invalid data (INVALID_DATA_ERROR) 9 = Unexpected end of file found (EOF_ERROR) 11 = Parameter out of range (RANGE_ERROR) 12 = Duplicate data or filename (DUP_ERROR) 14 = Unexpected NULL value (NULL_ERROR) 15 = Decryption error (DECRYPT_ERROR) 17 = Invalid option (BAD_FLAG_ERROR) 18 = Failed to wipe data (WIPE_ERROR) 19 = Item is not supported (NOT_SUPPORTED_ERROR) 23 = Failed a test e.g. known answer test (TEST_FAILED_ERROR) 26 = Data not a valid length (BAD_LENGTH_ERROR) 30 = Not enough room in output buffer (SHORT_BUF_ERROR) 31 = Zlib compression error (ZLIB_COMPR_ERROR) 33 = Invalid key length (BAD_KEY_LEN_ERROR) 34 = Invalid block length (BAD_BLK_LEN_ERROR) 35 = Invalid mode (BAD_MODE_ERROR) 36 = Invalid key (BAD_KEY_ERROR) 37 = Invalid initialization vector (BAD_IV_ERROR) 38 = Invalid IV length (BAD_IV_LEN_ERROR) 40 = Authentication failed (AUTH_FAIL_ERROR) 41 = Function called out of sequence (MISUSE_ERROR) 52 = Weak key (WEAK_KEY_ERROR) 64 = Invalid context handle (INVALID_HANDLE_ERROR) 201 = PRNG: Cannot open input file (PRNG_ERR_FILE_OPEN) 202 = PRNG: Cannot create output file (PRNG_ERR_FILE_CREATE) 203 = PRNG: File read error (PRNG_ERR_FILE_READ) 204 = PRNG: File write error (PRNG_ERR_FILE_WRITE) 205 = PRNG: File locking error (PRNG_ERR_FILE_LOCK) 210 = PRNG: Uninstantiation failed (PRNG_ERR_UNINST) 211 = PRNG: Requested length is too large (PRNG_ERR_TOOBIG) 212 = PRNG: Function failed (PRNG_ERR_FAILURE) 213 = PRNG: Invalid input parameter (PRNG_ERR_BADPARAM) 214 = PRNG: Function is not available (PRNG_ERR_NOTAVAIL) 299 = PRNG: Catastrophic failure (PRNG_ERR_CATASTROPHIC) 9745 = Something not expected to happen has happened (INTERNAL_ERROR) 9999 = Miscellaneous error (MISC_ERROR)To find the error message corresponding to a numerical error code use the API_ErrorLookup() function. Use API_ErrorCode() to find the error code that occurred when calling the last function.
long AEAD_AddAAD | ( | long | hContext, |
const unsigned char * | lpAAD, | ||
long | nAadLen | ||
) |
Add a chunk of additional authenticated data (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
[in] | lpAAD | array containing the chunk of Additional Authenticated Data (AAD) to add. |
[in] | nAadLen | equal to length of the AAD chunk in bytes. |
AEAD_StartEncrypt
or AEAD_StartDecrypt
. Returns MISUSE_ERROR
if called out of sequence. long AEAD_Decrypt | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpNonce, | ||
long | nNonceLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
const unsigned char * | lpTag, | ||
long | nTagLen, | ||
long | nOptions | ||
) |
Decrypt and authenticate input using specified AEAD algorithm in one-off operation.
All the input and output parameters are in byte arrays. The authentication tag is specified separately.
[out] | lpOutput | byte array of sufficient length to receive the plaintext output (at least as long as the input). |
[in] | nOutLen | length in bytes of the output array. |
[in] | lpData | byte array containing the input data. |
[in] | nDataLen | length of the input data in bytes. |
[in] | lpKey | byte array containing the key of exact length for given algorithm (currently either 16 or 32 bytes). |
[in] | nKeyLen | length of the key in bytes. |
[in] | lpNonce | containing the nonce of exact length for the given algorithm (currently always 12 bytes). |
[in] | nNonceLen | length of the nonce in bytes. |
[in] | lpAAD | byte array containing the optional Additional Authenticated Data (AAD). |
[in] | nAadLen | length of the AAD in bytes. |
[in] | lpTag | byte array containing the tag. |
[in] | nTagLen | length of the tag in bytes. |
[in] | nOptions | option flags. Select one of the following:API_AEAD_AES_128_GCM to use the AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_AES_256_GCM to use the AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_CHACHA20_POLY1305 to use the AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539) |
AUTH_FAILED_ERROR
and the decrypted output should be rejected. Note that the term "IV" is used here to mean exactly the same as "nonce". For more details of AEAD see Authenticated Encryption with Additional Data (AEAD). long AEAD_DecryptWithTag | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpNonce, | ||
long | nNonceLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
long | nOptions | ||
) |
Decrypt and authenticate input using specified AEAD algorithm in one-off operation.
All the input and output parameters are in byte arrays. The authentication tag is expected to be appended to the input ciphertext.
[out] | lpOutput | buffer of sufficient length to receive the plaintext output. |
[in] | nOutLen | length in bytes of the output buffer. |
[in] | lpInput | byte array containing the input data. |
[in] | nInputLen | length of the input data in bytes. |
[in] | lpKey | byte array containing the key of exact length for given algorithm (currently either 16 or 32 bytes). |
[in] | nKeyLen | length of the key in bytes. |
[in] | lpNonce | (optional) initialization vector (IV), a.k.a. nonce, if not provided in input. |
[in] | nNonceLen | length of the nonce in bytes. |
[in] | lpAAD | byte array containing the optional Additional Authenticated Data (AAD). |
[in] | nAadLen | length of the AAD in bytes. |
[in] | nOptions | option flags. Select one of the following:API_AEAD_AES_128_GCM to use the AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_AES_256_GCM to use the AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_CHACHA20_POLY1305 to use the AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539)API_AEAD_ASCON_128 to use the ASCON-128 authentication scheme (see ASCON) (provisional, subject to NIST final approval)API_AEAD_ASCON_128A to use the ASCON-128A authentication scheme (provisional, subject to NIST final approval)and optionally add: API_IV_PREFIX to expect the IV (nonce) to be prepended at the start of the input. |
The input is expected to be the ciphertext with a 16-byte tag appended ciphertext||Tag
, or, if the API_IV_PREFIX
option is set, then the same but with the 12/16-byte IV (nonce) prepended IV||ciphertext||Tag
, where ||
denotes concatenation. If the IV is not prepended to the input, then it must be provided in the lpNonce argument. The length of the nonce/IV must be exactly 16 bytes for API_AEAD_ASCON_128
, otherwise exactly 12 bytes. Note that the term "IV" is used here to mean exactly the same as "nonce". If additional authentication data (AAD) was provided during encryption then the exact same AAD data must be provided here.
Algorithm | keyLen | ivLen | tagLen |
---|---|---|---|
API_AEAD_AES_128_GCM | 16 | 12 | 16 |
API_AEAD_AES_256_GCM | 32 | 12 | 16 |
API_AEAD_CHACHA20_POLY1305 | 32 | 12 | 16 |
API_AEAD_ASCON_128 | 16 | 16 | 16 |
API_AEAD_ASCON_128A | 16 | 16 | 16 |
The output plaintext is always exactly the same length as the input ciphertext (excluding any IV or tags in the input). If nOutBytes is set to zero or lpOutput set to 0 (or NULL
in C or ByVal 0&
in VBA), the required number of bytes will be returned. This will be either exactly 16 bytes shorter than the length of the input, or 28/32 bytes shorter if the API_IV_PREFIX
option is used.
If the inputs are not authentic, the function returns the error code AUTH_FAILED_ERROR
and the decrypted output should be rejected.
The output buffer lpOutput must not be the same as or overlap with the input lpInput.
long AEAD_Destroy | ( | long | hContext | ) |
Closes the AEAD context and destroys the key (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
long AEAD_Encrypt | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
unsigned char * | lpTagOut, | ||
long | nTagLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpNonce, | ||
long | nNonceLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
long | nOptions | ||
) |
Encrypt input using specified AEAD algorithm in one-off operation.
All the input and output parameters are in byte arrays. The authentication tag is output separately.
[out] | lpOutput | byte array of sufficient length to receive the output. |
[in] | nOutLen | length in bytes of the output buffer. |
[out] | lpTagOut | byte array of sufficient length to receive the tag (currently 16 bytes for all supported algorithms). |
[in] | nTagLen | length in bytes of the tag array. |
[in] | lpData | byte array containing the input data. |
[in] | nDataLen | length in bytes of the input data. |
[in] | lpKey | byte array containing the key of exact length for given algorithm (currently either 16 or 32 bytes). |
[in] | nKeyLen | length of the key in bytes. |
[in] | lpNonce | containing the nonce (IV) of exact length for the given algorithm (currently always 12 bytes). |
[in] | nNonceLen | length of the nonce in bytes. |
[in] | lpAAD | byte array containing the optional Additional Authenticated Data (AAD). |
[in] | nAadLen | length of the AAD in bytes. |
[in] | nOptions | option flags. Must be one of the following:API_AEAD_AES_128_GCM to use the AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_AES_256_GCM to use the AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_CHACHA20_POLY1305 to use the AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539) |
AEAD_EncryptWithTag
.To compute a message authentication code (MAC) over the additional data (AAD), pass zero values for both nOutLen and nDataLen (lpOutput and lpData are ignored and may be NULL). The "message" is passed in the AAD parameter and the MAC value is output in lpTagOut. A nonce is still required.
long AEAD_EncryptWithTag | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpNonce, | ||
long | nNonceLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
long | nOptions | ||
) |
Encrypt input using specified AEAD algorithm in one-off operation with the authentication tag appended to output.
[out] | lpOutput | buffer of sufficient length to receive the output. |
[in] | nOutLen | length of the output buffer in bytes. |
[in] | lpInput | byte array containing the input data. |
[in] | nInputLen | length of the input data in bytes. |
[in] | lpKey | byte array containing the key. |
[in] | nKeyLen | length of the key in bytes (must be either 16 or 32). |
[in] | lpNonce | (required) initialization vector (IV), a.k.a. nonce. |
[in] | nNonceLen | length of the nonce in bytes (must be either 12 or 16). |
[in] | lpAAD | (optional) additional authenticated data (AAD). |
[in] | nAadLen | length of the AAD in bytes. |
[in] | nOptions | option flags. Must be one of the following:API_AEAD_AES_128_GCM to use the AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_AES_256_GCM to use the AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_CHACHA20_POLY1305 to use the AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539)API_AEAD_ASCON_128 to use the ASCON-128 authentication scheme (see ASCON) (provisional, subject to NIST final approval)API_AEAD_ASCON_128A to use the ASCON-128A authentication scheme (provisional, subject to NIST final approval)and optionally add: API_IV_PREFIX to prepend the IV (nonce) before the ciphertext in the output. |
API_IV_PREFIX
option flag. Note that the term "IV" is used here to mean exactly the same as "nonce".The length of key lpKey must be exactly the required key size in bytes: 16 for API_AEAD_AES_128_GCM
and API_AEAD_ASCON_128
; or 32 for API_AEAD_AES_256_GCM
and API_AEAD_CHACHA20_POLY1305
. It is an error if the algorithm is not specified in the nOptions argument. The length of the nonce/IV must be exactly 16 bytes for API_AEAD_ASCON_128
, otherwise exactly 12 bytes. The user is responsible for providing a unique IV each time the same key is used. Be aware it is a serious security risk if the same IV and key are used to encrypt different plaintexts.
Algorithm | keyLen | ivLen | tagLen |
---|---|---|---|
API_AEAD_AES_128_GCM | 16 | 12 | 16 |
API_AEAD_AES_256_GCM | 32 | 12 | 16 |
API_AEAD_CHACHA20_POLY1305 | 32 | 12 | 16 |
API_AEAD_ASCON_128 | 16 | 16 | 16 |
API_AEAD_ASCON_128A | 16 | 16 | 16 |
If nOutBytes is set to zero or lpOutput set to 0 (or NULL
in C or ByVal 0&
in VBA), the required number of bytes will be returned. This will be either exactly tagLen (16) bytes longer than the length of the input, or exactly tagLen+ivLen (28/32) bytes longer if the API_IV_PREFIX
option is used.
The output buffer lpOutput must not be the same as or overlap with the input lpInput.
long AEAD_FinishDecrypt | ( | long | hContext | ) |
Finishes the authenticated decryption (in incremental mode) .
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
AUTH_FAILED_ERROR
(-40) if the inputs are not authentic. Must be preceded by AEAD_StartDecrypt
and zero or more calls to AEAD_Update
. May be followed by AEAD_SetNonce
to begin processing another packet with the same key and algorithm; otherwise should be followed by AEAD_Destroy
. Returns MISUSE_ERROR
if called out of sequence. long AEAD_FinishEncrypt | ( | long | hContext, |
unsigned char * | lpTagOut, | ||
long | nTagLen | ||
) |
Finishes the authenticated encryption (in incremental mode) .
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
[out] | lpTagOut | byte array of sufficient length to receive the tag (currently 16 bytes for all supported algorithms). |
[in] | nTagLen | specifying the length in bytes of the tag array. |
AEAD_StartEncrypt
and zero or more calls to AEAD_Update
. May be followed by AEAD_SetNonce
to begin processing another packet with the same key and algorithm; otherwise should be followed by AEAD_Destroy
. Returns MISUSE_ERROR
if called out of sequence. long AEAD_InitKey | ( | const unsigned char * | lpKey, |
long | nKeyLen, | ||
long | nOptions | ||
) |
Initializes the context with the key and algorithm ready for repeated incremental operations.
[in] | lpKey | byte array containing the key of exact length for given algorithm (currently either 16 or 32 bytes). |
[in] | nKeyLen | equal to length of the key in bytes. |
[in] | nOptions | option flags. Select one of the following:API_AEAD_AES_128_GCM to use the AEAD_AES_128_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_AES_256_GCM to use the AEAD_AES_256_GCM authenticated encryption algorithm (RFC 5116)API_AEAD_CHACHA20_POLY1305 to use the AEAD_CHACHA20_POLY1305 authenticated encryption algorithm (RFC 7539) |
AEAD_SetNonce
. This function can be called at any time to cancel any previous context settings. Note that a zero return value indicates an error: Use API_ErrorCode
to find more details of the error. For more details of the correct sequence to call the incremental AEAD functions, see Correct sequence for AEAD incremental functions. long AEAD_SetNonce | ( | long | hContext, |
const unsigned char * | lpNonce, | ||
long | nNonceLen | ||
) |
Set the nonce (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
[in] | lpNonce | containing the nonce of exact length for the given algorithm (currently always 12 bytes). |
[in] | nNonceLen | equal to length of the nonce in bytes. |
AEAD_AddAAD
and then either AEAD_StartEncrypt
or AEAD_StartDecrypt
. Returns MISUSE_ERROR
if called out of sequence. long AEAD_StartDecrypt | ( | long | hContext, |
const unsigned char * | lpTagToCheck, | ||
long | nTagLen | ||
) |
Start authenticated decryption (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
[in] | lpTagToCheck | byte array containing the tag to be checked. |
[in] | nTagLen | equal to length of the tag in bytes. |
AEAD_Update
to decrypt data in chunks. Must eventually be followed by AEAD_FinishDecrypt
. Returns MISUSE_ERROR
if called out of sequence. Caution: do not trust decrypted data until final authentication. long AEAD_StartEncrypt | ( | long | hContext | ) |
Start authenticated encryption (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
AEAD_Update
to encrypt data in chunks. Must eventually be followed by AEAD_FinishEncrypt
. Returns MISUSE_ERROR
if called out of sequence. long AEAD_Update | ( | long | hContext, |
unsigned char * | lpOutput, | ||
long | nOutLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Encrypts or decrypts a chunk of input (in incremental mode).
[in] | hContext | handle to the AEAD context set up by an earlier call to AEAD_InitKey . |
[out] | lpOutput | byte array of sufficient length to receive the output (at least as long as the input). |
[in] | nOutLen | specifying the length in bytes of the output array. |
[in] | lpData | byte array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
The input data is encrypted or decrypted depending on the start mode set by a preceding call to AEAD_StartEncrypt
or AEAD_StartDecrypt
, respectively.
It must eventually be followed by either AEAD_FinishEncrypt
or AEAD_FinishDecrypt
, which must match the start mode.
Returns MISUSE_ERROR
if called out of sequence.
long AES128_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey must also represent exactly 16 bytes, the required key length. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long AES128_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
This function is equivalent to
nRet = AES128_BytesMode(lpOutput, abData, nDataLen, abKey, bEncrypt, "ECB", 0)
long AES128_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes using a specified mode.
The key and IV data are in byte arrays.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) for ECB mode. |
0
). The output array lpOutput must be at least as long as the input array. lpOutput and lpData may be the same. long AES128_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long AES128_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per AES128_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
AES128_File
. The options are ignored if not applicable. For more information on the behaviour of the options, see Extensions to block cipher functions for files. long AES128_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
""
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long AES128_Final | ( | long | hContext | ) |
Closes and clears the AES context.
[in] | hContext | containing the handle to the AES context. |
long AES128_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
This function is equivalent to
nRet = AES128_HexMode(strOutput, strInput, strHexKey, bEncrypt, "ECB", 0)
long AES128_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hex characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""
). The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
long AES128_Init | ( | const unsigned char * | lpKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are in byte arrays.
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector, or zero (0) for ECB mode. |
0
). Unlike most other functions in this API, AES128_Init
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function. long AES128_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to AES128_Init or AES128_InitHex.
long AES128_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are passed in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hexadecimal characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""
). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, AES128_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function.
long AES128_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES128_Init() or AES128_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES128_Init() or AES128_InitHex() . |
[in,out] | lpData | array containing the input to be processed by the AES function and to receive the output. |
[in] | nDataLen | containing length of the data in bytes. |
long AES128_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES128_Init() or AES128_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES128_Init() or AES128_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the AES function and to receive the output. |
If not, an error code will be returned. Valid hexadecimal characters are [0-9A-Fa-f]. Note that the output overwrites the input. szHexString must be a variable that can receive the output, not a constant.
long AES192_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey must represent exactly 24 bytes, the required key length. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long AES192_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
This function is equivalent to
nRet = AES192_BytesMode(lpOutput, abData, nDataLen, abKey, bEncrypt, "ECB", 0)
long AES192_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes using a specified mode.
The key and IV data are in byte arrays.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) for ECB mode. |
0
). The output array lpOutput must be at least as long as the input array. lpOutput and lpData may be the same. long AES192_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long AES192_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode with extended options.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per AES192_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
long AES192_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
""
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long AES192_Final | ( | long | hContext | ) |
Closes and clears the AES context.
[in] | hContext | containing the handle to the AES context. |
long AES192_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
This function is equivalent to
nRet = AES192_HexMode(strOutput, strInput, strHexKey, bEncrypt, "ECB", 0)
long AES192_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hex characters long (i.e. representing the block size of exactly 16 bytes), except for ECB mode, where it is ignored (use ""
). The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
long AES192_Init | ( | const unsigned char * | lpKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are in byte arrays.
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector, or zero (0) for ECB mode. |
0
). Unlike most other functions in this API, AES192_Init
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function. long AES192_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to AES192_Init or AES192_InitHex.
long AES192_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are passed in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hexadecimal characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""
). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, AES192_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function.
long AES192_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES192_Init() or AES192_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES192_Init() or AES192_InitHex() . |
[in,out] | lpData | array containing the input to be processed by the AES function and to receive the output. |
[in] | nDataLen | containing length of the data in bytes. |
long AES192_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES192_Init() or AES192_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES192_Init() or AES192_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the AES function and to receive the output. |
If not, an error code will be returned. Valid hexadecimal characters are [0-9A-Fa-f]. Note that the output overwrites the input. szHexString must be a variable that can receive the output, not a constant.
long AES256_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey must represent exactly 32 bytes, the required key length. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long AES256_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
This function is equivalent to
nRet = AES256_BytesMode(lpOutput, abData, nDataLen, abKey, bEncrypt, "ECB", 0)
long AES256_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes using a specified mode.
The key and IV data are in byte arrays.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) for ECB mode. |
0
). The output array lpOutput must be at least as long as the input array. lpOutput and lpData may be the same. long AES256_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long AES256_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode with extended options.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per AES256_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
AES256_File
. The options are ignored if not applicable. For more information on the behaviour of the options, see Extensions to block cipher functions for files. long AES256_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
""
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long AES256_Final | ( | long | hContext | ) |
Closes and clears the AES context.
[in] | hContext | containing the handle to the AES context. |
long AES256_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
This function is equivalent to
nRet = AES256_HexMode(strOutput, strInput, strHexKey, bEncrypt, "ECB", 0)
long AES256_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hex characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""
). The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].
long AES256_Init | ( | const unsigned char * | lpKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are in byte arrays.
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector, or zero (0) for ECB mode. |
0
). Unlike most other functions in this API, AES256_Init
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function. long AES256_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to AES256_Init or AES256_InitHex.
long AES256_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the AES function.
The key and IV data are passed in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 128-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector in hexadecimal. |
The initialization vector szHexIV must be exactly 32 hexadecimal characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""
). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, AES256_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function.
long AES256_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the AES transformation function on a byte array according to the direction and mode set up by an earlier call to AES256_Init() or AES256_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES256_Init() or AES256_InitHex() . |
[in,out] | lpData | array containing the input to be processed by the AES function and to receive the output. |
[in] | nDataLen | containing length of the data in bytes. |
long AES256_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the AES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to AES256_Init() or AES256_InitHex().
[in] | hContext | handle to the AES context set up by an earlier call to AES256_Init() or AES256_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the AES function and to receive the output. |
If not, an error code will be returned. Valid hexadecimal characters are [0-9A-Fa-f]. Note that the output overwrites the input. szHexString must be a variable that can receive the output, not a constant.
long API_CompileTime | ( | char * | szOutput, |
long | nMaxChars | ||
) |
Retrieves the date and time the core library executable was last compiled.
[out] | szOutput | to receive the date and time string. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
long API_ErrorCode | ( | void | ) |
Returns the error code of the error that occurred when calling the last function.
long API_ErrorLookup | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nErrCode | ||
) |
Retrieves the error message associated with a given error code.
[out] | szOutput | to receive error message. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | nErrCode | specifying the error code for which the message is required. |
long API_LicenceType | ( | long | nOptions | ) |
Returns the ASCII value of the licence type.
[in] | nOptions | not used in this release. Specify zero. |
long API_ModuleInfo | ( | char * | szOutput, |
long | nOutChars, | ||
long | nOptions | ||
) |
Get additional information about the core DLL module.
[out] | szOutput | Buffer to receive output string. |
[in] | nOutChars | Maximum length of output string in bytes. |
[in] | nOptions | option flags: not used in this release. Specify zero. |
long API_ModuleName | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nOptions | ||
) |
Retrieves the name of the current process's module.
[out] | szOutput | to receive the name of the module. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | nOptions | option flags: API_GEN_PLATFORM to get the platform name, either "Win32" or "X64". |
long API_Platform | ( | char * | szOutput, |
long | nOutChars | ||
) |
Gets the platform the core DLL was compiled for.
[out] | szOutput | to receive output, either "Win32" or "X64". |
[in] | nOutChars | specifying the maximum length of the string to be copied. |
long API_PowerUpTests | ( | long | nOptions | ) |
Carries out on demand the full set of power-up tests automatically performed by the toolkit when first powered up (i.e.
when the DLL is first attached to the process).
[in] | nOptions | option flags: not used in this release. Specify zero. |
long API_Version | ( | void | ) |
Retrieves the release version number.
long BLF_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey can represent up to 56 bytes. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long BLF_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
long | keyBytes, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | keyBytes | equal to length of the key in bytes. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long BLF_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
long | keyBytes, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes using a specified mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | keyBytes | equal to length of the key in bytes. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
long BLF_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
long | keyBytes, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | keyBytes | containing the length of the key in bytes. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
). The key array lpKey can be any length between 1 and 56 bytes (448 bits).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long BLF_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
long | keyBytes, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode with extended options.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | keyBytes | containing the length of the key in bytes. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per BLF_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
BLF_File
. The options are ignored if not applicable. For more information on the behaviour of the options, see Extensions to block cipher functions for files. long BLF_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | sHexIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | sHexIV | containing the initialization vector (IV) in hexadecimal. |
ECB
, in which case szHexIV is ignored (use ""
). The key szKey can be any even length between 2 and 112 hexadecimal characters. Valid hexadecimal characters are [0-9A-Fa-f].The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long BLF_Final | ( | long | hContext | ) |
Closes and clears the BLF context.
[in] | hContext | containing the handle to the BLF context. |
BLF_Init()
or BLF_InitHex()
. long BLF_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long BLF_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
ECB
, in which case szIV is ignored (use ""
). The key szKey can be any even length between 2 and 112 hexadecimal characters. Valid hexadecimal characters are [0-9A-Fa-f]. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long BLF_Init | ( | const unsigned char * | lpKey, |
long | keyBytes, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the BLF_Update or BLF_UpdateHex functions.
The key and IV data are provided in byte arrays.
[in] | lpKey | array containing the key. |
[in] | keyBytes | containing the length of the key in bytes. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
). The key array lpKey can be any length between 1 and 56 bytes (448 bits).Unlike most other functions in this API, BLF_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling BLF_Update
or BLF_UpdateHex
.
long BLF_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to BLF_Init or BLF_InitHex.
long BLF_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | sHexIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the BLF_Update or BLF_UpdateHex functions.
The key and IV data are in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | sHexIV | containing the initialization vector in hexadecimal. |
ECB
, in which case szIV is ignored (use ""
). The key szKey can be any even length between 2 and 112 hexadecimal characters. Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, BLF_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling BLF_Update
or BLF_UpdateHex
. long BLF_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the Blowfish transformation function on a byte array according to the direction and mode set up by an earlier call to BLF_Init() or BLF_InitHex().
[in] | hContext | handle to the BLF context set up by an earlier call to BLF_Init() or BLF_InitHex() . |
[in,out] | lpData | array containing the input to be processed by the BLF function and to receive the output. |
[in] | nDataLen | containing length of the data in bytes. |
long BLF_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the Blowfish transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to BLF_Init() or BLF_InitHex().
[in] | hContext | handle to the BLF context set up by an earlier call to BLF_Init() or BLF_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the BLF function and to receive the output. |
long CIPHER_DecryptBytes | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Decrypts data in a byte array using the specified block cipher algorithm, mode and padding.
The key and initialization vector are passed as byte arrays.
[out] | lpOutput | array of sufficient length to receive the output (must be at least as long as the input, see ** in remarks)). |
[in] | nOutBytes | specifying the length of the output buffer in bytes. |
[in] | lpInput | array containing the input data. |
[in] | nInputLen | specifying the length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | the length of the key in bytes. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) or NULL for ECB mode. |
[in] | nIvLen | the length of the IV in bytes. |
[in] | szAlgModePad | containing the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to expect the IV to be prepended at the start of the file (ignored for ECB mode). |
The length of key lpKey must be exactly the required key size, and the length of the IV, if required, exactly the block size. See Valid key and block sizes.
[New in v5.4] You can find the required output length in bytes by setting nOutBytes to zero or lpOutput to 0 (or NULL
in C or ByVal 0&
in VBA). For ECB and CBC cipher modes, the return value will be the exact length of plaintext after padding has been removed (or a negative error code).
** For ECB and CBC cipher modes, any padding must be removed. To specify the length of lpOutput you can either
NULL
to find the exact decrypted length. See the examples below. In both cases you may need to cope with the special case where the encrypted output is the empty string, a zero-length byte array.
It is an error (DECRYPT_ERROR
) if the padding bytes after decryption are not as expected according to the padding method specified. If the cipher mode is ECB or CBC, it is an error (BAD_LENGTH_ERROR
) if the length of the input is not an exact multiple of the block size. The input buffer lpInput may point to the same location as the output buffer. If so, the input ciphertext data will be overwritten by the output (and the user must truncate to remove any padding bytes).
Defaults: If padding is not specified then the default padding method depends on the cipher mode: pkcs5padding
will be used for ECB and CBC mode and nopadding
for all other modes. The default cipher mode is ECB
. Thus "aes128"
is the same as "aes128/ecb/pkcs5padding"
.
long CIPHER_DecryptHex | ( | char * | szOutput, |
long | nOutChars, | ||
const char * | szInputHex, | ||
const char * | szKeyHex, | ||
const char * | szIvHex, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Decrypt data using the specified block cipher algorithm, mode and padding.
The input data, key and initialization vector are all represented as hexadecimal strings.
[out] | szOutput | string buffer of sufficient length to receive the output. |
[in] | nOutChars | maximum number of characters to be received. |
[in] | szInputHex | the input data in hex format. |
[in] | szKeyHex | the key in hex format. |
[in] | szIvHex | the initialization vector (IV) in hex format, ignored for ECB mode or if API_IV_PREFIX is used (use "" ). |
[in] | szAlgModePad | string specifying the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to expect the IV to be prepended before the ciphertext in the input (not applicable for ECB mode). |
This is the equivalent of CIPHER_DecryptBytes
with all parameters passed as hex-encoded strings instead of byte arrays.
Any padding will be removed after decryption.
If the API_IV_PREFIX
option is used, the IV will be expected prepended to the ciphertext in the input.
The algorithm/mode/padding must be specified using either the szAlgModePad string or nOptions parameter, but not both (see Specifying the algorithm, mode and padding for generic block cipher functions).
It is an error (BAD_PARAM_ERROR
) to pass the empty string ""
as input in szInputHex. The output buffer strOutput should not be the same as the input strInputHex.
CAUTION: be aware of the special case where the output is the empty string ""
of length zero.
long CIPHER_EncryptBytes | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Encrypts data in a byte array using the specified block cipher algorithm, mode and padding.
The key and initialization vector are passed as byte arrays.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | nOutBytes | specifying the length of the output buffer in bytes. |
[in] | lpInput | array containing the input data. |
[in] | nInputLen | specifying the length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | the length of the key in bytes. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) or NULL for ECB mode. |
[in] | nIvLen | the length of the IV in bytes. |
[in] | szAlgModePad | containing the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to prepend the IV before the ciphertext in the output (ignored for ECB mode). |
The algorithm/mode/padding must be specified using either the szAlgModePad string or nOptions parameter, but not both (see Specifying the algorithm, mode and padding for generic block cipher functions).
The length of key lpKey must be exactly the required key size, and the length of the IV, if required, exactly the block size. See Valid key and block sizes.
If nOutBytes is set to zero or lpOutput set to 0 (or NULL
in C or ByVal 0&
in VBA), the required number of bytes will be returned. If the NoPadding
option is specified, the required output length will be the same as the input.
Defaults: If padding is not specified then the default padding method depends on the cipher mode: pkcs5padding
will be used for ECB and CBC mode and nopadding
for all other modes. The default cipher mode is ECB
. Thus "aes128"
is the same as "aes128/ecb/pkcs5padding"
.
Note that padding is only needed for ECB or CBC mode where the input length is not a multiple of the block size. It is an error (BAD_LENGTH_ERROR
) to specify NoPadding
with ECB or CBC mode if the length of the input is not an exact multiple of the block size.
The padding option is ignored for CTR, OFB and CFB modes, which do not need padding. The default nopadding
is always used for these modes regardless of what is specified (so just use the default, e.g. "aes128/ctr"
).
[New in v5.4] Use the API_IV_PREFIX
to prepend the IV before the ciphertext in the output. This will add the IV before the ciphertext in the form IV||CT
. This is the scheme used with block ciphers in XML encryption (see section 5.2 of [XMLENC]) where they use the phrase "The resulting cipher text is prefixed by the IV." It is the responsibility of the receiver to parse this data to recover the IV.
long CIPHER_EncryptHex | ( | char * | szOutput, |
long | nOutChars, | ||
const char * | szInputHex, | ||
const char * | szKeyHex, | ||
const char * | szIvHex, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Encrypt data using the specified block cipher algorithm, mode and padding.
The input data, key and initialization vector are all represented as hexadecimal strings.
[out] | szOutput | string buffer of sufficient length to receive the output. |
[in] | nOutChars | maximum number of characters to be received. |
[in] | szInputHex | the input data in hex format. |
[in] | szKeyHex | the key in hex format. |
[in] | szIvHex | the initialization vector (IV) in hex format, ignored for ECB mode (use "" ). |
[in] | szAlgModePad | string specifying the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to prepend the IV before the ciphertext in the output (ignored for ECB mode). |
This is the equivalent of CIPHER_EncryptBytes
with all parameters passed as hex-encoded strings instead of byte arrays.
Padding is added as specified to the input before encryption. The output will always be at least as long as the input, or longer if padding or a prefixed IV is to be added.
The algorithm/mode/padding must be specified using either the szAlgModePad string or nOptions parameter, but not both (see Specifying the algorithm, mode and padding for generic block cipher functions).
It is an error (BAD_PARAM_ERROR
) to pass the empty string ""
as input in szInputHex. The output buffer strOutput should not be the same as the input strInputHex.
Use the API_IV_PREFIX
option to prepend the IV before the ciphertext in the output. This will add the IV before the ciphertext in the form IV||CT
. This is the scheme used with block ciphers in XML encryption (see section 5.2 of [XMLENC]) where they use the phrase "The resulting cipher text is prefixed by the IV."
long CIPHER_FileDecrypt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Decrypts a file using specified block cipher algorithm, mode and padding.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | specifying the length of the key in bytes. |
[in] | lpIV | containing the initialization vector (IV), if required. |
[in] | nIvLen | specifying the length of the IV in bytes. |
[in] | szAlgModePad | containing the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to expect the IV to be prepended at the start of the file (ignored for ECB mode). |
The length of key must be exactly the required key size, and the length of the IV, if required, exactly the block size. See Valid key and block sizes.
The output file szFileOut will be overwritten without warning. If there is an error, the output file will not exist. The input and output files must not be the same.
Prepended IV: If the ciphertext file was created with the IV prepended at the start of the file, then you must specify the API_IV_PREFIX
option. In this case, leave the lpIV parameter empty. The input file is expected to be of the form IV||ciphertext
.
Defaults: If padding is not specified then the default padding method depends on the cipher mode: pkcs5padding
will be used for ECB and CBC mode and nopadding
for all other modes. The default cipher mode is ECB
. Thus "aes128"
is the same as "aes128/ecb/pkcs5padding"
.
Padding: When decrypting you can specify NoPadding
to leave any padding intact in the deciphered file. This is useful if you wish to examine an unknown padding scheme. Otherwise, when decrypting in ECB or CBC mode, you must specify the same padding scheme used when encrypting. It is an error (DECRYPT_ERROR
) if the expected padding string is not found after decrypting. The padding parameter is ignored when decrypting in CTR, OFB or CFB mode.
long CIPHER_FileEncrypt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const char * | szAlgModePad, | ||
long | nOptions | ||
) |
Encrypts a file using specified block cipher algorithm, mode and padding.
The IV may be prepended to the file, if required.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | specifying the length of the key in bytes. |
[in] | lpIV | containing the initialization vector (IV), if required. |
[in] | nIvLen | specifying the length of the IV in bytes. |
[in] | szAlgModePad | containing the block cipher algorithm, mode and padding (see Specifying the algorithm, mode and padding for generic block cipher functions). |
[in] | nOptions | option flags: Zero (0) for default options. Optionally add: API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode). |
The length of key must be exactly the required key size, and the length of the IV, if required, exactly the block size. See Valid key and block sizes.
The output file szFileOut will be overwritten without warning. If there is an error, the output file will not exist. The input and output files must not be the same.
Prepended IV: If the API_IV_PREFIX
option flag is set in nOptions then the IV will be prepended (i.e. added) at the start of the output file. That is, the output file will be of the form IV||ciphertext
. The API_IV_PREFIX
flag is ignored in ECB mode where an IV is not needed.
Defaults: If padding is not specified then the default padding method depends on the cipher mode: pkcs5padding
will be used for ECB and CBC mode and nopadding
for all other modes. The default cipher mode is ECB
. Thus "aes128"
is the same as "aes128/ecb/pkcs5padding"
.
Padding: In normal circumstances you should leave the padding unspecified and use the default padding when encrypting. The only time it should be required is if you want to use an exotic padding like OneAndZeroesPadding
instead of pkcs5padding
with ECB or CBC mode. Note that, unlike the behaviour with CIPHER_EncryptBytes
, it is an error (BAD_PARAM_ERROR
) to specify NoPadding
when encrypting a file with ECB or CBC mode under any circumstances. The padding option is ignored for CTR, OFB and CFB modes; that is, the default NoPadding
is always used for these modes regardless of what is specified (so just use the default, e.g. "aes128/ctr"
).
long CIPHER_Final | ( | long | hContext | ) |
Closes and clears the CIPHER context.
[in] | hContext | handle to the current CIPHER context. |
long CIPHER_Init | ( | int | fEncrypt, |
const char * | szAlgAndMode, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
long | nOptions | ||
) |
Initialize the CIPHER context with the key, iv, algorithm and mode ready for repeated update operations.
[in] | fEncrypt | Direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szAlgAndMode | String specifying the block cipher algorithm and mode, e.g. "aes128/cbc" (see Specifying the algorithm and mode for generic block cipher functions). |
[in] | lpKey | Key of exact length for block cipher algorithm. |
[in] | nKeyLen | Length of key in bytes. |
[in] | lpIV | Initialization Vector (IV) of exactly the block size, or zero (0) for ECB mode. |
[in] | nIvLen | Length of IV in bytes. |
[in] | nOptions | Option flags: zero (0) for default options. |
long CIPHER_InitHex | ( | int | fEncrypt, |
const char * | szAlgAndMode, | ||
const char * | szKeyHex, | ||
const char * | szIvHex, | ||
long | nOptions | ||
) |
Initialize the CIPHER context with hex-encoded key, iv, algorithm and mode ready for repeated update operations.
The key and IV data are passed as hexadecimal-encoded strings.
[in] | fEncrypt | Direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szAlgAndMode | String specifying the block cipher algorithm and mode, e.g. "aes128/cbc" (see Specifying the algorithm and mode for generic block cipher functions). |
[in] | szKeyHex | Hex-encoded key of exact length for block cipher algorithm. |
[in] | szIvHex | Hex-encoded Initialization Vector (IV) of exactly the block size, or "" for ECB mode. |
[in] | nOptions | Option flags: zero (0) for default options. |
CIPHER_Init
except it passes the key and IV parameters as hexadecimal-encoded strings. long CIPHER_KeyUnwrap | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKEK, | ||
long | nKekLen, | ||
long | nOptions | ||
) |
Unwraps (decrypts) a content-encryption key with a key-encryption key.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | nOutBytes | specifying the maximum length of the output array. |
[in] | lpData | array containing the input data (wrapped key). |
[in] | nDataLen | specifying the length of the input data in bytes. |
[in] | lpKEK | array containing the key encryption key. |
[in] | nKekLen | specifying the length of the key encryption key. |
[in] | nOptions | option flags: Select the key wrap algorithm from one of the following: API_BC_AES128 to use AES128-Wrap API_BC_AES192 to use AES192-Wrap API_BC_AES256 to use AES256-Wrap API_BC_3DES to use cms3DESWrap |
long CIPHER_KeyWrap | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKEK, | ||
long | nKekLen, | ||
long | nOptions | ||
) |
Wraps a content-encryption key with a key-encryption key.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | nOutBytes | specifying the maximum length of the output array. |
[in] | lpData | array containing the input data (key material). |
[in] | nDataLen | specifying the length of the input data in bytes. |
[in] | lpKEK | array containing the key encryption key. |
[in] | nKekLen | specifying the length of the key encryption key. |
[in] | nOptions | option flags: Select the key wrap algorithm from one of the following: API_BC_AES128 to use AES128-Wrap API_BC_AES192 to use AES192-Wrap API_BC_AES256 to use AES256-Wrap API_BC_3DES to use cms3DESWrap |
long CIPHER_StreamBytes | ( | unsigned char * | lpOutput, |
unsigned char * | lpData, | ||
long | nDataLen, | ||
unsigned char * | lpKey, | ||
long | nKeyLen, | ||
unsigned char * | lpIV, | ||
long | nIvLen, | ||
long | nCounter, | ||
long | nOptions | ||
) |
Enciphers data in array of bytes using specified stream cipher.
[out] | lpOutput | array of sufficient length to receive the output (at least as long as the input). |
[in] | lpData | array containing the input data. |
[in] | nDataLen | specifying the length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | specifying the length of the key in bytes. |
[in] | lpIV | array containing the initialization vector (IV, nonce), if required. |
[in] | nIvLen | specifying the length of the IV in bytes. |
[in] | nCounter | the value of the counter (ChaCha20 only). |
[in] | nOptions | option flags: Select one of the following: API_SC_ARCFOUR to use ARCFOUR (RC4)API_SC_SALSA20 to use Salsa20API_SC_CHACHA20 to use ChaCha20 |
null
for IV. long CIPHER_StreamFile | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
unsigned char * | lpIV, | ||
long | nIvLen, | ||
long | nCounter, | ||
long | nOptions | ||
) |
Enciphers data in a file using specified stream cipher.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | specifying the length of the key in bytes. |
[in] | lpIV | array containing the initialization vector (IV, nonce), if required. |
[in] | nIvLen | specifying the length of the IV in bytes. |
[in] | nCounter | the value of the counter (ChaCha20 only). |
[in] | nOptions | option flags: Select one of the following: API_SC_ARCFOUR to use ARCFOUR (RC4)API_SC_SALSA20 to use Salsa20API_SC_CHACHA20 to use ChaCha20 |
null
for IV. long CIPHER_StreamFinal | ( | long | hContext | ) |
Closes the CIPHERSTREAM context and destroys the key.
[in] | hContext | containing the handle to the CIPHERSTREAM context. |
long CIPHER_StreamHex | ( | char * | szOutput, |
long | nOutChars, | ||
const char * | szInputHex, | ||
const char * | szKeyHex, | ||
const char * | szIvHex, | ||
long | nCounter, | ||
long | nOptions | ||
) |
Enciphers data in a hex-encoded string using specified stream cipher.
[out] | szOutput | string of sufficient length to receive the output (at least as long as the input). |
[in] | nOutChars | specifying the length of the output buffer in bytes. |
[in] | szInputHex | string containing the hex-encoded input data. |
[in] | szKeyHex | string containing the hex-encoded key. |
[in] | szIvHex | string containing the hex-encoded initialization vector (IV, nonce). Specify "" for Arcfour. |
[in] | nCounter | the value of the counter (ChaCha20 only). |
[in] | nOptions | option flags: Select one of the following: API_SC_ARCFOUR to use ARCFOUR (RC4)API_SC_SALSA20 to use Salsa20API_SC_CHACHA20 to use ChaCha20 |
""
for IV. long CIPHER_StreamInit | ( | const unsigned char * | lpKey, |
long | nKeyLen, | ||
unsigned char * | lpIV, | ||
long | nIvLen, | ||
long | nCounter, | ||
long | nOptions | ||
) |
Initializes the CIPHERSTREAM context ready for repeated operations of CIPHER_StreamUpdate()
[in] | lpKey | array containing the key. |
[in] | nKeyLen | specifying the length of the key in bytes. |
[in] | lpIV | array containing the initialization vector (IV, nonce), if required. |
[in] | nIvLen | specifying the length of the IV in bytes. |
[in] | nCounter | the value of the counter (ChaCha20 only). |
[in] | nOptions | option flags: Select one of the following: API_SC_ARCFOUR to use ARCFOUR (RC4)API_SC_SALSA20 to use Salsa20API_SC_CHACHA20 to use ChaCha20 |
API_ErrorCode
to find the error code of the error that occured.null
for IV. long CIPHER_StreamUpdate | ( | long | hContext, |
unsigned char * | lpOutput, | ||
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Encrypts input using current CIPHERSTREAM context.
[in] | hContext | containing the handle to the CIPHERSTREAM context. |
[out] | lpOutput | array of sufficient length to receive the output (at least as long as the input). |
[in] | lpData | array containing the input data. |
[in] | nDataLen | specifying the length of the input data in bytes. |
long CIPHER_Update | ( | long | hContext, |
unsigned char * | lpOutput, | ||
long | nOutBytes, | ||
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Encrypts or decrypts a chunk of input (in incremental mode).
[in] | hContext | Handle to the CIPHER context. |
[out] | lpOutput | Byte array to receive output. |
[in] | nOutBytes | Length of output array in bytes. |
[in] | lpData | Input data to be processed. |
[in] | nDataLen | Length of input data in bytes. |
CIPHER_Init
or CIPHER_InitHex
.The chunks of data to be en/decrypted must be passed to the Update function in sequential order and only in lengths which are multiples of the block size (16 bytes for AES, 8 for Triple DES). For ECB and CBC modes, the last block in the sequence must be suitably padded to a length a multiple of the block size. For other modes, e.g. CTR, the last block in the sequence may be shorter than a multiple of the block length. However, once this final, shorter block has been processed, the Update function can no longer be used (well it can, but the output is wrong).
long CIPHER_UpdateHex | ( | long | hContext, |
char * | szOutput, | ||
long | nOutChars, | ||
const char * | szDataHex | ||
) |
Encrypts or decrypts a chunk of hexadecimal-encoded input (in incremental mode).
[in] | hContext | Handle to the CIPHER context. |
[out] | szOutput | String buffer to receive output. |
[in] | nOutChars | Length of output buffer in bytes. |
[in] | szDataHex | Hex-encoded input data to be processed. |
CIPHER_Update
except the input and output are hexadecimal-encoded strings. The functions CIPHER_Update
and CIPHER_UpdateHex
(and their wrappers cipherUpdate
and cipherUpdateHex
) may be used interchangeably. For more information, see the remarks section in CIPHER_Update
. long CNV_B64Filter | ( | char * | szOutput, |
const char * | szInput, | ||
long | nInStrLen | ||
) |
Removes non-base64 characters from a string.
[out] | szOutput | to receive filtered characters. |
[in] | szInput | to be filtered. |
[in] | nInStrLen | specifying the length of the input string. |
long CNV_B64StrFromBytes | ( | char * | szOutput, |
long | nMaxChars, | ||
const unsigned char * | lpInput, | ||
long | nBytes | ||
) |
Encodes an array of bytes into a base64-encoded string.
[out] | szOutput | to receive encoded data. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | lpInput | array of binary data to be encoded. |
[in] | nBytes | number of bytes to be encoded. |
long CNV_BytesFromB64Str | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const char * | szInput | ||
) |
Decodes a base64-encoded string into an array of Bytes.
[out] | lpOutput | array suitably dimensioned to receive output. |
[in] | nOutputLen | specifying the length of the byte array. |
[in] | szInput | of base64 data to be decoded. |
long CNV_BytesFromHexStr | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const char * | szInput | ||
) |
Decodes a hexadecimal-encoded string into an array of Bytes.
[out] | lpOutput | array suitably dimensioned to receive output. |
[in] | nOutputLen | specifying the length of the byte array. |
[in] | szInput | of hexadecimal data to be decoded. |
"DE:AD:BE:EF"
is OK) but obviously non-hex characters like those in the range [G-Zg-z]
will cause an error. long CNV_HexFilter | ( | char * | szOutput, |
const char * | szInput, | ||
long | nInStrLen | ||
) |
Removes non-hexadecimal characters from a string.
[out] | szOutput | to receive filtered characters. |
[in] | szInput | to be filtered. |
[in] | nInStrLen | specifying the length of the input string. |
long CNV_HexStrFromBytes | ( | char * | szOutput, |
long | nMaxChars, | ||
const unsigned char * | lpInput, | ||
long | nBytes | ||
) |
Encodes an array of bytes into a hexadecimal-encoded string.
[out] | szOutput | to receive encoded data. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | lpInput | array of binary data to be encoded. |
[in] | nBytes | number of bytes to be encoded. |
long CNV_ShortPathName | ( | char * | szOut, |
long | nOutChars, | ||
const wchar_t * | szwFilePath | ||
) |
Retrieve the Windows short path form of the specified path.
[out] | szOut | Buffer to receive output. |
[in] | nOutChars | Maximum length of output string in bytes (excluding the terminating null). |
[in] | szwFilePath | Path name in wide characters. |
wchar_t
characters. Then use this ASCII short name as an argument for an input file in any of the functions in this library that require a file name.The file must exist. The output path is guaranteed to be in ASCII characters, and the base name and each folder name will be 8 characters or fewer. It may not give the same value on a different system. Windows only.
For the "raw" function, pass a NULL szOut or zero nOutChars to find the required output length in bytes. ANSI C users must add one to this value when allocating memory.
long COMPR_Compress | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
long | nOptions | ||
) |
Compress data using compression algorithm.
[out] | lpOutput | byte buffer to receive output data. |
[in] | nOutBytes | size of the output buffer in bytes. |
[in] | lpInput | input data to be compressed. |
[in] | nInputLen | length of input array in bytes. |
[in] | nOptions | option flags. Select one of:API_COMPR_ZLIB (0) to use the zlib algorithm (default)API_COMPR_ZSTD to use the Zstandard algorithm |
long COMPR_Uncompress | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nInputLen, | ||
long | nOptions | ||
) |
Uncompress data using compression algorithm.
[out] | lpOutput | byte buffer to receive output data. |
[in] | nOutBytes | size of the output buffer in bytes. |
[in] | lpInput | input data to be uncompressed. |
[in] | nInputLen | length of input array in bytes. |
[in] | nOptions | option flags. Select one of:API_COMPR_ZLIB (0) to use the zlib algorithm (default)API_COMPR_ZSTD to use the Zstandard algorithm |
int32_t CRC_Bytes | ( | const unsigned char * | lpInput, |
long | nBytes, | ||
long | nOptions | ||
) |
Computes the CRC-32 checksum of an array of bytes.
[in] | lpInput | array of bytes containing input data. |
[in] | nBytes | specifying the number of bytes in the input. |
[in] | nOptions | option flags: not used in this release. Specify zero. |
0x04C11DB7
and is the one specified in ISO 3309 and ITU-T V.42 and used by WinZip. int32_t CRC_File | ( | const char * | szFileName, |
long | nOptions | ||
) |
Computes the CRC-32 checksum of a file.
[in] | szFileName | specifying the input file. |
[in] | nOptions | option flags: not used in this release. Specify zero. |
0x04C11DB7
and is the one specified in ISO 3309 and ITU-T V.42 and used by WinZip.A return value of zero probably indicates that the file could not be found, or that the file is empty. The chances of a file with random contents giving a CRC checksum of zero is one in 4.5 billion, but it is not difficult to construct a file with such a checksum.
int32_t CRC_String | ( | const char * | szInput, |
long | nOptions | ||
) |
Computes the CRC-32 checksum of an ANSI string.
[in] | szInput | ANSI string input. |
[in] | nOptions | option flags: not used in this release. Specify zero. |
0x04C11DB7
and is the one specified in ISO 3309 and ITU-T V.42 and used by WinZip. long DES_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey must also represent exactly 8 bytes, the required key length. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long DES_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long DES_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes in one step using a specified mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) for ECB mode. |
long DES_CheckKey | ( | const unsigned char * | lpKey, |
long | nKeyLen | ||
) |
Checks for weak or invalid-length DES or TDEA keys.
[in] | lpKey | array containing the key. |
[in] | nKeyLen | containing the length of the key in bytes. |
DES_CheckKey
verifies that the key size is valid for a single, double or triple DES key - i.e. is 8, 16 or 24 bytes long - and that no part of the key is a weak or semi-weak DES key. long DES_CheckKeyHex | ( | const char * | szHexKey | ) |
Checks for weak or invalid-length DES or TDEA keys in hexadecimal format.
[in] | szHexKey | containing the key in hexadecimal format. |
DES_CheckKey
verifies that the key size is valid for a single, double or triple DES key - i.e. is 8, 16 or 24 bytes long - and that no part of the key is a weak or semi-weak DES key. long DES_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long DES_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode with extended options.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per DES_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
DES_File
. The options are ignored if not applicable. For more information on the behaviour of the options, see Extensions to block cipher functions for files. long DES_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
ECB
, in which case szIV is ignored (use ""
).Valid hexadecimal characters are [0-9A-Fa-f].
The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long DES_Final | ( | long | hContext | ) |
Closes and clears the DES context.
[in] | hContext | containing the handle to the DES context. |
long DES_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long DES_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
ECB
, in which case szIV is ignored (use ""
). Valid hexadecimal characters are [0-9A-Fa-f]. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long DES_Init | ( | const unsigned char * | lpKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the DES function.
The key and IV data are provided in byte arrays.
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
DES_Init
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling a DES_Update function. long DES_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to DES_Init or DES_InitHex.
long DES_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the DES function.
The key and IV data are provided in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector in hexadecimal. |
""
). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, DES_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling a DES_Update function. long DES_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the DES transformation function on a byte array according to the direction and mode set up by an earlier call to DES_Init() or DES_InitHex().
[in] | hContext | handle to the DES context set up by an earlier call to DES_Init() or DES_InitHex() . |
[in,out] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
long DES_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the DES transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to DES_Init() or DES_InitHex().
[in] | hContext | handle to the DES context set up by an earlier call to DES_Init() or DES_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the DES function and to receive the output. |
long GCM_Decrypt | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
const unsigned char * | lpTag, | ||
long | nTagLen, | ||
long | nOptions | ||
) |
Decrypts authenticated ciphertext using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM).
All the input and output parameters are in byte arrays.
[out] | lpOutput | array of sufficient length to receive the ciphertext output. |
[in] | nOutLen | specifying the required length of the output in bytes. |
[in] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | equal to length of the key in bytes. Must be one of 16, 24 or 32 corresponding to the required key bytes for AES-128, AES-192 or AES-256, respectively. |
[in] | lpIV | containing the initialization vector (IV). |
[in] | nIvLen | equal to length of the IV in bytes. |
[in] | lpAAD | array containing the Additional Authenticated Data (AAD). |
[in] | nAadLen | equal to length of the AAD in bytes. |
[in] | lpTag | array containing the tag. |
[in] | nTagLen | equal to the length of the tag in bytes. |
[in] | nOptions | for future use. Specify zero. |
GCM_InitKey
- GCM_NextEncrypt
- GCM_FinishKey
instead. The output lpOutput must be at least as long as the input. The authenticated decryption operation has five inputs: the secret key, an initialization vector (IV), the ciphertext itself, the additional authentication data (AAD), which can be zero-length; and the tag. The IV and AAD are passed in the clear. There is one output: the plaintext, which is exactly the same length as the ciphertext. If the inputs are not authentic, the function returns the non-zero error code DECRYPT_ERROR
AUTH_FAIL_ERROR
.Changed in [v5.1]: Note that the error code on authentication fail has changed from
DECRYPT_ERROR
(-18) to AUTH_FAIL_ERROR
(-40).
long GCM_Encrypt | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
unsigned char * | lpTagOut, | ||
long | nTagLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpKey, | ||
long | nKeyLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
long | nOptions | ||
) |
Provides authenticated encryption using the Galois/Counter Mode (GCM) of operation with the AES algorithm (AES-GCM).
It can also provide a stand-alone message authentication code (GMAC). All the input and output parameters are in byte arrays.
[out] | lpOutput | array of sufficient length to receive the ciphertext output. |
[in] | nOutLen | specifying the required length of the output in bytes. |
[out] | lpTagOut | array of sufficient length to receive the tag, at least 4 bytes long. |
[in] | nTagLen | specifying the required length of the tag in bytes. |
[in] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyLen | equal to length of the key in bytes. Must be one of 16, 24 or 32 corresponding to the required key bytes for AES-128, AES-192 or AES-256, respectively. |
[in] | lpIV | containing the initialization vector (IV). |
[in] | nIvLen | equal to length of the IV in bytes. |
[in] | lpAAD | array containing the optional Additional Authenticated Data (AAD). |
[in] | nAadLen | equal to length of the AAD in bytes. |
[in] | nOptions | for future use. Specify zero. |
GCM_InitKey
- GCM_NextEncrypt
- GCM_FinishKey
instead. The output lpOutput must be at least as long as the input, or zero length for GMAC. There are four inputs for authenticated encryption: the secret key, an initialization vector (IV), the plaintext itself, and optional additional authentication data (AAD). The IV and AAD are passed in the clear. There are two outputs: the ciphertext, which is exactly the same length as the plaintext, and an authentication tag (the "tag"). The tag length can be any length from 4 to 16 bytes (API_MAX_GMAC_BYTES
); that is, 32 to 128 bits. You can truncate the tag value afterwards should you wish, at the cost of reduced security. The IV can, in principle, be any length, but 12 bytes (96 bits) is recommended as the algorithm is optimised for that length. The AES algorithm is decided by the length of key you pass: 16 bytes for AES-128, 24 for AES-192, 32 for AES-256; otherwise an error. See Security considerations for AEAD encryption.To produce a message authentication code (GMAC), pass an empty or null string for the plaintext input lpData and a zero length nOutLen for the output ciphertext. The "message" is passed in the AAD parameter and the GMAC value is output in the tag. A unique IV is still required.
long GCM_FinishKey | ( | long | hContext | ) |
Closes the GCM context and destroys the key.
[in] | hContext | containing the handle to the GCM context. |
long GCM_InitKey | ( | const unsigned char * | lpKey, |
long | nKeyLen, | ||
long | nOptions | ||
) |
Initializes the context with the key ready for repeated operations of GCM_NextEncrypt and GCM_NextDecrypt.
[in] | lpKey | array containing the key. |
[in] | nKeyLen | equal to length of the key in bytes. Must be one of 16, 24 or 32 corresponding to the required key bytes for AES-128, AES-192 or AES-256, respectively. |
[in] | nOptions | for future use. Specify zero. |
long GCM_NextDecrypt | ( | long | hContext, |
unsigned char * | lpOutput, | ||
long | nOutLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen, | ||
const unsigned char * | lpTag, | ||
long | nTagLen | ||
) |
Carries out the GCM authenticated decryption operation using the key set up by an earlier call to GCM_InitKey.
[in] | hContext | handle to the GCM context set up by an earlier call to GCM_InitKey. |
[out] | lpOutput | array of sufficient length to receive the ciphertext output. |
[in] | nOutLen | specifying the required length of the output in bytes. |
[in] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
[in] | lpIV | containing the initialization vector (IV). |
[in] | nIvLen | equal to length of the IV in bytes. |
[in] | lpAAD | array containing the Additional Authenticated Data (AAD). |
[in] | nAadLen | equal to length of the AAD in bytes. |
[in] | lpTag | array containing the tag. |
[in] | nTagLen | equal to the length of the tag in bytes. |
GCM_Decrypt
and the Security considerations for AEAD encryption. long GCM_NextEncrypt | ( | long | hContext, |
unsigned char * | lpOutput, | ||
long | nOutLen, | ||
unsigned char * | lpTagOut, | ||
long | nTagLen, | ||
const unsigned char * | lpData, | ||
long | nDataLen, | ||
const unsigned char * | lpIV, | ||
long | nIvLen, | ||
const unsigned char * | lpAAD, | ||
long | nAadLen | ||
) |
Carries out the GCM authenticated encryption operation using the key set up by an earlier call to GCM_InitKey.
[in] | hContext | handle to the GCM context set up by an earlier call to GCM_InitKey. |
[out] | lpOutput | array of sufficient length to receive the ciphertext output. |
[in] | nOutLen | specifying the required length of the output in bytes. |
[out] | lpTagOut | array of sufficient length to receive the tag, at least 4 bytes long. |
[in] | nTagLen | specifying the required length of the tag in bytes. |
[in] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
[in] | lpIV | containing the initialization vector (IV). |
[in] | nIvLen | equal to length of the IV in bytes. |
[in] | lpAAD | array containing the optional Additional Authenticated Data (AAD). |
[in] | nAadLen | equal to length of the AAD in bytes. |
GCM_Encrypt
and the Security considerations for AEAD encryption. long HASH_AddBytes | ( | long | hContext, |
const void * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to be digested in the HASH context.
[in] | hContext | Handle to the HASH context. |
[in] | lpData | Byte array containing the next part of the message. |
[in] | nDataLen | Number of bytes in the array |
HASH_Init
. The HASH_AddBytes
function may be called many times before creating the final message digest with HASH_Final
.VBA users can use the more convenient wrapper functions hashAddBytes
and hashAddString
.
long HASH_Bytes | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
long | nOptions | ||
) |
Creates a message digest hash as a byte array from byte data.
The hash algorithm to use is passed in the options parameter.
[out] | lpOutput | array to receive the hash digest. |
[in] | nOutLen | specifying the length in bytes of the output array. |
[in] | lpMessage | array containing the message data |
[in] | nMsgLen | specifying length of the message data in bytes. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_MD5 to use the MD5 algorithmAPI_HASH_MD2 to use the MD2 algorithm (legacy)API_HASH_RMD160 to use the RIPEMD-160 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithmAPI_HASH_ASCON_HASH to use the ASCON-HASH algorithmAPI_HASH_ASCON_HASHA to use the ASCON-HASHA algorithm |
API_MAX_HASH_BYTES
. Hint: SHA-1 requires 20 bytes; MD5 and MD2 require 16 bytes; SHA-512 requires 64. The final digest will be truncated to the specified length if less than the expected size. long HASH_DigestLength | ( | long | hContext | ) |
Returns the number of bytes in the hash output for the algorithm defined in the current HASH context.
[in] | hContext | handle to the current HASH context. |
long HASH_File | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
const char * | szFileName, | ||
long | nOptions | ||
) |
Creates a message digest hash in byte format for a file.
The hash algorithm to use is passed in the options parameter.
[out] | lpOutput | array to receive the hash digest. |
[in] | nOutLen | specifying the length in bytes of the output array. |
[in] | szFileName | containing the name of the file. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_MD5 to use the MD5 algorithmAPI_HASH_MD2 to use the MD2 algorithm (legacy)API_HASH_RMD160 to use the RIPEMD-160 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithmand add API_HASH_MODE_TEXT to hash in "text" mode instead of default "binary" mode |
API_MAX_HASH_BYTES
. The final digest will be truncated to the specified length if less than the expected size. Add the option API_HASH_MODE_TEXT
to work in "text" mode where CR-LF pairs are treated as a single newline (LF) character. Use this option to pass hash digests of text file between Windows and Unix systems. The default mode is "binary" where each byte is treated individually. Only ANSI file names and paths are supported (but see CNV_ShortPathName as a work around). Note that Ascon-Hash is not available with this function. long HASH_Final | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
long | hContext | ||
) |
Returns the final message digest value from the HASH context.
[out] | lpOutput | array to receive message digest. |
[in] | nOutLen | length in bytes of the output array. |
[in] | hContext | handle to the current HASH context. |
HASH_AddBytes
calls since HASH_Init
. Once called, the context is destroyed. long HASH_HexFromBits | ( | char * | szOutput, |
long | nMaxChars, | ||
const unsigned char * | lpData, | ||
long | nDataBitLen, | ||
long | nOptions | ||
) |
Creates a message digest hash in hexadecimal format from bit-oriented input.
The hash algorithm to use is passed in the options parameter.
[out] | szOutput | to receive hash digest in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | lpData | array containing the message data |
[in] | nDataBitLen | specifying length of the message data in bits. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithm |
For example, the byte array (0x)717F8C
with nDataBitLen=23
represents the 23-bit bitstring 0111 0001 0111 1111 1000 110
, and the byte array (0x)5180
with nDataBitLen=9
represents the 9-bit bitstring 0101 0001 1
.
The number of bytes in the array lpData must be at least ceil(nDataBitLen / 8)
. Only the SHA family of hash functions is supported in bit-oriented mode.
For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length.
Specify a zero nOutChars or an empty (""
) or NULL szOutput parameter to find out the required length of the output string (or use the appropriate API_SHAnnn_CHARS
constant). C/C++ users must add one to this value when allocating memory.
long HASH_HexFromBytes | ( | char * | szOutput, |
long | nMaxChars, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
long | nOptions | ||
) |
Creates a message digest hash in hexadecimal format from byte (or string) data.
The hash algorithm to use is passed in the options parameter.
[out] | szOutput | to receive hash digest in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | lpMessage | array containing the message data; or |
[in] | nMsgLen | specifying length of the message data in bytes. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_MD5 to use the MD5 algorithmAPI_HASH_MD2 to use the MD2 algorithm (legacy)API_HASH_RMD160 to use the RIPEMD-160 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithmAPI_HASH_ASCON_HASH to use the ASCON-HASH algorithmAPI_HASH_ASCON_HASHA to use the ASCON-HASHA algorithm |
Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory. The maximum number of characters is API_MAX_HASH_CHARS
. The final digest will be truncated to the specified length if less than the expected size. Only lower-case letters [a-f] are used in the output string.
long HASH_HexFromFile | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szFileName, | ||
long | nOptions | ||
) |
Creates a message digest hash in hexadecimal format for a file.
The hash algorithm to use is passed in the options parameter.
[out] | szOutput | to receive hash digest in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received in characters. |
[in] | szFileName | containing the name of the file. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_MD5 to use the MD5 algorithmAPI_HASH_MD2 to use the MD2 algorithm (legacy)API_HASH_RMD160 to use the RIPEMD-160 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithmand add API_HASH_MODE_TEXT to hash in "text" mode instead of default "binary" mode |
Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory. The maximum number of characters will be API_MAX_HASH_CHARS
. C/C++ users should add one to this value before allocating memory. The final digest will be truncated to the specified length if less than the expected size. Only lower-case letters [a-f] are used.
Add the option API_HASH_MODE_TEXT
to work in "text" mode where CR-LF pairs are treated as a single newline character. The default mode is "binary" where each byte is treated individually. Only ANSI file names and paths are supported (but see CNV_ShortPathName as a work around). Note that Ascon-Hash is not available with this function.
long HASH_HexFromHex | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szMsgHex, | ||
long | nOptions | ||
) |
Creates a message digest hash in hexadecimal format from data in a hexadecimal-encoded string.
The hash algorithm to use is passed in the options parameter.
[out] | szOutput | to receive hash digest in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | szMsgHex | containing the message data in hexadecimal-encoded format. |
[in] | nOptions | Option flags. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_MD5 to use the MD5 algorithmAPI_HASH_MD2 to use the MD2 algorithm (legacy)API_HASH_RMD160 to use the RIPEMD-160 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithmAPI_HASH_ASCON_HASH to use the ASCON-HASH algorithmAPI_HASH_ASCON_HASHA to use the ASCON-HASHA algorithm |
Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory. The maximum number of characters is API_MAX_HASH_CHARS
. The final digest will be truncated to the specified length if less than the expected size. Only lower-case letters [a-f] are used in the output.
long HASH_Init | ( | long | nAlg | ) |
Initialises the HASH context ready for subsequent calls with HASH_AddBytes and HASH_Final.
[in] | nAlg | Algorithm to be used. Select one of:API_HASH_SHA1 (0) to use the SHA-1 algorithm (default)API_HASH_SHA224 to use the SHA-224 algorithmAPI_HASH_SHA256 to use the SHA-256 algorithmAPI_HASH_SHA384 to use the SHA-384 algorithmAPI_HASH_SHA512 to use the SHA-512 algorithmAPI_HASH_SHA3_224 to use the SHA-3-224 algorithmAPI_HASH_SHA3_256 to use the SHA-3-256 algorithmAPI_HASH_SHA3_384 to use the SHA-3-384 algorithmAPI_HASH_SHA3_512 to use the SHA-3-512 algorithm |
HASH_AddBytes
. VBA users can use the wrapper functions hashAddBytes
and hashAddString
. long HASH_Length | ( | long | nAlgId | ) |
Return length of message digest output in bytes.
[in] | nAlgId | Algorithm Id flag. Select one of API_HASH_* :API_HASH_SHA1 SHA-1 algorithmAPI_HASH_SHA224 SHA-224 algorithmAPI_HASH_SHA256 SHA-256 algorithmAPI_HASH_SHA384 SHA-384 algorithmAPI_HASH_SHA512 SHA-512 algorithmAPI_HASH_SHA3_224 SHA-3-224 algorithmAPI_HASH_SHA3_256 SHA-3-256 algorithmAPI_HASH_SHA3_384 SHA-3-384 algorithmAPI_HASH_SHA3_512 SHA-3-512 algorithmAPI_HASH_MD5 MD5 algorithmAPI_HASH_MD2 MD2 algorithmAPI_HASH_RMD160 RIPEMD-160 algorithmAPI_HASH_ASCON_HASH ASCON-HASH algorithmAPI_HASH_ASCON_HASHA ASCON-HASHA algorithm |
long HASH_Reset | ( | long | hContext | ) |
Resets the HASH context.
[in] | hContext | handle to the HASH context. |
long MAC_AddBytes | ( | long | hContext, |
const void * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to be authenticated in the MAC context.
[in] | hContext | Handle to the MAC context. |
[in] | lpData | Byte array containing the next part of the message. |
[in] | nDataLen | Number of bytes in the array |
MAC_Init
. The MAC_AddBytes
function may be called many times before creating the final message digest with MAC_Final
.VBA users can use the more convenient wrapper functions macAddBytes
and macAddString
.
long MAC_Bytes | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
const void * | lpKey, | ||
long | nKeyLen, | ||
long | nOptions | ||
) |
Creates a keyed message authentication code (MAC) as a byte array from byte data.
The MAC algorithm to use is passed in the options parameter.
[out] | lpOutput | byte buffer to receive the MAC value. |
[in] | nOutBytes | size of output buffer in bytes. |
[in] | lpMessage | byte array containing the message (input) data |
[in] | nMsgLen | length of the input data in bytes. |
[in] | lpKey | byte array containing the key |
[in] | nKeyLen | length of the key in bytes. |
[in] | nOptions | Option flags. Select one of: HMAC algorithms: API_HMAC_SHA1 (0) to use HMAC-SHA-1 (default)API_HMAC_SHA224 to use HMAC-SHA-224API_HMAC_SHA256 to use HMAC-SHA-256API_HMAC_SHA384 to use HMAC-SHA-384API_HMAC_SHA512 to use HMAC-SHA-512API_HMAC_MD5 to use HMAC-MD5 (legacy)API_HMAC_RMD160 to use HMAC-RIPEMD160API_HMAC_SHA3_224 to use HMAC-SHA3-224API_HMAC_SHA3_256 to use HMAC-SHA3-256API_HMAC_SHA3_384 to use HMAC-SHA3-384API_HMAC_SHA3_512 to use HMAC-SHA3-512CMAC algorithms: API_CMAC_TDEA to use the Triple DES (DES-EDE) block cipherAPI_CMAC_AES128 to use the AES-128 block cipherAPI_CMAC_AES192 to use the AES-192 block cipherAPI_CMAC_AES256 to use the AES-256 block cipherOther: API_MAC_POLY1305 to use the Poly1305 algorithm [New in v5.0]API_KMAC_128 to use KMAC128 with a fixed-length output of 256 bits (32 bytes) [New in v5.3]API_KMAC_256 to use KMAC256 with a fixed-length output of 512 bits (64 bytes) [New in v5.3] |
API_MAX_MAC_BYTES
. The final MAC value will be truncated to the specified length if less than the expected size (except for KMAC which must not be truncated).To use KMAC with variable-length output or a customization string, use PRF_Bytes
.
long MAC_CodeLength | ( | long | hContext | ) |
Returns the number of bytes in the output for the algorithm defined in the current MAC context.
[in] | hContext | handle to the current MAC context. |
long MAC_Final | ( | unsigned char * | lpOutput, |
long | nOutLen, | ||
long | hContext | ||
) |
Returns the final message digest value from the MAC context.
[out] | lpOutput | array to receive message digest. |
[in] | nOutLen | length in bytes of the output array. |
[in] | hContext | handle to the current MAC context. |
MAC_AddBytes
calls since MAC_Init
. Once called, the context is destroyed. long MAC_HexFromBytes | ( | char * | szOutput, |
long | nMaxChars, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
const void * | lpKey, | ||
long | nKeyLen, | ||
long | nOptions | ||
) |
Creates a keyed-hash based message authentication code (HMAC) in hexadecimal format from byte data.
The hash algorithm to use is passed in the options parameter.
[out] | szOutput | to receive output in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | lpMessage | array containing the message data in a byte array |
[in] | nMsgLen | specifying length of the message data in bytes. |
[in] | lpKey | array containing the key in a byte array |
[in] | nKeyLen | specifying length of the key in bytes. |
[in] | nOptions | Option flags. Select one of: HMAC algorithms: API_HMAC_SHA1 (0) to use the SHA-1 hash algorithm (default)API_HMAC_SHA224 to use the SHA-224 algorithmAPI_HMAC_SHA256 to use the SHA-256 algorithmAPI_HMAC_SHA384 to use the SHA-384 algorithmAPI_HMAC_SHA512 to use the SHA-512 algorithmAPI_HMAC_MD5 to use the MD5 algorithmAPI_HMAC_RMD160 to use the RIPEMD-160 algorithmAPI_HMAC_SHA3_224 to use the SHA-3-224 algorithmAPI_HMAC_SHA3_256 to use the SHA-3-256 algorithmAPI_HMAC_SHA3_384 to use the SHA-3-384 algorithmAPI_HMAC_SHA3_512 to use the SHA-3-512 algorithmCMAC algorithms: API_CMAC_TDEA to use the Triple DES (DES-EDE) block cipherAPI_CMAC_AES128 to use the AES-128 block cipherAPI_CMAC_AES192 to use the AES-192 block cipherAPI_CMAC_AES256 to use the AES-256 block cipherOther: API_MAC_POLY1305 to use the Poly1305 algorithm [New in v5.0]API_KMAC_128 to use KMAC128 with a fixed-length output of 256 bits (32 bytes) [New in v5.3]API_KMAC_256 to use KMAC256 with a fixed-length output of 512 bits (64 bytes) [New in v5.3] |
Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory. The maximum number of characters is API_MAX_MAC_CHARS
. The final digest will be truncated to the specified length if less than the expected size (except for KMAC which must not be truncated).
long MAC_HexFromHex | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szMsgHex, | ||
const char * | szKeyHex, | ||
long | nOptions | ||
) |
Creates a message authentication code (MAC) in hexadecimal format from hex-encoded data and a hex-encoded key.
The MAC algorithm to use is passed in the options parameter.
[out] | szOutput | to receive output in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of characters to be received. |
[in] | szMsgHex | array containing the message data in hexadecimal-encoded format. |
[in] | szKeyHex | array containing the key in hexadecimal-encoded format. |
[in] | nOptions | Option flags. Select one of: HMAC algorithms: API_HMAC_SHA1 (0) to use the SHA-1 hash algorithm (default)API_HMAC_SHA224 to use the SHA-224 algorithmAPI_HMAC_SHA256 to use the SHA-256 algorithmAPI_HMAC_SHA384 to use the SHA-384 algorithmAPI_HMAC_SHA512 to use the SHA-512 algorithmAPI_HMAC_MD5 to use the MD5 algorithmAPI_HMAC_RMD160 to use the RIPEMD-160 algorithmAPI_HMAC_SHA3_224 to use the SHA-3-224 algorithmAPI_HMAC_SHA3_256 to use the SHA-3-256 algorithmAPI_HMAC_SHA3_384 to use the SHA-3-384 algorithmAPI_HMAC_SHA3_512 to use the SHA-3-512 algorithmCMAC algorithms: API_CMAC_TDEA to use the Triple DES (DES-EDE) block cipherAPI_CMAC_AES128 to use the AES-128 block cipherAPI_CMAC_AES192 to use the AES-192 block cipherAPI_CMAC_AES256 to use the AES-256 block cipherOther: API_MAC_POLY1305 to use the Poly1305 algorithm [New in v5.0]API_KMAC_128 to use KMAC128 with a fixed-length output of 256 bits (32 bytes) [New in v5.3]API_KMAC_256 to use KMAC256 with a fixed-length output of 512 bits (64 bytes) [New in v5.3] |
Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory. The maximum number of characters is API_MAX_MAC_CHARS
.
The final digest will be truncated to the specified length if less than the expected size (except for KMAC which must not be truncated).
long MAC_Init | ( | const void * | lpKey, |
long | nKeyLen, | ||
long | nAlg | ||
) |
Initialises the MAC context ready for subsequent calls with MAC_AddBytes and MAC_Final.
[in] | lpKey | Key in byte format. |
[in] | nKeyLen | Length of key in bytes. |
[in] | nAlg | Algorithm to be used. Select one of:API_HMAC_SHA1 (0) to use the HMAC-SHA-1 algorithm (default)API_HMAC_SHA224 to use the HMAC-SHA-224 algorithmAPI_HMAC_SHA256 to use the HMAC-SHA-256 algorithmAPI_HMAC_SHA384 to use the HMAC-SHA-384 algorithmAPI_HMAC_SHA512 to use the HMAC-SHA-512 algorithm |
MAC_AddBytes
. VBA users can use the wrapper functions macAddBytes
and macAddString
. long MAC_Reset | ( | long | hContext | ) |
Resets the MAC context.
[in] | hContext | handle to the MAC context. |
long MD5_AddBytes | ( | long | hContext, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to the digest.
[in] | hContext | handle to the MD5 context. |
[in] | lpData | array containing the next part of the message to be hashed. |
[in] | nDataLen | containing the number of bytes in the array |
MD5_Init
. This function may be called many times before creating the final message digest with MD5_HexDigest
. MD5_AddString
may also be called. long MD5_AddString | ( | long | hContext, |
const char * | szMessage | ||
) |
Adds a string of ascii characters to the digest.
[in] | hContext | handle to the MD5 context. |
[in] | szMessage | containing the next part of the message to be hashed. |
MD5_Init
. This function may be called many times before creating the final message digest with MD5_HexDigest
This function should only be used to hash "printable" strings. To hash a string that contains binary characters, such as ascii zero, use MD5_AddBytes
. long MD5_BytesHash | ( | unsigned char * | digest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates an MD5 message digest in Byte array format from a message in Byte array format.
[out] | digest | array to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
Byte
array format. This is particularly useful when you need to carry out repeated hash operations. lpDigest must be at least 16 (API_MAX_MD5_BYTES
) bytes long. long MD5_BytesHexHash | ( | char * | szDigest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates an MD5 message digest in hexadecimal format from a message in Byte array format.
[out] | szDigest | to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
API_MAX_MD5_CHARS
) characters long (33 in a C program). long MD5_FileHexHash | ( | char * | szDigest, |
const char * | szFileName, | ||
const char * | szMode | ||
) |
Creates an MD5 message digest in hexadecimal format from a file.
[out] | szDigest | to receive message digest. |
[in] | szFileName | with full path name of file. |
[in] | szMode | to set mode: "t" or "b" |
API_MAX_MD5_CHARS
) characters long (33 in a C program). Setting szMode equal to "t" or "T" will hash file in "text" mode treating a CR-LF pair as a single newline character. Setting szMode equal to "b" or "B" will hash file in "binary" mode treating CR-LF as two binary characters (default). long MD5_HexDigest | ( | char * | szDigest, |
long | hContext | ||
) |
Returns the final message digest value as a hex string.
[out] | szDigest | variable long enough to receive the final message digest. |
[in] | hContext | handle to the MD5 context. |
MD5_Init
. The string variable szDigest must have been set up with at least 32 (API_MAX_MD5_CHARS
) characters (33 in a C program) to receive the digest value in hex format. Note that this digest operation is a destructive, read-once operation. Once it has been performed, the context must be reset before being used to calculate another digest value. long MD5_Hmac | ( | char * | szDigest, |
const unsigned char * | textBytes, | ||
long | textLen, | ||
const unsigned char * | lpKeyBytes, | ||
long | keyLen | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the MD5 hash function.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | textBytes | array containing the text of the message. |
[in] | textLen | containing the number of bytes in the array |
[in] | lpKeyBytes | array containing the key. |
[in] | keyLen | containing the number of bytes in the key |
API_MAX_MD5_CHARS
) characters long (33 in a C program). long MD5_HmacHex | ( | char * | szDigest, |
const char * | szHexText, | ||
const char * | szHexKey | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the MD5 hash function, passing its arguments in hexadecimal format.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | szHexText | containing the text of the message in hexadecimal format. |
[in] | szHexKey | containing the key in hexadecimal format. |
API_MAX_MD5_CHARS
) characters long (33 in a C program). szData and szKey are expected to be an even number of characters long, i.e. representing complete byte values. Any trailing odd character will be ignored. long MD5_Init | ( | void | ) |
Initialises the MD5 context ready for subsequent calls with MD5_AddString, MD5_AddBytes, and MD5_HexDigest.
long MD5_Reset | ( | long | hContext | ) |
Resets the context.
[in] | hContext | handle to the SHA-1 context. |
long MD5_StringHexHash | ( | char * | szDigest, |
const char * | szMessage | ||
) |
Creates an MD5 message digest in hexadecimal format from a message of String type.
[out] | szDigest | to receive message digest. |
[in] | szMessage | containing the message to be hashed. |
API_MAX_MD5_CHARS
) characters long (33 in a C program). long PAD_BytesBlock | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const unsigned char * | lpInput, | ||
long | nBytes, | ||
long | nBlkLen, | ||
long | nOptions | ||
) |
Creates an input block suitably padded for encryption by a block cipher in ECB or CBC mode.
[out] | lpOutput | array to be filled with padded encryption block. |
[in] | nOutputLen | specifying the size of the output array in bytes. |
[in] | lpInput | array containing the plaintext bytes to be padded. |
[in] | nBytes | specifying the length of the plaintext in bytes. |
[in] | nBlkLen | specifying the cipher block length in bytes (8 or 16). |
[in] | nOptions | Option flags. Select one of:API_PAD_DEFAULT (0) to use the default PKCS5 padding API_PAD_1ZERO to use OneAndZeroes paddingAPI_PAD_AX923 to use ANSIX923 paddingAPI_PAD_W3C to use W3C padding |
NULL
in C or ByVal 0&
in VBA), then the required number of bytes will be returned. The output is always longer than the input. Only block lengths of 8 or 16 bytes are supported. For more details of the supported padding schemes, see Padding schemes for block ciphers. long PAD_HexBlock | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szInput, | ||
long | nBlkLen, | ||
long | nOptions | ||
) |
Creates a hex-encoded input block suitably padded for encryption by a block cipher in ECB or CBC mode.
[out] | szOutput | to receive the hexadecimal-encoded padded encryption block. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | szInput | containing the hexadecimal-encoded data to be padded. |
[in] | nBlkLen | specifying the cipher block length in bytes (8 or 16). |
[in] | nOptions | Option flags. Select one of:API_PAD_DEFAULT (0) to use the default PKCS5 padding API_PAD_1ZERO to use OneAndZeroes paddingAPI_PAD_AX923 to use ANSIX923 paddingAPI_PAD_W3C to use W3C padding |
The output is always longer than the input. Only block lengths of 8 or 16 bytes are supported. For more details of the supported padding schemes, see Padding schemes for block ciphers.
long PAD_UnpadBytes | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const unsigned char * | lpInput, | ||
long | nBytes, | ||
long | nBlkLen, | ||
long | nOptions | ||
) |
Removes the padding from an encryption block.
[out] | lpOutput | array to be filled with the output. |
[in] | nOutputLen | specifying the size of the output array in bytes. |
[in] | lpInput | array containing the padded data. |
[in] | nBytes | specifying the length of the input in bytes. |
[in] | nBlkLen | specifying the cipher block length in bytes (8 or 16). |
[in] | nOptions | Option flags. Select one of:API_PAD_DEFAULT (0) to use the default PKCS5 padding API_PAD_1ZERO to use OneAndZeroes paddingAPI_PAD_AX923 to use ANSIX923 paddingAPI_PAD_W3C to use W3C padding |
If nOutBytes is set to zero or lpOutput set to 0 (or NULL
in C or ByVal 0&
in VBA), then the required number of bytes will be returned. The output is always shorter than the input. Only block lengths of 8 or 16 bytes are supported. For more details of the supported padding schemes, see Padding schemes for block ciphers.
Note that it is still possible to have a "valid" padding string at the end of incorrectly deciphered data
long PAD_UnpadHex | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szInput, | ||
long | nBlkLen, | ||
long | nOptions | ||
) |
Removes the padding from a hex-encoded encryption block.
[out] | szOutput | to receive the hexadecimal-encoded output. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | szInput | containing the hexadecimal-encoded padded data. |
[in] | nBlkLen | specifying the cipher block length in bytes (8 or 16). |
[in] | nOptions | Option flags. Select one of:API_PAD_DEFAULT (0) to use the default PKCS5 padding API_PAD_1ZERO to use OneAndZeroes paddingAPI_PAD_AX923 to use ANSIX923 paddingAPI_PAD_W3C to use W3C padding |
For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length of the output string. C/C++ users must add one to this value when allocating memory.
When using the VBA wrapper function padUnpadHex
and there is an error, then the input is returned unchanged. The user should check for this and signal an error. See the VBA wrapper example below.
long PBE_Kdf2 | ( | unsigned char * | lpDerivedKey, |
long | nKeyLen, | ||
const unsigned char * | lpPwd, | ||
long | nPwdLen, | ||
const unsigned char * | lpSalt, | ||
long | nSaltLen, | ||
long | nCount, | ||
long | nOptions | ||
) |
Derives a key of any length from a password using the PBKDF2 algorithm from PKCS#5 v2.1.
[out] | lpDerivedKey | Byte array to be filled with derived key. |
[in] | nKeyLen | size of the required key in bytes. |
[in] | lpPwd | Byte array containing the password. |
[in] | nPwdLen | length of the password in bytes. |
[in] | lpSalt | Byte array containing the salt. |
[in] | nSaltLen | length of the salt in bytes. |
[in] | nCount | required iteration count. |
[in] | nOptions | Option flags. Select one of:API_HMAC_SHA1 (0) to use the HMAC-SHA-1 algorithm (default)API_HMAC_SHA256 to use the HMAC-SHA-256 algorithmAPI_HMAC_SHA384 to use the HMAC-SHA-384 algorithmAPI_HMAC_SHA512 to use the HMAC-SHA-512 algorithmAPI_HMAC_SHA224 to use the HMAC-SHA-224 algorithmAPI_HMAC_MD5 to use the HMAC-MD5 algorithm |
long PBE_Kdf2Hex | ( | char * | szOutput, |
long | nMaxChars, | ||
long | dkBytes, | ||
const char * | szPwd, | ||
const char * | szSaltHex, | ||
long | nCount, | ||
long | nOptions | ||
) |
Derives a key of any length from a password using the PBKDF2 algorithm from PKCS#5 v2.1 with the salt and derived key encoded in hexadecimal.
[out] | szOutput | to receive the hexadecimal-encoded derived key. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | dkBytes | specifying the size of the required key in bytes. |
[in] | szPwd | containing the password. |
[in] | szSaltHex | containing the salt in hex format. |
[in] | nCount | specifying the required iteration count. |
[in] | nOptions | Option flags. Select one of:API_HMAC_SHA1 (0) to use the HMAC-SHA-1 algorithm (default)API_HMAC_SHA256 to use the HMAC-SHA-256 algorithmAPI_HMAC_SHA384 to use the HMAC-SHA-384 algorithmAPI_HMAC_SHA512 to use the HMAC-SHA-512 algorithmAPI_HMAC_SHA224 to use the HMAC-SHA-224 algorithmAPI_HMAC_MD5 to use the HMAC-MD5 algorithm |
Len(strOutput)
). The seed szSaltHex is specified in hex format and can be any even number of hex digits in length. The password szPassword is normal text, not hexadecimal. long PBE_Scrypt | ( | unsigned char * | lpDerivedKey, |
long | nKeyLen, | ||
const unsigned char * | lpPwd, | ||
long | nPwdLen, | ||
const unsigned char * | lpSalt, | ||
long | nSaltLen, | ||
long | nParamN, | ||
long | nParamR, | ||
long | nParamP, | ||
long | nOptions | ||
) |
Derives a key of any length from a password using the SCRYPT algorithm.
[out] | lpDerivedKey | Byte array to be filled with derived key. |
[in] | nKeyLen | size of required key in bytes. |
[in] | lpPwd | Byte array containing the password. |
[in] | nPwdLen | length of the password in bytes. |
[in] | lpSalt | Byte array containing the salt. |
[in] | nSaltLen | length of the salt in bytes. |
[in] | nParamN | CPU/Memory cost parameter N ("costParameter" ) a number greater than one and a power of 2. |
[in] | nParamR | Block size r ("blockSize" ) |
[in] | nParamP | Parallelization parameter p ("parallelizationParameter" ) |
[in] | nOptions | Option flags: not used in this release. Specify zero. |
The output buffer for the derived key abDerivedKey must have been dimensioned to at least the required length nKeyLen in bytes.
long PBE_ScryptHex | ( | char * | szOutput, |
long | nMaxChars, | ||
long | dkBytes, | ||
const char * | szPwd, | ||
const char * | szSaltHex, | ||
long | nParamN, | ||
long | nParamR, | ||
long | nParamP, | ||
long | nOptions | ||
) |
Derives a key of any length from a password using the SCRYPT algorithm with the salt and derived key encoded in hexadecimal.
[out] | szOutput | to receive the hexadecimal-encoded derived key. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | dkBytes | specifying the size of the required key in bytes. |
[in] | szPwd | containing the password (as normal text). |
[in] | szSaltHex | containing the salt in hex format. |
[in] | nParamN | CPU/Memory cost parameter N ("costParameter" ) a number greater than one and a power of 2. |
[in] | nParamR | Block size r ("blockSize" ) |
[in] | nParamP | Parallelization parameter p ("parallelizationParameter" ) |
[in] | nOptions | Option flags: not used in this release. Specify zero. |
Len(strOutput)
). The seed szSaltHex is specified in hex format and can be any even number of hex digits in length. The password szPassword is normal text, not hexadecimal. long PC1_Bytes | ( | unsigned char * | lpOutput, |
unsigned char * | lpInput, | ||
long | nBytes, | ||
unsigned char * | lpKey, | ||
long | nKeyBytes | ||
) |
Enciphers an array of Bytes in one step using the RC4-compatible 'PC1' algorithm.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | nKeyBytes | equal to length of the key in bytes. |
long PC1_File | ( | char * | szFileOut, |
char * | szFileIn, | ||
unsigned char * | lpKey, | ||
long | nKeyBytes | ||
) |
Enciphers a file using the RC4-compatible 'PC1' algorithm.
The key is passed as an array of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | nKeyBytes | containing the length of the key in bytes. |
The output file szFileOut will be overwritten without warning. The input and output filenames must not be the same.
long PC1_Hex | ( | char * | szOutput, |
long | nMaxChars, | ||
const char * | szInputHex, | ||
const char * | szKeyHex | ||
) |
Enciphers data encoded in hex format in one step using the RC4-compatible 'PC1' algorithm.
[out] | szOutput | to receive the hexadecimal-encoded output. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | szInputHex | containing the input data in hex format. |
[in] | szKeyHex | containing the key in hex format. |
long PRF_Bytes | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
const void * | lpKey, | ||
long | nKeyLen, | ||
const char * | szCustom, | ||
long | nOptions | ||
) |
Generate output bytes using a pseudorandom function (PRF).
[out] | lpOutput | byte buffer to receive the output. |
[in] | nOutBytes | size of output buffer in bytes. |
[in] | lpMessage | byte array containing the input data. |
[in] | nMsgLen | length of the input data in bytes. |
[in] | lpKey | byte array containing the key. |
[in] | nKeyLen | length of the key in bytes. |
[in] | szCustom | customization string (optional). |
[in] | nOptions | Option flags. Select one of:API_KMAC_128 to use KMAC128 (KMAC with SHAKE128)API_KMAC_256 to use KMAC256 (KMAC with SHAKE256). |
""
. long RNG_BytesWithPrompt | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const char * | szPrompt, | ||
long | nOptions | ||
) |
Generates a random set of byte data suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements.
[out] | lpOutput | array to receive the random data. |
[in] | nOutputLen | specifying the required length in bytes. |
[in] | szPrompt | specifying an (optional) prompt for the dialog. Specify an empty string ("") or NULL to use the default dialog. |
[in] | nOptions | option flags:API_DEFAULT (0) for default optionsAPI_RNG_STRENGTH_112 to make user generate an estimated 112 bits of security (default)API_RNG_STRENGTH_128 to make user generate an estimated 128 bits of security API_RNG_STRENGTH_192 to make user generate an estimated 192 bits of security API_RNG_STRENGTH_256 to make user generate an estimated 256 bits of security |
long RNG_HexWithPrompt | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nBytes, | ||
const char * | szPrompt, | ||
long | nOptions | ||
) |
Generates a random set of data in hexadecimal format suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements.
[out] | szOutput | of sufficient length to receive the output. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | nBytes | value of the required random data length in bytes. |
[in] | szPrompt | specifying an (optional) prompt for the dialog. Specify an empty string ("") or NULL to use the default dialog. |
[in] | nOptions | option flags:API_DEFAULT (0) for default optionsAPI_RNG_STRENGTH_112 to make user generate an estimated 112 bits of security (default)API_RNG_STRENGTH_128 to make user generate an estimated 128 bits of security API_RNG_STRENGTH_192 to make user generate an estimated 192 bits of security API_RNG_STRENGTH_256 to make user generate an estimated 256 bits of security |
RNG_BytesWithPrompt
. long RNG_Initialize | ( | const char * | szSeedFile, |
long | nOptions | ||
) |
Initializes the RNG generator with a seed file.
[in] | szSeedFile | specifying a seed file. May be the empty string "" . |
[in] | nOptions | option flags:API_DEFAULT (0) for default optionsAPI_RNG_NO_INTEL_DRNG to turn off support for Intel(R) DRNG for the current session. |
Intel(R) DRNG support: [New in v6.22.1] Pass an empty string ""
for szSeedFile to query support for Intel(R) Digital Random Number Generator (DRNG) on your system (and add an extra 256 bits of entropy, if available). If supported, the return value is a positive integer (1,2,3), otherwise it returns the error code PRNG_ERR_NOTAVAIL
(-214). See Intel(R) DRNG.
Alternatively, use the option API_RNG_NO_INTEL_DRNG
to turn off support for Intel(R) DRNG for the current session. You might use this if calls to Intel(R) DRNG are causing problems on your system.
long RNG_KeyBytes | ( | unsigned char * | lpOutput, |
long | nOutputLen, | ||
const void * | lpSeed, | ||
long | nSeedLen | ||
) |
Generates a random set of byte data suitable for cryptographic keys.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | nOutputLen | value of the required key length in bytes. |
[in] | lpSeed | containing an (optional) user-specified seed to be used by the random number generator. Specify an empty string ("" ) or NULL to ignore.. |
[in] | nSeedLen | specifiying the size of the seed in bytes. |
long RNG_KeyHex | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nBytes, | ||
const void * | lpSeed, | ||
long | nSeedLen | ||
) |
Generates a random set of data in hexadecimal format suitable for cryptographic keys.
[out] | szOutput | of sufficient length to receive the output. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | nBytes | value of the required key length in bytes. |
[in] | lpSeed | containing an (optional) user-specified seed to be used by the random number generator. Specify an empty string ("" ) or NULL to ignore.. |
[in] | nSeedLen | specifying the size of the seed in bytes. |
Len(strOutput)
. C/C++ users must add one to this value when allocating memory. The seed szSeed is optional and is added to the automatic seed values generated internally. The seed cannot directly affect the value of the output; it will just ensure that it will be different. long RNG_MakeSeedFile | ( | const char * | szSeedFile, |
const char * | szPrompt, | ||
long | nOptions | ||
) |
Creates a new seed file suitable for use with RNG_Initialize.
[in] | szSeedFile | specifying the seed file to be created. |
[in] | szPrompt | specifying an (optional) prompt for the dialog. Specify an empty string ("") or NULL to use the default dialog. |
[in] | nOptions | option flags:API_DEFAULT (0) for default optionsAPI_RNG_STRENGTH_112 to make user generate an estimated 112 bits of security (default)API_RNG_STRENGTH_128 to make user generate an estimated 128 bits of security API_RNG_STRENGTH_192 to make user generate an estimated 192 bits of security API_RNG_STRENGTH_256 to make user generate an estimated 256 bits of security |
ApiMkRngSeed.exe
, provided in the distribution to make a new seed file [updated in v6.22]. long RNG_NonceData | ( | unsigned char * | lpOutput, |
long | nBytes | ||
) |
Returns a random nonce (number used once) as a specified-length byte array.
This replaces the RNG_Nonce function from version 2.
[out] | lpOutput | array to be filled with random values. |
[in] | nBytes | specifying the number of required bytes in the nonce. |
lpOutput
must be at least nBytes
bytes long. long RNG_NonceDataHex | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nBytes | ||
) |
Returns a specified-length random nonce (number used once) as a hexadecimal string.
This is a safer version of the RNG_NonceHex function in version 2.
[out] | szOutput | array to be filled with random values expressed in hexadecimal. |
[in] | nMaxChars | specifying the maximum number of characters in szOutput. |
[in] | nBytes | specifying the number of required bytes in the nonce. |
Returns a random 32-bit number between specified limits.
[in] | nLower | specifying a lower limit. |
[in] | nUpper | specifying an upper limit. |
long RNG_Test | ( | const char * | szFileName | ) |
Carries out a NIST SP800-90 health check and FIPS140-2 statistical tests on the random number generator.
[in] | szFileName | containing the full path name of a file to be created containing the results of the test. |
strFileName
does not exist, it will be created. If it already exists, it will be overwritten without warning. If no directory path is specified, the file will be created in the current default directory. This function carries out, on demand, the health testing procedure from section 11.3 of [SP80090A] and the statistical tests for randomness from section 4.9.1 of the October 2001 version of FIPS-140-2 [FIPS140]. The statistical test results and the 20,000-bit sample are written to a text file. Specify an empty (""
) or NULL szFileName to avoid creating an output file and just carry out the tests. The statistical tests have since been removed from FIPS-140-2, but we do them anyway. If any tests fail, a non-zero error code will be returned. long RNG_TestDRBGVS | ( | char * | szOutput, |
long | nMaxChars, | ||
long | nReturnedBitsLen, | ||
const char * | szEntropyInput, | ||
const char * | szNonce, | ||
const char * | szPersonalizationString, | ||
const char * | szAdditionalInput1, | ||
const char * | szEntropyReseed, | ||
const char * | szAdditionalInputReseed, | ||
const char * | szAdditionalInput2, | ||
long | nOptions | ||
) |
Tests the random number generator for conformance to NIST SP 800-90A using the relevant test specified in the Deterministic Random Bit Generator Validation System (DRBGVS).
[out] | szOutput | to receive the ReturnedBits in hexadecimal format. |
[in] | nMaxChars | specifying the maximum number of hexadecimal characters to be received. |
[in] | nReturnedBitsLen | specifying the number of bits to be returned from each call to the generate function in the test. |
[in] | szEntropyInput | containing the EntropyInput value in hex format. |
[in] | szNonce | containing the Nonce value in hex format. |
[in] | szPersonalizationString | containing the PersonalizationString value in hex format. |
[in] | szAdditionalInput1 | containing the first AdditionalInput value in hex format. |
[in] | szEntropyReseed | containing the EntropyReseed value in hex format. |
[in] | szAdditionalInputReseed | containing the AdditionalInputReseed value in hex format. |
[in] | szAdditionalInput2 | containing the second AdditionalInput value in hex format. |
[in] | nOptions | Option flags: not used in this release. Specify zero. |
HMAC_DRBG SHA-512
without prediction resistance. Use the empty string ""
to pass a zero-length input. All hex strings must have an even number of characters. long RNG_UpdateSeedFile | ( | const char * | szSeedFile, |
long | nOptions | ||
) |
Updates an RNG seed file.
[in] | szSeedFile | specifying the seed file to be updated. |
[in] | nOptions | option flags: not used in this release. Specify zero. |
long SHA1_AddBytes | ( | long | hContext, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to the digest.
[in] | hContext | handle to the SHA-1 context. |
[in] | lpData | array containing the next part of the message to be hashed. |
[in] | nDataLen | containing the number of bytes in the array |
SHA1_Init
. This function may be called many times before creating the final message digest with SHA1_HexDigest
. SHA1_AddString
may also be called. long SHA1_AddString | ( | long | hContext, |
const char * | szMessage | ||
) |
Adds a string of ascii characters to the digest.
[in] | hContext | handle to the SHA-1 context. |
[in] | szMessage | containing the next part of the message to be hashed. |
SHA1_Init
. This function may be called many times before creating the final message digest with SHA1_HexDigest
This function should only be used to hash strings of "printable" ANSI characters. To hash a string that contains binary characters, such as ascii zero, use SHA1_AddBytes
. long SHA1_BytesHash | ( | unsigned char * | digest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates a SHA-1 message digest in Byte array format from a message in Byte array format.
[out] | digest | array to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
Byte
array format. This is particularly useful when you need to carry out repeated hash operations. lpDigest must be at least 20 (API_MAX_SHA1_BYTES
)bytes long. long SHA1_BytesHexHash | ( | char * | szDigest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates a SHA-1 message digest in hexadecimal format from a message in Byte array format.
[out] | szDigest | to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
API_MAX_SHA1_CHARS
) characters long (41 in a C program). long SHA1_FileHexHash | ( | char * | szDigest, |
const char * | szFileName, | ||
const char * | szMode | ||
) |
Creates a SHA-1 message digest in hexadecimal format from a file.
[out] | szDigest | to receive message digest. |
[in] | szFileName | with full path name of file. |
[in] | szMode | to set mode: "t" or "b" |
API_MAX_SHA1_CHARS
) characters long (41 in a C program). Setting szMode equal to "t" or "T" will hash file in "text" mode treating a CR-LF pair as a single newline character. Setting szMode equal to "b" or "B" will hash file in "binary" mode treating CR-LF as two binary characters (default). long SHA1_HexDigest | ( | char * | szDigest, |
long | hContext | ||
) |
Returns the final message digest value as a hex string.
[out] | szDigest | variable long enough to receive the final message digest. |
[in] | hContext | handle to the SHA-1 context. |
SHA1_Init
. The string variable szDigest must have been set up with at least 40 (API_MAX_SHA1_CHARS
) characters (41 in a C program) to receive the digest value in hex format. Note that this digest operation is a destructive, read-once operation. Once it has been performed, the context must be reset before being used to calculate another digest value. long SHA1_Hmac | ( | char * | szDigest, |
const unsigned char * | textBytes, | ||
long | textLen, | ||
const unsigned char * | lpKeyBytes, | ||
long | keyLen | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-1 hash function.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | textBytes | array containing the text of the message. |
[in] | textLen | containing the number of bytes in the array |
[in] | lpKeyBytes | array containing the key. |
[in] | keyLen | containing the number of bytes in the key |
API_MAX_SHA1_CHARS
) characters long (41 in a C program). long SHA1_HmacHex | ( | char * | szDigest, |
const char * | sHexText, | ||
const char * | sHexKey | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-1 hash function, passing its arguments in hexadecimal format.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | sHexText | containing the text of the message in hexadecimal format. |
[in] | sHexKey | containing the key in hexadecimal format. |
API_MAX_SHA1_CHARS
) characters long (41 in a C program). szData and szKey are expected to be an even number of characters long, i.e. representing complete byte values. Any trailing odd character will be ignored. long SHA1_Init | ( | void | ) |
Initialises the SHA-1 context ready for subsequent calls with SHA1_AddString, SHA1_AddBytes, and SHA1_HexDigest.
long SHA1_Reset | ( | long | hContext | ) |
Resets the context.
[in] | hContext | handle to the SHA-1 context. |
long SHA1_StringHexHash | ( | char * | szDigest, |
const char * | szMessage | ||
) |
Creates a SHA-1 message digest in hexadecimal format from a message of String type.
[out] | szDigest | to receive message digest. |
[in] | szMessage | containing the message to be hashed. |
API_MAX_SHA1_CHARS
) characters long (41 in a C program). long SHA2_AddBytes | ( | long | hContext, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to the digest.
[in] | hContext | handle to the SHA-2 context. |
[in] | lpData | array containing the next part of the message to be hashed. |
[in] | nDataLen | containing the number of bytes in the array |
SHA2_Init
. This function may be called many times before creating the final message digest with SHA2_HexDigest
. SHA2_AddString
may also be called. long SHA2_AddString | ( | long | hContext, |
const char * | szMessage | ||
) |
Adds a string of ascii characters to the digest.
[in] | hContext | handle to the SHA-2 context. |
[in] | szMessage | containing the next part of the message to be hashed. |
SHA2_Init
. This function may be called many times before creating the final message digest with SHA2_HexDigest
This function should only be used to hash strings of "printable" ANSI characters. To hash a string that contains binary characters, such as ascii zero, use SHA1_AddBytes
. long SHA2_BytesHash | ( | unsigned char * | lpDigest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates a SHA-256 message digest in Byte array format from a message in Byte array format.
[out] | lpDigest | array to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
Byte
array format. This is particularly useful when you need to carry out repeated hash operations. lpDigest must be at least 32 (API_MAX_SHA2_BYTES
) bytes long. long SHA2_BytesHexHash | ( | char * | szDigest, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Creates a SHA-256 message digest in hexadecimal format from a message in Byte array format.
[out] | szDigest | to receive message digest. |
[in] | lpData | array containing the message to be hashed. |
[in] | nDataLen | containing number of bytes in the array. |
API_MAX_SHA2_CHARS
) characters long (65 in a C program). long SHA2_FileHexHash | ( | char * | szDigest, |
const char * | szFileName, | ||
const char * | szMode | ||
) |
Creates a SHA-256 message digest in hexadecimal format from a file.
[out] | szDigest | to receive message digest. |
[in] | szFileName | with full path name of file. |
[in] | szMode | to set mode: "t" or "b" |
API_MAX_SHA2_CHARS
) characters long (65 in a C program). Setting szMode equal to "t" or "T" will hash file in "text" mode treating a CR-LF pair as a single newline character. Setting szMode equal to "b" or "B" will hash file in "binary" mode treating CR-LF as two binary characters (default). long SHA2_HexDigest | ( | char * | szDigest, |
long | hContext | ||
) |
Returns the final message digest value as a hex string.
[out] | szDigest | variable long enough to receive the final message digest. |
[in] | hContext | handle to the SHA-1 context. |
SHA1_Init
. The string variable szDigest must have been set up with at least 64 (API_MAX_SHA2_CHARS
) characters (65 in a C program) to receive the digest value in hex format. Note that this digest operation is a destructive, read-once operation. Once it has been performed, the context must be reset before being used to calculate another digest value. long SHA2_Hmac | ( | char * | szDigest, |
const unsigned char * | textBytes, | ||
long | textLen, | ||
const unsigned char * | lpKeyBytes, | ||
long | keyLen | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-256 hash function.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | textBytes | array containing the text of the message. |
[in] | textLen | containing the number of bytes in the array |
[in] | lpKeyBytes | array containing the key. |
[in] | keyLen | containing the number of bytes in the key |
API_MAX_SHA2_CHARS
) characters long (65 in a C program). long SHA2_HmacHex | ( | char * | szDigest, |
const char * | sHexText, | ||
const char * | sHexKey | ||
) |
Is a keyed-hash function that provides message authentication using the HMAC algorithm and the SHA-256 hash function, passing its arguments in hexadecimal format.
[out] | szDigest | variable of sufficient length to receive the message digest in hex format. |
[in] | sHexText | containing the text of the message in hexadecimal format. |
[in] | sHexKey | containing the key in hexadecimal format. |
API_MAX_SHA2_CHARS
) characters long (65 in a C program). szData and szKey are expected to be an even number of characters long, i.e. representing complete byte values. Any trailing odd character will be ignored. long SHA2_Init | ( | void | ) |
Initialises the SHA-256 context ready for subsequent calls with SHA2_AddString, SHA2_AddBytes, and SHA2_HexDigest.
long SHA2_Reset | ( | long | hContext | ) |
Resets the context.
[in] | hContext | handle to the SHA-1 context. |
long SHA2_StringHexHash | ( | char * | szDigest, |
const char * | szMessage | ||
) |
Creates a SHA-256 message digest in hexadecimal format from a message of String type.
[out] | szDigest | to receive message digest. |
[in] | szMessage | containing the message to be hashed. |
API_MAX_SHA2_CHARS
) characters long (65 in a C program). long SHA3_AddBytes | ( | long | hContext, |
const unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Adds an array of bytes to the digest.
[in] | hContext | handle to the SHA-3 context. |
[in] | lpData | byte array containing the next part of the message to be hashed. |
[in] | nDataLen | number of bytes in the array |
SHA3_Init
. This function may be called many times before creating the final message digest with SHA3_HexDigest
. SHA3_AddString
may also be called. long SHA3_AddString | ( | long | hContext, |
const char * | szMessage | ||
) |
Adds a string of ascii characters to the digest.
[in] | hContext | handle to the SHA-3 context. |
[in] | szMessage | string containing the next part of the message to be hashed. |
SHA3_Init
. This function may be called many times before creating the final message digest with SHA3_HexDigest
This function should only be used to hash strings of "printable" ANSI characters. To hash a string that contains binary characters, such as ascii zero, use SHA3_AddBytes
. long SHA3_HexDigest | ( | char * | szOutput, |
long | nMaxChars, | ||
long | hContext | ||
) |
Returns the final message digest value as a hex string.
[out] | szOutput | buffer to receive the final message digest in hexadecimal format. |
[in] | nMaxChars | maximum number of hex characters to be received. |
[in] | hContext | handle to the SHA-3 context. |
SHA3_Init
.The final digest value will be truncated to the specified length if nMaxChars is less than the required digest size.
Note that this digest operation is a destructive, read-once operation. Once it has been performed, the context must be initialized before being used to calculate another digest value.
long SHA3_Init | ( | long | nHashBitLen | ) |
Initialises the SHA-3 context ready for subsequent calls with SHA3_AddString, SHA3_AddBytes, and SHA3_HexDigest.
[in] | nHashBitLen | specifying the number of bits in the hash output. This must be one of 224, 256, 384 or 512. |
long SHA3_LengthInBytes | ( | long | hContext | ) |
Returns the number of bytes in the hash output for the algorithm defined in the current SHA-3 context.
[in] | hContext | handle to the current SHA-3 context. |
long SHA3_Reset | ( | long | hContext | ) |
Resets the context.
[in] | hContext | handle to the SHA-3 context. |
long TDEA_B64Mode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a base64 string using a specified mode.
The key and initialization vector are represented as base64 strings.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in base64. |
[in] | szKey | containing the key in base64. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV), if required, in base64. |
ECB
, in which case szIV is ignored (use ""
). The key szKey must represent exactly 24 bytes, the required key length. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long TDEA_Bytes | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts an array of Bytes in one step in Electronic Codebook (EBC) mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long TDEA_BytesMode | ( | unsigned char * | lpOutput, |
const unsigned char * | lpInput, | ||
long | nBytes, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts an array of Bytes in one step using a specified mode.
[out] | lpOutput | array of sufficient length to receive the output. |
[in] | lpInput | array containing the input data. |
[in] | nBytes | equal to length of the input data in bytes. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector (IV), or zero (0) for ECB mode. |
long TDEA_File | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as arrays of bytes.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
0
).The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
long TDEA_FileExt | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const unsigned char * | lpKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV, | ||
long | nOptions | ||
) |
Encrypts or decrypts a file using a specified mode with extended options.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | lpKey | array containing the key. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | array containing the initialization vector (IV), or zero (0) for ECB mode. |
[in] | nOptions | option flags: Zero (0) for default behaviour as per TDEA_File .API_IV_PREFIX to prepend the IV before the ciphertext in the output file (ignored for ECB mode)API_PAD_LEAVE to leave any padding in place when decrypting (ECB and CBC modes only; ignored if encrypting) |
TDEA_File
. The options are ignored if not applicable. For more information on the behaviour of the options, see Extensions to block cipher functions for files. long TDEA_FileHex | ( | const char * | szFileOut, |
const char * | szFileIn, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts a file using a specified mode.
The key and initialization vector are passed as hexadecimal strings.
[in] | szFileOut | with the full path name of the output file to be created. |
[in] | szFileIn | with the full path name of the input file to be processed. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
""
). Valid hexadecimal characters are [0-9A-Fa-f].The output file szFileOut will be overwritten without warning. If there is an error [new in version 3.3], the output file will not exist. The input and output filepaths must not be the same.
In ECB and CBC modes, a padding string will be added or assumed according to the method outlined in Section 6.3 of [CMS], which is the same as the padding method in [PKCS7] and [PKCS5].
Note that even though the parameters are in hexadecimal-encoded form, the encrypted file is still binary.
long TDEA_Final | ( | long | hContext | ) |
Closes and clears the TDEA context.
[in] | hContext | containing the handle to the TDEA context. |
long TDEA_Hex | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
The process is carried out in one step in Electronic Codebook (EBC) mode.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
long TDEA_HexMode | ( | char * | szOutput, |
const char * | szInput, | ||
const char * | szKey, | ||
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Encrypts or decrypts data represented as a hexadecimal string using a specified mode.
The key and initialization vector are represented as a hexadecimal string.
[out] | szOutput | of sufficient length to receive the output. |
[in] | szInput | containing the input data in hexadecimal. |
[in] | szKey | containing the key in hexadecimal. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector (IV) in hexadecimal. |
ECB
, in which case szIV is ignored (use ""
). Valid hexadecimal characters are [0-9A-Fa-f]. The output string szOutput must be set up with at least the same number of characters as the input string before calling. The variables szOutput and szInput should be different. long TDEA_Init | ( | const unsigned char * | lpKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const unsigned char * | lpIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the TDEA function.
The key and IV data are provided in byte arrays.
[in] | lpKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | lpIV | containing the initialization vector in hexadecimal. Set as zero (0) for ECB mode. |
TDEA_Init
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling a TDEA function. long TDEA_InitError | ( | void | ) |
Returns the error code after an unsuccessful call to TDEA_Init or TDEA_InitHex.
long TDEA_InitHex | ( | const char * | szKey, |
int | fEncrypt, | ||
const char * | szMode, | ||
const char * | szIV | ||
) |
Initialises the context with the key, direction and mode ready for repeated operations of the TDEA function.
The key and IV data are provided in hexadecimal format.
[in] | szKey | containing the key in hexadecimal representation. |
[in] | fEncrypt | direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt. |
[in] | szMode | specifying the confidentiality mode:"ECB" for Electronic Codebook mode,"CBC" for Cipher Block Chaining mode,"CFB" for 64-bit Cipher Feedback mode,"OFB" for Output Feedback mode, or"CTR" for Counter mode. |
[in] | szIV | containing the initialization vector in hexadecimal. |
""
). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, TDEA_InitHex
returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling a TDEA function. long TDEA_Update | ( | long | hContext, |
unsigned char * | lpData, | ||
long | nDataLen | ||
) |
Carries out the TDEA transformation function on a byte array according to the direction and mode set up by an earlier call to TDEA_Init() or TDEA_InitHex().
[in] | hContext | handle to the TDEA context set up by an earlier call to TDEA_Init() or TDEA_InitHex() . |
[in,out] | lpData | array containing the input data. |
[in] | nDataLen | equal to length of the input data in bytes. |
long TDEA_UpdateHex | ( | long | hContext, |
char * | szHexData | ||
) |
Carries out the TDEA transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to TDEA_Init() or TDEA_InitHex().
[in] | hContext | handle to the TDEA context set up by an earlier call to TDEA_Init() or TDEA_InitHex() . |
[in,out] | szHexData | containing input in hexadecimal format to be processed by the TDEA function and to receive the output. |
long WIPE_Data | ( | void * | lpData, |
long | nDataLen | ||
) |
Zeroises data in memory.
[in,out] | lpData | Byte array to be cleared. |
[in] | nDataLen | specifying the number of bytes to be cleared. |
long WIPE_File | ( | const char * | szFileName, |
long | nOptions | ||
) |
Securely wipes and deletes a file using 7-pass DOD standards.
[in] | szFileName | specifying the file to be deleted. |
[in] | nOptions | Option flags. Select one of:API_WIPEFILE_DOD7 (0) to use DOD 7-pass (default)API_WIPEFILE_SIMPLE to overwrite with single pass of zero bytes (quicker but less secure) [New in v5.3]. |
NISPOM
] before deleting. long XOF_Bytes | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const void * | lpMessage, | ||
long | nMsgLen, | ||
long | nOptions | ||
) |
Generate bytes using an eXtendable Output Function (XOF).
[out] | lpOutput | byte buffer to receive the output. |
[in] | nOutBytes | size of output buffer in bytes. |
[in] | lpMessage | byte array containing the input data. |
[in] | nMsgLen | length of the input data in bytes. |
[in] | nOptions | Option flags. Select one of:API_XOF_SHAKE128 to use SHAKE128API_XOF_SHAKE256 to use SHAKE256API_XOF_MGF1_SHA1 to use MGF1-SHA-1API_XOF_MGF1_SHA256 to use MGF1-SHA-256API_XOF_MGF1_SHA512 to use MGF1-SHA-512API_XOF_ASCON_XOF to use ASCON-XOFAPI_XOF_ASCON_XOFA to use ASCON-XOFA |
SHAKE128 and SHAKE256 are described in the SHA-3 Standard [FIPS202]. MGF1, despite its name as a Mask Generation Function
(MGF), is also an eXtendable Output Function (XOF) using the SHA1/SHA-2 hash functions, and is described in [PKCS1]. The extendable output functions Ascon-Xof and Ascon-Xofa are from the cipher suite ASCON and are provisional subject to final approval by NIST.
long ZLIB_Deflate | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nBytes | ||
) |
Compresses data using the ZLIB deflate algorithm.
[out] | lpOutput | abyte buffer to receive output data. |
[in] | nOutBytes | size of the output buffer in bytes. |
[in] | lpInput | input data to be compressed. |
[in] | nBytes | length of input array in bytes. |
long ZLIB_Inflate | ( | unsigned char * | lpOutput, |
long | nOutBytes, | ||
const unsigned char * | lpInput, | ||
long | nBytes | ||
) |
Inflates compressed data using the ZLIB uncompress algorithm.
[out] | lpOutput | byte buffer to receive output data. |
[in] | nOutBytes | size of the output buffer in bytes. |
[in] | lpInput | input data to be uncompressed. |
[in] | nBytes | length of input array in bytes. |
To determine the required size of the output buffer, call the function with nOutBytes set to zero (or lpOutput set to NULL).