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

Classes

struct  TlvField
 Parsed TLV (tag-length-value) field from serialized metadata. More...
 

Functions

void write_le32 (uint8_t *dst, uint32_t val)
 Write a 4-byte little-endian uint32 to dst.
 
uint32_t read_le32 (const uint8_t *src)
 Read a 4-byte little-endian uint32 from src.
 
void append_tlv (std::vector< uint8_t > &buf, uint32_t tag, const uint8_t *data, uint32_t len)
 Append a TLV field: [4-byte LE tag] [4-byte LE length] [data].
 
void append_tlv_i32 (std::vector< uint8_t > &buf, uint32_t tag, int32_t val)
 Append a TLV field containing a single int32_t (little-endian).
 
void append_tlv_u8 (std::vector< uint8_t > &buf, uint32_t tag, uint8_t val)
 Append a TLV field containing a single byte.
 
void append_tlv_str (std::vector< uint8_t > &buf, uint32_t tag, const std::string &s)
 Append a TLV field containing a string.
 
void append_tlv_blob (std::vector< uint8_t > &buf, uint32_t tag, const std::vector< uint8_t > &blob)
 Append a TLV field containing a blob.
 
bool read_tlv (const uint8_t *buf, size_t buf_size, size_t &offset, TlvField &field)
 Parse the next TLV field from a buffer.
 
bool tlv_to_i32 (const TlvField &field, int32_t &out)
 Read an int32 from a TLV field's data (must be exactly 4 bytes).
 
bool tlv_to_u8 (const TlvField &field, uint8_t &out)
 Read a uint8 from a TLV field's data (must be exactly 1 byte).
 
std::string tlv_to_str (const TlvField &field)
 Read a string from a TLV field's data.
 
std::vector< uint8_t > tlv_to_blob (const TlvField &field)
 Read a blob from a TLV field's data.
 

Variables

constexpr uint32_t MAX_TLV_LENGTH = 64u * 1024u * 1024u
 Maximum TLV field length (64 MB cap to prevent memory exhaustion from malformed data).
 
constexpr size_t MAX_METADATA_SIZE = 1024 * 1024
 Maximum total metadata size (1 MB cap to prevent memory exhaustion from crafted payloads, CWE-770).
 
TLV tag constants for key metadata serialization.
constexpr uint32_t TAG_KEY_MODE = 0x0001
 Tag: key mode (4 bytes, int32_t LE).
 
constexpr uint32_t TAG_KEY_MATERIAL = 0x0002
 Tag: raw key material (variable blob).
 
constexpr uint32_t TAG_KEY_ID = 0x0003
 Tag: KMS key identifier (variable UTF-8).
 
constexpr uint32_t TAG_ALGORITHM = 0x0010
 Tag: encryption algorithm (4 bytes, int32_t LE).
 
constexpr uint32_t TAG_FOOTER_ENCRYPTED = 0x0011
 Tag: footer-encrypted flag (1 byte, 0/1).
 
constexpr uint32_t TAG_AAD_PREFIX = 0x0012
 Tag: AAD prefix string (variable UTF-8).
 

Function Documentation

◆ append_tlv()

void signet::forge::crypto::detail::meta::append_tlv ( std::vector< uint8_t > &  buf,
uint32_t  tag,
const uint8_t *  data,
uint32_t  len 
)
inline

Append a TLV field: [4-byte LE tag] [4-byte LE length] [data].

Definition at line 261 of file key_metadata.hpp.

◆ append_tlv_blob()

void signet::forge::crypto::detail::meta::append_tlv_blob ( std::vector< uint8_t > &  buf,
uint32_t  tag,
const std::vector< uint8_t > &  blob 
)
inline

Append a TLV field containing a blob.

Definition at line 299 of file key_metadata.hpp.

◆ append_tlv_i32()

void signet::forge::crypto::detail::meta::append_tlv_i32 ( std::vector< uint8_t > &  buf,
uint32_t  tag,
int32_t  val 
)
inline

Append a TLV field containing a single int32_t (little-endian).

Definition at line 274 of file key_metadata.hpp.

◆ append_tlv_str()

void signet::forge::crypto::detail::meta::append_tlv_str ( std::vector< uint8_t > &  buf,
uint32_t  tag,
const std::string &  s 
)
inline

Append a TLV field containing a string.

Definition at line 288 of file key_metadata.hpp.

◆ append_tlv_u8()

