diff options
| author | info@mode42.com <info@mode42.com> | 2026-08-08 03:54:55 +0000 |
|---|---|---|
| committer | info@mode42.com <info@mode42.com> | 2026-08-08 03:54:55 +0000 |
| commit | 20cb29c2f8c5c87bc590896854a20b1473ceb358 (patch) | |
| tree | 2857f41513a56ad41af97b57362639298aa7f033 /third_party/tinysha256/tinysha256.h | |
#2
Diffstat (limited to 'third_party/tinysha256/tinysha256.h')
| -rw-r--r-- | third_party/tinysha256/tinysha256.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/tinysha256/tinysha256.h b/third_party/tinysha256/tinysha256.h new file mode 100644 index 0000000..2e9ae96 --- /dev/null +++ b/third_party/tinysha256/tinysha256.h @@ -0,0 +1,30 @@ +#ifndef TINYSHA256_H +#define TINYSHA256_H + +/* + * tinysha256 — public-domain SHA-256 for HyBBX (bundled, no external deps). + * Adapted from the Unlicense implementation by 983 (https://github.com/983/SHA-256). + */ + +#include <stddef.h> +#include <stdint.h> + +#define TINYSHA256_HEX_SIZE (64 + 1) +#define TINYSHA256_BYTES_SIZE 32 + +void tinysha256_hex(const void *src, size_t n_bytes, char *dst_hex65); +void tinysha256_bytes(const void *src, size_t n_bytes, void *dst_bytes32); + +typedef struct tinysha256_ctx { + uint32_t state[8]; + uint8_t buffer[64]; + uint64_t n_bits; + uint8_t buffer_counter; +} tinysha256_ctx_t; + +void tinysha256_init(tinysha256_ctx_t *ctx); +void tinysha256_append(tinysha256_ctx_t *ctx, const void *data, size_t n_bytes); +void tinysha256_finalize_hex(tinysha256_ctx_t *ctx, char *dst_hex65); +void tinysha256_finalize_bytes(tinysha256_ctx_t *ctx, void *dst_bytes32); + +#endif /* TINYSHA256_H */ |
