Search Psychevus

12 results available.
↑ ↓ to navigate ↵ to open · esc to close

Open-source research project · MIT licence

cryptography-suite

Envelope encryption for Python, specified to the byte and built to be checked.

4.0.0rc1, released 1 December 2026. Release candidate, a pre-release. The envelope format, public API, command line and JSON documents are frozen for 4.0. Not independently audited; under public review before 4.0.0. The project’s own advice: evaluate it, but don’t protect production data with it yet.

What it is

Most encryption bugs aren’t broken ciphers. They’re a reused nonce, a key that decrypts the wrong tenant’s data, a ciphertext that can be cut short without anyone noticing, or a master key whose loss turns into data loss. cryptography-suite takes those decisions away from the caller.

One small API seals data under a fresh key, wraps that key for every recipient a policy names (a cloud key service, an offline escrow key, a quorum of custodians, a post-quantum hybrid key), binds the result to its context, and opens it only when every byte and every binding verifies. Version 4 is a rewrite into that shape, with a normative specification, 36 design records and a second implementation in JavaScript.

I started it in November 2024 as an educational toolkit. Version 3 is now retired, and the project says plainly why: its own list of that version’s weaknesses is part of the repository.

What was verified

Checked on commit eab9f0c, 2026-12-01. Each line says how, and by whom.

  1. 1,677 passed, 14 skipped

    The test suite passes

    Full pytest run of the v4.0.0rc1 tag (commit eab9f0c) on Windows, Python 3.13, with the project’s pinned development requirements and all five provider packages. The 14 skips are POSIX-only or need a symlink privilege.

    Me, on 1 December 2026

  2. 36 of 36 JavaScript tests pass

    A second implementation agrees

    The dependency-free WebCrypto reader and sealer, written from the specification by the same maintainer (so a cross-check, not an independent one): test vectors, negative vectors and a review suite (the project’s npm test), on Node.js 24, at the v4.0.0rc1 tag.

    Me, on 1 December 2026

  3. 248 of 248 cases agree

    The conformance corpus matches the specification

    tools/conformance.py check at the v4.0.0rc1 tag: every case’s expected plaintext or error code, reproduced by the reference implementation.

    Me, on 1 December 2026

  4. 7,376 of 7,376 single-bit changes refused

    Every single-bit change to two lab envelopes is refused

    This site’s own test flips each of the 8 bits of every byte of two lab envelopes (with and without an escrow recipient), one at a time, and opens every copy with the vendored JavaScript reader. Exhaustive for those two envelopes; it is a test, not a proof for every possible envelope.

    This site’s test suite, on every release

  5. Project Wycheproof (2,827 cases), CFRG HPKE vectors

    Primitives are checked against published vectors

    Part of the passing test suite: AES-256-GCM, HKDF, HMAC, X25519, P-384, Ed25519, RSA-OAEP, ML-KEM-768/1024 and ML-DSA-65, called as the library calls them.

    The project’s tests, run by me

  6. 100% line and branch coverage required; pinned actions; attested releases

    Coverage and supply chain are enforced

    Read in pyproject.toml and the workflows: CI fails below 100% combined across Linux, macOS and Windows; releases go to PyPI only through Trusted Publishing with build-provenance attestations (4.0.0rc1 published the core and the five provider packages together on 1 December 2026).

    Read by me; enforced by GitHub Actions

  7. 5 of 5 runbooks run as drills on every change

    The incident runbooks are rehearsed

    Each runbook (compromised key, compromised escrow key, departing quorum custodian, key-service outage, rising authentication failures) is a test that follows its steps through the public API on Linux, macOS and Windows, against in-process key services. A rehearsal against a real key service is still open.

    Read by me; run in the project’s CI

How it is built

In

  • Your data
  • A context: tenant, purpose
  • A policy

Protector

  • Fresh data key256 bits, per envelope, from the OS random source
  • Key scheduleHKDF-SHA-512 → content key, key commitment, context key, recipient key
  • RecordsAES-256-GCM, STREAM construction, bounded memory

Wraps the data key for

  • Cloud key servicesAWS KMS · Google Cloud KMS · Azure Key Vault · Vault Transit
  • Public-key recipientsHPKE: X25519, P-384, ML-KEM-768 + X25519, ML-KEM-1024 + P-384
  • RecoveryEscrow keys · k-of-n custodian quorum
  • ScaleHierarchical branch keys

Out

  • The envelopePreamble · protected header · recipients · records
  • Audit trailSecret-free events, signed and hash-chained (Ed25519, optionally + ML-DSA-65)
  • MetricsOpenTelemetry
Data never goes to the key service: only a 32-byte data key does, to be wrapped. Opening reverses the path, and the reader, not the envelope, decides which keys it trusts.

Capabilities, evidence and status

Every row is in the repository today. The last column is the kind of client work it is evidence for.

