sha256.h (1094B)
1 /********************************************************************* 2 * Filename: sha256.h 3 * Author: Brad Conte (brad AT bradconte.com) 4 * Copyright: 5 * Disclaimer: This code is presented "as is" without any guarantees. 6 * Details: Defines the API for the corresponding SHA1 implementation. 7 *********************************************************************/ 8 9 #ifndef SHA256_H 10 #define SHA256_H 11 12 /*************************** HEADER FILES ***************************/ 13 #include <stddef.h> 14 #include <stdint.h> 15 16 /****************************** MACROS ******************************/ 17 #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest 18 19 /**************************** DATA TYPES ****************************/ 20 typedef struct { 21 uint8_t data[64]; 22 uint32_t datalen; 23 uint64_t bitlen; 24 uint32_t state[8]; 25 } SHA256_CTX; 26 27 /*********************** FUNCTION DECLARATIONS **********************/ 28 void sha256_init(SHA256_CTX *ctx); 29 void sha256_update(SHA256_CTX *ctx, const uint8_t data[], size_t len); 30 void sha256_final(SHA256_CTX *ctx, uint8_t hash[]); 31 32 #endif // SHA256_H