opentdf-crypto
Cryptographic operations for OpenTDF with security hardening.
Features
- AES-256-GCM encryption/decryption with segment support
- RSA-OAEP key encapsulation (via aws-lc-rs or RustCrypto)
- EC key encapsulation (P-256, P-384, P-521, secp256k1)
- HMAC-SHA256 for policy binding and integrity verification
- NanoTDF encryption/decryption with ECDH key agreement
- Automatic memory zeroization for all sensitive data
Security
- All key material uses
zeroizeto clear memory on drop - Constant-time HMAC verification via
subtle::ConstantTimeEq - aws-lc-rs backend option for FIPS-validated RSA operations
- No timing side-channels in cryptographic comparisons
Usage
use TdfEncryption;
// Create encryption instance with generated keys
let tdf = new?;
// Encrypt data
let encrypted = tdf.encrypt?;
// Decrypt (using the same policy key)
let decrypted = decrypt_legacy?;
Feature Flags
aws-lc-provider- Use aws-lc-rs for RSA (FIPS validated, recommended)rustcrypto-provider- Use RustCrypto RSA (pure Rust,rsa0.10 with the RUSTSEC-2023-0071 fix; not FIPS validated)kem-rsa- RSA key encapsulationkem-ec- EC key encapsulation (P-256, P-384, P-521, secp256k1)nanotdf- NanoTDF support (requireskem-ec)
Part of the OpenTDF Workspace
This crate is part of the opentdf-rs workspace:
opentdf- High-level TDF APIopentdf-protocol- Protocol typesopentdf-crypto- Cryptographic operations (this crate)
License
MIT OR Apache-2.0