1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _AES_DRIVER_H 8 #define _AES_DRIVER_H 9 10 #include "driver_defs.h" 11 12 /****************************************************************************** 13 * TYPE DEFINITIONS 14 ******************************************************************************/ 15 16 /* The context data-base used by the AES functions on the low level */ 17 typedef struct AesContext { 18 /* IV buffer contains: on CTR mode - Counter, on other modes - IV */ 19 uint32_t ivBuf[AES_IV_SIZE_WORDS]; 20 /* AES Key: fixed size is 128 bit = 512/2*/ 21 uint32_t keyBuf[AES_256_BIT_KEY_SIZE_WORDS]; 22 /* keySize: 128, 192, 256 */ 23 keySizeId_t keySizeId; 24 /* mode: ECB, CBC, CTR, CBC-MAC, CMAC */ 25 aesMode_t mode; 26 /* Decrypt / Encrypt */ 27 cryptoDirection_t dir; 28 /* key type: user or hw(RKEK/PROV) */ 29 cryptoKeyType_t cryptoKey; 30 /* padding type */ 31 cryptoPaddingType_t padType; 32 /* first/middel/last */ 33 DataBlockType_t dataBlockType; 34 /* data input addr type */ 35 dataAddrType_t inputDataAddrType; 36 /* data output addr type */ 37 dataAddrType_t outputDataAddrType; 38 uint8_t tempBuff[AES_BLOCK_SIZE]; 39 } AesContext_t; 40 41 42 /****************************************************************************** 43 * FUNCTION PROTOTYPES 44 ******************************************************************************/ 45 46 /*! 47 * This function is used to process block(s) of data using the AES machine. 48 * 49 * \param aesCtx A pointer to the AES context buffer. 50 * \param pInputBuffInfo A structure which represents the data input buffer. 51 * \param pOutputBuffInfo A structure which represents the data output buffer. 52 * \param blockSize - number of bytes to copy. 53 * 54 * \return drvError_t defined in driver_defs.h. 55 */ 56 drvError_t ProcessAesDrv(AesContext_t *aesCtx, CCBuffInfo_t *pInputBuffInfo, CCBuffInfo_t *pOutputBuffInfo, uint32_t blockSize); 57 58 /*! 59 * This function is used as finish operation of AES on XCBC, CMAC, CBC 60 * and other modes besides XTS mode. 61 * The function may either be called after "InitCipher" or "ProcessCipher". 62 * 63 * \param aesCtx A pointer to the AES context buffer. 64 * \param pInputBuffInfo A structure which represents the data input buffer. 65 * \param pOutputBuffInfo A structure which represents the data output buffer. 66 * \param blockSize - number of bytes to copy. 67 * 68 * \return drvError_t defined in driver_defs.h. 69 */ 70 drvError_t FinishAesDrv(AesContext_t *aesCtx, CCBuffInfo_t *pInputBuffInfo, CCBuffInfo_t *pOutputBuffInfo, uint32_t blockSize); 71 72 73 #endif /* _AES_DRIVER_H */ 74 75