diff options
author | Daniel Schadt <kingdread@gmx.de> | 2025-04-17 12:56:44 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2025-04-17 12:56:44 +0200 |
commit | 9287a6cdc37c7c37e744f8418a13a74bb0e629ef (patch) | |
tree | f4d349e0d4ece886fda31f755b08163485a7a02e /aezref/aezv5/ref/blake2b.h | |
parent | 66814768f8c172d6996d037064924c908245a951 (diff) | |
download | zears-9287a6cdc37c7c37e744f8418a13a74bb0e629ef.tar.gz zears-9287a6cdc37c7c37e744f8418a13a74bb0e629ef.tar.bz2 zears-9287a6cdc37c7c37e744f8418a13a74bb0e629ef.zip |
fuzz against slow aez-ref, not fast aez-ni
Two reasons:
First, this allows us to test more of the algorithm, as the (slow)
reference implementation supports multiple associated data items, large
values for tau, ...
Second, this avoids the segfault crash, which is a limit of the fast
implementation (the assumption there is that data is aligned properly,
and even a read out-of-bounds will not cause a segfault).
Diffstat (limited to 'aezref/aezv5/ref/blake2b.h')
-rw-r--r-- | aezref/aezv5/ref/blake2b.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/aezref/aezv5/ref/blake2b.h b/aezref/aezv5/ref/blake2b.h new file mode 100644 index 0000000..c4ebc4a --- /dev/null +++ b/aezref/aezv5/ref/blake2b.h @@ -0,0 +1,38 @@ +// blake2b.h +// BLAKE2b Hashing Context and API Prototypes + +#ifndef BLAKE2B_H +#define BLAKE2B_H + +#include <stdint.h> +#include <stddef.h> + +// state context +typedef struct { + uint8_t b[128]; // input buffer + uint64_t h[8]; // chained state + uint64_t t[2]; // total number of bytes + size_t c; // pointer for b[] + size_t outlen; // digest size +} blake2b_ctx; + +// Initialize the hashing context "ctx" with optional key "key". +// 1 <= outlen <= 64 gives the digest size in bytes. +// Secret key (also <= 64 bytes) is optional (keylen = 0). +int blake2b_init(blake2b_ctx *ctx, size_t outlen, + const void *key, size_t keylen); // secret key + +// Add "inlen" bytes from "in" into the hash. +void blake2b_update(blake2b_ctx *ctx, // context + const void *in, size_t inlen); // data to be hashed + +// Generate the message digest (size given in init). +// Result placed in "out". +void blake2b_final(blake2b_ctx *ctx, void *out); + +// All-in-one convenience function. +int blake2b(void *out, size_t outlen, // return buffer for digest + const void *key, size_t keylen, // optional secret key + const void *in, size_t inlen); // data to be hashed + +#endif |