Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Cryptography Suite

Quality gate Python 3.11+ License: MIT

Policy-driven envelope encryption for Python. One small API seals data under a fresh key, wraps that key for every recipient you configure (a cloud key service, an offline escrow key, a quorum of custodians), binds the result to its context, and opens it only when every byte and every binding verifies.

Project page: psychevus.com/work/cryptography-suite · in-browser lab: psychevus.com/lab/envelope

Status: 4.0.0rc1 is a release candidate, a pre-release. The envelope format, the public API, the command line, and the JSON documents are frozen for 4.0; a change to any of them restarts the public review. It is not independently audited, and it is under public review for at least 60 days before 4.0.0 (review guide). Evaluate it, but do not protect production data with it yet. Install it with pip install --pre cryptography-suite; without --pre, pip selects 3.0.0, the retired v3 educational toolkit, which is unrelated to this API.

Why

  • No cryptographic decisions for the caller. No algorithms, key sizes, nonces, or KDFs to choose: AES-256-GCM under a fresh 256-bit key per envelope, with key commitment and a STREAM record construction.
  • Your key service, your control. AWS KMS, Google Cloud KMS, Azure Key Vault and Managed HSM, and HashiCorp Vault Transit, through clients you build. Keys never leave the service, and every wrap is bound to its envelope.
  • Recoverable by design. Every envelope can carry several recipients: a second region, an offline escrow key, or a k-of-n quorum of custodians. Rotation rewraps in place and never drops one.
  • Post-quantum ready. Hybrid ML-KEM recipients and an ML-DSA-signed audit trail, alongside classical keys, in the same format.
  • Safe at any size. Streams in bounded memory, publishes output only after the last record verifies, and reads authenticated byte ranges of large objects without reading the rest.
  • Built to be checked. A byte-level specification with test vectors, a 248-case conformance suite, an independent JavaScript implementation, 100% line and branch coverage, fuzzing, mutation testing, and a published threat model.

Install

git clone https://github.com/Psychevus/cryptography-suite.git
python -m pip install ./cryptography-suite

Python 3.11 or later. The core depends only on pyca/cryptography; each key-service integration is a separate distribution (installation).

Quick start

This runs as is, with a key held in the process:

from cryptography_suite import EncryptionContext, Policy, Protector
from cryptography_suite.providers.hpke import HpkeRecipientProvider, generate_private_key

identity = generate_private_key()  # in production: a key-service key
provider = HpkeRecipientProvider()
key = provider.add_identity("invoices", identity)
protector = Protector(provider=provider, policy=Policy(), primary_key=key)

context = EncryptionContext({"tenant": "acme"}, purpose="invoice-archive")
envelope = protector.seal(b"invoice 2026-0042: 1,200 EUR", context=context)
assert protector.open(envelope, context=context) == b"invoice 2026-0042: 1,200 EUR"

The context is authenticated but never stored: an envelope sealed for one tenant cannot be opened as another's. Any change to the envelope's bytes, or a different context, raises a typed error with a stable code.

A production shape

A key-service primary key, an offline escrow key, an enterprise policy, and a signed audit trail:

from cryptography_suite import KeyRef, Policy, Protector
from cryptography_suite.providers.hpke import HpkeRecipientProvider, load_public_key_text
from cryptography_suite_aws_kms import PROVIDER_ID as AWS, AwsKmsProvider

escrow = HpkeRecipientProvider(provider_id="com.example.escrow")
escrow.add_recipient("break-glass", load_public_key_text(escrow_public_key))

protector = Protector(
    providers=[AwsKmsProvider(kms_client), escrow],
    policy=Policy.enterprise(approved_providers=[AWS, escrow.provider_id]),
    primary_key=KeyRef(AWS, "alias/payments"),
    additional_keys=[KeyRef(escrow.provider_id, "break-glass")],
    audit_sink=audit_chain,
)

