Crate kestrel_crypto

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

decrypt
Decryption functions
encrypt
Encryption functions
errors
Library Errors

Structs§

NoiseDecryptMsg
A struct containing the result of a noise_decrypt PublicKey is the sender’s public key
NoiseEncryptMsg
A struct containing the result of a noise_encrypt
PayloadKey
Payload Key encrypted by the noise protocol
PrivateKey
X25519 Private Key
PublicKey
X25519 Public Key

Enums§

AsymFileFormat
Key file format
FileFormat
File format versions
PassFileFormat
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.