Esempio n. 1
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */
                
  /* USART configuration */
  USART_Config();
  /* Enable HASH clock */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE);
     
  /* Display the original message */
  Display_MainMessage();
/*=============================================================================
  HMAC SHA-1 Digest Computation
==============================================================================*/

  /* HMAC SHA-1 Digest Computation */
  HMAC_SHA1((uint8_t*)Key, KEY_TAB_SIZE,
            (uint8_t*)Input, INPUT_TAB_SIZE,
            Sha1output);


  /* Display the HMAC SHA1 digest */
  Display_SHA1Digest();

/*=============================================================================
  HMAC MD5 Digest Computation
==============================================================================*/

  /* HMAC MD5 Digest Computation */
  HMAC_MD5((uint8_t*)Key, KEY_TAB_SIZE, 
           (uint8_t*)Input, INPUT_TAB_SIZE,
           Md5output); 

  /* Display the HMAC MD5 digest */
  Display_MD5Digest();

  while(1);  
}
Esempio n. 2
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* USART configuration */
  USART_Config();

  /* Display the original message */
  Display_MainMessage(INPUT_TAB_SIZE);

  /* Enable HASH clock */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE);


/*=============================================================================
   SHA-1 Digest Computation
==============================================================================*/

  /* SHA-1 Digest Computation */
  HASH_SHA1((uint8_t *)Input, INPUT_TAB_SIZE, Sha1output);

  /* Display the  SHA1 digest */
  Display_SHA1Digest();

/*=============================================================================
   MD5 Digest Computation
==============================================================================*/

  /*  MD5 Digest Computation */
  HASH_MD5((uint8_t *)Input, INPUT_TAB_SIZE, Md5output); 

  /* Display the  MD5 digest */
  Display_MD5Digest();

  while(1);
}
Esempio n. 3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* USART configuration */
  USART_Config();

  /* Enable HASH and DMA clocks */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE);
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);

  /* Display the original message */
  Display_MainMessage();

/*=============================================================================
  SHA-1 Digest Computation
==============================================================================*/
  /* HASH SHA-1 Digest computation (using DMA for data transfer) */
  HASH_SHA1_DMA();

  /* Display the SHA1 digest */
  Display_SHA1Digest();

/*=============================================================================
  MD5 Digest Computation
==============================================================================*/
  /* HASH MD5 Digest computation (using DMA for data transfer) */
  HASH_MD5_DMA();

  /*  Display the MD5 digest */
  Display_MD5Digest();

  while(1);
}
Esempio n. 4
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */

  /* TIM6 configuration to get a regular interrupt */
  TIM6_Config();

  /* USART configuration */
  USART_Config();

  /* Display the original message */
  Display_MainMessage();

  /* Enable HASH clock */
  RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE);

/*=============================================================================
  SHA1/ MD5 Digest Computation without context swap
==============================================================================*/
  printf("\n\r>> MD5 Digest Computation without context swap \n\r");
  printf(">>> Start \n\r");

  /* MD5 Digest Computation *******************************/
  HASH_MD5((uint8_t*)Md5Input, MD5_INPUT_TAB_SIZE,Md5output); 
  printf(">>> Done \n\r");

  /* Display the MD5 digest */
  Display_MD5Digest();

  printf("\n\r>> SHA1 Digest Computation without context swap \n\r");
  printf(">>> Start \n\r");

  /* SHA1 Digest Computation */
  HASH_SHA1((uint8_t*)Sha1Input, SHA1_INPUT_TAB_SIZE, Sha1output); 
  printf(">>> Done \n\r");

  /* Display the SHA1 digest */
  Display_SHA1Digest();

/*=============================================================================
   SHA1 / MD5 Digest Computation with context swap
==============================================================================*/
  printf("\n\r>> MD5 Digest Computation with context swap \n\r");
  printf(">>> Start \n\r");

  /* Enable TIM6 */
  TIM_Cmd(TIM6, ENABLE);

  /* MD5 Digest Computation */
  HASH_MD5((uint8_t*)Md5Input, MD5_INPUT_TAB_SIZE, Md5output); 

  /* Disable TIM2 : no more interrupts */
  TIM_Cmd(TIM6, DISABLE);

  printf(" ====> During MD5 digest calculation, the context is saved and restored (%d) times to calculate the SHA1 digest \n\r", ContextSwapCounter);
  printf(">>> Done \n\r");

  /* Display the MD5 digest */
  Display_MD5Digest();

  printf(">> SHA1 Digest computed during MD5 context swap \n\r");

  /* Display the SHA1 digest */
  Display_SHA1Digest();

  while(1);  
}