Struct sequoia_openpgp::crypto::mem::Encrypted[][src]

pub struct Encrypted { /* fields omitted */ }
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

Encrypts the given chunk of memory.

Maps the given function over the temporarily decrypted memory.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.