wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
sha512.h
1#ifndef HASH_SHA512_H
2#define HASH_SHA512_H
3
5
6/* FIPS 180-4 SHA-512. Produces a 64-byte digest. */
7
8#define SHA512_DIGEST 64
9#define SHA512_BLOCK 128
10
13typedef struct {
14 u64 h[8];
16 u8 buf[SHA512_BLOCK];
19
20void sha512_init(sha512_ctx* s);
21void sha512_update(sha512_ctx* s, const u8* data, usz len);
22void sha512_final(sha512_ctx* s, u8 out[SHA512_DIGEST]);
23
24/* One-shot convenience: digest of data[0..len). */
25void sha512(const u8* data, usz len, u8 out[SHA512_DIGEST]);
26
27#endif
Incremental SHA-512 state: running hash, total bytes absorbed, and the partial-block buffer.
Definition sha512.h:13
u8 buf[SHA512_BLOCK]
partial-block buffer
Definition sha512.h:16
usz buf_len
bytes pending in buf
Definition sha512.h:17
u64 h[8]
running hash state
Definition sha512.h:14
u64 total
total bytes absorbed (low 64 bits suffice here)
Definition sha512.h:15
Linux direct syscalls.
u64 usz
unsigned size (size_t equivalent)
Definition types.h:20
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18
unsigned long u64
unsigned 64-bit integer
Definition types.h:13