1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Actually test multiple SHA-512 implementations.

Spotted in passing: the cryptsuite test functions iterate 'hashname'
through all the available implementations of SHA-512 (or SHA-384), but
then, in each iteration, ignore that loop variable completely and
always test the default algorithm. So on a platform where more than
one implementation is available, we were only actually testing one of
them. Oops!
This commit is contained in:
Simon Tatham 2021-11-21 09:36:22 +00:00
parent 3c21fa54c5
commit 60377a09b4

View File

@ -2753,30 +2753,30 @@ class standard_test_vectors(MyTestBase):
# Test cases from RFC 6234 section 8.5, omitting the ones
# whose input is not a multiple of 8 bits
self.assertEqualBin(hash_str('sha384', "abc"), unhex(
self.assertEqualBin(hash_str(hashname, "abc"), unhex(
'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded163'
'1a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7'))
self.assertEqualBin(hash_str('sha384',
self.assertEqualBin(hash_str(hashname,
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"),
unhex('09330c33f71147e83d192fc782cd1b4753111b173b3b05d2'
'2fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039'))
self.assertEqualBin(hash_str_iter('sha384',
self.assertEqualBin(hash_str_iter(hashname,
("a" * 1000 for _ in range(1000))), unhex(
'9d0e1809716474cb086e834e310a4a1ced149e9c00f24852'
'7972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985'))
self.assertEqualBin(hash_str('sha384',
self.assertEqualBin(hash_str(hashname,
"01234567012345670123456701234567" * 20), unhex(
'2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70'
'bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596'))
self.assertEqualBin(hash_str('sha384', b"\xB9"), unhex(
self.assertEqualBin(hash_str(hashname, b"\xB9"), unhex(
'bc8089a19007c0b14195f4ecc74094fec64f01f90929282c'
'2fb392881578208ad466828b1c6c283d2722cf0ad1ab6938'))
self.assertEqualBin(hash_str('sha384',
self.assertEqualBin(hash_str(hashname,
unhex("a41c497779c0375ff10a7f4e08591739")), unhex(
'c9a68443a005812256b8ec76b00516f0dbb74fab26d66591'
'3f194b6ffb0e91ea9967566b58109cbc675cc208e4c823f7'))
self.assertEqualBin(hash_str('sha384', unhex(
self.assertEqualBin(hash_str(hashname, unhex(
"399669e28f6b9c6dbcbb6912ec10ffcf74790349b7dc8fbe4a8e7b3b5621"
"db0f3e7dc87f823264bbe40d1811c9ea2061e1c84ad10a23fac1727e7202"
"fc3f5042e6bf58cba8a2746e1f64f9b9ea352c711507053cf4e5339d5286"
@ -2795,36 +2795,36 @@ class standard_test_vectors(MyTestBase):
# Test cases from RFC 6234 section 8.5, omitting the ones
# whose input is not a multiple of 8 bits
self.assertEqualBin(hash_str('sha512', "abc"), unhex(
self.assertEqualBin(hash_str(hashname, "abc"), unhex(
'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55'
'd39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94f'
'a54ca49f'))
self.assertEqualBin(hash_str('sha512',
self.assertEqualBin(hash_str(hashname,
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"),
unhex('8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299'
'aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26'
'545e96e55b874be909'))
self.assertEqualBin(hash_str_iter('sha512',
self.assertEqualBin(hash_str_iter(hashname,
("a" * 1000 for _ in range(1000))), unhex(
'e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa9'
'73ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217'
'ad8cc09b'))
self.assertEqualBin(hash_str('sha512',
self.assertEqualBin(hash_str(hashname,
"01234567012345670123456701234567" * 20), unhex(
'89d05ba632c699c31231ded4ffc127d5a894dad412c0e024db872d1abd2b'
'a8141a0f85072a9be1e2aa04cf33c765cb510813a39cd5a84c4acaa64d3f'
'3fb7bae9'))
self.assertEqualBin(hash_str('sha512', b"\xD0"), unhex(
self.assertEqualBin(hash_str(hashname, b"\xD0"), unhex(
'9992202938e882e73e20f6b69e68a0a7149090423d93c81bab3f21678d4a'
'ceeee50e4e8cafada4c85a54ea8306826c4ad6e74cece9631bfa8a549b4a'
'b3fbba15'))
self.assertEqualBin(hash_str('sha512',
self.assertEqualBin(hash_str(hashname,
unhex("8d4e3c0e3889191491816e9d98bff0a0")), unhex(
'cb0b67a4b8712cd73c9aabc0b199e9269b20844afb75acbdd1c153c98289'
'24c3ddedaafe669c5fdd0bc66f630f6773988213eb1b16f517ad0de4b2f0'
'c95c90f8'))
self.assertEqualBin(hash_str('sha512', unhex(
self.assertEqualBin(hash_str(hashname, unhex(
"a55f20c411aad132807a502d65824e31a2305432aa3d06d3e282a8d84e0d"
"e1de6974bf495469fc7f338f8054d58c26c49360c3e87af56523acf6d89d"
"03e56ff2f868002bc3e431edc44df2f0223d4bb3b243586e1a7d92493669"