Search Psychevus

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

Lab instrument / Applied cryptography

What does an encrypted record actually protect?

Envelope encryption seals each record under its own data key, then has a key service wrap that key. This page does it with a real library, in your browser. Change any byte and watch which check refuses it.

It runs the JavaScript implementation of cryptography-suite 4.0.0rc1, unchanged. The three keys are generated in this page and can’t be read out of it; nothing is sent anywhere. The key service is simulated, and the library is a pre-release that has not been independently audited.

Seal a message

The envelope, byte by byte

Generating three keys in your browser…

Try to break it

Result

Choose an experiment. Each one runs the real reader on these bytes.

One key per record, and the checks around it

Why envelopes

Sending every record to a key service to be encrypted is slow, costly and size-limited. So each record gets a fresh 256-bit data key that encrypts it locally, and only that 32-byte key goes to the key service to be wrapped. The wrapped key travels inside the envelope.

Rotating the master key then means rewrapping 32 bytes per record, not re-encrypting the data, and a second recipient (an escrow key, a second region) is one more wrap of the same small key.

What the checks catch

The binding. Each wrap is bound to the envelope’s header, so a wrapped key moved to another header won’t unwrap.

The commitments. AES-GCM alone doesn’t commit to its key: one ciphertext can be built to decrypt, differently, under two keys. A key commitment in the header rules that out. A keyed commitment to the tenant and purpose binds the record to one customer without storing either.

The records. Each one is authenticated with its position and a last-record flag, which is how the reader detects records that were reordered, cut off or appended.

What this lab leaves out

A real deployment uses a key service you don’t control from the browser (AWS KMS, Google Cloud KMS, Azure Key Vault, HashiCorp Vault) or public-key recipients, including post-quantum hybrid ones. Those live in the Python library. Streaming, range reads and rewrapping are Python-only too.

The lab shows that tampering is detected. It can’t show that a system is secure: that depends on who can call the key service, how keys are rotated and recovered, and what the application does with an error.

The same thing in Python

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"

From the project’s quick start. The format specification gives every byte you see above.

Sources and further reading

  1. Envelope format v4.0 (normative specification)cryptography-suite, 2026
  2. Threat model and security claimscryptography-suite, 2026
  3. Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance (the STREAM construction)Hoang, Reyhanitabar, Rogaway and Vizár, CRYPTO 2015
  4. How to Abuse and Fix Authenticated Encryption Without Key CommitmentAlbertini, Duong, Gueron, Kölbl, Luykx and Schmieg, USENIX Security 2022
  5. RFC 5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF)IETF, 2010
  6. NIST SP 800-38D: Galois/Counter Mode (GCM) and GMACNIST, 2007

Designing encryption for customer data?

An encryption architecture review looks at how your product seals data, which keys can open it, and how it recovers when a key is lost. Fixed scope, written findings.

See the encryption review

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 ↗