LLVM 20.0.0git
Classes | Functions
blake3.c File Reference
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "blake3_impl.h"

Go to the source code of this file.

Classes

struct  output_t
 

Functions

const charllvm_blake3_version (void)
 
INLINE void chunk_state_init (blake3_chunk_state *self, const uint32_t key[8], uint8_t flags)
 
INLINE void chunk_state_reset (blake3_chunk_state *self, const uint32_t key[8], uint64_t chunk_counter)
 
INLINE size_t chunk_state_len (const blake3_chunk_state *self)
 
INLINE size_t chunk_state_fill_buf (blake3_chunk_state *self, const uint8_t *input, size_t input_len)
 
INLINE uint8_t chunk_state_maybe_start_flag (const blake3_chunk_state *self)
 
INLINE output_t make_output (const uint32_t input_cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags)
 
INLINE void output_chaining_value (const output_t *self, uint8_t cv[32])
 
INLINE void output_root_bytes (const output_t *self, uint64_t seek, uint8_t *out, size_t out_len)
 
INLINE void chunk_state_update (blake3_chunk_state *self, const uint8_t *input, size_t input_len)
 
INLINE output_t chunk_state_output (const blake3_chunk_state *self)
 
INLINE output_t parent_output (const uint8_t block[BLAKE3_BLOCK_LEN], const uint32_t key[8], uint8_t flags)
 
INLINE size_t left_len (size_t content_len)
 
INLINE size_t compress_chunks_parallel (const uint8_t *input, size_t input_len, const uint32_t key[8], uint64_t chunk_counter, uint8_t flags, uint8_t *out)
 
INLINE size_t compress_parents_parallel (const uint8_t *child_chaining_values, size_t num_chaining_values, const uint32_t key[8], uint8_t flags, uint8_t *out)
 
static size_t blake3_compress_subtree_wide (const uint8_t *input, size_t input_len, const uint32_t key[8], uint64_t chunk_counter, uint8_t flags, uint8_t *out)
 
INLINE void compress_subtree_to_parent_node (const uint8_t *input, size_t input_len, const uint32_t key[8], uint64_t chunk_counter, uint8_t flags, uint8_t out[2 *BLAKE3_OUT_LEN])
 
INLINE void hasher_init_base (blake3_hasher *self, const uint32_t key[8], uint8_t flags)
 
void llvm_blake3_hasher_init (blake3_hasher *self)
 
void llvm_blake3_hasher_init_keyed (blake3_hasher *self, const uint8_t key[BLAKE3_KEY_LEN])
 
void llvm_blake3_hasher_init_derive_key_raw (blake3_hasher *self, const void *context, size_t context_len)
 
void llvm_blake3_hasher_init_derive_key (blake3_hasher *self, const char *context)
 
INLINE void hasher_merge_cv_stack (blake3_hasher *self, uint64_t total_len)
 
INLINE void hasher_push_cv (blake3_hasher *self, uint8_t new_cv[BLAKE3_OUT_LEN], uint64_t chunk_counter)
 
void llvm_blake3_hasher_update (blake3_hasher *self, const void *input, size_t input_len)
 
void llvm_blake3_hasher_finalize (const blake3_hasher *self, uint8_t *out, size_t out_len)
 
void llvm_blake3_hasher_finalize_seek (const blake3_hasher *self, uint64_t seek, uint8_t *out, size_t out_len)
 
void llvm_blake3_hasher_reset (blake3_hasher *self)
 

Function Documentation

◆ blake3_compress_subtree_wide()

static size_t blake3_compress_subtree_wide ( const uint8_t *  input,
size_t  input_len,
const uint32_t  key[8],
uint64_t  chunk_counter,
uint8_t  flags,
uint8_t *  out 
)
static

◆ chunk_state_fill_buf()

INLINE size_t chunk_state_fill_buf ( blake3_chunk_state self,
const uint8_t *  input,
size_t  input_len 
)

Definition at line 41 of file blake3.c.

References BLAKE3_BLOCK_LEN.

Referenced by chunk_state_update().

◆ chunk_state_init()

INLINE void chunk_state_init ( blake3_chunk_state self,
const uint32_t  key[8],
uint8_t  flags 
)

Definition at line 17 of file blake3.c.

References BLAKE3_BLOCK_LEN, and BLAKE3_KEY_LEN.

Referenced by compress_chunks_parallel(), hasher_init_base(), and llvm_blake3_hasher_update().

◆ chunk_state_len()

INLINE size_t chunk_state_len ( const blake3_chunk_state self)

Definition at line 36 of file blake3.c.

References BLAKE3_BLOCK_LEN.

Referenced by llvm_blake3_hasher_finalize_seek(), and llvm_blake3_hasher_update().

◆ chunk_state_maybe_start_flag()

INLINE uint8_t chunk_state_maybe_start_flag ( const blake3_chunk_state self)

Definition at line 53 of file blake3.c.

References CHUNK_START.

Referenced by chunk_state_output(), and chunk_state_update().

◆ chunk_state_output()

INLINE output_t chunk_state_output ( const blake3_chunk_state self)

◆ chunk_state_reset()

