diff options
| author | daniel <daniel@planethacker.net> | 2025-05-06 16:57:32 -0700 |
|---|---|---|
| committer | daniel <daniel@planethacker.net> | 2025-05-06 16:57:32 -0700 |
| commit | 2278df1493e064c197913e49b5d1935942d83448 (patch) | |
| tree | 42f06ab2f76e2ddf228bafbb03f79621975a4534 /include/sha256.h | |
initial import
Diffstat (limited to 'include/sha256.h')
| -rw-r--r-- | include/sha256.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/sha256.h b/include/sha256.h new file mode 100644 index 0000000..72cf9c3 --- /dev/null +++ b/include/sha256.h @@ -0,0 +1,40 @@ +/********************************************************************* +* Filename: sha256.h +* Author: Brad Conte (brad AT bradconte.com) +* Copyright: +* Disclaimer: This code is presented "as is" without any guarantees. +* Details: Defines the API for the corresponding SHA256 implementation. +*********************************************************************/ + +#ifndef SHA256_H +#define SHA256_H + +/*************************** HEADER FILES ***************************/ +#include <stddef.h> +#include <stdint.h> + +/****************************** MACROS ******************************/ +#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest +#define SHA256_DIGEST_LENGTH SHA256_BLOCK_SIZE +#define SHA256_TOO_LARGE "TOOLARGETOHASH" + +#undef SHA256_SHOW_ERRORS // for debugging + +/**************************** DATA TYPES ****************************/ +typedef unsigned char BYTE; // 8-bit byte +typedef uint32_t WORD; // 32-bit word + +typedef struct { + BYTE data[64]; + WORD datalen; + uint64_t bitlen; + //unsigned long long bitlen; + WORD state[8]; +} SHA256_CTX; + +/*********************** FUNCTION DECLARATIONS **********************/ +void sha256_init(SHA256_CTX *); +void sha256_update(SHA256_CTX *, const BYTE [], size_t); +void sha256_final(SHA256_CTX *, BYTE []); +char *sha256_digest_file(const char *); +#endif // SHA256_H |
