blob: 8873d82be54b0f501fdb18d89ecaf628548b36f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package aes_pkg is
type t_usig_1d is array(natural range <>) of unsigned(7 downto 0);
type t_usig_2d is array(natural range <>, natural range <>) of unsigned(7 downto 0);
constant C_STATE_ROWS : integer := 2;
constant C_STATE_COLS : integer := 2;
subtype st_word is t_usig_1d(0 to C_STATE_COLS - 1);
subtype st_state is t_usig_2d(0 to C_STATE_ROWS - 1, 0 to C_STATE_COLS - 1);
subtype st_sbox is t_usig_1d(0 to 255);
type t_key is array(natural range <>) of st_word;
function mix_columns (a_in : st_state) return st_state;
end package aes_pkg;
package body aes_pkg is
-- FIPS 197, 5.1.3 MixColumns() Transformation
function mix_columns (a_in : st_state) return st_state is
variable a_out : st_state;
begin
for col in 0 to C_STATE_COLS - 1 loop
a_out(0, col) := a_in(0, col) xor
a_in(1, col);
a_out(1, col) := a_in(0, col) xor
a_in(1, col);
end loop;
return a_out;
end mix_columns;
end package body;
|