The official mbed C/C SDK provides the software platform and libraries to build your applications.
Fork of mbed by
TARGET_NUCLEO_F401RE/stm32f4xx_hal_cryp.h@90:cb3d968589d8, 2014-10-28 (annotated)
- Committer:
- Kojto
- Date:
- Tue Oct 28 16:40:41 2014 +0000
- Revision:
- 90:cb3d968589d8
- Parent:
- 85:024bf7f99721
Release 90 of the mbed library
Changes:
- Freescale KSDK update (v1.0)
- K22 - new target addition
- KL43Z - new target addition
- Nucleo F091RC - new target addition
- Nucleo L152RE - STM32Cube driver
- Nordic - Softdevice v7.1.0
- Nvic files - BSD License
- LPC824 - various HAL fixes
- Nucleo F411RE - CMSIS - IAR files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 77:869cf507173a | 1 | /** |
emilmont | 77:869cf507173a | 2 | ****************************************************************************** |
emilmont | 77:869cf507173a | 3 | * @file stm32f4xx_hal_cryp.h |
emilmont | 77:869cf507173a | 4 | * @author MCD Application Team |
Kojto | 90:cb3d968589d8 | 5 | * @version V1.1.0 |
Kojto | 90:cb3d968589d8 | 6 | * @date 19-June-2014 |
emilmont | 77:869cf507173a | 7 | * @brief Header file of CRYP HAL module. |
emilmont | 77:869cf507173a | 8 | ****************************************************************************** |
emilmont | 77:869cf507173a | 9 | * @attention |
emilmont | 77:869cf507173a | 10 | * |
emilmont | 77:869cf507173a | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
emilmont | 77:869cf507173a | 12 | * |
emilmont | 77:869cf507173a | 13 | * Redistribution and use in source and binary forms, with or without modification, |
emilmont | 77:869cf507173a | 14 | * are permitted provided that the following conditions are met: |
emilmont | 77:869cf507173a | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
emilmont | 77:869cf507173a | 16 | * this list of conditions and the following disclaimer. |
emilmont | 77:869cf507173a | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
emilmont | 77:869cf507173a | 18 | * this list of conditions and the following disclaimer in the documentation |
emilmont | 77:869cf507173a | 19 | * and/or other materials provided with the distribution. |
emilmont | 77:869cf507173a | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
emilmont | 77:869cf507173a | 21 | * may be used to endorse or promote products derived from this software |
emilmont | 77:869cf507173a | 22 | * without specific prior written permission. |
emilmont | 77:869cf507173a | 23 | * |
emilmont | 77:869cf507173a | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
emilmont | 77:869cf507173a | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
emilmont | 77:869cf507173a | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
emilmont | 77:869cf507173a | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
emilmont | 77:869cf507173a | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
emilmont | 77:869cf507173a | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
emilmont | 77:869cf507173a | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emilmont | 77:869cf507173a | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
emilmont | 77:869cf507173a | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
emilmont | 77:869cf507173a | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
emilmont | 77:869cf507173a | 34 | * |
emilmont | 77:869cf507173a | 35 | ****************************************************************************** |
emilmont | 77:869cf507173a | 36 | */ |
emilmont | 77:869cf507173a | 37 | |
emilmont | 77:869cf507173a | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
emilmont | 77:869cf507173a | 39 | #ifndef __STM32F4xx_HAL_CRYP_H |
emilmont | 77:869cf507173a | 40 | #define __STM32F4xx_HAL_CRYP_H |
emilmont | 77:869cf507173a | 41 | |
emilmont | 77:869cf507173a | 42 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 43 | extern "C" { |
emilmont | 77:869cf507173a | 44 | #endif |
emilmont | 77:869cf507173a | 45 | |
emilmont | 77:869cf507173a | 46 | #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) |
emilmont | 77:869cf507173a | 47 | /* Includes ------------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 48 | #include "stm32f4xx_hal_def.h" |
emilmont | 77:869cf507173a | 49 | |
emilmont | 77:869cf507173a | 50 | /** @addtogroup STM32F4xx_HAL_Driver |
emilmont | 77:869cf507173a | 51 | * @{ |
emilmont | 77:869cf507173a | 52 | */ |
emilmont | 77:869cf507173a | 53 | |
emilmont | 77:869cf507173a | 54 | /** @addtogroup CRYP |
emilmont | 77:869cf507173a | 55 | * @{ |
bogdanm | 85:024bf7f99721 | 56 | */ |
emilmont | 77:869cf507173a | 57 | |
bogdanm | 85:024bf7f99721 | 58 | /* Exported types ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 59 | |
emilmont | 77:869cf507173a | 60 | /** |
bogdanm | 85:024bf7f99721 | 61 | * @brief CRYP Configuration Structure definition |
emilmont | 77:869cf507173a | 62 | */ |
emilmont | 77:869cf507173a | 63 | typedef struct |
bogdanm | 85:024bf7f99721 | 64 | { |
emilmont | 77:869cf507173a | 65 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
emilmont | 77:869cf507173a | 66 | This parameter can be a value of @ref CRYP_Data_Type */ |
bogdanm | 85:024bf7f99721 | 67 | |
emilmont | 77:869cf507173a | 68 | uint32_t KeySize; /*!< Used only in AES mode only : 128, 192 or 256 bit key length. |
emilmont | 77:869cf507173a | 69 | This parameter can be a value of @ref CRYP_Key_Size */ |
bogdanm | 85:024bf7f99721 | 70 | |
emilmont | 77:869cf507173a | 71 | uint8_t* pKey; /*!< The key used for encryption/decryption */ |
bogdanm | 85:024bf7f99721 | 72 | |
emilmont | 77:869cf507173a | 73 | uint8_t* pInitVect; /*!< The initialization vector used also as initialization |
emilmont | 77:869cf507173a | 74 | counter in CTR mode */ |
bogdanm | 85:024bf7f99721 | 75 | |
emilmont | 77:869cf507173a | 76 | uint8_t IVSize; /*!< The size of initialization vector. |
emilmont | 77:869cf507173a | 77 | This parameter (called nonce size in CCM) is used only |
emilmont | 77:869cf507173a | 78 | in AES-128/192/256 encryption/decryption CCM mode */ |
bogdanm | 85:024bf7f99721 | 79 | |
emilmont | 77:869cf507173a | 80 | uint8_t TagSize; /*!< The size of returned authentication TAG. |
emilmont | 77:869cf507173a | 81 | This parameter is used only in AES-128/192/256 |
emilmont | 77:869cf507173a | 82 | encryption/decryption CCM mode */ |
bogdanm | 85:024bf7f99721 | 83 | |
emilmont | 77:869cf507173a | 84 | uint8_t* Header; /*!< The header used in GCM and CCM modes */ |
bogdanm | 85:024bf7f99721 | 85 | |
emilmont | 77:869cf507173a | 86 | uint16_t HeaderSize; /*!< The size of header buffer in bytes */ |
bogdanm | 85:024bf7f99721 | 87 | |
emilmont | 77:869cf507173a | 88 | uint8_t* pScratch; /*!< Scratch buffer used to append the header. It's size must be equal to header size + 21 bytes. |
emilmont | 77:869cf507173a | 89 | This parameter is used only in AES-128/192/256 encryption/decryption CCM mode */ |
emilmont | 77:869cf507173a | 90 | }CRYP_InitTypeDef; |
emilmont | 77:869cf507173a | 91 | |
emilmont | 77:869cf507173a | 92 | /** |
bogdanm | 85:024bf7f99721 | 93 | * @brief HAL CRYP State structures definition |
bogdanm | 85:024bf7f99721 | 94 | */ |
emilmont | 77:869cf507173a | 95 | typedef enum |
emilmont | 77:869cf507173a | 96 | { |
emilmont | 77:869cf507173a | 97 | HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ |
emilmont | 77:869cf507173a | 98 | HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ |
emilmont | 77:869cf507173a | 99 | HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ |
emilmont | 77:869cf507173a | 100 | HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ |
bogdanm | 85:024bf7f99721 | 101 | HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ |
emilmont | 77:869cf507173a | 102 | }HAL_CRYP_STATETypeDef; |
emilmont | 77:869cf507173a | 103 | |
emilmont | 77:869cf507173a | 104 | /** |
bogdanm | 85:024bf7f99721 | 105 | * @brief HAL CRYP phase structures definition |
bogdanm | 85:024bf7f99721 | 106 | */ |
emilmont | 77:869cf507173a | 107 | typedef enum |
emilmont | 77:869cf507173a | 108 | { |
emilmont | 77:869cf507173a | 109 | HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ |
emilmont | 77:869cf507173a | 110 | HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */ |
emilmont | 77:869cf507173a | 111 | HAL_CRYP_PHASE_FINAL = 0x03 /*!< CRYP peripheral is in final phase |
emilmont | 77:869cf507173a | 112 | This is relevant only with CCM and GCM modes */ |
emilmont | 77:869cf507173a | 113 | }HAL_PhaseTypeDef; |
emilmont | 77:869cf507173a | 114 | |
emilmont | 77:869cf507173a | 115 | /** |
bogdanm | 85:024bf7f99721 | 116 | * @brief CRYP handle Structure definition |
emilmont | 77:869cf507173a | 117 | */ |
emilmont | 77:869cf507173a | 118 | typedef struct |
bogdanm | 85:024bf7f99721 | 119 | { |
emilmont | 77:869cf507173a | 120 | CRYP_InitTypeDef Init; /*!< CRYP required parameters */ |
bogdanm | 85:024bf7f99721 | 121 | |
emilmont | 77:869cf507173a | 122 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
bogdanm | 85:024bf7f99721 | 123 | |
emilmont | 77:869cf507173a | 124 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
bogdanm | 85:024bf7f99721 | 125 | |
emilmont | 77:869cf507173a | 126 | __IO uint16_t CrypInCount; /*!< Counter of inputed data */ |
bogdanm | 85:024bf7f99721 | 127 | |
emilmont | 77:869cf507173a | 128 | __IO uint16_t CrypOutCount; /*!< Counter of outputed data */ |
bogdanm | 85:024bf7f99721 | 129 | |
emilmont | 77:869cf507173a | 130 | HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ |
bogdanm | 85:024bf7f99721 | 131 | |
emilmont | 77:869cf507173a | 132 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ |
bogdanm | 85:024bf7f99721 | 133 | |
emilmont | 77:869cf507173a | 134 | DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ |
bogdanm | 85:024bf7f99721 | 135 | |
emilmont | 77:869cf507173a | 136 | DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ |
bogdanm | 85:024bf7f99721 | 137 | |
emilmont | 77:869cf507173a | 138 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
bogdanm | 85:024bf7f99721 | 139 | |
emilmont | 77:869cf507173a | 140 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
emilmont | 77:869cf507173a | 141 | }CRYP_HandleTypeDef; |
emilmont | 77:869cf507173a | 142 | |
emilmont | 77:869cf507173a | 143 | /* Exported constants --------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 144 | |
emilmont | 77:869cf507173a | 145 | /** @defgroup CRYP_Exported_Constants |
emilmont | 77:869cf507173a | 146 | * @{ |
emilmont | 77:869cf507173a | 147 | */ |
emilmont | 77:869cf507173a | 148 | |
emilmont | 77:869cf507173a | 149 | /** @defgroup CRYP_Key_Size |
emilmont | 77:869cf507173a | 150 | * @{ |
bogdanm | 85:024bf7f99721 | 151 | */ |
emilmont | 77:869cf507173a | 152 | #define CRYP_KEYSIZE_128B ((uint32_t)0x00000000) |
emilmont | 77:869cf507173a | 153 | #define CRYP_KEYSIZE_192B CRYP_CR_KEYSIZE_0 |
emilmont | 77:869cf507173a | 154 | #define CRYP_KEYSIZE_256B CRYP_CR_KEYSIZE_1 |
emilmont | 77:869cf507173a | 155 | |
emilmont | 77:869cf507173a | 156 | #define IS_CRYP_KEYSIZE(KEYSIZE) (((KEYSIZE) == CRYP_KEYSIZE_128B) || \ |
emilmont | 77:869cf507173a | 157 | ((KEYSIZE) == CRYP_KEYSIZE_192B) || \ |
emilmont | 77:869cf507173a | 158 | ((KEYSIZE) == CRYP_KEYSIZE_256B)) |
emilmont | 77:869cf507173a | 159 | /** |
emilmont | 77:869cf507173a | 160 | * @} |
emilmont | 77:869cf507173a | 161 | */ |
emilmont | 77:869cf507173a | 162 | |
emilmont | 77:869cf507173a | 163 | /** @defgroup CRYP_Data_Type |
emilmont | 77:869cf507173a | 164 | * @{ |
emilmont | 77:869cf507173a | 165 | */ |
emilmont | 77:869cf507173a | 166 | #define CRYP_DATATYPE_32B ((uint32_t)0x00000000) |
emilmont | 77:869cf507173a | 167 | #define CRYP_DATATYPE_16B CRYP_CR_DATATYPE_0 |
emilmont | 77:869cf507173a | 168 | #define CRYP_DATATYPE_8B CRYP_CR_DATATYPE_1 |
emilmont | 77:869cf507173a | 169 | #define CRYP_DATATYPE_1B CRYP_CR_DATATYPE |
emilmont | 77:869cf507173a | 170 | |
emilmont | 77:869cf507173a | 171 | #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DATATYPE_32B) || \ |
emilmont | 77:869cf507173a | 172 | ((DATATYPE) == CRYP_DATATYPE_16B) || \ |
emilmont | 77:869cf507173a | 173 | ((DATATYPE) == CRYP_DATATYPE_8B) || \ |
emilmont | 77:869cf507173a | 174 | ((DATATYPE) == CRYP_DATATYPE_1B)) |
emilmont | 77:869cf507173a | 175 | /** |
emilmont | 77:869cf507173a | 176 | * @} |
emilmont | 77:869cf507173a | 177 | */ |
emilmont | 77:869cf507173a | 178 | |
emilmont | 77:869cf507173a | 179 | /** @defgroup CRYP_AlgoModeDirection |
emilmont | 77:869cf507173a | 180 | * @{ |
emilmont | 77:869cf507173a | 181 | */ |
emilmont | 77:869cf507173a | 182 | #define CRYP_CR_ALGOMODE_DIRECTION ((uint32_t)0x0008003C) |
emilmont | 77:869cf507173a | 183 | #define CRYP_CR_ALGOMODE_TDES_ECB_ENCRYPT ((uint32_t)0x00000000) |
emilmont | 77:869cf507173a | 184 | #define CRYP_CR_ALGOMODE_TDES_ECB_DECRYPT ((uint32_t)0x00000004) |
emilmont | 77:869cf507173a | 185 | #define CRYP_CR_ALGOMODE_TDES_CBC_ENCRYPT ((uint32_t)0x00000008) |
emilmont | 77:869cf507173a | 186 | #define CRYP_CR_ALGOMODE_TDES_CBC_DECRYPT ((uint32_t)0x0000000C) |
emilmont | 77:869cf507173a | 187 | #define CRYP_CR_ALGOMODE_DES_ECB_ENCRYPT ((uint32_t)0x00000010) |
emilmont | 77:869cf507173a | 188 | #define CRYP_CR_ALGOMODE_DES_ECB_DECRYPT ((uint32_t)0x00000014) |
emilmont | 77:869cf507173a | 189 | #define CRYP_CR_ALGOMODE_DES_CBC_ENCRYPT ((uint32_t)0x00000018) |
emilmont | 77:869cf507173a | 190 | #define CRYP_CR_ALGOMODE_DES_CBC_DECRYPT ((uint32_t)0x0000001C) |
emilmont | 77:869cf507173a | 191 | #define CRYP_CR_ALGOMODE_AES_ECB_ENCRYPT ((uint32_t)0x00000020) |
emilmont | 77:869cf507173a | 192 | #define CRYP_CR_ALGOMODE_AES_ECB_DECRYPT ((uint32_t)0x00000024) |
emilmont | 77:869cf507173a | 193 | #define CRYP_CR_ALGOMODE_AES_CBC_ENCRYPT ((uint32_t)0x00000028) |
emilmont | 77:869cf507173a | 194 | #define CRYP_CR_ALGOMODE_AES_CBC_DECRYPT ((uint32_t)0x0000002C) |
emilmont | 77:869cf507173a | 195 | #define CRYP_CR_ALGOMODE_AES_CTR_ENCRYPT ((uint32_t)0x00000030) |
emilmont | 77:869cf507173a | 196 | #define CRYP_CR_ALGOMODE_AES_CTR_DECRYPT ((uint32_t)0x00000034) |
emilmont | 77:869cf507173a | 197 | /** |
emilmont | 77:869cf507173a | 198 | * @} |
emilmont | 77:869cf507173a | 199 | */ |
emilmont | 77:869cf507173a | 200 | |
emilmont | 77:869cf507173a | 201 | /** @defgroup CRYP_Interrupt |
emilmont | 77:869cf507173a | 202 | * @{ |
emilmont | 77:869cf507173a | 203 | */ |
emilmont | 77:869cf507173a | 204 | #define CRYP_IT_INI ((uint32_t)CRYP_IMSCR_INIM) /*!< Input FIFO Interrupt */ |
emilmont | 77:869cf507173a | 205 | #define CRYP_IT_OUTI ((uint32_t)CRYP_IMSCR_OUTIM) /*!< Output FIFO Interrupt */ |
emilmont | 77:869cf507173a | 206 | /** |
emilmont | 77:869cf507173a | 207 | * @} |
emilmont | 77:869cf507173a | 208 | */ |
emilmont | 77:869cf507173a | 209 | |
emilmont | 77:869cf507173a | 210 | /** @defgroup CRYP_Flags |
emilmont | 77:869cf507173a | 211 | * @{ |
emilmont | 77:869cf507173a | 212 | */ |
emilmont | 77:869cf507173a | 213 | |
emilmont | 77:869cf507173a | 214 | #define CRYP_FLAG_BUSY ((uint32_t)0x00000010) /*!< The CRYP core is currently |
emilmont | 77:869cf507173a | 215 | processing a block of data |
emilmont | 77:869cf507173a | 216 | or a key preparation (for |
emilmont | 77:869cf507173a | 217 | AES decryption). */ |
emilmont | 77:869cf507173a | 218 | #define CRYP_FLAG_IFEM ((uint32_t)0x00000001) /*!< Input FIFO is empty */ |
emilmont | 77:869cf507173a | 219 | #define CRYP_FLAG_IFNF ((uint32_t)0x00000002) /*!< Input FIFO is not Full */ |
emilmont | 77:869cf507173a | 220 | #define CRYP_FLAG_OFNE ((uint32_t)0x00000004) /*!< Output FIFO is not empty */ |
emilmont | 77:869cf507173a | 221 | #define CRYP_FLAG_OFFU ((uint32_t)0x00000008) /*!< Output FIFO is Full */ |
emilmont | 77:869cf507173a | 222 | #define CRYP_FLAG_OUTRIS ((uint32_t)0x01000002) /*!< Output FIFO service raw |
emilmont | 77:869cf507173a | 223 | interrupt status */ |
emilmont | 77:869cf507173a | 224 | #define CRYP_FLAG_INRIS ((uint32_t)0x01000001) /*!< Input FIFO service raw |
emilmont | 77:869cf507173a | 225 | interrupt status */ |
emilmont | 77:869cf507173a | 226 | /** |
emilmont | 77:869cf507173a | 227 | * @} |
bogdanm | 85:024bf7f99721 | 228 | */ |
emilmont | 77:869cf507173a | 229 | |
emilmont | 77:869cf507173a | 230 | /** |
emilmont | 77:869cf507173a | 231 | * @} |
emilmont | 77:869cf507173a | 232 | */ |
emilmont | 77:869cf507173a | 233 | |
emilmont | 77:869cf507173a | 234 | /* Exported macro ------------------------------------------------------------*/ |
emilmont | 77:869cf507173a | 235 | |
bogdanm | 85:024bf7f99721 | 236 | /** @brief Reset CRYP handle state |
bogdanm | 85:024bf7f99721 | 237 | * @param __HANDLE__: specifies the CRYP handle. |
bogdanm | 85:024bf7f99721 | 238 | * @retval None |
bogdanm | 85:024bf7f99721 | 239 | */ |
bogdanm | 85:024bf7f99721 | 240 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
bogdanm | 85:024bf7f99721 | 241 | |
emilmont | 77:869cf507173a | 242 | /** |
emilmont | 77:869cf507173a | 243 | * @brief Enable/Disable the CRYP peripheral. |
emilmont | 77:869cf507173a | 244 | * @param None |
emilmont | 77:869cf507173a | 245 | * @retval None |
emilmont | 77:869cf507173a | 246 | */ |
emilmont | 77:869cf507173a | 247 | #define __HAL_CRYP_ENABLE() (CRYP->CR |= CRYP_CR_CRYPEN) |
emilmont | 77:869cf507173a | 248 | #define __HAL_CRYP_DISABLE() (CRYP->CR &= ~CRYP_CR_CRYPEN) |
emilmont | 77:869cf507173a | 249 | |
emilmont | 77:869cf507173a | 250 | /** |
emilmont | 77:869cf507173a | 251 | * @brief Flush the data FIFO. |
emilmont | 77:869cf507173a | 252 | * @param None |
emilmont | 77:869cf507173a | 253 | * @retval None |
emilmont | 77:869cf507173a | 254 | */ |
emilmont | 77:869cf507173a | 255 | #define __HAL_CRYP_FIFO_FLUSH() (CRYP->CR |= CRYP_CR_FFLUSH) |
emilmont | 77:869cf507173a | 256 | |
emilmont | 77:869cf507173a | 257 | /** |
Kojto | 90:cb3d968589d8 | 258 | * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC. |
emilmont | 77:869cf507173a | 259 | * @param MODE: The algorithm mode. |
emilmont | 77:869cf507173a | 260 | * @retval None |
emilmont | 77:869cf507173a | 261 | */ |
emilmont | 77:869cf507173a | 262 | #define __HAL_CRYP_SET_MODE(MODE) CRYP->CR |= (uint32_t)(MODE) |
emilmont | 77:869cf507173a | 263 | |
emilmont | 77:869cf507173a | 264 | /** @brief Check whether the specified CRYP flag is set or not. |
emilmont | 77:869cf507173a | 265 | * @param __FLAG__: specifies the flag to check. |
emilmont | 77:869cf507173a | 266 | * This parameter can be one of the following values: |
emilmont | 77:869cf507173a | 267 | * @arg CRYP_FLAG_BUSY: The CRYP core is currently processing a block of data |
emilmont | 77:869cf507173a | 268 | * or a key preparation (for AES decryption). |
emilmont | 77:869cf507173a | 269 | * @arg CRYP_FLAG_IFEM: Input FIFO is empty |
emilmont | 77:869cf507173a | 270 | * @arg CRYP_FLAG_IFNF: Input FIFO is not full |
emilmont | 77:869cf507173a | 271 | * @arg CRYP_FLAG_INRIS: Input FIFO service raw interrupt is pending |
emilmont | 77:869cf507173a | 272 | * @arg CRYP_FLAG_OFNE: Output FIFO is not empty |
emilmont | 77:869cf507173a | 273 | * @arg CRYP_FLAG_OFFU: Output FIFO is full |
emilmont | 77:869cf507173a | 274 | * @arg CRYP_FLAG_OUTRIS: Input FIFO service raw interrupt is pending |
emilmont | 77:869cf507173a | 275 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
emilmont | 77:869cf507173a | 276 | */ |
emilmont | 77:869cf507173a | 277 | #define CRYP_FLAG_MASK ((uint32_t)0x0000001F) |
emilmont | 77:869cf507173a | 278 | #define __HAL_CRYP_GET_FLAG(__FLAG__) ((((uint8_t)((__FLAG__) >> 24)) == 0x01)?(((CRYP->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK)): \ |
emilmont | 77:869cf507173a | 279 | (((CRYP->RISR) & ((__FLAG__) & CRYP_FLAG_MASK)) == ((__FLAG__) & CRYP_FLAG_MASK))) |
emilmont | 77:869cf507173a | 280 | |
emilmont | 77:869cf507173a | 281 | /** @brief Check whether the specified CRYP interrupt is set or not. |
emilmont | 77:869cf507173a | 282 | * @param __INTERRUPT__: specifies the interrupt to check. |
emilmont | 77:869cf507173a | 283 | * This parameter can be one of the following values: |
emilmont | 77:869cf507173a | 284 | * @arg CRYP_IT_INRIS: Input FIFO service raw interrupt is pending |
emilmont | 77:869cf507173a | 285 | * @arg CRYP_IT_OUTRIS: Output FIFO service raw interrupt is pending |
emilmont | 77:869cf507173a | 286 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
emilmont | 77:869cf507173a | 287 | */ |
emilmont | 77:869cf507173a | 288 | #define __HAL_CRYP_GET_IT(__INTERRUPT__) ((CRYP->MISR & (__INTERRUPT__)) == (__INTERRUPT__)) |
emilmont | 77:869cf507173a | 289 | |
emilmont | 77:869cf507173a | 290 | /** |
emilmont | 77:869cf507173a | 291 | * @brief Enable the CRYP interrupt. |
emilmont | 77:869cf507173a | 292 | * @param __INTERRUPT__: CRYP Interrupt. |
emilmont | 77:869cf507173a | 293 | * @retval None |
emilmont | 77:869cf507173a | 294 | */ |
emilmont | 77:869cf507173a | 295 | #define __HAL_CRYP_ENABLE_IT(__INTERRUPT__) ((CRYP->IMSCR) |= (__INTERRUPT__)) |
emilmont | 77:869cf507173a | 296 | |
emilmont | 77:869cf507173a | 297 | /** |
emilmont | 77:869cf507173a | 298 | * @brief Disable the CRYP interrupt. |
emilmont | 77:869cf507173a | 299 | * @param __INTERRUPT__: CRYP interrupt. |
emilmont | 77:869cf507173a | 300 | * @retval None |
emilmont | 77:869cf507173a | 301 | */ |
emilmont | 77:869cf507173a | 302 | #define __HAL_CRYP_DISABLE_IT(__INTERRUPT__) ((CRYP->IMSCR) &= ~(__INTERRUPT__)) |
emilmont | 77:869cf507173a | 303 | |
emilmont | 77:869cf507173a | 304 | /* Include CRYP HAL Extension module */ |
emilmont | 77:869cf507173a | 305 | #include "stm32f4xx_hal_cryp_ex.h" |
emilmont | 77:869cf507173a | 306 | |
emilmont | 77:869cf507173a | 307 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 85:024bf7f99721 | 308 | /* Initialization/de-initialization functions ********************************/ |
emilmont | 77:869cf507173a | 309 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 310 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 311 | |
emilmont | 77:869cf507173a | 312 | /* AES encryption/decryption using polling ***********************************/ |
emilmont | 77:869cf507173a | 313 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 314 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 315 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 316 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 317 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 318 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 319 | |
emilmont | 77:869cf507173a | 320 | /* AES encryption/decryption using interrupt *********************************/ |
emilmont | 77:869cf507173a | 321 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 322 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 323 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 324 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 325 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 326 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 327 | |
emilmont | 77:869cf507173a | 328 | /* AES encryption/decryption using DMA ***************************************/ |
emilmont | 77:869cf507173a | 329 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 330 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 331 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 332 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 333 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 334 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 335 | |
emilmont | 77:869cf507173a | 336 | /* DES encryption/decryption using polling ***********************************/ |
emilmont | 77:869cf507173a | 337 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 338 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 339 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 340 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 341 | |
emilmont | 77:869cf507173a | 342 | /* DES encryption/decryption using interrupt *********************************/ |
emilmont | 77:869cf507173a | 343 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 344 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 345 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 346 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 347 | |
emilmont | 77:869cf507173a | 348 | /* DES encryption/decryption using DMA ***************************************/ |
emilmont | 77:869cf507173a | 349 | HAL_StatusTypeDef HAL_CRYP_DESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 350 | HAL_StatusTypeDef HAL_CRYP_DESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 351 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 352 | HAL_StatusTypeDef HAL_CRYP_DESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 353 | |
emilmont | 77:869cf507173a | 354 | /* TDES encryption/decryption using polling **********************************/ |
emilmont | 77:869cf507173a | 355 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 356 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 357 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 358 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
emilmont | 77:869cf507173a | 359 | |
emilmont | 77:869cf507173a | 360 | /* TDES encryption/decryption using interrupt ********************************/ |
emilmont | 77:869cf507173a | 361 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 362 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 363 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 364 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 365 | |
emilmont | 77:869cf507173a | 366 | /* TDES encryption/decryption using DMA **************************************/ |
emilmont | 77:869cf507173a | 367 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 368 | HAL_StatusTypeDef HAL_CRYP_TDESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 369 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
emilmont | 77:869cf507173a | 370 | HAL_StatusTypeDef HAL_CRYP_TDESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
emilmont | 77:869cf507173a | 371 | |
bogdanm | 85:024bf7f99721 | 372 | /* Processing functions ******************************************************/ |
emilmont | 77:869cf507173a | 373 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 374 | |
bogdanm | 85:024bf7f99721 | 375 | /* Peripheral State functions ************************************************/ |
emilmont | 77:869cf507173a | 376 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 377 | |
emilmont | 77:869cf507173a | 378 | /* MSP functions *************************************************************/ |
bogdanm | 81:7d30d6019079 | 379 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
bogdanm | 81:7d30d6019079 | 380 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 381 | |
emilmont | 77:869cf507173a | 382 | /* CallBack functions ********************************************************/ |
bogdanm | 81:7d30d6019079 | 383 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
bogdanm | 81:7d30d6019079 | 384 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
bogdanm | 81:7d30d6019079 | 385 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
emilmont | 77:869cf507173a | 386 | |
emilmont | 77:869cf507173a | 387 | #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx */ |
emilmont | 77:869cf507173a | 388 | |
emilmont | 77:869cf507173a | 389 | /** |
emilmont | 77:869cf507173a | 390 | * @} |
emilmont | 77:869cf507173a | 391 | */ |
emilmont | 77:869cf507173a | 392 | |
emilmont | 77:869cf507173a | 393 | /** |
emilmont | 77:869cf507173a | 394 | * @} |
emilmont | 77:869cf507173a | 395 | */ |
emilmont | 77:869cf507173a | 396 | |
emilmont | 77:869cf507173a | 397 | #ifdef __cplusplus |
emilmont | 77:869cf507173a | 398 | } |
emilmont | 77:869cf507173a | 399 | #endif |
emilmont | 77:869cf507173a | 400 | |
emilmont | 77:869cf507173a | 401 | #endif /* __STM32F4xx_HAL_CRYP_H */ |
emilmont | 77:869cf507173a | 402 | |
emilmont | 77:869cf507173a | 403 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |