From e0ce9f8797171aeff46176c7b3d6129ace9be30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Thu, 5 Apr 2018 16:43:48 +0200 Subject: Moved tests to separate function to allow for adding multi block message tests. --- src/model/python/sha512.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/model/python/sha512.py b/src/model/python/sha512.py index 8116c20..9e7cded 100755 --- a/src/model/python/sha512.py +++ b/src/model/python/sha512.py @@ -192,7 +192,7 @@ class SHA512(): print("c = 0x%016x, d = 0x%016x" % (self.c, self.d)) print("e = 0x%016x, f = 0x%016x" % (self.e, self.f)) print("g = 0x%016x, h = 0x%016x" % (self.g, self.h)) - print("") + print() def _sha512_round(self, round): @@ -262,7 +262,7 @@ class SHA512(): print("k = 0x%016x, w = 0x%016x" % (k, w)) print("Ch = 0x%016x, sigma1 = 0x%016x" % (self._Ch(e, f, g), self._sigma1(e))) print("T1 = 0x%016x" % (T1)) - print("") + print() return T1 @@ -296,16 +296,15 @@ def compare_digests(digest, expected): #------------------------------------------------------------------- -# main() +# single_block_tests() # -# If executed tests the ChaCha class using known test vectors. +# NIST test with single block messages for the different +# versions of SHA-512. #------------------------------------------------------------------- -def main(): - print("Testing the SHA-512 Python model.") - print("---------------------------------") - print +def single_block_tests(): + print("Running single block message tests.") + print() - # Single block message. TC1_block = [0x6162638000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, @@ -346,6 +345,17 @@ def main(): compare_digests(my_digest, TC4_expected) +#------------------------------------------------------------------- +# main() +# +# If executed tests the ChaCha class using known test vectors. +#------------------------------------------------------------------- +def main(): + print("Testing the SHA-512 Python model.") + print("---------------------------------") + print + + single_block_tests() #------------------------------------------------------------------- # __name__ -- cgit v1.2.3