CapabilityEvidenceStatusRelated work
Envelope format v4.0 and suite 1: AES-256-GCM with an HKDF-SHA-512 key schedule, key commitment, keyed context commitment, STREAM recordsdocs/v4/spec, envelope/Byte-level specification, test vectors, 248-case conformance corpus, a second reader in JavaScript written from the specificationRelease candidate; frozen for 4.0Encryption architecture review
Key-service providers: AWS KMS, Google Cloud KMS, Azure Key Vault and Managed HSM, HashiCorp Vault Transitpackages/Exercised through each vendor’s real SDK against local fakes; a provider conformance kit; each published to PyPI as its own packageTier 2 Preview: no live-service tests yetKMS integration
Post-quantum hybrid recipients: ML-KEM-768 with X25519 (X-Wing), ML-KEM-1024 with P-384, through pyca/cryptography’s HPKEproviders/hpke.pyWycheproof ML-KEM vectors; refuses to downgrade when the backend lacks ML-KEMRelease candidate; needs a backend with ML-KEMPost-quantum readiness sprint
Signed, hash-chained audit trail: Ed25519, or Ed25519 with ML-DSA-65audit/chain.pyTests for edit, insertion, deletion, reordering and truncation; downgrade of a hybrid trail refusedRelease candidateEncryption architecture review
Recovery: escrow recipients, k-of-n quorum recovery (Shamir sharing over HPKE), rewrap without re-encryptionproviders/quorum.py, protector.pyCeremony tests; two internal reviewsRelease candidate; the quorum code is custom and in the audit scopeEncryption architecture review
Hierarchical (branch) keys: one key-service call per tenant key per cache periodproviders/hierarchical.pyBenchmarks: about 17× faster than direct calls with a simulated 10 ms key serviceRelease candidateKMS integration
Streaming up to 1 TiB, authenticated range reads, failure-atomic file outputstreaming/, _internal/filesystem.pyFailure-injection matrix on Linux, macOS and WindowsRelease candidateImplementation
Interoperability: COSE-HPKE messages and keys (draft-ietf-cose-hpke-27)cose/CFRG HPKE vectors; the draft’s own examplesTracks an IETF draft that may changeCryptographic code review
Policy: immutable policies with content-derived identifiers, a FIPS-algorithms profilepolicy.pyTests; the FIPS profile restricts algorithms on a FIPS-mode backendRelease candidate; a policy profile, not a FIPS 140-3 validationCrypto-agility design
Verified migration from the retired v3 toolkit, without writing plaintext to diskmigration.py, legacy/Failed migrations publish nothing and never touch the source (integration tests)Release candidateMigration engineering

What it is not

  • No independent security audit has been done. Under RFC-0036, 4.0.0 can ship at the “community-reviewed” level (a public review period of at least 60 days, a published external review, an independent rebuild and an external trial); “audited” needs a funded audit, whose scope is written down. Until 4.0.0, the project says: don’t protect production data with it.
  • The AWS, Google Cloud, Azure and Vault providers ship as Tier 2 Preview: tested through each vendor’s real SDK against local fakes, not yet against live cloud accounts.
  • Two internal reviews found and fixed issues, including two rated High. The second was a blind review run with AI model instances by the maintainer: useful, but not independent.
  • One maintainer. Two-person review needs a second maintainer; the external review, independent rebuild and external trial are open gates that outsiders can close.
  • Python can’t guarantee that secrets are erased from memory; the library overwrites the buffers it owns, as a best effort. Constant-time behaviour is claimed only for the comparisons the specification names.
  • Envelopes authenticate their recipients, not their sender: anyone who can wrap to a recipient key can seal to it.
  • No FIPS validation, certification or compliance claim is made, and using standardised algorithms doesn’t create one.

For production data today, use a mature, widely reviewed library: the AWS Encryption SDK, Google’s Tink, or your cloud’s client-side encryption. Choosing between them is part of the work I do.

My review notes

I read my own project the way I would read a client’s: on commit eab9f0c, 2026-12-01. This is a maintainer’s review, not an independent one.

What holds up

  • Sound, conventional choices: a fresh data key and message identifier per envelope, so counter nonces never repeat under one key; key commitment from the key schedule; STREAM-style records with a final flag; a context commitment keyed from the data key so low-entropy tenant names can’t be guessed offline.
  • The reader, not the envelope, decides which keys are trusted. An envelope sealed under someone else’s key is never sent to a key service.
  • Claims are tied to tests. The threat model lists each security claim with the test that would fail if it stopped holding, and a contract test keeps unsupported production, FIPS or audit claims out of the documentation.
  • Primitives come from pyca/cryptography and WebCrypto. The project assembles standard constructions; it doesn’t invent ciphers.

What I would change next

  • Since rc1 the README says the format is frozen, but SECURITY.md, the production guide and the specification’s status line still say it is not frozen until RC1. They should all say the same thing. (The post-quantum guide’s missing rewrap caveat, noted in my first reading, has been fixed upstream.)
  • pip install cryptography-suite, without --pre, still selects the retired 3.0.0 toolkit. Until 4.0.0 is final, yanking 3.0.0 on PyPI (or a 3.0.1 that warns) would stop new users landing on code the project itself says not to use.
  • The custom parts deserve the auditor’s first hours: the quorum ceremony and its Shamir arithmetic (table-based, in Python), the HPKE key schedule assembled for COSE, and the filesystem race handling.

Using it, and working with me

Try it

pip install --pre cryptography-suite on Python 3.11 or later, on test data. Without --pre, pip selects the retired 3.0.0.

Documentation

Trial it with your key service

The stable release needs at least one outside party to seal and open synthetic data through a real key service and report the result. The trial costs nothing; help wiring it to your KMS is quoted work.

Report a trial Ask for help with a trial

Review it, or rebuild it

A published review counts even if it finds nothing, as long as it states its scope and method. An independent rebuild checks that the published packages match the source. Both are gates for 4.0.0 in RFC-0036.

Review guide Report a rebuild

Fund an audit

The “audited” level can’t be reached without an independent audit, and its scope is written down. If you fund or perform reviews of open-source cryptography, start there.

Proposed audit scope

The same care, applied to your system.

If you’re designing how your product encrypts customer data, choosing a key service, or planning a move to post-quantum algorithms, the cryptography practice has fixed-scope reviews, and the first reply, with a scope and a price, is free.

See the cryptography practice

Or write to me with a question. Short messages are fine.

YOUR VISIT, YOUR CHOICE

Privacy, by intention.

You decide what stays on your device. You can change your choice at any time.

Essential

Saves your privacy choice. Administrator sign-in uses a secure session cookie.

Always on
Full privacy notice ↗