How to use sha256_update if buf is larger than 64 bytes? - Printable Version +- hashcat Forum (https://hashcat.net/forum) +-- Forum: Developer (https://hashcat.net/forum/forum-39.html) +--- Forum: hashcat (https://hashcat.net/forum/forum-40.html) +--- Thread: How to use sha256_update if buf is larger than 64 bytes? (/thread-12069.html) |
How to use sha256_update if buf is larger than 64 bytes? - otto3405 - 07-16-2024 I'm trying to change the logic of one of the modules, adding sha256 instead of other hashing. The problem is that the data for the hash exceeds the buffer limit of 64 bytes. I think there should be approximately such logic: Code: sha256_ctx_t ctx; I expect the correct result sha256(k, ct), but the result is wrong. RE: How to use sha256_update if buf is larger than 64 bytes? - penguinkeeper - 07-16-2024 Firstly, you need to scale that size based on the amount of bytes so if your "ct" value is 71 bytes long, the length value would be 71-64 = 5 Secondly, you can't reuse the buffer like that, you have to start from the beginning again and you may have to 0-out the rest of the buffer that you're not using for safety, so instead of "st[16] = ct[11]", you'd do "st[0] = ct[11]" and likely have to do: st[6-15] = 0 or you can just have a new array called "st2" or whatever if you want Unrelated but you should use "%08x" in your printf so that 0s get padded correctly RE: How to use sha256_update if buf is larger than 64 bytes? - otto3405 - 07-17-2024 Thanks! I made a new (second) array and it worked |