Skip to main content

Python bindings for oboron — string-in/string-out authenticated symmetric encryption + encoding (Dgcmsiv, Dsiv, Pgcmsiv, Psiv).

Project description

oboron

PyPI Python Versions License: MIT OR Apache-2.0 oboron crate

Python bindings for oboron — a string-in, string-out symmetric encryption and encoding library. One call takes plaintext to obtext (encrypted + encoded), one call brings it back. Multiple authenticated AES-based schemes (deterministic and probabilistic) share a single key and a uniform API.

For the bytes-in/bytes-out cryptographic core (no encoding, no UTF-8 validation), see obcrypt-py. oboron-py layers encoding and format strings on top.

Install

pip install oboron

Wheels are published for Linux (x86_64, aarch64), macOS (arm64, x86_64), and Windows (x86_64). The extension is built against PyO3's stable ABI (abi3-py38); a single wheel per platform covers CPython 3.8 and later.

Keys

Keys are 128-character hex strings — the canonical oboron key form, the same form that comes out of env vars, config files, and secrets managers. Generate one:

import oboron

key = oboron.generate_key()
# 'b5129efd1cf34b0c7a83...'  (128 lowercase hex chars)

Wherever oboron takes a key, it takes that string directly. Raw 64-byte key material is available via the key_bytes property and generate_key_bytes() for interop with byte-native APIs (HSMs, cryptography, pynacl, custom storage), but hex is the canonical input everywhere.

Quick start

Fixed-format codec (most common)

import oboron

key = oboron.generate_key()
ob = oboron.DsivC32(key)

obtext = ob.enc("hello, world")
plaintext = ob.dec(obtext)
assert plaintext == "hello, world"

DsivC32 binds a key + the dsiv.c32 format together — most ergonomic when one codec handles many messages of the same format. Available classes follow the {Scheme}{Encoding} pattern: DgcmsivB64, DsivHex, PsivC32, PgcmsivB32, etc.

Or, from an env var:

import os, oboron
ob = oboron.DsivC32(os.environ["OBORON_KEY"])

Runtime-flexible (Ob)

When the format is chosen at runtime (config, user input), use Ob — same shape, but set_format / set_scheme / set_encoding mutate the format in place.

ob = oboron.Ob("dsiv.b64", key)
obtext = ob.enc("hello")

ob.set_encoding("c32")        # now dsiv.c32
ob.set_scheme("dgcmsiv")      # now dgcmsiv.c32
ob.set_format("psiv.hex")     # now psiv.hex

Multi-format (Omnib)

Omnib doesn't store a format — pass one per call.

omb = oboron.Omnib(key)

ot_dsiv = omb.enc("hello", "dsiv.b64")
ot_dgcmsiv = omb.enc("hello", "dgcmsiv.c32")

assert omb.dec(ot_dsiv, "dsiv.b64") == "hello"
assert omb.dec(ot_dgcmsiv, "dgcmsiv.c32") == "hello"

Free functions

For one-off operations without instantiating a codec:

import oboron
from oboron import formats

key = oboron.generate_key()

obtext = oboron.enc("hello", formats.DSIV_B64, key)
plaintext = oboron.dec(obtext, formats.DSIV_B64, key)

Schemes

Name Determinism Algorithm Use case
dsiv deterministic AES-SIV General-purpose auth, nonce-misuse safe
psiv probabilistic AES-SIV Auth + max privacy + nonce-misuse safe
dgcmsiv deterministic AES-GCM-SIV Auth + compact + deterministic
pgcmsiv probabilistic AES-GCM-SIV Auth + max privacy

Every oboron scheme is authenticated. In general, AES-SIV and AES-GCM-SIV have similar properties, with AES-SIV being typically more performant on short inputs, while AES-GCM-SIV scales better with input size, and outperforms AES-SIV on long inputs.

The unauthenticated (upcbc) and obfuscation (zdcbc) layers live in the separate obu crate, not these bindings.

Encodings

Encoding Description Notes
b32 RFC 4648 base32 Uppercase
c32 Crockford base32 Lowercase (obscenity safe)
b64 RFC 4648 URL-safe base64 Most compact
hex Hexadecimal Longest output (slightly faster decode)

