diff options
Diffstat (limited to 'Tests/LibCrypto/TestHash.cpp')
-rw-r--r-- | Tests/LibCrypto/TestHash.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Tests/LibCrypto/TestHash.cpp b/Tests/LibCrypto/TestHash.cpp index d59ba7defd..25e14cf540 100644 --- a/Tests/LibCrypto/TestHash.cpp +++ b/Tests/LibCrypto/TestHash.cpp @@ -142,6 +142,15 @@ TEST_CASE(test_SHA1_hash_successive_updates) EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0); } +TEST_CASE(test_SHA1_hash_split_into_blocks) +{ + u8 result[] { + 0x53, 0x58, 0x96, 0x2d, 0xac, 0x60, 0xb6, 0xcf, 0xdc, 0xc0, 0x2c, 0x70, 0xc5, 0x36, 0xdb, 0x0b, 0x3c, 0x01, 0xc9, 0x90 + }; + auto digest = Crypto::Hash::SHA1::hash("0123456789012345678901234567890123456789012345678901234567890123abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd"sv); + EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0); +} + TEST_CASE(test_SHA256_name) { Crypto::Hash::SHA256 sha; @@ -166,6 +175,15 @@ TEST_CASE(test_SHA256_hash_empty_string) EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0); } +TEST_CASE(test_SHA256_hash_split_into_blocks) +{ + u8 result[] { + 0x1b, 0x90, 0x74, 0xf9, 0x9b, 0xf3, 0x56, 0x20, 0xd3, 0xf6, 0xbf, 0x7d, 0x72, 0x53, 0xb3, 0x3c, 0xd1, 0x1b, 0x7d, 0xd8, 0xa9, 0xa0, 0x4e, 0x55, 0xf5, 0x72, 0x43, 0x94, 0xaf, 0x27, 0x6c, 0x5c + }; + auto digest = Crypto::Hash::SHA256::hash("0123456789012345678901234567890123456789012345678901234567890123abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd"sv); + EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0); +} + TEST_CASE(test_SHA384_name) { Crypto::Hash::SHA384 sha; |