![]() |
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_AESCTRInit (MOC_SYM(hwAccelDescr hwAccelCtx) AES_CTR_Ctx *pCtx, const ubyte *pKeyMaterial, sbyte4 keyLength, const ubyte pInitCounter[AES_BLOCK_SIZE]) |
Populates an already created AES-CTR context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_CloneAESCTRCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx) |
Clone a AES-CTR context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAESCTRCtx (MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-CTR context. More... | |
MOC_EXTERN BulkCtx | CRYPTO_INTERFACE_CreateAesCtrCtx (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyMaterial, sbyte4 keyLength, sbyte4 encrypt) |
Create a new AES-CTR context for ipSec specifications. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DeleteAESCTRCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ppCtx) |
Delete an AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAESCTR (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt, ubyte *pIv) |
This function is effectively a wrapper to CRYPTO_INTERFACE_DoAESCTREx. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAESCTREx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt, ubyte *pIv, sbyte4 limit) |
Encrypt or decrypt data using the provided AES counter mode context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_DoAesCtrEx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, sbyte4 dataLength, sbyte4 encrypt, ubyte *pIv) |
Encrypt or decrypt data for ipSec specifications using the provided AES context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_FinalAesCtrEx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pOutput, sbyte4 *pBytesWritten) |
Finalizes the AES-CTR stream cipher operation on a buffer of data. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_GetCounterBlockAESCTR (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte pCounterBuffer[AES_BLOCK_SIZE]) |
Extract the working IV from the AES-CTR context. More... | |
MOC_EXTERN MSTATUS | CRYPTO_INTERFACE_UpdateAesCtrEx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pInput, sbyte4 inputLen, ubyte *pOutput, sbyte4 *pBytesWritten) |
Perform the AES-CTR stream cipher operation on a buffer of data. More... | |
Add details here.
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AESCTRInit | ( | MOC_SYM(hwAccelDescr hwAccelCtx) AES_CTR_Ctx * | pCtx, |
const ubyte * | pKeyMaterial, | ||
sbyte4 | keyLength, | ||
const ubyte | pInitCounter[AES_BLOCK_SIZE] | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCTRCtx. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAESCTR or CRYPTO_INTERFACE_DoAESCTREx to encrypt or decrypt data.
pCtx | AES counter mode context to populate |
pKeyMaterial | Key material to use for the cipher operation. |
keyLength | Length in bytes of the key material, valid key lengths are {16, 24, 32}. |
pInitCounter | A 16 byte buffer that contains the counter to be used |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_CloneAESCTRCtx | ( | 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_CreateAESCTRCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
Note it is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCTRCtx. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAESCTR or CRYPTO_INTERFACE_DoAESCTREx to encrypt or decrypt data. The last 16 bytes of the pKeyMaterial buffer are expected to be the counter.
pKeyMaterial | Key material to use for the cipher operation including the 16 byte counter. |
keyLength | Length in bytes of the key material plus counter, valid values are {32, 40, 48}. |
encrypt | unused variable |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN BulkCtx CRYPTO_INTERFACE_CreateAesCtrCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) ubyte * | pKeyMaterial, |
sbyte4 | keyLength, | ||
sbyte4 | encrypt | ||
) |
This is analogous to CRYPTO_INTERFACE_CreateAESCTRCtx except that instead of the key being appended by the nonce, iv, and ctr, it just appended by the nonce. It is the callers responsibility to free this object after use by calling CRYPTO_INTERFACE_DeleteAESCTRCtx. Once created, you can use this context as input to CRYPTO_INTERFACE_DoAesCtrEx to encrypt or decrypt data.
pKeyMaterial | Key material to use for the cipher operation including the 4 byte nonce. |
keyLength | Length in bytes of the key material plus nonce, valid values are {32, 40, 48}. |
encrypt | unused variable |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DeleteAESCTRCtx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx * | ppCtx | ) |
Applies to CTR mode only.
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_DoAESCTR | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | pIv | ||
) |
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Does not have to be a multiple of the AES block size (16). |
encrypt | This value is unused. |
pIv | This function does not take an IV, therefore this value is ignored 16 bytes. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoAESCTREx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | pIv, | ||
sbyte4 | limit | ||
) |
This function does not use an IV. This operation is in place, therefore pData will be overwritten with computed ciphertext.
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Does not have to be a multiple of the AES block size (16). |
encrypt | This value is unused. |
pIv | Optional. If provied the internal IV will be set to the 16 byte buffer and the stream offset will be set back to 0. |
limit | limit specifies the last byte to increment. If AES_BLOCK_SIZE, all bytes will be incremented. If 0, no bytes will be incremented |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_DoAesCtrEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pData, | ||
sbyte4 | dataLength, | ||
sbyte4 | encrypt, | ||
ubyte * | pIv | ||
) |
pCtx | Context to use for the cipher operation. |
pData | Data to encrypt or decrypt. |
dataLength | Length in bytes of the data to process. Does not have to be a multiple of the AES block size (16). |
encrypt | This value is unused. |
pIv | The 8 byte iv to be used. The counter will be reset to [nonce || iv || 1 ] |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_FinalAesCtrEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pOutput, | ||
sbyte4 * | pBytesWritten | ||
) |
This API should be used when the underlying implementation may return output of a differing length from that of the input and there may be leftover unprocessed bytes left to be encrypted or decryped.
pCtx | Pointer to an instantiated BulkCtx of aesCTRCipherContext type. |
pOutput | Buffer to hold the resulting output. This must have enough space available for the expected output. |
pBytesWritten | Contents will be set to the number of bytes actually written to the output buffer. |
OK
(0) if successful, otherwise a negative number error code from merrors.h. MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GetCounterBlockAESCTR | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte | pCounterBuffer[AES_BLOCK_SIZE] | ||
) |
The buffer must be at least the size of an AES block size.
pCtx | Context to retrieve the IV from. |
pCounterBuffer | Buffer to store the IV in. |
OK
(0) if successful, otherwise a negative number error code from merrors.h MOC_EXTERN MSTATUS CRYPTO_INTERFACE_UpdateAesCtrEx | ( | MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx | pCtx, |
ubyte * | pInput, | ||
sbyte4 | inputLen, | ||
ubyte * | pOutput, | ||
sbyte4 * | pBytesWritten | ||
) |
This API should be used in place of CRYPTO_INTERFACE_DoAESCTR
when the underlying implementation may return output of a differing length from that of the input (for example if only 16 byte blocks are returned).
pCtx | Pointer to an instantiated BulkCtx of aesCTRCipherContext type. |
pInput | Buffer of the input plaintext or ciphertext. |
inputLen | The length of the input buffer in bytes. |
pOutput | Buffer to hold the resulting output. This may be the same as the input buffer but must have enough space available for the expected output. |
pBytesWritten | Contents will be set to the number of bytes actually written to the output buffer. |
OK
(0) if successful, otherwise a negative number error code from merrors.h.