raw
eucrypt_ch6_kecca...    1 with SMG_Keccak; use SMG_Keccak;
eucrypt_ch6_kecca... 2 with Ada.Exceptions; use Ada.Exceptions;
eucrypt_ch6_kecca... 3 with Ada.Text_IO; use Ada.Text_IO;
eucrypt_ch6_kecca... 4 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
eucrypt_ch6_kecca... 5 with Interfaces; use Interfaces;
eucrypt_ch6_kecca... 6
eucrypt_ch6_kecca... 7 procedure SMG_Keccak.Test is
eucrypt_ch6_kecca... 8 --types
eucrypt_ch6_kecca... 9 type Keccak_Perms is (None, Theta, Rho, Pi, Chi, Iota);
eucrypt_ch6_kecca... 10 type Test_Vector is array(Keccak_Perms) of State;
eucrypt_ch6_kecca... 11 type Test_Round is array(Round_Index) of Test_Vector;
eucrypt_ch6_kecca... 12
eucrypt_ch6_kecca... 13 --helper methods
eucrypt_ch6_kecca... 14 procedure print_state(S: in State; Title: in String) is
eucrypt_ch6_kecca... 15 Hex: array(0..15) of Character := ("0123456789ABCDEF");
eucrypt_ch6_kecca... 16 Len: constant Natural := Z_Length / 4;
eucrypt_ch6_kecca... 17 HexString: String(1..Len);
eucrypt_ch6_kecca... 18 W: ZWord;
eucrypt_ch6_kecca... 19 begin
eucrypt_ch6_kecca... 20 Put_Line("---------" & Title & "---------");
eucrypt_ch6_kecca... 21 for Y in XYCoord loop
eucrypt_ch6_kecca... 22 for X in XYCoord loop
eucrypt_ch6_kecca... 23 W := S(X,Y);
eucrypt_ch6_kecca... 24 for Z in 0..Len-1 loop
eucrypt_ch6_kecca... 25 HexString(Natural(Len-Z)) := Hex(Natural(W mod 16));
eucrypt_ch6_kecca... 26 W := W / 16;
eucrypt_ch6_kecca... 27 end loop;
eucrypt_ch6_kecca... 28 Put(HexString & " ");
eucrypt_ch6_kecca... 29 end loop;
eucrypt_ch6_kecca... 30 Put_Line("");
eucrypt_ch6_kecca... 31 end loop;
eucrypt_ch6_kecca... 32 end;
eucrypt_ch6_kecca... 33
eucrypt_ch7_kecca... 34 procedure print_bitstream(B: in Bitstream; Title: in String) is
eucrypt_ch7_kecca... 35 Hex : array(0..15) of Character := ("0123456789ABCDEF");
eucrypt_ch7_kecca... 36 HexString : String(1..B'Length/4);
eucrypt_ch7_kecca... 37 C : Natural;
eucrypt_ch7_kecca... 38 Pos : Natural;
eucrypt_ch7_kecca... 39 begin
eucrypt_ch7_kecca... 40 for I in 1..B'Length/4 loop
eucrypt_ch7_kecca... 41 Pos := (I-1)*4 + B'First;
eucrypt_ch7_kecca... 42 C := Natural( B(Pos) ) * 8 +
eucrypt_ch7_kecca... 43 Natural( B(Pos + 1) ) * 4 +
eucrypt_ch7_kecca... 44 Natural( B(Pos + 2) ) * 2 +
eucrypt_ch7_kecca... 45 Natural( B(Pos + 3) );
eucrypt_ch7_kecca... 46 HexString(I) := Hex(C);
eucrypt_ch7_kecca... 47 end loop;
eucrypt_ch7_kecca... 48 Put_Line("---" & Title & "---");
eucrypt_ch7_kecca... 49 Put_Line(HexString);
eucrypt_ch7_kecca... 50 end print_bitstream;
eucrypt_ch7_kecca... 51
eucrypt_ch6_kecca... 52 function read_state(File: in FILE_TYPE; Oct: Positive :=8) return State is
eucrypt_ch6_kecca... 53 S: State;
eucrypt_ch6_kecca... 54 Line1: String := "0000000000000000 " &
eucrypt_ch6_kecca... 55 "0000000000000000 " &
eucrypt_ch6_kecca... 56 "0000000000000000 " &
eucrypt_ch6_kecca... 57 "0000000000000000 " &
eucrypt_ch6_kecca... 58 "0000000000000000";
eucrypt_ch6_kecca... 59 StartPos, EndPos: Positive;
eucrypt_ch6_kecca... 60 Len: Positive := Oct*2;
eucrypt_ch6_kecca... 61 begin
eucrypt_ch6_kecca... 62 for Y in XYCoord loop
eucrypt_ch6_kecca... 63 Line1 := Get_Line(File);
eucrypt_ch6_kecca... 64 StartPos := Line1'First;
eucrypt_ch6_kecca... 65 EndPos := StartPos + Len-1;
eucrypt_ch6_kecca... 66
eucrypt_ch6_kecca... 67 for X in XYCoord loop
eucrypt_ch6_kecca... 68 S(X,Y) := ZWord'value("16#" & Line1(StartPos..EndPos) & "#");
eucrypt_ch6_kecca... 69 StartPos := EndPos + 2; --one space to skip
eucrypt_ch6_kecca... 70 EndPos := StartPos + Len - 1;
eucrypt_ch6_kecca... 71 end loop;
eucrypt_ch6_kecca... 72 end loop;
eucrypt_ch6_kecca... 73 return S;
eucrypt_ch6_kecca... 74 end read_state;
eucrypt_ch6_kecca... 75
eucrypt_ch6_kecca... 76 --reads a full test round from specified file (pre-defined format)
eucrypt_ch6_kecca... 77 function read_from_file (filename : in String;
eucrypt_ch6_kecca... 78 T : out Test_Round)
eucrypt_ch6_kecca... 79 return Boolean is
eucrypt_ch6_kecca... 80 file: FILE_TYPE;
eucrypt_ch6_kecca... 81 InputMarker: String := "lanes as 64-bit words:";
eucrypt_ch6_kecca... 82 octets: Positive := 8;
eucrypt_ch6_kecca... 83 RoundNo: Round_Index;
eucrypt_ch6_kecca... 84 begin
eucrypt_ch6_kecca... 85 -- try to open the input file
eucrypt_ch6_kecca... 86 begin
eucrypt_ch6_kecca... 87 open(file, In_File, filename);
eucrypt_ch6_kecca... 88 exception
eucrypt_ch6_kecca... 89 when others =>
eucrypt_ch6_kecca... 90 Put_Line(Standard_Error,
eucrypt_ch6_kecca... 91 "Can not open the file '" & filename & "'. Does it exist?");
eucrypt_ch6_kecca... 92 return False;
eucrypt_ch6_kecca... 93 end;
eucrypt_ch6_kecca... 94
eucrypt_ch6_kecca... 95 -- find & read input state first
eucrypt_ch6_kecca... 96 RoundNo := -1;
eucrypt_ch6_kecca... 97 loop
eucrypt_ch6_kecca... 98 declare
eucrypt_ch6_kecca... 99 Line: String := Get_Line(file);
eucrypt_ch6_kecca... 100 begin
eucrypt_ch6_kecca... 101 --check if this is test data of any known kind
eucrypt_ch6_kecca... 102 if index(Line, InputMarker, 1) > 0 then
eucrypt_ch6_kecca... 103 T(0)(None) := read_state(file, octets);
eucrypt_ch6_kecca... 104 print_state(T(0)(None), "Read Input State");
eucrypt_ch6_kecca... 105 elsif index(Line, "Round ", 1) > 0 then
eucrypt_ch6_kecca... 106 RoundNo := RoundNo +1;
eucrypt_ch6_kecca... 107 elsif index(Line, "theta", 1) > 0 then
eucrypt_ch6_kecca... 108 T(RoundNo)(Theta) := read_state(file, octets);
eucrypt_ch6_kecca... 109 if (RoundNo > 0) then
eucrypt_ch6_kecca... 110 T(RoundNo)(None) := T(RoundNo-1)(Iota); -- previous state as input
eucrypt_ch6_kecca... 111 end if;
eucrypt_ch6_kecca... 112 elsif index(Line, "rho", 1) > 0 then
eucrypt_ch6_kecca... 113 T(RoundNo)(Rho) := read_state(file, octets);
eucrypt_ch6_kecca... 114 elsif index(Line, "pi", 1) > 0 then
eucrypt_ch6_kecca... 115 T(RoundNo)(Pi) := read_state(file, octets);
eucrypt_ch6_kecca... 116 elsif index(Line, "chi", 1) > 0 then
eucrypt_ch6_kecca... 117 T(RoundNo)(Chi) := read_state(file, octets);
eucrypt_ch6_kecca... 118 elsif index(Line, "iota", 1) > 0 then
eucrypt_ch6_kecca... 119 T(RoundNo)(Iota) := read_state(file, octets);
eucrypt_ch6_kecca... 120 end if;
eucrypt_ch6_kecca... 121 exit when End_Of_File(file);
eucrypt_ch6_kecca... 122 end;
eucrypt_ch6_kecca... 123 end loop;
eucrypt_ch6_kecca... 124 Close(file);
eucrypt_ch6_kecca... 125 return True;
eucrypt_ch6_kecca... 126 end read_from_file;
eucrypt_ch6_kecca... 127
eucrypt_ch6_kecca... 128 -- performs one single round of Keccak, step by step
eucrypt_ch6_kecca... 129 -- each permutation is tested separately
eucrypt_ch6_kecca... 130 -- test fails with exception raised at first output not matching expected
eucrypt_ch6_kecca... 131 procedure test_one_round(T: Test_Vector; Round: Round_Index) is
eucrypt_ch6_kecca... 132 Input: State;
eucrypt_ch6_kecca... 133 Expected: State;
eucrypt_ch6_kecca... 134 Output: State;
eucrypt_ch6_kecca... 135 Test_One_Round_Fail: Exception;
eucrypt_ch6_kecca... 136 begin
eucrypt_ch6_kecca... 137 Input := T(None);
eucrypt_ch6_kecca... 138 for I in Keccak_Perms range Theta..Iota loop
eucrypt_ch6_kecca... 139 Expected := T(I);
eucrypt_ch6_kecca... 140 case I is
eucrypt_ch6_kecca... 141 when Theta => Output := SMG_Keccak.Theta(Input);
eucrypt_ch6_kecca... 142 when Rho => Output := SMG_Keccak.Rho(Input);
eucrypt_ch6_kecca... 143 when Pi => Output := SMG_Keccak.Pi(Input);
eucrypt_ch6_kecca... 144 when Chi => Output := SMG_Keccak.Chi(Input);
eucrypt_ch6_kecca... 145 when Iota => Output := SMG_Keccak.Iota(RC(Round), Input);
eucrypt_ch6_kecca... 146 when others => null;
eucrypt_ch6_kecca... 147 end case;
eucrypt_ch6_kecca... 148
eucrypt_ch6_kecca... 149 if (Output /= Expected) then
eucrypt_ch6_kecca... 150 print_state(Output, "----------real output-------");
eucrypt_ch6_kecca... 151 print_state(Expected, "----------expected output--------");
eucrypt_ch6_kecca... 152 raise Test_One_Round_Fail;
eucrypt_ch6_kecca... 153 else
eucrypt_ch6_kecca... 154 Put_Line("PASSED: " & Keccak_Perms'Image(I));
eucrypt_ch6_kecca... 155 end if;
eucrypt_ch6_kecca... 156 -- get ready for next permutation
eucrypt_ch6_kecca... 157 Input := Expected;
eucrypt_ch6_kecca... 158 end loop;
eucrypt_ch6_kecca... 159 end test_one_round;
eucrypt_ch7_kecca... 160
eucrypt_ch7_kecca... 161 procedure test_bits_to_word_conversion is
eucrypt_ch7_kecca... 162 bits: Bitword := (others => 0);
eucrypt_ch7_kecca... 163 obtained_bits: Bitword := (others => 0);
eucrypt_ch7_kecca... 164 expected: ZWord;
eucrypt_ch7_kecca... 165 obtained: ZWord;
eucrypt_ch7_kecca... 166 begin
eucrypt_ch9_kecca... 167 expected := 16#8FA4F19E0287BBE7#;
eucrypt_ch7_kecca... 168 bits := (1,1,1,0, 0,1,1,1, 1,1,0,1, 1,1,0,1, 1,1,1,0, 0,0,0,1, 0,1,0,0,
eucrypt_ch7_kecca... 169 0,0,0,0, 0,1,1,1, 1,0,0,1, 1,0,0,0, 1,1,1,1, 0,0,1,0, 0,1,0,1,
eucrypt_ch7_kecca... 170 1,1,1,1, 0,0,0,1);
eucrypt_ch7_kecca... 171 obtained := BitsToWord(bits);
eucrypt_ch7_kecca... 172 obtained_bits := WordToBits(expected);
eucrypt_ch7_kecca... 173
eucrypt_ch7_kecca... 174 if obtained /= expected then
eucrypt_ch7_kecca... 175 Put_Line("FAIL: bits to word");
eucrypt_ch7_kecca... 176 Put_Line("Expected: " & ZWord'Image(expected));
eucrypt_ch7_kecca... 177 Put_Line("Obtained: " & ZWord'Image(obtained));
eucrypt_ch7_kecca... 178 else
eucrypt_ch7_kecca... 179 Put_Line("PASSED: bits to word");
eucrypt_ch7_kecca... 180 end if;
eucrypt_ch7_kecca... 181
eucrypt_ch7_kecca... 182 if obtained_bits /= bits then
eucrypt_ch7_kecca... 183 Put_Line("FAIL: word to bits");
eucrypt_ch7_kecca... 184 Put("Expected: ");
eucrypt_ch7_kecca... 185 for I in Bitword'Range loop
eucrypt_ch7_kecca... 186 Put(Bit'Image(bits(I)));
eucrypt_ch7_kecca... 187 end loop;
eucrypt_ch7_kecca... 188 Put_Line("");
eucrypt_ch7_kecca... 189 Put_Line("Obtained: ");
eucrypt_ch7_kecca... 190 for I in Bitword'Range loop
eucrypt_ch7_kecca... 191 Put(Bit'Image(obtained_bits(I)));
eucrypt_ch7_kecca... 192 end loop;
eucrypt_ch7_kecca... 193 Put_Line("");
eucrypt_ch7_kecca... 194 else
eucrypt_ch7_kecca... 195 Put_Line("PASSED: word to bits");
eucrypt_ch7_kecca... 196 end if;
eucrypt_ch7_kecca... 197 end test_bits_to_word_conversion;
eucrypt_ch7_kecca... 198
eucrypt_ch9_kecca... 199 procedure test_flip is
eucrypt_ch9_kecca... 200 B: constant Bitword := (1, 0, 1, 1, 1, 1, 0, 0,
eucrypt_ch9_kecca... 201 1, 1, 1, 0, 0, 0, 0, 1,
eucrypt_ch9_kecca... 202 0, 1, 1, 0, 0, 0, 1, 0,
eucrypt_ch9_kecca... 203 1, 1, 1, 1, 1, 1, 1, 1,
eucrypt_ch9_kecca... 204 1, 1, 0, 1, 1, 0, 0, 1,
eucrypt_ch9_kecca... 205 0, 0, 0, 0, 0, 0, 0, 0,
eucrypt_ch9_kecca... 206 0, 0, 1, 1, 0, 0, 0, 1,
eucrypt_ch9_kecca... 207 0, 0, 0, 1, 1, 0, 0, 0);
eucrypt_ch9_kecca... 208 Expected: Bitword := (0, 0, 0, 1, 1, 0, 0, 0,
eucrypt_ch9_kecca... 209 0, 0, 1, 1, 0, 0, 0, 1,
eucrypt_ch9_kecca... 210 0, 0, 0, 0, 0, 0, 0, 0,
eucrypt_ch9_kecca... 211 1, 1, 0, 1, 1, 0, 0, 1,
eucrypt_ch9_kecca... 212 1, 1, 1, 1, 1, 1, 1, 1,
eucrypt_ch9_kecca... 213 0, 1, 1, 0, 0, 0, 1, 0,
eucrypt_ch9_kecca... 214 1, 1, 1, 0, 0, 0, 0, 1,
eucrypt_ch9_kecca... 215 1, 0, 1, 1, 1, 1, 0, 0);
eucrypt_ch9_kecca... 216 Output : Bitword;
eucrypt_ch9_kecca... 217 begin
eucrypt_ch9_kecca... 218 Output := FlipOctets( B );
eucrypt_ch9_kecca... 219 if Output /= Expected then
eucrypt_ch9_kecca... 220 Put_Line( "FAILED: flip octets" );
eucrypt_ch9_kecca... 221 Put_Line( "Expected: " );
eucrypt_ch9_kecca... 222 for I of Expected loop
eucrypt_ch9_kecca... 223 Put(Bit'Image(I));
eucrypt_ch9_kecca... 224 end loop;
eucrypt_ch9_kecca... 225 new_line(1);
eucrypt_ch9_kecca... 226 Put_Line( "Output: " );
eucrypt_ch9_kecca... 227 for I of Output loop
eucrypt_ch9_kecca... 228 Put(Bit'Image(I));
eucrypt_ch9_kecca... 229 end loop;
eucrypt_ch9_kecca... 230 new_line(1);
eucrypt_ch9_kecca... 231 else
eucrypt_ch9_kecca... 232 Put_Line( "PASSED: flip octets" );
eucrypt_ch9_kecca... 233 end if;
eucrypt_ch9_kecca... 234 end test_flip;
eucrypt_ch9_kecca... 235
eucrypt_ch7_kecca... 236 procedure test_sponge is
eucrypt_ch7_kecca... 237 Bitrate : constant Keccak_Rate := 1344;
eucrypt_ch7_kecca... 238 Input : Bitstream(1..5) := (1, 1, 0, 0, 1);
eucrypt_ch7_kecca... 239 Hex : array(0..15) of Character := ("0123456789ABCDEF");
eucrypt_ch7_kecca... 240 C : Natural;
eucrypt_ch9_kecca... 241 HexPos : Natural;
eucrypt_ch7_kecca... 242 Error : Natural;
eucrypt_ch7_kecca... 243 Pos : Natural;
eucrypt_ch9_kecca... 244 ExpHex : constant String :=
eucrypt_ch9_kecca... 245 "CB7FFB7CE7572A06C537858A0090FC2888C3C6BA9A3ADAB4"&
eucrypt_ch9_kecca... 246 "FE7C9AB4EFE7A1E619B834C843A5A79E23F3F7E314AA597D"&
eucrypt_ch9_kecca... 247 "9DAD376E8413A005984D00CF954F62F59EF30B050C99EA64"&
eucrypt_ch9_kecca... 248 "E958335DAE684195D439B6E6DFD0E402518B5E7A227C48CF"&
eucrypt_ch9_kecca... 249 "239CEA1C391241D7605733A9F4B8F3FFBE74EE45A40730ED"&
eucrypt_ch9_kecca... 250 "1E2FDEFCCA941F518708CBB5B6D5A69C30263267B97D7B29"&
eucrypt_ch9_kecca... 251 "AC87043880AE43033B1017EFB75C33248E2962892CE69DA8"&
eucrypt_ch9_kecca... 252 "BAF1DF4C0902B16C64A1ADD42FF458C94C4D3B0B32711BBA"&
eucrypt_ch9_kecca... 253 "22104989982543D1EF1661AFAF2573687D588C81113ED7FA"&
eucrypt_ch9_kecca... 254 "F7DDF912021FC03D0E98ACC0200A9F7A0E9629DBA33BA0A3"&
eucrypt_ch9_kecca... 255 "C03CCA5A7D3560A6DB589422AC64882EF14A62AD9807B353"&
eucrypt_ch9_kecca... 256 "8DEE1548194DBD456F92B568CE76827F41E0FB3C7F25F3A4"&
eucrypt_ch9_kecca... 257 "C707AD825B289730FEBDFD22A3E742C6FB7125DE0E38B130"&
eucrypt_ch9_kecca... 258 "F3059450CA6185156A7EEE2AB7C8E4709956DC6D5E9F99D5"&
eucrypt_ch9_kecca... 259 "0A19473EA7D737AC934815D68C0710235483DB8551FD8756"&
eucrypt_ch9_kecca... 260 "45692B4E5E16BB9B1142AE300F5F69F43F0091D534F372E1"&
eucrypt_ch9_kecca... 261 "FFC2E522E71003E4D27EF6ACCD36B2756FB5FF02DBF0C96B"&
eucrypt_ch9_kecca... 262 "CAE68E7D6427810582F87051590F6FB65D7B948A9C9D6C93"&
eucrypt_ch9_kecca... 263 "AF4562367A0AD79109D6F3087C775FE6D60D66B74F8D29FB"&
eucrypt_ch9_kecca... 264 "4BA80D0168693A748812EA0CD3CA23854CC84D4E716F4C1A"&
eucrypt_ch9_kecca... 265 "A3B340B1DED2F304DFDBACC1D792C8AC9A1426913E3F67DB"&
eucrypt_ch9_kecca... 266 "790FD5CFB77DAA29";
eucrypt_ch9_kecca... 267 Output : Bitstream( 1 .. ExpHex'Length * 4 );
eucrypt_ch9_kecca... 268 HexString : String( 1 .. ExpHex'Length );
eucrypt_ch7_kecca... 269 begin
eucrypt_ch7_kecca... 270 Put_Line("---sponge test---");
eucrypt_ch7_kecca... 271 Sponge(Input, Bitrate, Output);
eucrypt_ch7_kecca... 272 Put_Line("Input is:");
eucrypt_ch7_kecca... 273 for I of Input loop
eucrypt_ch7_kecca... 274 Put(Bit'Image(I));
eucrypt_ch7_kecca... 275 end loop;
eucrypt_ch7_kecca... 276 new_line(1);
eucrypt_ch7_kecca... 277
eucrypt_ch7_kecca... 278 Put_Line("Output is:");
eucrypt_ch7_kecca... 279 for I of Output loop
eucrypt_ch7_kecca... 280 Put(Bit'Image(I));
eucrypt_ch7_kecca... 281 end loop;
eucrypt_ch7_kecca... 282 new_line(1);
eucrypt_ch7_kecca... 283
eucrypt_ch7_kecca... 284 Error := 0;
eucrypt_ch7_kecca... 285 for I in 1..Output'Length/4 loop
eucrypt_ch7_kecca... 286 Pos := Output'First + (I-1)*4;
eucrypt_ch9_kecca... 287 C := Natural( Output( Pos ) ) +
eucrypt_ch9_kecca... 288 Natural( Output( Pos + 1 ) ) * 2 +
eucrypt_ch9_kecca... 289 Natural( Output( Pos + 2 ) ) * 4 +
eucrypt_ch9_kecca... 290 Natural( Output( Pos + 3 ) ) * 8;
eucrypt_ch9_kecca... 291 HexPos := I + 2 * ( I mod 2 ) - 1;
eucrypt_ch9_kecca... 292 Hexstring(HexPos) := Hex( C );
eucrypt_ch9_kecca... 293 if Hexstring(HexPos) /= ExpHex(HexPos) then
eucrypt_ch7_kecca... 294 Error := Error + 1;
eucrypt_ch7_kecca... 295 end if;
eucrypt_ch7_kecca... 296 end loop;
eucrypt_ch7_kecca... 297 Put_Line("Expected: ");
eucrypt_ch7_kecca... 298 Put_Line(ExpHex);
eucrypt_ch7_kecca... 299 Put_Line("Obtained: ");
eucrypt_ch7_kecca... 300 Put_Line(Hexstring);
eucrypt_ch7_kecca... 301 Put_Line("Errors found: " & Natural'Image(Error));
eucrypt_ch7_kecca... 302
eucrypt_ch7_kecca... 303 end test_sponge;
eucrypt_ch7_kecca... 304
eucrypt_ch7_kecca... 305 procedure test_keccak_function(T: in Test_Round) is
eucrypt_ch7_kecca... 306 S: State;
eucrypt_ch7_kecca... 307 begin
eucrypt_ch7_kecca... 308 Put_Line("---Full Keccak Function test---");
eucrypt_ch7_kecca... 309 S := Keccak_Function(T(Round_Index'First)(None));
eucrypt_ch7_kecca... 310 if S /= T(Round_Index'Last)(Iota) then
eucrypt_ch7_kecca... 311 Put_Line("FAILED: full keccak function test");
eucrypt_ch7_kecca... 312 else
eucrypt_ch7_kecca... 313 Put_Line("PASSED: full keccak function test");
eucrypt_ch7_kecca... 314 end if;
eucrypt_ch7_kecca... 315 end test_keccak_function;
eucrypt_ch7_kecca... 316
eucrypt_ch6_kecca... 317 -- end of helper methods
eucrypt_ch6_kecca... 318
eucrypt_ch6_kecca... 319 --variables
eucrypt_ch6_kecca... 320 T: Test_Round;
eucrypt_ch6_kecca... 321 begin
eucrypt_ch6_kecca... 322 Put_Line("-----Testing with zero state as input------");
eucrypt_ch6_kecca... 323 if (not read_from_file("testvectorszero.txt", T)) then
eucrypt_ch6_kecca... 324 return;
eucrypt_ch6_kecca... 325 end if;
eucrypt_ch6_kecca... 326
eucrypt_ch6_kecca... 327 for I in Round_Index loop
eucrypt_ch6_kecca... 328 Put_Line("---round " & Round_Index'Image(I) & "---");
eucrypt_ch6_kecca... 329 test_one_round(T(I), I);
eucrypt_ch6_kecca... 330 end loop;
eucrypt_ch6_kecca... 331
eucrypt_ch7_kecca... 332 -- test also Keccak_Function as a whole --
eucrypt_ch7_kecca... 333 test_keccak_function(T);
eucrypt_ch7_kecca... 334
eucrypt_ch6_kecca... 335 Put_Line("-----Testing with non-zero state as input------");
eucrypt_ch6_kecca... 336 if (not read_from_file("testvectorsnonzero.txt", T)) then
eucrypt_ch6_kecca... 337 return;
eucrypt_ch6_kecca... 338 end if;
eucrypt_ch6_kecca... 339
eucrypt_ch6_kecca... 340 for I in Round_Index loop
eucrypt_ch6_kecca... 341 Put_Line("---round " & Round_Index'Image(I) & "---");
eucrypt_ch6_kecca... 342 test_one_round(T(I), I);
eucrypt_ch6_kecca... 343 end loop;
eucrypt_ch6_kecca... 344
eucrypt_ch7_kecca... 345 -- test also Keccak_Function as a whole --
eucrypt_ch7_kecca... 346 test_keccak_function(T);
eucrypt_ch7_kecca... 347
eucrypt_ch7_kecca... 348 -- test BitsToWord and WordToBits
eucrypt_ch7_kecca... 349 test_bits_to_word_conversion;
eucrypt_ch7_kecca... 350
eucrypt_ch7_kecca... 351 -- test Sponge construction
eucrypt_ch7_kecca... 352 test_sponge;
eucrypt_ch7_kecca... 353
eucrypt_ch9_kecca... 354 -- test flipping octets
eucrypt_ch9_kecca... 355 test_flip;
eucrypt_ch9_kecca... 356
eucrypt_ch6_kecca... 357 end SMG_Keccak.Test;