I'm currently working on a Blake2b implementation to use later for
password hashing schemes like Lyra2 or Catena
(https://github.com/Beloumi/eck.cologne.crypto). I have see your
implementation on GitHub. This is clearly more comprehensive and
thorough than my version, but maybe there is also sometimes need for a
simple variant.
As I can see, there is a minor not critical bug in the implementation
for messages from 2^64+1 up to 2^64+127 bytes, because the counter
(t[1]) will not be incremented for the last block. So, digests of this
implementation will differ from the C reference implementation.
This can easily fixed by replacing line 446 of the class Blake2b.java
in the function digest()
(currently: this.t[1] += this.t[0] == 0 ? 1 : 0;)
by:
this.t[1] += (t[0] < 0 && buflen > -t[0]) ? 1 : 0;
Best regards
Axel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
This issue was kindly brought to my attention by Axel von dem Bruch.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Joubin Mohammad,
I'm currently working on a Blake2b implementation to use later for password hashing schemes like Lyra2 or Catena (https://github.com/Beloumi/eck.cologne.crypto). I have see your implementation on GitHub. This is clearly more comprehensive and thorough than my version, but maybe there is also sometimes need for a simple variant.
As I can see, there is a minor not critical bug in the implementation for messages from 2^64+1 up to 2^64+127 bytes, because the counter (t[1]) will not be incremented for the last block. So, digests of this implementation will differ from the C reference implementation.
This can easily fixed by replacing line 446 of the class Blake2b.java in the function digest() (currently: this.t[1] += this.t[0] == 0 ? 1 : 0;) by: this.t[1] += (t[0] < 0 && buflen > -t[0]) ? 1 : 0;
Best regards Axel -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux)
iQEcBAEBAgAGBQJU+ZlQAAoJEB6PWtWjd4ECHywH/Rfs2WIJoY5lf2bWATWcncc9 oUjj1oPzLF2X8kI2s7RkRal8rQiVIoYu0UnJIPFncmUfqETQZJ7Wpn+yvbxTcbQT t/e+BloYqFRwAl18z67M8HJhxB51l1ua/z74xfb3lYsNTGqszxenf6ALBcdLIUFy f1ZnaTr2fFHD+RF1kFBEPXx/S6w7l7Rsj2fsFuwPXwxJ18RtsJwfbsYF2dYybbNU 4FM6PA9rEHmmSDJvo/KPK7VBA7EPUZokrcI2uD+55+TmEHiUJQ5DTRBk2Xlv4GNZ mJYZzrYrW3c8Ou0l/nB0pFjLfpNPxFf6oOuWbuIy36UtTvdZSLIJ/gC7tyyfyjc= =++V4 -----END PGP SIGNATURE-----