Browse Source

Revision 1.1 2011/09/25

integrated all encryption tests of NIST 800-17 publication except the
modes-tests
master
Torsten Meissner 13 years ago
parent
commit
ec99a6b8eb
1 changed files with 116 additions and 90 deletions
  1. +116
    -90
      cbcdes/sim/tb_cbcdes.vhd

+ 116
- 90
cbcdes/sim/tb_cbcdes.vhd View File

@ -21,6 +21,8 @@
-- Revision 1.0 2011/09/23 -- Revision 1.0 2011/09/23
-- Initial release, variable plaintext known answer test integrated -- Initial release, variable plaintext known answer test integrated
-- Revision 1.1 2011/09/25
-- integrated all encryption tests of NIST 800-17 publication except the modes-tests
library ieee; library ieee;
@ -200,67 +202,91 @@ begin
s_iv <= (others => '0'); s_iv <= (others => '0');
s_key <= (others => '0'); s_key <= (others => '0');
s_datain <= (others => '0'); s_datain <= (others => '0');
-- wait for 100 ns;
-- -- Inverse permutation known answer test
-- s_key <= x"0101010101010101";
-- for index in c_variable_plaintext_known_answers'range loop
-- wait until rising_edge(s_clk);
-- s_validin <= '1';
-- s_datain <= c_variable_plaintext_known_answers(index);
-- end loop;
-- wait until rising_edge(s_clk);
-- s_mode <= '0';
-- s_validin <= '0';
-- s_key <= (others => '0');
-- s_datain <= (others => '0');
-- wait for 100 ns;
-- -- Variable key known answer test
-- s_key <= x"8000000000000000";
-- for index in c_variable_key_known_answers'range loop
-- wait until rising_edge(s_clk);
-- s_validin <= '1';
-- if(index /= 0) then
-- if(index = 7 or index = 14 or index = 21 or index = 28 or index = 35 or
-- index = 42 or index = 49) then
-- s_key <= "00" & s_key(0 to 61);
-- else
-- s_key <= '0' & s_key(0 to 62);
-- end if;
-- end if;
-- end loop;
-- wait until rising_edge(s_clk);
-- s_mode <= '0';
-- s_validin <= '0';
-- s_key <= (others => '0');
-- s_datain <= (others => '0');
-- wait for 100 ns;
-- -- Permutation operation known answer test
-- s_datain <= x"0000000000000000";
-- for index in c_permutation_operation_known_answers_keys'range loop
-- wait until rising_edge(s_clk);
-- s_validin <= '1';
-- s_key <= c_permutation_operation_known_answers_keys(index);
-- end loop;
-- wait until rising_edge(s_clk);
-- s_mode <= '0';
-- s_validin <= '0';
-- s_key <= (others => '0');
-- s_datain <= (others => '0');
-- wait for 100 ns;
-- -- Substitution table known answer test
-- for index in c_substitution_table_test_keys'range loop
-- wait until rising_edge(s_clk);
-- s_validin <= '1';
-- s_key <= c_substitution_table_test_keys(index);
-- s_datain <= c_substitution_table_test_plain(index);
-- end loop;
-- wait until rising_edge(s_clk);
-- -- DECRYPTION TESTS
-- s_mode <= '0';
-- s_validin <= '0';
-- s_key <= (others => '0');
-- s_datain <= (others => '0');
-- wait for 100 ns;
wait for 1 us;
-- Inverse permutation known answer test
s_key <= x"0101010101010101";
for index in c_variable_plaintext_known_answers'range loop
wait until rising_edge(s_clk) and s_ready = '1';
s_validin <= '1';
s_start <= '1';
s_datain <= c_variable_plaintext_known_answers(index);
wait until rising_edge(s_clk);
s_validin <= '0';
s_start <= '0';
end loop;
wait until rising_edge(s_clk);
s_start <= '0';
s_mode <= '0';
s_validin <= '0';
s_iv <= (others => '0');
s_key <= (others => '0');
s_datain <= (others => '0');
wait for 1 us;
-- Variable key known answer test
s_key <= x"8000000000000000";
for index in c_variable_key_known_answers'range loop
wait until rising_edge(s_clk) and s_ready = '1';
s_validin <= '1';
s_start <= '1';
if(index /= 0) then
if(index = 7 or index = 14 or index = 21 or index = 28 or index = 35 or
index = 42 or index = 49) then
s_key <= "00" & s_key(0 to 61);
else
s_key <= '0' & s_key(0 to 62);
end if;
end if;
wait until rising_edge(s_clk);
s_validin <= '0';
s_start <= '0';
end loop;
wait until rising_edge(s_clk);
s_start <= '0';
s_mode <= '0';
s_validin <= '0';
s_iv <= (others => '0');
s_key <= (others => '0');
s_datain <= (others => '0');
wait for 1 us;
-- Permutation operation known answer test
s_datain <= x"0000000000000000";
for index in c_permutation_operation_known_answers_keys'range loop
wait until rising_edge(s_clk) and s_ready = '1';
s_validin <= '1';
s_start <= '1';
s_key <= c_permutation_operation_known_answers_keys(index);
wait until rising_edge(s_clk);
s_validin <= '0';
s_start <= '0';
end loop;
wait until rising_edge(s_clk);
s_start <= '0';
s_mode <= '0';
s_validin <= '0';
s_iv <= (others => '0');
s_key <= (others => '0');
s_datain <= (others => '0');
wait for 1 us;
-- Substitution table known answer test
for index in c_substitution_table_test_keys'range loop
wait until rising_edge(s_clk) and s_ready = '1';
s_validin <= '1';
s_start <= '1';
s_key <= c_substitution_table_test_keys(index);
s_datain <= c_substitution_table_test_plain(index);
wait until rising_edge(s_clk);
s_validin <= '0';
s_start <= '0';
end loop;
wait until rising_edge(s_clk);
-- DECRYPTION TESTS
s_start <= '0';
s_mode <= '0';
s_validin <= '0';
s_iv <= (others => '0');
s_key <= (others => '0');
s_datain <= (others => '0');
wait for 1 us;
-- -- Variable ciphertext known answer test -- -- Variable ciphertext known answer test
-- s_key <= x"0101010101010101"; -- s_key <= x"0101010101010101";
-- for index in c_variable_plaintext_known_answers'range loop -- for index in c_variable_plaintext_known_answers'range loop
@ -355,35 +381,35 @@ begin
report "encryption error" report "encryption error"
severity error; severity error;
end loop; end loop;
-- report "# Inverse permutation known answer test";
-- for index in c_variable_plaintext_known_answers'range loop
-- wait until rising_edge(s_clk) and s_validout = '1';
-- assert (s_dataout = v_plaintext)
-- report "encryption error"
-- severity error;
-- v_plaintext := '0' & v_plaintext(0 to 62);
-- end loop;
-- report "# Variable key known answer test";
-- for index in c_variable_key_known_answers'range loop
-- wait until rising_edge(s_clk) and s_validout = '1';
-- assert (s_dataout = c_variable_key_known_answers(index))
-- report "encryption error"
-- severity error;
-- end loop;
-- report "# Permutation operation known answer test";
-- for index in c_permutation_operation_known_answers_cipher'range loop
-- wait until rising_edge(s_clk) and s_validout = '1';
-- assert (s_dataout = c_permutation_operation_known_answers_cipher(index))
-- report "encryption error"
-- severity error;
-- end loop;
-- report "# Substitution table known answer test";
-- for index in c_substitution_table_test_cipher'range loop
-- wait until rising_edge(s_clk) and s_validout = '1';
-- assert (s_dataout = c_substitution_table_test_cipher(index))
-- report "encryption error"
-- severity error;
-- end loop;
report "# Inverse permutation known answer test";
for index in c_variable_plaintext_known_answers'range loop
wait until rising_edge(s_clk) and s_validout = '1';
assert (s_dataout = v_plaintext)
report "encryption error"
severity error;
v_plaintext := '0' & v_plaintext(0 to 62);
end loop;
report "# Variable key known answer test";
for index in c_variable_key_known_answers'range loop
wait until rising_edge(s_clk) and s_validout = '1';
assert (s_dataout = c_variable_key_known_answers(index))
report "encryption error"
severity error;
end loop;
report "# Permutation operation known answer test";
for index in c_permutation_operation_known_answers_cipher'range loop
wait until rising_edge(s_clk) and s_validout = '1';
assert (s_dataout = c_permutation_operation_known_answers_cipher(index))
report "encryption error"
severity error;
end loop;
report "# Substitution table known answer test";
for index in c_substitution_table_test_cipher'range loop
wait until rising_edge(s_clk) and s_validout = '1';
assert (s_dataout = c_substitution_table_test_cipher(index))
report "encryption error"
severity error;
end loop;
-- report "# DECRYPTION TESTS"; -- report "# DECRYPTION TESTS";
-- report "# Variable ciphertext known answer test"; -- report "# Variable ciphertext known answer test";
-- v_plaintext := x"8000000000000000"; -- v_plaintext := x"8000000000000000";


Loading…
Cancel
Save