Test that splitting the data and hashing via multiple updates yields the same * result as not splitting the data. */
| 20 | /* Test that splitting the data and hashing via multiple updates yields the same |
| 21 | * result as not splitting the data. */ |
| 22 | static void test_split_update(int num_splits, const struct sha256 *expected, |
| 23 | const u8 *data, size_t size) |
| 24 | { |
| 25 | const size_t split_size = size / (num_splits + 1); |
| 26 | struct sha256_ctx ctx = SHA256_INIT; |
| 27 | struct sha256 actual; |
| 28 | |
| 29 | for (int i = 0; i < num_splits; ++i) { |
| 30 | sha256_update(&ctx, data, split_size); |
| 31 | data += split_size; |
| 32 | size -= split_size; |
| 33 | } |
| 34 | sha256_update(&ctx, data, size); /* Hash remaining data. */ |
| 35 | |
| 36 | sha256_done(&ctx, &actual); |
| 37 | assert(memeq(expected, sizeof(*expected), &actual, sizeof(actual))); |
| 38 | } |
| 39 | |
| 40 | /* Test that the hash calculated by CCAN matches OpenSSL's hash. */ |
| 41 | static void test_vs_openssl(const struct sha256 *expected, const u8 *data, |
no test coverage detected