mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-04 15:06:13 +02:00
b5f1e925f7
This is simpler than sometimes incrementing by CHUNK_LEN and other times incrementing by BLOCK_LEN.
37 lines
1.0 KiB
C
37 lines
1.0 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#define BLAKE3_KEY_LEN 32
|
|
#define BLAKE3_OUT_LEN 32
|
|
#define BLAKE3_BLOCK_LEN 64
|
|
#define BLAKE3_CHUNK_LEN 1024
|
|
#define BLAKE3_MAX_DEPTH 53
|
|
#define BLAKE3_MAX_SIMD_DEGREE 16
|
|
|
|
typedef struct {
|
|
uint32_t cv[8];
|
|
uint64_t chunk_counter;
|
|
uint8_t buf[BLAKE3_BLOCK_LEN];
|
|
uint8_t buf_len;
|
|
uint8_t blocks_compressed;
|
|
uint8_t flags;
|
|
} blake3_chunk_state;
|
|
|
|
typedef struct {
|
|
uint32_t key[8];
|
|
blake3_chunk_state chunk;
|
|
uint8_t cv_stack_len;
|
|
uint8_t cv_stack[BLAKE3_MAX_DEPTH * BLAKE3_OUT_LEN];
|
|
} blake3_hasher;
|
|
|
|
void blake3_hasher_init(blake3_hasher *self);
|
|
void blake3_hasher_init_keyed(blake3_hasher *self,
|
|
const uint8_t key[BLAKE3_KEY_LEN]);
|
|
void blake3_hasher_init_derive_key(blake3_hasher *self,
|
|
const uint8_t key[BLAKE3_KEY_LEN]);
|
|
void blake3_hasher_update(blake3_hasher *self, const void *input,
|
|
size_t input_len);
|
|
void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out,
|
|
size_t out_len);
|