I’m implementing the SHA1 algorithm from the pseudocode on wikipedia.
It says I should append to original length as 64 bits to the message, so I tried the following:
// new_message is of type char[] and is 9+ bytes long
*((__int64*)(new_message-8)) = (__int64) length;
This makes the new_message’s memory corrupt.
Could someone spot the error?
Thanks!
Edit:
Jesus, I’m so stupid. new_message pointed to the start of my array, no wonder it crashed!
Not definitively, without seeing the part of the code that shows what
new_messageis set to.It looks like you are underflowing the buffer though, which will mess up the heap header that probably precedes
&new_message[0]. You are writing your__int648 bytes before the start of thechar[], by the look of things.