aboutsummaryrefslogtreecommitdiff
path: root/src/tb/tb_aes_core.v
diff options
context:
space:
mode:
Diffstat (limited to 'src/tb/tb_aes_core.v')
-rw-r--r--src/tb/tb_aes_core.v89
1 files changed, 29 insertions, 60 deletions
diff --git a/src/tb/tb_aes_core.v b/src/tb/tb_aes_core.v
index d7c424c..d36d0bc 100644
--- a/src/tb/tb_aes_core.v
+++ b/src/tb/tb_aes_core.v
@@ -339,8 +339,15 @@ module tb_aes_core();
endtask // ecb_mode_single_block_test
- task nist_fips_tests;
- begin : fips_tests
+ //----------------------------------------------------------------
+ // aes_core_test
+ // The main test functionality.
+ //
+ // Test cases taken from NIST SP 800-38A:
+ // http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
+ //----------------------------------------------------------------
+ initial
+ begin : aes_core_test
reg [255 : 0] nist_aes128_key;
reg [255 : 0] nist_aes256_key;
@@ -378,19 +385,29 @@ module tb_aes_core();
nist_ecb_256_enc_expected3 = 128'h23304b7a39f9f3ff067d8d8f9e24ecc7;
- $display("NIST FIPS ECB 128 bit key tests");
- $display("-------------------------------");
+ $display(" -= Testbench for aes core started =-");
+ $display(" ================================");
+ $display("");
+
+ init_sim();
+ dump_dut_state();
+ reset_dut();
+ dump_dut_state();
+
+
+ $display("ECB 128 bit key tests");
+ $display("---------------------");
ecb_mode_single_block_test(8'h01, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
nist_plaintext0, nist_ecb_128_enc_expected0);
- ecb_mode_single_block_test(8'h02, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
- nist_plaintext1, nist_ecb_128_enc_expected1);
+ ecb_mode_single_block_test(8'h02, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
+ nist_plaintext1, nist_ecb_128_enc_expected1);
- ecb_mode_single_block_test(8'h03, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
- nist_plaintext2, nist_ecb_128_enc_expected2);
+ ecb_mode_single_block_test(8'h03, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
+ nist_plaintext2, nist_ecb_128_enc_expected2);
- ecb_mode_single_block_test(8'h04, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
- nist_plaintext3, nist_ecb_128_enc_expected3);
+ ecb_mode_single_block_test(8'h04, AES_ENCIPHER, nist_aes128_key, AES_128_BIT_KEY,
+ nist_plaintext3, nist_ecb_128_enc_expected3);
ecb_mode_single_block_test(8'h05, AES_DECIPHER, nist_aes128_key, AES_128_BIT_KEY,
@@ -407,8 +424,8 @@ module tb_aes_core();
$display("");
- $display("NIST FIPS ECB 256 bit key tests");
- $display("-------------------------------");
+ $display("ECB 256 bit key tests");
+ $display("---------------------");
ecb_mode_single_block_test(8'h10, AES_ENCIPHER, nist_aes256_key, AES_256_BIT_KEY,
nist_plaintext0, nist_ecb_256_enc_expected0);
@@ -433,55 +450,7 @@ module tb_aes_core();
ecb_mode_single_block_test(8'h17, AES_DECIPHER, nist_aes256_key, AES_256_BIT_KEY,
nist_ecb_256_enc_expected3, nist_plaintext3);
- end
- endtask // nist_fips_tests
-
-
- //----------------------------------------------------------------
- // nist_kwp_test()
- //
- // Test that we can perform operations based on NIST KWP
- // AE 128 test vectors.
- //----------------------------------------------------------------
- task nist_kwp_test;
- reg [255 : 0] kwp_key;
- reg [127 : 0] kwp_plaintext;
- reg [127 : 0] kwp_expected;
-
- begin
- kwp_key = 256'hc03db3cc1416dcd1c069a195a8d77e3d00000000000000000000000000000000;
- kwp_plaintext = 128'ha65959a60000001f46f87f58cdda4200;
- kwp_expected = 128'hd1bac797ff82fa4bde9f7490729fd0a7;
-
- $display("");
- $display("NIST KWP AE 128 bit test");
-
- ecb_mode_single_block_test(8'h18, AES_ENCIPHER, kwp_key, AES_128_BIT_KEY,
- kwp_plaintext, kwp_expected);
- end
- endtask // nist_kwp_test
-
-
- //----------------------------------------------------------------
- // aes_core_test
- // The main test functionality.
- //
- // Test cases taken from NIST SP 800-38A:
- // http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
- //----------------------------------------------------------------
- initial
- begin : aes_core_test
- $display(" -= Testbench for aes core started =-");
- $display(" ================================");
- $display("");
-
- init_sim();
- dump_dut_state();
- reset_dut();
- dump_dut_state();
- nist_fips_tests();
- nist_kwp_test();
display_test_result();
$display("");