STM32F439xx HAL User Manual
Functions
stm32f4xx_hal_hash.c File Reference

HASH HAL module driver. This file provides firmware functions to manage the following functionalities of the HASH peripheral: + Initialization and de-initialization functions + HASH/HMAC Processing functions by algorithm using polling mode + HASH/HMAC functions by algorithm using interrupt mode + HASH/HMAC functions by algorithm using DMA mode + Peripheral State functions. More...

#include "stm32f4xx_hal.h"

Go to the source code of this file.

Functions

static void HASH_DMAXferCplt (DMA_HandleTypeDef *hdma)
 DMA HASH Input Data complete callback.
static void HASH_DMAError (DMA_HandleTypeDef *hdma)
 DMA HASH communication error callback.
static void HASH_GetDigest (uint8_t *pMsgDigest, uint8_t Size)
 Provides the message digest result.
static void HASH_WriteData (uint8_t *pInBuffer, uint32_t Size)
 Writes the input buffer in data register.
HAL_StatusTypeDef HAL_HASH_Init (HASH_HandleTypeDef *hhash)
 Initializes the HASH according to the specified parameters in the HASH_HandleTypeDef and creates the associated handle.
HAL_StatusTypeDef HAL_HASH_DeInit (HASH_HandleTypeDef *hhash)
 DeInitializes the HASH peripheral.
__weak void HAL_HASH_MspInit (HASH_HandleTypeDef *hhash)
 Initializes the HASH MSP.
__weak void HAL_HASH_MspDeInit (HASH_HandleTypeDef *hhash)
 DeInitializes HASH MSP.
__weak void HAL_HASH_InCpltCallback (HASH_HandleTypeDef *hhash)
 Input data transfer complete callback.
__weak void HAL_HASH_ErrorCallback (HASH_HandleTypeDef *hhash)
 Data transfer Error callback.
__weak void HAL_HASH_DgstCpltCallback (HASH_HandleTypeDef *hhash)
 Digest computation complete callback.
HAL_StatusTypeDef HAL_HASH_MD5_Start (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
 Initializes the HASH peripheral in MD5 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_MD5_Accumulate (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in MD5 mode then writes the pInBuffer.
HAL_StatusTypeDef HAL_HASH_SHA1_Start (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
 Initializes the HASH peripheral in SHA1 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in SHA1 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_MD5_Start_IT (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
 Initializes the HASH peripheral in MD5 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer)
 Initializes the HASH peripheral in SHA1 mode then processes pInBuffer.
void HAL_HASH_IRQHandler (HASH_HandleTypeDef *hhash)
 This function handles HASH interrupt request.
HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in MD5 mode then enables DMA to control data transfer.
HAL_StatusTypeDef HAL_HASH_MD5_Finish (HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout)
 Returns the computed digest in MD5 mode.
HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in SHA1 mode then enables DMA to control data transfer.
HAL_StatusTypeDef HAL_HASH_SHA1_Finish (HASH_HandleTypeDef *hhash, uint8_t *pOutBuffer, uint32_t Timeout)
 Returns the computed digest in SHA1 mode.
HAL_StatusTypeDef HAL_HMAC_MD5_Start (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
 Initializes the HASH peripheral in HMAC MD5 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HMAC_SHA1_Start (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t *pOutBuffer, uint32_t Timeout)
 Initializes the HASH peripheral in HMAC SHA1 mode then processes pInBuffer.
HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in HMAC MD5 mode then enables DMA to control data transfer.
HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA (HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size)
 Initializes the HASH peripheral in HMAC SHA1 mode then enables DMA to control data transfer.
HAL_HASH_StateTypeDef HAL_HASH_GetState (HASH_HandleTypeDef *hhash)
 return the HASH state

Detailed Description

HASH HAL module driver. This file provides firmware functions to manage the following functionalities of the HASH peripheral: + Initialization and de-initialization functions + HASH/HMAC Processing functions by algorithm using polling mode + HASH/HMAC functions by algorithm using interrupt mode + HASH/HMAC functions by algorithm using DMA mode + Peripheral State functions.

Author:
MCD Application Team
  ==============================================================================
                     ##### How to use this driver #####
  ==============================================================================
    [..]
    The HASH HAL driver can be used as follows:
    (#)Initialize the HASH low level resources by implementing the HAL_HASH_MspInit():
        (##) Enable the HASH interface clock using __HAL_RCC_HASH_CLK_ENABLE()
        (##) In case of using processing APIs based on interrupts (e.g. HAL_HMAC_SHA1_Start_IT())
            (+++) Configure the HASH interrupt priority using HAL_NVIC_SetPriority()
            (+++) Enable the HASH IRQ handler using HAL_NVIC_EnableIRQ()
            (+++) In HASH IRQ handler, call HAL_HASH_IRQHandler()
        (##) In case of using DMA to control data transfer (e.g. HAL_HMAC_SHA1_Start_DMA())
            (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE()
            (+++) Configure and enable one DMA stream one for managing data transfer from
                memory to peripheral (input stream). Managing data transfer from
                peripheral to memory can be performed only using CPU
            (+++) Associate the initialized DMA handle to the HASH DMA handle
                using  __HAL_LINKDMA()
            (+++) Configure the priority and enable the NVIC for the transfer complete
                interrupt on the DMA Stream using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ()
    (#)Initialize the HASH HAL using HAL_HASH_Init(). This function configures mainly:
        (##) The data type: 1-bit, 8-bit, 16-bit and 32-bit.
        (##) For HMAC, the encryption key.
        (##) For HMAC, the key size used for encryption.
    (#)Three processing functions are available:
        (##) Polling mode: processing APIs are blocking functions
             i.e. they process the data and wait till the digest computation is finished
             e.g. HAL_HASH_SHA1_Start()
        (##) Interrupt mode: encryption and decryption APIs are not blocking functions
                i.e. they process the data under interrupt
                e.g. HAL_HASH_SHA1_Start_IT()
        (##) DMA mode: processing APIs are not blocking functions and the CPU is
             not used for data transfer i.e. the data transfer is ensured by DMA
                e.g. HAL_HASH_SHA1_Start_DMA()
    (#)When the processing function is called at first time after HAL_HASH_Init()
       the HASH peripheral is initialized and processes the buffer in input.
       After that, the digest computation is started.
       When processing multi-buffer use the accumulate function to write the
       data in the peripheral without starting the digest computation. In last 
       buffer use the start function to input the last buffer ans start the digest
       computation.
       (##) e.g. HAL_HASH_SHA1_Accumulate() : write 1st data buffer in the peripheral without starting the digest computation
       (##) write (n-1)th data buffer in the peripheral without starting the digest computation
       (##) HAL_HASH_SHA1_Start() : write (n)th data buffer in the peripheral and start the digest computation
    (#)In HMAC mode, there is no Accumulate API. Only Start API is available.
    (#)In case of using DMA, call the DMA start processing e.g. HAL_HASH_SHA1_Start_DMA().
       After that, call the finish function in order to get the digest value
       e.g. HAL_HASH_SHA1_Finish()
    (#)Call HAL_HASH_DeInit() to deinitialize the HASH peripheral.

  
Attention:

© COPYRIGHT(c) 2017 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file stm32f4xx_hal_hash.c.