1 | /********************************************************************* |
2 | * Source: https://github.com/B-Con/crypto-algorithms |
3 | * Filename: sha256.h |
4 | * Author: Brad Conte (brad AT bradconte.com) |
5 | * Copyright: This code is released into the public domain. |
6 | * Disclaimer: This code is presented "as is" without any guarantees. |
7 | * Details: Defines the API for the corresponding SHA1 implementation. |
8 | *********************************************************************/ |
9 | |
10 | #ifndef SHA256_H |
11 | #define SHA256_H |
12 | |
13 | /*************************** HEADER FILES ***************************/ |
14 | #include <stddef.h> |
15 | |
16 | /****************************** MACROS ******************************/ |
17 | #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest |
18 | |
19 | /**************************** DATA TYPES ****************************/ |
20 | typedef unsigned char BYTE; // 8-bit byte |
21 | typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines |
22 | |
23 | typedef struct { |
24 | BYTE data[64]; |
25 | WORD datalen; |
26 | unsigned long long bitlen; |
27 | WORD state[8]; |
28 | } CRYAL_SHA256_CTX; |
29 | |
30 | /*********************** FUNCTION DECLARATIONS **********************/ |
31 | void sha256_init(CRYAL_SHA256_CTX *ctx); |
32 | void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len); |
33 | void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]); |
34 | |
35 | #endif // SHA256_H |
36 | |