Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 1 | #ifndef _SHA256_H |
| 2 | #define _SHA256_H |
| 3 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 4 | #include <linux/types.h> |
| 5 | |
Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 6 | #define SHA256_SUM_LEN 32 |
Andrew Duda | 3db9ff0 | 2016-11-08 18:53:40 +0000 | [diff] [blame] | 7 | #define SHA256_DER_LEN 19 |
| 8 | |
| 9 | extern const uint8_t sha256_der_prefix[]; |
Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 10 | |
Simon Glass | 0df8243 | 2012-12-05 14:46:34 +0000 | [diff] [blame] | 11 | /* Reset watchdog each time we process this many bytes */ |
| 12 | #define CHUNKSZ_SHA256 (64 * 1024) |
| 13 | |
Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 14 | typedef struct { |
| 15 | uint32_t total[2]; |
| 16 | uint32_t state[8]; |
| 17 | uint8_t buffer[64]; |
| 18 | } sha256_context; |
| 19 | |
| 20 | void sha256_starts(sha256_context * ctx); |
Simon Glass | 0df8243 | 2012-12-05 14:46:34 +0000 | [diff] [blame] | 21 | void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length); |
Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 22 | void sha256_finish(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]); |
| 23 | |
Simon Glass | 0df8243 | 2012-12-05 14:46:34 +0000 | [diff] [blame] | 24 | void sha256_csum_wd(const unsigned char *input, unsigned int ilen, |
| 25 | unsigned char *output, unsigned int chunk_sz); |
| 26 | |
Jean-Christophe PLAGNIOL-VILLARD | c58a6b8 | 2008-06-07 12:29:52 +0200 | [diff] [blame] | 27 | #endif /* _SHA256_H */ |