Repository navigation
LunaPack 0.1.4
LunaPack 0.1.4
The encryption of the entries.
The mechanism is the one of the reference implementation this package
follows: a key is established with the recipient, HKDF-SHA512 turns it
into the key of the package, and every entry is sealed on its own with
ChaCha20-Poly1305 under a key and a nonce that are derived for it. The
additional data of an entry holds its place in the package and its name,
so that neither the order nor the name of an entry can be changed
without the seal breaking. A check in the manifest tells a wrong key
from a damaged package.
The key exchange is the one part that is different. The reference uses the
sntrup761 KEM, which the toolchain has no counterpart of, so this package
uses X25519, the curve that the reference itself carries as a part of its
own sntrup761x25519-sha512 method.
Every primitive is implemented here, because the toolchain ships none of
them: SHA-512, HMAC, HKDF, PBKDF2, ChaCha20, Poly1305 and X25519. Each
one is checked against the vector that its standard publishes, and the
derivation is checked against the reference implementation itself.
There are two methods. The x25519 method seals a package to the owner of
a public key; the passphrase method seals it with a passphrase. A secret
key that a passphrase protects is the better form.
The self-extracting bundle finds its key next to itself: the file
.key for a public key, the file .pass for a passphrase.
The manifest format version goes to 5, because an entry may now be
sealed. A package written by an older version still unpacks.
70/70 tests pass on the native and the wasm backend.