Format = scheme.encoding, e.g. dsiv.c32, dgcmsiv.b64, psiv.hex. The oboron.formats module exposes every valid combination as a constant: formats.DSIV_C32, formats.DGCMSIV_B64, etc. — useful for typo-resistance and editor autocomplete.

Exceptions

All errors inherit from oboron.OboronError:

  • InvalidKey — bad hex / wrong-length key
  • InvalidFormat — unknown scheme, unknown encoding, malformed format string
  • EncryptionFailed — AEAD failure / empty plaintext
  • DecryptionFailed — tag check, obtext-decode failure, post-decrypt UTF-8 validation
try:
    ob = oboron.DsivC32("not-a-real-key")
except oboron.InvalidKey as e:
    ...

Inheritance / isinstance

All codec classes plus Ob are registered as virtual subclasses of oboron.OboronBase. Useful for generic code:

def encrypt_each(cipher: oboron.OboronBase, items: list[str]) -> list[str]:
    return [cipher.enc(item) for item in items]

Keyless mode

Every codec accepts keyless=True instead of a key — it substitutes a publicly hardcoded key. This is for testing and obfuscation contexts where you actively want the output to be recoverable without secret material. Never use keyless=True when confidentiality matters.

ob = oboron.DgcmsivB64(keyless=True)

Development build

pip install maturin
cd oboron-py
maturin develop --release
python -m oboron.test_inheritance

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oboron-1.0.2.tar.gz (111.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

oboron-1.0.2-cp38-abi3-win_amd64.whl (275.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

oboron-1.0.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (351.4 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

oboron-1.0.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (332.2 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

oboron-1.0.2-cp38-abi3-macosx_11_0_arm64.whl (315.9 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

oboron-1.0.2-cp38-abi3-macosx_10_12_x86_64.whl (337.3 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file oboron-1.0.2.tar.gz.

File metadata

  • Download URL: oboron-1.0.2.tar.gz
  • Upload date:
  • Size: 111.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oboron-1.0.2.tar.gz
Algorithm Hash digest
SHA256 aa1490d6e0fd5fbfbf24ac7e3bfcf0a868e585b432b4165e9e077189af2742d3
MD5 8cb8b509649cf6c999f90545c790767b
BLAKE2b-256 4a8d9d6f516363210db4d90904d317c158866314857884d51f83d3e1211e3ffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2.tar.gz:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oboron-1.0.2-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: oboron-1.0.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 275.4 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oboron-1.0.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e1718c84b21590f400b1b90890d59d679a312d9972f729b3cf55d365a1785fff
MD5 0c1ce0641bec99edc3f8bf67abaf1bbd
BLAKE2b-256 8ab8c9b5a3844f1e3df484cf272bd4d4ac3b724bb87d679cb32387c32ef9a228

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2-cp38-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oboron-1.0.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for oboron-1.0.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58129d67d04787c5e6319a66b2cbf1886b2949299cbbfb3e74d76b7cd357663d
MD5 d2a898f9919daa61c631a9c8c97273e1
BLAKE2b-256 f31ce58cee699d734484415a97d590f96bfcf131dc2648e7f1031b244591b920

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oboron-1.0.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for oboron-1.0.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5d7e5f408d5dea89797de6a88c9e7107d57dad8e2e7e10c48d5af852082d2ee6
MD5 af7305326931b8c51246387fa14c8a9b
BLAKE2b-256 ffdab01d6fc1cccfae5acafef9003f79b9b5e357c12708dd6df6c0bbbb150a35

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oboron-1.0.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: oboron-1.0.2-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 315.9 kB
  • Tags: CPython 3.8+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oboron-1.0.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02543a2412c8c26ac9d81b310141c6fe465cb172c05b70dacd5a852d8a745f2a
MD5 f48f7deba81f9e5f780601b9231077ce
BLAKE2b-256 83e887f10eed82d24e2d48c6aca47328e7d4d8110bbd928d4e49fa2763e65d90

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oboron-1.0.2-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for oboron-1.0.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b6cdd36d8f6dede82d6e7cf623bb650f5eb94353e034fa838bdba5e9614204e4
MD5 13336d241b7462ba25d2d4ee618bef72
BLAKE2b-256 c11ecadb037ebc10cf0703f7fe144fc5822688d40e66091d11ea519cfd84ee5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.2-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/oboron-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page