Bailey is a small, opinionated Clojure library for managing server-side encryption keys with strong operational safety guarantees.
It is designed for applications that need:
Bailey does not implement cryptographic primitives. It uses the well-reviewed library Tempel to implement a robust, auditable key lifecycle.
Bailey is built around a few explicit goals:
Separation of mechanism and policy Bailey provides how keys are managed, not who owns them or where secrets come from.
Recoverability without fragility Encrypted data must remain recoverable even if:
Operational clarity All key material has a clear lifecycle:
Auditability The logic for key handling is small, explicit, and readable. This library is intended to simplify security reviews, not complicate them.
Bailey manages three distinct layers of keys:
This key allows recovery even if the server’s encrypted keychain is lost or corrupted.
This keychain is recoverable using the offline backup key.
Bailey assumes you control:
Bailey is designed with the following assumptions:
Run once, offline or in CI:
(bailey.core/generate-backup-keys!
{:secrets-dir "secrets" ;; secure, offline storage
:resources-dir "resources"}) ;; public key embedded in app
(bailey.core/init!
{:secrets-dir "var/bailey"
:read-server-password!!
(fn []
;; must return a fresh byte[] each call
(read-tpm-sealed-secret))})
This will:
(def ciphertext
(bailey.core/encrypt (.getBytes "secret data")))
(def plaintext
(bailey.core/decrypt ciphertext))
For especially critical data:
(bailey.core/encrypt-critical (.getBytes "critical config"))
This adds asymmetric backup encryption so the data is recoverable even if the server keychain is lost.
(bailey.core/rotate-keys!
{:read-server-password!! read-tpm-sealed-secret})
Bailey provides explicit recovery tools intended for offline, administrative use.
Given:
You can recover the server keychain and decrypt protected data without access to the original server.
This is a deliberate, manual process by design.
Bailey handles key mechanics — operational security remains your responsibility.
Apache License 2.0
Copyright © Sturdy Statistics
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |