pub struct PqcMetadata {
pub kem_params: Option<KemParameters>,
pub sig_params: Option<SigParameters>,
pub enc_params: EncParameters,
pub compression_params: Option<CompressionParameters>,
pub custom: HashMap<String, Vec<u8>>,
}Expand description
Algorithm-specific metadata container
Contains all parameters needed to decrypt and verify the encrypted data.
Fields§
§kem_params: Option<KemParameters>Key encapsulation parameters (optional)
sig_params: Option<SigParameters>Signature parameters (optional)
enc_params: EncParametersEncryption parameters (required)
compression_params: Option<CompressionParameters>Compression parameters (optional)
custom: HashMap<String, Vec<u8>>Additional custom parameters
Implementations§
Source§impl PqcMetadata
impl PqcMetadata
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new empty metadata with default encryption parameters
§Example
use pqc_binary_format::PqcMetadata;
let mut metadata = PqcMetadata::new();
metadata.enc_params.iv = vec![0; 12];
metadata.enc_params.tag = vec![0; 16];Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate metadata structure
Ensures all required fields are present and valid.
Sourcepub fn add_custom(&mut self, key: String, value: Vec<u8>)
pub fn add_custom(&mut self, key: String, value: Vec<u8>)
Add custom parameter
§Example
use pqc_binary_format::PqcMetadata;
let mut metadata = PqcMetadata::new();
metadata.add_custom("my_param".to_string(), vec![1, 2, 3]);Sourcepub fn get_custom(&self, key: &str) -> Option<&[u8]>
pub fn get_custom(&self, key: &str) -> Option<&[u8]>
Get custom parameter
§Example
use pqc_binary_format::PqcMetadata;
let mut metadata = PqcMetadata::new();
metadata.add_custom("my_param".to_string(), vec![1, 2, 3]);
assert_eq!(metadata.get_custom("my_param"), Some(&[1, 2, 3][..]));Sourcepub fn to_json_bytes(&self) -> Vec<u8> ⓘ
pub fn to_json_bytes(&self) -> Vec<u8> ⓘ
Serialize the metadata to the canonical UTF-8 JSON object used in the metadata section of the binary format (Section 5 of the specification).
Byte-valued fields (IV, tag, public keys, ciphertext, signature, custom
values) are base64-encoded so the section stays valid UTF-8. Object keys
serialize in sorted order (serde_json’s map is a BTreeMap), giving a
deterministic encoding suitable for the integrity checksum.
Sourcepub fn from_json_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_json_bytes(bytes: &[u8]) -> Result<Self>
Reconstruct metadata from the canonical JSON object produced by
PqcMetadata::to_json_bytes.
§Errors
Returns CryptoError::MetadataError if the bytes are not valid UTF-8
JSON, the required encryption_params object is missing, or any
base64-encoded field cannot be decoded.
Trait Implementations§
Source§impl Clone for PqcMetadata
impl Clone for PqcMetadata
Source§fn clone(&self) -> PqcMetadata
fn clone(&self) -> PqcMetadata
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PqcMetadata
impl Debug for PqcMetadata
Source§impl Default for PqcMetadata
impl Default for PqcMetadata
Source§impl<'de> Deserialize<'de> for PqcMetadata
impl<'de> Deserialize<'de> for PqcMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PqcMetadata
Source§impl PartialEq for PqcMetadata
impl PartialEq for PqcMetadata
Source§fn eq(&self, other: &PqcMetadata) -> bool
fn eq(&self, other: &PqcMetadata) -> bool
self and other values to be equal, and is used by ==.