How to use sha256_update if buf is larger than 64 bytes?
#2
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
Reply


Messages In This Thread
RE: How to use sha256_update if buf is larger than 64 bytes? - by penguinkeeper - 07-16-2024, 05:25 PM