Liking cljdoc? Tell your friends :D

hive-system.crypto.caesium

Caesium / libsodium-backed implementation of hive-system.protocols/ICrypto.

Uses parameter-object map signatures (:crypto/* keys) like the rest of the crypto layer. Loads caesium lazily via requiring-resolve so absence of native libsodium only fails at construction (->caesium-crypto).

Algorithms supported: :xchacha20-poly1305 — caesium.crypto.aead/xchacha20poly1305-ietf-{encrypt,decrypt}

Caesium / libsodium-backed implementation of `hive-system.protocols/ICrypto`.

Uses parameter-object map signatures (`:crypto/*` keys) like the rest of
the crypto layer. Loads caesium lazily via `requiring-resolve` so absence
of native libsodium only fails at construction (`->caesium-crypto`).

Algorithms supported:
  :xchacha20-poly1305  — caesium.crypto.aead/xchacha20poly1305-ietf-{encrypt,decrypt}
raw docstring

hive-system.crypto.core

Plain-fn DSL over hive-system.protocols/ICrypto. Parameter-object style: every fn takes a single map keyed under :crypto/*.

Callers depend on this ns + ICrypto, never on a concrete adapter (Tink / caesium / ...). Java interop stays inside the adapters.

Surface (key prefix :crypto/*):

(aead-seal! {:crypto/adapter c :crypto/key k :crypto/plaintext pt :crypto/aad aad}) => Result<{:crypto/ciphertext ^bytes :crypto/iv ^bytes}>

(aead-open! {:crypto/adapter c :crypto/key k :crypto/ciphertext ct :crypto/iv nonce :crypto/aad aad}) => Result<{:crypto/plaintext ^bytes}>

(hpke-seal! {:crypto/adapter c :crypto/pubkey pub :crypto/plaintext pt :crypto/aad aad}) => Result<{:crypto/ciphertext ^bytes}>

(hpke-open! {:crypto/adapter c :crypto/keypair kp :crypto/ciphertext ct :crypto/aad aad}) => Result<{:crypto/plaintext ^bytes}>

(sha256 {:crypto/adapter c :crypto/data ^bytes}) => Result<{:crypto/hash ^bytes :crypto/algorithm :sha256}>

(random-key) -> 32-byte ^bytes (XChaCha20 key) (random-nonce) -> 24-byte ^bytes (XChaCha20 nonce) (random-x25519-keypair) -> {:public 32B :private 32B}

Default :crypto/algorithm keys are filled in by each fn (caller may override via the same key in the input map).

Plain-fn DSL over `hive-system.protocols/ICrypto`. Parameter-object style:
every fn takes a single map keyed under `:crypto/*`.

Callers depend on this ns + ICrypto, never on a concrete adapter
(Tink / caesium / ...). Java interop stays inside the adapters.

Surface (key prefix `:crypto/*`):

  (aead-seal! {:crypto/adapter c :crypto/key k :crypto/plaintext pt :crypto/aad aad})
    => Result<{:crypto/ciphertext ^bytes :crypto/iv ^bytes}>

  (aead-open! {:crypto/adapter c :crypto/key k :crypto/ciphertext ct
               :crypto/iv nonce :crypto/aad aad})
    => Result<{:crypto/plaintext ^bytes}>

  (hpke-seal! {:crypto/adapter c :crypto/pubkey pub
               :crypto/plaintext pt :crypto/aad aad})
    => Result<{:crypto/ciphertext ^bytes}>

  (hpke-open! {:crypto/adapter c :crypto/keypair kp
               :crypto/ciphertext ct :crypto/aad aad})
    => Result<{:crypto/plaintext ^bytes}>

  (sha256 {:crypto/adapter c :crypto/data ^bytes})
    => Result<{:crypto/hash ^bytes :crypto/algorithm :sha256}>

  (random-key)              -> 32-byte ^bytes  (XChaCha20 key)
  (random-nonce)             -> 24-byte ^bytes  (XChaCha20 nonce)
  (random-x25519-keypair)    -> {:public 32B :private 32B}

Default `:crypto/algorithm` keys are filled in by each fn (caller may
override via the same key in the input map).
raw docstring

hive-system.crypto.ed25519-der

Ed25519 over PKCS#8 / X.509 DER encodings, via the JDK provider (Java 15+).

The Tink path in hive-system.crypto.tink consumes RAW 32-byte key material. Keyrings and key files in this ecosystem store the JDK encodings instead — PKCS#8 for a private key, X.509 for a public one — which is what KeyFactory consumes. Both encodings wrap the same 32 bytes and yield byte-identical RFC 8032 signatures, so the two paths are interchangeable over one key.

Selected with :crypto/key-encoding :der; :raw, the default, keeps the Tink path. Signing takes the PKCS#8 private key as :crypto/key — the public half is derived from it, so no keypair need be assembled.

Ed25519 over PKCS#8 / X.509 DER encodings, via the JDK provider (Java 15+).

The Tink path in `hive-system.crypto.tink` consumes RAW 32-byte key
material. Keyrings and key files in this ecosystem store the JDK encodings
instead — PKCS#8 for a private key, X.509 for a public one — which is what
KeyFactory consumes. Both encodings wrap the same 32 bytes and yield
byte-identical RFC 8032 signatures, so the two paths are interchangeable
over one key.

Selected with `:crypto/key-encoding :der`; `:raw`, the default, keeps the
Tink path. Signing takes the PKCS#8 private key as `:crypto/key` — the
public half is derived from it, so no keypair need be assembled.
raw docstring

hive-system.crypto.kdf

Pure-Java HKDF-SHA256 (RFC 5869). Shared by ICrypto adapters so that crypto-derive-key returns byte-identical bytes regardless of which adapter resolves the call.

Composed from javax.crypto.Mac HMAC-SHA256 — no native dependency.

Pure-Java HKDF-SHA256 (RFC 5869). Shared by ICrypto adapters so that
`crypto-derive-key` returns byte-identical bytes regardless of which
adapter resolves the call.

Composed from `javax.crypto.Mac` HMAC-SHA256 — no native dependency.
raw docstring

hive-system.crypto.macros

Macro sugar for AEAD ceremonies built on hive-system.crypto.core.

Provided as an opt-in convenience layer on top of the fn DSL — required only when call sites benefit from compact nested-let composition.

Use:

(let-aead [crypto (tink/->tink-crypto) key (core/random-key) {:keys [ciphertext iv]} (core/aead-seal! crypto key pt aad)] (core/aead-open! crypto key ciphertext iv aad))

let-aead short-circuits on the first :error Result — same semantics as hive-dsl.result/let-ok — but accepts plain (non-Result) values for adapter / key construction lines.

Macro sugar for AEAD ceremonies built on `hive-system.crypto.core`.

Provided as an opt-in convenience layer on top of the fn DSL — required
only when call sites benefit from compact nested-let composition.

Use:

  (let-aead [crypto (tink/->tink-crypto)
             key (core/random-key)
             {:keys [ciphertext iv]} (core/aead-seal! crypto key pt aad)]
    (core/aead-open! crypto key ciphertext iv aad))

`let-aead` short-circuits on the first :error Result — same semantics as
`hive-dsl.result/let-ok` — but accepts plain (non-Result) values for
adapter / key construction lines.
raw docstring

hive-system.crypto.signer

An hive-spi.crypto.ports/ISigner backed by this system's ICrypto.

The port speaks base64 text — PKCS#8 private, X.509 public, base64 signature — while ICrypto speaks bytes. This namespace is that translation and nothing else: it decodes, delegates with :crypto/key-encoding :der, and re-encodes.

Installing it makes hive-license sign through whichever ICrypto a host has already built, instead of hive-license's own JDK adapter. Signatures are byte-identical either way, so licences issued before and after an install verify against the same public key.

An `hive-spi.crypto.ports/ISigner` backed by this system's ICrypto.

The port speaks base64 text — PKCS#8 private, X.509 public, base64
signature — while ICrypto speaks bytes. This namespace is that translation
and nothing else: it decodes, delegates with `:crypto/key-encoding :der`,
and re-encodes.

Installing it makes hive-license sign through whichever ICrypto a host has
already built, instead of hive-license's own JDK adapter. Signatures are
byte-identical either way, so licences issued before and after an install
verify against the same public key.
raw docstring

hive-system.crypto.tink

Tink-backed implementation of hive-system.protocols/ICrypto.

See hive-system.protocols/ICrypto for the parameter-object contract — every op receives a single map keyed under :crypto/*.

Algorithms supported: :xchacha20-poly1305 — symmetric AEAD (subtle.XChaCha20Poly1305) :hpke-x25519 — RFC 9180 single-shot HPKE (DHKEM-X25519 + HKDF-SHA256 + ChaCha20-Poly1305) :sha256 — message digest

Ed25519 keys default to RAW 32-byte material. Pass :crypto/key-encoding :der to work in the JDK encodings instead — PKCS#8 private under :crypto/key, X.509 public under :crypto/pubkey — which is what a keyring stores. Both encodings wrap the same 32 bytes and produce byte-identical signatures. See hive-system.crypto.ed25519-der.

Tink-backed implementation of `hive-system.protocols/ICrypto`.

See `hive-system.protocols/ICrypto` for the parameter-object contract —
every op receives a single map keyed under `:crypto/*`.

Algorithms supported:
  :xchacha20-poly1305  — symmetric AEAD (subtle.XChaCha20Poly1305)
  :hpke-x25519         — RFC 9180 single-shot HPKE
                         (DHKEM-X25519 + HKDF-SHA256 + ChaCha20-Poly1305)
  :sha256              — message digest

Ed25519 keys default to RAW 32-byte material. Pass
`:crypto/key-encoding :der` to work in the JDK encodings instead — PKCS#8
private under `:crypto/key`, X.509 public under `:crypto/pubkey` — which is
what a keyring stores. Both encodings wrap the same 32 bytes and produce
byte-identical signatures. See `hive-system.crypto.ed25519-der`.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close