b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #ifndef _SHA256_H |
| 2 | #define _SHA256_H |
| 3 | |
| 4 | #define SHA256_SUM_LEN 32 |
| 5 | |
| 6 | /* Reset watchdog each time we process this many bytes */ |
| 7 | #define CHUNKSZ_SHA256 (64 * 1024) |
| 8 | |
| 9 | typedef struct { |
| 10 | uint32_t total[2]; |
| 11 | uint32_t state[8]; |
| 12 | uint8_t buffer[64]; |
| 13 | int tee_sha256; |
| 14 | } sha256_context; |
| 15 | |
| 16 | void sha256_starts(sha256_context * ctx); |
| 17 | void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length); |
| 18 | void sha256_finish(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]); |
| 19 | |
| 20 | void sha256_starts_neon(sha256_context * ctx); |
| 21 | void sha256_update_neon(sha256_context *ctx, const uint8_t *input, uint32_t length); |
| 22 | void sha256_finish_neon(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]); |
| 23 | |
| 24 | #ifndef CONFIG_TEE_OS |
| 25 | #ifdef CONFIG_ASR_TE200 |
| 26 | void sha256_starts_te200(sha256_context * ctx); |
| 27 | void sha256_update_te200(sha256_context *ctx, const uint8_t *input, uint32_t length); |
| 28 | void sha256_finish_te200(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]); |
| 29 | #endif |
| 30 | |
| 31 | #ifdef CONFIG_ASR_BCM |
| 32 | void sha256_starts_bcm(sha256_context * ctx); |
| 33 | void sha256_update_bcm(sha256_context *ctx, const uint8_t *input, uint32_t length); |
| 34 | void sha256_finish_bcm(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]); |
| 35 | #endif |
| 36 | |
| 37 | #else |
| 38 | void sha256_starts_optee(sha256_context * ctx); |
| 39 | void sha256_update_optee(sha256_context *ctx, const uint8_t *input, uint32_t length); |
| 40 | void sha256_finish_optee(sha256_context * ctx, uint8_t digest[32]); |
| 41 | #endif |
| 42 | |
| 43 | void sha256_csum_wd(const unsigned char *input, unsigned int ilen, |
| 44 | unsigned char *output, unsigned int chunk_sz); |
| 45 | |
| 46 | #endif /* _SHA256_H */ |