Expand description
The encryption layer of the embark toolkit: AEAD sealing and opening
for embedded entries, keyed by the CryptoId
that embark-format writes into every entry header.
seal and open dispatch on that id at runtime; ChaCha20Poly1305
and, behind the aes feature, Aes256Gcm are the same two ciphers
named as types, through the sealed Aead trait. Both take a 32-byte
key and a 12-byte nonce and produce a detached 16-byte tag over the
payload and whatever associated data is passed; embark passes the
entry header, so its codec and claimed length are bound into the tag.
gen_key_nonce draws a fresh key and nonce for one entry from the
operating system generator, and xor32 is the masking primitive behind
the build-time key obfuscation that embark-macros emits.
§What this crate does not promise
Nothing here decides where the key lives, and that is what determines
whether an embedded file is actually confidential. embark’s default
mode reconstructs the key from material compiled into the binary, which
is obfuscation against a casual reader and not security against anyone
willing to reverse the binary. Real confidentiality needs a key supplied
at runtime. See embark::EncryptedFile for that distinction.
§Features
enc compiles the build-time sealing half (and the OS key generator with
it), dec the runtime opening half. aes adds AES-256-GCM alongside the
always-present ChaCha20-Poly1305.
Structs§
- Aes256
Gcm aes - The AES-256-GCM AEAD cipher, gated behind the
aesfeature. Same key (32B), nonce (12B), and tag (16B) shape asChaCha20Poly1305. - ChaCha20
Poly1305 - The built-in ChaCha20-Poly1305 AEAD cipher.
- Zeroizing
- A wrapper that wipes its contents on drop, from the
zeroizecrate.
Traits§
- Aead
- An AEAD (authenticated encryption with associated data) cipher.
Functions§
- gen_
key_ nonce enc - Draws a fresh key and nonce for one embedded entry from the operating system CSPRNG.
- open
decand (decorenc) - Open
ct(with detachedtag) under the AEAD cipher named bycrypto, verifyingaad– the entry header – along with it. - seal
encand (decorenc) - Seal
plainunder the AEAD cipher named bycrypto, bindingaad– the entry header, seeHeader::aad_len– into the tag. - xor32
- XOR two 32-byte blocks, the primitive behind build-time key obfuscation: a key masked at build time is recovered by XOR-ing the mask back in.