mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F7/stm32f7xx_hal_hash.c@637:ed69428d4850, 2015-12-22 (annotated)
- Committer:
- jaerts
- Date:
- Tue Dec 22 13:22:16 2015 +0000
- Revision:
- 637:ed69428d4850
- Parent:
- 610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 573:ad23fe03a082 | 1 | /** |
mbed_official | 573:ad23fe03a082 | 2 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 3 | * @file stm32f7xx_hal_hash.c |
mbed_official | 573:ad23fe03a082 | 4 | * @author MCD Application Team |
mbed_official | 610:813dcc80987e | 5 | * @version V1.0.1 |
mbed_official | 610:813dcc80987e | 6 | * @date 25-June-2015 |
mbed_official | 573:ad23fe03a082 | 7 | * @brief HASH HAL module driver. |
mbed_official | 573:ad23fe03a082 | 8 | * This file provides firmware functions to manage the following |
mbed_official | 573:ad23fe03a082 | 9 | * functionalities of the HASH peripheral: |
mbed_official | 573:ad23fe03a082 | 10 | * + Initialization and de-initialization functions |
mbed_official | 573:ad23fe03a082 | 11 | * + HASH/HMAC Processing functions by algorithm using polling mode |
mbed_official | 573:ad23fe03a082 | 12 | * + HASH/HMAC functions by algorithm using interrupt mode |
mbed_official | 573:ad23fe03a082 | 13 | * + HASH/HMAC functions by algorithm using DMA mode |
mbed_official | 573:ad23fe03a082 | 14 | * + Peripheral State functions |
mbed_official | 573:ad23fe03a082 | 15 | * |
mbed_official | 573:ad23fe03a082 | 16 | @verbatim |
mbed_official | 573:ad23fe03a082 | 17 | ============================================================================== |
mbed_official | 573:ad23fe03a082 | 18 | ##### How to use this driver ##### |
mbed_official | 573:ad23fe03a082 | 19 | ============================================================================== |
mbed_official | 573:ad23fe03a082 | 20 | [..] |
mbed_official | 573:ad23fe03a082 | 21 | The HASH HAL driver can be used as follows: |
mbed_official | 573:ad23fe03a082 | 22 | (#)Initialize the HASH low level resources by implementing the HAL_HASH_MspInit(): |
mbed_official | 573:ad23fe03a082 | 23 | (##) Enable the HASH interface clock using __HAL_RCC_HASH_CLK_ENABLE() |
mbed_official | 573:ad23fe03a082 | 24 | (##) In case of using processing APIs based on interrupts (e.g. HAL_HMAC_SHA1_Start_IT()) |
mbed_official | 573:ad23fe03a082 | 25 | (+++) Configure the HASH interrupt priority using HAL_NVIC_SetPriority() |
mbed_official | 573:ad23fe03a082 | 26 | (+++) Enable the HASH IRQ handler using HAL_NVIC_EnableIRQ() |
mbed_official | 573:ad23fe03a082 | 27 | (+++) In HASH IRQ handler, call HAL_HASH_IRQHandler() |
mbed_official | 573:ad23fe03a082 | 28 | (##) In case of using DMA to control data transfer (e.g. HAL_HMAC_SHA1_Start_DMA()) |
mbed_official | 573:ad23fe03a082 | 29 | (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() |
mbed_official | 573:ad23fe03a082 | 30 | (+++) Configure and enable one DMA stream one for managing data transfer from |
mbed_official | 573:ad23fe03a082 | 31 | memory to peripheral (input stream). Managing data transfer from |
mbed_official | 573:ad23fe03a082 | 32 | peripheral to memory can be performed only using CPU |
mbed_official | 573:ad23fe03a082 | 33 | (+++) Associate the initialized DMA handle to the HASH DMA handle |
mbed_official | 573:ad23fe03a082 | 34 | using __HAL_LINKDMA() |
mbed_official | 573:ad23fe03a082 | 35 | (+++) Configure the priority and enable the NVIC for the transfer complete |
mbed_official | 573:ad23fe03a082 | 36 | interrupt on the DMA Stream using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() |
mbed_official | 573:ad23fe03a082 | 37 | (#)Initialize the HASH HAL using HAL_HASH_Init(). This function configures mainly: |
mbed_official | 573:ad23fe03a082 | 38 | (##) The data type: 1-bit, 8-bit, 16-bit and 32-bit. |
mbed_official | 573:ad23fe03a082 | 39 | (##) For HMAC, the encryption key. |
mbed_official | 573:ad23fe03a082 | 40 | (##) For HMAC, the key size used for encryption. |
mbed_official | 573:ad23fe03a082 | 41 | (#)Three processing functions are available: |
mbed_official | 573:ad23fe03a082 | 42 | (##) Polling mode: processing APIs are blocking functions |
mbed_official | 573:ad23fe03a082 | 43 | i.e. they process the data and wait till the digest computation is finished |
mbed_official | 573:ad23fe03a082 | 44 | e.g. HAL_HASH_SHA1_Start() |
mbed_official | 573:ad23fe03a082 | 45 | (##) Interrupt mode: encryption and decryption APIs are not blocking functions |
mbed_official | 573:ad23fe03a082 | 46 | i.e. they process the data under interrupt |
mbed_official | 573:ad23fe03a082 | 47 | e.g. HAL_HASH_SHA1_Start_IT() |
mbed_official | 573:ad23fe03a082 | 48 | (##) DMA mode: processing APIs are not blocking functions and the CPU is |
mbed_official | 573:ad23fe03a082 | 49 | not used for data transfer i.e. the data transfer is ensured by DMA |
mbed_official | 573:ad23fe03a082 | 50 | e.g. HAL_HASH_SHA1_Start_DMA() |
mbed_official | 573:ad23fe03a082 | 51 | (#)When the processing function is called at first time after HAL_HASH_Init() |
mbed_official | 573:ad23fe03a082 | 52 | the HASH peripheral is initialized and processes the buffer in input. |
mbed_official | 573:ad23fe03a082 | 53 | After that, the digest computation is started. |
mbed_official | 573:ad23fe03a082 | 54 | When processing multi-buffer use the accumulate function to write the |
mbed_official | 573:ad23fe03a082 | 55 | data in the peripheral without starting the digest computation. In last |
mbed_official | 573:ad23fe03a082 | 56 | buffer use the start function to input the last buffer ans start the digest |
mbed_official | 573:ad23fe03a082 | 57 | computation. |
mbed_official | 573:ad23fe03a082 | 58 | (##) e.g. HAL_HASH_SHA1_Accumulate() : write 1st data buffer in the peripheral without starting the digest computation |
mbed_official | 573:ad23fe03a082 | 59 | (##) write (n-1)th data buffer in the peripheral without starting the digest computation |
mbed_official | 573:ad23fe03a082 | 60 | (##) HAL_HASH_SHA1_Start() : write (n)th data buffer in the peripheral and start the digest computation |
mbed_official | 573:ad23fe03a082 | 61 | (#)In HMAC mode, there is no Accumulate API. Only Start API is available. |
mbed_official | 573:ad23fe03a082 | 62 | (#)In case of using DMA, call the DMA start processing e.g. HAL_HASH_SHA1_Start_DMA(). |
mbed_official | 573:ad23fe03a082 | 63 | After that, call the finish function in order to get the digest value |
mbed_official | 573:ad23fe03a082 | 64 | e.g. HAL_HASH_SHA1_Finish() |
mbed_official | 573:ad23fe03a082 | 65 | (#)Call HAL_HASH_DeInit() to deinitialize the HASH peripheral. |
mbed_official | 573:ad23fe03a082 | 66 | |
mbed_official | 573:ad23fe03a082 | 67 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 68 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 69 | * @attention |
mbed_official | 573:ad23fe03a082 | 70 | * |
mbed_official | 573:ad23fe03a082 | 71 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
mbed_official | 573:ad23fe03a082 | 72 | * |
mbed_official | 573:ad23fe03a082 | 73 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 573:ad23fe03a082 | 74 | * are permitted provided that the following conditions are met: |
mbed_official | 573:ad23fe03a082 | 75 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 573:ad23fe03a082 | 76 | * this list of conditions and the following disclaimer. |
mbed_official | 573:ad23fe03a082 | 77 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 573:ad23fe03a082 | 78 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 573:ad23fe03a082 | 79 | * and/or other materials provided with the distribution. |
mbed_official | 573:ad23fe03a082 | 80 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 573:ad23fe03a082 | 81 | * may be used to endorse or promote products derived from this software |
mbed_official | 573:ad23fe03a082 | 82 | * without specific prior written permission. |
mbed_official | 573:ad23fe03a082 | 83 | * |
mbed_official | 573:ad23fe03a082 | 84 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 573:ad23fe03a082 | 85 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 573:ad23fe03a082 | 86 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 573:ad23fe03a082 | 87 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 573:ad23fe03a082 | 88 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 573:ad23fe03a082 | 89 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 573:ad23fe03a082 | 90 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 573:ad23fe03a082 | 91 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 573:ad23fe03a082 | 92 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 573:ad23fe03a082 | 93 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 573:ad23fe03a082 | 94 | * |
mbed_official | 573:ad23fe03a082 | 95 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 96 | */ |
mbed_official | 573:ad23fe03a082 | 97 | |
mbed_official | 573:ad23fe03a082 | 98 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 99 | #include "stm32f7xx_hal.h" |
mbed_official | 573:ad23fe03a082 | 100 | |
mbed_official | 573:ad23fe03a082 | 101 | /** @addtogroup STM32F7xx_HAL_Driver |
mbed_official | 573:ad23fe03a082 | 102 | * @{ |
mbed_official | 573:ad23fe03a082 | 103 | */ |
mbed_official | 573:ad23fe03a082 | 104 | |
mbed_official | 573:ad23fe03a082 | 105 | #if defined(STM32F756xx) |
mbed_official | 573:ad23fe03a082 | 106 | |
mbed_official | 573:ad23fe03a082 | 107 | /** @defgroup HASH HASH |
mbed_official | 573:ad23fe03a082 | 108 | * @brief HASH HAL module driver. |
mbed_official | 573:ad23fe03a082 | 109 | * @{ |
mbed_official | 573:ad23fe03a082 | 110 | */ |
mbed_official | 573:ad23fe03a082 | 111 | #ifdef HAL_HASH_MODULE_ENABLED |
mbed_official | 573:ad23fe03a082 | 112 | |
mbed_official | 573:ad23fe03a082 | 113 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 114 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 115 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 116 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 117 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 118 | /** @defgroup HASH_Private_Functions HASH Private Functions |
mbed_official | 573:ad23fe03a082 | 119 | * @{ |
mbed_official | 573:ad23fe03a082 | 120 | */ |
mbed_official | 573:ad23fe03a082 | 121 | static void HASH_DMAXferCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 122 | static void HASH_DMAError(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 123 | static void HASH_GetDigest(uint8_t *pMsgDigest, uint8_t Size); |
mbed_official | 573:ad23fe03a082 | 124 | static void HASH_WriteData(uint8_t *pInBuffer, uint32_t Size); |
mbed_official | 573:ad23fe03a082 | 125 | /** |
mbed_official | 573:ad23fe03a082 | 126 | * @} |
mbed_official | 573:ad23fe03a082 | 127 | */ |
mbed_official | 573:ad23fe03a082 | 128 | |
mbed_official | 573:ad23fe03a082 | 129 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 130 | /** @addtogroup HASH_Private_Functions |
mbed_official | 573:ad23fe03a082 | 131 | * @{ |
mbed_official | 573:ad23fe03a082 | 132 | */ |
mbed_official | 573:ad23fe03a082 | 133 | |
mbed_official | 573:ad23fe03a082 | 134 | /** |
mbed_official | 573:ad23fe03a082 | 135 | * @brief DMA HASH Input Data complete callback. |
mbed_official | 573:ad23fe03a082 | 136 | * @param hdma: DMA handle |
mbed_official | 573:ad23fe03a082 | 137 | * @retval None |
mbed_official | 573:ad23fe03a082 | 138 | */ |
mbed_official | 573:ad23fe03a082 | 139 | static void HASH_DMAXferCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 140 | { |
mbed_official | 573:ad23fe03a082 | 141 | HASH_HandleTypeDef* hhash = ( HASH_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 142 | uint32_t inputaddr = 0; |
mbed_official | 573:ad23fe03a082 | 143 | uint32_t buffersize = 0; |
mbed_official | 573:ad23fe03a082 | 144 | |
mbed_official | 573:ad23fe03a082 | 145 | if((HASH->CR & HASH_CR_MODE) != HASH_CR_MODE) |
mbed_official | 573:ad23fe03a082 | 146 | { |
mbed_official | 573:ad23fe03a082 | 147 | /* Disable the DMA transfer */ |
mbed_official | 573:ad23fe03a082 | 148 | HASH->CR &= (uint32_t)(~HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 149 | |
mbed_official | 573:ad23fe03a082 | 150 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 151 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 152 | |
mbed_official | 573:ad23fe03a082 | 153 | /* Call Input data transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 154 | HAL_HASH_InCpltCallback(hhash); |
mbed_official | 573:ad23fe03a082 | 155 | } |
mbed_official | 573:ad23fe03a082 | 156 | else |
mbed_official | 573:ad23fe03a082 | 157 | { |
mbed_official | 573:ad23fe03a082 | 158 | /* Increment Interrupt counter */ |
mbed_official | 573:ad23fe03a082 | 159 | hhash->HashInCount++; |
mbed_official | 573:ad23fe03a082 | 160 | /* Disable the DMA transfer before starting the next transfer */ |
mbed_official | 573:ad23fe03a082 | 161 | HASH->CR &= (uint32_t)(~HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 162 | |
mbed_official | 573:ad23fe03a082 | 163 | if(hhash->HashInCount <= 2) |
mbed_official | 573:ad23fe03a082 | 164 | { |
mbed_official | 573:ad23fe03a082 | 165 | /* In case HashInCount = 1, set the DMA to transfer data to HASH DIN register */ |
mbed_official | 573:ad23fe03a082 | 166 | if(hhash->HashInCount == 1) |
mbed_official | 573:ad23fe03a082 | 167 | { |
mbed_official | 573:ad23fe03a082 | 168 | inputaddr = (uint32_t)hhash->pHashInBuffPtr; |
mbed_official | 573:ad23fe03a082 | 169 | buffersize = hhash->HashBuffSize; |
mbed_official | 573:ad23fe03a082 | 170 | } |
mbed_official | 573:ad23fe03a082 | 171 | /* In case HashInCount = 2, set the DMA to transfer key to HASH DIN register */ |
mbed_official | 573:ad23fe03a082 | 172 | else if(hhash->HashInCount == 2) |
mbed_official | 573:ad23fe03a082 | 173 | { |
mbed_official | 573:ad23fe03a082 | 174 | inputaddr = (uint32_t)hhash->Init.pKey; |
mbed_official | 573:ad23fe03a082 | 175 | buffersize = hhash->Init.KeySize; |
mbed_official | 573:ad23fe03a082 | 176 | } |
mbed_official | 573:ad23fe03a082 | 177 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 610:813dcc80987e | 178 | MODIFY_REG(HASH->STR, HASH_STR_NBLW, 8 * (buffersize % 4)); |
mbed_official | 573:ad23fe03a082 | 179 | |
mbed_official | 573:ad23fe03a082 | 180 | /* Set the HASH DMA transfer complete */ |
mbed_official | 573:ad23fe03a082 | 181 | hhash->hdmain->XferCpltCallback = HASH_DMAXferCplt; |
mbed_official | 573:ad23fe03a082 | 182 | |
mbed_official | 573:ad23fe03a082 | 183 | /* Enable the DMA In DMA Stream */ |
mbed_official | 573:ad23fe03a082 | 184 | HAL_DMA_Start_IT(hhash->hdmain, inputaddr, (uint32_t)&HASH->DIN, (buffersize%4 ? (buffersize+3)/4:buffersize/4)); |
mbed_official | 573:ad23fe03a082 | 185 | |
mbed_official | 573:ad23fe03a082 | 186 | /* Enable DMA requests */ |
mbed_official | 573:ad23fe03a082 | 187 | HASH->CR |= (HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 188 | } |
mbed_official | 573:ad23fe03a082 | 189 | else |
mbed_official | 573:ad23fe03a082 | 190 | { |
mbed_official | 573:ad23fe03a082 | 191 | /* Disable the DMA transfer */ |
mbed_official | 573:ad23fe03a082 | 192 | HASH->CR &= (uint32_t)(~HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 193 | |
mbed_official | 573:ad23fe03a082 | 194 | /* Reset the InCount */ |
mbed_official | 573:ad23fe03a082 | 195 | hhash->HashInCount = 0; |
mbed_official | 573:ad23fe03a082 | 196 | |
mbed_official | 573:ad23fe03a082 | 197 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 198 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 199 | |
mbed_official | 573:ad23fe03a082 | 200 | /* Call Input data transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 201 | HAL_HASH_InCpltCallback(hhash); |
mbed_official | 573:ad23fe03a082 | 202 | } |
mbed_official | 573:ad23fe03a082 | 203 | } |
mbed_official | 573:ad23fe03a082 | 204 | } |
mbed_official | 573:ad23fe03a082 | 205 | |
mbed_official | 573:ad23fe03a082 | 206 | /** |
mbed_official | 573:ad23fe03a082 | 207 | * @brief DMA HASH communication error callback. |
mbed_official | 573:ad23fe03a082 | 208 | * @param hdma: DMA handle |
mbed_official | 573:ad23fe03a082 | 209 | * @retval None |
mbed_official | 573:ad23fe03a082 | 210 | */ |
mbed_official | 573:ad23fe03a082 | 211 | static void HASH_DMAError(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 212 | { |
mbed_official | 573:ad23fe03a082 | 213 | HASH_HandleTypeDef* hhash = ( HASH_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 214 | hhash->State= HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 215 | HAL_HASH_ErrorCallback(hhash); |
mbed_official | 573:ad23fe03a082 | 216 | } |
mbed_official | 573:ad23fe03a082 | 217 | |
mbed_official | 573:ad23fe03a082 | 218 | /** |
mbed_official | 573:ad23fe03a082 | 219 | * @brief Writes the input buffer in data register. |
mbed_official | 573:ad23fe03a082 | 220 | * @param pInBuffer: Pointer to input buffer |
mbed_official | 573:ad23fe03a082 | 221 | * @param Size: The size of input buffer |
mbed_official | 573:ad23fe03a082 | 222 | * @retval None |
mbed_official | 573:ad23fe03a082 | 223 | */ |
mbed_official | 573:ad23fe03a082 | 224 | static void HASH_WriteData(uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 225 | { |
mbed_official | 573:ad23fe03a082 | 226 | uint32_t buffercounter; |
mbed_official | 573:ad23fe03a082 | 227 | uint32_t inputaddr = (uint32_t) pInBuffer; |
mbed_official | 573:ad23fe03a082 | 228 | |
mbed_official | 573:ad23fe03a082 | 229 | for(buffercounter = 0; buffercounter < Size; buffercounter+=4) |
mbed_official | 573:ad23fe03a082 | 230 | { |
mbed_official | 573:ad23fe03a082 | 231 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 232 | inputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 233 | } |
mbed_official | 573:ad23fe03a082 | 234 | } |
mbed_official | 573:ad23fe03a082 | 235 | |
mbed_official | 573:ad23fe03a082 | 236 | /** |
mbed_official | 573:ad23fe03a082 | 237 | * @brief Provides the message digest result. |
mbed_official | 573:ad23fe03a082 | 238 | * @param pMsgDigest: Pointer to the message digest |
mbed_official | 573:ad23fe03a082 | 239 | * @param Size: The size of the message digest in bytes |
mbed_official | 573:ad23fe03a082 | 240 | * @retval None |
mbed_official | 573:ad23fe03a082 | 241 | */ |
mbed_official | 573:ad23fe03a082 | 242 | static void HASH_GetDigest(uint8_t *pMsgDigest, uint8_t Size) |
mbed_official | 573:ad23fe03a082 | 243 | { |
mbed_official | 573:ad23fe03a082 | 244 | uint32_t msgdigest = (uint32_t)pMsgDigest; |
mbed_official | 573:ad23fe03a082 | 245 | |
mbed_official | 573:ad23fe03a082 | 246 | switch(Size) |
mbed_official | 573:ad23fe03a082 | 247 | { |
mbed_official | 573:ad23fe03a082 | 248 | case 16: |
mbed_official | 573:ad23fe03a082 | 249 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 250 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 251 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 252 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 253 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 254 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 255 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 256 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 257 | break; |
mbed_official | 573:ad23fe03a082 | 258 | case 20: |
mbed_official | 573:ad23fe03a082 | 259 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 260 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 261 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 262 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 263 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 264 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 265 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 266 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 267 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 268 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[4]); |
mbed_official | 573:ad23fe03a082 | 269 | break; |
mbed_official | 573:ad23fe03a082 | 270 | case 28: |
mbed_official | 573:ad23fe03a082 | 271 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 272 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 273 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 274 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 275 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 276 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 277 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 278 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 279 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 280 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[4]); |
mbed_official | 573:ad23fe03a082 | 281 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 282 | *(uint32_t*)(msgdigest) = __REV(HASH_DIGEST->HR[5]); |
mbed_official | 573:ad23fe03a082 | 283 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 284 | *(uint32_t*)(msgdigest) = __REV(HASH_DIGEST->HR[6]); |
mbed_official | 573:ad23fe03a082 | 285 | break; |
mbed_official | 573:ad23fe03a082 | 286 | case 32: |
mbed_official | 573:ad23fe03a082 | 287 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 288 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 289 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 290 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 291 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 292 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 293 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 294 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 295 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 296 | *(uint32_t*)(msgdigest) = __REV(HASH->HR[4]); |
mbed_official | 573:ad23fe03a082 | 297 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 298 | *(uint32_t*)(msgdigest) = __REV(HASH_DIGEST->HR[5]); |
mbed_official | 573:ad23fe03a082 | 299 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 300 | *(uint32_t*)(msgdigest) = __REV(HASH_DIGEST->HR[6]); |
mbed_official | 573:ad23fe03a082 | 301 | msgdigest+=4; |
mbed_official | 573:ad23fe03a082 | 302 | *(uint32_t*)(msgdigest) = __REV(HASH_DIGEST->HR[7]); |
mbed_official | 573:ad23fe03a082 | 303 | break; |
mbed_official | 573:ad23fe03a082 | 304 | default: |
mbed_official | 573:ad23fe03a082 | 305 | break; |
mbed_official | 573:ad23fe03a082 | 306 | } |
mbed_official | 573:ad23fe03a082 | 307 | } |
mbed_official | 573:ad23fe03a082 | 308 | |
mbed_official | 573:ad23fe03a082 | 309 | /** |
mbed_official | 573:ad23fe03a082 | 310 | * @} |
mbed_official | 573:ad23fe03a082 | 311 | */ |
mbed_official | 573:ad23fe03a082 | 312 | |
mbed_official | 573:ad23fe03a082 | 313 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 314 | /** @addtogroup HASH_Exported_Functions |
mbed_official | 573:ad23fe03a082 | 315 | * @{ |
mbed_official | 573:ad23fe03a082 | 316 | */ |
mbed_official | 573:ad23fe03a082 | 317 | |
mbed_official | 573:ad23fe03a082 | 318 | |
mbed_official | 573:ad23fe03a082 | 319 | /** @addtogroup HASH_Exported_Functions_Group1 Initialization and de-initialization functions |
mbed_official | 573:ad23fe03a082 | 320 | * @brief Initialization and Configuration functions. |
mbed_official | 573:ad23fe03a082 | 321 | * |
mbed_official | 573:ad23fe03a082 | 322 | @verbatim |
mbed_official | 573:ad23fe03a082 | 323 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 324 | ##### Initialization and de-initialization functions ##### |
mbed_official | 573:ad23fe03a082 | 325 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 326 | [..] This section provides functions allowing to: |
mbed_official | 573:ad23fe03a082 | 327 | (+) Initialize the HASH according to the specified parameters |
mbed_official | 573:ad23fe03a082 | 328 | in the HASH_InitTypeDef and creates the associated handle. |
mbed_official | 573:ad23fe03a082 | 329 | (+) DeInitialize the HASH peripheral. |
mbed_official | 573:ad23fe03a082 | 330 | (+) Initialize the HASH MSP. |
mbed_official | 573:ad23fe03a082 | 331 | (+) DeInitialize HASH MSP. |
mbed_official | 573:ad23fe03a082 | 332 | |
mbed_official | 573:ad23fe03a082 | 333 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 334 | * @{ |
mbed_official | 573:ad23fe03a082 | 335 | */ |
mbed_official | 573:ad23fe03a082 | 336 | |
mbed_official | 573:ad23fe03a082 | 337 | /** |
mbed_official | 573:ad23fe03a082 | 338 | * @brief Initializes the HASH according to the specified parameters in the |
mbed_official | 573:ad23fe03a082 | 339 | HASH_HandleTypeDef and creates the associated handle. |
mbed_official | 573:ad23fe03a082 | 340 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 341 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 342 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 343 | */ |
mbed_official | 573:ad23fe03a082 | 344 | HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 345 | { |
mbed_official | 573:ad23fe03a082 | 346 | /* Check the hash handle allocation */ |
mbed_official | 573:ad23fe03a082 | 347 | if(hhash == NULL) |
mbed_official | 573:ad23fe03a082 | 348 | { |
mbed_official | 573:ad23fe03a082 | 349 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 350 | } |
mbed_official | 573:ad23fe03a082 | 351 | |
mbed_official | 573:ad23fe03a082 | 352 | /* Check the parameters */ |
mbed_official | 573:ad23fe03a082 | 353 | assert_param(IS_HASH_DATATYPE(hhash->Init.DataType)); |
mbed_official | 573:ad23fe03a082 | 354 | |
mbed_official | 573:ad23fe03a082 | 355 | if(hhash->State == HAL_HASH_STATE_RESET) |
mbed_official | 573:ad23fe03a082 | 356 | { |
mbed_official | 573:ad23fe03a082 | 357 | /* Allocate lock resource and initialize it */ |
mbed_official | 573:ad23fe03a082 | 358 | hhash->Lock = HAL_UNLOCKED; |
mbed_official | 573:ad23fe03a082 | 359 | /* Init the low level hardware */ |
mbed_official | 573:ad23fe03a082 | 360 | HAL_HASH_MspInit(hhash); |
mbed_official | 573:ad23fe03a082 | 361 | } |
mbed_official | 573:ad23fe03a082 | 362 | |
mbed_official | 573:ad23fe03a082 | 363 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 364 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 365 | |
mbed_official | 573:ad23fe03a082 | 366 | /* Reset HashInCount, HashBuffSize and HashITCounter */ |
mbed_official | 573:ad23fe03a082 | 367 | hhash->HashInCount = 0; |
mbed_official | 573:ad23fe03a082 | 368 | hhash->HashBuffSize = 0; |
mbed_official | 573:ad23fe03a082 | 369 | hhash->HashITCounter = 0; |
mbed_official | 573:ad23fe03a082 | 370 | |
mbed_official | 573:ad23fe03a082 | 371 | /* Set the data type */ |
mbed_official | 573:ad23fe03a082 | 372 | HASH->CR |= (uint32_t) (hhash->Init.DataType); |
mbed_official | 573:ad23fe03a082 | 373 | |
mbed_official | 573:ad23fe03a082 | 374 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 375 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 376 | |
mbed_official | 573:ad23fe03a082 | 377 | /* Set the default HASH phase */ |
mbed_official | 573:ad23fe03a082 | 378 | hhash->Phase = HAL_HASH_PHASE_READY; |
mbed_official | 573:ad23fe03a082 | 379 | |
mbed_official | 573:ad23fe03a082 | 380 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 381 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 382 | } |
mbed_official | 573:ad23fe03a082 | 383 | |
mbed_official | 573:ad23fe03a082 | 384 | /** |
mbed_official | 573:ad23fe03a082 | 385 | * @brief DeInitializes the HASH peripheral. |
mbed_official | 573:ad23fe03a082 | 386 | * @note This API must be called before starting a new processing. |
mbed_official | 573:ad23fe03a082 | 387 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 388 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 389 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 390 | */ |
mbed_official | 573:ad23fe03a082 | 391 | HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 392 | { |
mbed_official | 573:ad23fe03a082 | 393 | /* Check the HASH handle allocation */ |
mbed_official | 573:ad23fe03a082 | 394 | if(hhash == NULL) |
mbed_official | 573:ad23fe03a082 | 395 | { |
mbed_official | 573:ad23fe03a082 | 396 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 397 | } |
mbed_official | 573:ad23fe03a082 | 398 | |
mbed_official | 573:ad23fe03a082 | 399 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 400 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 401 | |
mbed_official | 573:ad23fe03a082 | 402 | /* Set the default HASH phase */ |
mbed_official | 573:ad23fe03a082 | 403 | hhash->Phase = HAL_HASH_PHASE_READY; |
mbed_official | 573:ad23fe03a082 | 404 | |
mbed_official | 573:ad23fe03a082 | 405 | /* Reset HashInCount, HashBuffSize and HashITCounter */ |
mbed_official | 573:ad23fe03a082 | 406 | hhash->HashInCount = 0; |
mbed_official | 573:ad23fe03a082 | 407 | hhash->HashBuffSize = 0; |
mbed_official | 573:ad23fe03a082 | 408 | hhash->HashITCounter = 0; |
mbed_official | 573:ad23fe03a082 | 409 | |
mbed_official | 573:ad23fe03a082 | 410 | /* DeInit the low level hardware */ |
mbed_official | 573:ad23fe03a082 | 411 | HAL_HASH_MspDeInit(hhash); |
mbed_official | 573:ad23fe03a082 | 412 | |
mbed_official | 573:ad23fe03a082 | 413 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 414 | hhash->State = HAL_HASH_STATE_RESET; |
mbed_official | 573:ad23fe03a082 | 415 | |
mbed_official | 573:ad23fe03a082 | 416 | /* Release Lock */ |
mbed_official | 573:ad23fe03a082 | 417 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 418 | |
mbed_official | 573:ad23fe03a082 | 419 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 420 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 421 | } |
mbed_official | 573:ad23fe03a082 | 422 | |
mbed_official | 573:ad23fe03a082 | 423 | /** |
mbed_official | 573:ad23fe03a082 | 424 | * @brief Initializes the HASH MSP. |
mbed_official | 573:ad23fe03a082 | 425 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 426 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 427 | * @retval None |
mbed_official | 573:ad23fe03a082 | 428 | */ |
mbed_official | 573:ad23fe03a082 | 429 | __weak void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 430 | { |
mbed_official | 573:ad23fe03a082 | 431 | /* NOTE: This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 432 | the HAL_HASH_MspInit could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 433 | */ |
mbed_official | 573:ad23fe03a082 | 434 | } |
mbed_official | 573:ad23fe03a082 | 435 | |
mbed_official | 573:ad23fe03a082 | 436 | /** |
mbed_official | 573:ad23fe03a082 | 437 | * @brief DeInitializes HASH MSP. |
mbed_official | 573:ad23fe03a082 | 438 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 439 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 440 | * @retval None |
mbed_official | 573:ad23fe03a082 | 441 | */ |
mbed_official | 573:ad23fe03a082 | 442 | __weak void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 443 | { |
mbed_official | 573:ad23fe03a082 | 444 | /* NOTE: This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 445 | the HAL_HASH_MspDeInit could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 446 | */ |
mbed_official | 573:ad23fe03a082 | 447 | } |
mbed_official | 573:ad23fe03a082 | 448 | |
mbed_official | 573:ad23fe03a082 | 449 | /** |
mbed_official | 573:ad23fe03a082 | 450 | * @brief Input data transfer complete callback. |
mbed_official | 573:ad23fe03a082 | 451 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 452 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 453 | * @retval None |
mbed_official | 573:ad23fe03a082 | 454 | */ |
mbed_official | 573:ad23fe03a082 | 455 | __weak void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 456 | { |
mbed_official | 573:ad23fe03a082 | 457 | /* NOTE: This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 458 | the HAL_HASH_InCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 459 | */ |
mbed_official | 573:ad23fe03a082 | 460 | } |
mbed_official | 573:ad23fe03a082 | 461 | |
mbed_official | 573:ad23fe03a082 | 462 | /** |
mbed_official | 573:ad23fe03a082 | 463 | * @brief Data transfer Error callback. |
mbed_official | 573:ad23fe03a082 | 464 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 465 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 466 | * @retval None |
mbed_official | 573:ad23fe03a082 | 467 | */ |
mbed_official | 573:ad23fe03a082 | 468 | __weak void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 469 | { |
mbed_official | 573:ad23fe03a082 | 470 | /* NOTE: This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 471 | the HAL_HASH_ErrorCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 472 | */ |
mbed_official | 573:ad23fe03a082 | 473 | } |
mbed_official | 573:ad23fe03a082 | 474 | |
mbed_official | 573:ad23fe03a082 | 475 | /** |
mbed_official | 573:ad23fe03a082 | 476 | * @brief Digest computation complete callback. It is used only with interrupt. |
mbed_official | 573:ad23fe03a082 | 477 | * @note This callback is not relevant with DMA. |
mbed_official | 573:ad23fe03a082 | 478 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 479 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 480 | * @retval None |
mbed_official | 573:ad23fe03a082 | 481 | */ |
mbed_official | 573:ad23fe03a082 | 482 | __weak void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 483 | { |
mbed_official | 573:ad23fe03a082 | 484 | /* NOTE: This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 485 | the HAL_HASH_DgstCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 486 | */ |
mbed_official | 573:ad23fe03a082 | 487 | } |
mbed_official | 573:ad23fe03a082 | 488 | |
mbed_official | 573:ad23fe03a082 | 489 | /** |
mbed_official | 573:ad23fe03a082 | 490 | * @} |
mbed_official | 573:ad23fe03a082 | 491 | */ |
mbed_official | 573:ad23fe03a082 | 492 | |
mbed_official | 573:ad23fe03a082 | 493 | /** @defgroup HASH_Exported_Functions_Group2 HASH processing functions using polling mode |
mbed_official | 573:ad23fe03a082 | 494 | * @brief processing functions using polling mode |
mbed_official | 573:ad23fe03a082 | 495 | * |
mbed_official | 573:ad23fe03a082 | 496 | @verbatim |
mbed_official | 573:ad23fe03a082 | 497 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 498 | ##### HASH processing using polling mode functions##### |
mbed_official | 573:ad23fe03a082 | 499 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 500 | [..] This section provides functions allowing to calculate in polling mode |
mbed_official | 573:ad23fe03a082 | 501 | the hash value using one of the following algorithms: |
mbed_official | 573:ad23fe03a082 | 502 | (+) MD5 |
mbed_official | 573:ad23fe03a082 | 503 | (+) SHA1 |
mbed_official | 573:ad23fe03a082 | 504 | |
mbed_official | 573:ad23fe03a082 | 505 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 506 | * @{ |
mbed_official | 573:ad23fe03a082 | 507 | */ |
mbed_official | 573:ad23fe03a082 | 508 | |
mbed_official | 573:ad23fe03a082 | 509 | /** |
mbed_official | 573:ad23fe03a082 | 510 | * @brief Initializes the HASH peripheral in MD5 mode then processes pInBuffer. |
mbed_official | 573:ad23fe03a082 | 511 | The digest is available in pOutBuffer. |
mbed_official | 573:ad23fe03a082 | 512 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 513 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 514 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 515 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 516 | * If the Size is multiple of 64 bytes, appending the input buffer is possible. |
mbed_official | 573:ad23fe03a082 | 517 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware |
mbed_official | 573:ad23fe03a082 | 518 | * and appending the input buffer is no more possible. |
mbed_official | 573:ad23fe03a082 | 519 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 16 bytes. |
mbed_official | 573:ad23fe03a082 | 520 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 521 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 522 | */ |
mbed_official | 573:ad23fe03a082 | 523 | HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 524 | { |
mbed_official | 573:ad23fe03a082 | 525 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 526 | |
mbed_official | 573:ad23fe03a082 | 527 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 528 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 529 | |
mbed_official | 573:ad23fe03a082 | 530 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 531 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 532 | |
mbed_official | 573:ad23fe03a082 | 533 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 534 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 535 | { |
mbed_official | 573:ad23fe03a082 | 536 | /* Select the MD5 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 537 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 538 | HASH->CR |= HASH_ALGOSELECTION_MD5 | HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 539 | } |
mbed_official | 573:ad23fe03a082 | 540 | |
mbed_official | 573:ad23fe03a082 | 541 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 542 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 543 | |
mbed_official | 573:ad23fe03a082 | 544 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 545 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 546 | |
mbed_official | 573:ad23fe03a082 | 547 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 548 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 549 | |
mbed_official | 573:ad23fe03a082 | 550 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 551 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 552 | |
mbed_official | 573:ad23fe03a082 | 553 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 554 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 555 | |
mbed_official | 573:ad23fe03a082 | 556 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 557 | { |
mbed_official | 573:ad23fe03a082 | 558 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 559 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 560 | { |
mbed_official | 573:ad23fe03a082 | 561 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 562 | { |
mbed_official | 573:ad23fe03a082 | 563 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 564 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 565 | |
mbed_official | 573:ad23fe03a082 | 566 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 567 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 568 | |
mbed_official | 573:ad23fe03a082 | 569 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 570 | } |
mbed_official | 573:ad23fe03a082 | 571 | } |
mbed_official | 573:ad23fe03a082 | 572 | } |
mbed_official | 573:ad23fe03a082 | 573 | |
mbed_official | 573:ad23fe03a082 | 574 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 575 | HASH_GetDigest(pOutBuffer, 16); |
mbed_official | 573:ad23fe03a082 | 576 | |
mbed_official | 573:ad23fe03a082 | 577 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 578 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 579 | |
mbed_official | 573:ad23fe03a082 | 580 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 581 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 582 | |
mbed_official | 573:ad23fe03a082 | 583 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 584 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 585 | } |
mbed_official | 573:ad23fe03a082 | 586 | |
mbed_official | 573:ad23fe03a082 | 587 | /** |
mbed_official | 573:ad23fe03a082 | 588 | * @brief Initializes the HASH peripheral in MD5 mode then writes the pInBuffer. |
mbed_official | 573:ad23fe03a082 | 589 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 590 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 591 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 592 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 593 | * If the Size is multiple of 64 bytes, appending the input buffer is possible. |
mbed_official | 573:ad23fe03a082 | 594 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware |
mbed_official | 573:ad23fe03a082 | 595 | * and appending the input buffer is no more possible. |
mbed_official | 573:ad23fe03a082 | 596 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 597 | */ |
mbed_official | 573:ad23fe03a082 | 598 | HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 599 | { |
mbed_official | 573:ad23fe03a082 | 600 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 601 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 602 | |
mbed_official | 573:ad23fe03a082 | 603 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 604 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 605 | |
mbed_official | 573:ad23fe03a082 | 606 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 607 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 608 | { |
mbed_official | 573:ad23fe03a082 | 609 | /* Select the MD5 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 610 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 611 | HASH->CR |= HASH_ALGOSELECTION_MD5 | HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 612 | } |
mbed_official | 573:ad23fe03a082 | 613 | |
mbed_official | 573:ad23fe03a082 | 614 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 615 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 616 | |
mbed_official | 573:ad23fe03a082 | 617 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 618 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 619 | |
mbed_official | 573:ad23fe03a082 | 620 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 621 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 622 | |
mbed_official | 573:ad23fe03a082 | 623 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 624 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 625 | |
mbed_official | 573:ad23fe03a082 | 626 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 627 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 628 | |
mbed_official | 573:ad23fe03a082 | 629 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 630 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 631 | } |
mbed_official | 573:ad23fe03a082 | 632 | |
mbed_official | 573:ad23fe03a082 | 633 | /** |
mbed_official | 573:ad23fe03a082 | 634 | * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. |
mbed_official | 573:ad23fe03a082 | 635 | The digest is available in pOutBuffer. |
mbed_official | 573:ad23fe03a082 | 636 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 637 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 638 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 639 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 640 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 641 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. |
mbed_official | 573:ad23fe03a082 | 642 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 643 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 644 | */ |
mbed_official | 573:ad23fe03a082 | 645 | HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 646 | { |
mbed_official | 573:ad23fe03a082 | 647 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 648 | |
mbed_official | 573:ad23fe03a082 | 649 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 650 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 651 | |
mbed_official | 573:ad23fe03a082 | 652 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 653 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 654 | |
mbed_official | 573:ad23fe03a082 | 655 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 656 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 657 | { |
mbed_official | 573:ad23fe03a082 | 658 | /* Select the SHA1 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 659 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 660 | HASH->CR |= HASH_ALGOSELECTION_SHA1 | HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 661 | } |
mbed_official | 573:ad23fe03a082 | 662 | |
mbed_official | 573:ad23fe03a082 | 663 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 664 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 665 | |
mbed_official | 573:ad23fe03a082 | 666 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 667 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 668 | |
mbed_official | 573:ad23fe03a082 | 669 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 670 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 671 | |
mbed_official | 573:ad23fe03a082 | 672 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 673 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 674 | |
mbed_official | 573:ad23fe03a082 | 675 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 676 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 677 | |
mbed_official | 573:ad23fe03a082 | 678 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 679 | { |
mbed_official | 573:ad23fe03a082 | 680 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 681 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 682 | { |
mbed_official | 573:ad23fe03a082 | 683 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 684 | { |
mbed_official | 573:ad23fe03a082 | 685 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 686 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 687 | |
mbed_official | 573:ad23fe03a082 | 688 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 689 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 690 | |
mbed_official | 573:ad23fe03a082 | 691 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 692 | } |
mbed_official | 573:ad23fe03a082 | 693 | } |
mbed_official | 573:ad23fe03a082 | 694 | } |
mbed_official | 573:ad23fe03a082 | 695 | |
mbed_official | 573:ad23fe03a082 | 696 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 697 | HASH_GetDigest(pOutBuffer, 20); |
mbed_official | 573:ad23fe03a082 | 698 | |
mbed_official | 573:ad23fe03a082 | 699 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 700 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 701 | |
mbed_official | 573:ad23fe03a082 | 702 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 703 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 704 | |
mbed_official | 573:ad23fe03a082 | 705 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 706 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 707 | } |
mbed_official | 573:ad23fe03a082 | 708 | |
mbed_official | 573:ad23fe03a082 | 709 | /** |
mbed_official | 573:ad23fe03a082 | 710 | * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. |
mbed_official | 573:ad23fe03a082 | 711 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 712 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 713 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 714 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 715 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 610:813dcc80987e | 716 | * @note Input buffer size in bytes must be a multiple of 4 otherwise the digest computation is corrupted. |
mbed_official | 573:ad23fe03a082 | 717 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 718 | */ |
mbed_official | 573:ad23fe03a082 | 719 | HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 720 | { |
mbed_official | 610:813dcc80987e | 721 | /* Check the parameters */ |
mbed_official | 610:813dcc80987e | 722 | assert_param(IS_HASH_SHA1_BUFFER_SIZE(Size)); |
mbed_official | 610:813dcc80987e | 723 | |
mbed_official | 573:ad23fe03a082 | 724 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 725 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 726 | |
mbed_official | 573:ad23fe03a082 | 727 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 728 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 729 | |
mbed_official | 573:ad23fe03a082 | 730 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 731 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 732 | { |
mbed_official | 573:ad23fe03a082 | 733 | /* Select the SHA1 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 734 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 735 | HASH->CR |= HASH_ALGOSELECTION_SHA1 | HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 736 | } |
mbed_official | 573:ad23fe03a082 | 737 | |
mbed_official | 573:ad23fe03a082 | 738 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 739 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 740 | |
mbed_official | 573:ad23fe03a082 | 741 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 742 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 743 | |
mbed_official | 573:ad23fe03a082 | 744 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 745 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 746 | |
mbed_official | 573:ad23fe03a082 | 747 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 748 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 749 | |
mbed_official | 573:ad23fe03a082 | 750 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 751 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 752 | |
mbed_official | 573:ad23fe03a082 | 753 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 754 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 755 | } |
mbed_official | 573:ad23fe03a082 | 756 | |
mbed_official | 573:ad23fe03a082 | 757 | /** |
mbed_official | 573:ad23fe03a082 | 758 | * @} |
mbed_official | 573:ad23fe03a082 | 759 | */ |
mbed_official | 573:ad23fe03a082 | 760 | |
mbed_official | 573:ad23fe03a082 | 761 | /** @defgroup HASH_Exported_Functions_Group3 HASH processing functions using interrupt mode |
mbed_official | 573:ad23fe03a082 | 762 | * @brief processing functions using interrupt mode. |
mbed_official | 573:ad23fe03a082 | 763 | * |
mbed_official | 573:ad23fe03a082 | 764 | @verbatim |
mbed_official | 573:ad23fe03a082 | 765 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 766 | ##### HASH processing using interrupt mode functions ##### |
mbed_official | 573:ad23fe03a082 | 767 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 768 | [..] This section provides functions allowing to calculate in interrupt mode |
mbed_official | 573:ad23fe03a082 | 769 | the hash value using one of the following algorithms: |
mbed_official | 573:ad23fe03a082 | 770 | (+) MD5 |
mbed_official | 573:ad23fe03a082 | 771 | (+) SHA1 |
mbed_official | 573:ad23fe03a082 | 772 | |
mbed_official | 573:ad23fe03a082 | 773 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 774 | * @{ |
mbed_official | 573:ad23fe03a082 | 775 | */ |
mbed_official | 573:ad23fe03a082 | 776 | |
mbed_official | 573:ad23fe03a082 | 777 | /** |
mbed_official | 573:ad23fe03a082 | 778 | * @brief Initializes the HASH peripheral in MD5 mode then processes pInBuffer. |
mbed_official | 573:ad23fe03a082 | 779 | * The digest is available in pOutBuffer. |
mbed_official | 573:ad23fe03a082 | 780 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 781 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 782 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 783 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 784 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 785 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 16 bytes. |
mbed_official | 573:ad23fe03a082 | 786 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 787 | */ |
mbed_official | 573:ad23fe03a082 | 788 | HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer) |
mbed_official | 573:ad23fe03a082 | 789 | { |
mbed_official | 573:ad23fe03a082 | 790 | uint32_t inputaddr; |
mbed_official | 573:ad23fe03a082 | 791 | uint32_t outputaddr; |
mbed_official | 573:ad23fe03a082 | 792 | uint32_t buffercounter; |
mbed_official | 573:ad23fe03a082 | 793 | uint32_t inputcounter; |
mbed_official | 573:ad23fe03a082 | 794 | |
mbed_official | 573:ad23fe03a082 | 795 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 796 | __HAL_LOCK(hhash); |
mbed_official | 610:813dcc80987e | 797 | |
mbed_official | 573:ad23fe03a082 | 798 | if(hhash->State == HAL_HASH_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 799 | { |
mbed_official | 573:ad23fe03a082 | 800 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 801 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 802 | |
mbed_official | 573:ad23fe03a082 | 803 | hhash->HashInCount = Size; |
mbed_official | 573:ad23fe03a082 | 804 | hhash->pHashInBuffPtr = pInBuffer; |
mbed_official | 573:ad23fe03a082 | 805 | hhash->pHashOutBuffPtr = pOutBuffer; |
mbed_official | 573:ad23fe03a082 | 806 | |
mbed_official | 573:ad23fe03a082 | 807 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 808 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 809 | { |
mbed_official | 573:ad23fe03a082 | 810 | /* Select the SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 811 | HASH->CR |= HASH_ALGOSELECTION_MD5; |
mbed_official | 573:ad23fe03a082 | 812 | /* Reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 813 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 814 | HASH->CR |= HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 815 | } |
mbed_official | 573:ad23fe03a082 | 816 | |
mbed_official | 610:813dcc80987e | 817 | /* Reset interrupt counter */ |
mbed_official | 610:813dcc80987e | 818 | hhash->HashITCounter = 0; |
mbed_official | 610:813dcc80987e | 819 | |
mbed_official | 573:ad23fe03a082 | 820 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 821 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 822 | |
mbed_official | 573:ad23fe03a082 | 823 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 824 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 825 | |
mbed_official | 573:ad23fe03a082 | 826 | /* Enable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 827 | HASH->IMR = (HASH_IT_DINI | HASH_IT_DCI); |
mbed_official | 573:ad23fe03a082 | 828 | |
mbed_official | 573:ad23fe03a082 | 829 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 830 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 831 | } |
mbed_official | 573:ad23fe03a082 | 832 | if(__HAL_HASH_GET_FLAG(HASH_FLAG_DCIS)) |
mbed_official | 573:ad23fe03a082 | 833 | { |
mbed_official | 573:ad23fe03a082 | 834 | outputaddr = (uint32_t)hhash->pHashOutBuffPtr; |
mbed_official | 573:ad23fe03a082 | 835 | /* Read the Output block from the Output FIFO */ |
mbed_official | 573:ad23fe03a082 | 836 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 837 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 838 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 839 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 840 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 841 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 842 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 843 | |
mbed_official | 573:ad23fe03a082 | 844 | if(hhash->HashInCount == 0) |
mbed_official | 573:ad23fe03a082 | 845 | { |
mbed_official | 573:ad23fe03a082 | 846 | /* Disable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 847 | HASH->IMR = 0; |
mbed_official | 573:ad23fe03a082 | 848 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 849 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 850 | /* Call digest computation complete callback */ |
mbed_official | 573:ad23fe03a082 | 851 | HAL_HASH_DgstCpltCallback(hhash); |
mbed_official | 610:813dcc80987e | 852 | |
mbed_official | 610:813dcc80987e | 853 | /* Process Unlocked */ |
mbed_official | 610:813dcc80987e | 854 | __HAL_UNLOCK(hhash); |
mbed_official | 610:813dcc80987e | 855 | |
mbed_official | 610:813dcc80987e | 856 | /* Return function status */ |
mbed_official | 610:813dcc80987e | 857 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 858 | } |
mbed_official | 573:ad23fe03a082 | 859 | } |
mbed_official | 610:813dcc80987e | 860 | |
mbed_official | 573:ad23fe03a082 | 861 | if(__HAL_HASH_GET_FLAG(HASH_FLAG_DINIS)) |
mbed_official | 573:ad23fe03a082 | 862 | { |
mbed_official | 610:813dcc80987e | 863 | if(hhash->HashInCount >= 68) |
mbed_official | 573:ad23fe03a082 | 864 | { |
mbed_official | 573:ad23fe03a082 | 865 | inputaddr = (uint32_t)hhash->pHashInBuffPtr; |
mbed_official | 573:ad23fe03a082 | 866 | /* Write the Input block in the Data IN register */ |
mbed_official | 573:ad23fe03a082 | 867 | for(buffercounter = 0; buffercounter < 64; buffercounter+=4) |
mbed_official | 573:ad23fe03a082 | 868 | { |
mbed_official | 573:ad23fe03a082 | 869 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 870 | inputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 871 | } |
mbed_official | 573:ad23fe03a082 | 872 | if(hhash->HashITCounter == 0) |
mbed_official | 573:ad23fe03a082 | 873 | { |
mbed_official | 573:ad23fe03a082 | 874 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 875 | |
mbed_official | 573:ad23fe03a082 | 876 | if(hhash->HashInCount >= 68) |
mbed_official | 573:ad23fe03a082 | 877 | { |
mbed_official | 573:ad23fe03a082 | 878 | /* Decrement buffer counter */ |
mbed_official | 573:ad23fe03a082 | 879 | hhash->HashInCount -= 68; |
mbed_official | 573:ad23fe03a082 | 880 | hhash->pHashInBuffPtr+= 68; |
mbed_official | 573:ad23fe03a082 | 881 | } |
mbed_official | 573:ad23fe03a082 | 882 | else |
mbed_official | 573:ad23fe03a082 | 883 | { |
mbed_official | 610:813dcc80987e | 884 | hhash->HashInCount = 0; |
mbed_official | 610:813dcc80987e | 885 | hhash->pHashInBuffPtr+= hhash->HashInCount; |
mbed_official | 573:ad23fe03a082 | 886 | } |
mbed_official | 610:813dcc80987e | 887 | /* Set Interrupt counter */ |
mbed_official | 610:813dcc80987e | 888 | hhash->HashITCounter = 1; |
mbed_official | 573:ad23fe03a082 | 889 | } |
mbed_official | 573:ad23fe03a082 | 890 | else |
mbed_official | 573:ad23fe03a082 | 891 | { |
mbed_official | 573:ad23fe03a082 | 892 | /* Decrement buffer counter */ |
mbed_official | 573:ad23fe03a082 | 893 | hhash->HashInCount -= 64; |
mbed_official | 573:ad23fe03a082 | 894 | hhash->pHashInBuffPtr+= 64; |
mbed_official | 573:ad23fe03a082 | 895 | } |
mbed_official | 573:ad23fe03a082 | 896 | } |
mbed_official | 573:ad23fe03a082 | 897 | else |
mbed_official | 573:ad23fe03a082 | 898 | { |
mbed_official | 573:ad23fe03a082 | 899 | /* Get the buffer address */ |
mbed_official | 573:ad23fe03a082 | 900 | inputaddr = (uint32_t)hhash->pHashInBuffPtr; |
mbed_official | 573:ad23fe03a082 | 901 | /* Get the buffer counter */ |
mbed_official | 573:ad23fe03a082 | 902 | inputcounter = hhash->HashInCount; |
mbed_official | 573:ad23fe03a082 | 903 | /* Disable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 904 | HASH->IMR &= ~(HASH_IT_DINI); |
mbed_official | 573:ad23fe03a082 | 905 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 906 | __HAL_HASH_SET_NBVALIDBITS(inputcounter); |
mbed_official | 573:ad23fe03a082 | 907 | |
mbed_official | 573:ad23fe03a082 | 908 | if((inputcounter > 4) && (inputcounter%4)) |
mbed_official | 573:ad23fe03a082 | 909 | { |
mbed_official | 573:ad23fe03a082 | 910 | inputcounter = (inputcounter+4-inputcounter%4); |
mbed_official | 573:ad23fe03a082 | 911 | } |
mbed_official | 610:813dcc80987e | 912 | else if ((inputcounter < 4) && (inputcounter != 0)) |
mbed_official | 610:813dcc80987e | 913 | { |
mbed_official | 610:813dcc80987e | 914 | inputcounter = 4; |
mbed_official | 610:813dcc80987e | 915 | } |
mbed_official | 573:ad23fe03a082 | 916 | |
mbed_official | 573:ad23fe03a082 | 917 | /* Write the Input block in the Data IN register */ |
mbed_official | 573:ad23fe03a082 | 918 | for(buffercounter = 0; buffercounter < inputcounter/4; buffercounter++) |
mbed_official | 573:ad23fe03a082 | 919 | { |
mbed_official | 573:ad23fe03a082 | 920 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 921 | inputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 922 | } |
mbed_official | 573:ad23fe03a082 | 923 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 924 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 925 | /* Reset buffer counter */ |
mbed_official | 573:ad23fe03a082 | 926 | hhash->HashInCount = 0; |
mbed_official | 610:813dcc80987e | 927 | /* Call Input data transfer complete callback */ |
mbed_official | 610:813dcc80987e | 928 | HAL_HASH_InCpltCallback(hhash); |
mbed_official | 573:ad23fe03a082 | 929 | } |
mbed_official | 573:ad23fe03a082 | 930 | } |
mbed_official | 573:ad23fe03a082 | 931 | |
mbed_official | 573:ad23fe03a082 | 932 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 933 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 934 | |
mbed_official | 573:ad23fe03a082 | 935 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 936 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 937 | } |
mbed_official | 573:ad23fe03a082 | 938 | |
mbed_official | 573:ad23fe03a082 | 939 | /** |
mbed_official | 573:ad23fe03a082 | 940 | * @brief Initializes the HASH peripheral in SHA1 mode then processes pInBuffer. |
mbed_official | 573:ad23fe03a082 | 941 | * The digest is available in pOutBuffer. |
mbed_official | 573:ad23fe03a082 | 942 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 943 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 944 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 945 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 946 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 947 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. |
mbed_official | 573:ad23fe03a082 | 948 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 949 | */ |
mbed_official | 573:ad23fe03a082 | 950 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer) |
mbed_official | 573:ad23fe03a082 | 951 | { |
mbed_official | 573:ad23fe03a082 | 952 | uint32_t inputaddr; |
mbed_official | 573:ad23fe03a082 | 953 | uint32_t outputaddr; |
mbed_official | 573:ad23fe03a082 | 954 | uint32_t buffercounter; |
mbed_official | 573:ad23fe03a082 | 955 | uint32_t inputcounter; |
mbed_official | 573:ad23fe03a082 | 956 | |
mbed_official | 573:ad23fe03a082 | 957 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 958 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 959 | |
mbed_official | 573:ad23fe03a082 | 960 | if(hhash->State == HAL_HASH_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 961 | { |
mbed_official | 573:ad23fe03a082 | 962 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 963 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 964 | |
mbed_official | 573:ad23fe03a082 | 965 | hhash->HashInCount = Size; |
mbed_official | 573:ad23fe03a082 | 966 | hhash->pHashInBuffPtr = pInBuffer; |
mbed_official | 573:ad23fe03a082 | 967 | hhash->pHashOutBuffPtr = pOutBuffer; |
mbed_official | 573:ad23fe03a082 | 968 | |
mbed_official | 573:ad23fe03a082 | 969 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 970 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 971 | { |
mbed_official | 573:ad23fe03a082 | 972 | /* Select the SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 973 | HASH->CR |= HASH_ALGOSELECTION_SHA1; |
mbed_official | 573:ad23fe03a082 | 974 | /* Reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 975 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 976 | HASH->CR |= HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 977 | } |
mbed_official | 573:ad23fe03a082 | 978 | |
mbed_official | 610:813dcc80987e | 979 | /* Reset interrupt counter */ |
mbed_official | 610:813dcc80987e | 980 | hhash->HashITCounter = 0; |
mbed_official | 610:813dcc80987e | 981 | |
mbed_official | 573:ad23fe03a082 | 982 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 983 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 984 | |
mbed_official | 573:ad23fe03a082 | 985 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 986 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 987 | |
mbed_official | 573:ad23fe03a082 | 988 | /* Enable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 989 | HASH->IMR = (HASH_IT_DINI | HASH_IT_DCI); |
mbed_official | 573:ad23fe03a082 | 990 | |
mbed_official | 573:ad23fe03a082 | 991 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 992 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 993 | } |
mbed_official | 573:ad23fe03a082 | 994 | if(__HAL_HASH_GET_FLAG(HASH_FLAG_DCIS)) |
mbed_official | 573:ad23fe03a082 | 995 | { |
mbed_official | 573:ad23fe03a082 | 996 | outputaddr = (uint32_t)hhash->pHashOutBuffPtr; |
mbed_official | 573:ad23fe03a082 | 997 | /* Read the Output block from the Output FIFO */ |
mbed_official | 573:ad23fe03a082 | 998 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[0]); |
mbed_official | 573:ad23fe03a082 | 999 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1000 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[1]); |
mbed_official | 573:ad23fe03a082 | 1001 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1002 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[2]); |
mbed_official | 573:ad23fe03a082 | 1003 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1004 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[3]); |
mbed_official | 573:ad23fe03a082 | 1005 | outputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1006 | *(uint32_t*)(outputaddr) = __REV(HASH->HR[4]); |
mbed_official | 573:ad23fe03a082 | 1007 | if(hhash->HashInCount == 0) |
mbed_official | 573:ad23fe03a082 | 1008 | { |
mbed_official | 573:ad23fe03a082 | 1009 | /* Disable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 1010 | HASH->IMR = 0; |
mbed_official | 573:ad23fe03a082 | 1011 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1012 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1013 | /* Call digest computation complete callback */ |
mbed_official | 573:ad23fe03a082 | 1014 | HAL_HASH_DgstCpltCallback(hhash); |
mbed_official | 610:813dcc80987e | 1015 | |
mbed_official | 610:813dcc80987e | 1016 | /* Process Unlocked */ |
mbed_official | 610:813dcc80987e | 1017 | __HAL_UNLOCK(hhash); |
mbed_official | 610:813dcc80987e | 1018 | |
mbed_official | 610:813dcc80987e | 1019 | /* Return function status */ |
mbed_official | 610:813dcc80987e | 1020 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1021 | } |
mbed_official | 573:ad23fe03a082 | 1022 | } |
mbed_official | 573:ad23fe03a082 | 1023 | if(__HAL_HASH_GET_FLAG(HASH_FLAG_DINIS)) |
mbed_official | 573:ad23fe03a082 | 1024 | { |
mbed_official | 610:813dcc80987e | 1025 | if(hhash->HashInCount >= 68) |
mbed_official | 573:ad23fe03a082 | 1026 | { |
mbed_official | 573:ad23fe03a082 | 1027 | inputaddr = (uint32_t)hhash->pHashInBuffPtr; |
mbed_official | 573:ad23fe03a082 | 1028 | /* Write the Input block in the Data IN register */ |
mbed_official | 573:ad23fe03a082 | 1029 | for(buffercounter = 0; buffercounter < 64; buffercounter+=4) |
mbed_official | 573:ad23fe03a082 | 1030 | { |
mbed_official | 573:ad23fe03a082 | 1031 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 1032 | inputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1033 | } |
mbed_official | 573:ad23fe03a082 | 1034 | if(hhash->HashITCounter == 0) |
mbed_official | 573:ad23fe03a082 | 1035 | { |
mbed_official | 573:ad23fe03a082 | 1036 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 1037 | |
mbed_official | 573:ad23fe03a082 | 1038 | if(hhash->HashInCount >= 68) |
mbed_official | 573:ad23fe03a082 | 1039 | { |
mbed_official | 573:ad23fe03a082 | 1040 | /* Decrement buffer counter */ |
mbed_official | 573:ad23fe03a082 | 1041 | hhash->HashInCount -= 68; |
mbed_official | 573:ad23fe03a082 | 1042 | hhash->pHashInBuffPtr+= 68; |
mbed_official | 573:ad23fe03a082 | 1043 | } |
mbed_official | 573:ad23fe03a082 | 1044 | else |
mbed_official | 573:ad23fe03a082 | 1045 | { |
mbed_official | 610:813dcc80987e | 1046 | hhash->HashInCount = 0; |
mbed_official | 610:813dcc80987e | 1047 | hhash->pHashInBuffPtr+= hhash->HashInCount; |
mbed_official | 573:ad23fe03a082 | 1048 | } |
mbed_official | 610:813dcc80987e | 1049 | /* Set Interrupt counter */ |
mbed_official | 610:813dcc80987e | 1050 | hhash->HashITCounter = 1; |
mbed_official | 573:ad23fe03a082 | 1051 | } |
mbed_official | 573:ad23fe03a082 | 1052 | else |
mbed_official | 573:ad23fe03a082 | 1053 | { |
mbed_official | 573:ad23fe03a082 | 1054 | /* Decrement buffer counter */ |
mbed_official | 573:ad23fe03a082 | 1055 | hhash->HashInCount -= 64; |
mbed_official | 573:ad23fe03a082 | 1056 | hhash->pHashInBuffPtr+= 64; |
mbed_official | 573:ad23fe03a082 | 1057 | } |
mbed_official | 573:ad23fe03a082 | 1058 | } |
mbed_official | 573:ad23fe03a082 | 1059 | else |
mbed_official | 573:ad23fe03a082 | 1060 | { |
mbed_official | 573:ad23fe03a082 | 1061 | /* Get the buffer address */ |
mbed_official | 573:ad23fe03a082 | 1062 | inputaddr = (uint32_t)hhash->pHashInBuffPtr; |
mbed_official | 573:ad23fe03a082 | 1063 | /* Get the buffer counter */ |
mbed_official | 573:ad23fe03a082 | 1064 | inputcounter = hhash->HashInCount; |
mbed_official | 573:ad23fe03a082 | 1065 | /* Disable Interrupts */ |
mbed_official | 573:ad23fe03a082 | 1066 | HASH->IMR &= ~(HASH_IT_DINI); |
mbed_official | 573:ad23fe03a082 | 1067 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1068 | __HAL_HASH_SET_NBVALIDBITS(inputcounter); |
mbed_official | 573:ad23fe03a082 | 1069 | |
mbed_official | 573:ad23fe03a082 | 1070 | if((inputcounter > 4) && (inputcounter%4)) |
mbed_official | 573:ad23fe03a082 | 1071 | { |
mbed_official | 573:ad23fe03a082 | 1072 | inputcounter = (inputcounter+4-inputcounter%4); |
mbed_official | 573:ad23fe03a082 | 1073 | } |
mbed_official | 610:813dcc80987e | 1074 | else if ((inputcounter < 4) && (inputcounter != 0)) |
mbed_official | 610:813dcc80987e | 1075 | { |
mbed_official | 610:813dcc80987e | 1076 | inputcounter = 4; |
mbed_official | 610:813dcc80987e | 1077 | } |
mbed_official | 573:ad23fe03a082 | 1078 | /* Write the Input block in the Data IN register */ |
mbed_official | 573:ad23fe03a082 | 1079 | for(buffercounter = 0; buffercounter < inputcounter/4; buffercounter++) |
mbed_official | 573:ad23fe03a082 | 1080 | { |
mbed_official | 573:ad23fe03a082 | 1081 | HASH->DIN = *(uint32_t*)inputaddr; |
mbed_official | 573:ad23fe03a082 | 1082 | inputaddr+=4; |
mbed_official | 573:ad23fe03a082 | 1083 | } |
mbed_official | 573:ad23fe03a082 | 1084 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1085 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1086 | /* Reset buffer counter */ |
mbed_official | 573:ad23fe03a082 | 1087 | hhash->HashInCount = 0; |
mbed_official | 610:813dcc80987e | 1088 | /* Call Input data transfer complete callback */ |
mbed_official | 610:813dcc80987e | 1089 | HAL_HASH_InCpltCallback(hhash); |
mbed_official | 573:ad23fe03a082 | 1090 | } |
mbed_official | 573:ad23fe03a082 | 1091 | } |
mbed_official | 573:ad23fe03a082 | 1092 | |
mbed_official | 573:ad23fe03a082 | 1093 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1094 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1095 | |
mbed_official | 573:ad23fe03a082 | 1096 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1097 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1098 | } |
mbed_official | 573:ad23fe03a082 | 1099 | |
mbed_official | 573:ad23fe03a082 | 1100 | /** |
mbed_official | 573:ad23fe03a082 | 1101 | * @brief This function handles HASH interrupt request. |
mbed_official | 573:ad23fe03a082 | 1102 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1103 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1104 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1105 | */ |
mbed_official | 573:ad23fe03a082 | 1106 | void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 1107 | { |
mbed_official | 573:ad23fe03a082 | 1108 | switch(HASH->CR & HASH_CR_ALGO) |
mbed_official | 573:ad23fe03a082 | 1109 | { |
mbed_official | 573:ad23fe03a082 | 1110 | case HASH_ALGOSELECTION_MD5: |
mbed_official | 573:ad23fe03a082 | 1111 | HAL_HASH_MD5_Start_IT(hhash, NULL, 0, NULL); |
mbed_official | 573:ad23fe03a082 | 1112 | break; |
mbed_official | 573:ad23fe03a082 | 1113 | |
mbed_official | 573:ad23fe03a082 | 1114 | case HASH_ALGOSELECTION_SHA1: |
mbed_official | 573:ad23fe03a082 | 1115 | HAL_HASH_SHA1_Start_IT(hhash, NULL, 0, NULL); |
mbed_official | 573:ad23fe03a082 | 1116 | break; |
mbed_official | 573:ad23fe03a082 | 1117 | |
mbed_official | 573:ad23fe03a082 | 1118 | default: |
mbed_official | 573:ad23fe03a082 | 1119 | break; |
mbed_official | 573:ad23fe03a082 | 1120 | } |
mbed_official | 573:ad23fe03a082 | 1121 | } |
mbed_official | 573:ad23fe03a082 | 1122 | |
mbed_official | 573:ad23fe03a082 | 1123 | /** |
mbed_official | 573:ad23fe03a082 | 1124 | * @} |
mbed_official | 573:ad23fe03a082 | 1125 | */ |
mbed_official | 573:ad23fe03a082 | 1126 | |
mbed_official | 573:ad23fe03a082 | 1127 | /** @defgroup HASH_Exported_Functions_Group4 HASH processing functions using DMA mode |
mbed_official | 573:ad23fe03a082 | 1128 | * @brief processing functions using DMA mode. |
mbed_official | 573:ad23fe03a082 | 1129 | * |
mbed_official | 573:ad23fe03a082 | 1130 | @verbatim |
mbed_official | 573:ad23fe03a082 | 1131 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1132 | ##### HASH processing using DMA mode functions ##### |
mbed_official | 573:ad23fe03a082 | 1133 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1134 | [..] This section provides functions allowing to calculate in DMA mode |
mbed_official | 573:ad23fe03a082 | 1135 | the hash value using one of the following algorithms: |
mbed_official | 573:ad23fe03a082 | 1136 | (+) MD5 |
mbed_official | 573:ad23fe03a082 | 1137 | (+) SHA1 |
mbed_official | 573:ad23fe03a082 | 1138 | |
mbed_official | 573:ad23fe03a082 | 1139 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 1140 | * @{ |
mbed_official | 573:ad23fe03a082 | 1141 | */ |
mbed_official | 573:ad23fe03a082 | 1142 | |
mbed_official | 573:ad23fe03a082 | 1143 | /** |
mbed_official | 573:ad23fe03a082 | 1144 | * @brief Initializes the HASH peripheral in MD5 mode then enables DMA to |
mbed_official | 573:ad23fe03a082 | 1145 | control data transfer. Use HAL_HASH_MD5_Finish() to get the digest. |
mbed_official | 573:ad23fe03a082 | 1146 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1147 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1148 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1149 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1150 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1151 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1152 | */ |
mbed_official | 573:ad23fe03a082 | 1153 | HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 1154 | { |
mbed_official | 573:ad23fe03a082 | 1155 | uint32_t inputaddr = (uint32_t)pInBuffer; |
mbed_official | 573:ad23fe03a082 | 1156 | |
mbed_official | 573:ad23fe03a082 | 1157 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1158 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1159 | |
mbed_official | 573:ad23fe03a082 | 1160 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1161 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1162 | |
mbed_official | 573:ad23fe03a082 | 1163 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1164 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1165 | { |
mbed_official | 573:ad23fe03a082 | 1166 | /* Select the MD5 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 1167 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 1168 | HASH->CR |= HASH_ALGOSELECTION_MD5 | HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 1169 | } |
mbed_official | 573:ad23fe03a082 | 1170 | |
mbed_official | 573:ad23fe03a082 | 1171 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1172 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 1173 | |
mbed_official | 573:ad23fe03a082 | 1174 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1175 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1176 | |
mbed_official | 573:ad23fe03a082 | 1177 | /* Set the HASH DMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 1178 | hhash->hdmain->XferCpltCallback = HASH_DMAXferCplt; |
mbed_official | 573:ad23fe03a082 | 1179 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 1180 | hhash->hdmain->XferErrorCallback = HASH_DMAError; |
mbed_official | 573:ad23fe03a082 | 1181 | |
mbed_official | 573:ad23fe03a082 | 1182 | /* Enable the DMA In DMA Stream */ |
mbed_official | 573:ad23fe03a082 | 1183 | HAL_DMA_Start_IT(hhash->hdmain, inputaddr, (uint32_t)&HASH->DIN, (Size%4 ? (Size+3)/4:Size/4)); |
mbed_official | 573:ad23fe03a082 | 1184 | |
mbed_official | 573:ad23fe03a082 | 1185 | /* Enable DMA requests */ |
mbed_official | 573:ad23fe03a082 | 1186 | HASH->CR |= (HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 1187 | |
mbed_official | 573:ad23fe03a082 | 1188 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1189 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1190 | |
mbed_official | 573:ad23fe03a082 | 1191 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1192 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1193 | } |
mbed_official | 573:ad23fe03a082 | 1194 | |
mbed_official | 573:ad23fe03a082 | 1195 | /** |
mbed_official | 573:ad23fe03a082 | 1196 | * @brief Returns the computed digest in MD5 mode |
mbed_official | 573:ad23fe03a082 | 1197 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1198 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1199 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 16 bytes. |
mbed_official | 573:ad23fe03a082 | 1200 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 1201 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1202 | */ |
mbed_official | 573:ad23fe03a082 | 1203 | HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 1204 | { |
mbed_official | 573:ad23fe03a082 | 1205 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 1206 | |
mbed_official | 573:ad23fe03a082 | 1207 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1208 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1209 | |
mbed_official | 573:ad23fe03a082 | 1210 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 1211 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1212 | |
mbed_official | 573:ad23fe03a082 | 1213 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1214 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1215 | |
mbed_official | 573:ad23fe03a082 | 1216 | while(HAL_IS_BIT_CLR(HASH->SR, HASH_FLAG_DCIS)) |
mbed_official | 573:ad23fe03a082 | 1217 | { |
mbed_official | 573:ad23fe03a082 | 1218 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1219 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1220 | { |
mbed_official | 573:ad23fe03a082 | 1221 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1222 | { |
mbed_official | 573:ad23fe03a082 | 1223 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1224 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1225 | |
mbed_official | 573:ad23fe03a082 | 1226 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1227 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1228 | |
mbed_official | 573:ad23fe03a082 | 1229 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1230 | } |
mbed_official | 573:ad23fe03a082 | 1231 | } |
mbed_official | 573:ad23fe03a082 | 1232 | } |
mbed_official | 573:ad23fe03a082 | 1233 | |
mbed_official | 573:ad23fe03a082 | 1234 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 1235 | HASH_GetDigest(pOutBuffer, 16); |
mbed_official | 573:ad23fe03a082 | 1236 | |
mbed_official | 573:ad23fe03a082 | 1237 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 1238 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1239 | |
mbed_official | 573:ad23fe03a082 | 1240 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1241 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1242 | |
mbed_official | 573:ad23fe03a082 | 1243 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1244 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1245 | } |
mbed_official | 573:ad23fe03a082 | 1246 | |
mbed_official | 573:ad23fe03a082 | 1247 | /** |
mbed_official | 573:ad23fe03a082 | 1248 | * @brief Initializes the HASH peripheral in SHA1 mode then enables DMA to |
mbed_official | 573:ad23fe03a082 | 1249 | control data transfer. Use HAL_HASH_SHA1_Finish() to get the digest. |
mbed_official | 573:ad23fe03a082 | 1250 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1251 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1252 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1253 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1254 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1255 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1256 | */ |
mbed_official | 573:ad23fe03a082 | 1257 | HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 1258 | { |
mbed_official | 573:ad23fe03a082 | 1259 | uint32_t inputaddr = (uint32_t)pInBuffer; |
mbed_official | 573:ad23fe03a082 | 1260 | |
mbed_official | 573:ad23fe03a082 | 1261 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1262 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1263 | |
mbed_official | 573:ad23fe03a082 | 1264 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1265 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1266 | |
mbed_official | 573:ad23fe03a082 | 1267 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1268 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1269 | { |
mbed_official | 573:ad23fe03a082 | 1270 | /* Select the SHA1 mode and reset the HASH processor core, so that the HASH will be ready to compute |
mbed_official | 573:ad23fe03a082 | 1271 | the message digest of a new message */ |
mbed_official | 573:ad23fe03a082 | 1272 | HASH->CR |= HASH_ALGOSELECTION_SHA1; |
mbed_official | 573:ad23fe03a082 | 1273 | HASH->CR |= HASH_CR_INIT; |
mbed_official | 573:ad23fe03a082 | 1274 | } |
mbed_official | 573:ad23fe03a082 | 1275 | |
mbed_official | 573:ad23fe03a082 | 1276 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1277 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 1278 | |
mbed_official | 573:ad23fe03a082 | 1279 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1280 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1281 | |
mbed_official | 573:ad23fe03a082 | 1282 | /* Set the HASH DMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 1283 | hhash->hdmain->XferCpltCallback = HASH_DMAXferCplt; |
mbed_official | 573:ad23fe03a082 | 1284 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 1285 | hhash->hdmain->XferErrorCallback = HASH_DMAError; |
mbed_official | 573:ad23fe03a082 | 1286 | |
mbed_official | 573:ad23fe03a082 | 1287 | /* Enable the DMA In DMA Stream */ |
mbed_official | 573:ad23fe03a082 | 1288 | HAL_DMA_Start_IT(hhash->hdmain, inputaddr, (uint32_t)&HASH->DIN, (Size%4 ? (Size+3)/4:Size/4)); |
mbed_official | 573:ad23fe03a082 | 1289 | |
mbed_official | 573:ad23fe03a082 | 1290 | /* Enable DMA requests */ |
mbed_official | 573:ad23fe03a082 | 1291 | HASH->CR |= (HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 1292 | |
mbed_official | 573:ad23fe03a082 | 1293 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1294 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1295 | |
mbed_official | 573:ad23fe03a082 | 1296 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1297 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1298 | } |
mbed_official | 573:ad23fe03a082 | 1299 | |
mbed_official | 573:ad23fe03a082 | 1300 | /** |
mbed_official | 573:ad23fe03a082 | 1301 | * @brief Returns the computed digest in SHA1 mode. |
mbed_official | 573:ad23fe03a082 | 1302 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1303 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1304 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. |
mbed_official | 573:ad23fe03a082 | 1305 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 1306 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1307 | */ |
mbed_official | 573:ad23fe03a082 | 1308 | HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 1309 | { |
mbed_official | 573:ad23fe03a082 | 1310 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 1311 | |
mbed_official | 573:ad23fe03a082 | 1312 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1313 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1314 | |
mbed_official | 573:ad23fe03a082 | 1315 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 1316 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1317 | |
mbed_official | 573:ad23fe03a082 | 1318 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1319 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1320 | while(HAL_IS_BIT_CLR(HASH->SR, HASH_FLAG_DCIS)) |
mbed_official | 573:ad23fe03a082 | 1321 | { |
mbed_official | 573:ad23fe03a082 | 1322 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1323 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1324 | { |
mbed_official | 573:ad23fe03a082 | 1325 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1326 | { |
mbed_official | 573:ad23fe03a082 | 1327 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1328 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1329 | |
mbed_official | 573:ad23fe03a082 | 1330 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1331 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1332 | |
mbed_official | 573:ad23fe03a082 | 1333 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1334 | } |
mbed_official | 573:ad23fe03a082 | 1335 | } |
mbed_official | 573:ad23fe03a082 | 1336 | } |
mbed_official | 573:ad23fe03a082 | 1337 | |
mbed_official | 573:ad23fe03a082 | 1338 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 1339 | HASH_GetDigest(pOutBuffer, 20); |
mbed_official | 573:ad23fe03a082 | 1340 | |
mbed_official | 573:ad23fe03a082 | 1341 | /* Change HASH peripheral state */ |
mbed_official | 573:ad23fe03a082 | 1342 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1343 | |
mbed_official | 573:ad23fe03a082 | 1344 | /* Process UnLock */ |
mbed_official | 573:ad23fe03a082 | 1345 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1346 | |
mbed_official | 573:ad23fe03a082 | 1347 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1348 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1349 | } |
mbed_official | 573:ad23fe03a082 | 1350 | |
mbed_official | 573:ad23fe03a082 | 1351 | |
mbed_official | 573:ad23fe03a082 | 1352 | /** |
mbed_official | 573:ad23fe03a082 | 1353 | * @} |
mbed_official | 573:ad23fe03a082 | 1354 | */ |
mbed_official | 573:ad23fe03a082 | 1355 | |
mbed_official | 573:ad23fe03a082 | 1356 | /** @defgroup HASH_Exported_Functions_Group5 HASH-MAC (HMAC) processing functions using polling mode |
mbed_official | 573:ad23fe03a082 | 1357 | * @brief HMAC processing functions using polling mode . |
mbed_official | 573:ad23fe03a082 | 1358 | * |
mbed_official | 573:ad23fe03a082 | 1359 | @verbatim |
mbed_official | 573:ad23fe03a082 | 1360 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1361 | ##### HMAC processing using polling mode functions ##### |
mbed_official | 573:ad23fe03a082 | 1362 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1363 | [..] This section provides functions allowing to calculate in polling mode |
mbed_official | 573:ad23fe03a082 | 1364 | the HMAC value using one of the following algorithms: |
mbed_official | 573:ad23fe03a082 | 1365 | (+) MD5 |
mbed_official | 573:ad23fe03a082 | 1366 | (+) SHA1 |
mbed_official | 573:ad23fe03a082 | 1367 | |
mbed_official | 573:ad23fe03a082 | 1368 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 1369 | * @{ |
mbed_official | 573:ad23fe03a082 | 1370 | */ |
mbed_official | 573:ad23fe03a082 | 1371 | |
mbed_official | 573:ad23fe03a082 | 1372 | /** |
mbed_official | 573:ad23fe03a082 | 1373 | * @brief Initializes the HASH peripheral in HMAC MD5 mode |
mbed_official | 573:ad23fe03a082 | 1374 | * then processes pInBuffer. The digest is available in pOutBuffer |
mbed_official | 573:ad23fe03a082 | 1375 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1376 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1377 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1378 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1379 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1380 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. |
mbed_official | 573:ad23fe03a082 | 1381 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 1382 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1383 | */ |
mbed_official | 573:ad23fe03a082 | 1384 | HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 1385 | { |
mbed_official | 573:ad23fe03a082 | 1386 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 1387 | |
mbed_official | 573:ad23fe03a082 | 1388 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1389 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1390 | |
mbed_official | 573:ad23fe03a082 | 1391 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1392 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1393 | |
mbed_official | 573:ad23fe03a082 | 1394 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1395 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1396 | { |
mbed_official | 573:ad23fe03a082 | 1397 | /* Check if key size is greater than 64 bytes */ |
mbed_official | 573:ad23fe03a082 | 1398 | if(hhash->Init.KeySize > 64) |
mbed_official | 573:ad23fe03a082 | 1399 | { |
mbed_official | 573:ad23fe03a082 | 1400 | /* Select the HMAC MD5 mode */ |
mbed_official | 573:ad23fe03a082 | 1401 | HASH->CR |= (HASH_ALGOSELECTION_MD5 | HASH_ALGOMODE_HMAC | HASH_HMAC_KEYTYPE_LONGKEY | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1402 | } |
mbed_official | 573:ad23fe03a082 | 1403 | else |
mbed_official | 573:ad23fe03a082 | 1404 | { |
mbed_official | 573:ad23fe03a082 | 1405 | /* Select the HMAC MD5 mode */ |
mbed_official | 573:ad23fe03a082 | 1406 | HASH->CR |= (HASH_ALGOSELECTION_MD5 | HASH_ALGOMODE_HMAC | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1407 | } |
mbed_official | 573:ad23fe03a082 | 1408 | } |
mbed_official | 573:ad23fe03a082 | 1409 | |
mbed_official | 573:ad23fe03a082 | 1410 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1411 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1412 | |
mbed_official | 573:ad23fe03a082 | 1413 | /************************** STEP 1 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1414 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1415 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1416 | |
mbed_official | 573:ad23fe03a082 | 1417 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1418 | HASH_WriteData(hhash->Init.pKey, hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1419 | |
mbed_official | 573:ad23fe03a082 | 1420 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1421 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1422 | |
mbed_official | 573:ad23fe03a082 | 1423 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1424 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1425 | |
mbed_official | 573:ad23fe03a082 | 1426 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1427 | { |
mbed_official | 573:ad23fe03a082 | 1428 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1429 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1430 | { |
mbed_official | 573:ad23fe03a082 | 1431 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1432 | { |
mbed_official | 573:ad23fe03a082 | 1433 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1434 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1435 | |
mbed_official | 573:ad23fe03a082 | 1436 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1437 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1438 | |
mbed_official | 573:ad23fe03a082 | 1439 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1440 | } |
mbed_official | 573:ad23fe03a082 | 1441 | } |
mbed_official | 573:ad23fe03a082 | 1442 | } |
mbed_official | 573:ad23fe03a082 | 1443 | /************************** STEP 2 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1444 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1445 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 1446 | |
mbed_official | 573:ad23fe03a082 | 1447 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1448 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 1449 | |
mbed_official | 573:ad23fe03a082 | 1450 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1451 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1452 | |
mbed_official | 573:ad23fe03a082 | 1453 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1454 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1455 | |
mbed_official | 573:ad23fe03a082 | 1456 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1457 | { |
mbed_official | 573:ad23fe03a082 | 1458 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1459 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1460 | { |
mbed_official | 573:ad23fe03a082 | 1461 | if((HAL_GetTick() - tickstart ) > Timeout) |
mbed_official | 573:ad23fe03a082 | 1462 | { |
mbed_official | 573:ad23fe03a082 | 1463 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1464 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1465 | |
mbed_official | 573:ad23fe03a082 | 1466 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1467 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1468 | |
mbed_official | 573:ad23fe03a082 | 1469 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1470 | } |
mbed_official | 573:ad23fe03a082 | 1471 | } |
mbed_official | 573:ad23fe03a082 | 1472 | } |
mbed_official | 573:ad23fe03a082 | 1473 | /************************** STEP 3 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1474 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1475 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1476 | |
mbed_official | 573:ad23fe03a082 | 1477 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1478 | HASH_WriteData(hhash->Init.pKey, hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1479 | |
mbed_official | 573:ad23fe03a082 | 1480 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1481 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1482 | |
mbed_official | 573:ad23fe03a082 | 1483 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1484 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1485 | |
mbed_official | 573:ad23fe03a082 | 1486 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1487 | { |
mbed_official | 573:ad23fe03a082 | 1488 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1489 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1490 | { |
mbed_official | 573:ad23fe03a082 | 1491 | if((HAL_GetTick() - tickstart ) > Timeout) |
mbed_official | 573:ad23fe03a082 | 1492 | { |
mbed_official | 573:ad23fe03a082 | 1493 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1494 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1495 | |
mbed_official | 573:ad23fe03a082 | 1496 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1497 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1498 | |
mbed_official | 573:ad23fe03a082 | 1499 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1500 | } |
mbed_official | 573:ad23fe03a082 | 1501 | } |
mbed_official | 573:ad23fe03a082 | 1502 | } |
mbed_official | 573:ad23fe03a082 | 1503 | |
mbed_official | 573:ad23fe03a082 | 1504 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 1505 | HASH_GetDigest(pOutBuffer, 16); |
mbed_official | 573:ad23fe03a082 | 1506 | |
mbed_official | 573:ad23fe03a082 | 1507 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1508 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1509 | |
mbed_official | 573:ad23fe03a082 | 1510 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1511 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1512 | |
mbed_official | 573:ad23fe03a082 | 1513 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1514 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1515 | } |
mbed_official | 573:ad23fe03a082 | 1516 | |
mbed_official | 573:ad23fe03a082 | 1517 | /** |
mbed_official | 573:ad23fe03a082 | 1518 | * @brief Initializes the HASH peripheral in HMAC SHA1 mode |
mbed_official | 573:ad23fe03a082 | 1519 | * then processes pInBuffer. The digest is available in pOutBuffer. |
mbed_official | 573:ad23fe03a082 | 1520 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1521 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1522 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1523 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1524 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1525 | * @param pOutBuffer: Pointer to the computed digest. Its size must be 20 bytes. |
mbed_official | 573:ad23fe03a082 | 1526 | * @param Timeout: Timeout value |
mbed_official | 573:ad23fe03a082 | 1527 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1528 | */ |
mbed_official | 573:ad23fe03a082 | 1529 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 1530 | { |
mbed_official | 573:ad23fe03a082 | 1531 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 1532 | |
mbed_official | 573:ad23fe03a082 | 1533 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1534 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1535 | |
mbed_official | 573:ad23fe03a082 | 1536 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1537 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1538 | |
mbed_official | 573:ad23fe03a082 | 1539 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1540 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1541 | { |
mbed_official | 573:ad23fe03a082 | 1542 | /* Check if key size is greater than 64 bytes */ |
mbed_official | 573:ad23fe03a082 | 1543 | if(hhash->Init.KeySize > 64) |
mbed_official | 573:ad23fe03a082 | 1544 | { |
mbed_official | 573:ad23fe03a082 | 1545 | /* Select the HMAC SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 1546 | HASH->CR |= (HASH_ALGOSELECTION_SHA1 | HASH_ALGOMODE_HMAC | HASH_HMAC_KEYTYPE_LONGKEY | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1547 | } |
mbed_official | 573:ad23fe03a082 | 1548 | else |
mbed_official | 573:ad23fe03a082 | 1549 | { |
mbed_official | 573:ad23fe03a082 | 1550 | /* Select the HMAC SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 1551 | HASH->CR |= (HASH_ALGOSELECTION_SHA1 | HASH_ALGOMODE_HMAC | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1552 | } |
mbed_official | 573:ad23fe03a082 | 1553 | } |
mbed_official | 573:ad23fe03a082 | 1554 | |
mbed_official | 573:ad23fe03a082 | 1555 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1556 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1557 | |
mbed_official | 573:ad23fe03a082 | 1558 | /************************** STEP 1 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1559 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1560 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1561 | |
mbed_official | 573:ad23fe03a082 | 1562 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1563 | HASH_WriteData(hhash->Init.pKey, hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1564 | |
mbed_official | 573:ad23fe03a082 | 1565 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1566 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1567 | |
mbed_official | 573:ad23fe03a082 | 1568 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1569 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1570 | |
mbed_official | 573:ad23fe03a082 | 1571 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1572 | { |
mbed_official | 573:ad23fe03a082 | 1573 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1574 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1575 | { |
mbed_official | 573:ad23fe03a082 | 1576 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1577 | { |
mbed_official | 573:ad23fe03a082 | 1578 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1579 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1580 | |
mbed_official | 573:ad23fe03a082 | 1581 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1582 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1583 | |
mbed_official | 573:ad23fe03a082 | 1584 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1585 | } |
mbed_official | 573:ad23fe03a082 | 1586 | } |
mbed_official | 573:ad23fe03a082 | 1587 | } |
mbed_official | 573:ad23fe03a082 | 1588 | /************************** STEP 2 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1589 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1590 | __HAL_HASH_SET_NBVALIDBITS(Size); |
mbed_official | 573:ad23fe03a082 | 1591 | |
mbed_official | 573:ad23fe03a082 | 1592 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1593 | HASH_WriteData(pInBuffer, Size); |
mbed_official | 573:ad23fe03a082 | 1594 | |
mbed_official | 573:ad23fe03a082 | 1595 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1596 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1597 | |
mbed_official | 573:ad23fe03a082 | 1598 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1599 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1600 | |
mbed_official | 573:ad23fe03a082 | 1601 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1602 | { |
mbed_official | 573:ad23fe03a082 | 1603 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1604 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1605 | { |
mbed_official | 573:ad23fe03a082 | 1606 | if((HAL_GetTick() - tickstart ) > Timeout) |
mbed_official | 573:ad23fe03a082 | 1607 | { |
mbed_official | 573:ad23fe03a082 | 1608 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1609 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1610 | |
mbed_official | 573:ad23fe03a082 | 1611 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1612 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1613 | |
mbed_official | 573:ad23fe03a082 | 1614 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1615 | } |
mbed_official | 573:ad23fe03a082 | 1616 | } |
mbed_official | 573:ad23fe03a082 | 1617 | } |
mbed_official | 573:ad23fe03a082 | 1618 | /************************** STEP 3 ******************************************/ |
mbed_official | 573:ad23fe03a082 | 1619 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1620 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1621 | |
mbed_official | 573:ad23fe03a082 | 1622 | /* Write input buffer in data register */ |
mbed_official | 573:ad23fe03a082 | 1623 | HASH_WriteData(hhash->Init.pKey, hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1624 | |
mbed_official | 573:ad23fe03a082 | 1625 | /* Start the digest calculation */ |
mbed_official | 573:ad23fe03a082 | 1626 | __HAL_HASH_START_DIGEST(); |
mbed_official | 573:ad23fe03a082 | 1627 | |
mbed_official | 573:ad23fe03a082 | 1628 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1629 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1630 | |
mbed_official | 573:ad23fe03a082 | 1631 | while(HAL_IS_BIT_SET(HASH->SR, HASH_FLAG_BUSY)) |
mbed_official | 573:ad23fe03a082 | 1632 | { |
mbed_official | 573:ad23fe03a082 | 1633 | /* Check for the Timeout */ |
mbed_official | 573:ad23fe03a082 | 1634 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1635 | { |
mbed_official | 573:ad23fe03a082 | 1636 | if((HAL_GetTick() - tickstart ) > Timeout) |
mbed_official | 573:ad23fe03a082 | 1637 | { |
mbed_official | 573:ad23fe03a082 | 1638 | /* Change state */ |
mbed_official | 573:ad23fe03a082 | 1639 | hhash->State = HAL_HASH_STATE_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1640 | |
mbed_official | 573:ad23fe03a082 | 1641 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1642 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1643 | |
mbed_official | 573:ad23fe03a082 | 1644 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1645 | } |
mbed_official | 573:ad23fe03a082 | 1646 | } |
mbed_official | 573:ad23fe03a082 | 1647 | } |
mbed_official | 573:ad23fe03a082 | 1648 | /* Read the message digest */ |
mbed_official | 573:ad23fe03a082 | 1649 | HASH_GetDigest(pOutBuffer, 20); |
mbed_official | 573:ad23fe03a082 | 1650 | |
mbed_official | 573:ad23fe03a082 | 1651 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1652 | hhash->State = HAL_HASH_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1653 | |
mbed_official | 573:ad23fe03a082 | 1654 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1655 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1656 | |
mbed_official | 573:ad23fe03a082 | 1657 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1658 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1659 | } |
mbed_official | 573:ad23fe03a082 | 1660 | |
mbed_official | 573:ad23fe03a082 | 1661 | /** |
mbed_official | 573:ad23fe03a082 | 1662 | * @} |
mbed_official | 573:ad23fe03a082 | 1663 | */ |
mbed_official | 573:ad23fe03a082 | 1664 | |
mbed_official | 573:ad23fe03a082 | 1665 | /** @defgroup HASH_Exported_Functions_Group6 HASH-MAC (HMAC) processing functions using DMA mode |
mbed_official | 573:ad23fe03a082 | 1666 | * @brief HMAC processing functions using DMA mode . |
mbed_official | 573:ad23fe03a082 | 1667 | * |
mbed_official | 573:ad23fe03a082 | 1668 | @verbatim |
mbed_official | 573:ad23fe03a082 | 1669 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1670 | ##### HMAC processing using DMA mode functions ##### |
mbed_official | 573:ad23fe03a082 | 1671 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1672 | [..] This section provides functions allowing to calculate in DMA mode |
mbed_official | 573:ad23fe03a082 | 1673 | the HMAC value using one of the following algorithms: |
mbed_official | 573:ad23fe03a082 | 1674 | (+) MD5 |
mbed_official | 573:ad23fe03a082 | 1675 | (+) SHA1 |
mbed_official | 573:ad23fe03a082 | 1676 | |
mbed_official | 573:ad23fe03a082 | 1677 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 1678 | * @{ |
mbed_official | 573:ad23fe03a082 | 1679 | */ |
mbed_official | 573:ad23fe03a082 | 1680 | |
mbed_official | 573:ad23fe03a082 | 1681 | /** |
mbed_official | 573:ad23fe03a082 | 1682 | * @brief Initializes the HASH peripheral in HMAC MD5 mode |
mbed_official | 573:ad23fe03a082 | 1683 | * then enables DMA to control data transfer. |
mbed_official | 573:ad23fe03a082 | 1684 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1685 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1686 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1687 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1688 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1689 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1690 | */ |
mbed_official | 573:ad23fe03a082 | 1691 | HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 1692 | { |
mbed_official | 573:ad23fe03a082 | 1693 | uint32_t inputaddr = 0; |
mbed_official | 573:ad23fe03a082 | 1694 | |
mbed_official | 573:ad23fe03a082 | 1695 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1696 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1697 | |
mbed_official | 573:ad23fe03a082 | 1698 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1699 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1700 | |
mbed_official | 573:ad23fe03a082 | 1701 | /* Save buffer pointer and size in handle */ |
mbed_official | 573:ad23fe03a082 | 1702 | hhash->pHashInBuffPtr = pInBuffer; |
mbed_official | 573:ad23fe03a082 | 1703 | hhash->HashBuffSize = Size; |
mbed_official | 573:ad23fe03a082 | 1704 | hhash->HashInCount = 0; |
mbed_official | 573:ad23fe03a082 | 1705 | |
mbed_official | 573:ad23fe03a082 | 1706 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1707 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1708 | { |
mbed_official | 573:ad23fe03a082 | 1709 | /* Check if key size is greater than 64 bytes */ |
mbed_official | 573:ad23fe03a082 | 1710 | if(hhash->Init.KeySize > 64) |
mbed_official | 573:ad23fe03a082 | 1711 | { |
mbed_official | 573:ad23fe03a082 | 1712 | /* Select the HMAC MD5 mode */ |
mbed_official | 573:ad23fe03a082 | 1713 | HASH->CR |= (HASH_ALGOSELECTION_MD5 | HASH_ALGOMODE_HMAC | HASH_HMAC_KEYTYPE_LONGKEY | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1714 | } |
mbed_official | 573:ad23fe03a082 | 1715 | else |
mbed_official | 573:ad23fe03a082 | 1716 | { |
mbed_official | 573:ad23fe03a082 | 1717 | /* Select the HMAC MD5 mode */ |
mbed_official | 573:ad23fe03a082 | 1718 | HASH->CR |= (HASH_ALGOSELECTION_MD5 | HASH_ALGOMODE_HMAC | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1719 | } |
mbed_official | 573:ad23fe03a082 | 1720 | } |
mbed_official | 573:ad23fe03a082 | 1721 | |
mbed_official | 573:ad23fe03a082 | 1722 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1723 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1724 | |
mbed_official | 573:ad23fe03a082 | 1725 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1726 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1727 | |
mbed_official | 573:ad23fe03a082 | 1728 | /* Get the key address */ |
mbed_official | 573:ad23fe03a082 | 1729 | inputaddr = (uint32_t)(hhash->Init.pKey); |
mbed_official | 573:ad23fe03a082 | 1730 | |
mbed_official | 573:ad23fe03a082 | 1731 | /* Set the HASH DMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 1732 | hhash->hdmain->XferCpltCallback = HASH_DMAXferCplt; |
mbed_official | 573:ad23fe03a082 | 1733 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 1734 | hhash->hdmain->XferErrorCallback = HASH_DMAError; |
mbed_official | 573:ad23fe03a082 | 1735 | |
mbed_official | 573:ad23fe03a082 | 1736 | /* Enable the DMA In DMA Stream */ |
mbed_official | 573:ad23fe03a082 | 1737 | HAL_DMA_Start_IT(hhash->hdmain, inputaddr, (uint32_t)&HASH->DIN, (hhash->Init.KeySize%4 ? (hhash->Init.KeySize+3)/4:hhash->Init.KeySize/4)); |
mbed_official | 573:ad23fe03a082 | 1738 | /* Enable DMA requests */ |
mbed_official | 573:ad23fe03a082 | 1739 | HASH->CR |= (HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 1740 | |
mbed_official | 573:ad23fe03a082 | 1741 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1742 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1743 | |
mbed_official | 573:ad23fe03a082 | 1744 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1745 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1746 | } |
mbed_official | 573:ad23fe03a082 | 1747 | |
mbed_official | 573:ad23fe03a082 | 1748 | /** |
mbed_official | 573:ad23fe03a082 | 1749 | * @brief Initializes the HASH peripheral in HMAC SHA1 mode |
mbed_official | 573:ad23fe03a082 | 1750 | * then enables DMA to control data transfer. |
mbed_official | 573:ad23fe03a082 | 1751 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1752 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1753 | * @param pInBuffer: Pointer to the input buffer (buffer to be hashed). |
mbed_official | 573:ad23fe03a082 | 1754 | * @param Size: Length of the input buffer in bytes. |
mbed_official | 573:ad23fe03a082 | 1755 | * If the Size is not multiple of 64 bytes, the padding is managed by hardware. |
mbed_official | 573:ad23fe03a082 | 1756 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1757 | */ |
mbed_official | 573:ad23fe03a082 | 1758 | HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size) |
mbed_official | 573:ad23fe03a082 | 1759 | { |
mbed_official | 573:ad23fe03a082 | 1760 | uint32_t inputaddr = 0; |
mbed_official | 573:ad23fe03a082 | 1761 | |
mbed_official | 573:ad23fe03a082 | 1762 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1763 | __HAL_LOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1764 | |
mbed_official | 573:ad23fe03a082 | 1765 | /* Change the HASH state */ |
mbed_official | 573:ad23fe03a082 | 1766 | hhash->State = HAL_HASH_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 1767 | |
mbed_official | 573:ad23fe03a082 | 1768 | /* Save buffer pointer and size in handle */ |
mbed_official | 573:ad23fe03a082 | 1769 | hhash->pHashInBuffPtr = pInBuffer; |
mbed_official | 573:ad23fe03a082 | 1770 | hhash->HashBuffSize = Size; |
mbed_official | 573:ad23fe03a082 | 1771 | hhash->HashInCount = 0; |
mbed_official | 573:ad23fe03a082 | 1772 | |
mbed_official | 573:ad23fe03a082 | 1773 | /* Check if initialization phase has already been performed */ |
mbed_official | 573:ad23fe03a082 | 1774 | if(hhash->Phase == HAL_HASH_PHASE_READY) |
mbed_official | 573:ad23fe03a082 | 1775 | { |
mbed_official | 573:ad23fe03a082 | 1776 | /* Check if key size is greater than 64 bytes */ |
mbed_official | 573:ad23fe03a082 | 1777 | if(hhash->Init.KeySize > 64) |
mbed_official | 573:ad23fe03a082 | 1778 | { |
mbed_official | 573:ad23fe03a082 | 1779 | /* Select the HMAC SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 1780 | HASH->CR |= (HASH_ALGOSELECTION_SHA1 | HASH_ALGOMODE_HMAC | HASH_HMAC_KEYTYPE_LONGKEY | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1781 | } |
mbed_official | 573:ad23fe03a082 | 1782 | else |
mbed_official | 573:ad23fe03a082 | 1783 | { |
mbed_official | 573:ad23fe03a082 | 1784 | /* Select the HMAC SHA1 mode */ |
mbed_official | 573:ad23fe03a082 | 1785 | HASH->CR |= (HASH_ALGOSELECTION_SHA1 | HASH_ALGOMODE_HMAC | HASH_CR_INIT); |
mbed_official | 573:ad23fe03a082 | 1786 | } |
mbed_official | 573:ad23fe03a082 | 1787 | } |
mbed_official | 573:ad23fe03a082 | 1788 | |
mbed_official | 573:ad23fe03a082 | 1789 | /* Set the phase */ |
mbed_official | 573:ad23fe03a082 | 1790 | hhash->Phase = HAL_HASH_PHASE_PROCESS; |
mbed_official | 573:ad23fe03a082 | 1791 | |
mbed_official | 573:ad23fe03a082 | 1792 | /* Configure the number of valid bits in last word of the message */ |
mbed_official | 573:ad23fe03a082 | 1793 | __HAL_HASH_SET_NBVALIDBITS(hhash->Init.KeySize); |
mbed_official | 573:ad23fe03a082 | 1794 | |
mbed_official | 573:ad23fe03a082 | 1795 | /* Get the key address */ |
mbed_official | 573:ad23fe03a082 | 1796 | inputaddr = (uint32_t)(hhash->Init.pKey); |
mbed_official | 573:ad23fe03a082 | 1797 | |
mbed_official | 573:ad23fe03a082 | 1798 | /* Set the HASH DMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 1799 | hhash->hdmain->XferCpltCallback = HASH_DMAXferCplt; |
mbed_official | 573:ad23fe03a082 | 1800 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 1801 | hhash->hdmain->XferErrorCallback = HASH_DMAError; |
mbed_official | 573:ad23fe03a082 | 1802 | |
mbed_official | 573:ad23fe03a082 | 1803 | /* Enable the DMA In DMA Stream */ |
mbed_official | 573:ad23fe03a082 | 1804 | HAL_DMA_Start_IT(hhash->hdmain, inputaddr, (uint32_t)&HASH->DIN, (hhash->Init.KeySize%4 ? (hhash->Init.KeySize+3)/4:hhash->Init.KeySize/4)); |
mbed_official | 573:ad23fe03a082 | 1805 | /* Enable DMA requests */ |
mbed_official | 573:ad23fe03a082 | 1806 | HASH->CR |= (HASH_CR_DMAE); |
mbed_official | 573:ad23fe03a082 | 1807 | |
mbed_official | 573:ad23fe03a082 | 1808 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1809 | __HAL_UNLOCK(hhash); |
mbed_official | 573:ad23fe03a082 | 1810 | |
mbed_official | 573:ad23fe03a082 | 1811 | /* Return function status */ |
mbed_official | 573:ad23fe03a082 | 1812 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1813 | } |
mbed_official | 573:ad23fe03a082 | 1814 | |
mbed_official | 573:ad23fe03a082 | 1815 | /** |
mbed_official | 573:ad23fe03a082 | 1816 | * @} |
mbed_official | 573:ad23fe03a082 | 1817 | */ |
mbed_official | 573:ad23fe03a082 | 1818 | |
mbed_official | 573:ad23fe03a082 | 1819 | /** @defgroup HASH_Exported_Functions_Group7 Peripheral State functions |
mbed_official | 573:ad23fe03a082 | 1820 | * @brief Peripheral State functions. |
mbed_official | 573:ad23fe03a082 | 1821 | * |
mbed_official | 573:ad23fe03a082 | 1822 | @verbatim |
mbed_official | 573:ad23fe03a082 | 1823 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1824 | ##### Peripheral State functions ##### |
mbed_official | 573:ad23fe03a082 | 1825 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1826 | [..] |
mbed_official | 573:ad23fe03a082 | 1827 | This subsection permits to get in run-time the status of the peripheral. |
mbed_official | 573:ad23fe03a082 | 1828 | |
mbed_official | 573:ad23fe03a082 | 1829 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 1830 | * @{ |
mbed_official | 573:ad23fe03a082 | 1831 | */ |
mbed_official | 573:ad23fe03a082 | 1832 | |
mbed_official | 573:ad23fe03a082 | 1833 | /** |
mbed_official | 573:ad23fe03a082 | 1834 | * @brief return the HASH state |
mbed_official | 573:ad23fe03a082 | 1835 | * @param hhash: pointer to a HASH_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1836 | * the configuration information for HASH module |
mbed_official | 573:ad23fe03a082 | 1837 | * @retval HAL state |
mbed_official | 573:ad23fe03a082 | 1838 | */ |
mbed_official | 573:ad23fe03a082 | 1839 | HAL_HASH_STATETypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash) |
mbed_official | 573:ad23fe03a082 | 1840 | { |
mbed_official | 573:ad23fe03a082 | 1841 | return hhash->State; |
mbed_official | 573:ad23fe03a082 | 1842 | } |
mbed_official | 573:ad23fe03a082 | 1843 | |
mbed_official | 573:ad23fe03a082 | 1844 | /** |
mbed_official | 573:ad23fe03a082 | 1845 | * @} |
mbed_official | 573:ad23fe03a082 | 1846 | */ |
mbed_official | 573:ad23fe03a082 | 1847 | |
mbed_official | 573:ad23fe03a082 | 1848 | /** |
mbed_official | 573:ad23fe03a082 | 1849 | * @} |
mbed_official | 573:ad23fe03a082 | 1850 | */ |
mbed_official | 573:ad23fe03a082 | 1851 | |
mbed_official | 573:ad23fe03a082 | 1852 | #endif /* HAL_HASH_MODULE_ENABLED */ |
mbed_official | 573:ad23fe03a082 | 1853 | |
mbed_official | 573:ad23fe03a082 | 1854 | /** |
mbed_official | 573:ad23fe03a082 | 1855 | * @} |
mbed_official | 573:ad23fe03a082 | 1856 | */ |
mbed_official | 573:ad23fe03a082 | 1857 | #endif /* STM32F756xx */ |
mbed_official | 573:ad23fe03a082 | 1858 | |
mbed_official | 573:ad23fe03a082 | 1859 | /** |
mbed_official | 573:ad23fe03a082 | 1860 | * @} |
mbed_official | 573:ad23fe03a082 | 1861 | */ |
mbed_official | 573:ad23fe03a082 | 1862 | |
mbed_official | 573:ad23fe03a082 | 1863 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |