Skip to main content

pd_cipher::keys

Key generation, derivation, and management utilities. Key generation and management for cryptographic operations.

This module provides functionality for generating and managing cryptographic keys used in the symmetric encryption of token maps.

Types

  • [KeyGenerator] - Generates cryptographic keys for a given algorithm.
  • [Key] - Represents a cryptographic key with metadata.
  • [EncryptionAlgorithm] - The supported symmetric encryption algorithms.

Key Generation

use pd_cipher::keys::{KeyGenerator, EncryptionAlgorithm};

# fn main() -> pd_cipher::Result<()> {
// Generate a key for AES-256-GCM
let key = KeyGenerator::generate_key(EncryptionAlgorithm::Aes256Gcm)?;

// Access key properties
println!("Key ID: {}", key.id());
println!("Key size: {} bytes", key.size());
assert_eq!(key.size(), 32);
# Ok(())
# }