smg_comms_packing... 1
smg_comms_packing... 2
smg_comms_packing... 3
smg_comms_packing... 4
smg_comms_packing... 5
smg_comms_packing... 6 package body Packing is
smg_comms_packing... 7
smg_comms_packing... 8
smg_comms_packing... 9 function Pack( Msg : in Raw_Types.Serpent_Msg;
smg_comms_packing... 10 K : in Serpent.Key )
smg_comms_packing... 11 return Raw_Types.Serpent_Pkt is
smg_comms_packing... 12
smg_comms_packing... 13
smg_comms_packing... 14 Plain : Serpent.Block;
smg_comms_packing... 15 Encr : Serpent.Block;
smg_comms_packing... 16
smg_comms_packing... 17
smg_comms_packing... 18 KS : Serpent.Key_Schedule;
smg_comms_packing... 19
smg_comms_packing... 20
smg_comms_packing... 21 Pkt : Raw_Types.Serpent_Pkt := (others => 0);
smg_comms_packing... 22 begin
smg_comms_packing... 23
smg_comms_packing... 24 Serpent.Prepare_Key( K, KS );
smg_comms_packing... 25
smg_comms_packing... 26
smg_comms_packing... 27 for I in 1 .. S_Blocks loop
smg_comms_packing... 28
smg_comms_packing... 29 Plain := Msg( Msg'First + (I-1) * Block_Len ..
smg_comms_packing... 30 Msg'First + I * Block_Len - 1 );
smg_comms_packing... 31
smg_comms_packing... 32 Serpent.Encrypt( KS, Plain, Encr );
smg_comms_packing... 33
smg_comms_packing... 34 Pkt( Pkt'First + (I-1) * Block_Len ..
smg_comms_packing... 35 Pkt'First + I * Block_Len - 1 )
smg_comms_packing... 36 := Encr;
smg_comms_packing... 37 end loop;
smg_comms_packing... 38
smg_comms_packing... 39
smg_comms_packing... 40 return Pkt;
smg_comms_packing... 41 end Pack;
smg_comms_packing... 42
smg_comms_packing... 43
smg_comms_packing... 44 function Unpack( Pkt : in Raw_Types.Serpent_Pkt;
smg_comms_packing... 45 K : in Serpent.Key)
smg_comms_packing... 46 return Raw_Types.Serpent_Msg is
smg_comms_packing... 47
smg_comms_packing... 48 Plain : Serpent.Block;
smg_comms_packing... 49 Encr : Serpent.Block;
smg_comms_packing... 50
smg_comms_packing... 51
smg_comms_packing... 52 KS : Serpent.Key_Schedule;
smg_comms_packing... 53
smg_comms_packing... 54
smg_comms_packing... 55 Msg : Raw_Types.Serpent_Msg := (others => 0);
smg_comms_packing... 56 begin
smg_comms_packing... 57
smg_comms_packing... 58 Serpent.Prepare_Key( K, KS );
smg_comms_packing... 59
smg_comms_packing... 60
smg_comms_packing... 61 for I in 1 .. S_Blocks loop
smg_comms_packing... 62
smg_comms_packing... 63 Encr := Pkt( Pkt'First + (I-1) * Block_Len ..
smg_comms_packing... 64 Pkt'First + I * Block_Len - 1 );
smg_comms_packing... 65 Serpent.Decrypt( KS, Encr, Plain );
smg_comms_packing... 66
smg_comms_packing... 67
smg_comms_packing... 68 Msg( Msg'First + (I-1) * Block_Len ..
smg_comms_packing... 69 Msg'First + I * Block_Len - 1 )
smg_comms_packing... 70 := Plain;
smg_comms_packing... 71 end loop;
smg_comms_packing... 72
smg_comms_packing... 73
smg_comms_packing... 74 return Msg;
smg_comms_packing... 75 end Unpack;
smg_comms_packing... 76
smg_comms_packing... 77 end Packing;