1 |
2 |
ruschi |
-------------------------------------------------------------------------------
|
2 |
10 |
ruschi |
-- This file is part of the project avs_aes
|
3 |
|
|
-- see: http://opencores.org/project,avs_aes
|
4 |
2 |
ruschi |
--
|
5 |
|
|
-- description:
|
6 |
|
|
-- AddRoundKey module for AES algorithm, basically a simple XOR for states and
|
7 |
|
|
-- keyblocks.... just a simple XOR wrapped into a component for nicer usage.
|
8 |
|
|
--
|
9 |
|
|
--
|
10 |
|
|
-------------------------------------------------------------------------------
|
11 |
|
|
-- Author(s):
|
12 |
|
|
-- Thomas Ruschival -- ruschi@opencores.org (www.ruschival.de)
|
13 |
|
|
--
|
14 |
|
|
--------------------------------------------------------------------------------
|
15 |
|
|
-- Copyright (c) 2009, Thomas Ruschival
|
16 |
|
|
-- All rights reserved.
|
17 |
|
|
--
|
18 |
|
|
-- Redistribution and use in source and binary forms, with or without modification,
|
19 |
|
|
-- are permitted provided that the following conditions are met:
|
20 |
|
|
-- * Redistributions of source code must retain the above copyright notice,
|
21 |
|
|
-- this list of conditions and the following disclaimer.
|
22 |
|
|
-- * Redistributions in binary form must reproduce the above copyright notice,
|
23 |
|
|
-- this list of conditions and the following disclaimer in the documentation
|
24 |
|
|
-- and/or other materials provided with the distribution.
|
25 |
|
|
-- * Neither the name of the nor the names of its contributors
|
26 |
|
|
-- may be used to endorse or promote products derived from this software without
|
27 |
|
|
-- specific prior written permission.
|
28 |
|
|
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
29 |
|
|
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
30 |
|
|
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
31 |
|
|
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
32 |
|
|
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
33 |
|
|
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
34 |
|
|
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35 |
|
|
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
36 |
|
|
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
37 |
|
|
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
38 |
|
|
-- THE POSSIBILITY OF SUCH DAMAGE
|
39 |
|
|
-------------------------------------------------------------------------------
|
40 |
|
|
-- version management:
|
41 |
20 |
ruschi |
-- $Author:: $
|
42 |
|
|
-- $Date:: $
|
43 |
|
|
-- $Revision:: $
|
44 |
2 |
ruschi |
-------------------------------------------------------------------------------
|
45 |
|
|
|
46 |
|
|
library IEEE;
|
47 |
|
|
use IEEE.std_logic_1164.all;
|
48 |
|
|
use ieee.numeric_std.all;
|
49 |
|
|
|
50 |
11 |
ruschi |
library avs_aes_lib;
|
51 |
|
|
use avs_aes_lib.avs_aes_pkg.all;
|
52 |
2 |
ruschi |
|
53 |
|
|
entity AddRoundKey is
|
54 |
|
|
port (
|
55 |
|
|
roundkey : in KEYBLOCK; -- Roundkey
|
56 |
|
|
cypherblock : in STATE; -- State for this round
|
57 |
|
|
result : out STATE); -- result
|
58 |
|
|
end entity AddRoundKey;
|
59 |
|
|
|
60 |
|
|
architecture arch1 of AddRoundKey is
|
61 |
|
|
|
62 |
|
|
begin -- architecture arch1
|
63 |
|
|
|
64 |
|
|
-- purpose: Adding (Xor) roundkey words with Keywords
|
65 |
|
|
-- type : combinational
|
66 |
|
|
-- inputs : cypherblock, roundkey
|
67 |
|
|
-- outputs: result
|
68 |
|
|
Xoring : process (cypherblock, roundkey) is
|
69 |
|
|
begin -- process Xoring
|
70 |
|
|
for cnt in cypherblock'range loop
|
71 |
|
|
result(cnt) <= cypherblock(cnt) xor roundkey(cnt);
|
72 |
|
|
end loop; -- cnt
|
73 |
|
|
end process Xoring;
|
74 |
|
|
|
75 |
|
|
end architecture arch1;
|