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

How to use HASH?

Hi. I'm using nRF52832, SDK13.0.0.

I want tuse SHA256 abd MD5.

Could you let me know which function is for SHA256 and MD5?

Actually I've tried my code as below.

 uint8_t p_init_cmd[32];
 uint32_t init_cmd_len = 32;

 for(int i=0;i<32;i++) p_init_cmd[i]=(i%10);

 SEGGER_RTT_printf_log_Hex(0, RTT_CTRL_TEXT_CYAN"p_init_cmd     : ", p_init_cmd, 32);

 err_code = nrf_crypto_hash_compute(hash_info_sha256, p_init_cmd, init_cmd_len, &init_packet_hash);

 SEGGER_RTT_printf_log(0, "hash_info_sha256, err_code=0x%x\n", err_code);
 SEGGER_RTT_printf_log_Hex(0, "init_packet_hash     : ", init_packet_hash.p_value, 32);
 
 err_code = nrf_crypto_hash_compute(hash_info_MD5, p_init_cmd, init_cmd_len, &init_packet_md5);

 SEGGER_RTT_printf_log(0, "hash_info_MD5, err_code=0x%x\n", err_code);
 SEGGER_RTT_printf_log_Hex(0, "init_packet_hash     : ", init_packet_md5.p_value, 16);

But it doesn't work.

I need your help.

Parents
  • And init is below.

    NRF_CRYPTO_HASH_CREATE(init_packet_hash, SHA256);
    NRF_CRYPTO_HASH_CREATE(init_packet_md5, MD5);

    const nrf_crypto_hash_info_t hash_info_sha256 =
    {
        .hash_type = NRF_CRYPTO_HASH_TYPE_SHA256,
        .endian_type = NRF_CRYPTO_ENDIAN_LE
    };

    const nrf_crypto_hash_info_t hash_info_MD5 =
    {
        .hash_type = NRF_CRYPTO_HASH_TYPE_MD5,
        .endian_type = NRF_CRYPTO_ENDIAN_LE
    };

Reply
  • And init is below.

    NRF_CRYPTO_HASH_CREATE(init_packet_hash, SHA256);
    NRF_CRYPTO_HASH_CREATE(init_packet_md5, MD5);

    const nrf_crypto_hash_info_t hash_info_sha256 =
    {
        .hash_type = NRF_CRYPTO_HASH_TYPE_SHA256,
        .endian_type = NRF_CRYPTO_ENDIAN_LE
    };

    const nrf_crypto_hash_info_t hash_info_MD5 =
    {
        .hash_type = NRF_CRYPTO_HASH_TYPE_MD5,
        .endian_type = NRF_CRYPTO_ENDIAN_LE
    };

Children
No Data
Related