aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2018-04-05 16:43:48 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2018-04-05 16:43:48 +0200
commite0ce9f8797171aeff46176c7b3d6129ace9be30b (patch)
tree07f1bbd8a8d7bba09a3058f1ff317d21da392374
parente7b732c3ea5dd1849bb7711da04f569f82aea372 (diff)
Moved tests to separate function to allow for adding multi block message tests.
-rwxr-xr-xsrc/model/python/sha512.py28
1 files 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__