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

key_schedule.vhd (3029B)


      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.numeric_std.ALL;
     14 use IEEE.STD_LOGIC_1164.ALL;
     15 use work.crypt_pack.ALL;
     16 
     17 
     18 entity key_schedule_liliput is
     19 	port (
     20 		key_i        : in  type_tweak_key_array;
     21 		round_number : in  std_logic_vector(7 downto 0);
     22 		key_o        : out type_tweak_key_array;
     23 		round_key_o  : out type_key
     24 	);
     25 end key_schedule_liliput;
     26 
     27 architecture key_schedule_liliput_arch of key_schedule_liliput is
     28 
     29 	component multiplications
     30 		port(
     31 			mularray_i : in  type_tweak_key_array;
     32 			mularray_o : out type_tweak_key_array
     33 		);
     34 	end component;
     35 
     36 
     37 	signal key_s       : type_tweak_key_array;
     38 	signal round_key_s : type_key;
     39 
     40 begin
     41 
     42 	multiplications_t : multiplications
     43 		port map (
     44 			mularray_i => key_i,
     45 			mularray_o => key_s
     46 		);
     47 
     48 	key_o <= key_s;
     49 
     50 	if_lane4 : if LANE_NB=4 generate
     51 		col2 : for j in 0 to 3 generate
     52 			round_key_s(0)(j) <= key_i(0)(j) xor key_i(1)(j) xor key_i(2)(j) xor key_i(3)(j) ;
     53 			round_key_s(1)(j) <= key_i(0)(j+4) xor key_i(1)(j+4) xor key_i(2)(j+4) xor key_i(3)(j+4);
     54 		end generate;
     55 	end generate;
     56 
     57 	if_lane5 : if LANE_NB=5 generate
     58 		col2 : for j in 0 to 3 generate
     59 			round_key_s(0)(j) <= key_i(0)(j) xor key_i(1)(j) xor key_i(2)(j) xor key_i(3)(j) xor key_i(4)(j) ;
     60 			round_key_s(1)(j) <= key_i(0)(j+4) xor key_i(1)(j+4) xor key_i(2)(j+4) xor key_i(3)(j+4) xor key_i(4)(j+4);
     61 		end generate;
     62 	end generate;
     63 
     64 	if_lane6 : if LANE_NB=6 generate
     65 		col2 : for j in 0 to 3 generate
     66 			round_key_s(0)(j) <= key_i(0)(j) xor key_i(1)(j) xor key_i(2)(j) xor key_i(3)(j) xor key_i(4)(j) xor key_i(5)(j) ;
     67 			round_key_s(1)(j) <= key_i(0)(j+4) xor key_i(1)(j+4) xor key_i(2)(j+4) xor key_i(3)(j+4) xor key_i(4)(j+4) xor key_i(5)(j+4);
     68 		end generate;
     69 	end generate;
     70 
     71 	if_lane7 : if LANE_NB=7 generate
     72 		col2 : for j in 0 to 3 generate
     73 			round_key_s(0)(j) <= key_i(0)(j) xor key_i(1)(j) xor key_i(2)(j) xor key_i(3)(j) xor key_i(4)(j) xor key_i(5)(j) xor key_i(6)(j) ;
     74 			round_key_s(1)(j) <= key_i(0)(j+4) xor key_i(1)(j+4) xor key_i(2)(j+4) xor key_i(3)(j+4) xor key_i(4)(j+4) xor key_i(5)(j+4) xor key_i(6)(j+4);
     75 		end generate;
     76 	end generate;
     77 
     78 
     79 	round_key_o(0)(0) <= round_key_s(0)(0) xor round_number;
     80 	round_key_o(0)(1) <= round_key_s(0)(1);
     81 	round_key_o(0)(2) <= round_key_s(0)(2);
     82 	round_key_o(0)(3) <= round_key_s(0)(3);
     83 	round_key_o(1)    <= round_key_s(1);
     84 
     85 
     86 
     87 end key_schedule_liliput_arch;
     88 
     89 
     90 configuration key_schedule_liliput_conf of key_schedule_liliput is
     91 	for key_schedule_liliput_arch
     92 		for multiplications_t : multiplications
     93 			use entity work.multiplications(Behavioral);
     94 		end for;
     95 	end for;
     96 end configuration key_schedule_liliput_conf ;