]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/AtmelFiles/drivers/peripherals/aes.h
Add SAMA5D2 Xplained IAR demo.
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D2x_Xplained_IAR / AtmelFiles / drivers / peripherals / aes.h
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License\r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2015, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\r
8  * Redistribution and use in source and binary forms, with or without\r
9  * modification, are permitted provided that the following conditions are met:\r
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\r
14  * Atmel's name may not be used to endorse or promote products derived from\r
15  * this software without specific prior written permission.\r
16  *\r
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
27  * ----------------------------------------------------------------------------\r
28  */\r
29 \r
30 #ifndef _AES_\r
31 #define _AES_\r
32 \r
33 /*------------------------------------------------------------------------------\r
34  *         Headers\r
35  *------------------------------------------------------------------------------*/\r
36 \r
37 #include "chip.h"\r
38 \r
39 /*------------------------------------------------------------------------------*/\r
40 /*         Definition                                                           */\r
41 /*------------------------------------------------------------------------------*/\r
42 #define AES_MR_CIPHER_ENCRYPT 1\r
43 #define AES_MR_CIPHER_DECRYPT 0\r
44 /*------------------------------------------------------------------------------*/\r
45 /*         Exported functions                                                   */\r
46 /*------------------------------------------------------------------------------*/\r
47 \r
48 /**\r
49  * \brief Starts Manual encryption/decryption process.\r
50  */\r
51 void aes_start(void);\r
52 \r
53 /**\r
54  * \brief Resets the AES.\r
55  * A software triggered hardware reset of the AES interface is performed.\r
56  */\r
57 void aes_soft_reset(void);\r
58 \r
59 /**\r
60  * \brief Configures an AES peripheral with the specified parameters.\r
61  *  \param mode  Desired value for the AES mode register (see the datasheet).\r
62  */\r
63 void aes_configure(uint32_t mode);\r
64 \r
65 /**\r
66  * \brief Enables the selected interrupts sources on a AES peripheral.\r
67  * \param sources  Bitwise OR of selected interrupt sources.\r
68  */\r
69 void aes_enable_it(uint32_t sources);\r
70 \r
71 /**\r
72  * \brief Disables the selected interrupts sources on a AES peripheral.\r
73  * \param sources  Bitwise OR of selected interrupt sources.\r
74  */\r
75 void aes_disable_it(uint32_t sources);\r
76 \r
77 /**\r
78  * \brief Get the current status register of the given AES peripheral.\r
79  * \return  AES status register.\r
80  */\r
81 extern uint32_t aes_get_status(void);\r
82 \r
83 /**\r
84  * \brief Set the 128-bit/192-bit/256-bit cryptographic key used for\r
85  * encryption/decryption.\r
86  * \param key  Pointer to a 16/24/32 bytes cipher key.\r
87  * \param len  Length of the key, in bytes.\r
88  */\r
89 void aes_write_key(const uint32_t * key, uint32_t len);\r
90 \r
91 /**\r
92  * \brief Set the for 32-bit input Data allow to set the 128-bit data block used\r
93  * for encryption/decryption.\r
94  * \param data  Pointer to the 16-bytes data to cipher/decipher.\r
95  */\r
96 void aes_set_input(uint32_t * data);\r
97 \r
98 /**\r
99  * \brief Get the four 32-bit data contain the 128-bit data block which has\r
100  * been encrypted/decrypted.\r
101  * \param data  Pointer to the word that has been encrypted/decrypted..\r
102  */\r
103 void aes_get_output(uint32_t * data);\r
104 \r
105 /**\r
106  * \brief Set four 64-bit initialization vector data block, which is used by\r
107  * some modes of operation as an additional initial input.\r
108  * \param vector  Pointer to the word of the initialization vector.\r
109  */\r
110 void aes_set_vector(const uint32_t * vector);\r
111 \r
112 /**\r
113  * \brief Set Length in bytes of the Additional Authenticated Data that are to\r
114  * be processed.\r
115  * \param len  Length.\r
116  */\r
117 void aes_set_aad_len(uint32_t len);\r
118 \r
119 /**\r
120  * \brief Set Length in bytes of the plaintext/ciphertext data (that is, the C\r
121  * portion of the message) that are to be processed.\r
122  * \param len  Length.\r
123  */\r
124 void aes_set_data_len(uint32_t len);\r
125 \r
126 /**\r
127  * \brief Set The four 32-bit Hash Word registers expose the intermediate GHASH\r
128  * value. May be read to save the current GHASH value so processing can later be\r
129  * resumed, presumably on a later message fragment.\r
130  * Modes of operation as an additional initial input.\r
131  * \param hash  Pointer to the word of the hash.\r
132  */\r
133 void aes_set_gcm_hash(uint32_t * hash);\r
134 \r
135 /**\r
136  * \brief Get The four 32-bit Tag which contain the final 128-bit GCM\r
137  * Authentication tag 'T' when GCM processing is complete.\r
138  * \param tag  Pointer to the word of the tag.\r
139  */\r
140 void aes_get_gcm_tag(uint32_t * tag);\r
141 \r
142 /**\r
143  * \brief Reports the current value of the 32-bit GCM counter.\r
144  * \param counter  Pointer to value of GCM counter.\r
145  */\r
146 void aes_get_gcm_counter(uint32_t * counter);\r
147 \r
148 /**\r
149  * \brief Get the four 32-bit data containing the 128-bit H value computed from\r
150  * the KEYW value.\r
151  * \param h  Pointer to the word that has been encrypted/decrypted.\r
152  */\r
153 void aes_get_gcm_hash_subkey(uint32_t * h);\r
154 \r
155 #endif                          /* #ifndef _AES_ */\r