Expand description
oboron is a string-in / string-out authenticated symmetric encryption layer for UTF-8 text: it encrypts a string under an AES-SIV or AES-GCM-SIV scheme and encodes the result to compact obtext (Crockford base32, base32, base64url, or hex). Every scheme is authenticated; the scheme is supplied by the caller (the obtext carries no marker), and keys are 128-character hex.
§Quick Start
use oboron::{DsivC32, ObtextCodec};
let key = oboron::generate_key(); // get key
let ob = DsivC32::new(&key)?; // instantiate ObtextCodec (cipher+encoder)
let ot = ob.enc("secret data")?; // get obtext (encoded ciphertext)§Parameter Order Convention
All functions in this library follow a consistent parameter ordering convention:
data < format < key
data(plaintext/obtext) comes first - it’s what you’re operating onformatcomes second (when present) - it’s configuration/optionskeycomes last (when present) - it’s the security credential
Examples:
// Operations: data, format
let ot = omb.enc("plaintext", "dsiv.b64")?;
omb.dec(&ot, "dsiv.b64")?;
// Constructors: format, key
oboron::Ob::new("dsiv.b64", &key)?;
// Convenience functions: data, format, key
let ot = oboron::enc("plaintext", "dsiv.b64", &key)?;
oboron::dec(&ot, "dsiv.b64", &key)?;§Choosing the Right Type
Oboron provides several types optimized for different use cases:
§1. Fixed-Format Types (Fastest, Compile-Time)
Use format-specific types when you know the format at compile time:
let dsiv = DsivC32::new(&key)?; // dsiv.c32 format (Crockford base32)
let dsiv_b64 = DsivB64::new(&key)?; // dsiv.b64 format (base64url)
let ot = dsiv.enc("hello")?;
let pt2 = dsiv.dec(&ot)?;- Use case: Format is known at compile time
- Performance: Fastest (zero overhead)
- Flexibility: Format fixed, explicit in type name
§2. Ob - Runtime Format (Flexible)
Use Ob when you need to choose the format at runtime:
// Format chosen at runtime
let mut ob = Ob::new("dsiv.b64", &key)?;
let ot = ob.enc("hello")?;
let pt2 = ob.dec(&ot)?;
// Can change format if needed
ob.set_format("dsiv.hex")?;- Use case: Format determined at runtime (config, user input)
- Performance: Near-zero overhead (inlines to static functions)
- Flexibility: Runtime format selection, can be changed after construction
§3. Omnib - Multi-Format Operations
Use Omnib when working with different formats in a single context:
let omb = Omnib::new(&key)?;
// Encode to different formats
let ot_c32 = omb.enc("data", "dsiv.c32")?;
let ot_b64 = omb.enc("data", "dsiv.b64")?;
let ot_hex = omb.enc("data", "dsiv.hex")?;
// Decode with the matching format (the scheme is supplied, not detected)
let pt2 = omb.dec(&ot_b64, "dsiv.b64")?;- Use case: Working with multiple formats in one context
- Performance: Small overhead (format parsing per operation)
- Flexibility: Maximum - handles any format on a per-operation basis
§Quick Reference
| Type | Format | Use Case | Performance |
|---|---|---|---|
DsivC32, etc. | Compile-time | Known format | Fastest (zero-cost) |
Ob | Runtime, mutable | Config-driven | Near-zero overhead |
Omnib | Per-operation | Multiple formats | Small overhead |
§Typical Production Usage: Fixed ObtextCodec
Best performance and type safety for multiple operations with the same format:
// Fixed format types (best performance for multiple operations with same format)
let dsiv = oboron::DsivC32::new(&key)?; // "dsiv.c32" fixed-format ObtextCodec instance
let pgcmsiv = oboron::PgcmsivC32::new(&key)?; // "pgcmsiv.c32" fixed-format ObtextCodec instance
let ot_dsiv = dsiv.enc("data1")?;
let ot_pgcmsiv = pgcmsiv.enc("data2")?;
// Decoding
let pt1 = dsiv.dec(&ot_dsiv)?; // Decodes successfully
let pt2 = pgcmsiv.dec(&ot_pgcmsiv)?;
assert_eq!(pt1, "data1");
assert_eq!(pt2, "data2");§Encryption Schemes
All four core schemes are authenticated:
Dgcmsiv: deterministic AES-GCM-SIVDsiv: deterministic AES-SIV (nonce-misuse resistant)Pgcmsiv: probabilistic AES-GCM-SIVPsiv: probabilistic AES-SIV
Unauthenticated (upcbc) and obfuscation (zdcbc) schemes are not
part of oboron — they live in the separate
obu crate.
Testing/Demo only schemes using no encryption (mock feature group):
Mock1: IdentityMock2: Reverse plaintext
Each scheme supports four string encodings:
- B64 - URL-safe base64 (RFC 4648 base64url standard)
- B32 - Standard base32 (RFC 4648)
- C32 - Crockford base32
- Hex - Hexadecimal
§Security
oboron is a thin string/encoding layer over the
obcrypt authenticated-encryption core;
the cryptography, threat model, and usage limits are documented in
obcrypt’s SECURITY.md and summarized in this crate’s
SECURITY.md.
Key points:
- Not independently audited. Neither oboron nor obcrypt has had an external security audit. Evaluate accordingly for high-assurance use.
- Deterministic schemes use a fixed nonce.
dsiv/dgcmsivencrypt under a constant (all-zero) nonce, sound only because AES-SIV / AES-GCM-SIV are nonce-misuse-resistant (RFC 5297, RFC 8452). The confidentiality cost is the deterministic-equality leak those schemes expose by design — equal plaintexts yield equal obtext. - The binding limit is data volume, not nonce reuse. Security degrades only as the total data encrypted under one key approaches the AES-GCM-SIV birthday bound — far out of reach for the short-string workloads oboron targets. The library is stateless, so honoring that bound is a deployment responsibility: under high-volume use, rotate the master key well before it.
- Keys are 128-character lowercase hex. There is no base64 key
encoding; generate keys with
generate_key.
§The ObtextCodec Trait
All types (Ob, DsivC32, PsivB64, etc.) except Omnib implement the ObtextCodec trait,
fn process<O: ObtextCodec>(ob: &O, data: &str) -> Result<String, oboron::Error> {
let ot = ob.enc(data)?;
ob.dec(&ot)
}
let dsiv = DsivC32::new(&key)?;
let ob = Ob::new("dsiv.c32", &key)?;
process(&dsiv, "hello")?;
process(&ob, "hello")?;The ObtextCodec trait is automatically imported via the prelude.
Modules§
- prelude
- Convenience prelude for common imports.
Structs§
- Dgcmsiv
B32 - ObtextCodec implementation for dgcmsiv. b32 format.
- Dgcmsiv
B64 - ObtextCodec implementation for dgcmsiv.b64 format.
- Dgcmsiv
C32 - ObtextCodec implementation for dgcmsiv. c32 format.
- Dgcmsiv
Hex - ObtextCodec implementation for dgcmsiv.hex format.
- DsivB32
- ObtextCodec implementation for dsiv.b32 format.
- DsivB64
- ObtextCodec implementation for dsiv.b64 format.
- DsivC32
- ObtextCodec implementation for dsiv.c32 format.
- DsivHex
- ObtextCodec implementation for dsiv.hex format.
- Format
- Format combines a scheme (encryption method) with an encoding (text representation).
- Ob
- A flexible ObtextCodec implementation with runtime format selection.
- Omnib
- An ObtextCodec that takes the format per operation.
- Pgcmsiv
B32 - ObtextCodec implementation for pgcmsiv.b32 format.
- Pgcmsiv
B64 - ObtextCodec implementation for pgcmsiv.b64 format.
- Pgcmsiv
C32 - ObtextCodec implementation for pgcmsiv.c32 format.
- Pgcmsiv
Hex - ObtextCodec implementation for pgcmsiv.hex format.
- PsivB32
- ObtextCodec implementation for psiv.b32 format.
- PsivB64
- ObtextCodec implementation for psiv.b64 format.
- PsivC32
- ObtextCodec implementation for psiv.c32 format.
- PsivHex
- ObtextCodec implementation for psiv.hex format.
Enums§
- Encoding
- Encoding identifier for text representation.
- Error
- All errors that can occur in oboron operations.
- ObAny
- Type-erased ObtextCodec encoder that can hold any scheme+encoding combination.
- Scheme
- Scheme identifier for oboron encoding schemes.
Constants§
- DGCMSIV_
B32 - DGCMSIV_
B64 - DGCMSIV_
B32_ STR - DGCMSIV_
B64_ STR - DGCMSIV_
C32 - DGCMSIV_
C32_ STR - DGCMSIV_
HEX - DGCMSIV_
HEX_ STR - DSIV_
B32 - DSIV_
B64 - DSIV_
B32_ STR - DSIV_
B64_ STR - DSIV_
C32 - DSIV_
C32_ STR - DSIV_
HEX - DSIV_
HEX_ STR - PGCMSIV_
B32 - PGCMSIV_
B64 - PGCMSIV_
B32_ STR - PGCMSIV_
B64_ STR - PGCMSIV_
C32 - PGCMSIV_
C32_ STR - PGCMSIV_
HEX - PGCMSIV_
HEX_ STR - PSIV_
B32 - PSIV_
B64 - PSIV_
B32_ STR - PSIV_
B64_ STR - PSIV_
C32 - PSIV_
C32_ STR - PSIV_
HEX - PSIV_
HEX_ STR
Traits§
- Obtext
Codec - Core trait for ObtextCodec encryption+encoding/decoding+decryption implementations.
Functions§
- dec
- Decode+decrypt obtext with a specified format.
- enc
- Encrypt+encode plaintext with a specified format.
- from_
bytes - Create an encoder from a format string and raw bytes.
- from_
bytes_ with_ format - Create an encoder from a pre-parsed Format and raw bytes.
- from_
hex_ key - Create an encoder from a format string and a 128-character hex key.
- from_
hex_ key_ with_ format - Create an encoder from a pre-parsed Format and a 128-character hex key.
- generate_
key - Generate a cryptographically secure random 64-byte key and return it as a 128-character lowercase hex string.
- generate_
key_ bytes - Generate a cryptographically secure random 64-byte key as raw bytes.
- generate_
key_ hex Deprecated - Deprecated alias for
generate_key. - new
- Create an encoder from a format string and a 128-character hex key.
- new_
with_ format - Create an encoder from a pre-parsed Format and a 128-character hex key.