diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2018-04-05 17:04:16 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2018-04-05 17:04:16 +0200 |
commit | 5bdeacbbd8ed2fef33f4b2c6b5f75ba51b374ec6 (patch) | |
tree | 82b4bb1ace0b6ed8ab1c37d64221e465466648c9 /src/model/python | |
parent | 75248c00c275820b8499a8c938b4bf465be20812 (diff) |
Adding first double block test for SHA-512. Test ok.
Diffstat (limited to 'src/model/python')
-rwxr-xr-x | src/model/python/sha512.py | 22 |
1 files changed, 18 insertions, 4 deletions
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__ |