The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

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