KCl v0.1.0 Kcl

A poor NaCl crypto suite substitute

The functions exposed here are the equivalent of (and interoperable with):

  • crypto_box_curve25519xsalsa20poly1305
  • crypto_box_curve25519xsalsa20poly1305_open

At this time, no support is provided for multiple packets/streaming or nonce-agreement.

Summary

Types

public or private key

shared nonce

Functions

box up an authenticated packet

derive a public key from a private key

generate a private/public key pair

pre-compute a shared key

unbox an authenticated packet

Types

key :: <<_::32 * 8>>

public or private key

nonce :: <<_::24 * 8>>

shared nonce

Functions

box(msg, shared_secret, nonce)

Specs

box(binary, key, nonce) :: binary
box(msg, our_private, their_public, nonce)

Specs

box(binary, key, key, nonce) :: binary

box up an authenticated packet

box/3 uses the result of shared_secret box/4 will recompute this key from the parties’ secret and public keys.

derive_public_key(private_key)

Specs

derive_public_key(key) :: key | :error

derive a public key from a private key

generate_key_pair()

Specs

generate_key_pair :: {key, key} | :error

generate a private/public key pair

shared_secret(our_private, their_public)

pre-compute a shared key

Mainly useful in a situation where many messages will be exchanged. This module does not yet do a lot of support in that area.

unbox(packet, shared_secret, nonce)
unbox(packet, our_private, their_public, nonce)

Specs

unbox(binary, key, key, nonce) :: binary | :error

unbox an authenticated packet

Returns :error when the packet contents cannot be authenticated, otherwise the decrypted payload.

unbox/3 uses the pre-computed keys from shared_secret unbox/4 recomputes the shared key from the parties’ secret and public keys