1 #ifndef _SHA512_H
2 #define _SHA512_H
3 
4 #include <linux/kconfig.h>
5 #include <linux/types.h>
6 
7 #if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
8 #include <mbedtls/sha512.h>
9 #endif
10 
11 #define SHA384_SUM_LEN          48
12 #define SHA384_DER_LEN          19
13 #define SHA512_SUM_LEN          64
14 #define SHA512_DER_LEN          19
15 #define SHA512_BLOCK_SIZE       128
16 
17 #define CHUNKSZ_SHA384	(16 * 1024)
18 #define CHUNKSZ_SHA512	(16 * 1024)
19 
20 #if CONFIG_IS_ENABLED(MBEDTLS_LIB_CRYPTO)
21 typedef mbedtls_sha512_context sha384_context;
22 typedef mbedtls_sha512_context sha512_context;
23 #else
24 typedef struct {
25 	uint64_t state[SHA512_SUM_LEN / 8];
26 	uint64_t count[2];
27 	uint8_t buf[SHA512_BLOCK_SIZE];
28 } sha512_context;
29 #endif
30 
31 extern const uint8_t sha512_der_prefix[];
32 
33 void sha512_starts(sha512_context * ctx);
34 void sha512_update(sha512_context *ctx, const uint8_t *input, uint32_t length);
35 void sha512_finish(sha512_context * ctx, uint8_t digest[SHA512_SUM_LEN]);
36 
37 void sha512_csum_wd(const unsigned char *input, unsigned int ilen,
38 		unsigned char *output, unsigned int chunk_sz);
39 
40 extern const uint8_t sha384_der_prefix[];
41 
42 void sha384_starts(sha512_context * ctx);
43 void sha384_update(sha512_context *ctx, const uint8_t *input, uint32_t length);
44 void sha384_finish(sha512_context * ctx, uint8_t digest[SHA384_SUM_LEN]);
45 
46 void sha384_csum_wd(const unsigned char *input, unsigned int ilen,
47 		unsigned char *output, unsigned int chunk_sz);
48 
49 #endif /* _SHA512_H */
50