Line 42... |
Line 42... |
---- ----
|
---- ----
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
------------------------------------------------------
|
------------------------------------------------------
|
-- Project: AESFast
|
-- Project: AESFast
|
-- Author: Subhasis
|
-- Author: Subhasis
|
-- Last Modified: 20/03/10
|
-- Last Modified: 25/03/10
|
-- Email: subhasis256@gmail.com
|
-- Email: subhasis256@gmail.com
|
------------------------------------------------------
|
------------------------------------------------------
|
--
|
--
|
-- Description: The Sbox and Shiftrows step
|
-- Description: The Sbox and Shiftrows step
|
-- Ports:
|
-- Ports:
|
Line 70... |
Line 70... |
use work.aes_pkg.all;
|
use work.aes_pkg.all;
|
|
|
entity sboxshr is
|
entity sboxshr is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
blockin: in datablock;
|
blockin: in datablock;
|
fc3: in blockcol;
|
fc3: in blockcol;
|
c0: in blockcol;
|
c0: in blockcol;
|
c1: in blockcol;
|
c1: in blockcol;
|
c2: in blockcol;
|
c2: in blockcol;
|
Line 85... |
Line 86... |
|
|
architecture rtl of sboxshr is
|
architecture rtl of sboxshr is
|
component sbox is
|
component sbox is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
bytein: in std_logic_vector(7 downto 0);
|
bytein: in std_logic_vector(7 downto 0);
|
byteout: out std_logic_vector(7 downto 0)
|
byteout: out std_logic_vector(7 downto 0)
|
);
|
);
|
end component;
|
end component;
|
begin
|
begin
|
-- The sbox, the output going to the appropriate state byte after shiftrows
|
-- The sbox, the output going to the appropriate state byte after shiftrows
|
g0: for i in 3 downto 0 generate
|
g0: for i in 3 downto 0 generate
|
g1: for j in 3 downto 0 generate
|
g1: for j in 3 downto 0 generate
|
sub: sbox port map(
|
sub: sbox port map(
|
clk => clk,
|
clk => clk,
|
|
rst => rst,
|
bytein => blockin(i,j),
|
bytein => blockin(i,j),
|
byteout => blockout(i,(j-i) mod 4)
|
byteout => blockout(i,(j-i) mod 4)
|
);
|
);
|
end generate;
|
end generate;
|
end generate;
|
end generate;
|
process(clk)
|
process(clk,rst)
|
begin
|
begin
|
if(rising_edge(clk)) then
|
if(rst = '1') then
|
|
nextkey <= zero_data;
|
|
elsif(rising_edge(clk)) then
|
-- col0 of nextkey = fc3 xor col0
|
-- col0 of nextkey = fc3 xor col0
|
-- col1 of nextkey = fc3 xor col0 xor col1
|
-- col1 of nextkey = fc3 xor col0 xor col1
|
-- col2 of nextkey = fc3 xor col0 xor col1 xor col2
|
-- col2 of nextkey = fc3 xor col0 xor col1 xor col2
|
-- col3 of nextkey = fc3 xor col0 xor col1 xor col2 xor col3
|
-- col3 of nextkey = fc3 xor col0 xor col1 xor col2 xor col3
|
genkey: for j in 3 downto 0 loop
|
genkey: for j in 3 downto 0 loop
|