Test that splitting the data and hashing via multiple updates yields the same * result as not splitting the data. */
| 35 | /* Test that splitting the data and hashing via multiple updates yields the same |
| 36 | * result as not splitting the data. */ |
| 37 | static 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. */ |
| 56 | static void test_vs_openssl(const struct ripemd160 *expected, const u8 *data, |
no test coverage detected