INLINE void chunk_state_reset ( blake3_chunk_state self,
const uint32_t  key[8],
uint64_t  chunk_counter 
)

Definition at line 27 of file blake3.c.

References BLAKE3_BLOCK_LEN, and BLAKE3_KEY_LEN.

Referenced by llvm_blake3_hasher_reset(), and llvm_blake3_hasher_update().

◆ chunk_state_update()

INLINE void chunk_state_update ( blake3_chunk_state self,
const uint8_t *  input,
size_t  input_len 
)

◆ compress_chunks_parallel()

INLINE size_t compress_chunks_parallel ( const uint8_t *  input,
size_t  input_len,
const uint32_t  key[8],
uint64_t  chunk_counter,
uint8_t  flags,
uint8_t *  out 
)

◆ compress_parents_parallel()

INLINE size_t compress_parents_parallel ( const uint8_t *  child_chaining_values,
size_t  num_chaining_values,
const uint32_t  key[8],
uint8_t  flags,
uint8_t *  out 
)

◆ compress_subtree_to_parent_node()

INLINE void compress_subtree_to_parent_node ( const uint8_t *  input,
size_t  input_len,
const uint32_t  key[8],
uint64_t  chunk_counter,
uint8_t  flags,
uint8_t  out[2 *BLAKE3_OUT_LEN] 
)

◆ hasher_init_base()

INLINE void hasher_init_base ( blake3_hasher self,
const uint32_t  key[8],
uint8_t  flags 
)

◆ hasher_merge_cv_stack()

INLINE void hasher_merge_cv_stack ( blake3_hasher self,
uint64_t  total_len 
)

Definition at line 409 of file blake3.c.

References BLAKE3_OUT_LEN, output_chaining_value(), parent_output(), and popcnt().

Referenced by hasher_push_cv(), and llvm_blake3_hasher_update().

◆ hasher_push_cv()

INLINE void hasher_push_cv ( blake3_hasher self,
uint8_t  new_cv[BLAKE3_OUT_LEN],
uint64_t  chunk_counter 
)

Definition at line 452 of file blake3.c.

References BLAKE3_OUT_LEN, and hasher_merge_cv_stack().

Referenced by llvm_blake3_hasher_update().

◆ left_len()

INLINE size_t left_len ( size_t  content_len)

Definition at line 162 of file blake3.c.

References BLAKE3_CHUNK_LEN, and round_down_to_power_of_2().

Referenced by blake3_compress_subtree_wide().

◆ llvm_blake3_hasher_finalize()

void llvm_blake3_hasher_finalize ( const blake3_hasher self,
uint8_t *  out,
size_t  out_len 
)

◆ llvm_blake3_hasher_finalize_seek()

void llvm_blake3_hasher_finalize_seek ( const blake3_hasher self,
uint64_t  seek,
uint8_t *  out,
size_t  out_len 
)

◆ llvm_blake3_hasher_init()

void llvm_blake3_hasher_init ( blake3_hasher self)

Definition at line 374 of file blake3.c.

References hasher_init_base(), and IV.

◆ llvm_blake3_hasher_init_derive_key()

void llvm_blake3_hasher_init_derive_key ( blake3_hasher self,
const char context 
)

Definition at line 395 of file blake3.c.

References llvm_blake3_hasher_init_derive_key_raw().

◆ llvm_blake3_hasher_init_derive_key_raw()

void llvm_blake3_hasher_init_derive_key_raw ( blake3_hasher self,
const void *  context,
size_t  context_len 
)

◆ llvm_blake3_hasher_init_keyed()

void llvm_blake3_hasher_init_keyed ( blake3_hasher self,
const uint8_t  key[BLAKE3_KEY_LEN] 
)

Definition at line 376 of file blake3.c.

References hasher_init_base(), KEYED_HASH, and load_key_words().

◆ llvm_blake3_hasher_reset()

void llvm_blake3_hasher_reset ( blake3_hasher self)

Definition at line 622 of file blake3.c.

References chunk_state_reset().

◆ llvm_blake3_hasher_update()

void llvm_blake3_hasher_update ( blake3_hasher self,
const void *  input,
size_t  input_len 
)

◆ llvm_blake3_version()

const char * llvm_blake3_version ( void  )

Definition at line 15 of file blake3.c.

References BLAKE3_VERSION_STRING.

◆ make_output()

INLINE output_t make_output ( const uint32_t  input_cv[8],
const uint8_t  block[BLAKE3_BLOCK_LEN],
uint8_t  block_len,
uint64_t  counter,
uint8_t  flags 
)

◆ output_chaining_value()

INLINE void output_chaining_value ( const output_t self,
uint8_t  cv[32] 
)

◆ output_root_bytes()

INLINE void output_root_bytes ( const output_t self,
uint64_t  seek,
uint8_t *  out,
size_t  out_len 
)

◆ parent_output()

INLINE output_t parent_output ( const uint8_t  block[BLAKE3_BLOCK_LEN],
const uint32_t  key[8],
uint8_t  flags 
)

Definition at line 154 of file blake3.c.

References BLAKE3_BLOCK_LEN, block, make_output(), and PARENT.

Referenced by hasher_merge_cv_stack(), and llvm_blake3_hasher_finalize_seek().