raw
smg_comms_packing...    1 -- S.MG, 2018
smg_comms_packing... 2
smg_comms_packing... 3 with Raw_Types; use Raw_Types;
smg_comms_packing... 4 with Serpent; use Serpent;
smg_comms_packing... 5
smg_comms_packing... 6 package body Test_Serpent is
smg_comms_packing... 7
smg_comms_packing... 8 procedure Selftest is
smg_comms_packing... 9 K : Key := (others => 0);
smg_comms_packing... 10 P : Block := (others => 0);
smg_comms_packing... 11 P2, C : Block;
smg_comms_packing... 12 W : Key_Schedule;
smg_comms_packing... 13 begin
smg_comms_packing... 14 for I in 1 .. 128 loop
smg_comms_packing... 15 Prepare_Key(K, W);
smg_comms_packing... 16 Encrypt(W, P, C);
smg_comms_packing... 17 Decrypt(W, C, P2);
smg_comms_packing... 18 if (P2 /= P) then
smg_comms_packing... 19 raise Implementation_Error;
smg_comms_packing... 20 end if;
smg_comms_packing... 21 P := K( 0 .. 15);
smg_comms_packing... 22 K( 0 .. 15) := K(16 .. 31);
smg_comms_packing... 23 K(16 .. 31) := C;
smg_comms_packing... 24 end loop;
smg_comms_packing... 25 if C /= (16#A2#, 16#46#, 16#AB#, 16#69#, 16#0A#, 16#E6#, 16#8D#, 16#FB#,
smg_comms_packing... 26 16#02#, 16#04#, 16#CB#, 16#E2#, 16#8E#, 16#D8#, 16#EB#, 16#7A#)
smg_comms_packing... 27 then
smg_comms_packing... 28 raise Implementation_Error;
smg_comms_packing... 29 end if;
smg_comms_packing... 30 end Selftest;
smg_comms_packing... 31 end Test_Serpent;