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