wifi test
Dependencies: X_NUCLEO_IKS01A2 mbed-http
easy-connect/stm-spirit1-rf-driver/source/libs/spirit1/SPIRIT1_Library/Src/SPIRIT_Aes.c@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.c |
| 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 | * @attention |
| JMF | 0:24d3eb812fd4 | 10 | * |
| JMF | 0:24d3eb812fd4 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
| JMF | 0:24d3eb812fd4 | 12 | * |
| JMF | 0:24d3eb812fd4 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| JMF | 0:24d3eb812fd4 | 14 | * are permitted provided that the following conditions are met: |
| JMF | 0:24d3eb812fd4 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| JMF | 0:24d3eb812fd4 | 16 | * this list of conditions and the following disclaimer. |
| JMF | 0:24d3eb812fd4 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| JMF | 0:24d3eb812fd4 | 18 | * this list of conditions and the following disclaimer in the documentation |
| JMF | 0:24d3eb812fd4 | 19 | * and/or other materials provided with the distribution. |
| JMF | 0:24d3eb812fd4 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| JMF | 0:24d3eb812fd4 | 21 | * may be used to endorse or promote products derived from this software |
| JMF | 0:24d3eb812fd4 | 22 | * without specific prior written permission. |
| JMF | 0:24d3eb812fd4 | 23 | * |
| JMF | 0:24d3eb812fd4 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| JMF | 0:24d3eb812fd4 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| JMF | 0:24d3eb812fd4 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| JMF | 0:24d3eb812fd4 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| JMF | 0:24d3eb812fd4 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| JMF | 0:24d3eb812fd4 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| JMF | 0:24d3eb812fd4 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| JMF | 0:24d3eb812fd4 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| JMF | 0:24d3eb812fd4 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| JMF | 0:24d3eb812fd4 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| JMF | 0:24d3eb812fd4 | 34 | * |
| JMF | 0:24d3eb812fd4 | 35 | ****************************************************************************** |
| JMF | 0:24d3eb812fd4 | 36 | */ |
| JMF | 0:24d3eb812fd4 | 37 | |
| JMF | 0:24d3eb812fd4 | 38 | |
| JMF | 0:24d3eb812fd4 | 39 | /* Includes ------------------------------------------------------------------*/ |
| JMF | 0:24d3eb812fd4 | 40 | #include "SPIRIT_Aes.h" |
| JMF | 0:24d3eb812fd4 | 41 | #include "MCU_Interface.h" |
| JMF | 0:24d3eb812fd4 | 42 | |
| JMF | 0:24d3eb812fd4 | 43 | |
| JMF | 0:24d3eb812fd4 | 44 | /** |
| JMF | 0:24d3eb812fd4 | 45 | * @addtogroup SPIRIT_Libraries |
| JMF | 0:24d3eb812fd4 | 46 | * @{ |
| JMF | 0:24d3eb812fd4 | 47 | */ |
| JMF | 0:24d3eb812fd4 | 48 | |
| JMF | 0:24d3eb812fd4 | 49 | |
| JMF | 0:24d3eb812fd4 | 50 | /** |
| JMF | 0:24d3eb812fd4 | 51 | * @addtogroup SPIRIT_Aes |
| JMF | 0:24d3eb812fd4 | 52 | * @{ |
| JMF | 0:24d3eb812fd4 | 53 | */ |
| JMF | 0:24d3eb812fd4 | 54 | |
| JMF | 0:24d3eb812fd4 | 55 | |
| JMF | 0:24d3eb812fd4 | 56 | /** |
| JMF | 0:24d3eb812fd4 | 57 | * @defgroup Aes_Private_TypesDefinitions AES Private Types Definitions |
| JMF | 0:24d3eb812fd4 | 58 | * @{ |
| JMF | 0:24d3eb812fd4 | 59 | */ |
| JMF | 0:24d3eb812fd4 | 60 | |
| JMF | 0:24d3eb812fd4 | 61 | /** |
| JMF | 0:24d3eb812fd4 | 62 | * @} |
| JMF | 0:24d3eb812fd4 | 63 | */ |
| JMF | 0:24d3eb812fd4 | 64 | |
| JMF | 0:24d3eb812fd4 | 65 | |
| JMF | 0:24d3eb812fd4 | 66 | /** |
| JMF | 0:24d3eb812fd4 | 67 | * @defgroup Aes_Private_Defines AES Private Defines |
| JMF | 0:24d3eb812fd4 | 68 | * @{ |
| JMF | 0:24d3eb812fd4 | 69 | */ |
| JMF | 0:24d3eb812fd4 | 70 | |
| JMF | 0:24d3eb812fd4 | 71 | /** |
| JMF | 0:24d3eb812fd4 | 72 | * @} |
| JMF | 0:24d3eb812fd4 | 73 | */ |
| JMF | 0:24d3eb812fd4 | 74 | |
| JMF | 0:24d3eb812fd4 | 75 | |
| JMF | 0:24d3eb812fd4 | 76 | /** |
| JMF | 0:24d3eb812fd4 | 77 | * @defgroup Aes_Private_Macros AES Private Macros |
| JMF | 0:24d3eb812fd4 | 78 | * @{ |
| JMF | 0:24d3eb812fd4 | 79 | */ |
| JMF | 0:24d3eb812fd4 | 80 | |
| JMF | 0:24d3eb812fd4 | 81 | /** |
| JMF | 0:24d3eb812fd4 | 82 | * @} |
| JMF | 0:24d3eb812fd4 | 83 | */ |
| JMF | 0:24d3eb812fd4 | 84 | |
| JMF | 0:24d3eb812fd4 | 85 | |
| JMF | 0:24d3eb812fd4 | 86 | /** |
| JMF | 0:24d3eb812fd4 | 87 | * @defgroup Aes_Private_Variables AES Private Variables |
| JMF | 0:24d3eb812fd4 | 88 | * @{ |
| JMF | 0:24d3eb812fd4 | 89 | */ |
| JMF | 0:24d3eb812fd4 | 90 | |
| JMF | 0:24d3eb812fd4 | 91 | /** |
| JMF | 0:24d3eb812fd4 | 92 | * @} |
| JMF | 0:24d3eb812fd4 | 93 | */ |
| JMF | 0:24d3eb812fd4 | 94 | |
| JMF | 0:24d3eb812fd4 | 95 | |
| JMF | 0:24d3eb812fd4 | 96 | /** |
| JMF | 0:24d3eb812fd4 | 97 | * @defgroup Aes_Private_FunctionPrototypes AES Private Function Prototypes |
| JMF | 0:24d3eb812fd4 | 98 | * @{ |
| JMF | 0:24d3eb812fd4 | 99 | */ |
| JMF | 0:24d3eb812fd4 | 100 | |
| JMF | 0:24d3eb812fd4 | 101 | /** |
| JMF | 0:24d3eb812fd4 | 102 | * @} |
| JMF | 0:24d3eb812fd4 | 103 | */ |
| JMF | 0:24d3eb812fd4 | 104 | |
| JMF | 0:24d3eb812fd4 | 105 | |
| JMF | 0:24d3eb812fd4 | 106 | /** |
| JMF | 0:24d3eb812fd4 | 107 | * @defgroup Aes_Private_Functions AES Private Functions |
| JMF | 0:24d3eb812fd4 | 108 | * @{ |
| JMF | 0:24d3eb812fd4 | 109 | */ |
| JMF | 0:24d3eb812fd4 | 110 | |
| JMF | 0:24d3eb812fd4 | 111 | |
| JMF | 0:24d3eb812fd4 | 112 | /** |
| JMF | 0:24d3eb812fd4 | 113 | * @brief Enables or Disables the AES engine. |
| JMF | 0:24d3eb812fd4 | 114 | * @param xNewState new state for AES engine. |
| JMF | 0:24d3eb812fd4 | 115 | * This parameter can be: S_ENABLE or S_DISABLE. |
| JMF | 0:24d3eb812fd4 | 116 | * @retval None |
| JMF | 0:24d3eb812fd4 | 117 | */ |
| JMF | 0:24d3eb812fd4 | 118 | void SpiritAesMode(SpiritFunctionalState xNewState) |
| JMF | 0:24d3eb812fd4 | 119 | { |
| JMF | 0:24d3eb812fd4 | 120 | uint8_t tempRegValue = 0x00; |
| JMF | 0:24d3eb812fd4 | 121 | |
| JMF | 0:24d3eb812fd4 | 122 | /* Check the parameters */ |
| JMF | 0:24d3eb812fd4 | 123 | s_assert_param(IS_SPIRIT_FUNCTIONAL_STATE(xNewState)); |
| JMF | 0:24d3eb812fd4 | 124 | |
| JMF | 0:24d3eb812fd4 | 125 | /* Modifies the register value */ |
| JMF | 0:24d3eb812fd4 | 126 | g_xStatus = SpiritSpiReadRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 127 | if(xNewState == S_ENABLE) |
| JMF | 0:24d3eb812fd4 | 128 | { |
| JMF | 0:24d3eb812fd4 | 129 | tempRegValue |= AES_MASK; |
| JMF | 0:24d3eb812fd4 | 130 | } |
| JMF | 0:24d3eb812fd4 | 131 | else |
| JMF | 0:24d3eb812fd4 | 132 | { |
| JMF | 0:24d3eb812fd4 | 133 | tempRegValue &= ~AES_MASK; |
| JMF | 0:24d3eb812fd4 | 134 | } |
| JMF | 0:24d3eb812fd4 | 135 | |
| JMF | 0:24d3eb812fd4 | 136 | /* Writes the ANA_FUNC_CONF0 register to enable or disable the AES engine */ |
| JMF | 0:24d3eb812fd4 | 137 | g_xStatus = SpiritSpiWriteRegisters(ANA_FUNC_CONF0_BASE, 1, &tempRegValue); |
| JMF | 0:24d3eb812fd4 | 138 | |
| JMF | 0:24d3eb812fd4 | 139 | } |
| JMF | 0:24d3eb812fd4 | 140 | |
| JMF | 0:24d3eb812fd4 | 141 | |
| JMF | 0:24d3eb812fd4 | 142 | /** |
| JMF | 0:24d3eb812fd4 | 143 | * @brief Writes the data to encrypt or decrypt, or the encryption key for the |
| JMF | 0:24d3eb812fd4 | 144 | * derive decryption key operation into the AES_DATA_IN registers. |
| JMF | 0:24d3eb812fd4 | 145 | * @param pcBufferDataIn pointer to the user data buffer. The first byte of the array |
| JMF | 0:24d3eb812fd4 | 146 | * shall be the MSB byte and it will be put in the AES_DATA_IN[0] register, while |
| JMF | 0:24d3eb812fd4 | 147 | * the last one shall be the LSB and it will be put in the AES_DATA_IN[cDataLength-1] |
| JMF | 0:24d3eb812fd4 | 148 | * register. If data to write are less than 16 bytes the remaining AES_DATA_IN registers |
| JMF | 0:24d3eb812fd4 | 149 | * will be filled with bytes equal to 0. This parameter is an uint8_t*. |
| JMF | 0:24d3eb812fd4 | 150 | * @param cDataLength length of data in bytes. |
| JMF | 0:24d3eb812fd4 | 151 | * This parameter is an uint8_t. |
| JMF | 0:24d3eb812fd4 | 152 | * @retval None |
| JMF | 0:24d3eb812fd4 | 153 | */ |
| JMF | 0:24d3eb812fd4 | 154 | void SpiritAesWriteDataIn(uint8_t* pcBufferDataIn, uint8_t cDataLength) |
| JMF | 0:24d3eb812fd4 | 155 | { |
| JMF | 0:24d3eb812fd4 | 156 | uint8_t i, dataInArray[16]; |
| JMF | 0:24d3eb812fd4 | 157 | |
| JMF | 0:24d3eb812fd4 | 158 | /* Verifies that there are no more than 16 bytes */ |
| JMF | 0:24d3eb812fd4 | 159 | (cDataLength>16) ? (cDataLength=16) : cDataLength; |
| JMF | 0:24d3eb812fd4 | 160 | |
| JMF | 0:24d3eb812fd4 | 161 | /* Fill the dataInArray with the data buffer, using padding */ |
| JMF | 0:24d3eb812fd4 | 162 | for(i=0;i<16;i++) |
| JMF | 0:24d3eb812fd4 | 163 | { |
| JMF | 0:24d3eb812fd4 | 164 | (i<(16 - cDataLength)) ? (dataInArray[i]=0):(dataInArray[i]=pcBufferDataIn[15-i]); |
| JMF | 0:24d3eb812fd4 | 165 | |
| JMF | 0:24d3eb812fd4 | 166 | } |
| JMF | 0:24d3eb812fd4 | 167 | |
| JMF | 0:24d3eb812fd4 | 168 | /* Writes the AES_DATA_IN registers */ |
| JMF | 0:24d3eb812fd4 | 169 | g_xStatus = SpiritSpiWriteRegisters(AES_DATA_IN_15_BASE, 16, dataInArray); |
| JMF | 0:24d3eb812fd4 | 170 | |
| JMF | 0:24d3eb812fd4 | 171 | } |
| JMF | 0:24d3eb812fd4 | 172 | |
| JMF | 0:24d3eb812fd4 | 173 | |
| JMF | 0:24d3eb812fd4 | 174 | /** |
| JMF | 0:24d3eb812fd4 | 175 | * @brief Returns the encrypted or decrypted data or the decription key from the AES_DATA_OUT register. |
| JMF | 0:24d3eb812fd4 | 176 | * @param pcBufferDataOut pointer to the user data buffer. The AES_DATA_OUT[0] |
| JMF | 0:24d3eb812fd4 | 177 | * register value will be put as first element of the buffer (MSB), while the |
| JMF | 0:24d3eb812fd4 | 178 | * AES_DAT_OUT[cDataLength-1] register value will be put as last element of the buffer (LSB). |
| JMF | 0:24d3eb812fd4 | 179 | * This parameter is a uint8_t*. |
| JMF | 0:24d3eb812fd4 | 180 | * @param cDataLength length of data to read in bytes. |
| JMF | 0:24d3eb812fd4 | 181 | * This parameter is a uint8_t. |
| JMF | 0:24d3eb812fd4 | 182 | * @retval None |
| JMF | 0:24d3eb812fd4 | 183 | */ |
| JMF | 0:24d3eb812fd4 | 184 | void SpiritAesReadDataOut(uint8_t* pcBufferDataOut, uint8_t cDataLength) |
| JMF | 0:24d3eb812fd4 | 185 | { |
| JMF | 0:24d3eb812fd4 | 186 | uint8_t address, dataOutArray[16]; |
| JMF | 0:24d3eb812fd4 | 187 | |
| JMF | 0:24d3eb812fd4 | 188 | /* Verifies that there are no more than 16 bytes */ |
| JMF | 0:24d3eb812fd4 | 189 | (cDataLength>16) ? (cDataLength=16) : cDataLength; |
| JMF | 0:24d3eb812fd4 | 190 | |
| JMF | 0:24d3eb812fd4 | 191 | /* Evaluates the address of AES_DATA_OUT from which start to read */ |
| JMF | 0:24d3eb812fd4 | 192 | address = AES_DATA_OUT_15_BASE+16-cDataLength; |
| JMF | 0:24d3eb812fd4 | 193 | |
| JMF | 0:24d3eb812fd4 | 194 | /* Reads the exact number of AES_DATA_OUT registers */ |
| JMF | 0:24d3eb812fd4 | 195 | g_xStatus = (SpiritSpiReadRegisters(address, cDataLength, dataOutArray)); |
| JMF | 0:24d3eb812fd4 | 196 | |
| JMF | 0:24d3eb812fd4 | 197 | /* Copy in the user buffer the read values changing the order */ |
| JMF | 0:24d3eb812fd4 | 198 | for(int i = (cDataLength-1); i>=0; i--) |
| JMF | 0:24d3eb812fd4 | 199 | { |
| JMF | 0:24d3eb812fd4 | 200 | *pcBufferDataOut = dataOutArray[i]; |
| JMF | 0:24d3eb812fd4 | 201 | pcBufferDataOut++; |
| JMF | 0:24d3eb812fd4 | 202 | } |
| JMF | 0:24d3eb812fd4 | 203 | |
| JMF | 0:24d3eb812fd4 | 204 | } |
| JMF | 0:24d3eb812fd4 | 205 | |
| JMF | 0:24d3eb812fd4 | 206 | |
| JMF | 0:24d3eb812fd4 | 207 | /** |
| JMF | 0:24d3eb812fd4 | 208 | * @brief Writes the encryption key into the AES_KEY_IN register. |
| JMF | 0:24d3eb812fd4 | 209 | * @param pcKey pointer to the buffer of 4 words containing the AES key. |
| JMF | 0:24d3eb812fd4 | 210 | * The first byte of the buffer shall be the most significant byte AES_KEY_0 of the AES key. |
| JMF | 0:24d3eb812fd4 | 211 | * The last byte of the buffer shall be the less significant byte AES_KEY_15 of the AES key. |
| JMF | 0:24d3eb812fd4 | 212 | * This parameter is an uint8_t*. |
| JMF | 0:24d3eb812fd4 | 213 | * @retval None |
| JMF | 0:24d3eb812fd4 | 214 | */ |
| JMF | 0:24d3eb812fd4 | 215 | void SpiritAesWriteKey(uint8_t* pcKey) |
| JMF | 0:24d3eb812fd4 | 216 | { |
| JMF | 0:24d3eb812fd4 | 217 | uint8_t pcTempKey[16]; |
| JMF | 0:24d3eb812fd4 | 218 | for (uint8_t i = 0; i < 16; i++) |
| JMF | 0:24d3eb812fd4 | 219 | { |
| JMF | 0:24d3eb812fd4 | 220 | pcTempKey[15-i] = pcKey[i]; |
| JMF | 0:24d3eb812fd4 | 221 | } |
| JMF | 0:24d3eb812fd4 | 222 | |
| JMF | 0:24d3eb812fd4 | 223 | /* Writes the AES_DATA_IN registers */ |
| JMF | 0:24d3eb812fd4 | 224 | g_xStatus = SpiritSpiWriteRegisters(AES_KEY_IN_15_BASE, 16, pcTempKey); |
| JMF | 0:24d3eb812fd4 | 225 | |
| JMF | 0:24d3eb812fd4 | 226 | } |
| JMF | 0:24d3eb812fd4 | 227 | |
| JMF | 0:24d3eb812fd4 | 228 | /** |
| JMF | 0:24d3eb812fd4 | 229 | * @brief Returns the encryption/decryption key from the AES_KEY_IN register. |
| JMF | 0:24d3eb812fd4 | 230 | * @param pcKey pointer to the buffer of 4 words (16 bytes) containing the AES key. |
| JMF | 0:24d3eb812fd4 | 231 | * The first byte of the buffer shall be the most significant byte AES_KEY_0 of the AES key. |
| JMF | 0:24d3eb812fd4 | 232 | * The last byte of the buffer shall be the less significant byte AES_KEY_15 of the AES key. |
| JMF | 0:24d3eb812fd4 | 233 | * This parameter is an uint8_t*. |
| JMF | 0:24d3eb812fd4 | 234 | * @retval None |
| JMF | 0:24d3eb812fd4 | 235 | */ |
| JMF | 0:24d3eb812fd4 | 236 | void SpiritAesReadKey(uint8_t* pcKey) |
| JMF | 0:24d3eb812fd4 | 237 | { |
| JMF | 0:24d3eb812fd4 | 238 | uint8_t pcTempKey[16]; |
| JMF | 0:24d3eb812fd4 | 239 | |
| JMF | 0:24d3eb812fd4 | 240 | /* Reads the AES_DATA_IN registers */ |
| JMF | 0:24d3eb812fd4 | 241 | g_xStatus = SpiritSpiReadRegisters(AES_KEY_IN_15_BASE, 16, pcTempKey); |
| JMF | 0:24d3eb812fd4 | 242 | |
| JMF | 0:24d3eb812fd4 | 243 | |
| JMF | 0:24d3eb812fd4 | 244 | for (uint8_t i = 0; i < 16; i++) |
| JMF | 0:24d3eb812fd4 | 245 | pcKey[i] = pcTempKey[15-i]; |
| JMF | 0:24d3eb812fd4 | 246 | |
| JMF | 0:24d3eb812fd4 | 247 | } |
| JMF | 0:24d3eb812fd4 | 248 | |
| JMF | 0:24d3eb812fd4 | 249 | |
| JMF | 0:24d3eb812fd4 | 250 | |
| JMF | 0:24d3eb812fd4 | 251 | /** |
| JMF | 0:24d3eb812fd4 | 252 | * @brief Derives the decryption key from a given encryption key. |
| JMF | 0:24d3eb812fd4 | 253 | * @param None. |
| JMF | 0:24d3eb812fd4 | 254 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 255 | */ |
| JMF | 0:24d3eb812fd4 | 256 | void SpiritAesDeriveDecKeyFromEnc(void) |
| JMF | 0:24d3eb812fd4 | 257 | { |
| JMF | 0:24d3eb812fd4 | 258 | /* Sends the COMMAND_AES_KEY command */ |
| JMF | 0:24d3eb812fd4 | 259 | g_xStatus = SpiritSpiCommandStrobes(COMMAND_AES_KEY); |
| JMF | 0:24d3eb812fd4 | 260 | |
| JMF | 0:24d3eb812fd4 | 261 | } |
| JMF | 0:24d3eb812fd4 | 262 | |
| JMF | 0:24d3eb812fd4 | 263 | |
| JMF | 0:24d3eb812fd4 | 264 | /** |
| JMF | 0:24d3eb812fd4 | 265 | * @brief Executes the encryption operation. |
| JMF | 0:24d3eb812fd4 | 266 | * @param None. |
| JMF | 0:24d3eb812fd4 | 267 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 268 | */ |
| JMF | 0:24d3eb812fd4 | 269 | void SpiritAesExecuteEncryption(void) |
| JMF | 0:24d3eb812fd4 | 270 | { |
| JMF | 0:24d3eb812fd4 | 271 | /* Sends the COMMAND_AES_ENC command */ |
| JMF | 0:24d3eb812fd4 | 272 | g_xStatus = SpiritSpiCommandStrobes(COMMAND_AES_ENC); |
| JMF | 0:24d3eb812fd4 | 273 | |
| JMF | 0:24d3eb812fd4 | 274 | } |
| JMF | 0:24d3eb812fd4 | 275 | |
| JMF | 0:24d3eb812fd4 | 276 | |
| JMF | 0:24d3eb812fd4 | 277 | /** |
| JMF | 0:24d3eb812fd4 | 278 | * @brief Executes the decryption operation. |
| JMF | 0:24d3eb812fd4 | 279 | * @param None. |
| JMF | 0:24d3eb812fd4 | 280 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 281 | */ |
| JMF | 0:24d3eb812fd4 | 282 | void SpiritAesExecuteDecryption(void) |
| JMF | 0:24d3eb812fd4 | 283 | { |
| JMF | 0:24d3eb812fd4 | 284 | /* Sends the COMMAND_AES_DEC command */ |
| JMF | 0:24d3eb812fd4 | 285 | g_xStatus = SpiritSpiCommandStrobes(COMMAND_AES_DEC); |
| JMF | 0:24d3eb812fd4 | 286 | |
| JMF | 0:24d3eb812fd4 | 287 | } |
| JMF | 0:24d3eb812fd4 | 288 | |
| JMF | 0:24d3eb812fd4 | 289 | |
| JMF | 0:24d3eb812fd4 | 290 | /** |
| JMF | 0:24d3eb812fd4 | 291 | * @brief Executes the key derivation and the decryption operation. |
| JMF | 0:24d3eb812fd4 | 292 | * @param None. |
| JMF | 0:24d3eb812fd4 | 293 | * @retval None. |
| JMF | 0:24d3eb812fd4 | 294 | */ |
| JMF | 0:24d3eb812fd4 | 295 | void SpiritAesDeriveDecKeyExecuteDec(void) |
| JMF | 0:24d3eb812fd4 | 296 | { |
| JMF | 0:24d3eb812fd4 | 297 | /* Sends the COMMAND_AES_KEY_DEC command */ |
| JMF | 0:24d3eb812fd4 | 298 | g_xStatus = SpiritSpiCommandStrobes(COMMAND_AES_KEY_DEC); |
| JMF | 0:24d3eb812fd4 | 299 | |
| JMF | 0:24d3eb812fd4 | 300 | } |
| JMF | 0:24d3eb812fd4 | 301 | |
| JMF | 0:24d3eb812fd4 | 302 | |
| JMF | 0:24d3eb812fd4 | 303 | /** |
| JMF | 0:24d3eb812fd4 | 304 | * @} |
| JMF | 0:24d3eb812fd4 | 305 | */ |
| JMF | 0:24d3eb812fd4 | 306 | |
| JMF | 0:24d3eb812fd4 | 307 | |
| JMF | 0:24d3eb812fd4 | 308 | /** |
| JMF | 0:24d3eb812fd4 | 309 | * @} |
| JMF | 0:24d3eb812fd4 | 310 | */ |
| JMF | 0:24d3eb812fd4 | 311 | |
| JMF | 0:24d3eb812fd4 | 312 | |
| JMF | 0:24d3eb812fd4 | 313 | /** |
| JMF | 0:24d3eb812fd4 | 314 | * @} |
| JMF | 0:24d3eb812fd4 | 315 | */ |
| JMF | 0:24d3eb812fd4 | 316 | |
| JMF | 0:24d3eb812fd4 | 317 | |
| JMF | 0:24d3eb812fd4 | 318 | |
| JMF | 0:24d3eb812fd4 | 319 | /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/ |