20 lines
586 B
C
20 lines
586 B
C
#ifndef DIGEST_UPDATE_H
|
|
#define DIGEST_UPDATE_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define IMPL_DIGEST_UPDATE(algo, block_mask, compress_fn) \
|
|
void \
|
|
algo##_update(void *ctx, const uint8_t *data, size_t len) \
|
|
{ \
|
|
struct algo##_ctx *local_ctx = ctx; \
|
|
for (size_t i = 0; i < len; ++i) { \
|
|
local_ctx->buf[(local_ctx->count & (block_mask))] = data[i]; \
|
|
++local_ctx->count; \
|
|
if (0 == (local_ctx->count & (block_mask))) \
|
|
compress_fn(local_ctx, local_ctx->buf); \
|
|
} \
|
|
}
|
|
|
|
#endif
|