nbos

nbos

https://git.tonybtw.com/nbos.git git://git.tonybtw.com/nbos.git
621 bytes raw
1
#ifndef NB_HASH_H
2
#define NB_HASH_H
3
4
#include <stddef.h>
5
#include <stdint.h>
6
7
typedef struct {
8
    uint32_t state[8];
9
    uint64_t bitcount;
10
    uint8_t  buffer[64];
11
    size_t   buffer_used;
12
} sha256_ctx;
13
14
void sha256_init  (sha256_ctx *ctx);
15
void sha256_update(sha256_ctx *ctx, const void *data, size_t len);
16
void sha256_final (sha256_ctx *ctx, uint8_t out[32]);
17
18
void sha256_hash(const void *data, size_t len, uint8_t out[32]);
19
void sha256_hex(const uint8_t digest[32], char out[65]);
20
21
[[nodiscard]] bool sha256_verify_file(
22
    const char *path,
23
    const char *expected_hex,
24
    char        actual_hex[65]);
25
26
#endif