I have got some problems trying to programm the HMAC_MD5 code.
I am working in C on a STM32F4 microprocessor.
Here is my (updated) code:
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_HASH, ENABLE); static uint8_t
static Challenge[16] = "ldopwhjtsnkiaq8f";
static uint8_t Key[16] = "abcdefghijklmnop";
static uint8_t* HMAC_Key;
static uint8_t* HMAC_Input;
static uint8_t HMAC_Response1[16];
static uint8_t HMAC_Response2[16];
int m = 0;
HMAC_Input = &Challenge[0];
HMAC_Key = &Key[0];
ErrorStatus Result = ERROR;
for(m=0;m<16;m++){
HMAC_Response1[m]=1;
HMAC_Response2[m]=2;
}
Result = HASH_MD5(HMAC_Input, 16, HMAC_Response1);
Result = HMAC_MD5(HMAC_Key, 16, HMAC_Input, 16, HMAC_Response2);
That is the official description of the HMAC_MD5 function (https://github.com/espruino/Espruino/blob/master/targetlibs/stm32f4/lib/stm32f4xx_hash_md5.c):
/**
* @brief Compute the HMAC MD5 digest.
* @param Key: pointer to the Key used for HMAC.
* @param Keylen: length of the Key used for HMAC.
* @param Input: pointer to the Input buffer to be treated.
* @param Ilen: length of the Input buffer
* @param Output: the returned digest
* @retval An ErrorStatus enumeration value:
* - SUCCESS: digest computation done
* - ERROR: digest computation failed
*/
ErrorStatus HMAC_MD5(uint8_t *Key, uint32_t Keylen, uint8_t *Input,
uint32_t Ilen, uint8_t Output[16])
The function returns the value "SUCCESS" but the digest "Output" is still empty (full of '\0').
I don't get any warning from the compiler (Attolic TrueStudio) and I cannot change the value of the Key or of the Challenge (Concatenation), because the server is already running with older systems.