diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2014-05-16 16:24:11 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2014-05-16 16:24:11 +0200 |
commit | ab819878444d72366ce1e2819dc074d96d3fb155 (patch) | |
tree | 8cf66390bd7997dfa13cacd5823bff080c3398d9 /src/sw | |
parent | 7c3d902535b7f89d594021dcb1df96b400783a05 (diff) |
Fixed huge message test. We now run test of message with 100 blocks in SHA-256.
Diffstat (limited to 'src/sw')
-rwxr-xr-x | src/sw/hash_tester.py | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/sw/hash_tester.py b/src/sw/hash_tester.py index f042b01..52bca7d 100755 --- a/src/sw/hash_tester.py +++ b/src/sw/hash_tester.py @@ -79,7 +79,7 @@ VERBOSE = False # Delay times we wait PROC_DELAY_TIME = 0.0001 -COMM_DELAY_TIME = 0.005 +COMM_DELAY_TIME = 0.05 # Memory map. SOC = '\x55' @@ -603,34 +603,33 @@ def huge_message_test_sha256(block, n, ser): block[(i * 4) : ((i * 4 ) + 4)] + [EOC] write_serial_bytes(message, ser) - # Start initial block hashing, wait. + # Start initial block hashing, wait and check status. write_serial_bytes([SOC, WRITE_CMD, SHA256_ADDR_PREFIX, SHA256_ADDR_CTRL, '\x00', '\x00', '\x00', SHA256_CTRL_INIT_CMD, EOC], ser) time.sleep(PROC_DELAY_TIME) - print "Block 0 done." - - # First block done. - n = n - 1 + write_serial_bytes([SOC, READ_CMD, SHA256_ADDR_PREFIX, SHA256_ADDR_STATUS, EOC], ser) - # Extract the digest for the current block. + # Extract the first digest. + print "Digest for block 00:" for digest_addr in sha256_digest_addr: message = [SOC, READ_CMD, SHA256_ADDR_PREFIX] + [digest_addr] + [EOC] write_serial_bytes(message, ser) - print"" + print"" - for i in range(n): - # Start next block hashing, wait. + # First block done. Do the rest. + for i in range(n - 1): + # Start next block hashing, wait and check status. write_serial_bytes([SOC, WRITE_CMD, SHA256_ADDR_PREFIX, SHA256_ADDR_CTRL, '\x00', '\x00', '\x00', SHA256_CTRL_NEXT_CMD, EOC], ser) - print "Block %d done." % (i + 1) time.sleep(PROC_DELAY_TIME) + write_serial_bytes([SOC, READ_CMD, SHA256_ADDR_PREFIX, SHA256_ADDR_STATUS, EOC], ser) - # Extract the digest for the current block. + # Extract the second digest. + print "Digest for block %02d" % (i + 1) for digest_addr in sha256_digest_addr: message = [SOC, READ_CMD, SHA256_ADDR_PREFIX] + [digest_addr] + [EOC] write_serial_bytes(message, ser) - print"" - time.sleep(PROC_DELAY_TIME) + print"" #------------------------------------------------------------------- @@ -809,24 +808,28 @@ def tc6(ser): # TC7: SHA-256 Huge message test. #------------------------------------------------------------------- def tc7(ser): - n = 10 + n = 100 print "TC7: Message with %d blocks test for SHA-256." % n tc7_block = ['\xaa', '\x55', '\xaa', '\x55', '\xde', '\xad', '\xbe', '\xef', '\x55', '\xaa', '\x55', '\xaa', '\xf0', '\x0f', '\xf0', '\x0f', + '\xaa', '\x55', '\xaa', '\x55', '\xde', '\xad', '\xbe', '\xef', '\x55', '\xaa', '\x55', '\xaa', '\xf0', '\x0f', '\xf0', '\x0f', + '\xaa', '\x55', '\xaa', '\x55', '\xde', '\xad', '\xbe', '\xef', '\x55', '\xaa', '\x55', '\xaa', '\xf0', '\x0f', '\xf0', '\x0f', + '\xaa', '\x55', '\xaa', '\x55', '\xde', '\xad', '\xbe', '\xef', '\x55', '\xaa', '\x55', '\xaa', '\xf0', '\x0f', '\xf0', '\x0f'] - tc7_expected = [0xf407ff0d, 0xb9dce2f6, 0x9b9759a9, 0xd3cdc805, - 0xf250086d, 0x73bbefd5, 0xa972e0f7, 0x61a9c13e] + tc7_expected = [0x881e9d79, 0xba8b92b1, 0xbb72c103, 0x617e5580, + 0x31fb69ce, 0xd954e335, 0xb5e702c3, 0xc04b1379] print "TC7: Expected digest values after %d blocks:" %n for i in tc7_expected: print("0x%08x " % i) print("") + huge_message_test_sha256(tc7_block, n, ser) @@ -989,9 +992,9 @@ def main(): my_thread.start() # Run the enabled test cases. - tc_list = [(tc1, True), (tc2, True), (tc3, True), (tc4, True), - (tc5, True), (tc6, True), (tc7, True), (tc8, True), - (tc9, True), (tc10, True)] + tc_list = [(tc1, False), (tc2, False), (tc3, False), (tc4, False), + (tc5, False), (tc6, False), (tc7, True), (tc8, False), + (tc9, False), (tc10, False)] for (test_case, action) in tc_list: if action: test_case(ser) |