lilliput-ae-reference-implementation

Implementations of Lilliput-AE submitted to the NIST LWC standardization process
git clone https://git.kevinlegouguec.net/lilliput-ae-reference-implementation
Log | Files | Refs | README

crypt_pack.vhd (3166B)


      1 -- Implementation of the Lilliput-TBC tweakable block cipher by the
      2 -- Lilliput-AE team, hereby denoted as "the implementer".
      3 --
      4 -- For more information, feedback or questions, refer to our website:
      5 -- https://paclido.fr/lilliput-ae
      6 --
      7 -- To the extent possible under law, the implementer has waived all copyright
      8 -- and related or neighboring rights to the source code in this file.
      9 -- http://creativecommons.org/publicdomain/zero/1.0/;
     10 
     11 library IEEE;
     12 library work;
     13 use IEEE.STD_LOGIC_1164.ALL;
     14 use work.const_pack.ALL;
     15 
     16 package crypt_pack is
     17 
     18     subtype bit2 is std_logic_vector(1 downto 0);
     19     subtype bit4 is std_logic_vector(3 downto 0);
     20     subtype bit8 is std_logic_vector(7 downto 0);
     21     subtype bit16 is std_logic_vector(15 downto 0);
     22     subtype bit32 is std_logic_vector(31 downto 0);
     23     subtype bit64 is std_logic_vector(63 downto 0);
     24     subtype bit128 is std_logic_vector(127 downto 0);
     25     subtype bit256 is std_logic_vector(255 downto 0);
     26     subtype bit192 is std_logic_vector(191 downto 0);
     27     subtype bit80 is std_logic_vector(79 downto 0);
     28 
     29     subtype bit_nonce is std_logic_vector(NONCE_LEN-1 downto 0);
     30     subtype bit_tag is std_logic_vector(TAG_LEN-1 downto 0);
     31     subtype bit_data is std_logic_vector(DATA_LEN-1 downto 0);
     32     subtype bit_tweak is std_logic_vector(TWEAK_LEN-1 downto 0);
     33     subtype bit_key is std_logic_vector(KEY_LEN-1 downto 0);
     34     subtype bit_tweak_key is std_logic_vector((TWEAK_LEN+KEY_LEN)-1 downto 0);
     35     subtype bit_data_in is std_logic_vector(DATA_IN_LEN-1 downto 0);
     36     subtype bit_tweak_in is std_logic_vector(TWEAK_IN_LEN-1 downto 0);
     37     subtype bit_key_in is std_logic_vector(sw-1 downto 0);
     38     subtype bit_data_out is std_logic_vector(DATA_OUT_LEN-1 downto 0);
     39 
     40     type row_b8 is array(0 to 7) of bit8;
     41 
     42     type row_state is array(0 to 3) of bit8;
     43     type type_half_state is array(0 to 1) of row_state;
     44     type type_state is array(0 to 3) of row_state;
     45 
     46     type key_row_state is array(0 to 3) of bit8;
     47     type type_key is array(0 to 1) of key_row_state;
     48     type type_stored_key is array(0 to ROUND_NB-1) of type_key;
     49 
     50 
     51     type type_output_vector is array(0 to DATA_LEN/w-1) of bit_data_out;
     52 
     53     type type_tweak_key_row is array(0 to 7) of bit8;
     54     type type_tweak_key_array is array(0 to ((TWEAK_LEN+KEY_LEN)/64)-1) of type_tweak_key_row;
     55 	 type type_key_array       is array(TWEAK_LEN/64 to ((TWEAK_LEN+KEY_LEN)/64)-1) of type_tweak_key_row;
     56 
     57     type keyschedule_row_state is array(0 to 3) of bit8;
     58     type type_keyschedule is array(0 to 3) of keyschedule_row_state;
     59 
     60     constant Wdiv8          : integer := W/8;
     61     constant ROUND          : integer := ROUND_NB;
     62     constant INOUT_CYCLE_NB : integer := (KEY_LEN/sw)-1;
     63     constant TWEAK_KEY_LEN  : integer := TWEAK_LEN+KEY_LEN-1;
     64     constant LANE_NB        : integer := ((TWEAK_LEN+KEY_LEN)/64);
     65 	 constant LANE_Y_BEGIN_NB : integer := (TWEAK_LEN/64);
     66     constant DATA_IN_LOOP   : integer := (DATA_LEN/DATA_IN_LEN)-1;
     67     constant KEY_IN_LOOP    : integer := (KEY_LEN/sw)-1;
     68     constant TWEAK_IN_LOOP  : integer := (TWEAK_LEN/TWEAK_IN_LEN)-1;
     69     constant DATA_OUT_LOOP  : integer := (DATA_LEN/DATA_OUT_LEN)-1;
     70 end crypt_pack;