AnsweredAssumed Answered

MCF5235 MDHA SHA1 problem

Question asked by Chang Liu on Sep 20, 2017

I am using the MDHA of  MCF5235 to calculate the  SHA1.

The test code is :

void sha1_test()

{

   uint8 buf[]="abcdefghijklmnopqrstuvwxyz";
   uint32 results[5]={0};
   int i;

   MCF_MDHA_MDCMR = MCF_MDHA_MDCMR_SWR;// software reset
   while(0 != (MCF_MDHA_MDCMR & MCF_MDHA_MDCMR_SWR)) // self clearing
   {}
   MCF_MDHA_MDCR = 0u;//disable all interrupt
   MCF_MDHA_MDMR = 0
                                       | MCF_MDHA_MDMR_PDATA
                                       | MCF_MDHA_MDMR_INIT;//enable initialization
   for(i=0;i<26;i=i+4)
   {
      MCF_MDHA_MDIN = *(uint32 *)buf[i];
   }
   MCF_MDHA_MDIN = *(uint32 *)buf[i];

   MCF_MDHA_MDDSR = 26;
   MCF_MDHA_MDCMR = MCF_MDHA_MDCMR_GO;// command = GO

   delay(10);//delay 10 us

   results[0] = MCF_MDHA_MDA0;
   results[1] = MCF_MDHA_MDB0;
   results[2] = MCF_MDHA_MDC0;
   results[3] = MCF_MDHA_MDD0;
   results[4] = MCF_MDHA_MDE0;

}

The test result is : 0xC700DFB3, 0x14957954,0x9087EE75, 0xED04935D,0x30B541E9

It is different from the SHA1 tools from the web, for example https://www.cnfree.org/tools/hash.php 

The test result is 0x32d10c7b,0x8cf96570,0xca04ce37,0xf2a19d84,0x240d3a89.

 

I had known both the results are correct. But why they are so different? 

Original Attachment has been moved to: sha1_26.txt.zip

Outcomes