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

Subversion Repositories tiny_encryption_algorithm

[/] [tiny_encryption_algorithm/] [trunk/] [tea64.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 feketebv
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
use ieee.std_logic_unsigned.all;
5
 
6
entity tea64 is
7
   port(
8
      key : in std_logic_vector(127 downto 0);
9
      text : in std_logic_vector(63 downto 0);
10
      cipher : out std_logic_vector(63 downto 0)
11
      );
12
end tea64;
13
 
14
architecture Behavioral of tea64 is
15
   type teaA is array (64 downto 0) of std_logic_vector(31 downto 0);
16
   signal v0,v1,sum,feistelOut,feistelKey0,feistelKey1 : teaA;
17
   signal k0,k1,k2,k3 : std_logic_vector(31 downto 0);
18
begin
19
 
20
   sum(0)  <= x"9e3779b9";
21
   k0 <= key(31  downto  0);
22
   k1 <= key(63  downto 32);
23
   k2 <= key(95  downto 64);
24
   k3 <= key(127 downto 96);
25
   v0(0) <= text(31  downto  0);
26
   v1(0) <= text(63  downto 32);
27
 
28
   general_pipe: for i in 1 to 64 generate
29
      v1(i) <= v0(i-1) + feistelOut(i);
30
      v0(i) <= v1(i-1);
31
   end generate;
32
 
33
   feistel_pipe_odd: for j in 0 to 31 generate
34
      sum(2*j+1) <= sum(2*j);
35
      feistelOut(2*j+1) <= (v1(2*j) + sum(2*j)) xor ((v1(2*j)(27 downto 0) & "0000") + k0) xor (("00000" & v1(2*j)(31 downto 5)) + k1);
36
   end generate;
37
 
38
   feistel_pipe_even: for k in 1 to 32 generate
39
      sum(2*k) <= sum(2*k-1) + x"9e3779b9";
40
      feistelOut(2*k) <= (v1(2*k-1) + sum(2*k-1)) xor ((v1(2*k-1)(27 downto 0) & "0000") + k2) xor (("00000" & v1(2*k-1)(31 downto 5)) + k3);
41
   end generate;
42
 
43
   cipher <= v1(64) & v0(64);
44
 
45
end Behavioral;
46
 

powered by: WebSVN 2.1.0

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