Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::crypto::detail::sha256 Namespace Reference

Functions

constexpr uint32_t rotr (uint32_t x, int n)
 Right-rotate a 32-bit word by n bits.
 
constexpr uint32_t Ch (uint32_t x, uint32_t y, uint32_t z)
 SHA-256 logical functions (FIPS 180-4 Section 4.1.2)
 
constexpr uint32_t Maj (uint32_t x, uint32_t y, uint32_t z)
 
constexpr uint32_t Sigma0 (uint32_t x)
 
constexpr uint32_t Sigma1 (uint32_t x)
 
constexpr uint32_t sigma0 (uint32_t x)
 
constexpr uint32_t sigma1 (uint32_t x)
 
uint32_t load_be32 (const uint8_t *p)
 Load a big-endian uint32 from 4 bytes.
 
void store_be32 (uint8_t *p, uint32_t v)
 Store a uint32 as 4 big-endian bytes.
 
void store_be64 (uint8_t *p, uint64_t v)
 Store a uint64 as 8 big-endian bytes.
 
void compress (uint32_t h[8], const uint8_t block[64])
 Process a single 64-byte (512-bit) message block.
 
std::array< uint8_t, 32 > sha256 (const uint8_t *data, size_t size)
 Compute SHA-256 hash of arbitrary-length input.
 
std::array< uint8_t, 32 > sha256 (const std::vector< uint8_t > &data)
 Convenience overload: hash a vector of bytes.
 
std::array< uint8_t, 32 > sha256_concat (const uint8_t *a, size_t a_size, const uint8_t *b, size_t b_size)
 Hash concatenation of two byte spans with domain separation: SHA-256(label || a || b).
 

Function Documentation

◆ Ch()

constexpr uint32_t signet::forge::crypto::detail::sha256::Ch ( uint32_t  x,
uint32_t  y,
uint32_t  z 
)
inlineconstexpr

SHA-256 logical functions (FIPS 180-4 Section 4.1.2)

Definition at line 64 of file sha256.hpp.

◆ compress()

void signet::forge::crypto::detail::sha256::compress ( uint32_t  h[8],
const uint8_t  block[64] 
)
inline

Process a single 64-byte (512-bit) message block.

FIPS 180-4 Section 6.2.2: SHA-256 hash computation. Updates the 8-word hash state h[0..7] with one message block.

Definition at line 120 of file sha256.hpp.

◆ load_be32()

uint32_t signet::forge::crypto::detail::sha256::load_be32 ( const uint8_t *  p)
inline

Load a big-endian uint32 from 4 bytes.

Definition at line 89 of file sha256.hpp.

◆ Maj()

constexpr uint32_t signet::forge::crypto::detail::sha256::Maj ( uint32_t  x,
uint32_t  y,
uint32_t  z 
)
inlineconstexpr

Definition at line 68 of file sha256.hpp.

◆ rotr()

constexpr uint32_t signet::forge::crypto::detail::sha256::rotr ( uint32_t  x,
int  n 
)
inlineconstexpr

Right-rotate a 32-bit word by n bits.

Definition at line 59 of file sha256.hpp.

◆ sha256() [1/2]

std::array< uint8_t, 32 > signet::forge::crypto::detail::sha256::sha256 ( const std::vector< uint8_t > &  data)
inline

Convenience overload: hash a vector of bytes.

Definition at line 215 of file sha256.hpp.

◆ sha256() [2/2]

std::array< uint8_t, 32 > signet::forge::crypto::detail::sha256::sha256 ( const uint8_t *  data,
size_t  size 
)
inline

Compute SHA-256 hash of arbitrary-length input.

Returns a 32-byte (256-bit) digest.

Implements the full FIPS 180-4 algorithm:

  1. Pad message to 512-bit boundary (with 1-bit, zeros, 64-bit length)
  2. Process each 512-bit block through the compression function
  3. Output the final hash state as big-endian bytes

Definition at line 165 of file sha256.hpp.

◆ sha256_concat()

std::array< uint8_t, 32 > signet::forge::crypto::detail::sha256::sha256_concat ( const uint8_t *  a,
size_t  a_size,
const uint8_t *  b,
size_t  b_size 
)
inline

Hash concatenation of two byte spans with domain separation: SHA-256(label || a || b).

Used for hybrid key combining and HMAC-style constructions.

Domain separation label prevents cross-protocol attacks per NIST SP 800-227 (Final, Sep 2025) ยง4.2 and Barker & Roginsky "Transitioning the Use of Cryptographic Algorithms" guidance.

Definition at line 226 of file sha256.hpp.

◆ Sigma0()

constexpr uint32_t signet::forge::crypto::detail::sha256::Sigma0 ( uint32_t  x)
inlineconstexpr

Definition at line 72 of file sha256.hpp.

◆ sigma0()

constexpr uint32_t signet::forge::crypto::detail::sha256::sigma0 ( uint32_t  x)
inlineconstexpr

Definition at line 80 of file sha256.hpp.

◆ Sigma1()

constexpr uint32_t signet::forge::crypto::detail::sha256::Sigma1 ( uint32_t  x)
inlineconstexpr

Definition at line 76 of file sha256.hpp.

◆ sigma1()

constexpr uint32_t signet::forge::crypto::detail::sha256::sigma1 ( uint32_t  x)
inlineconstexpr

Definition at line 84 of file sha256.hpp.

◆ store_be32()

void signet::forge::crypto::detail::sha256::store_be32 ( uint8_t *  p,
uint32_t  v 
)
inline

Store a uint32 as 4 big-endian bytes.

Definition at line 97 of file sha256.hpp.

◆ store_be64()

void signet::forge::crypto::detail::sha256::store_be64 ( uint8_t *  p,
uint64_t  v 
)
inline

Store a uint64 as 8 big-endian bytes.

Definition at line 105 of file sha256.hpp.