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