CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::core::hash Namespace Reference

Functions

void fnv1a_mix_byte (uint32_t &hash, uint8_t value)
 Mixes a single value into a running FNV-1a 32-bit hash.
void fnv1a_mix_u32 (uint32_t &hash, uint32_t value)
 Mixes a 32-bit word into a running FNV-1a 32-bit hash.
uint32_t fnv1a_32 (const uint8_t *data, size_t len)
 Computes FNV-1a 32-bit hash over a byte buffer.

Variables

static constexpr uint32_t FNV1A_32_OFFSET_BASIS = 0x811C9DC5u
 FNV-1a 32-bit constants (Fowler/Noll/Vo).
static constexpr uint32_t FNV1A_32_PRIME = 0x01000193u

Function Documentation

◆ fnv1a_32()

uint32_t cdc::core::hash::fnv1a_32 ( const uint8_t * data,
size_t len )
inline

Computes FNV-1a 32-bit hash over a byte buffer.

Parameters
dataInput buffer.
lenBuffer length in bytes.
Returns
32-bit hash value.

Definition at line 52 of file Hash.h.

References FNV1A_32_OFFSET_BASIS, and fnv1a_mix_byte().

Referenced by fnv1a_hash().

◆ fnv1a_mix_byte()

void cdc::core::hash::fnv1a_mix_byte ( uint32_t & hash,
uint8_t value )
inline

Mixes a single value into a running FNV-1a 32-bit hash.

Parameters
hashIn/out running hash; pass FNV1A_32_OFFSET_BASIS initially.
valueByte to mix in.

Definition at line 28 of file Hash.h.

References FNV1A_32_PRIME.

Referenced by fnv1a_32().

◆ fnv1a_mix_u32()

void cdc::core::hash::fnv1a_mix_u32 ( uint32_t & hash,
uint32_t value )
inline

Mixes a 32-bit word into a running FNV-1a 32-bit hash.

Parameters
hashIn/out running hash; pass FNV1A_32_OFFSET_BASIS initially.
valueWord to mix in.

Convenience for callers that hash structured numeric fields rather than byte buffers; matches the pre-existing pattern in TropicSlotMap.

Definition at line 41 of file Hash.h.

References FNV1A_32_PRIME.

Referenced by cdc::core::TropicSlotMap::computeMapSignature().

Variable Documentation

◆ FNV1A_32_OFFSET_BASIS

uint32_t cdc::core::hash::FNV1A_32_OFFSET_BASIS = 0x811C9DC5u
staticconstexpr

◆ FNV1A_32_PRIME

uint32_t cdc::core::hash::FNV1A_32_PRIME = 0x01000193u
staticconstexpr

Definition at line 21 of file Hash.h.

Referenced by fnv1a_mix_byte(), and fnv1a_mix_u32().