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: First stage of key expansion
|
-- Description: First stage of key expansion
|
-- Ports:
|
-- Ports:
|
Line 69... |
Line 69... |
use work.aes_pkg.all;
|
use work.aes_pkg.all;
|
|
|
entity keysched1 is
|
entity keysched1 is
|
port(
|
port(
|
clk: in std_logic;
|
clk: in std_logic;
|
|
rst: in std_logic;
|
roundkey: in datablock;
|
roundkey: in datablock;
|
rcon: in std_logic_vector(7 downto 0);
|
rcon: in std_logic_vector(7 downto 0);
|
fc3: out blockcol;
|
fc3: out blockcol;
|
c0: out blockcol;
|
c0: out blockcol;
|
c1: out blockcol;
|
c1: out blockcol;
|
Line 85... |
Line 86... |
signal subst: blockcol;
|
signal subst: blockcol;
|
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
|
signal key0, key1, key2, key3: std_logic_vector(7 downto 0);
|
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;
|
signal rcon_d: std_logic_vector(7 downto 0);
|
signal rcon_d: std_logic_vector(7 downto 0);
|
begin
|
begin
|
sub0: sbox port map(
|
sub0: sbox port map(
|
clk => clk,
|
clk => clk,
|
|
rst => rst,
|
bytein => roundkey(0, 3),
|
bytein => roundkey(0, 3),
|
byteout => subst(3)
|
byteout => subst(3)
|
);
|
);
|
sub1: sbox port map(
|
sub1: sbox port map(
|
clk => clk,
|
clk => clk,
|
|
rst => rst,
|
bytein => roundkey(1, 3),
|
bytein => roundkey(1, 3),
|
byteout => subst(0)
|
byteout => subst(0)
|
);
|
);
|
sub2: sbox port map(
|
sub2: sbox port map(
|
clk => clk,
|
clk => clk,
|
|
rst => rst,
|
bytein => roundkey(2, 3),
|
bytein => roundkey(2, 3),
|
byteout => subst(1)
|
byteout => subst(1)
|
);
|
);
|
sub3: sbox port map(
|
sub3: sbox port map(
|
clk => clk,
|
clk => clk,
|
|
rst => rst,
|
bytein => roundkey(3, 3),
|
bytein => roundkey(3, 3),
|
byteout => subst(2)
|
byteout => subst(2)
|
);
|
);
|
fc3(0) <= subst(0) xor rcon_d;
|
fc3(0) <= subst(0) xor rcon_d;
|
fc3(1) <= subst(1);
|
fc3(1) <= subst(1);
|
fc3(2) <= subst(2);
|
fc3(2) <= subst(2);
|
fc3(3) <= subst(3);
|
fc3(3) <= subst(3);
|
process(clk)
|
process(clk,rst)
|
begin
|
begin
|
if(rising_edge(clk)) then
|
if(rst = '1') then
|
|
rcon_d <= X"00";
|
|
c0 <= zero_col;
|
|
c1 <= zero_col;
|
|
c2 <= zero_col;
|
|
c3 <= zero_col;
|
|
elsif(rising_edge(clk)) then
|
rcon_d <= rcon;
|
rcon_d <= rcon;
|
for j in 3 downto 0 loop
|
for j in 3 downto 0 loop
|
c0(j) <= roundkey(j, 0);
|
c0(j) <= roundkey(j, 0);
|
c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
|
c1(j) <= roundkey(j, 0) xor roundkey(j, 1);
|
c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
|
c2(j) <= roundkey(j, 0) xor roundkey(j, 1) xor roundkey(j, 2);
|