Skip to main content

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

Project description

oboron

PyPI Python Versions License: MIT 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.0.tar.gz (107.5 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.0-cp38-abi3-win_amd64.whl (274.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

oboron-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (350.8 kB view details)

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

oboron-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (331.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

oboron-1.0.0-cp38-abi3-macosx_11_0_arm64.whl (315.4 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

oboron-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl (337.8 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: oboron-1.0.0.tar.gz
  • Upload date:
  • Size: 107.5 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.0.tar.gz
Algorithm Hash digest
SHA256 c1aea2d33063c32b7fd88ae91b88bed46109ff6f815f13c132488ce81cb080e4
MD5 0b6d20b123e7a62056c8673244d77399
BLAKE2b-256 1d9d5c2f10fd29f52320427520e5a290924b5e687e578c909e7f1aaabb3bfc7d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oboron-1.0.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 274.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.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 76680ca4509f5f02c611d443899dfc35f0aa21cdb40bce77b23767ee5c703369
MD5 f554236c83f3b822bdd364615589710c
BLAKE2b-256 4574db87793e3f7d6cb0e0f4a7e742db9275d146287331754af49f1034a1f353

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oboron-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0887e242a35da09b399a1cf7ded3009904f5f4e708cc9882b54533f5d27d211f
MD5 0f9fb7b7615f208de723c318dcb7f2f7
BLAKE2b-256 345cb18a0a499a164460fdf5eec21112e23f400322301c3ca31fc46151e3bb79

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oboron-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1575c441d5b4c662baa5c10f61786f6e152c253c10fd4753cd64a9e8c864d26b
MD5 f5df29cdae5ebce79a1b4ae21c0a2416
BLAKE2b-256 60a32afc862993a0c2bc9dbb157af8a08ae6d278724cd6ed74ddaa5956f9ec4b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: oboron-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 315.4 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.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e78b2ff9643676659d75fccf16444540357c7f66082fc61820bdcfb027f0e9d
MD5 b3b0ce92bf558ceeeef6d2f147f42e6b
BLAKE2b-256 c29a593e26a378f04b50b766038578e37d48bd8ed2fb962097b03f8f7ce0588a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for oboron-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0d355fb616c7f5fa4ac1d33389cf55f6b2d229b2be661f63abe7747a1b8f1617
MD5 c9d8f3806943f2d1e483abfa586e035d
BLAKE2b-256 5e203b9ddc1e76a2c27e75d980ff4d3faed4c18d6397f394871491d05ef2180b

See more details on using hashes here.

Provenance

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