1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2015, Atmel Corporation
\r
6 * All rights reserved.
\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
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\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
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
33 /*------------------------------------------------------------------------------
\r
35 *------------------------------------------------------------------------------*/
\r
39 /*------------------------------------------------------------------------------*/
\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
49 * \brief Starts Manual encryption/decryption process.
\r
51 void aes_start(void);
\r
54 * \brief Resets the AES.
\r
55 * A software triggered hardware reset of the AES interface is performed.
\r
57 void aes_soft_reset(void);
\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
63 void aes_configure(uint32_t mode);
\r
66 * \brief Enables the selected interrupts sources on a AES peripheral.
\r
67 * \param sources Bitwise OR of selected interrupt sources.
\r
69 void aes_enable_it(uint32_t sources);
\r
72 * \brief Disables the selected interrupts sources on a AES peripheral.
\r
73 * \param sources Bitwise OR of selected interrupt sources.
\r
75 void aes_disable_it(uint32_t sources);
\r
78 * \brief Get the current status register of the given AES peripheral.
\r
79 * \return AES status register.
\r
81 extern uint32_t aes_get_status(void);
\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
89 void aes_write_key(const uint32_t * key, uint32_t len);
\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
96 void aes_set_input(uint32_t * data);
\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
103 void aes_get_output(uint32_t * data);
\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
110 void aes_set_vector(const uint32_t * vector);
\r
113 * \brief Set Length in bytes of the Additional Authenticated Data that are to
\r
115 * \param len Length.
\r
117 void aes_set_aad_len(uint32_t len);
\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
124 void aes_set_data_len(uint32_t len);
\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
133 void aes_set_gcm_hash(uint32_t * hash);
\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
140 void aes_get_gcm_tag(uint32_t * tag);
\r
143 * \brief Reports the current value of the 32-bit GCM counter.
\r
144 * \param counter Pointer to value of GCM counter.
\r
146 void aes_get_gcm_counter(uint32_t * counter);
\r
149 * \brief Get the four 32-bit data containing the 128-bit H value computed from
\r
151 * \param h Pointer to the word that has been encrypted/decrypted.
\r
153 void aes_get_gcm_hash_subkey(uint32_t * h);
\r
155 #endif /* #ifndef _AES_ */
\r