Skip to main content

Python bindings for obcrypt — bytes-in/bytes-out authenticated encryption (oboron protocol core schemes).

Project description

obcrypt

Python bindings for obcrypt — the bytes-in / bytes-out cryptographic core of the oboron protocol. Authenticated symmetric encryption operating on raw bytes; no text encoding, no UTF-8 validation.

Install

pip install obcrypt

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 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 obcrypt

key = obcrypt.generate_key()
# 'd853c88c2b1f...f10649cb'  (128 lowercase hex chars)

Wherever obcrypt 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 the hex form is the canonical input everywhere.

Quick start

Codec class style

Binds a key and scheme together — most ergonomic when one codec handles many messages.

import obcrypt

key = obcrypt.generate_key()
dsiv = obcrypt.Dsiv(key)

payload = dsiv.encrypt(b"hello")
plaintext = dsiv.decrypt(payload)
assert plaintext == b"hello"

Or, from an env var:

import os, obcrypt
dsiv = obcrypt.Dsiv(os.environ["OBCRYPT_KEY"])

Free-function style

Pass the scheme as a string (or a constant from obcrypt.schemes) on each call.

import obcrypt
from obcrypt import schemes

key = obcrypt.generate_key()

payload = obcrypt.encrypt(b"hello", schemes.DSIV, key)
plaintext = obcrypt.decrypt(payload, schemes.DSIV, key)
assert plaintext == b"hello"

The output carries no scheme marker, so the same scheme used to encrypt must be supplied to decrypt; a wrong scheme raises DecryptionFailed (the authentication check fails).

Schemes

All four are authenticated.

Name Determinism Algorithm
dsiv deterministic AES-SIV
psiv probabilistic AES-SIV
dgcmsiv deterministic AES-GCM-SIV
pgcmsiv probabilistic AES-GCM-SIV

dsiv is the most general default. See the obcrypt crate docs for algorithm details and per-scheme use-case guidance.

Exceptions

All errors inherit from obcrypt.ObcryptError:

  • InvalidKey — bad hex / wrong-length key
  • InvalidScheme — unknown scheme name
  • EncryptionFailed — AEAD failure / empty plaintext
  • DecryptionFailed — tag check, short payload, wrong scheme

Development build

pip install maturin
cd obcrypt-py
maturin develop --release

License

Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE) or the MIT license (LICENSE-MIT) at your option. Both texts are bundled in the package.

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

obcrypt-1.0.0.tar.gz (57.1 kB view details)

Uploaded Source

Built Distributions

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

obcrypt-1.0.0-cp38-abi3-win_amd64.whl (183.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

obcrypt-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (273.1 kB view details)

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

obcrypt-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (259.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

obcrypt-1.0.0-cp38-abi3-macosx_11_0_arm64.whl (244.1 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

obcrypt-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl (259.2 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for obcrypt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9abb089139558011ce9bac8853ff17daaee1114a7774699e212c9e98c6b23174
MD5 2aac61004eb276d841017255652dcd38
BLAKE2b-256 e22aca540ca3f18b9999f44bdc71de21925c6d0d8db9cd847c9a01620729b71c

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0.tar.gz:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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 obcrypt-1.0.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: obcrypt-1.0.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 183.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 obcrypt-1.0.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 425a5ebe0b8ff60ccd7903f438c2e747889967a1280ac02587dc579ddb06b876
MD5 0fad650e93754f9f93b0f3d70e6e38e3
BLAKE2b-256 58461272b43d4d26f1c19a13bc686e341e632d5a70965ea2b8ac8349681ed165

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0-cp38-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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 obcrypt-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for obcrypt-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 93e80e30c63467106dc40f5195012614da2e16af6185a70580203b42ebb6875d
MD5 6f8c4d3348c244073181bd1c2e63bef6
BLAKE2b-256 e79f2e6cddcb0cb8a855a2a2dc81441a34e8935227b6ce643cc2cd809c080a28

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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 obcrypt-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for obcrypt-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 abbd79351654981bd106ad3f3281206369e2a9304dcb94895a895f7541016819
MD5 0b6209c3bcfaefa63c68001e0c3d40a4
BLAKE2b-256 cff939f0d4cd13d11387f9805860f542e8badb3f3db70ef11e33497e00043d18

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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 obcrypt-1.0.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for obcrypt-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b1afb95a080632a42aecff3de1f5415124951748bfbd023dce6de6b66c04728
MD5 ed2081b7a1de99cde757e43a6cc2b835
BLAKE2b-256 fbffff21d7c670a0fa3501c094c9527334c16ed33d59c3ed1a10db629c29182c

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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 obcrypt-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for obcrypt-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 21816a6269bb75f4237c51bdc6d0c74145dc66188d34dfdfd479c97efc10678a
MD5 e1c56f904c7e1099fcf82772bbbc69b9
BLAKE2b-256 83767b136cbaa4bf18d05b1f4b5bcec9830bc3cda2d80464157f931499b694b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for obcrypt-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-pypi.yml on deyanovich/obcrypt-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