void signet::forge::crypto::detail::meta::append_tlv_u8 ( std::vector< uint8_t > &  buf,
uint32_t  tag,
uint8_t  val 
)
inline

Append a TLV field containing a single byte.

Definition at line 282 of file key_metadata.hpp.

◆ read_le32()

uint32_t signet::forge::crypto::detail::meta::read_le32 ( const uint8_t *  src)
inline

Read a 4-byte little-endian uint32 from src.

Definition at line 247 of file key_metadata.hpp.

◆ read_tlv()

bool signet::forge::crypto::detail::meta::read_tlv ( const uint8_t *  buf,
size_t  buf_size,
size_t &  offset,
TlvField field 
)
inline

Parse the next TLV field from a buffer.

On success, advances offset past the field and populates field.

Parameters
bufPointer to the serialized buffer.
buf_sizeTotal buffer size in bytes.
offsetCurrent read offset (updated on success).
fieldOutput field (populated on success).
Returns
True on success, false if truncated or oversized.

Definition at line 323 of file key_metadata.hpp.

◆ tlv_to_blob()

std::vector< uint8_t > signet::forge::crypto::detail::meta::tlv_to_blob ( const TlvField field)
inline

Read a blob from a TLV field's data.

Definition at line 358 of file key_metadata.hpp.

◆ tlv_to_i32()

bool signet::forge::crypto::detail::meta::tlv_to_i32 ( const TlvField field,
int32_t &  out 
)
inline

Read an int32 from a TLV field's data (must be exactly 4 bytes).

Definition at line 339 of file key_metadata.hpp.

◆ tlv_to_str()

std::string signet::forge::crypto::detail::meta::tlv_to_str ( const TlvField field)
inline

Read a string from a TLV field's data.

Definition at line 353 of file key_metadata.hpp.

◆ tlv_to_u8()

bool signet::forge::crypto::detail::meta::tlv_to_u8 ( const TlvField field,
uint8_t &  out 
)
inline

Read a uint8 from a TLV field's data (must be exactly 1 byte).

Definition at line 346 of file key_metadata.hpp.

◆ write_le32()

void signet::forge::crypto::detail::meta::write_le32 ( uint8_t *  dst,
uint32_t  val 
)
inline

Write a 4-byte little-endian uint32 to dst.

Definition at line 239 of file key_metadata.hpp.

Variable Documentation

◆ MAX_METADATA_SIZE

constexpr size_t signet::forge::crypto::detail::meta::MAX_METADATA_SIZE = 1024 * 1024
inlineconstexpr

Maximum total metadata size (1 MB cap to prevent memory exhaustion from crafted payloads, CWE-770).

Definition at line 258 of file key_metadata.hpp.

◆ MAX_TLV_LENGTH

constexpr uint32_t signet::forge::crypto::detail::meta::MAX_TLV_LENGTH = 64u * 1024u * 1024u
inlineconstexpr

Maximum TLV field length (64 MB cap to prevent memory exhaustion from malformed data).

Definition at line 255 of file key_metadata.hpp.

◆ TAG_AAD_PREFIX

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_AAD_PREFIX = 0x0012
inlineconstexpr

Tag: AAD prefix string (variable UTF-8).

Definition at line 369 of file key_metadata.hpp.

◆ TAG_ALGORITHM

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_ALGORITHM = 0x0010
inlineconstexpr

Tag: encryption algorithm (4 bytes, int32_t LE).

Definition at line 367 of file key_metadata.hpp.

◆ TAG_FOOTER_ENCRYPTED

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_FOOTER_ENCRYPTED = 0x0011
inlineconstexpr

Tag: footer-encrypted flag (1 byte, 0/1).

Definition at line 368 of file key_metadata.hpp.

◆ TAG_KEY_ID

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_KEY_ID = 0x0003
inlineconstexpr

Tag: KMS key identifier (variable UTF-8).

Definition at line 366 of file key_metadata.hpp.

◆ TAG_KEY_MATERIAL

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_KEY_MATERIAL = 0x0002
inlineconstexpr

Tag: raw key material (variable blob).

Definition at line 365 of file key_metadata.hpp.

◆ TAG_KEY_MODE

constexpr uint32_t signet::forge::crypto::detail::meta::TAG_KEY_MODE = 0x0001
inlineconstexpr

Tag: key mode (4 bytes, int32_t LE).

Definition at line 364 of file key_metadata.hpp.