Keccak::getHash() is broken if no new data is added
stbrumme opened this issue · comments
Calling Keccak::getHash() repeatedly produces different hashes, SHA3 could be affected, too
int main(int argc, char *argv[]) {
Keccak k;
std::string temp("hello world");
k.add(&temp[0], temp.size());
std::cout << k.getHash() << std::endl;
std::cout << k.getHash() << std::endl;
std::cout << k.getHash() << std::endl;
return 0;
}
returns
47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
c82cad59277af8d880d6ccbbddf0bbed8359fdfaa7491960e1f2397011bf5ae5
d165ecff4927241ce0fa7184b3ad53b4116f7fea6a8b2e1f509e75d087bcfead
I can't reproduce this bug anymore. Everything's working as expected.
A minimal test case github-issue2.cpp will be added.
My last comment was actually wrong: I fixed this bug long ago but never committed the change to the repository.
SHA3 was affected as well as Keccak (but not the other algorithms such as SHA1).
Version 8 will be pushed to GitHub in a few minutes, including a test program.
Sorry for the confusion.