1 /* 2 * Copyright (c) 2001-2021, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 8 #ifndef _AESCCM_DRIVER_H 9 #define _AESCCM_DRIVER_H 10 11 /* 12 * All the includes that are needed for code using this file to 13 * compile correctly should be #included here. 14 */ 15 #include "driver_defs.h" 16 #include "cc_aes_defs.h" 17 18 #ifdef __cplusplus 19 extern "C" 20 { 21 #endif 22 23 /************************ Defines ******************************/ 24 25 /************************ Enums ********************************/ 26 27 /************************ Typedefs ****************************/ 28 29 /* NOTE: make sure struct size equals to CC_AESCCM_USER_CTX_SIZE_IN_WORDS */ 30 typedef struct AesCcmContext_t { 31 /* IV buffer */ 32 uint32_t ivBuf[AES_IV_SIZE_WORDS]; 33 /* AES max key size supported is 256 bit */ 34 uint32_t keyBuf[AES_256_BIT_KEY_SIZE_WORDS]; 35 /* AES counter for CTR mode */ 36 uint32_t ctrStateBuf[AES_IV_SIZE_WORDS]; 37 /* scratch buffer for internal use */ 38 uint8_t tempBuff[CC_AES_BLOCK_SIZE_IN_BYTES]; 39 /* mode: CBC_MAC, CTR, CCMAPD, CCMAPE */ 40 aesMode_t mode; 41 /* keySize: 128, 192, 256 */ 42 keySizeId_t keySizeId; 43 /* Decrypt / Encrypt */ 44 cryptoDirection_t dir; 45 /* Data size (Plain/Cipher text) */ 46 uint32_t dataSize; 47 /* nonce size */ 48 uint8_t sizeOfN; 49 /* AAD size */ 50 uint32_t aadSize; 51 /* T mac size */ 52 uint8_t sizeOfT; 53 }AesCcmContext_t; 54 55 56 /****************************************************************************** 57 * FUNCTION PROTOTYPES 58 ******************************************************************************/ 59 60 /*! 61 * This function is used to process block of data using the AES machine. 62 * It is optimized to support only CBC_MAC, CTR, CCMPE, CCMPD. 63 * 64 * \param pAesCcmCtx A pointer to the AEAD context buffer 65 * \param pInputBuffInfo A structure which represents the data input buffer. 66 * \param pOutputBuffInfo A structure which represents the data output buffer. 67 * \param blockSize - number of bytes to copy 68 * 69 * \return drvError_t defined in driver_defs.h 70 */ 71 drvError_t ProcessAesCcmDrv(AesCcmContext_t *pAesCcmCtx, CCBuffInfo_t *pInputBuffInfo, CCBuffInfo_t *pOutputBuffInfo, uint32_t blockSize); 72 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif 79 80 81