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
dgcmsiv deterministic AES-GCM-SIV Auth + compact + deterministic
pgcmsiv probabilistic AES-GCM-SIV Auth + max privacy
dsiv deterministic AES-SIV General-purpose auth, nonce-misuse safe
psiv probabilistic AES-SIV Auth + max privacy + nonce-misuse safe

Every oboron scheme is authenticated. For new security-sensitive work, dsiv is a strong default.

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, no obscenity rules
c32 Crockford base32 Lowercase, obscenity-aware
b64 RFC 4648 URL-safe base64 Most compact
hex Hexadecimal Longest output, fastest 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.1.tar.gz (110.9 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.1-cp38-abi3-win_amd64.whl (275.5 kB view details)

Uploaded CPython 3.8+Windows x86-64

oboron-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (351.3 kB view details)

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

oboron-1.0.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (331.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

oboron-1.0.1-cp38-abi3-macosx_11_0_arm64.whl (315.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

oboron-1.0.1-cp38-abi3-macosx_10_12_x86_64.whl (337.5 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: oboron-1.0.1.tar.gz
  • Upload date:
  • Size: 110.9 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.1.tar.gz
Algorithm Hash digest
SHA256 dd31114e9565af75a30cbd7187166a5918391f8e50a1387dd08bce7f2f5fc0ad
MD5 5f9484aa687dbd19204f5472bfe23655
BLAKE2b-256 f6c8843d0a1478540513dafa47c6a9845abc570effb44eaa92dc2b7ccaf27689

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1.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.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: oboron-1.0.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 275.5 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.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d79ea5d0d57870a5a1145269ebdbc1d6a194fdeca90fa420f6257623495b7ed9
MD5 0369f9520575c26842f3a35554217472
BLAKE2b-256 ba8587208924c75155a51e73692509ad577fc8972699c97fe8eb5a73420e405a

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1-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.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for oboron-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13bcd98cf0b442694d0ddf2a8e74f21350d074f468e121fd873c750e71ae3b98
MD5 da9873afd6335526ce7163dd15236dbf
BLAKE2b-256 83f385f91d1a0e89ef8f1113de5e36f705913ea14a2d60b4359f5d3d34c9ebd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1-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.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for oboron-1.0.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 294d8e3457a90c86d9aedec2b7056f1031f58c88fd374081b8303293861a06a7
MD5 0995bdd571f9ccddea257dc502da3a88
BLAKE2b-256 b6e70d9417a1b7a0e6eac1fb0c9cd34f3ca550837178652b9542d9eabba062ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1-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.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: oboron-1.0.1-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 315.8 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.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7a7e5358d2c86963fed3959e50b443dd041b95578c5ac2a8b34981ceee061ea
MD5 c57832f22d514d92a7346fcd7baf18c5
BLAKE2b-256 4e7019ff3996c179bd60e43823edc9027f6efe41b0f8ad780e9a2d4125474bbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1-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.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for oboron-1.0.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 aa661c6f1a664978ddb9a7a350cb2c494a99ef015a749a8820ac10b293d93843
MD5 3d93fc9042770a399456918477340a30
BLAKE2b-256 56a6410048975b37523b484364fb4e2d188ddeb4824815f121b96f69a5320054

See more details on using hashes here.

Provenance

The following attestation bundles were made for oboron-1.0.1-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