[Cryptech-Commits] [core/hash/sha512] 01/01: Adding initial version of test case for state restore functionality.

git at cryptech.is git at cryptech.is
Sat Jul 18 13:15:00 UTC 2015


This is an automated email from the git hooks/post-receive script.

joachim at secworks.se pushed a commit to branch state_restore
in repository core/hash/sha512.

commit 87e603dd294d43fb7335c1a139363552134a4886
Author: Joachim Strömbergson <joachim at secworks.se>
Date:   Sat Jul 18 15:14:51 2015 +0200

    Adding initial version of test case for state restore functionality.
---
 src/tb/tb_sha512.v | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/tb/tb_sha512.v b/src/tb/tb_sha512.v
index c993cfc..a3409f5 100644
--- a/src/tb/tb_sha512.v
+++ b/src/tb/tb_sha512.v
@@ -662,6 +662,68 @@ module tb_sha512();
 
 
   //----------------------------------------------------------------
+  // state_restore_test()
+  //
+  // Perform test of state restore followed by block processing.
+  //----------------------------------------------------------------
+  task state_restore_test(input [7 : 0]    tc_number,
+                          input [1 : 0]    mode,
+                          input [511 : 0]  state,
+                          input [1023 : 0] block,
+                          input [511 : 0]  expected
+                         );
+    reg [511 : 0] mask;
+    reg [511 : 0] masked_data;
+    begin
+      $display("*** TC%01d - State restore test started.", tc_ctr);
+
+      // Write state.
+      write_word(ADDR_DIGEST0, state[511 : 480]);
+      write_word(ADDR_DIGEST0, state[479 : 448]);
+      write_word(ADDR_DIGEST0, state[447 : 416]);
+      write_word(ADDR_DIGEST0, state[415 : 384]);
+      write_word(ADDR_DIGEST0, state[383 : 352]);
+      write_word(ADDR_DIGEST0, state[351 : 320]);
+      write_word(ADDR_DIGEST0, state[319 : 288]);
+      write_word(ADDR_DIGEST0, state[287 : 256]);
+      write_word(ADDR_DIGEST0, state[255 : 224]);
+      write_word(ADDR_DIGEST0, state[223 : 192]);
+      write_word(ADDR_DIGEST0, state[191 : 160]);
+      write_word(ADDR_DIGEST0, state[159 : 128]);
+      write_word(ADDR_DIGEST0, state[127 : 096]);
+      write_word(ADDR_DIGEST0, state[095 : 064]);
+      write_word(ADDR_DIGEST0, state[063 : 032]);
+      write_word(ADDR_DIGEST0, state[031 : 000]);
+
+      // Final block
+      write_block(block);
+      write_word(ADDR_CTRL, {28'h0000000, mode, CTRL_NEXT_VALUE});
+      #(CLK_PERIOD);
+      wait_ready();
+      read_digest();
+
+      mask = get_mask(mode);
+      masked_data = digest_data & mask;
+
+      if (masked_data == expected)
+        begin
+          $display("TC%01d final block: OK.", tc_ctr);
+        end
+      else
+        begin
+          $display("TC%01d: ERROR in final digest", tc_ctr);
+          $display("TC%01d: Expected: 0x%0128x", tc_ctr, expected);
+          $display("TC%01d: Got:      0x%0128x", tc_ctr, masked_data);
+          error_ctr = error_ctr + 1;
+        end
+
+      $display("*** TC%01d - Double block test done.", tc_ctr);
+      tc_ctr = tc_ctr + 1;
+    end
+  endtask // state_restore_test
+
+
+  //----------------------------------------------------------------
   // work_factor_test()
   //
   // Perform test of the work factor function.
@@ -782,7 +844,10 @@ module tb_sha512();
       double_block_test(8'h08, MODE_SHA_384, double_block_one, double_block_two, tc11_expected, tc12_expected);
 
       // Work factor test.
-      work_factor_test();
+//      work_factor_test();
+
+      // State restore test.
+      state_restore_test(8'h09, MODE_SHA_512, tc5_expected, double_block_two, tc6_expected);
 
       dump_dut_state();
 



More information about the Commits mailing list