diff -uNr a/eucrypt/README b/eucrypt/README --- a/eucrypt/README 82f1271903c039ffba8620c425beb86cb3e0b585d1b6ec61ff2ecb79f60eb7700093eee06760b24745710036a541381a33fd262f05d1d4f561851044a6d39cdb +++ b/eucrypt/README 6d9112fb539eed54572be08e83fa23127773c52c6aea0500217d50ec2f8c728cc64864f11c666521f393eb25690961b1c5fcae914efb049f6d65f8c4f34e64ec @@ -19,6 +19,7 @@ 3. smg_keccak Word (64 bits) level implementation of the Keccak sponge according to The Keccak Reference v 3.0. + NOTE: Keccak rate has its own type (Keccak_Rate) that makes clear the valid range (1 to width of state). Calling Keccak sponge with a bitrate outside the valid range will CORRECTLY cause the execution to abort with a constraint_error. Implemented in Ada. 4. smg_serpent diff -uNr a/eucrypt/smg_keccak/smg_keccak.adb b/eucrypt/smg_keccak/smg_keccak.adb --- a/eucrypt/smg_keccak/smg_keccak.adb 88e40423c88ba2ac7d44225b388794d61719746b02412e2dae4684bcfa72399978d599f9301b4a2be101b41769d3c5b20de6ff94e76a01ff767edc00746b8b96 +++ b/eucrypt/smg_keccak/smg_keccak.adb c1a09df1a356cc9042207a12de9290c85b22a734499661486d419e44b3b22551f87eaa0f6eb2173f771e31cbb078471d3b6650b76434ea9ffbde1a8d4afb2814 @@ -148,7 +148,7 @@ ToPos := Block'Last; FromPos := ToPos - SBB + 1; BWord := (others => 0); - BWord(Bitword'First .. Bitword'First + SBB - 1) := Block(ToPos..FromPos); + BWord(Bitword'First .. Bitword'First + SBB - 1) := Block(FromPos..ToPos); Word := BitsToWord( BWord ); S( X, Y ) := S( X, Y ) xor Word; end if; diff -uNr a/eucrypt/smg_keccak/tests/smg_keccak-test.adb b/eucrypt/smg_keccak/tests/smg_keccak-test.adb --- a/eucrypt/smg_keccak/tests/smg_keccak-test.adb d32b0ad7d28c2641a7172dd10f409670eb9d6a925a755faaaeed545123abf45db6b30bad662c88b1428a656876154c2c5091fccf82b4924f1863b9a6b9ad2537 +++ b/eucrypt/smg_keccak/tests/smg_keccak-test.adb 3735cbb1dee9b07a59bbb461ba507613d83d6a67b9cdf5298613ef27074e6962c926c96a491501a315907c01c3e16cc6fd56aacf58106306d56d67d9835753c5 @@ -466,6 +466,19 @@ end test_oaep; + procedure test_all_bitrates is + Input : constant String := "hello, world"; + Bin : Bitstream( 0 .. Input'Length * 8 - 1 ) := ( others => 0 ); + Bout : Bitstream( 0 .. 100 ) := ( others => 0 ); + begin + ToBitstream( Input, Bin ); + Put_Line("Testing all bitrates:"); + for Bitrate in Keccak_Rate'Range loop + Sponge(Bin, Bout, Bitrate); + Put_Line("PASSED: keccak with bitrate " & Integer'Image(Bitrate)); + end loop; + end test_all_bitrates; + -- end of helper methods --variables @@ -518,4 +531,7 @@ -- test xor on strings test_xor_strings; + -- test ALL bitrates of the Keccak sponge + test_all_bitrates; + end SMG_Keccak.Test;