MAX32675 Peripheral Driver API
Peripheral Driver API for the MAX32675
aes.h
1 
6 /* ****************************************************************************
7  * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
23  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Except as contained in this notice, the name of Maxim Integrated
28  * Products, Inc. shall not be used except as stated in the Maxim Integrated
29  * Products, Inc. Branding Policy.
30  *
31  * The mere transfer of this software does not imply any licenses
32  * of trade secrets, proprietary technology, copyrights, patents,
33  * trademarks, maskwork rights, or any other form of intellectual
34  * property whatsoever. Maxim Integrated Products, Inc. retains all
35  * ownership rights.
36  *
37  *************************************************************************** */
38 
39 #ifndef _AES_H_
40 #define _AES_H_
41 
42 /***** Includes *****/
43 #include "aes_regs.h"
44 #include "aes_key_regs.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
55 
57 /***** Definitions *****/
58 
59 typedef void (*mxc_aes_complete_t) (void* req, int result);
60 
61 /* ************************************************************************* */
62 /* Cipher Definitions */
63 /* ************************************************************************* */
64 
69 typedef enum {
74 
79 typedef enum {
84 
89 typedef struct _mxc_aes_cipher_req_t {
90  uint32_t length;
91  uint32_t *inputData;
92  uint32_t *resultData;
95  mxc_aes_complete_t callback;
96 } mxc_aes_req_t;
97 
98 /***** Function Prototypes *****/
99 
100 /* ************************************************************************* */
101 /* Global Control/Configuration functions */
102 /* ************************************************************************* */
103 
109 int MXC_AES_Init (void);
110 
116 void MXC_AES_EnableInt (uint32_t interrupt);
117 
123 void MXC_AES_DisableInt (uint32_t interrupt);
124 
130 int MXC_AES_IsBusy (void);
131 
137 int MXC_AES_Shutdown (void);
138 
143 void MXC_AES_DMACallback (int ch, int error);
144 
148 void MXC_AES_GenerateKey (void);
149 
156 
163 
168 void MXC_AES_FlushInputFIFO (void);
169 
174 void MXC_AES_FlushOutputFIFO (void);
175 
180 void MXC_AES_Start (void);
181 
187 uint32_t MXC_AES_GetFlags (void);
188 
194 void MXC_AES_ClearFlags (uint32_t flags);
195 
204 int MXC_AES_Generic (mxc_aes_req_t* req);
205 
214 int MXC_AES_Encrypt (mxc_aes_req_t* req);
215 
224 int MXC_AES_Decrypt (mxc_aes_req_t* req);
225 
233 int MXC_AES_TXDMAConfig (void *src_addr, int len);
234 
242 int MXC_AES_RXDMAConfig (void *dest_addr, int len);
243 
252 int MXC_AES_GenericAsync (mxc_aes_req_t* req, uint8_t enc);
253 
262 int MXC_AES_EncryptAsync (mxc_aes_req_t* req);
263 
272 int MXC_AES_DecryptAsync (mxc_aes_req_t* req);
273 
279 void MXC_AES_SetExtKey(const void* key, mxc_aes_keys_t len);
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 
286 #endif /* _AES_H_ */
mxc_aes_enc_type_t
mxc_aes_enc_type_t
Enumeration type to select AES key source and encryption type.
Definition: aes.h:79
MXC_AES_DisableInt
void MXC_AES_DisableInt(uint32_t interrupt)
Disable AES Interrupts.
MXC_AES_RXDMAConfig
int MXC_AES_RXDMAConfig(void *dest_addr, int len)
Perform AES RX using DMA. Configures DMA request and receives data from AES FIFO.
_mxc_aes_cipher_req_t::callback
mxc_aes_complete_t callback
Callback function.
Definition: aes.h:95
MXC_AES_EnableInt
void MXC_AES_EnableInt(uint32_t interrupt)
Enable AES Interrupts.
MXC_AES_Start
void MXC_AES_Start(void)
Start AES Calculations.
MXC_AES_FlushInputFIFO
void MXC_AES_FlushInputFIFO(void)
Flush Input Data FIFO.
MXC_AES_Encrypt
int MXC_AES_Encrypt(mxc_aes_req_t *req)
Perform an encryption.
MXC_AES_Decrypt
int MXC_AES_Decrypt(mxc_aes_req_t *req)
Perform a decryption.
_mxc_aes_cipher_req_t::resultData
uint32_t * resultData
Pointer to encrypted data.
Definition: aes.h:92
MXC_AES_GetKeySize
mxc_aes_keys_t MXC_AES_GetKeySize(void)
Get the currently set key size.
MXC_AES_128BITS
@ MXC_AES_128BITS
Select AES-128 bit key.
Definition: aes.h:70
_mxc_aes_cipher_req_t
Structure used to set up AES request.
Definition: aes.h:89
mxc_aes_keys_t
mxc_aes_keys_t
Enumeration type to select AES key.
Definition: aes.h:69
MXC_AES_DECRYPT_EXT_KEY
@ MXC_AES_DECRYPT_EXT_KEY
Encryption using internal key.
Definition: aes.h:81
_mxc_aes_cipher_req_t::inputData
uint32_t * inputData
Pointer to input data.
Definition: aes.h:91
MXC_S_AES_CTRL_KEY_SIZE_AES256
#define MXC_S_AES_CTRL_KEY_SIZE_AES256
Definition: aes_regs.h:141
_mxc_aes_cipher_req_t::length
uint32_t length
Length of the data.
Definition: aes.h:90
MXC_AES_TXDMAConfig
int MXC_AES_TXDMAConfig(void *src_addr, int len)
Perform AES TX using DMA. Configures DMA request and starts the transmission.
MXC_AES_GenerateKey
void MXC_AES_GenerateKey(void)
This function should be called before encryption to genrate external key.
MXC_AES_DMACallback
void MXC_AES_DMACallback(int ch, int error)
This function should be called from the DMA Handler when using Async functions.
MXC_AES_Init
int MXC_AES_Init(void)
Enable portions of the AES.
MXC_AES_SetExtKey
void MXC_AES_SetExtKey(const void *key, mxc_aes_keys_t len)
Set the external key.
MXC_AES_GenericAsync
int MXC_AES_GenericAsync(mxc_aes_req_t *req, uint8_t enc)
Perform encryption or decryption using DMA.
MXC_AES_GetFlags
uint32_t MXC_AES_GetFlags(void)
Get Interrupt flags set.
MXC_AES_192BITS
@ MXC_AES_192BITS
Select AES-192 bit key.
Definition: aes.h:71
MXC_AES_DecryptAsync
int MXC_AES_DecryptAsync(mxc_aes_req_t *req)
Perform a decryption using Interrupt.
MXC_AES_256BITS
@ MXC_AES_256BITS
Select AES-256 bit key.
Definition: aes.h:72
MXC_S_AES_CTRL_KEY_SIZE_AES192
#define MXC_S_AES_CTRL_KEY_SIZE_AES192
Definition: aes_regs.h:139
MXC_AES_EncryptAsync
int MXC_AES_EncryptAsync(mxc_aes_req_t *req)
Perform an encryption using Interrupt.
MXC_AES_ClearFlags
void MXC_AES_ClearFlags(uint32_t flags)
Clear the interrupts.
MXC_AES_Shutdown
int MXC_AES_Shutdown(void)
Disable and reset portions of the AES.
MXC_AES_DECRYPT_INT_KEY
@ MXC_AES_DECRYPT_INT_KEY
Decryption using internal key.
Definition: aes.h:82
MXC_AES_ENCRYPT_EXT_KEY
@ MXC_AES_ENCRYPT_EXT_KEY
Encryption using External key.
Definition: aes.h:80
MXC_AES_FlushOutputFIFO
void MXC_AES_FlushOutputFIFO(void)
Flush Output Data FIFO.
MXC_AES_Generic
int MXC_AES_Generic(mxc_aes_req_t *req)
MXC_AES_IsBusy
int MXC_AES_IsBusy(void)
Checks the global AES Busy Status.
_mxc_aes_cipher_req_t::keySize
mxc_aes_keys_t keySize
Size of AES key.
Definition: aes.h:93
_mxc_aes_cipher_req_t::encryption
mxc_aes_enc_type_t encryption
Encrytion type or mxc_aes_enc_type_t.
Definition: aes.h:94
MXC_AES_SetKeySize
void MXC_AES_SetKeySize(mxc_aes_keys_t key)
Set Key size for encryption or decryption.
MXC_S_AES_CTRL_KEY_SIZE_AES128
#define MXC_S_AES_CTRL_KEY_SIZE_AES128
Definition: aes_regs.h:137