Easily add all supported connectivity methods to your mbed OS project
stm-spirit1-rf-driver/source/libs/spirit1/SPIRIT1_Library/Inc/SPIRIT_Aes.h@0:615f90842ce8, 2017-07-12 (annotated)
- Committer:
- MACRUM
- Date:
- Wed Jul 12 10:52:58 2017 +0000
- Revision:
- 0:615f90842ce8
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:615f90842ce8 | 1 | /** |
MACRUM | 0:615f90842ce8 | 2 | ****************************************************************************** |
MACRUM | 0:615f90842ce8 | 3 | * @file SPIRIT_Aes.h |
MACRUM | 0:615f90842ce8 | 4 | * @author VMA division - AMS |
MACRUM | 0:615f90842ce8 | 5 | * @version 3.2.2 |
MACRUM | 0:615f90842ce8 | 6 | * @date 08-July-2015 |
MACRUM | 0:615f90842ce8 | 7 | * @brief Configuration and management of SPIRIT AES Engine. |
MACRUM | 0:615f90842ce8 | 8 | * |
MACRUM | 0:615f90842ce8 | 9 | * @details |
MACRUM | 0:615f90842ce8 | 10 | * |
MACRUM | 0:615f90842ce8 | 11 | * In order to encrypt data, the user must manage the AES_END IRQ. |
MACRUM | 0:615f90842ce8 | 12 | * The data have to be splitted in blocks of 16 bytes and written |
MACRUM | 0:615f90842ce8 | 13 | * into the <i>AES DATA IN registers</i>. Then, after the key is written |
MACRUM | 0:615f90842ce8 | 14 | * into the <i>AES KEY registers</i>, a command of <i>Execute encryption</i> |
MACRUM | 0:615f90842ce8 | 15 | * has to be sent. |
MACRUM | 0:615f90842ce8 | 16 | * |
MACRUM | 0:615f90842ce8 | 17 | * <b>Example:</b> |
MACRUM | 0:615f90842ce8 | 18 | * @code |
MACRUM | 0:615f90842ce8 | 19 | * |
MACRUM | 0:615f90842ce8 | 20 | * SpiritAesWriteDataIn(data_buff , N_BYTES); |
MACRUM | 0:615f90842ce8 | 21 | * SpiritAesExecuteEncryption(); |
MACRUM | 0:615f90842ce8 | 22 | * |
MACRUM | 0:615f90842ce8 | 23 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
MACRUM | 0:615f90842ce8 | 24 | * aes_end_flag=RESET; |
MACRUM | 0:615f90842ce8 | 25 | * |
MACRUM | 0:615f90842ce8 | 26 | * SpiritAesReadDataOut(enc_data_buff , N_BYTES); |
MACRUM | 0:615f90842ce8 | 27 | * |
MACRUM | 0:615f90842ce8 | 28 | * @endcode |
MACRUM | 0:615f90842ce8 | 29 | * |
MACRUM | 0:615f90842ce8 | 30 | * In order to decrypt data, the user must manage the AES_END IRQ and have a decryption key. |
MACRUM | 0:615f90842ce8 | 31 | * There are two operative modes to make the data decryption: |
MACRUM | 0:615f90842ce8 | 32 | * <ul> |
MACRUM | 0:615f90842ce8 | 33 | * <li> Derive the decryption key from the encryption key and decrypt data directly |
MACRUM | 0:615f90842ce8 | 34 | * using the <i>SpiritAesDeriveDecKeyExecuteDec()</i> function |
MACRUM | 0:615f90842ce8 | 35 | * |
MACRUM | 0:615f90842ce8 | 36 | * <b>Example:</b> |
MACRUM | 0:615f90842ce8 | 37 | * @code |
MACRUM | 0:615f90842ce8 | 38 | * |
MACRUM | 0:615f90842ce8 | 39 | * SpiritAesWriteDataIn(enc_data_buff , N_BYTES); |
MACRUM | 0:615f90842ce8 | 40 | * SpiritAesDeriveDecKeyExecuteDec(); |
MACRUM | 0:615f90842ce8 | 41 | * |
MACRUM | 0:615f90842ce8 | 42 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
MACRUM | 0:615f90842ce8 | 43 | * aes_end_flag=RESET; |
MACRUM | 0:615f90842ce8 | 44 | * |
MACRUM | 0:615f90842ce8 | 45 | * SpiritAesReadDataOut(data_buff , N_BYTES); |
MACRUM | 0:615f90842ce8 | 46 | * |
MACRUM | 0:615f90842ce8 | 47 | * @endcode |
MACRUM | 0:615f90842ce8 | 48 | * </li> |
MACRUM | 0:615f90842ce8 | 49 | * |
MACRUM | 0:615f90842ce8 | 50 | * <li> Derive the decryption key from the encryption key using the <i>SpiritAesDeriveDecKeyFromEnc()</i> |
MACRUM | 0:615f90842ce8 | 51 | * function, store it into the <i>AES KEY registers</i> and then decrypt data using the |
MACRUM | 0:615f90842ce8 | 52 | * <i>SpiritAesExecuteDecryption()</i> function |
MACRUM | 0:615f90842ce8 | 53 | * |
MACRUM | 0:615f90842ce8 | 54 | * <b>Example:</b> |
MACRUM | 0:615f90842ce8 | 55 | * @code |
MACRUM | 0:615f90842ce8 | 56 | * |
MACRUM | 0:615f90842ce8 | 57 | * SpiritAesWriteDataIn(key_enc , 16); |
MACRUM | 0:615f90842ce8 | 58 | * SpiritAesDeriveDecKeyFromEnc(); |
MACRUM | 0:615f90842ce8 | 59 | * |
MACRUM | 0:615f90842ce8 | 60 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
MACRUM | 0:615f90842ce8 | 61 | * aes_end_flag=RESET; |
MACRUM | 0:615f90842ce8 | 62 | * |
MACRUM | 0:615f90842ce8 | 63 | * SpiritAesReadDataOut(key_dec , 16); |
MACRUM | 0:615f90842ce8 | 64 | * |
MACRUM | 0:615f90842ce8 | 65 | * SpiritAesWriteKey(key_dec); |
MACRUM | 0:615f90842ce8 | 66 | * SpiritAesWriteDataIn(enc_data_buff , 16); |
MACRUM | 0:615f90842ce8 | 67 | * SpiritAesExecuteDecryption(); |
MACRUM | 0:615f90842ce8 | 68 | * |
MACRUM | 0:615f90842ce8 | 69 | * while(!aes_end_flag); // the flag is set by the ISR routine which manages the AES_END irq |
MACRUM | 0:615f90842ce8 | 70 | * aes_end_flag=RESET; |
MACRUM | 0:615f90842ce8 | 71 | * |
MACRUM | 0:615f90842ce8 | 72 | * SpiritAesReadDataOut(data_buff , N_BYTES); |
MACRUM | 0:615f90842ce8 | 73 | * |
MACRUM | 0:615f90842ce8 | 74 | * @endcode |
MACRUM | 0:615f90842ce8 | 75 | * </li> |
MACRUM | 0:615f90842ce8 | 76 | * </ul> |
MACRUM | 0:615f90842ce8 | 77 | * |
MACRUM | 0:615f90842ce8 | 78 | * @attention |
MACRUM | 0:615f90842ce8 | 79 | * |
MACRUM | 0:615f90842ce8 | 80 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
MACRUM | 0:615f90842ce8 | 81 | * |
MACRUM | 0:615f90842ce8 | 82 | * Redistribution and use in source and binary forms, with or without modification, |
MACRUM | 0:615f90842ce8 | 83 | * are permitted provided that the following conditions are met: |
MACRUM | 0:615f90842ce8 | 84 | * 1. Redistributions of source code must retain the above copyright notice, |
MACRUM | 0:615f90842ce8 | 85 | * this list of conditions and the following disclaimer. |
MACRUM | 0:615f90842ce8 | 86 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
MACRUM | 0:615f90842ce8 | 87 | * this list of conditions and the following disclaimer in the documentation |
MACRUM | 0:615f90842ce8 | 88 | * and/or other materials provided with the distribution. |
MACRUM | 0:615f90842ce8 | 89 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
MACRUM | 0:615f90842ce8 | 90 | * may be used to endorse or promote products derived from this software |
MACRUM | 0:615f90842ce8 | 91 | * without specific prior written permission. |
MACRUM | 0:615f90842ce8 | 92 | * |
MACRUM | 0:615f90842ce8 | 93 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
MACRUM | 0:615f90842ce8 | 94 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
MACRUM | 0:615f90842ce8 | 95 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
MACRUM | 0:615f90842ce8 | 96 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
MACRUM | 0:615f90842ce8 | 97 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
MACRUM | 0:615f90842ce8 | 98 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
MACRUM | 0:615f90842ce8 | 99 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
MACRUM | 0:615f90842ce8 | 100 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
MACRUM | 0:615f90842ce8 | 101 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
MACRUM | 0:615f90842ce8 | 102 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
MACRUM | 0:615f90842ce8 | 103 | * |
MACRUM | 0:615f90842ce8 | 104 | ****************************************************************************** |
MACRUM | 0:615f90842ce8 | 105 | */ |
MACRUM | 0:615f90842ce8 | 106 | |
MACRUM | 0:615f90842ce8 | 107 | /* Define to prevent recursive inclusion -------------------------------------*/ |
MACRUM | 0:615f90842ce8 | 108 | #ifndef __SPIRIT_AES_H |
MACRUM | 0:615f90842ce8 | 109 | #define __SPIRIT_AES_H |
MACRUM | 0:615f90842ce8 | 110 | |
MACRUM | 0:615f90842ce8 | 111 | |
MACRUM | 0:615f90842ce8 | 112 | /* Includes ------------------------------------------------------------------*/ |
MACRUM | 0:615f90842ce8 | 113 | |
MACRUM | 0:615f90842ce8 | 114 | #include "SPIRIT_Regs.h" |
MACRUM | 0:615f90842ce8 | 115 | #include "SPIRIT_Types.h" |
MACRUM | 0:615f90842ce8 | 116 | |
MACRUM | 0:615f90842ce8 | 117 | |
MACRUM | 0:615f90842ce8 | 118 | #ifdef __cplusplus |
MACRUM | 0:615f90842ce8 | 119 | extern "C" { |
MACRUM | 0:615f90842ce8 | 120 | #endif |
MACRUM | 0:615f90842ce8 | 121 | |
MACRUM | 0:615f90842ce8 | 122 | |
MACRUM | 0:615f90842ce8 | 123 | /** |
MACRUM | 0:615f90842ce8 | 124 | * @addtogroup SPIRIT_Libraries |
MACRUM | 0:615f90842ce8 | 125 | * @{ |
MACRUM | 0:615f90842ce8 | 126 | */ |
MACRUM | 0:615f90842ce8 | 127 | |
MACRUM | 0:615f90842ce8 | 128 | |
MACRUM | 0:615f90842ce8 | 129 | /** |
MACRUM | 0:615f90842ce8 | 130 | * @defgroup SPIRIT_Aes AES |
MACRUM | 0:615f90842ce8 | 131 | * @brief Configuration and management of SPIRIT AES Engine. |
MACRUM | 0:615f90842ce8 | 132 | * @details See the file <i>@ref SPIRIT_Aes.h</i> for more details. |
MACRUM | 0:615f90842ce8 | 133 | * @{ |
MACRUM | 0:615f90842ce8 | 134 | */ |
MACRUM | 0:615f90842ce8 | 135 | |
MACRUM | 0:615f90842ce8 | 136 | /** |
MACRUM | 0:615f90842ce8 | 137 | * @defgroup Aes_Exported_Types AES Exported Types |
MACRUM | 0:615f90842ce8 | 138 | * @{ |
MACRUM | 0:615f90842ce8 | 139 | */ |
MACRUM | 0:615f90842ce8 | 140 | |
MACRUM | 0:615f90842ce8 | 141 | /** |
MACRUM | 0:615f90842ce8 | 142 | * @} |
MACRUM | 0:615f90842ce8 | 143 | */ |
MACRUM | 0:615f90842ce8 | 144 | |
MACRUM | 0:615f90842ce8 | 145 | |
MACRUM | 0:615f90842ce8 | 146 | /** |
MACRUM | 0:615f90842ce8 | 147 | * @defgroup Aes_Exported_Constants AES Exported Constants |
MACRUM | 0:615f90842ce8 | 148 | * @{ |
MACRUM | 0:615f90842ce8 | 149 | */ |
MACRUM | 0:615f90842ce8 | 150 | |
MACRUM | 0:615f90842ce8 | 151 | |
MACRUM | 0:615f90842ce8 | 152 | /** |
MACRUM | 0:615f90842ce8 | 153 | * @} |
MACRUM | 0:615f90842ce8 | 154 | */ |
MACRUM | 0:615f90842ce8 | 155 | |
MACRUM | 0:615f90842ce8 | 156 | |
MACRUM | 0:615f90842ce8 | 157 | /** |
MACRUM | 0:615f90842ce8 | 158 | * @defgroup Aes_Exported_Macros AES Exported Macros |
MACRUM | 0:615f90842ce8 | 159 | * @{ |
MACRUM | 0:615f90842ce8 | 160 | */ |
MACRUM | 0:615f90842ce8 | 161 | |
MACRUM | 0:615f90842ce8 | 162 | |
MACRUM | 0:615f90842ce8 | 163 | /** |
MACRUM | 0:615f90842ce8 | 164 | * @} |
MACRUM | 0:615f90842ce8 | 165 | */ |
MACRUM | 0:615f90842ce8 | 166 | |
MACRUM | 0:615f90842ce8 | 167 | |
MACRUM | 0:615f90842ce8 | 168 | /** |
MACRUM | 0:615f90842ce8 | 169 | * @defgroup Aes_Exported_Functions AES Exported Functions |
MACRUM | 0:615f90842ce8 | 170 | * @{ |
MACRUM | 0:615f90842ce8 | 171 | */ |
MACRUM | 0:615f90842ce8 | 172 | |
MACRUM | 0:615f90842ce8 | 173 | void SpiritAesMode(SpiritFunctionalState xNewState); |
MACRUM | 0:615f90842ce8 | 174 | void SpiritAesWriteDataIn(uint8_t* pcBufferDataIn, uint8_t cDataLength); |
MACRUM | 0:615f90842ce8 | 175 | void SpiritAesReadDataOut(uint8_t* pcBufferDataOut, uint8_t cDataLength); |
MACRUM | 0:615f90842ce8 | 176 | void SpiritAesWriteKey(uint8_t* pcKey); |
MACRUM | 0:615f90842ce8 | 177 | void SpiritAesReadKey(uint8_t* pcKey); |
MACRUM | 0:615f90842ce8 | 178 | void SpiritAesDeriveDecKeyFromEnc(void); |
MACRUM | 0:615f90842ce8 | 179 | void SpiritAesExecuteEncryption(void); |
MACRUM | 0:615f90842ce8 | 180 | void SpiritAesExecuteDecryption(void); |
MACRUM | 0:615f90842ce8 | 181 | void SpiritAesDeriveDecKeyExecuteDec(void); |
MACRUM | 0:615f90842ce8 | 182 | |
MACRUM | 0:615f90842ce8 | 183 | /** |
MACRUM | 0:615f90842ce8 | 184 | * @} |
MACRUM | 0:615f90842ce8 | 185 | */ |
MACRUM | 0:615f90842ce8 | 186 | |
MACRUM | 0:615f90842ce8 | 187 | /** |
MACRUM | 0:615f90842ce8 | 188 | * @} |
MACRUM | 0:615f90842ce8 | 189 | */ |
MACRUM | 0:615f90842ce8 | 190 | |
MACRUM | 0:615f90842ce8 | 191 | |
MACRUM | 0:615f90842ce8 | 192 | /** |
MACRUM | 0:615f90842ce8 | 193 | * @} |
MACRUM | 0:615f90842ce8 | 194 | */ |
MACRUM | 0:615f90842ce8 | 195 | |
MACRUM | 0:615f90842ce8 | 196 | |
MACRUM | 0:615f90842ce8 | 197 | |
MACRUM | 0:615f90842ce8 | 198 | |
MACRUM | 0:615f90842ce8 | 199 | #ifdef __cplusplus |
MACRUM | 0:615f90842ce8 | 200 | } |
MACRUM | 0:615f90842ce8 | 201 | #endif |
MACRUM | 0:615f90842ce8 | 202 | |
MACRUM | 0:615f90842ce8 | 203 | #endif |
MACRUM | 0:615f90842ce8 | 204 | |
MACRUM | 0:615f90842ce8 | 205 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |