-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] in SHA1_Transform - const uint8_t buffer's data is modified #59
Comments
An alternative fix for this would be to replace the line sha1.cpp#L198
Which I assume was the intened use of the buffer as it was done for the transform prior to the loop. |
No, then it would not fix basic issue within |
That is the only place it's called with inital data instead of a copy, but copying in the transform works fine as well, although I'd recommend removing the context buffer then, as well as the lines where we copy into it. |
What do you talking about? SHA1_CTX::buffer is needed to follow SHA calculation (basically on every update for every chunk, because SHA-calculation is independent of data chunk size): |
Hi,
When calculating SHA-1 hashes of a block of data,
SHA1_Update
is called with a pointer to const uint8_t data.Unfortunately, the constness of
data
is casted away, and the contents ofdata
are modified during theSHA1_Transform
function.An example, using sha1.h, and also sha1.cpp's digest_to_hex:
hash1
!=hash2
!=hash3
, andtest_buffer
is changed every time its SHA-1 hash is calculated.This is fixed in other repositories, based off of the same original code (ex.: http://download.redis.io/redis-stable/src/sha1.c).
The text was updated successfully, but these errors were encountered: