Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix: gost-crypto hash incorrect if input data contains long 0xFF sequence #2391
Problem was within overflow detection: if result is less than any of two arguments, than there was overflow. But in fact there are three arguments, so with the right data overflow would not be detected: 0x00000001 + 0xFFFFFFFF+0xFFFFFFFF = 0xFFFFFFFF.
My fix changes operations to 16-bits, so there are no undetectable overflows possible.
Could you please add a test for this change?
Also, the implementation looks unnecessarily complicated. For example, this is how the same code in rhash looks like: https://github.com/rhash/RHash/blob/master/librhash/gost.c#L326