From 5bdeacbbd8ed2fef33f4b2c6b5f75ba51b374ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Thu, 5 Apr 2018 17:04:16 +0200 Subject: Adding first double block test for SHA-512. Test ok. --- src/model/python/sha512.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/model/python') diff --git a/src/model/python/sha512.py b/src/model/python/sha512.py index f25e6ae..3dbab00 100755 --- a/src/model/python/sha512.py +++ b/src/model/python/sha512.py @@ -307,10 +307,22 @@ def double_block_tests(): 0x696A6B6C6D6E6F70, 0x6A6B6C6D6E6F7071, 0x6B6C6D6E6F707172, 0x6C6D6E6F70717273, 0x6D6E6F7071727374, 0x6E6F707172737475, 0x8000000000000000, 0x0000000000000000] - TC_BLOC2 = [0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, - 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000380] + TC_BLOCK2 = [0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000380] + + print("Running double block message tests.") + print() + + my_sha512 = SHA512(mode = 'MODE_SHA_512', verbose=1) + TC1_expected = [0x8E959B75DAE313DA, 0x8CF4F72814FC143F, 0x8F7779C6EB9F7FA1, 0x7299AEADB6889018, + 0x501D289E4900F7E4, 0x331B99DEC4B5433A, 0xC7D329EEB6DD2654, 0x5E96E55B874BE909] + my_sha512.init() + my_sha512.next(TC_BLOCK1) + my_sha512.next(TC_BLOCK2) + my_digest = my_sha512.get_digest() + compare_digests(my_digest, TC1_expected) #------------------------------------------------------------------- @@ -374,6 +386,8 @@ def main(): print single_block_tests() + double_block_tests() + #------------------------------------------------------------------- # __name__ -- cgit v1.2.3