Every envelope is wrapped for both keys. If the KMS key is disabled or the region is lost, the escrow key opens everything; when the KMS key rotates, rewrap moves envelopes to the new version and keeps the escrow recipient. Only keys you configure are trusted for opening, so an envelope made under someone else's key is never accepted as yours.

Features

Key services AWS KMS, Google Cloud KMS (including ML-KEM and X-Wing keys), Azure Key Vault and Managed HSM, HashiCorp Vault Transit; your own with a conformance kit
Public-key recipients HPKE (RFC 9180) with X25519, P-384, ML-KEM-768 + X25519, and ML-KEM-1024 + P-384; sealers hold only public keys
Recovery Escrow keys, k-of-n quorum recovery in which no custodian's key moves, rewrap without re-encryption
Scale Hierarchical keys: one key-service call per tenant key per cache period instead of one per envelope
Large data Streaming up to 1 TiB, atomic file output, authenticated range reads
Audit Secret-free events, a signed hash-chained trail (Ed25519, or Ed25519 with ML-DSA-65), OpenTelemetry metrics
Policy Immutable policies with content-derived identifiers that only narrow when combined; a FIPS profile
Interoperability COSE-HPKE messages and keys; a JavaScript implementation for browsers, Node.js, Deno, and edge runtimes
Command line cryptosuite with atomic output, JSON status, and stable exit codes
From v3 Verified migration of v3 encrypted files into v4 envelopes, without writing plaintext, and an inventory and policy-checked import of v3 keys

Documentation

The full documentation, with the API reference, is built from docs/.

Assurance

What has been done, and what has not:

  • The format is specified byte by byte, with test vectors checked by an independent reader, and a conformance suite that the Python and JavaScript implementations both pass.
  • Every primitive is checked against Project Wycheproof, HPKE against the CFRG vectors, and COSE-HPKE against the draft's examples.
  • CI enforces 100% line and branch coverage, combined across Linux, macOS, and Windows; tests every single-bit change and truncation of envelopes against every reader; and fuzzes every untrusted input weekly.
  • An internal audit, including mutation testing, found and addressed twelve issues (RFC-0031). The threat model states each security claim with the tests that support it.
  • No independent audit has been done yet. It is a release gate for 4.0.0 (proposed scope).

Report vulnerabilities privately, as described in SECURITY.md.

Contributing

See CONTRIBUTING.md. The design is recorded in RFCs, and changes are listed in the changelog.

License

MIT.

Metadata

Release files for cryptography-suite 4.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptography-suite 4.0.0rc1
File Size Uploaded Provenance Actions
cryptography_suite-4.0.0rc1.tar.gz 135.2 kB With provenance Details for cryptography_suite-4.0.0rc1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cryptography-suite 4.0.0rc1
File Interpreter ABI Platform Actions
cryptography_suite-4.0.0rc1-py3-none-any.whl Python 3 none any Details for cryptography_suite-4.0.0rc1-py3-none-any.whl

Total release size: 294.4 kB

Release files / cryptography_suite-4.0.0rc1.tar.gz

Download URL cryptography_suite-4.0.0rc1.tar.gz
Size 135.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a5038ee4f7e681a5c16c3077cee5763f6805ffcce59cad555e8fbba05d921e1e
BLAKE2b-256 checksum
How to use checksums
2eca828679f3926c28598c08961ae1ded2c36903466ca14ffa83adf95eab6380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / cryptography_suite-4.0.0rc1-py3-none-any.whl

Download URL cryptography_suite-4.0.0rc1-py3-none-any.whl
Size 159.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ec80d1dcd349c818c8ba9e815bfe38922e27d038d722e9b70f8d51e835a557
BLAKE2b-256 checksum
How to use checksums
250ae87eab0eba0e5c246e78b84a8f2383d61025663256987a04eee40bedc101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for cryptography-suite 4.0.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cryptography_suite-4.0.0rc1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page