library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; --- package package rijndael_package is subtype SLV_8 is std_logic_vector(7 downto 0); subtype STATE_TYPE is std_logic_vector(127 downto 0); subtype SLV_128 is std_logic_vector(127 downto 0); subtype SLV_32 is std_logic_vector(31 downto 0); subtype round_type is integer range 0 to 16; function SBOX_LOOKUP (a: SLV_8) return SLV_8; function INV_SBOX_LOOKUP (a: SLV_8) return SLV_8; function BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE; function INV_BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE; function SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE; function INV_SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE; function MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE; function POLY_MULTE_FUNCT (a: SLV_8; b: SLV_8) return SLV_8; function POLY_MULTD_FUNCT (a: SLV_8; b: SLV_8) return SLV_8; function INV_MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE; function ADD_ROUNDKEY_FUNCT (roundkey, state: STATE_TYPE) return STATE_TYPE; function ROUNDKEY_GEN (roundkey: STATE_TYPE; round: round_type) return STATE_TYPE; end package rijndael_package; package body rijndael_package is function SBOX_LOOKUP (a: SLV_8) return SLV_8 is variable temp: SLV_8; ---generation of SBOX begin case a is when x"00" => temp := x"63"; when x"01" => temp := x"7c"; when x"02" => temp := x"77"; when x"03" => temp := x"7b"; when x"04" => temp := x"f2"; when x"05" => temp := x"6b"; when x"06" => temp := x"6f"; when x"07" => temp := x"c5"; when x"08" => temp := x"30"; when x"09" => temp := x"01"; when x"0a" => temp := x"67"; when x"0b" => temp := x"2b"; when x"0c" => temp := x"fe"; when x"0d" => temp := x"d7"; when x"0e" => temp := x"ab"; when x"0f" => temp := x"76"; when x"10" => temp := x"ca"; when x"11" => temp := x"82"; when x"12" => temp := x"c9"; when x"13" => temp := x"7d"; when x"14" => temp := x"fa"; when x"15" => temp := x"59"; when x"16" => temp := x"47"; when x"17" => temp := x"f0"; when x"18" => temp := x"ad"; when x"19" => temp := x"d4"; when x"1a" => temp := x"a2"; when x"1b" => temp := x"af"; when x"1c" => temp := x"9c"; when x"1d" => temp := x"a4"; when x"1e" => temp := x"72"; when x"1f" => temp := x"c0"; when x"20" => temp := x"b7"; when x"21" => temp := x"fd"; when x"22" => temp := x"93"; when x"23" => temp := x"26"; when x"24" => temp := x"36"; when x"25" => temp := x"3f"; when x"26" => temp := x"f7"; when x"27" => temp := x"cc"; when x"28" => temp := x"34"; when x"29" => temp := x"a5"; when x"2a" => temp := x"e5"; when x"2b" => temp := x"f1"; when x"2c" => temp := x"71"; when x"2d" => temp := x"d8"; when x"2e" => temp := x"31"; when x"2f" => temp := x"15"; when x"30" => temp := x"04"; when x"31" => temp := x"c7"; when x"32" => temp := x"23"; when x"33" => temp := x"c3"; when x"34" => temp := x"18"; when x"35" => temp := x"96"; when x"36" => temp := x"05"; when x"37" => temp := x"9a"; when x"38" => temp := x"07"; when x"39" => temp := x"12"; when x"3a" => temp := x"80"; when x"3b" => temp := x"e2"; when x"3c" => temp := x"eb"; when x"3d" => temp := x"27"; when x"3e" => temp := x"b2"; when x"3f" => temp := x"75"; when x"40" => temp := x"09"; when x"41" => temp := x"83"; when x"42" => temp := x"2c"; when x"43" => temp := x"1a"; when x"44" => temp := x"1b"; when x"45" => temp := x"6e"; when x"46" => temp := x"5a"; when x"47" => temp := x"a0"; when x"48" => temp := x"52"; when x"49" => temp := x"3b"; when x"4a" => temp := x"d6"; when x"4b" => temp := x"b3"; when x"4c" => temp := x"29"; when x"4d" => temp := x"e3"; when x"4e" => temp := x"2f"; when x"4f" => temp := x"84"; when x"50" => temp := x"53"; when x"51" => temp := x"d1"; when x"52" => temp := x"00"; when x"53" => temp := x"ed"; when x"54" => temp := x"20"; when x"55" => temp := x"fc"; when x"56" => temp := x"b1"; when x"57" => temp := x"5b"; when x"58" => temp := x"6a"; when x"59" => temp := x"cb"; when x"5a" => temp := x"be"; when x"5b" => temp := x"39"; when x"5c" => temp := x"4a"; when x"5d" => temp := x"4c"; when x"5e" => temp := x"58"; when x"5f" => temp := x"cf"; when x"60" => temp := x"d0"; when x"61" => temp := x"ef"; when x"62" => temp := x"aa"; when x"63" => temp := x"fb"; when x"64" => temp := x"43"; when x"65" => temp := x"4d"; when x"66" => temp := x"33"; when x"67" => temp := x"85"; when x"68" => temp := x"45"; when x"69" => temp := x"f9"; when x"6a" => temp := x"02"; when x"6b" => temp := x"7f"; when x"6c" => temp := x"50"; when x"6d" => temp := x"3c"; when x"6e" => temp := x"9f"; when x"6f" => temp := x"a8"; when x"70" => temp := x"51"; when x"71" => temp := x"a3"; when x"72" => temp := x"40"; when x"73" => temp := x"8f"; when x"74" => temp := x"92"; when x"75" => temp := x"9d"; when x"76" => temp := x"38"; when x"77" => temp := x"f5"; when x"78" => temp := x"bc"; when x"79" => temp := x"b6"; when x"7a" => temp := x"da"; when x"7b" => temp := x"21"; when x"7c" => temp := x"10"; when x"7d" => temp := x"ff"; when x"7e" => temp := x"f3"; when x"7f" => temp := x"d2"; when x"80" => temp := x"cd"; when x"81" => temp := x"0c"; when x"82" => temp := x"13"; when x"83" => temp := x"ec"; when x"84" => temp := x"5f"; when x"85" => temp := x"97"; when x"86" => temp := x"44"; when x"87" => temp := x"17"; when x"88" => temp := x"c4"; when x"89" => temp := x"a7"; when x"8a" => temp := x"7e"; when x"8b" => temp := x"3d"; when x"8c" => temp := x"64"; when x"8d" => temp := x"5d"; when x"8e" => temp := x"19"; when x"8f" => temp := x"73"; when x"90" => temp := x"60"; when x"91" => temp := x"81"; when x"92" => temp := x"4f"; when x"93" => temp := x"dc"; when x"94" => temp := x"22"; when x"95" => temp := x"2a"; when x"96" => temp := x"90"; when x"97" => temp := x"88"; when x"98" => temp := x"46"; when x"99" => temp := x"ee"; when x"9a" => temp := x"b8"; when x"9b" => temp := x"14"; when x"9c" => temp := x"de"; when x"9d" => temp := x"5e"; when x"9e" => temp := x"0b"; when x"9f" => temp := x"db"; when x"a0" => temp := x"e0"; when x"a1" => temp := x"32"; when x"a2" => temp := x"3a"; when x"a3" => temp := x"0a"; when x"a4" => temp := x"49"; when x"a5" => temp := x"06"; when x"a6" => temp := x"24"; when x"a7" => temp := x"5c"; when x"a8" => temp := x"c2"; when x"a9" => temp := x"d3"; when x"aa" => temp := x"ac"; when x"ab" => temp := x"62"; when x"ac" => temp := x"91"; when x"ad" => temp := x"95"; when x"ae" => temp := x"e4"; when x"af" => temp := x"79"; when x"b0" => temp := x"e7"; when x"b1" => temp := x"c8"; when x"b2" => temp := x"37"; when x"b3" => temp := x"6d"; when x"b4" => temp := x"8d"; when x"b5" => temp := x"d5"; when x"b6" => temp := x"4e"; when x"b7" => temp := x"a9"; when x"b8" => temp := x"6c"; when x"b9" => temp := x"56"; when x"ba" => temp := x"f4"; when x"bb" => temp := x"ea"; when x"bc" => temp := x"65"; when x"bd" => temp := x"7a"; when x"be" => temp := x"ae"; when x"bf" => temp := x"08"; when x"c0" => temp := x"ba"; when x"c1" => temp := x"78"; when x"c2" => temp := x"25"; when x"c3" => temp := x"2e"; when x"c4" => temp := x"1c"; when x"c5" => temp := x"a6"; when x"c6" => temp := x"b4"; when x"c7" => temp := x"c6"; when x"c8" => temp := x"e8"; when x"c9" => temp := x"dd"; when x"ca" => temp := x"74"; when x"cb" => temp := x"1f"; when x"cc" => temp := x"4b"; when x"cd" => temp := x"bd"; when x"ce" => temp := x"8b"; when x"cf" => temp := x"8a"; when x"d0" => temp := x"70"; when x"d1" => temp := x"3e"; when x"d2" => temp := x"b5"; when x"d3" => temp := x"66"; when x"d4" => temp := x"48"; when x"d5" => temp := x"03"; when x"d6" => temp := x"f6"; when x"d7" => temp := x"0e"; when x"d8" => temp := x"61"; when x"d9" => temp := x"35"; when x"da" => temp := x"57"; when x"db" => temp := x"b9"; when x"dc" => temp := x"86"; when x"dd" => temp := x"c1"; when x"de" => temp := x"1d"; when x"df" => temp := x"9e"; when x"e0" => temp := x"e1"; when x"e1" => temp := x"f8"; when x"e2" => temp := x"98"; when x"e3" => temp := x"11"; when x"e4" => temp := x"69"; when x"e5" => temp := x"d9"; when x"e6" => temp := x"8e"; when x"e7" => temp := x"94"; when x"e8" => temp := x"9b"; when x"e9" => temp := x"1e"; when x"ea" => temp := x"87"; when x"eb" => temp := x"e9"; when x"ec" => temp := x"ce"; when x"ed" => temp := x"55"; when x"ee" => temp := x"28"; when x"ef" => temp := x"df"; when x"f0" => temp := x"8c"; when x"f1" => temp := x"a1"; when x"f2" => temp := x"89"; when x"f3" => temp := x"0d"; when x"f4" => temp := x"bf"; when x"f5" => temp := x"e6"; when x"f6" => temp := x"42"; when x"f7" => temp := x"68"; when x"f8" => temp := x"41"; when x"f9" => temp := x"99"; when x"fa" => temp := x"2d"; when x"fb" => temp := x"0f"; when x"fc" => temp := x"b0"; when x"fd" => temp := x"54"; when x"fe" => temp := x"bb"; when x"ff" => temp := x"16"; when others => null; end case; return temp; end function SBOX_LOOKUP; ---- generation of inverse SBOX function INV_SBOX_LOOKUP (a: SLV_8) return SLV_8 is variable temp: SLV_8; begin case a is when x"00" => temp := x"52"; when x"01" => temp := x"09"; when x"02" => temp := x"6a"; when x"03" => temp := x"d5"; when x"04" => temp := x"30"; when x"05" => temp := x"36"; when x"06" => temp := x"a5"; when x"07" => temp := x"38"; when x"08" => temp := x"bf"; when x"09" => temp := x"40"; when x"0a" => temp := x"a3"; when x"0b" => temp := x"9e"; when x"0c" => temp := x"81"; when x"0d" => temp := x"f3"; when x"0e" => temp := x"d7"; when x"0f" => temp := x"fb"; when x"10" => temp := x"7c"; when x"11" => temp := x"e3"; when x"12" => temp := x"39"; when x"13" => temp := x"82"; when x"14" => temp := x"9b"; when x"15" => temp := x"2f"; when x"16" => temp := x"ff"; when x"17" => temp := x"87"; when x"18" => temp := x"34"; when x"19" => temp := x"8e"; when x"1a" => temp := x"43"; when x"1b" => temp := x"44"; when x"1c" => temp := x"c4"; when x"1d" => temp := x"de"; when x"1e" => temp := x"e9"; when x"1f" => temp := x"cb"; when x"20" => temp := x"54"; when x"21" => temp := x"7b"; when x"22" => temp := x"94"; when x"23" => temp := x"32"; when x"24" => temp := x"a6"; when x"25" => temp := x"c2"; when x"26" => temp := x"23"; when x"27" => temp := x"3d"; when x"28" => temp := x"ee"; when x"29" => temp := x"4c"; when x"2a" => temp := x"95"; when x"2b" => temp := x"0b"; when x"2c" => temp := x"42"; when x"2d" => temp := x"fa"; when x"2e" => temp := x"c3"; when x"2f" => temp := x"49"; when x"30" => temp := x"08"; when x"31" => temp := x"2e"; when x"32" => temp := x"a1"; when x"33" => temp := x"66"; when x"34" => temp := x"28"; when x"35" => temp := x"d9"; when x"36" => temp := x"24"; when x"37" => temp := x"b2"; when x"38" => temp := x"76"; when x"39" => temp := x"5b"; when x"3a" => temp := x"a2"; when x"3b" => temp := x"49"; when x"3c" => temp := x"6d"; when x"3d" => temp := x"8b"; when x"3e" => temp := x"d1"; when x"40" => temp := x"72"; when x"41" => temp := x"f8"; when x"42" => temp := x"f6"; when x"43" => temp := x"64"; when x"44" => temp := x"86"; when x"45" => temp := x"68"; when x"46" => temp := x"98"; when x"47" => temp := x"16"; when x"48" => temp := x"d4"; when x"49" => temp := x"a4"; when x"4a" => temp := x"5c"; when x"4b" => temp := x"cc"; when x"4c" => temp := x"5d"; when x"4d" => temp := x"65"; when x"4e" => temp := x"b6"; when x"4f" => temp := x"92"; when x"50" => temp := x"6c"; when x"51" => temp := x"70"; when x"52" => temp := x"48"; when x"53" => temp := x"50"; when x"54" => temp := x"fd"; when x"55" => temp := x"ed"; when x"56" => temp := x"b9"; when x"57" => temp := x"da"; when x"58" => temp := x"5e"; when x"59" => temp := x"15"; when x"5a" => temp := x"46"; when x"5b" => temp := x"57"; when x"5c" => temp := x"a7"; when x"5d" => temp := x"8d"; when x"5e" => temp := x"9d"; when x"5f" => temp := x"84"; when x"60" => temp := x"90"; when x"61" => temp := x"d8"; when x"62" => temp := x"ab"; when x"63" => temp := x"00"; when x"64" => temp := x"8c"; when x"65" => temp := x"bc"; when x"66" => temp := x"d3"; when x"67" => temp := x"0a"; when x"68" => temp := x"f7"; when x"69" => temp := x"e4"; when x"6a" => temp := x"58"; when x"6b" => temp := x"05"; when x"6c" => temp := x"b8"; when x"6d" => temp := x"b3"; when x"6e" => temp := x"45"; when x"6f" => temp := x"06"; when x"70" => temp := x"d0"; when x"71" => temp := x"2c"; when x"72" => temp := x"1e"; when x"73" => temp := x"8f"; when x"74" => temp := x"ca"; when x"75" => temp := x"3f"; when x"76" => temp := x"0f"; when x"77" => temp := x"02"; when x"78" => temp := x"c1"; when x"79" => temp := x"af"; when x"7a" => temp := x"bd"; when x"7b" => temp := x"03"; when x"7c" => temp := x"01"; when x"7d" => temp := x"13"; when x"7e" => temp := x"8a"; when x"7f" => temp := x"6b"; when x"80" => temp := x"3a"; when x"81" => temp := x"91"; when x"82" => temp := x"11"; when x"83" => temp := x"41"; when x"84" => temp := x"4f"; when x"85" => temp := x"67"; when x"86" => temp := x"dc"; when x"87" => temp := x"ea"; when x"88" => temp := x"97"; when x"89" => temp := x"f2"; when x"8a" => temp := x"cf"; when x"8b" => temp := x"ce"; when x"8c" => temp := x"f0"; when x"8d" => temp := x"b4"; when x"8e" => temp := x"e6"; when x"8f" => temp := x"73"; when x"90" => temp := x"96"; when x"91" => temp := x"ac"; when x"92" => temp := x"74"; when x"93" => temp := x"22"; when x"94" => temp := x"e7"; when x"95" => temp := x"ad"; when x"96" => temp := x"35"; when x"97" => temp := x"85"; when x"98" => temp := x"e2"; when x"99" => temp := x"f9"; when x"9a" => temp := x"37"; when x"9b" => temp := x"e8"; when x"9c" => temp := x"1c"; when x"9d" => temp := x"75"; when x"9e" => temp := x"df"; when x"9f" => temp := x"6e"; when x"a0" => temp := x"47"; when x"a1" => temp := x"f1"; when x"a2" => temp := x"1a"; when x"a3" => temp := x"71"; when x"a4" => temp := x"1d"; when x"a5" => temp := x"29"; when x"a6" => temp := x"c5"; when x"a7" => temp := x"89"; when x"a8" => temp := x"6f"; when x"a9" => temp := x"b7"; when x"aa" => temp := x"62"; when x"ab" => temp := x"0e"; when x"ac" => temp := x"aa"; when x"ad" => temp := x"18"; when x"ae" => temp := x"be"; when x"af" => temp := x"1b"; when x"b0" => temp := x"fc"; when x"b1" => temp := x"56"; when x"b2" => temp := x"3e"; when x"b3" => temp := x"4b"; when x"b4" => temp := x"c6"; when x"b5" => temp := x"d2"; when x"b6" => temp := x"79"; when x"b7" => temp := x"20"; when x"b8" => temp := x"9a"; when x"b9" => temp := x"db"; when x"ba" => temp := x"c0"; when x"bb" => temp := x"fe"; when x"bc" => temp := x"78"; when x"bd" => temp := x"cd"; when x"be" => temp := x"5a"; when x"bf" => temp := x"f4"; when x"c0" => temp := x"1f"; when x"c1" => temp := x"dd"; when x"c2" => temp := x"a8"; when x"c3" => temp := x"33"; when x"c4" => temp := x"88"; when x"c5" => temp := x"07"; when x"c6" => temp := x"c7"; when x"c7" => temp := x"31"; when x"c8" => temp := x"b1"; when x"c9" => temp := x"12"; when x"ca" => temp := x"10"; when x"cb" => temp := x"59"; when x"cc" => temp := x"27"; when x"cd" => temp := x"80"; when x"ce" => temp := x"ec"; when x"cf" => temp := x"5f"; when x"d0" => temp := x"60"; when x"d1" => temp := x"51"; when x"d2" => temp := x"7f"; when x"d3" => temp := x"a9"; when x"d4" => temp := x"19"; when x"d5" => temp := x"b5"; when x"d6" => temp := x"4a"; when x"d7" => temp := x"0d"; when x"d8" => temp := x"2d"; when x"d9" => temp := x"e5"; when x"da" => temp := x"7a"; when x"db" => temp := x"9f"; when x"dc" => temp := x"93"; when x"dd" => temp := x"c9"; when x"de" => temp := x"9c"; when x"df" => temp := x"ef"; when x"e0" => temp := x"a0"; when x"e1" => temp := x"e0"; when x"e2" => temp := x"3b"; when x"e3" => temp := x"4d"; when x"e4" => temp := x"ae"; when x"e5" => temp := x"2a"; when x"e6" => temp := x"f5"; when x"e7" => temp := x"b0"; when x"e8" => temp := x"c8"; when x"e9" => temp := x"eb"; when x"ea" => temp := x"bb"; when x"eb" => temp := x"3c"; when x"ec" => temp := x"83"; when x"ed" => temp := x"53"; when x"ee" => temp := x"99"; when x"ef" => temp := x"61"; when x"f0" => temp := x"17"; when x"f1" => temp := x"2b"; when x"f2" => temp := x"04"; when x"f3" => temp := x"7e"; when x"f4" => temp := x"ba"; when x"f5" => temp := x"77"; when x"f6" => temp := x"d6"; when x"f7" => temp := x"26"; when x"f8" => temp := x"e1"; when x"f9" => temp := x"69"; when x"fa" => temp := x"14"; when x"fb" => temp := x"63"; when x"fc" => temp := x"55"; when x"fd" => temp := x"21"; when x"fe" => temp := x"0c"; when x"ff" => temp := x"7d"; when others => null; end case; return temp; end function INV_SBOX_LOOKUP; --- Byte Substitution Function function BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable b: STATE_TYPE; variable temp: STATE_TYPE; begin b(127 downto 120) := SBOX_LOOKUP(state(127 downto 120)); b(119 downto 112) := SBOX_LOOKUP(state(119 downto 112)); b(111 downto 104) := SBOX_LOOKUP(state(111 downto 104)); b(103 downto 96) := SBOX_LOOKUP(state(103 downto 96)); b(95 downto 88) := SBOX_LOOKUP(state(95 downto 88)); b(87 downto 80) := SBOX_LOOKUP(state(87 downto 80)); b(79 downto 72) := SBOX_LOOKUP(state(79 downto 72)); b(71 downto 64) := SBOX_LOOKUP(state(71 downto 64)); b(63 downto 56) := SBOX_LOOKUP(state(63 downto 56)); b(55 downto 48) := SBOX_LOOKUP(state(55 downto 48)); b(47 downto 40) := SBOX_LOOKUP(state(47 downto 40)); b(39 downto 32) := SBOX_LOOKUP(state(39 downto 32)); b(31 downto 24) := SBOX_LOOKUP(state(31 downto 24)); b(23 downto 16) := SBOX_LOOKUP(state(23 downto 16)); b(15 downto 8) := SBOX_LOOKUP(state(15 downto 8)); b(7 downto 0) := SBOX_LOOKUP(state(7 downto 0)); temp:=b; return temp; end function BYTE_SUB_FUNCT; ---Inverse Byte substituion function INV_BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable b: STATE_TYPE; variable temp: STATE_TYPE; begin b(127 downto 120) := INV_SBOX_LOOKUP(state(127 downto 120)); b(119 downto 112) := INV_SBOX_LOOKUP(state(119 downto 112)); b(111 downto 104) := INV_SBOX_LOOKUP(state(111 downto 104)); b(103 downto 96) := INV_SBOX_LOOKUP(state(103 downto 96)); b(95 downto 88) := INV_SBOX_LOOKUP(state(95 downto 88)); b(87 downto 80) := INV_SBOX_LOOKUP(state(87 downto 80)); b(79 downto 72) := INV_SBOX_LOOKUP(state(79 downto 72)); b(71 downto 64) := INV_SBOX_LOOKUP(state(71 downto 64)); b(63 downto 56) := INV_SBOX_LOOKUP(state(63 downto 56)); b(55 downto 48) := INV_SBOX_LOOKUP(state(55 downto 48)); b(47 downto 40) := INV_SBOX_LOOKUP( state(47 downto 40)); b(39 downto 32) := INV_SBOX_LOOKUP(state(39 downto 32)); b(31 downto 24) := INV_SBOX_LOOKUP(state(31 downto 24)); b(23 downto 16) := INV_SBOX_LOOKUP(state(23 downto 16)); b(15 downto 8) := INV_SBOX_LOOKUP(state(15 downto 8)); b(7 downto 0) := INV_SBOX_LOOKUP(state(7 downto 0)); temp:=b; return temp; end function INV_BYTE_SUB_FUNCT; ---Shift Row function function SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable a: STATE_TYPE; variable temp: STATE_TYPE; begin temp(127 downto 120) := state(127 downto 120); --t0 temp(119 downto 112) := state(87 downto 80); --t1 temp(111 downto 104) := state(47 downto 40); --t2 temp(103 downto 96) := state(7 downto 0); --t3 temp(95 downto 88) := state(95 downto 88); --t4 temp(87 downto 80) := state(55 downto 48); --t5 temp(79 downto 72) := state(15 downto 8); --t6 temp(71 downto 64) := state(103 downto 96); --t7 temp(63 downto 56) := state(63 downto 56); --t8 temp(55 downto 48) := state(23 downto 16); --t9 temp(47 downto 40) := state(111 downto 104); --t10 temp(39 downto 32) := state(71 downto 64); --t11 temp(31 downto 24) := state(31 downto 24); --t12 temp(23 downto 16) := state(119 downto 112); --t13 temp(15 downto 8) := state(79 downto 72); --t14 temp(7 downto 0) := state(39 downto 32); --t15 a:=temp; return a; end function SHIFT_ROW_FUNCT; ---Inverse Shift Row function INV_SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable a: STATE_TYPE; variable temp: STATE_TYPE; begin temp(127 downto 120) := state(127 downto 120); --t0 temp(119 downto 112) := state(23 downto 16); --t1 temp(111 downto 104) := state(47 downto 40); --t2 temp(103 downto 96) := state(71 downto 64); --t3 temp(95 downto 88) := state(95 downto 88); --t4 temp(87 downto 80) := state(119 downto 112); --t5 temp(79 downto 72) := state(15 downto 8); --t6 temp(71 downto 64) := state(39 downto 32); --t7 temp(63 downto 56) := state(63 downto 56); --t8 temp(55 downto 48) := state(87 downto 80); --t9 temp(47 downto 40) := state(111 downto 104); --t10 temp(39 downto 32) := state(7 downto 0); --t11 temp(31 downto 24) := state(31 downto 24); --t12 temp(23 downto 16) := state(55 downto 48); --t13 temp(15 downto 8) := state(79 downto 72); --t14 temp(7 downto 0) := state(103 downto 96); --t15 a := temp; return a; end function INV_SHIFT_ROW_FUNCT; --- Mix Column function MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable t0: SLV_8; variable t1: SLV_8; variable t2: SLV_8; variable t3: SLV_8; variable t4: SLV_8; variable t5: SLV_8; variable t6: SLV_8; variable t7: SLV_8; variable t8: SLV_8; variable t9: SLV_8; variable t10: SLV_8; variable t11: SLV_8; variable t12: SLV_8; variable t13: SLV_8; variable t14: SLV_8; variable t15: SLV_8; variable DATAOUT: SLV_128; variable temp: SLV_128; begin t0 := state(127 downto 120); t1 := state(119 downto 112); t2 := state(111 downto 104); t3 := state(103 downto 96); t4 := state(95 downto 88); t5 := state(87 downto 80); t6 := state(79 downto 72); t7:= state(71 downto 64); t8 := state(63 downto 56); t9 := state(55 downto 48); t10 := state(47 downto 40); t11 := state(39 downto 32); t12 := state(31 downto 24); t13 := state(23 downto 16); t14 := state(15 downto 8); t15 := state(7 downto 0); DATAOUT(127 downto 120) := POLY_MULTE_FUNCT("00000010", t0) xor POLY_MULTE_FUNCT("00000011", t1) xor t2 xor t3; DATAOUT(119 downto 112) := t0 xor POLY_MULTE_FUNCT("00000010", t1) xor POLY_MULTE_FUNCT("00000011", t2) xor t3; DATAOUT(111 downto 104) := POLY_MULTE_FUNCT("00000010" , t2) xor POLY_MULTE_FUNCT("00000011", t3) xor t0 xor t1; DATAOUT(103 downto 96) := POLY_MULTE_FUNCT("00000011" , t0) xor POLY_MULTE_FUNCT("00000010", t3) xor t1 xor t2; DATAOUT(95 downto 88) := POLY_MULTE_FUNCT("00000010" , t4) xor POLY_MULTE_FUNCT("00000011", t5) xor t6 xor t7; DATAOUT(87 downto 80) := POLY_MULTE_FUNCT("00000010" , t5) xor POLY_MULTE_FUNCT("00000011" , t6) xor t4 xor t7; DATAOUT(79 downto 72) := POLY_MULTE_FUNCT("00000010" , t6) xor POLY_MULTE_FUNCT("00000011", t7) xor t4 xor t5; DATAOUT(71 downto 64) := POLY_MULTE_FUNCT("00000011" , t4) xor POLY_MULTE_FUNCT("00000010", t7) xor t5 xor t6; DATAOUT(63 downto 56) := POLY_MULTE_FUNCT("00000010", t8) xor POLY_MULTE_FUNCT("00000011", t9) xor t10 xor t11; DATAOUT(55 downto 48) := POLY_MULTE_FUNCT("00000010", t9) xor POLY_MULTE_FUNCT("00000011", t10) xor t8 xor t11; DATAOUT(47 downto 40) := POLY_MULTE_FUNCT("00000010", t10) xor POLY_MULTE_FUNCT("00000011", t11) xor t8 xor t9; DATAOUT(39 downto 32) := POLY_MULTE_FUNCT("00000011", t8) xor POLY_MULTE_FUNCT("00000010", t11) xor t9 xor t10; DATAOUT(31 downto 24) := POLY_MULTE_FUNCT("00000010", t12) xor POLY_MULTE_FUNCT("00000011", t13) xor t14 xor t15; DATAOUT(23 downto 16) := POLY_MULTE_FUNCT("00000010",t13) xor POLY_MULTE_FUNCT("00000011",t14) xor t12 xor t15; DATAOUT(15 downto 8) := POLY_MULTE_FUNCT("00000010", t14) xor POLY_MULTE_FUNCT("00000011", t15) xor t12 xor t13; DATAOUT(7 downto 0) := POLY_MULTE_FUNCT("00000011", t12) xor POLY_MULTE_FUNCT("00000010", t15) xor t13 xor t14; temp:=DATAOUT; return temp; end function MIX_COLUMN_FUNCT; --- Inverse Mix Column Function function INV_MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE is variable t0: SLV_8; variable t1: SLV_8; variable t2: SLV_8; variable t3: SLV_8; variable t4: SLV_8; variable t5: SLV_8; variable t6: SLV_8; variable t7: SLV_8; variable t8: SLV_8; variable t9: SLV_8; variable t10: SLV_8; variable t11: SLV_8; variable t12: SLV_8; variable t13: SLV_8; variable t14: SLV_8; variable t15: SLV_8; variable b: STATE_TYPE; variable temp: STATE_TYPE; begin t0 := state(127 downto 120); t1 := state(119 downto 112); t2 := state(111 downto 104); t3 := state(103 downto 96); t4 := state(95 downto 88); t5 := state(87 downto 80); t6 := state(79 downto 72); t7 := state(71 downto 64); t8 := state(63 downto 56); t9 := state(55 downto 48); t10 := state(47 downto 40); t11 := state(39 downto 32); t12 := state(31 downto 24); t13 := state(23 downto 16); t14 := state(15 downto 8); t15 := state(7 downto 0); b(127 downto 120) := POLY_MULTD_FUNCT("00001110", t0) xor POLY_MULTD_FUNCT("00001011", t1) xor POLY_MULTD_FUNCT("00001101", t2) xor POLY_MULTD_FUNCT("00001001", t3); b(119 downto 112) := POLY_MULTD_FUNCT("00001001", t0) xor POLY_MULTD_FUNCT("00001110", t1) xor POLY_MULTD_FUNCT("00001011", t2) xor POLY_MULTD_FUNCT("00001101", t3); b(111 downto 104) := POLY_MULTD_FUNCT("00001101", t0) xor POLY_MULTD_FUNCT("00001001", t1) xor POLY_MULTD_FUNCT("00001110", t2) xor POLY_MULTD_FUNCT("00001011", t3); b(103 downto 96) := POLY_MULTD_FUNCT("00001011", t0) xor POLY_MULTD_FUNCT("00001101", t1) xor POLY_MULTD_FUNCT("00001001", t2) xor POLY_MULTD_FUNCT("00001110", t3); b(95 downto 88) := POLY_MULTD_FUNCT("00001110", t4) xor POLY_MULTD_FUNCT("00001011", t5) xor POLY_MULTD_FUNCT("00001101", t6) xor POLY_MULTD_FUNCT("00001001", t7) ; b(87 downto 80) := POLY_MULTD_FUNCT("00001001", t4) xor POLY_MULTD_FUNCT("00001110", t5) xor POLY_MULTD_FUNCT("00001011", t6) xor POLY_MULTD_FUNCT("00001101", t7); b(79 downto 72) := POLY_MULTD_FUNCT("00001101", t4) xor POLY_MULTD_FUNCT("00001001", t5) xor POLY_MULTD_FUNCT("00001110", t6) xor POLY_MULTD_FUNCT("00001011", t7); b(71 downto 64) := POLY_MULTD_FUNCT("00001011", t4) xor POLY_MULTD_FUNCT("00001101", t5) xor POLY_MULTD_FUNCT("00001001", t6) xor POLY_MULTD_FUNCT("00001110", t7); b(63 downto 56) := POLY_MULTD_FUNCT("00001110", t8) xor POLY_MULTD_FUNCT("00001011", t9) xor POLY_MULTD_FUNCT("00001101", t10) xor POLY_MULTD_FUNCT("00001001", t11) ; b(55 downto 48) := POLY_MULTD_FUNCT("00001001", t8) xor POLY_MULTD_FUNCT("00001110", t9) xor POLY_MULTD_FUNCT("00001011", t10) xor POLY_MULTD_FUNCT("00001101", t11); b(47 downto 40) := POLY_MULTD_FUNCT("00001101", t8) xor POLY_MULTD_FUNCT("00001001", t9) xor POLY_MULTD_FUNCT("00001110", t10) xor POLY_MULTD_FUNCT("00001011", t11); b(39 downto 32) := POLY_MULTD_FUNCT("00001011", t8) xor POLY_MULTD_FUNCT("00001101", t9) xor POLY_MULTD_FUNCT("00001001", t10) xor POLY_MULTD_FUNCT("00001110", t11); b(31 downto 24) := POLY_MULTD_FUNCT("00001110", t12) xor POLY_MULTD_FUNCT("00001011", t13) xor POLY_MULTD_FUNCT("00001101", t14) xor POLY_MULTD_FUNCT("00001001", t15); b(23 downto 16) := POLY_MULTD_FUNCT("00001001", t12) xor POLY_MULTD_FUNCT("00001110", t13) xor POLY_MULTD_FUNCT("00001011", t14) xor POLY_MULTD_FUNCT("00001101", t15); b(15 downto 8) := POLY_MULTD_FUNCT("00001101", t12) xor POLY_MULTD_FUNCT("00001001", t13) xor POLY_MULTD_FUNCT("00001110", t14) xor POLY_MULTD_FUNCT("00001011", t15); b(7 downto 0) := POLY_MULTD_FUNCT("00001011", t12) xor POLY_MULTD_FUNCT("00001101", t13) xor POLY_MULTD_FUNCT("00001001", t14) xor POLY_MULTD_FUNCT("00001110", t15); temp:=b; return temp; end function INV_MIX_COLUMN_FUNCT; --- function POLY_MULTE_FUNCT (a: SLV_8; b : SLV_8 ) return SLV_8 is variable temp : SLV_8; variable temp1 : SLV_8; variable temp2 : SLV_8; variable temp3 : SLV_8; variable and_mask : SLV_8; begin and_mask := b(7) & b(7) & b(7) & b(7) & b(7) & b(7) & b(7) & b(7); case a(3 downto 0) is when "0001" => temp := b; when "0010" =>temp := b(6 downto 0) & '0' xor (("00011011") and and_mask); when "0011"=> temp := b(6 downto 0) & '0' xor (("00011011") and and_mask) xor b; when others => temp := (others => '0'); end case; return temp; end function POLY_MULTE_FUNCT; --- POLYNOMIAL Multi function POLY_MULTD_FUNCT (a: SLV_8; b: SLV_8) return SLV_8 is variable temp: SLV_8; variable temp1: SLV_8; variable temp2: SLV_8; variable temp3: SLV_8; variable and_mask: SLV_8; begin and_mask := b(7) & b(7) & b(7) & b(7) & b(7) & b(7) & b(7) & b(7); case a(3 downto 0) is when "1001"=> temp1 := b(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7); temp2 := temp1(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto 0) & '0' xor (("00011011") and and_mask); temp := temp3 xor b; when "1011"=> temp1 := b(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7); temp2 := temp1(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto 0) & '0' xor (("00011011") and and_mask); temp := temp1 xor temp3 xor b; when "1101" => temp1 := b(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7); temp2 := temp1(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto 0) & '0' xor (("00011011") and and_mask); temp := temp2 xor temp3 xor b; when "1110"=> temp1 := b(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7) & temp1(7); temp2 := temp1(6 downto 0) & '0' xor (("00011011") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto 0) & '0' xor (("00011011") and and_mask); temp := temp1 xor temp2 xor temp3; when others => temp := (others => '0'); end case; return temp; end function POLY_MULTD_FUNCT; ---Add round key function ADD_ROUNDKEY_FUNCT (roundkey: STATE_TYPE; state: STATE_TYPE) return STATE_TYPE is variable b: STATE_TYPE; begin b := state xor roundkey; return b; end function ADD_ROUNDKEY_FUNCT; --- Round key genertion function ROUNDKEY_GEN (roundkey: STATE_TYPE; round: round_type) return STATE_TYPE is variable b: STATE_TYPE; variable b0:SLV_8; variable b1:SLV_8; variable b2:SLV_8; variable b3:SLV_8; begin b0 := roundkey(31 downto 24); b1 := roundkey(23 downto 16); b2 := roundkey(15 downto 8); b3 := roundkey(7 downto 0); case round is when 1 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00000001" xor roundkey(127 downto 120); b(119 downto 112) := SBOX_LOOKUP(b2)xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 2 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00000010" xor roundkey(127 downto 120); b(119 downto 112):= SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 3 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00000100" xor roundkey(127 downto 120); b(119 downto 112):= SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 4 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00001000" xor roundkey(127 downto 120); b(119 downto 112) := SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 5 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00010000" xor roundkey(127 downto 120); b(119 downto 112) := SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 6 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00100000" xor roundkey(127 downto 120); b(119 downto 112) := SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 7 =>b(127 downto 120) := SBOX_LOOKUP(b1) xor "01000000" xor roundkey(127 downto 120) ; b(119 downto 112):= SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 8 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "10000000" xor roundkey(127 downto 120) ; b(119 downto 112) := SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 9 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00011011" xor roundkey(127 downto 120); b(119 downto 112):= SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when 10 => b(127 downto 120) := SBOX_LOOKUP(b1) xor "00110110" xor roundkey(127 downto 120); b(119 downto 112) := SBOX_LOOKUP(b2) xor roundkey(119 downto 112); b(111 downto 104) := SBOX_LOOKUP(b3) xor roundkey(111 downto 104); b(103 downto 96) := SBOX_LOOKUP(b0) xor roundkey(103 downto 96); b(95 downto 64) := b(127 downto 96) xor roundkey(95 downto 64); b(63 downto 32) := b(95 downto 64) xor roundkey(63 downto 32); b(31 downto 0) := b(63 downto 32) xor roundkey(31 downto 0); when others => null; end case; return b; end function ROUNDKEY_GEN; end package body rijndael_package; ---S-Box Transformation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity byte_sub is port (state: in STD_LOGIC_VECTOR(7 downto 0); clk: in std_logic; rst: in std_logic; b: out STD_LOGIC_VECTOR(7 downto 0)); end entity byte_sub; architecture top_aes_RTL of byte_sub is begin process (clk) is begin if rst = '1' then b <= (others => '0'); elsif (clk='1' and clk'event) then b <= SBOX_LOOKUP( state); end if; end process; end architecture top_aes_RTL; ---Shift Row Transformation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity shift_row is port (state: in STD_LOGIC_VECTOR(127 downto 0); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(127 downto 0)); end entity shift_row; architecture top_aes_RTL of shift_row is begin process (clk) is begin if rst = '1' then DATAOUT <= (others => '0'); elsif (clk='1' and clk'event) then DATAOUT <= SHIFT_ROW_FUNCT(state); end if; end process; end architecture top_aes_RTL; ---Mix Column Transformation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity mix_column is port (state: in STD_LOGIC_VECTOR(127 downto 0); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(127 downto 0)); end entity mix_column; architecture top_aes_RTL of mix_column is begin process (clk) is begin if rst = '1' then DATAOUT <= (others => '0'); elsif (clk='1' and clk'event) then DATAOUT <= MIX_COLUMN_FUNCT(state); end if; end process; end architecture top_aes_RTL; ---Key Generation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity key_gen is port (roundkey: in STD_LOGIC_VECTOR(127 downto 0); round: in round_type; DATAOUT: out STD_LOGIC_VECTOR(127 downto 0)); end entity key_gen; architecture top_aes_RTL of key_gen is begin process (roundkey, round) is begin DATAOUT <= ROUNDKEY_GEN(roundkey, round); end process; end architecture top_aes_RTL; ---Inverse S-BOX library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_byte_sub is port (state: IN STD_LOGIC_VECTOR(7 downto 0); clk: in std_logic; rst: in std_logic; b: out STD_LOGIC_VECTOR(7 downto 0)); end entity inv_byte_sub; architecture top_aes_RTL of inv_byte_sub is begin process (clk) is begin if rst = '1' then b <= ( others => '0' ); elsif (clk='1' and clk'event) then b <= INV_SBOX_LOOKUP( state); end if; end process; end architecture top_aes_RTL; ---Inverse Shift Row Transformation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_shift_row is port (state: in STD_LOGIC_VECTOR(127 downto 0); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(127 downto 0)); end entity inv_shift_row; architecture top_aes_RTL of inv_shift_row is begin process (clk) is begin if rst = '1' then DATAOUT <= (others => '0'); elsif (clk='1' and clk'event) then DATAOUT <= INV_SHIFT_ROW_FUNCT(state); end if; end process; end architecture top_aes_RTL; ---Inverse Mix Column Transformation library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_mix_column is port (state: in STD_LOGIC_VECTOR(127 downto 0); clk: in std_logic; rst: in std_logic; DATAOUT : out STD_LOGIC_VECTOR(127 downto 0)); end entity inv_mix_column; architecture top_aes_RTL of inv_mix_column is begin process (clk) is begin if rst = '1' then DATAOUT <= ( others => '0' ); elsif (clk='1' and clk'event) then DATAOUT <= INV_MIX_COLUMN_FUNCT(state); end if; end process; end architecture top_aes_RTL;