jonelo / jacksum

A hash utility, est. 2002, FLOSS. 489 hash functions, HMAC support, cross platform, feature-rich, multi threaded. CLI and API. Recursive hashing, predefined and customizable formats, verify data integrity and find ok/failed/missing/new files, find files by their hashes, find the hash function to a hash. GUI provided by HashGarten.
https://jacksum.net
GNU General Public License v3.0
43 stars 5 forks source link

Wrong hashSize in GNU-Crypto's whirlpool 0-arguments constructor (and all whirlpool derived implementations) #19

Closed jonelo closed 2 years ago

jonelo commented 2 years ago

Describe the bug First of all, the whirlpool calculation is correct. However, the whirlpool implementations have been registered with a wrong bitwidth.

whirlpool ist not listed in the list of 512 bit hashes:

$ jacksum31 -a all:512 --list
blake512
blake2b-512
echo512
fnv-0_512
fnv-1_512
fnv-1a_512
fugue512
groestl-512
jh512
keccak512
kupyna-512
lsh-512-512
luffa512
marsupilamifourteen
sha512
sha3-512
shake256
skein-512-512
skein-1024-512
streebog512

Instead it is listed at the end of the 160 bit width message digest list:

$ jacksum31 -a all:160 --list
blake2b-160
blake2s-160
has160
haval_160_3
haval_160_4
haval_160_5
ripemd160
sha0
sha1
skein-256-160
skein-512-160
skein-1024-160
whirlpool0
whirlpool1
whirlpool2

which is wrong, because whirlpool have a hash bit width of 512 bits.

To Reproduce Since the other two Whirlpool implementations (Whirlpool-0 and Whirlpool-2) are derived from the GNU Crypto Whirlpool-1 (aka Whirlpool-T), the bug is in all three implementations.

The bug is in GNU-Crypto's original Whirlpool.java (even in GNU-Crypto 2.1.0):

   /** Trivial 0-arguments constructor. */
   public Whirlpool() {
      super(Registry.WHIRLPOOL_HASH, 20, BLOCK_SIZE);
   }

This is wrong because Whirlpool's hashSize is 512 bit (64 bytes), and not 160 bit (20 bytes).

Expected behavior

jacksum -a all:512 --list once fixed, the command above should list whirlpool0, whirlpool1, and whirlpool2 in this list also jacksum -a all:whirlpool --list --info should list the hash length correctly which is 512 bits or 64 bytes

Screenshots n/a

Environment (please complete the following information): Jacksum 3.1.0

Additional context n/a

jonelo commented 2 years ago

fixed in commit https://github.com/jonelo/jacksum/commit/88f2eb14f823cfbc8f0c39fb8a485546fe49ff0c

jonelo commented 2 years ago

the bug is also in the GNU Classpath 0.99, class gnu.java.security.hash.Whirlpool.java