Import the base tree (MIT, see LICENSE)

This commit is contained in:
Valiantsin Dzerakh
2026-11-04 22:16:41 +03:00
committed by chrg6
commit 0478c13e45
734 changed files with 233953 additions and 0 deletions

16
runtime/sha256.h Normal file
View File

@@ -0,0 +1,16 @@
// SHA-256 (FIPS 180-4), streaming. Uses the x86 SHA extensions when the CPU has them, portable C otherwise.
#pragma once
#include <stddef.h>
#include <stdint.h>
typedef struct {
uint32_t h[8];
uint64_t bytes; // message bytes so far
uint8_t buf[64]; // a partial block
uint32_t used;
} Sha256;
void sha256_init(Sha256 *s);
void sha256_update(Sha256 *s, const void *data, size_t n);
void sha256_final(Sha256 *s, uint8_t out[32]);
void sha256(const void *data, size_t n, uint8_t out[32]); // the three above in one call