1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 /*! 7 @addtogroup aes_ext_dma 8 @{ 9 */ 10 11 /*! 12 @file 13 @brief This file contains all the CryptoCell AES external DMA APIs, their 14 enums and definitions. 15 */ 16 17 18 #ifndef _MBEDTLS_AES_EXT_DMA_H 19 #define _MBEDTLS_AES_EXT_DMA_H 20 21 #include "cc_aes_defs_proj.h" 22 #include "cc_pal_types.h" 23 24 25 #ifdef __cplusplus 26 extern "C" 27 { 28 #endif 29 30 /*! 31 @brief This function initializes the external DMA Control. It configures the 32 AES mode, the direction (encryption or decryption), and the data size. 33 34 @return \c CC_OK on success. 35 @return A non-zero value from cc_aes_error.h on failure. 36 */ 37 int mbedtls_aes_ext_dma_init( 38 /*! [in] AES key size. Valid values are: 128 bits, 192 bits, or 256 bits. */ 39 unsigned int keybits, 40 /*! [in] 0: Encrypt. 1: Decrypt. */ 41 int encryptDecryptFlag, 42 /*! [in] AES mode. Supported modes are: ECB, CBC, CTR, CBC_MAC, CMAC, 43 or OFB. */ 44 CCAesOperationMode_t operationMode 45 ); 46 47 48 /*! 49 @brief This function configures the key. 50 51 @return \c CC_OK on success. 52 @return A non-zero value from cc_aes_error.h on failure. 53 */ 54 int mbedtls_aes_ext_dma_set_key( 55 /*! [in] AES mode. Supported modes are: ECB, CBC, CTR, CBC_MAC, CMAC or 56 OFB. */ 57 CCAesOperationMode_t operationMode, 58 /*! [in] The AES key buffer. */ 59 const unsigned char *key, 60 /*! [in] The size of the AES Key. Valid values are: 128 bits, 192 bits, or 61 256 bits. */ 62 unsigned int keybits 63 ); 64 65 66 /*! 67 @brief This function configures the IV. 68 69 @return \c CC_OK on success. 70 @return A non-zero value from cc_aes_error.h on failure. 71 */ 72 int mbedtls_aes_ext_dma_set_iv( 73 /*! [in] AES mode. Supported modes are: ECB, CBC, CTR, CBC_MAC, CMAC or 74 OFB. */ 75 CCAesOperationMode_t operationMode, 76 /*! [in] The AES IV buffer. */ 77 unsigned char *iv, 78 /*! [in] The size of the IV. Must be 16 bytes. */ 79 unsigned int iv_size 80 ); 81 82 /*! 83 @brief This function configures data size which will be written to external 84 DMA interface. 85 86 @return \c CC_OK on success. 87 @return A non-zero value from cc_aes_error.h on failure. 88 */ 89 int mbedtls_aes_ext_dma_set_data_size( 90 /*! [in] Size of input data in bytes. */ 91 uint32_t dataSize, 92 /*! [in] The AES mode. Supported modes are: ECB, CBC, CTR, CBC_MAC, CMAC 93 or OFB. */ 94 CCAesOperationMode_t operationMode 95 ); 96 97 98 /*! 99 @brief This function returns the IV after an AES CMAC or a CBCMAC operation. 100 101 @return \c CC_OK on success. 102 @return A non-zero value from cc_aes_error.h on failure. 103 */ 104 int mbedtls_aes_ext_dma_finish( 105 /*! [in] The AES mode. Supported modes are: ECB, CBC, CTR, CBC_MAC, CMAC or OFB. */ 106 CCAesOperationMode_t operationMode, 107 /*! [out] The AES IV buffer. */ 108 unsigned char *iv, 109 /*! [in] The size of the IV. Must be 16 bytes. */ 110 unsigned int iv_size 111 ); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 /*! 118 @} 119 */ 120 121 #endif /* #ifndef MBEDTLS_AES_EXT_DMA_H */ 122