Skip to main content
Visitor II
October 22, 2024
Question

Migrating STM32 Crypto Library from v3.1.5 to v4.2.1

  • October 22, 2024
  • 1 reply
  • 788 views

Hi, 

I am currently working on migrating a project from STM32 Crypto Library version 3.1.5 to version 4.2.1. I would greatly appreciate your assistance with the following queries:

  1. Compatibility Inquiry: Is version 4.2.1 compatible with version 3.1.5? Specifically, Device ‘A’ is operating on version 3.1.5, while Device ‘B’ is on version 4.2.0. Are there any known compatibility issues between these versions?

  2. Function Replacement Issue: After importing the v4.2.0 library, I encountered an error with the HKDF_SHA512() function call. I replaced this function as follows:

    In v3.1.5:

 

 

HKDF_SHA512(&StHkdfInput, Aru8HkdfOut, sizeof(Aru8HkdfOut));

 

 

 

In v4.2.0:

 

 

 if (cmox_initialize(NULL) != CMOX_INIT_SUCCESS) {
	#ifdef APP_DEBUG
		printf("cmox_initialize failed\n");
 #endif
 } 

if(HASH_SUCCESS == HMAC_SHA512_Init(&SHA512ctx_st))
 {
 if(HASH_SUCCESS == HMAC_SHA512_Append(&SHA512ctx_st, Aru8HkdfInput, sizeof(Aru8HkdfInput)))
 {
 if(HASH_SUCCESS == HMAC_SHA512_Finish(&SHA512ctx_st, Aru8HkdfOut, &Aru8HkdfOutSize))
 {
 //Create session key, initial vector and hamc key
 memcpy(m_Aru8AesKey , Aru8HkdfOut, AES_KEY_ARRAY_SIZE );
 memcpy(m_Aru8InitVect, Aru8HkdfOut + AES_KEY_ARRAY_SIZE, INIT_VECT_SIZE );
 memcpy(m_Aru8HmacKey, Aru8HkdfOut + AES_KEY_ARRAY_SIZE + INIT_VECT_SIZE, HMAC_KEY_SIZE );
 bReturnStatus = true;
 }
 }
 }

 

 

 

                       
        Could you please confirm if these changes are correct?
 
Additionally, after making the above changes, the digested message HMAC is failing with the following code:

 

 

 if (HAL_OK == HAL_HASH_Init(&HashHandle))
 {
 if (HAL_OK == HAL_HMAC_SHA1_Start(&HashHandle, (uint8_t *)pu8InputMessage, u32InputMessageLength, pu8MessageDigest, 0xFF))
 {
 bStatus = true;
 }
 } 

 

 

 

Your support in resolving these issues would be highly appreciated.

Thank you in advance for your assistance.

Regards.
   
 
 
 

1 reply

Douglas MILLER
ST Employee
October 24, 2024

This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.