Saltpack (saltpack v1.3.5)

View Source

saltpack implementation

https://saltpack.org/

Handling complete, ASCII-armored messages at rest.

Summary

Types

a public or private key

desired key variety

signature mode

Types

key()

@type key() :: binary()

a public or private key

key_variety()

@type key_variety() :: :encrypt | :sign

desired key variety

signature_mode()

@type signature_mode() :: :attached | :detached

signature mode

Functions

armor_message(message, opts \\ [])

@spec armor_message(binary(), Saltpack.Armor.formatting_options()) :: binary()

armor a new message

encrypt_message(message, recipients, private, public \\ nil, opts \\ [])

@spec encrypt_message(
  binary(),
  [key()],
  key(),
  key(),
  Saltpack.Armor.formatting_options()
) :: binary()

encrypt a new message

recipients should contain a list of all recipient public keys. An entry may be nil for anonymous recipients.

new_key_pair(kv \\ :encrypt)

@spec new_key_pair(key_variety()) :: {key(), key()}

generate a new {private, public} key pair

open_message(message, key \\ nil, plaintext \\ nil)

@spec open_message(binary(), key(), binary()) :: binary()

open a saltpack message

This may fail in spectacular ways with messages which are not properly formatted for the supplied key.

Opening a detached signature with plaintext will return the signing public key. All other forms return the decoded contents upon validation.

sign_message(message, private, public \\ nil, mode \\ :attached, opts \\ [])

@spec sign_message(
  binary(),
  key(),
  key(),
  signature_mode(),
  Saltpack.Armor.formatting_options()
) ::
  binary()

sign a new message

This is presently considerably slower than encrypting a same-sized message and has slightly different calling semantics. Where possible, encrypt_message/5 should be preferred.