Functions
stm32f4xx_hash.c File Reference

This file provides firmware functions to manage the following functionalities of the HASH / HMAC Processor (HASH) peripheral: More...

#include "stm32f4xx_hash.h"
#include "stm32f4xx_rcc.h"
Include dependency graph for stm32f4xx_hash.c:

Go to the source code of this file.

Functions

void HASH_AutoStartDigest (FunctionalState NewState)
 Enables or disables auto-start message padding and calculation of the final message digest at the end of DMA transfer. More...
 
void HASH_ClearFlag (uint32_t HASH_FLAG)
 Clears the HASH flags. More...
 
void HASH_ClearITPendingBit (uint32_t HASH_IT)
 Clears the HASH interrupt pending bit(s). More...
 
void HASH_DataIn (uint32_t Data)
 Writes data in the Data Input FIFO. More...
 
void HASH_DeInit (void)
 De-initializes the HASH peripheral registers to their default reset values. More...
 
void HASH_DMACmd (FunctionalState NewState)
 Enables or disables the HASH DMA interface. More...
 
void HASH_GetDigest (HASH_MsgDigest *HASH_MessageDigest)
 Provides the message digest result. More...
 
FlagStatus HASH_GetFlagStatus (uint32_t HASH_FLAG)
 Checks whether the specified HASH flag is set or not. More...
 
uint8_t HASH_GetInFIFOWordsNbr (void)
 Returns the number of words already pushed into the IN FIFO. More...
 
ITStatus HASH_GetITStatus (uint32_t HASH_IT)
 Checks whether the specified HASH interrupt has occurred or not. More...
 
void HASH_Init (HASH_InitTypeDef *HASH_InitStruct)
 Initializes the HASH peripheral according to the specified parameters in the HASH_InitStruct structure. More...
 
void HASH_ITConfig (uint32_t HASH_IT, FunctionalState NewState)
 Enables or disables the specified HASH interrupts. More...
 
void HASH_Reset (void)
 Resets the HASH processor core, so that the HASH will be ready to compute the message digest of a new message. More...
 
void HASH_RestoreContext (HASH_Context *HASH_ContextRestore)
 Restore the Hash peripheral Context. More...
 
void HASH_SaveContext (HASH_Context *HASH_ContextSave)
 Save the Hash peripheral Context. More...
 
void HASH_SetLastWordValidBitsNbr (uint16_t ValidNumber)
 Configure the Number of valid bits in last word of the message. More...
 
void HASH_StartDigest (void)
 Starts the message padding and calculation of the final message. More...
 
void HASH_StructInit (HASH_InitTypeDef *HASH_InitStruct)
 Fills each HASH_InitStruct member with its default value. More...
 

Detailed Description

This file provides firmware functions to manage the following functionalities of the HASH / HMAC Processor (HASH) peripheral:

Author
MCD Application Team
Version
V1.1.0
Date
11-January-2013
  • Initialization and Configuration functions
  • Message Digest generation functions
  • context swapping functions
  • DMA interface function
  • Interrupts and flags management
 ===================================================================      
                 ##### How to use this driver #####
 ===================================================================
            
 *** HASH operation : *** 
 ========================                 
 [..]
   (#) Enable the HASH controller clock using 
       RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE) function.
             
   (#) Initialise the HASH using HASH_Init() function. 
                 
   (#) Reset the HASH processor core, so that the HASH will be ready 
       to compute he message digest of a new message by using HASH_Reset() function.
  
   (#) Enable the HASH controller using the HASH_Cmd() function. 
                  
   (#) if using DMA for Data input transfer, Activate the DMA Request 
       using HASH_DMACmd() function 
                      
   (#) if DMA is not used for data transfer, use HASH_DataIn() function 
       to enter data to IN FIFO.
               
            
   (#) Configure the Number of valid bits in last word of the message 
       using HASH_SetLastWordValidBitsNbr() function.
               
   (#) if the message length is not an exact multiple of 512 bits, 
       then the function HASH_StartDigest() must be called to launch the computation
       of the final digest.     
               
   (#) Once computed, the digest can be read using HASH_GetDigest() function.         
                     
   (#) To control HASH events you can use one of the following wo methods:
       (++) Check on HASH flags using the HASH_GetFlagStatus() function.  
       (++) Use HASH interrupts through the function HASH_ITConfig() at 
            initialization phase and HASH_GetITStatus() function into 
            interrupt routines in hashing phase.
            After checking on a flag you should clear it using HASH_ClearFlag()
            function. And after checking on an interrupt event you should 
            clear it using HASH_ClearITPendingBit() function.     
                       
   (#) Save and restore hash processor context using 
       HASH_SaveContext() and HASH_RestoreContext() functions.     
                
  
              
 *** HMAC operation : *** 
 ========================
 [..] The HMAC algorithm is used for message authentication, by 
      irreversibly binding the message being processed to a key chosen 
      by the user. 
      For HMAC specifications, refer to "HMAC: keyed-hashing for message 
      authentication, H. Krawczyk, M. Bellare, R. Canetti, February 1997"
            
 [..] Basically, the HMAC algorithm consists of two nested hash operations:
      HMAC(message) = Hash[((key | pad) XOR 0x5C) | Hash(((key | pad) XOR 0x36) | message)]
      where:
      (+) "pad" is a sequence of zeroes needed to extend the key to the 
          length of the underlying hash function data block (that is 
          512 bits for both the SHA-1 and MD5 hash algorithms)
      (+) "|"   represents the concatenation operator 
            
           
 [..]To compute the HMAC, four different phases are required:                  
   (#) Initialise the HASH using HASH_Init() function to do HMAC 
       operation. 
                  
   (#) The key (to be used for the inner hash function) is then given to the core. 
       This operation follows the same mechanism as the one used to send the 
       message in the hash operation (that is, by HASH_DataIn() function and, 
       finally, HASH_StartDigest() function.
            
   (#) Once the last word has been entered and computation has started, 
       the hash processor elaborates the key. It is then ready to accept the message
       text using the same mechanism as the one used to send the message in the
       hash operation.
         
   (#) After the first hash round, the hash processor returns "ready" to indicate 
       that it is ready to receive the key to be used for the outer hash function 
       (normally, this key is the same as the one used for the inner hash function). 
       When the last word of the key is entered and computation starts, the HMAC 
       result is made available using HASH_GetDigest() function.
@attention

<h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
You may not use this file except in compliance with the License.
You may obtain a copy of the License at:

       http://www.st.com/software_license_agreement_liberty_v2

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Definition in file stm32f4xx_hash.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:27