KCl v0.3.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
  • crypto_secretbox_curve25519xsalsa20poly1305
  • crypto_secretbox_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, nonce, state)

Specs

box(binary, nonce, Kcl.State.t) :: {binary, Kcl.State.t}
box(msg, nonce, our_private, their_public)

Specs

box(binary, nonce, key, key) :: {binary, Kcl.State.t}

box up an authenticated packet

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, nonce, state)
unbox(packet, nonce, our_private, their_public)

Specs

unbox(binary, nonce, key, key) ::
  {binary, Kcl.State.t} |
  :error

unbox an authenticated packet

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