picofuse

hash.h
Go to the documentation of this file.
1 
15 #pragma once
16 #include "io.h"
17 #include <stdbool.h>
18 #include <stddef.h>
19 #include <stdint.h>
20 
26 #ifndef SYS_HASH_SIZE
27 #define SYS_HASH_SIZE 32
28 #endif
29 
35 #ifndef SYS_HASH_CAPACITY
36 #ifdef SYSTEM_NAME_PICO
37 #define SYS_HASH_CAPACITY 1
38 #else
39 #define SYS_HASH_CAPACITY 4
40 #endif
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
48 // TYPES
49 
54 typedef enum sys_hash_algorithm_t {
58 
64 typedef struct sys_hash_t sys_hash_t;
65 
67 // LIFECYCLE
68 
84 sys_hash_t *sys_hash_init(sys_hash_algorithm_t algorithm);
85 
94 void sys_hash_deinit(sys_hash_t *hash);
95 
98 // PUBLIC METHODS
100 
110 size_t sys_hash_size(const sys_hash_t *hash);
111 
125 bool sys_hash_update(sys_hash_t *hash, sys_iostream_t *stream, size_t size);
126 
137 const uint8_t *sys_hash_finalize(sys_hash_t *hash);
138 
145 uintptr_t sys_hash_djb2(const char *str);
146 
149 #ifdef __cplusplus
150 }
151 #endif
size_t sys_hash_size(const sys_hash_t *hash)
Return the digest size in bytes for a hash context.
Opaque byte streams for reading, writing, seeking, and readiness notification.
struct sys_iostream_t sys_iostream_t
An opaque byte stream.
Definition: io.h:70
bool sys_hash_update(sys_hash_t *hash, sys_iostream_t *stream, size_t size)
Update a hash context by reading more data from a stream.
MD5 digest.
Definition: hash.h:55
struct sys_hash_t sys_hash_t
Hash context.
Definition: hash.h:64
sys_hash_algorithm_t
Hash algorithm identifiers.
Definition: hash.h:54
const uint8_t * sys_hash_finalize(sys_hash_t *hash)
Finalize the hash computation.
void sys_hash_deinit(sys_hash_t *hash)
Release a hash context.
sys_hash_t * sys_hash_init(sys_hash_algorithm_t algorithm)
Initialize a new hash context.
uintptr_t sys_hash_djb2(const char *str)
Compute a djb2 hash for a NULL-terminated string.
SHA-256 digest.
Definition: hash.h:56