pub struct DataKey { /* private fields */ }Expand description
A content-encryption key in the two forms envelope encryption needs.
The plaintext is for the caller to encrypt with and drop. The wrapped copy is what the container carries, and only the key-encryption key that produced it opens that again.
This is what every key-protection device offers instead of a cipher: AWS KMS
calls it GenerateDataKey, PKCS#11 reaches it with C_GenerateKey followed
by C_WrapKey. The content never crosses the boundary, so a device that
protects a key it will not export does not also have to be fast enough to
encrypt a file.
Implementations§
Source§impl DataKey
impl DataKey
Sourcepub fn new(
plaintext: Zeroizing<Vec<u8>>,
wrapped: Vec<u8>,
protection: KeyProtection,
) -> Self
pub fn new( plaintext: Zeroizing<Vec<u8>>, wrapped: Vec<u8>, protection: KeyProtection, ) -> Self
Pair a fresh data key with the copy its protector can open, and with what protected it.
Sourcepub fn wrapped(&self) -> &[u8] ⓘ
pub fn wrapped(&self) -> &[u8] ⓘ
The same key, protected. This is what goes into the container.
Sourcepub fn protection(&self) -> KeyProtection
pub fn protection(&self) -> KeyProtection
What protected it, which is what a container has to declare and what opening it again needs.