Skip to content
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

Wrong padding for SHA1 -- incorrect hash when last block is more. than 448 bits #2

Open
centprod opened this issue Nov 1, 2024 · 0 comments

Comments

@centprod
Copy link

centprod commented Nov 1, 2024

Pretty much the same as the already reported issue for sha256 and sha512; when the message length won't fit into the final block, an extra block is added which should be zeroed out, but the memset doesn't account for the buffer being four-byte words.

  •           memset(result, 0, BLOCK_SIZE - 8);
    
  •           memset(result, 0, (BLOCK_SIZE - 8) * sizeof(word_t));
    

The incorrect clearing means the extra block still contains data from the final block. The resulting hash is consistent: it's always the same for the same incoming message; but it doesn't match the sha1 standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant