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 _PROD_CRYPTO_DRIVER_H 8 #define _PROD_CRYPTO_DRIVER_H 9 10 #include "cc_cmpu.h" 11 #include "cc_otp_defs.h" 12 #include "driver_defs.h" 13 #include "aes_driver.h" 14 15 /* The AES block size in words and in bytes */ 16 #define CC_PROD_AES_BLOCK_SIZE_IN_WORDS 4 17 #define CC_PROD_AES_BLOCK_SIZE_IN_BYTES (CC_PROD_AES_BLOCK_SIZE_IN_WORDS * CC_32BIT_WORD_SIZE) 18 19 /* The size of the IV or counter buffer */ 20 #define CC_PROD_AES_IV_COUNTER_SIZE_IN_WORDS CC_PROD_AES_BLOCK_SIZE_IN_WORDS 21 #define CC_PROD_AES_IV_COUNTER_SIZE_IN_BYTES (CC_PROD_AES_IV_COUNTER_SIZE_IN_WORDS * CC_32BIT_WORD_SIZE) 22 23 #define CC_PROD_AES_Key256Bits_SIZE_IN_WORDS 8 24 #define CC_PROD_AES_Key256Bits_SIZE_IN_BYTES (CC_PROD_AES_Key256Bits_SIZE_IN_WORDS * CC_32BIT_WORD_SIZE) 25 26 27 uint32_t CC_PROD_AesCcmDecrypt(uint8_t *pKey, 28 uint32_t keySizeInBytes, 29 uint8_t *pNonce, 30 uint32_t nonceSizeInBytes, 31 uint8_t *pAddData, 32 uint32_t addDataSizeInBytes, 33 uint8_t *pCipherData, 34 uint32_t dataSize, 35 uint8_t *pPlainBuff, 36 uint32_t tagSize, 37 uint8_t *pTagBuff, 38 unsigned long workspaceAddr, 39 uint32_t workspaceSize); 40 41 uint32_t CC_PROD_Aes(aesMode_t cipherMode, 42 cryptoDirection_t encDecDir, 43 cryptoKeyType_t keyType, 44 uint8_t *pKey, 45 uint32_t keySize, 46 uint8_t *pIv, 47 uint32_t ivSize, 48 uint32_t *pDataIn, 49 uint32_t dataInSize, 50 uint32_t *pOutbuff); 51 52 uint32_t CC_PROD_AesInit(AesContext_t *pAesCtx, 53 aesMode_t cipherMode, 54 cryptoDirection_t encDecDir, 55 cryptoKeyType_t keyType, 56 uint8_t *pKey, 57 uint32_t keySize, 58 uint8_t *pIv, 59 uint32_t ivSize); 60 61 uint32_t CC_PROD_AesProcess(AesContext_t *pAesCtx, 62 uint32_t *pDataIn, 63 uint32_t dataInSize, 64 uint32_t *pOutbuff); 65 66 uint32_t CC_PROD_KeyDerivation( cryptoKeyType_t keyType, 67 uint8_t *pUserKey, 68 const uint8_t *pLabel, 69 size_t labelSize, 70 const uint8_t *pContextData, 71 size_t contextSize, 72 uint8_t *pDerivedKey); 73 74 #endif //_PROD_CRYPTO_DRIVER_H 75 76