From 2278df1493e064c197913e49b5d1935942d83448 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 6 May 2025 16:57:32 -0700 Subject: initial import --- include/sha256.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/sha256.h (limited to 'include/sha256.h') 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 +#include + +/****************************** 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 -- cgit v1.2.3