blob: 7e10f590a1d5a44ffe4dbc4b0a71770b0a601c05 [file] [log] [blame]
Reuben Dowle1908fd92020-04-16 17:36:52 +12001#ifndef _SHA512_H
2#define _SHA512_H
3
Tom Rinidec7ea02024-05-20 13:35:03 -06004#include <linux/types.h>
5
Raymond Maoa571b982024-10-03 14:50:16 -07006#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
7#include <mbedtls/sha512.h>
8#endif
9
Reuben Dowle1908fd92020-04-16 17:36:52 +120010#define SHA384_SUM_LEN 48
11#define SHA384_DER_LEN 19
12#define SHA512_SUM_LEN 64
13#define SHA512_DER_LEN 19
14#define SHA512_BLOCK_SIZE 128
15
16#define CHUNKSZ_SHA384 (16 * 1024)
17#define CHUNKSZ_SHA512 (16 * 1024)
18
Raymond Maoa571b982024-10-03 14:50:16 -070019#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
20typedef mbedtls_sha512_context sha384_context;
21typedef mbedtls_sha512_context sha512_context;
22#else
Reuben Dowle1908fd92020-04-16 17:36:52 +120023typedef struct {
24 uint64_t state[SHA512_SUM_LEN / 8];
25 uint64_t count[2];
26 uint8_t buf[SHA512_BLOCK_SIZE];
27} sha512_context;
Raymond Maoa571b982024-10-03 14:50:16 -070028#endif
Reuben Dowle1908fd92020-04-16 17:36:52 +120029
30extern const uint8_t sha512_der_prefix[];
31
32void sha512_starts(sha512_context * ctx);
33void sha512_update(sha512_context *ctx, const uint8_t *input, uint32_t length);
34void sha512_finish(sha512_context * ctx, uint8_t digest[SHA512_SUM_LEN]);
35
36void sha512_csum_wd(const unsigned char *input, unsigned int ilen,
37 unsigned char *output, unsigned int chunk_sz);
38
39extern const uint8_t sha384_der_prefix[];
40
41void sha384_starts(sha512_context * ctx);
42void sha384_update(sha512_context *ctx, const uint8_t *input, uint32_t length);
43void sha384_finish(sha512_context * ctx, uint8_t digest[SHA384_SUM_LEN]);
44
45void sha384_csum_wd(const unsigned char *input, unsigned int ilen,
46 unsigned char *output, unsigned int chunk_sz);
47
Reuben Dowle1908fd92020-04-16 17:36:52 +120048#endif /* _SHA512_H */