This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

about HMAC SHA1

Hello,

I'm porting from ST32L151 to NRF52840.

I want to use the HMAC SHA1 method, but I can't see the related function.

The nrf_crypto_hmac_init function seems to be able to use SHA256 and SHA512, but SHA1 cannot be used.

But there is a mbedtls_sha1_init function, And I think this is different from HMAC.

Can you tell me the difference between HMAC and mbedtls?

Can't use HMAC SHA1 method in NRF52840?

Please let me know if there is a way.

Parents
  • Hi,

    HMAC is a message authentication algoritm based on hash function, it's not the same as SHA1/SHA256. You can find many open-source implementations of hmac-sha1, for example here.

    Keep in mind that SHA1 is an old and weak hash algorithm - if you don't have serious reasons to keep it for compatibility, it's better to switch to SHA256/SHA512.

  • I want to use hmac-sha1 even if the security is weak.

    But the examples you gave or the ones I found on Google are not what I want.

    The function used in ST is as follows.

    int32_t HMAC_SHA1_Init(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx);
    int32_t HMAC_SHA1_Append(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx, const uint8_t *P_pInputBuffer, int32_t P_inputSize);
    int32_t HMAC_SHA1_Finish(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx, uint8_t *P_pOutputBuffer, int32_t *P_pOutputSize);

    Isn't there a way to use Nordic with a function that does the same thing?

Reply
  • I want to use hmac-sha1 even if the security is weak.

    But the examples you gave or the ones I found on Google are not what I want.

    The function used in ST is as follows.

    int32_t HMAC_SHA1_Init(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx);
    int32_t HMAC_SHA1_Append(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx, const uint8_t *P_pInputBuffer, int32_t P_inputSize);
    int32_t HMAC_SHA1_Finish(HMAC_SHA1ctx_stt *P_pHMAC_SHA1ctx, uint8_t *P_pOutputBuffer, int32_t *P_pOutputSize);

    Isn't there a way to use Nordic with a function that does the same thing?

Children
Related