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

Classes

struct  IvParsed
 Result of parsing an IV header from encrypted data. More...
 

Functions

void fill_random_bytes (uint8_t *buf, size_t size)
 Fill a buffer with cryptographically random bytes using the best available OS-level CSPRNG (CWE-338: Use of Cryptographically Weak PRNG).
 
std::vector< uint8_t > generate_iv (size_t iv_size)
 Generate a random initialization vector of the specified size.
 
std::vector< uint8_t > prepend_iv (const std::vector< uint8_t > &iv, const std::vector< uint8_t > &ciphertext)
 Prepend an IV header to ciphertext: [1 byte: iv.size()] [iv bytes] [ciphertext].
 
expected< IvParsedparse_iv_header (const uint8_t *data, size_t size)
 Parse the IV header from encrypted data: [1 byte: iv_size] [iv] [ciphertext].
 

Function Documentation

◆ fill_random_bytes()

void signet::forge::crypto::detail::cipher::fill_random_bytes ( uint8_t *  buf,
size_t  size 
)
inline

Fill a buffer with cryptographically random bytes using the best available OS-level CSPRNG (CWE-338: Use of Cryptographically Weak PRNG).

  • macOS/BSD: arc4random_buf (seeded from /dev/urandom, never fails)
  • Linux: getrandom(2) with EINTR retry (blocks until urandom seeded)
  • Windows: BCryptGenRandom with ULONG size validation (CWE-190)

Definition at line 108 of file cipher_interface.hpp.

◆ generate_iv()

std::vector< uint8_t > signet::forge::crypto::detail::cipher::generate_iv ( size_t  iv_size)
inline

Generate a random initialization vector of the specified size.

Parameters
iv_sizeNumber of random bytes to generate (12 for GCM, 16 for CTR).
Returns
Vector of cryptographically random bytes.

Definition at line 143 of file cipher_interface.hpp.

◆ parse_iv_header()

expected< IvParsed > signet::forge::crypto::detail::cipher::parse_iv_header ( const uint8_t *  data,
size_t  size 
)
inline

Parse the IV header from encrypted data: [1 byte: iv_size] [iv] [ciphertext].

Parameters
dataPointer to the encrypted data buffer.
sizeTotal size of the encrypted data.
Returns
Parsed IV and ciphertext pointers, or an error if malformed.

Definition at line 174 of file cipher_interface.hpp.

◆ prepend_iv()

std::vector< uint8_t > signet::forge::crypto::detail::cipher::prepend_iv ( const std::vector< uint8_t > &  iv,
const std::vector< uint8_t > &  ciphertext 
)
inline

Prepend an IV header to ciphertext: [1 byte: iv.size()] [iv bytes] [ciphertext].

Parameters
ivInitialization vector bytes.
ciphertextEncrypted data (may include auth tag for GCM).
Returns
Combined output with IV header prepended.

Definition at line 153 of file cipher_interface.hpp.