blob: 52129a61f744094848d8976a19f8a55e09095a14 [file] [log] [blame]
Remi Pommarel199d6e32019-03-28 23:34:18 +01001/*
2 * Copyright (c) 2019, Remi Pommarel <repk@triplefau.lt>
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#ifndef SHA_DMA_H
7#define SHA_DMA_H
8
9#define SHA256_HASHSZ 32
10#define SHA256_BLOCKSZ 0x40
11
12enum ASD_MODE {
13 ASM_INVAL,
14 ASM_SHA256,
15 ASM_SHA224,
16};
17
18struct asd_ctx {
19 uint8_t digest[SHA256_HASHSZ];
20 uint8_t block[SHA256_BLOCKSZ];
21 size_t blocksz;
22 enum ASD_MODE mode;
23 uint8_t started;
24};
25
26static inline void asd_sha_init(struct asd_ctx *ctx, enum ASD_MODE mode)
27{
28 ctx->started = 0;
29 ctx->mode = mode;
30 ctx->blocksz = 0;
31}
32
33void asd_sha_update(struct asd_ctx *ctx, void *data, size_t len);
34void asd_sha_finalize(struct asd_ctx *ctx);
35
36#endif