1 /* 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 12 enum ASD_MODE { 13 ASM_INVAL, 14 ASM_SHA256, 15 ASM_SHA224, 16 }; 17 18 struct 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 asd_sha_init(struct asd_ctx * ctx,enum ASD_MODE mode)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 33 void asd_sha_update(struct asd_ctx *ctx, void *data, size_t len); 34 void asd_sha_finalize(struct asd_ctx *ctx); 35 36 #endif 37