summaryrefslogtreecommitdiff
path: root/third_party/tinysha256/tinysha256.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/tinysha256/tinysha256.h')
-rw-r--r--third_party/tinysha256/tinysha256.h30
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 */
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com