MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_split_update

Function test_split_update

tests/fuzz/fuzz-hmac-sha256.c:27–43  ·  view source on GitHub ↗

Test that splitting the data and updating via multiple calls yields the same * result as processing the data in a single pass. */

Source from the content-addressed store, hash-verified

25 * result as processing the data in a single pass.
26 */
27static 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. */
46static void test_vs_openssl(const struct hmac_sha256 *expected, const u8 *data, size_t size)

Callers 1

runFunction · 0.70

Calls 4

hmac_sha256_initFunction · 0.85
hmac_sha256_updateFunction · 0.85
hmac_sha256_doneFunction · 0.85
memeqFunction · 0.85

Tested by

no test coverage detected