Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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