Test that splitting the data and updating via multiple calls yields the same * result as processing the data in a single pass. */
| 25 | * result as processing the data in a single pass. |
| 26 | */ |
| 27 | static void test_split_update(int num_splits, const struct hmac_sha256 *expected, |
| 28 | const u8 *data, size_t size) |
| 29 | { |
| 30 | const size_t split_size = size / (num_splits + 1); |
| 31 | struct hmac_sha256_ctx ctx; |
| 32 | struct hmac_sha256 actual; |
| 33 | |
| 34 | hmac_sha256_init(&ctx, hmac_key, hmac_key_len); |
| 35 | for (int i = 0; i < num_splits; ++i) { |
| 36 | hmac_sha256_update(&ctx, data, split_size); |
| 37 | data += split_size; |
| 38 | size -= split_size; |
| 39 | } |
| 40 | hmac_sha256_update(&ctx, data, size); /* Process remaining data. */ |
| 41 | hmac_sha256_done(&ctx, &actual); |
| 42 | assert(memeq(expected, sizeof(*expected), &actual, sizeof(actual))); |
| 43 | } |
| 44 | |
| 45 | /* Test that the HMAC calculated by CCAN matches OpenSSL's HMAC. */ |
| 46 | static void test_vs_openssl(const struct hmac_sha256 *expected, const u8 *data, size_t size) |
no test coverage detected