Skip to main content

Crate embark_crypt

Crate embark_crypt 

Source
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§

Aes256Gcmaes
The AES-256-GCM AEAD cipher, gated behind the aes feature. Same key (32B), nonce (12B), and tag (16B) shape as ChaCha20Poly1305.
ChaCha20Poly1305
The built-in ChaCha20-Poly1305 AEAD cipher.
Zeroizing
A wrapper that wipes its contents on drop, from the zeroize crate.

Traits§

Aead
An AEAD (authenticated encryption with associated data) cipher.

Functions§

gen_key_nonceenc
Draws a fresh key and nonce for one embedded entry from the operating system CSPRNG.
opendec and (dec or enc)
Open ct (with detached tag) under the AEAD cipher named by crypto, verifying aad – the entry header – along with it.
sealenc and (dec or enc)
Seal plain under the AEAD cipher named by crypto, binding aad – the entry header, see Header::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.