aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/model/python/sha512.py13
1 files changed, 12 insertions, 1 deletions
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)