AES(Advanced Encryption Standard)


7.0 Key Expansion

The Key Expansion Module is used to replicate the round keys generated from the last tutorial. An array of constants are added or blended with the round keys to generate an expanded key equal to the number of rounds.

For example, the size of the round key is 128 Bits and we have to go ten rounds. Therefore, we will have an array of ten constants which will blend with the 128its round key to generate 10 different keys making it a total of 1280bits, each of the newly generated keys will be fed into each rounds. watch the video below.





`timescale 1 ns/1 ps

 module KeyExpantion
 #
 (
 parameter DATA_W = 128,               //data width
 parameter KEY_L = 128,                //key length
 parameter NO_ROUNDS = 10              //number of rounds
 )
 (
 input clk,                            //system clock
 input reset,                          //async reset               
 input valid_in,                       //input valid in
 input [KEY_L-1:0] cipher_key,         //cipher key
 output [(NO_ROUNDS*DATA_W)-1:0] W,    //contains all generated round keys
 output [NO_ROUNDS-1:0] valid_out      //output valid signal
 );

 wire [31:0] RCON [0:9];                       //round constant array of words
 wire [NO_ROUNDS-1:0] keygen_valid_out;        //every bit represens output valid signal for every RoundKeyGen module 
 wire [DATA_W-1:0] W_array  [0:NO_ROUNDS-1];   //array of round keys to form W output 

 //round connstant values
 assign RCON[0] = 32'h01000000;
 assign RCON[1] = 32'h02000000;
 assign RCON[2] = 32'h04000000;
 assign RCON[3] = 32'h08000000;
 assign RCON[4] = 32'h10000000;
 assign RCON[5] = 32'h20000000;
 assign RCON[6] = 32'h40000000;
 assign RCON[7] = 32'h80000000;
 assign RCON[8] = 32'h1b000000;
 assign RCON[9] = 32'h36000000;

 //instantiate number RounkeyGen modules = number of rounds to get number of roundkeys = number of  rounds
 RoundKeyGen #(KEY_L)RKGEN_U0(clk,reset,RCON[0],valid_in,cipher_key,W_array[0],keygen_valid_out[0]);

 genvar i;
 generate
 for (i=1 ;i<NO_ROUNDS;i=i+1) begin : ROUND_KEY_GEN
 RoundKeyGen #(KEY_L)RKGEN_U(clk,reset,RCON[i],keygen_valid_out[i-1],W_array[i-1],W_array[i],keygen_valid_out[i]);
 end
 endgenerate

                          //assigning all the round keys to one output
 assign W = {  W_array[0],
               W_array[1],
               W_array[2],
               W_array[3],
               W_array[4],
               W_array[5],
               W_array[6],
               W_array[7],
               W_array[8],
               W_array[9] };

 assign valid_out = keygen_valid_out;


 endmodule
 





John Doe
11:37:05am On 2022.09.26
extravaganza overall market [url=http://bag33ondu.com]bag33ondu.com[/url] <a href= http://bag33ondu.com >bag33ondu.com</a> http://bag33ondu.com sleaze method bolshevik .
John Doe
11:12:42am On 2022.09.30
ani kilo kaybı sebeplerikilo kaybı ile ilgili doktor <a href="https://hamilelik-kilo-kayb.thehottrader.online/">hamilelik kilo kayb?</a> kilo kaybı hangi bölümstrese bağlı kilo .
John Doe
12:27:41pm On 2022.10.13
<a href="https://turhaberleri.online/">Türkiye Haberleri</a>.