blu85 / aes-gcm-128-192-256-bits Goto Github PK
View Code? Open in Web Editor NEWConfigurable AES-GCM IP (128, 192, 256 bits)
Configurable AES-GCM IP (128, 192, 256 bits)
Can the core handle multiple messages ?
Lets say the first message is 18bytes. The first cycle byte enables will obviously be FFFF and the second cycle byte enables are 0xC000.
Then after many clock cycles second message of size 20 bytes arrives with first cycle byte enables as 0x3FFF (and data also barrel shifted by 2 bytes), second cycle of second message with byteenables as 0xFC00 i.e remaining 6 bytes.
If the data inputs and byteenables are handled outside the core, will the core be able to handle it ?
I am planning to modify the test environment to generate a text file with multiple lines, each line representing one message and then using it to feed the encryption core by adjusting/barrel shifting the aes_gcm_data_in_i and aes_gcm_data_in_bval_i signals. But i wish to know if the core can handle it in the first place.
Hello,
I have checked my python3 version is over 3.5 but could not do the command mentioned in the config page:
bash-4.2$ cd config/
bash-4.2$ python gcm_config.py --mode 256 --size L --pipe 0
Traceback (most recent call last):
File "gcm_config.py", line 11, in
conf.gcm_ip_config()
File "/home/chenyang/common/smb_files/git/AES-GCM-128-192-256-bits/config/gcm_utils.py", line 225, in gcm_ip_config
self.set_default_value(self.args.ngfmul, seed, 'n_gfmul_ip', 1)
AttributeError: 'Namespace' object has no attribute 'ngfmul'
bash-4.2$ python3 gcm_config.py --mode 256 --size L --pipe 0
Traceback (most recent call last):
File "gcm_config.py", line 11, in
conf.gcm_ip_config()
File "/home/chenyang/common/smb_files/git/AES-GCM-128-192-256-bits/config/gcm_utils.py", line 225, in gcm_ip_config
self.set_default_value(self.args.ngfmul, seed, 'n_gfmul_ip', 1)
AttributeError: 'Namespace' object has no attribute 'ngfmul'
bash-4.2$ python gcm_config --help
python: can't open file 'gcm_config': [Errno 2] No such file or directory
bash-4.2$ python3 --version
Python 3.6.8
I suspect this maybe a python issue but a quick search online could not give me the solution, do you have any ideas on this?
thanks
lcy0816
Hi @BLu85,
I have a few questions about this AES-GCM core and was wondering if you could answer them. I am particularly interested in the 256-bit version. I have generated the files from the configuration scripts and implemented them into two different testbenches. When comparing to another AES-GCM core I get different results. I followed the timing diagram shown in the README, but it is possible that I may still have an implementation issue. Also, has this core been tested using NIST test vectors? I cannot get the expected results when using this core.
The NIST test vector that I am currently using is the following:
[Keylen = 256]
[IVlen = 96]
[PTlen = 128]
[AADlen = 128]
[Taglen = 128]
Count = 0
Key = 92e11dcdaa866f5ce790fd24501f92509aacf4cb8b1339d50c9c1240935dd08b
IV = ac93a1a6145299bde902f21a
PT = 2d71bcfa914e4ac045b2aa60955fad24
AAD = 1e0889016f67601c8ebea4943bc23ad6
CT = 8995ae2e6df3dbf96fac7b7137bae67f
Tag = eca5aa77d51d4a0a14d9c51e1da474ab
However, instead I get the following CT and Tag:
CT = 56eb7bf1f2aebfdcb1ae519f5a38d61f
Tag = 3252d0baf357703e0f017e647a54aea9
Here are the simulation waveforms in case anything pops out as incorrect:
Is there a misunderstanding on my end based on the attached waveforms?
Thank you for your time and consideration!
HI!
Thanks for uploading the code, it helped me a lot! I believe there is a bug with the masking of the AAD input values. I found that when
aes_ghash_aad <= x"ffff0000000000000000000000000000";
aes_ghash_aad_bval <= x"c000";
the GCM tag is different to when I use
aes_ghash_aad <= x"ffff0000000000000000000000000001";
aes_ghash_aad_bval <= x"c000";
The first example returns the correct tag, the second one not. Here is my full testbench file:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.gcm_pkg.all;
use work.aes_pkg.all;
entity aes_tb is
end entity;
architecture default of aes_tb is
constant t: time := 5 ns;
signal clk, reset, done : std_logic;
signal enable : std_logic;
signal aes_mode: std_logic_vector(1 downto 0);
signal aes_enc_dec : std_logic;
signal aes_pipe_reset : std_logic;
signal aes_key_word_val : std_logic_vector(3 downto 0);
signal aes_key_word : std_logic_vector(AES_256_KEY_WIDTH_C-1 downto 0);
signal aes_iv_val : std_logic;
signal aes_iv : std_logic_vector(GCM_ICB_WIDTH_C-1 downto 0);
signal aes_icb_start_cnt : std_logic;
signal aes_icb_stop_cnt : std_logic;
signal aes_ghash_pkt_val : std_logic;
signal aes_ghash_aad_bval : std_logic_vector(NB_STAGE_C-1 downto 0);
signal aes_ghash_aad : std_logic_vector(GCM_DATA_WIDTH_C-1 downto 0);
signal aes_data_in_bval : std_logic_vector(NB_STAGE_C-1 downto 0);
signal aes_data_in : std_logic_vector(AES_DATA_WIDTH_C-1 downto 0);
-- Output
signal aes_ready : std_logic;
signal aes_data_out_val : std_logic;
signal aes_data_out_bval : std_logic_vector(NB_STAGE_C-1 downto 0);
signal aes_data_out : std_logic_vector(AES_DATA_WIDTH_C-1 downto 0);
signal aes_ghash_tag_val : std_logic;
signal aes_ghash_tag_o : std_logic_vector(GCM_DATA_WIDTH_C-1 downto 0);
signal aes_overflow : std_logic;
begin
uut: entity work.top_aes_gcm
port map(
enable => enable,
rst_i => reset,
clk_i => clk,
aes_gcm_mode_i => aes_mode,
aes_gcm_enc_dec_i => aes_enc_dec,
aes_gcm_pipe_reset_i => aes_pipe_reset,
aes_gcm_key_word_val_i => aes_key_word_val,
aes_gcm_key_word_i => aes_key_word,
aes_gcm_iv_val_i => aes_iv_val,
aes_gcm_iv_i => aes_iv,
aes_gcm_icb_start_cnt_i => aes_icb_start_cnt,
aes_gcm_icb_stop_cnt_i => aes_icb_stop_cnt,
aes_gcm_ghash_pkt_val_i => aes_ghash_pkt_val,
aes_gcm_ghash_aad_bval_i => aes_ghash_aad_bval,
aes_gcm_ghash_aad_i => aes_ghash_aad,
aes_gcm_data_in_bval_i => aes_data_in_bval,
aes_gcm_data_in_i => aes_data_in,
aes_gcm_ready_o => aes_ready,
aes_gcm_data_out_val_o => aes_data_out_val,
aes_gcm_data_out_bval_o => aes_data_out_bval,
aes_gcm_data_out_o => aes_data_out,
aes_gcm_ghash_tag_val_o => aes_ghash_tag_val,
aes_gcm_ghash_tag_o => aes_ghash_tag_o,
aes_gcm_icb_cnt_overflow_o => aes_overflow
);
clk_gen: process
begin
clk <= '1';
wait for t / 2;
clk <= '0';
wait for t / 2;
if done = '1' then
wait;
end if;
end process;
test: process
variable correct: boolean := true;
begin
enable <= '1';
done <= '0';
reset <= '1';
aes_mode <= AES_MODE_128_C;
aes_key_word_val <= "0000";
aes_pipe_reset <= '1';
aes_iv_val <= '0';
aes_ghash_pkt_val <= '0';
aes_ghash_aad_bval <= (others => '0');
aes_data_in_bval <= (others => '0');
aes_enc_dec <= '0';
aes_icb_start_cnt <= '0';
aes_icb_stop_cnt <= '0';
wait for t;
reset <= '0';
aes_pipe_reset <= '0';
wait for t;
-- Load the key
aes_key_word <= x"affeaffeaffeaffeaffeaffeaffeaffe00000000000000000000000000000000";
aes_key_word_val(2) <= '1';
wait for t;
aes_key_word_val(2) <= '0';
aes_key_word <= x"aaaeaffeaffeaffeaffeaffeaffeaffe00000000000000000000000000000000";
wait for t;
-- Load the IV
aes_iv <= x"d2423c7f670eb2ad17469b86";
aes_iv_val <= '1';
wait for t;
aes_iv_val <= '0';
aes_icb_start_cnt <= '1';
wait for t;
aes_icb_start_cnt <= '0';
wait until aes_ready = '1';
aes_ghash_pkt_val <= '1';
wait for 10*t;
aes_ghash_aad <= x"ffff0000000000000000000000000000";
aes_ghash_aad_bval <= x"c000";
wait for t;
aes_ghash_aad_bval <= x"0000";
aes_data_in <= x"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0";
aes_data_in_bval <= x"FFFF";
wait for t;
aes_data_in <= x"efeeedecebeae9e8e7e6e50000000001";
aes_data_in_bval <= x"ffe0";
wait for 3*t/2;
aes_data_in_bval <= x"0000";
aes_ghash_pkt_val <= '0';
wait for t;
wait for 100*t;
done <= '1';
wait;
end process;
end architecture;
I tried to run the entire code on Vivado but it threw out output just the same as the input. I checked and it seemed like the aes_kexp block was not working correctly, output kexp_key_next_part_o[7:4] and kexp_key_last_stage_o were equal to X when kexp_dval_i asserted.
In tb/gcm_gctr.py the comparison with 'empty' is incorrect. The comparison should be done with 'EMPTY' as thats how the json file gets created with 'empty' with -a switch.
The code misses the module aes-ecb, can you please upload it? thank u
Hi,
I'm having this error while executing python3 gcm_config.py --mode 256 --size L --pipe 0
in the config directory with the raw project :
Traceback (most recent call last):
File "gcm_config.py", line 11, in <module>
conf.gcm_ip_config()
File "/home/rafael/projects/AES-GCM-128-192-256-bits/config/gcm_utils.py", line 227, in gcm_ip_config
if self.args.seed == None:
AttributeError: 'Namespace' object has no attribute 'seed'
I tried this fix :
- if self.args.seed == None:
+ #if self.args.seed == None: ---> fix because it causes Attribute error
+ if ~hasattr(self.args, "seed"):
but then I'm having troubles whit this seed argument while trying to run python gcm_testbench.py -m 128 -p 0 -s M -g
.
Any help would be appreciated. Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.