View Single Post
Old 08-19-2019, 07:46
chants chants is offline
Join Date: Jul 2016
Posts: 476
Rept. Given: 2
Rept. Rcvd 33 Times in 19 Posts
Thanks Given: 404
Thanks Rcvd at 751 Times in 345 Posts
chants Reputation: 33
First off the relevant file for this change (assuming you are using the 1450 variant which it sure sounds like you are) - size independent files:
This chain led me to:
typedef struct pw
  u32 i[64];
  u32 pw_len;
} pw_t;
So sizeof(u32)*64 = 256...change to sizeof(u32)*2048=8192. I am assuming you made exactly this change and recompiled e.g. u32 i[2048];

I don't know why it would crash - perhaps you can use a debugger and give the source code line upon which it crashes. I am assuming you are using OpenCL and not GPU though I would have imagined they would share definitional source.

It does call sha256_hmac_init_swap which has special handling above 64 size - the truncation to 8 bytes looks strange and maybe this is untested given the buffer limitation? It in turn calls sha256_update_swap which looks like it handles any size. Based on the spec:
it would seem this is correct behavior as 256 bit output is 32 bytes.

It would be nice to make a PR for this but because of the optimization sensitive nature of this project, more thinking about exactly how to do that is needed - maintain optimization while allowing the buffer size to change without annoying recompilations.

Oh and finally this is likely the issue - code needs to be generalized in:
First change:
  token.len_min[1] = SALT_MIN;
  token.len_max[1] = SALT_MAX;
Next change:
  digest[0] = hex_to_u32 (hash_pos +  0);
  digest[1] = hex_to_u32 (hash_pos +  8);
  digest[2] = hex_to_u32 (hash_pos + 16);
  digest[3] = hex_to_u32 (hash_pos + 24);
  digest[4] = hex_to_u32 (hash_pos + 32);
  digest[5] = hex_to_u32 (hash_pos + 40);
  digest[6] = hex_to_u32 (hash_pos + 48);
  digest[7] = hex_to_u32 (hash_pos + 56);
  digest[0] = byte_swap_32 (digest[0]);
  digest[1] = byte_swap_32 (digest[1]);
  digest[2] = byte_swap_32 (digest[2]);
  digest[3] = byte_swap_32 (digest[3]);
  digest[4] = byte_swap_32 (digest[4]);
  digest[5] = byte_swap_32 (digest[5]);
  digest[6] = byte_swap_32 (digest[6]);
  digest[7] = byte_swap_32 (digest[7]);

Last edited by chants; 08-19-2019 at 08:13.
Reply With Quote