In 2009, arebound attack was announced that presents full collisions against 4.5 rounds of Whirlpool in 2120 operations, semi-free-start collisions against 5.5 rounds in 2120 time and semi-free-start near-collisions against 7.5 rounds in 2128 time.[1]
The original Whirlpool will be calledWhirlpool-0, the first revision of Whirlpool will be calledWhirlpool-T and the latest version will be calledWhirlpool in the following test vectors.
In the first revision in 2001, theS-box was changed from a randomly generated one with good cryptographic properties to one which has better cryptographic properties and is easier to implement in hardware.
In the second revision (2003), a flaw in thediffusion matrix was found that lowered the estimated security of the algorithm below its potential.[4] Changing the 8x8 rotating matrix constants from (1, 1, 3, 1, 5, 8, 9, 5) to (1, 1, 4, 1, 8, 5, 2, 9) solved this issue.
Theblock cipher consists of an 8×8 state matrix of bytes, for a total of 512 bits.
The encryption process consists of updating the state with four round functions over 10 rounds. The four round functions are SubBytes (SB or), ShiftColumns (SC or), MixRows (MR or) and AddRoundKey (AK or). During each round the new state is computed as.
TheSubBytes operation applies a non-linear permutation (the S-box) to each byte of the state independently. The 8-bit S-box is composed of 3 smaller 4-bit S-boxes.
TheMixBytesInRows operation is a right-multiplication of each row by an 8×8matrix over. The matrix is chosen such that thebranch number (an important property when looking at resistance todifferential cryptanalysis) is 9, which is maximal.
TheAddRoundKey operation uses bitwisexor to add a key calculated by the key schedule to the current state. The key schedule is identical to the encryption itself, except the AddRoundKey function is replaced by anAddRoundConstant function that adds a predetermined constant in each round.
The message that is to be hashed is firstpadded to ensure its length is a multiple of the block size (512 bits). This is done using the standardpadding scheme defined in theISO/IEC 10118-1 standard (the same used formd5,sha-2, and others):
Append a '1' bit;
Append as many '0' bits as needed for the length to reach a multiple of 256 ();
Append the original length of the message in bits using 256-bitbig-endian format.
Then, the padded message is divided into 512-bit blocks,.
Whirlpool iterates theMiyaguchi-Preneel hashing scheme over these blocks[sections 3.11 and 3.12][1]:
Acirculant matrix is defined as a matrix where each row is a cyclic shift of the previous row[section 2.2][1]. Formally, acirculant matrix can be represented as:
The S-Box is typically represented as alookup table, where each inputbyte is mapped to a corresponding outputbyte. It can be computed using optimal diffusion mapping generation techniques[section 2.4][1] but here is amatrix representation of it:
The Whirlpool algorithm has undergone two revisions since its original 2000 specification.
People incorporating Whirlpool will most likely use the most recent revision of Whirlpool; while there are no known security weaknesses in earlier versions of Whirlpool, the most recent revision has better hardware implementation efficiency characteristics, and is also likely to be more secure. As mentioned earlier, it is also the version adopted in the ISO/IEC 10118-3international standard.
The 512-bit (64-byte) Whirlpool hashes (also termedmessage digests) are typically represented as 128-digithexadecimal numbers. The following demonstrates a 43-byteASCII input (not including quotes) and the corresponding Whirlpool hashes:
The authors providereference implementations of the Whirlpool algorithm, including a version written inC and a version written inJava.[2] These reference implementations have been released into the public domain.[2]
Research on the security analysis of the Whirlpool function however, has revealed that on average, the introduction of 8 random faults is sufficient to compromise the 512-bit Whirlpool hash message being processed and the secret key of HMAC-Whirlpool within the context of Cloud of Things (CoTs). This emphasizes the need for increased security measures in its implementation.[5]
func dotProduct(A, B) tmp: Matrix for i from 0 to 7 for j from 0 to 7 tmp[i * 8 + j] := 0 for k from 0 to 7 # Galois Field (2^8) multiplication a := A[i * 8 + k]; b := B[k * 8 + j]; product := 0; while b > 0 if b & 1 == 1 product := product xor a endif if a & 0x80 != 0 a := (a << 1) xor 0x11d # x^8 + x^4 + x^3 + x^2 + 1 else a := a << 1 endif b := b >> 1 endwhile tmp[i * 8 + j] := tmp[i * 8 + j] xor product endfor endfor endfor return tmpendfunc
Here is an implementation of the 512-bit (64-bits size,big-endian)padding:
func pad(M) original_length := len(M) # In bytes # 512 bits (total length) - 256 bits (size length) - 1 bit (padding bit) # 64 bytes - 32 bytes - 1 byte = 31 bytes padding := (31 - original_length) % 64 padding := (padding + 64) % 64 # Avoid negative padding total_length := original_length + 1 + padding + 32 # In bytes padded: Byte[total_length] # Copy original message for i from 0 to original_length - 1 padded[i] := M[i] endfor padded[original_length] := 0x80 # Append the '1' bit, then 7 '0' bits for i from original_length + 1 to original_length + padding padded[i] := 0x00 # Append 8 '0' bits endfor for i from 0 to 31 padded[total_length - 32 + i] := (original_length * 8) >> (8 * (31 - i)) & 0xff endfor chunk_amount := total_length / 64 divided := Byte[chunk_amount][64] for i from 0 to chunk_amount - 1 for j from 0 to 63 divided[i][j] := padded[i * 64 + j] endfor endfor return divided, chunk_amountendfunc
And here is an example of amatrix-to-string conversion:
func matrixToHexString(matrix) HEX := "0123456789abcdef" result: Byte[128] for i from 0 to 63 byte := matrix[i] result[i * 2] := HEX[byte >> 4] result[i * 2 + 1] := HEX[byte & 0xf] endfor return resultendfunc
Two of the first widely used mainstream cryptographic programs that started using Whirlpool wereFreeOTFE, followed byTrueCrypt in 2005.[citation needed]
VeraCrypt (a fork ofTrueCrypt) included Whirlpool (the final version) as one of its supported hash algorithms.[6]
^Li, W., Gao, Z., Gu, D., Ge, C., Liao, L., Zhou, Z., Liu, Y., & Liu, Z. (2017). Security Analysis of the Whirlpool Hash Function in the Cloud of Things. KSII Transactions on Internet and Information Systems, 11(1), 536–551.https://doi.org/10.3837/tiis.2017.01.028