Reuben Dowle | 1908fd9 | 2020-04-16 17:36:52 +1200 | [diff] [blame] | 1 | #ifndef _SHA512_H |
| 2 | #define _SHA512_H |
| 3 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 4 | #include <linux/types.h> |
| 5 | |
Raymond Mao | a571b98 | 2024-10-03 14:50:16 -0700 | [diff] [blame] | 6 | #if defined(CONFIG_MBEDTLS_LIB_CRYPTO) |
| 7 | #include <mbedtls/sha512.h> |
| 8 | #endif |
| 9 | |
Reuben Dowle | 1908fd9 | 2020-04-16 17:36:52 +1200 | [diff] [blame] | 10 | #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 Mao | a571b98 | 2024-10-03 14:50:16 -0700 | [diff] [blame] | 19 | #if defined(CONFIG_MBEDTLS_LIB_CRYPTO) |
| 20 | typedef mbedtls_sha512_context sha384_context; |
| 21 | typedef mbedtls_sha512_context sha512_context; |
| 22 | #else |
Reuben Dowle | 1908fd9 | 2020-04-16 17:36:52 +1200 | [diff] [blame] | 23 | typedef 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 Mao | a571b98 | 2024-10-03 14:50:16 -0700 | [diff] [blame] | 28 | #endif |
Reuben Dowle | 1908fd9 | 2020-04-16 17:36:52 +1200 | [diff] [blame] | 29 | |
| 30 | extern const uint8_t sha512_der_prefix[]; |
| 31 | |
| 32 | void sha512_starts(sha512_context * ctx); |
| 33 | void sha512_update(sha512_context *ctx, const uint8_t *input, uint32_t length); |
| 34 | void sha512_finish(sha512_context * ctx, uint8_t digest[SHA512_SUM_LEN]); |
| 35 | |
| 36 | void sha512_csum_wd(const unsigned char *input, unsigned int ilen, |
| 37 | unsigned char *output, unsigned int chunk_sz); |
| 38 | |
| 39 | extern const uint8_t sha384_der_prefix[]; |
| 40 | |
| 41 | void sha384_starts(sha512_context * ctx); |
| 42 | void sha384_update(sha512_context *ctx, const uint8_t *input, uint32_t length); |
| 43 | void sha384_finish(sha512_context * ctx, uint8_t digest[SHA384_SUM_LEN]); |
| 44 | |
| 45 | void sha384_csum_wd(const unsigned char *input, unsigned int ilen, |
| 46 | unsigned char *output, unsigned int chunk_sz); |
| 47 | |
Reuben Dowle | 1908fd9 | 2020-04-16 17:36:52 +1200 | [diff] [blame] | 48 | #endif /* _SHA512_H */ |