Question
sha-1 problem with stm32 crypto lib
Posted on June 14, 2015 at 15:15
Hi,
I'm developing on the stm32f207 with the M3_CryptoFW_RngHW_2_0_6.libI would like to use the sha-1 from lib but from some reason I do not get the correct result.Here is my test...My input buffer is 8 bytes: 1,2,3,4,5,6,7,8============================================The result I receive (abySHA_result) from SHA-1 crypto lib is:AC A7 3F C9 71 45 CB BE 5C 41 4B 76 9E DF FD 50 6E EB 28 A9============================================The expected result is:DD 57 83 BC F1 E9 00 2B C0 0A D5 B8 3A 95 ED 6E 4E BB 4A D5============================================What am I missing???Thanks,AriHere is my code:=======================================SHA1ctx_stt SHA1ctx_st;uint8_t MyData[8] = {1,2,3,4,5,6,7,8};int DataLengthOut = 0;uint8_t abySHA_result[20];int Test_Hash(void){ int32_t status = HASH_SUCCESS; bool result; /* DeInitialize STM32 Cryptographic Library */ Crypto_DeInit(); /* Initialize context */ memset (&SHA1ctx_st, 0, sizeof(SHA1ctx_st)) ; /* Set the size of the desired hash digest */ /* Set flag field to default value */ SHA1ctx_st.mTagSize = 20; SHA1ctx_st.mFlags = E_HASH_DEFAULT; result = SHA1_Init(&SHA1ctx_st); if (result != HASH_SUCCESS) return false ; // Compute hash SHA1_Append(&SHA1ctx_st, MyData, 8); if (status != HASH_SUCCESS) return false; result = SHA1_Finish(&SHA1ctx_st, abySHA_result, &DataLengthOut); if (result != HASH_SUCCESS) return false ; return true;}