Expand description
OpenTDF - Trusted Data Format for Rust
This crate provides a Rust implementation of the OpenTDF (Trusted Data Format) standard, supporting:
- Standard TDF (TDF3, ZTDF) with segment-based encryption
- Attribute-Based Access Control (ABAC) policies
- Key Access Service (KAS) integration
- JSON-RPC format (ZTDF-JSON)
- Security hardening (zeroizing keys, constant-time verification)
§Architecture
opentdf-protocol: Protocol types and structures (no crypto)opentdf-crypto: Cryptographic operations with security hardeningopentdf: High-level TDF API and integration
§Getting Started
For the best experience, import the prelude to get all commonly used types and traits:
use opentdf::prelude::*;
// Create a policy with the new builder
let policy = PolicyBuilder::new()
.id_auto()
.dissemination(["user@example.com"])
.build()?;
// Encrypt data to a TDF file
Tdf::encrypt(b"sensitive data")
.kas_url("https://kas.example.com")
.policy(policy.clone())
.to_file("output.tdf")?;
// Extension trait methods work automatically with prelude!
let mut manifest = TdfManifest::new("payload".to_string(), "https://kas.example.com".to_string());
manifest.set_policy(&policy)?; // No need to import TdfManifestExtRe-exports§
pub use fqn::AttributeFqn;pub use fqn::FqnValidationRules;pub use fqn::NamespaceRegistry;pub use kas::CallerKey;pub use kas::KasClient;pub use kas::KeyType;pub use kas_key::KasEcPublicKeyResponse;pub use kas_key::KasKeyError;pub use kas_key::KasPublicKeyResponse;pub use kas_key::fetch_kas_ec_public_key;Deprecated pub use kas_key::fetch_kas_ec_public_key_connect;pub use kas_key::fetch_kas_public_key;Deprecated pub use kas_key::fetch_kas_public_key_connect;pub use kas_key::validate_ec_public_key_pem;pub use kas_key::validate_rsa_public_key_pem;pub use jsonrpc::JsonPayload;pub use jsonrpc::TdfJson;pub use jsonrpc::TdfJsonManifest;pub use jsonrpc::TdfJsonBuilder;pub use jsonrpc::InlinePayload;Deprecated pub use jsonrpc::TdfJsonRpc;Deprecated pub use jsonrpc::TdfJsonRpcBuilder;Deprecated pub use jsonrpc::TdfManifestInline;Deprecated pub use hkdf;pub use p256;pub use pkcs8;pub use sha1;pub use sha2;pub use ed25519_dalek;
Modules§
- fqn
- Fully Qualified Name (FQN) support for OpenTDF attributes
- jsonrpc
- TDF-JSON format implementation (per TDF-JSON specification draft-00)
- kas
- KAS (Key Access Service) client implementation for OpenTDF rewrap protocol
- kas_
discovery - KAS endpoint discovery via /.well-known/opentdf-configuration
- kas_key
- KAS public key retrieval and parsing
- manifest
- TDF Manifest extension methods
- pdp
- Local Access Policy Decision Point.
- prelude
- OpenTDF Prelude
Structs§
- AesKey
- AES-256 key (32 bytes) that zeroizes on drop
- Assertion
- A verifiable statement about the TDF or its payload (spec: assertion.md).
- Assertion
Binding - The
bindingobject of an assertion (spec: assertion_binding.md). - Assertion
Statement - The
statementobject of an assertion (spec: assertion_statement.md). - Attribute
Condition - A condition that must be satisfied for access
- Attribute
Identifier - Attribute namespace and name
- Collection
Item - Collection item containing an encrypted payload with its IV
- EcdhKem
- ECDH key encapsulation mechanism (NanoTDF)
- Encrypted
Payload - Encrypted payload structure
- Encrypted
Segment - One encrypted OpenTDF segment:
IV[12] || ciphertext || tag[16]. - Encryption
Information - Encryption information in TDF manifest
- Encryption
Method - Encryption method configuration
- Gguf
Index - Top-level
ggufobject on agguf-tdf/1manifest. - Gguf
Segment - One encrypted zip member and its plaintext length.
- Gguf
Tensor - One GGUF tensor located in the virtual file.
- Integrity
Information - Integrity information including segments and root signature
- KasPolicy
Binding - Policy binding for KAS requests
- KeyAccess
- Key access object in manifest
- KeyAccess
Object - Key access object details
- KeyAccess
Object Wrapper - Key access object wrapper
- KeyAccess
Rewrap Result - Individual key access rewrap result
- Nano
TdfCollection - NanoTDF Collection for encrypting multiple payloads with a shared DEK
- Nano
TdfCollection Builder - Builder for creating NanoTDF collections
- Nano
TdfCollection Decryptor - Decryptor for NanoTDF collection items
- Payload
- Payload reference in TDF manifest
- Payload
Key - Payload key (32 bytes) that zeroizes on drop
- Policy
- Root policy that includes metadata and effective dates
- Policy
Binding - Policy binding structure
- Policy
Body - Policy body containing attribute requirements and dissemination list
- Policy
Builder - Builder for creating Policy instances with ergonomic defaults
- Policy
Key - Policy key (32 bytes) that zeroizes on drop
- Policy
Request - Individual policy request entry
- Policy
Rewrap Result - Policy rewrap result
- Rewrap
Response - Rewrap response structure
- Root
Signature - Root signature for integrity verification
- RsaOaep
Kem - RSA-OAEP key encapsulation mechanism
- Segment
- Segment information
- Segment
Info - Information about an encrypted segment
- Segmented
Payload - Result of segment-based encryption
- Signed
Rewrap Request - Signed rewrap request wrapper
- Tdf
- High-level TDF operations
- TdfArchive
- Reader for a TDF ZIP archive.
- TdfArchive
Builder - TdfArchive
Memory Builder - In-memory TDF archive builder for WASM compatibility
- TdfDecrypt
Builder - Builder for decrypting TDF data
- TdfDecrypt
File Builder - Builder for decrypting TDF files
- TdfEncrypt
Builder - Builder for encrypting data to TDF format
- TdfEncrypt
File Builder - Builder for encrypting files to TDF format
- TdfEncryption
- TDF encryption engine with zeroizing keys
- TdfManifest
- TDF manifest structure
- TdfMember
Index - Central-directory map from member name to byte range, built once at open.
- TdfMember
Location - Byte range of a Stored zip member’s data, for
read_at-style access. - TdfMulti
Entry Builder - Writes a TDF whose payload is many Stored members rather than one
concatenated
0.payload, with the manifest written last. - Unsigned
Rewrap Request - Unsigned rewrap request structure (before JWT signing)
- Validation
Error - Attribute-Based Access Control Policy Error Validation error with structured information
Enums§
- Attribute
Policy - A policy that can be evaluated against a set of attributes
- Attribute
Value - Supported attribute value types
- Encryption
Error - FqnError
- FQN (Fully Qualified Name) parsing and validation errors
- FqnError
Kind - Error kind for programmatic FQN error handling
- Gguf
Segment Kind - What a segment’s plaintext covers.
- KasError
- KAS client errors
- KeyError
- Key-related errors
- Logical
Operator - Logical operators for combining conditions
- Oaep
Hash - OAEP hash algorithm selection
- Open
TdfError - Unified error type for all OpenTDF operations
- Operator
- Comparison operators for attribute values
- Policy
Binding Error - Why
PolicyBinding::validaterejected a policy binding. - Policy
Error - TdfError
- Validation
Error Type - Types of validation errors
Constants§
- DEFAULT_
MAX_ MANIFEST_ SIZE - Default cap on the size of a manifest member once read into memory: 16 MiB.
- DEFAULT_
MAX_ PAYLOAD_ SIZE - Default cap on the size of a payload member once read into memory: 1 GiB.
- GGUF_
TDF_ PROFILE_ V1 - Profile identifier for the index version defined by draft-00.
- LEGACY_
TDF_ MANIFEST_ FILE_ NAME - Name every SDK wrote before spec compliance; accepted on read forever.
- TDF_
MANIFEST_ FILE_ NAME - Spec (opentdf/spec schema/OpenTDF/README.md): the manifest entry MUST be
manifest.jsonat the archive root. - TDF_
PAYLOAD_ FILE_ NAME - Default payload entry name. Written into
manifest.payload.urlby callers ofTdfManifest::new; on read it is only a fallback for an empty url.
Functions§
- wrap_
key_ with_ rsa_ oaep - Convenience function to wrap a key with RSA-OAEP (SHA-1 default)