summaryrefslogtreecommitdiff
path: root/src/add_vhdltbc/ii/machine_etat_chiffrement.vhd
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@airbus.com>2019-07-10 15:23:17 +0200
committerKévin Le Gouguec <kevin.legouguec@airbus.com>2019-07-10 15:23:17 +0200
commit3a3a75683ff4e9b2a3ab311d266fd1bd0392ee62 (patch)
treee4b2326efb78838e1036bf0910a1545c91236c50 /src/add_vhdltbc/ii/machine_etat_chiffrement.vhd
parente509afef04676c9c9dad11a41a196599b70dc774 (diff)
parentc14dee173636d326f26352773cf8201c9ae65961 (diff)
downloadlilliput-ae-implem-3a3a75683ff4e9b2a3ab311d266fd1bd0392ee62.tar.xz
Merge branch 'fix-vhdltbc'
Diffstat (limited to 'src/add_vhdltbc/ii/machine_etat_chiffrement.vhd')
-rw-r--r--src/add_vhdltbc/ii/machine_etat_chiffrement.vhd130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/add_vhdltbc/ii/machine_etat_chiffrement.vhd b/src/add_vhdltbc/ii/machine_etat_chiffrement.vhd
new file mode 100644
index 0000000..9da6816
--- /dev/null
+++ b/src/add_vhdltbc/ii/machine_etat_chiffrement.vhd
@@ -0,0 +1,130 @@
+-- Implementation of the Lilliput-TBC tweakable block cipher by the
+-- Lilliput-AE team, hereby denoted as "the implementer".
+--
+-- For more information, feedback or questions, refer to our website:
+-- https://paclido.fr/lilliput-ae
+--
+-- To the extent possible under law, the implementer has waived all copyright
+-- and related or neighboring rights to the source code in this file.
+-- http://creativecommons.org/publicdomain/zero/1.0/
+
+library IEEE;
+library work;
+use IEEE.numeric_std.all;
+use IEEE.std_logic_1164.all;
+use work.crypt_pack.all;
+
+entity fsm_chiffrement is
+ port (
+ start_i : in std_logic;
+ clock_i : in std_logic;
+ reset_i : in std_logic;
+ decrypt_i : in std_logic;
+ compteur_o : out std_logic_vector(7 downto 0);
+ liliput_on_out : out std_logic;
+ invert_o : out std_logic;
+ data_out_valid_o : out std_logic;
+ permutation_o : out std_logic;
+ mux_keyschdule_o : out std_logic;
+ mux_chiffrement_o : out std_logic
+ );
+end fsm_chiffrement;
+
+architecture fsm_chiffrement_arch of fsm_chiffrement is
+
+ type state is (etat_initial,initroundkey, firstround, loopround, lastround);
+
+ signal present, futur : state;
+ signal compteur : integer range 0 to ROUND;
+
+begin
+
+ invert_o <= '0';
+ compteur_o <= std_logic_vector(to_unsigned(compteur,8));
+
+ process_0 : process(clock_i,reset_i,compteur)
+ begin
+ if reset_i = '0' then
+ compteur <= 0;
+ present <= etat_initial;
+ elsif clock_i'event and clock_i='1' then
+ present <= futur;
+ if (present = initroundkey or present = firstround or present =loopround) then
+ compteur <= compteur+1;
+ else
+ compteur <= 0;
+ end if;
+ end if;
+ end process process_0;
+
+
+ process_1 : process(present, start_i, compteur)
+ begin
+ case present is
+ when etat_initial =>
+ if start_i = '1' then
+ futur <= initroundkey;
+ else
+ futur <= present;
+ end if;
+
+ when initroundkey =>
+ futur <= firstround;
+
+ when firstround =>
+ futur <= loopround;
+
+ when loopround =>
+ if compteur = ROUND-1 then
+ futur <= lastround;
+ else
+ futur <= present;
+ end if;
+
+ when lastround =>
+ futur <= etat_initial;
+
+ end case;
+ end process process_1;
+
+ process_2 : process(present)
+ begin
+ case present is
+ when etat_initial =>
+ liliput_on_out <= '0';
+ data_out_valid_o <= '0';
+ permutation_o <= '0';
+ mux_keyschdule_o <= '1';
+ mux_chiffrement_o <= '1';
+
+ when initroundkey =>
+ liliput_on_out <= '0';
+ data_out_valid_o <= '0';
+ permutation_o <= '0';
+ mux_keyschdule_o <= '1';
+ mux_chiffrement_o <= '1';
+
+ when firstround =>
+ liliput_on_out <= '1';
+ data_out_valid_o <= '0';
+ permutation_o <= '1';
+ mux_keyschdule_o <= '0';
+ mux_chiffrement_o <= '0';
+
+ when loopround =>
+ liliput_on_out <= '1';
+ data_out_valid_o <= '0';
+ permutation_o <= '1';
+ mux_keyschdule_o <= '0';
+ mux_chiffrement_o <= '0';
+
+ when lastround =>
+ liliput_on_out <= '1';
+ data_out_valid_o <= '1';
+ permutation_o <= '0';
+ mux_keyschdule_o <= '0';
+ mux_chiffrement_o <= '0';
+ end case;
+ end process process_2;
+
+end architecture fsm_chiffrement_arch; \ No newline at end of file