/* sha512.h -- freestanding SHA-512 (FIPS 180-4 / RFC 6234), C99, no libc * beyond memcpy/memset (both available in the kernel via * src/starkernel/vm/host/shim.c). No __int128 used -- 64-bit words only, * portable to amd64/aarch64/riscv64 without libgcc helpers. */ #ifndef SHA512_H #define SHA512_H #include #include typedef struct { uint64_t state[8]; uint64_t bitlen; /* total message length in bits, low 64 bits * (SHA-512 defines a 128-bit length field; a * single uint64_t of bit-length is enough for * any message this kernel will ever hash -- * capsules and certs, not exabyte streams) */ uint8_t buf[128]; size_t buf_len; } sha512_ctx_t; void sha512_init(sha512_ctx_t *ctx); void sha512_update(sha512_ctx_t *ctx, const uint8_t *data, size_t len); void sha512_final(sha512_ctx_t *ctx, uint8_t out[64]); /* Convenience one-shot. */ void sha512(const uint8_t *data, size_t len, uint8_t out[64]); #endif /* SHA512_H */