Expand description
The Kestrel cryptography library. This library provides implementations of ChaCha20-Poly1305, X25519, SHA-256, HMAC-SHA-256 and the Noise X protocol.
The goal of this library is not to serve as a general purpose cryptographic library, but the functions provided here could certainly be used as such.
Modules§
Structs§
- Noise
Decrypt Msg - A struct containing the result of a
noise_decrypt
PublicKey is the sender’s public key - Noise
Encrypt Msg - A struct containing the result of a
noise_encrypt
- Payload
Key - Payload Key encrypted by the noise protocol
- Private
Key - X25519 Private Key
- Public
Key - X25519 Public Key
Enums§
- Asym
File Format - Key file format
- File
Format - File format versions
- Pass
File Format - Password file format
Functions§
- chapoly_
decrypt_ ietf - RFC 8439 ChaCha20-Poly1305 decrypt function. The key must be 32 bytes and the nonce must be 12 bytes. The 16 byte poly1305 tag must be appended to the ciphertext. Returns the plaintext.
- chapoly_
encrypt_ ietf - RFC 8439 ChaCha20-Poly1305 encrypt function. The key must be 32 bytes and the nonce must be 12 bytes. The aad should be an empty slice if not used. Returns the ciphertext.
- hkdf_
sha256 - HKDF-SHA256 If no info or salt is required, use the empty slice.
- hmac_
sha256 - HMAC-SHA-256
- noise_
decrypt - Decrypt the payload key using the noise protocol. The given recipient public key must match the recipient private key. Returns the payload key, and the sender’s PublicKey
- noise_
encrypt - Encrypt the payload key using the noise X protocol.
- scrypt
- Derives a secret key from a password and a salt using scrypt. Recommended parameters are n = 32768, r = 8, p = 1 Parameter n must be larger than 1 and a power of 2.
- secure_
random - Generates the specified amount of bytes from a CSPRNG
- sha256
- SHA-256
- x25519
- RFC 7748 compliant X25519. k is the private key and u is the public key. Keys must be 32 bytes. Returns a DhError if the shared secret is the all zero output
- x25519_
derive_ public - Derive an X25519 public key from a private key. The private key must be 32 bytes.