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