OpenCores
URL https://opencores.org/ocsvn/mini_aes/mini_aes/trunk

Subversion Repositories mini_aes

[/] [mini_aes/] [trunk/] [source/] [mix_column.vhdl] - Blame information for rev 12

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 arif_endro
-- $Id: mix_column.vhdl,v 1.1.1.1 2005-12-06 02:48:33 arif_endro Exp $
2
-------------------------------------------------------------------------------
3
-- Title       :
4
-- Project     : Mini AES 128 
5
-------------------------------------------------------------------------------
6
-- File        :
7
-- Author      : "Arif E. Nugroho" <arif_endro@yahoo.com>
8
-- Created     : 2005/12/03
9
-- Last update : 
10
-- Simulators  : ModelSim SE PLUS 6.0
11
-- Synthesizers: ISE Xilinx 6.3i
12
-- Target      : 
13
-------------------------------------------------------------------------------
14
-- Description : 
15
-------------------------------------------------------------------------------
16
-- Copyright (C) 2005 Arif E. Nugroho
17
-- This VHDL design file is an open design; you can redistribute it and/or
18
-- modify it and/or implement it after contacting the author
19
-------------------------------------------------------------------------------
20
-------------------------------------------------------------------------------
21
-- 
22
--         THIS SOURCE FILE MAY BE USED AND DISTRIBUTED WITHOUT RESTRICTION
23
-- PROVIDED THAT THIS COPYRIGHT STATEMENT IS NOT REMOVED FROM THE FILE AND THAT
24
-- ANY DERIVATIVE WORK CONTAINS THE ORIGINAL COPYRIGHT NOTICE AND THE
25
-- ASSOCIATED DISCLAIMER.
26
-- 
27
-------------------------------------------------------------------------------
28
-- 
29
--         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
30
-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31
-- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
32
-- EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
35
-- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
36
-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
37
-- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
38
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
-- 
40
-------------------------------------------------------------------------------
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44
use work.xtime_pkg.all;
45
 
46
entity mix_column is
47
 
48
  port (
49
    s0          : in  std_logic_vector (07 downto 00);
50
    s1          : in  std_logic_vector (07 downto 00);
51
    s2          : in  std_logic_vector (07 downto 00);
52
    s3          : in  std_logic_vector (07 downto 00);
53
    mix_col     : out std_logic_vector (31 downto 00);
54
    inv_mix_col : out std_logic_vector (31 downto 00)
55
    );
56
 
57
end mix_column;
58
 
59
architecture data_flow of mix_column is
60
 
61
  type state is array (03 downto 00) of std_logic_vector (07 downto 00);
62
 
63
  signal mc : state :=
64
    ( X"00", X"00", X"00", X"00" );
65
 
66
begin
67
 
68
  --
69
  -- MixColumn   : a(x)  = {03}x^3 + {01}x^2 + {01}x + {02}
70
  --
71
  -- s'0c = | 02 03 01 01 | s0c
72
  -- s'1c = | 01 02 03 01 | s1c
73
  -- s'2c = | 01 01 02 03 | s2c
74
  -- s'3c = | 03 01 01 02 | s3c
75
  --
76
  -- InvMixColumn: a'(x) = {0B}x^3 + {0D}x^2 + {09}x + {0E}
77
  --               a'(x) = {03}x^3 + {01}x^2 + {01}x + {02} +
78
  --                       {08}x^3 + {08}x^2 + {08}x + {08} +
79
  --                                 {04}x^2 + {04}x
80
  --  a(x) * a'(x)     = {01}
81
  --  a(x) * {a'(x)}^2 = {01} * a'(x) = a'(x)
82
  --         {a'(x)}^2 = {04}x^2 + {05}
83
  --
84
  --              | 05 00 04 00 |          | 0E 0B 0D 09 |   E = 14 = 1110 = 8 xor 4 xor 2 = 1000 xor 0100 xor 0010
85
  --  {a'(x)}^2 = | 00 05 00 04 |  a'(x) = | 09 0E 0B 0D |   D = 13 = 1101 = 8 xor 4 xor 1 = 1000 xor 0100 xor 0001
86
  --              | 04 00 05 00 |          | 0D 09 0E 0B |   B = 11 = 1011 = 8 xor 2 xor 1 = 1000 xor 0010 xor 0001
87
  --              | 00 04 00 05 |          | 0B 0D 09 0E |   9 = 09 = 1001 = 8 xor 0 xor 1 = 1000 xor 0000 xor 0001
88
  --
89
 
90
  mc (3) <= xtime_2(s0) xor xtime_2(s1) xor s1 xor s2 xor s3;
91
  mc (2) <= s0 xor xtime_2(s1) xor xtime_2(s2) xor s2 xor s3;
92
  mc (1) <= s0 xor s1 xor xtime_2(s2) xor xtime_2(s3) xor s3;
93
  mc (0) <= xtime_2(s0) xor s0 xor s1 xor s2 xor xtime_2(s3);
94
--
95
  mix_col <= (mc(3) & mc(2) & mc(1) & mc(0));
96
-- 
97
  inv_mix_col (31 downto 24) <= xtime_4(mc(3)) xor mc(3) xor xtime_4(mc(1));
98
  inv_mix_col (23 downto 16) <= xtime_4(mc(2)) xor mc(2) xor xtime_4(mc(0));
99
  inv_mix_col (15 downto 08) <= xtime_4(mc(1)) xor mc(1) xor xtime_4(mc(3));
100
  inv_mix_col (07 downto 00) <= xtime_4(mc(0)) xor mc(0) xor xtime_4(mc(2));
101
--
102
--   inv_mix_col (31 downto 24) <= 
103
--                                 xtime_8(mc(3)) xor xtime_4(mc(3)) xor xtime_2(mc(3)) xor 
104
--                                 xtime_8(mc(2)) xor xtime_2(mc(2)) xor mc(2) xor
105
--                                 xtime_8(mc(1)) xor xtime_4(mc(1)) xor mc(1) xor
106
--                                 xtime_8(mc(0)) xor mc(0);
107
--   inv_mix_col (23 downto 16) <= 
108
--                                 xtime_8(mc(3)) xor mc(3) xor
109
--                                 xtime_8(mc(2)) xor xtime_4(mc(2)) xor xtime_2(mc(2)) xor 
110
--                                 xtime_8(mc(1)) xor xtime_2(mc(1)) xor mc(1) xor
111
--                                 xtime_8(mc(0)) xor xtime_4(mc(0)) xor mc(0);
112
--   inv_mix_col (15 downto 08) <= 
113
--                                 xtime_8(mc(3)) xor xtime_4(mc(3)) xor mc(3) xor
114
--                                 xtime_8(mc(2)) xor mc(2) xor
115
--                                 xtime_8(mc(1)) xor xtime_4(mc(1)) xor xtime_2(mc(1)) xor 
116
--                                 xtime_8(mc(0)) xor xtime_2(mc(0)) xor mc(0);
117
--   inv_mix_col (07 downto 00) <= 
118
--                                 xtime_8(mc(3)) xor xtime_2(mc(3)) xor mc(3) xor
119
--                                 xtime_8(mc(2)) xor xtime_4(mc(2)) xor mc(2) xor
120
--                                 xtime_8(mc(1)) xor mc(1) xor
121
--                                 xtime_8(mc(0)) xor xtime_4(mc(0)) xor xtime_2(mc(0));
122
 
123
end data_flow;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.