[Cryptech-Commits] [core/hash/sha512] branch clock_speed updated: Finally implemented SHA-512-224 digest properly. Added test case for SHA-512-224 with double block message. Test ok.

git at cryptech.is git at cryptech.is
Fri Apr 6 07:39:27 UTC 2018


This is an automated email from the git hooks/post-receive script.

joachim at secworks.se pushed a commit to branch clock_speed
in repository core/hash/sha512.

The following commit(s) were added to refs/heads/clock_speed by this push:
     new e303dec  Finally implemented SHA-512-224 digest properly. Added test case for SHA-512-224 with double block message. Test ok.
e303dec is described below

commit e303dece38db2916d787fa068a2eeaa445ae6e2b
Author: Joachim Strömbergson <joachim at secworks.se>
AuthorDate: Fri Apr 6 09:39:16 2018 +0200

    Finally implemented SHA-512-224 digest properly. Added test case for SHA-512-224 with double block message. Test ok.
---
 src/model/python/sha512.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/model/python/sha512.py b/src/model/python/sha512.py
index bfeea54..ad5b1fb 100755
--- a/src/model/python/sha512.py
+++ b/src/model/python/sha512.py
@@ -150,7 +150,9 @@ class SHA512():
 
     def get_digest(self):
         if self.mode == 'MODE_SHA_512_224':
-            return self.H[0:3] # FIX THIS!
+            d = self.H[0:4]
+            d[3] = d[3] & 0xffffffff00000000
+            return d
 
         elif self.mode == 'MODE_SHA_512_256':
             return self.H[0:4]
@@ -314,6 +316,15 @@ def double_block_tests():
                  0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
                  0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000380]
 
+    print("Test case for SHA-512-224.")
+    TC256_expected = [0x23fec5bb94d60b23, 0x308192640b0c4533, 0x35d664734fe40e72, 0x68674af900000000]
+    my_sha512 = SHA512(mode = 'MODE_SHA_512_224', verbose = 0)
+    my_sha512.init()
+    my_sha512.next(TC_BLOCK1)
+    my_sha512.next(TC_BLOCK2)
+    my_digest = my_sha512.get_digest()
+    compare_digests(my_digest, TC256_expected)
+
     print("Test case for SHA-512-256.")
     TC256_expected = [0x3928e184fb8690f8, 0x40da3988121d31be, 0x65cb9d3ef83ee614, 0x6feac861e19b563a]
     my_sha512 = SHA512(mode = 'MODE_SHA_512_256', verbose = 0)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list