#memory-protection #memory #encryption #secure #encryption-key

shielded

Shielded Memory. Memory protection from speculation and side-channel attacks like Spectre, Meltdown, Rowhammer and Rambleed.

3 releases

0.1.2 Oct 17, 2023
0.1.1 Feb 18, 2021
0.1.0 Jun 25, 2019

#797 in Cryptography

42 downloads per month

MIT license

10KB
133 lines

Shielded Memory

A crate drawing inspiration and parts of the documentation from OpenBSD's / OpenSSH's commit.

This crate implements a Shielded Memory providing protection at rest for secrets kept in memory against speculation and memory sidechannel attacks like Spectre, Meltdown, Rowhammer and Rambleed. The contents of the memory are encrypted when Shielded is constructed, then decrypted on demand and encrypted again after memory is no longer needed.

The memory protection is achieved by generating a 16kB secure random prekey which is then hashed with SHA512 to construct an encryption key for ChaCha20-Poly1305 cipher. This cipher is then used to encrypt the contents of memory in-place.

Attackers must recover the entire prekey with high accuracy before they can attempt to decrypt the shielded memory, but the current generation of attacks have bit error rates that, when applied cumulatively to the entire prekey, make this unlikely.

Dependencies

~5–14MB
~239K SLoC