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

Function test_split_update

tests/fuzz/fuzz-ripemd160.c:37–53  ·  view source on GitHub ↗

Test that splitting the data and hashing via multiple updates yields the same * result as not splitting the data. */

Source from the content-addressed store, hash-verified

35/* Test that splitting the data and hashing via multiple updates yields the same
36 * result as not splitting the data. */
37static void test_split_update(int num_splits, const struct ripemd160 *expected,
38 const u8 *data, size_t size)
39{
40 const size_t split_size = size / (num_splits + 1);
41 struct ripemd160_ctx ctx = RIPEMD160_INIT;
42 struct ripemd160 actual;
43
44 for (int i = 0; i < num_splits; ++i) {
45 ripemd160_update(&ctx, data, split_size);
46 data += split_size;
47 size -= split_size;
48 }
49 ripemd160_update(&ctx, data, size); /* Hash remaining data. */
50
51 ripemd160_done(&ctx, &actual);
52 assert(memeq(expected, sizeof(*expected), &actual, sizeof(actual)));
53}
54
55/* Test that the hash calculated by CCAN matches OpenSSL's hash. */
56static void test_vs_openssl(const struct ripemd160 *expected, const u8 *data,

Callers 1

runFunction · 0.70

Calls 3

ripemd160_updateFunction · 0.85
ripemd160_doneFunction · 0.85
memeqFunction · 0.85

Tested by

no test coverage detected