1 #pragma once
2 
3 #include "../shared/ufotypes.h"
4 
5 typedef struct {
6 	uint64_t total[2];
7 	uint64_t state[8];
8 	byte buffer[64];
9 } sha2_context;
10 
11 /**
12  * Core SHA-256 functions
13  */
14 void Com_SHA2Starts (sha2_context *ctx);
15 void Com_SHA2Update (sha2_context *ctx, const byte* input, uint32_t length);
16 void Com_SHA2Finish (sha2_context *ctx, byte digest[32]);
17 
18 /**
19  * @brief Output SHA-256(file contents)
20  * @return @c true if successful
21  */
22 bool Com_SHA2File (const char* filename, byte digest[32]);
23 
24 /**
25  * @brief Output SHA-256(buf)
26  */
27 void Com_SHA2Csum (const byte* buf, uint32_t buflen, byte digest[32]);
28 
29 /**
30  * @brief Output HMAC-SHA-256(buf,key)
31  */
32 void Com_SHA2Hmac (const byte* buf, uint32_t buflen, const byte* key, uint32_t keylen, byte digest[32]);
33 
34 void Com_SHA2ToHex (const byte digest[32], char final[65]);
35