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