SHA512_HMAC
#1
Good day !

I am attempting to write a module where I derive a key from 2048 SHA512_HMAC iterations, however I cannot seem to get the hash correct after the initial hash.

This is what I am trying
Code:
  sha512_hmac_ctx_t ctx0;   sha512_hmac_init_swap(&ctx0, &pw, pwl);   sha512_hmac_update_swap(&ctx0, &salt, 12);   sha512_hmac_final(&ctx0);   print_u64_array_hex(&ctx0.opad.h, 8);     memcpy(&seed, &ctx0.opad.h, 64);   //xor_seed_with_round(&seed, &ctx0.opad.h);     u64 U[16] = {0};   memcpy(&U, &ctx0.opad.h, 64);   for(int x=1;x<2048;x++){     sha512_hmac_ctx_t ctx;     sha512_hmac_init_swap(&ctx, &pw, pwl);     sha512_hmac_update_swap(&ctx, U, 64);     sha512_hmac_final(&ctx);     if (x == 1) { print_u64_array_hex(&ctx.opad.h, 8); }     memcpy(&U, &ctx.opad.h, 64);     xor_seed_with_round(&seed, &U);   }


As I mentioned, the initial hash at ctx0 is correct, however just after one iteration in the loop, the hash is wrong. I know the hash is wrong because I have a working implementation in Golang.

The same issue I have with normal sha512 as well, where I can get the first hash as expected, but then it just works unexpectedly.

Would appreciate any help
Thanks !
Reply


Messages In This Thread
SHA512_HMAC - by ruro - 12-05-2020, 07:40 PM
RE: SHA512_HMAC - by ruro - 12-06-2020, 02:45 PM