| 12 | } |
| 13 | |
| 14 | TEST(Hash, Sha256) |
| 15 | { |
| 16 | // https://en.wikipedia.org/w/index.php?title=SHA-2&oldid=840187620#Test_vectors |
| 17 | ExpectSha256(sha256("", 0), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); |
| 18 | SHA256_CTX ctxt; |
| 19 | |
| 20 | sha256_init(&ctxt); |
| 21 | ExpectSha256(sha256_finish(&ctxt), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); |
| 22 | |
| 23 | // printf 'The quick brown fox jumps over the lazy dog.' | sha256sum |
| 24 | char QUICK_BROWN_FOX[] = "The quick brown fox jumps over the lazy dog."; |
| 25 | ExpectSha256(sha256(QUICK_BROWN_FOX, str_length(QUICK_BROWN_FOX)), "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"); |
| 26 | |
| 27 | sha256_init(&ctxt); |
| 28 | sha256_update(&ctxt, "The ", 4); |
| 29 | sha256_update(&ctxt, "quick ", 6); |
| 30 | sha256_update(&ctxt, "brown ", 6); |
| 31 | sha256_update(&ctxt, "fox ", 4); |
| 32 | sha256_update(&ctxt, "jumps ", 6); |
| 33 | sha256_update(&ctxt, "over ", 5); |
| 34 | sha256_update(&ctxt, "the ", 4); |
| 35 | sha256_update(&ctxt, "lazy ", 5); |
| 36 | sha256_update(&ctxt, "dog.", 4); |
| 37 | ExpectSha256(sha256_finish(&ctxt), "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"); |
| 38 | } |
| 39 | |
| 40 | TEST(Hash, Sha256ToStringSmallBuffer) |
| 41 | { |
nothing calls this directly
no test coverage detected