diff options
| author | Yawning Angel <yawning@schwanenlied.me> | 2023-11-16 20:44:10 +0900 |
|---|---|---|
| committer | Yawning Angel <yawning@schwanenlied.me> | 2023-11-17 19:31:51 +0900 |
| commit | 41fdcfeecfe0b82927f0a123aa91ea2d85136dae (patch) | |
| tree | af7bdf3de185fed7a1de7cbb3dac11dca1d1461c /tests | |
| parent | 70ba4b532176703b11d962e7e4f0bf0e85726c70 (diff) | |
core/crypto/sha2: Add SHA-512/256
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/crypto/test_core_crypto.odin | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/core/crypto/test_core_crypto.odin b/tests/core/crypto/test_core_crypto.odin index f6b4b10b8..ad1c5738d 100644 --- a/tests/core/crypto/test_core_crypto.odin +++ b/tests/core/crypto/test_core_crypto.odin @@ -71,6 +71,7 @@ main :: proc() { test_sha256(&t) test_sha384(&t) test_sha512(&t) + test_sha512_256(&t) test_sha3_224(&t) test_sha3_256(&t) test_sha3_384(&t) @@ -302,6 +303,21 @@ test_sha512 :: proc(t: ^testing.T) { } @(test) +test_sha512_256 :: proc(t: ^testing.T) { + // Test vectors from + // https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/examples/sha_all.pdf + test_vectors := [?]TestHash { + TestHash{"53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23", "abc"}, + TestHash{"3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a", "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"}, + } + for v, _ in test_vectors { + computed := sha2.hash_512_256(v.str) + computed_str := hex_string(computed[:]) + expect(t, computed_str == v.hash, fmt.tprintf("Expected: %s for input of %s, but got %s instead", v.hash, v.str, computed_str)) + } +} + +@(test) test_sha3_224 :: proc(t: ^testing.T) { // Test vectors from // https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/documents/examples/sha_all.pdf |