Struct sequoia_openpgp::crypto::mem::Encrypted
source · pub struct Encrypted { /* private fields */ }
Expand description
Encrypted memory.
This type encrypts sensitive data, such as secret keys, in memory while they are unused, and decrypts them on demand. This protects against cross-protection-boundary readout via microarchitectural flaws like Spectre or Meltdown, via attacks on physical layout like Rowbleed, and even via coldboot attacks.
The key insight is that these kinds of attacks are imperfect, i.e. the recovered data contains bitflips, or the attack only provides a probability for any given bit. Applied to cryptographic keys, these kind of imperfect attacks are enough to recover the actual key.
This implementation on the other hand, derives a sealing key from a large area of memory, the “pre-key”, using a key derivation function. Now, any single bitflip in the readout of the pre-key will avalanche through all the bits in the sealing key, rendering it unusable with no indication of where the error occurred.
This kind of protection was pioneered by OpenSSH. The commit adding it can be found here.
§Examples
use sequoia_openpgp::crypto::mem::Encrypted;
let e = Encrypted::new(vec![0, 1, 2].into());
e.map(|p| {
// e is temporarily decrypted and made available to the closure.
assert_eq!(p.as_ref(), &[0, 1, 2]);
// p is cleared once the function returns.
});
Implementations§
Trait Implementations§
source§impl PartialEq for Encrypted
impl PartialEq for Encrypted
impl Eq for Encrypted
Auto Trait Implementations§
impl Freeze for Encrypted
impl RefUnwindSafe for Encrypted
impl Send for Encrypted
impl Sync for Encrypted
impl Unpin for Encrypted
impl UnwindSafe for Encrypted
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)