![]() |
TrustCore SDK Crypto Interface API reference
version 2.0
|
Cryptographic Interface header file for declaring AES functions. More...
Go to the source code of this file.
Functions | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_blockDecrypt (aesCipherContext *pCtx, ubyte *pIv, ubyte *pInput, sbyte4 inputLen, ubyte *pOutBuffer, sbyte4 *pRetLength) |
Decrypt some data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_blockDecryptEx (MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext *pCtx, ubyte *pIv, ubyte *pInput, sbyte4 inputLen, ubyte *pOutBuffer, sbyte4 *pRetLength) |
Decrypt some data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_blockEncrypt (aesCipherContext *pCtx, ubyte *pIv, ubyte *pInput, sbyte4 inputLen, ubyte *pOutBuffer, sbyte4 *pRetLength) |
Encrypt some data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_blockEncryptEx (MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext *pCtx, ubyte *pIv, ubyte *pInput, sbyte4 inputLen, ubyte *pOutBuffer, sbyte4 *pRetLength) |
Encrypt some data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_clearKey (aesCipherContext *pCtx) |
Delete an AES context previously initialized with CRYPTO_INTERFACE_AESALGO_makeAesKey . More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_makeAesKey (aesCipherContext *pCtx, sbyte4 keyLen, const ubyte *pKeyMaterial, sbyte4 encrypt, sbyte4 mode) |
Initialize a raw AES object for operation. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_AESALGO_makeAesKeyEx (MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext *pCtx, sbyte4 keyLen, const ubyte *pKeyMaterial, sbyte4 encrypt, sbyte4 mode) |
Initialize a raw AES object for operation. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_CloneAESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx) |
Clone a AES context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESCFB1Ctx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *keyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-CFB1 context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESCFBCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-CFB128 context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-CBC context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESECBCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-ECB context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESOFBCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-OFB context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DeleteAESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ppCtx) |
Delete an AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAES (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt, ubyte *pIv) |
Encrypt or decrypt data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAESECB (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt) |
Same as CRYPTO_INTERFACE_DoAES but specifically for ECB mode. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAESEx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt, ubyte *pIv) |
Encrypt or decrypt data using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_ResetAESCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ppCtx) |
"Reset" an AES context by setting the "initialized" field within the aesCipherContext to 0. More... | |
Add details here.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_blockDecrypt | ( | aesCipherContext * | pCtx, |
ubyte * | pIv, | ||
ubyte * | pInput, | ||
sbyte4 | inputLen, | ||
ubyte * | pOutBuffer, | ||
sbyte4 * | pRetLength | ||
) |
pCtx | The context to use for this cipher operation. |
pIv | Initialization vector to use for this operation, optional for ECB mode. Must be 16 bytes for all other modes. |
pInput | Data to decrypt. |
inputLen | Length in bytes of the input data, must be a multiple of the AES block size (16). |
pOutBuffer | Buffer that will recieve the decrypted result, must be as large as the input data. |
pRetLength | Pointer to the sbyte4 which will recieve the length of the resulting plaintext. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_blockDecryptEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext * | pCtx, |
ubyte * | pIv, | ||
ubyte * | pInput, | ||
sbyte4 | inputLen, | ||
ubyte * | pOutBuffer, | ||
sbyte4 * | pRetLength | ||
) |
pCtx | The context to use for this cipher operation. |
pIv | Initialization vector to use for this operation, optional for ECB mode. Must be 16 bytes for all other modes. |
pInput | Data to decrypt. |
inputLen | Length in bytes of the input data, must be a multiple of the AES block size (16). |
pOutBuffer | Buffer that will recieve the decrypted result, must be as large as the input data. |
pRetLength | Pointer to the sbyte4 which will recieve the length of the resulting plaintext. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_blockEncrypt | ( | aesCipherContext * | pCtx, |
ubyte * | pIv, | ||
ubyte * | pInput, | ||
sbyte4 | inputLen, | ||
ubyte * | pOutBuffer, | ||
sbyte4 * | pRetLength | ||
) |
pCtx | The context to use for this cipher operation. |
pIv | Initialization vector to use for this operation, optional for ECB mode. Must be 16 bytes for all other modes. |
pInput | Data to encrypt. |
inputLen | Length in bytes of the input data, must be a multiple of the AES block size (16). |
pOutBuffer | Buffer that will recieve the encrypted result, must be as large as the input data. |
pRetLength | Pointer to the sbyte4 which will recieve the length of the resulting ciphertext. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_blockEncryptEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext * | pCtx, |
ubyte * | pIv, | ||
ubyte * | pInput, | ||
sbyte4 | inputLen, | ||
ubyte * | pOutBuffer, | ||
sbyte4 * | pRetLength | ||
) |
pCtx | The context to use for this cipher operation. |
pIv | Initialization vector to use for this operation, optional for ECB mode. Must be 16 bytes for all other modes. |
pInput | Data to encrypt. |
inputLen | Length in bytes of the input data, must be a multiple of the AES block size (16). |
pOutBuffer | Buffer that will recieve the encrypted result, must be as large as the input data. |
pRetLength | Pointer to the sbyte4 which will recieve the length of the resulting ciphertext. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_clearKey | ( | aesCipherContext * | pCtx | ) |
Note that this function frees the underlying context created by the crypto interface. Even though the aesCipherContext
pointer was originally allocated by the caller, failing to call this function after use will result in a memory leak.
pCtx | Pointer to an AES context previously created with CRYPTO_INTERFACE_AESALGO_makeAesKey . |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_makeAesKey | ( | aesCipherContext * | pCtx, |
sbyte4 | keyLen, | ||
const ubyte * | pKeyMaterial, | ||
sbyte4 | encrypt, | ||
sbyte4 | mode | ||
) |
Note that this should only be used when constructing a larger cryptographic scheme that requires an AES primitive. To use AES for encrypting/decrypting data in general, use one of the CRYPTO_INTERFACE_CreateAES*Ctx
functions instead. It is the callers responsibility to delete this context after use by calling CRYPTO_INTERFACE_AESALGO_clearKey
.
pCtx | Pointer to a caller allocated AES context to be initialized. |
keyLen | Length in bytes of key material to use, must be one of {16,24,32}. |
pKeyMaterial | Key material to use for this operation. |
encrypt | TRUE to encrypt, FALSE to decrypt. |
mode | The AES mode of operation to use. Must be one of { MODE_ECB, MODE_CBC, MODE_CFB128, MODE_OFB } |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESALGO_makeAesKeyEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext * | pCtx, |
sbyte4 | keyLen, | ||
const ubyte * | pKeyMaterial, | ||
sbyte4 | encrypt, | ||
sbyte4 | mode | ||
) |
Note that this should only be used when constructing a larger cryptographic scheme that requires an AES primitive. To use AES for encrypting/decrypting data in general, use one of the CRYPTO_INTERFACE_CreateAES*Ctx
functions instead. It is the callers responsibility to delete this context after use by calling CRYPTO_INTERFACE_AESALGO_clearKey.
pCtx | Pointer to a caller allocated AES context to be initialized. |
keyLen | Length in bytes of key material to use, must be one of {16,24,32}. |
pKeyMaterial | Key material to use for this operation. |
encrypt | TRUE to encrypt, FALSE to decrypt. |
mode | The AES mode of operation to use. Must be one of { MODE_ECB, MODE_CBC, MODE_CFB128, MODE_OFB } |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_CloneAESCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
BulkCtx * | ppNewCtx | ||
) |
pCtx | Pointer to an instantiated BulkCtx . |
ppNewCtx | Double pointer to the BulkCtx to be created and populated with the key data from the source key. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAESCFB1Ctx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | keyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCtx
. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAES
to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
encrypt | TRUE to prepare this context for encryption, FALSE to prepare this context for decryption. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAESCFBCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCtx
. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAES
to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
encrypt | TRUE to prepare this context for encryption, FALSE to prepare this context for decryption. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAESCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCtx
. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAES
to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
encrypt | TRUE to prepare this context for encryption, FALSE to prepare this context for decryption. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAESECBCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCtx
. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAESECB
to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
encrypt | TRUE to prepare this context for encryption, FALSE to prepare this context for decryption. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAESOFBCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCtx
. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAES to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
encrypt | TRUE to prepare this context for encryption, FALSE to prepare this context for decryption. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DeleteAESCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * | ppCtx | ) |
Applies to CBC, CFB, and OFB modes.
ppCtx | Pointer to the BulkCtx to be deleted. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoAES | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | pIv | ||
) |
Use this for AES contexts created with the CBC, CFB, or OFB modes. This function can be used to stream data, pass in the initialization vector on the first call, but note each subsequent call is not guaranteed to use the pIv field passed in. Please use CRYPTO_INTERFACE_DoAESEx
if you wish to update the iv. Note that this operation is in place, so the pData buffer will contain the result.
Note that you must use ResetAESCtx to start a new cipher operation.
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Must be a multiple of the AES block size (16). |
encrypt | TRUE to encrypt, FALSE to decrypt. Must match the value used during context creation. |
pIv | Initialization vector for the cipher operation. Must be exactly 16 bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoAESECB | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt | ||
) |
Note this function does not take an initialization vector as it is not used in ECB mode.
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Must be a multiple of the AES block size (16). |
encrypt | TRUE to encrypt, FALSE to decrypt. Must match the value used during context creation. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoAESEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | pIv | ||
) |
Use this for AES contexts created with the CBC, CFB, or OFB modes. This function can be used to stream data, pass in the initialization vector on the first call then continue to pass in new data on each subsequent call. Note that this operation is in place, so the pData buffer will contain the result. This method will copy the working IV into the pIv
parameter upon completion.
Note that you must use ResetAESCtx
to start a new cipher operation.
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Must be a multiple of the AES block size (16). |
encrypt | TRUE to encrypt, FALSE to decrypt. Must match the value used during context creation. |
pIv | Initialization vector for the cipher operation. Must be exactly 16 bytes. Will contain the working IV when the method finishes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_ResetAESCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * | ppCtx | ) |
This function is a helper whose purpose is to bridge the gap between the standard DoAES
& CRYPTO_INTERFACE_DoAES
. The standard DoAES
function modifies parameter buffers in-place, whereas CI version makes an internal copy of the buffers to operate on. Therefore, calling this function will allow the user to re-use the same context for multiple buffers.
ppCtx | Pointer to the BulkCtx to be reset. |
OK
(0) if successful, otherwise a negative number error code from merrors.h.