Command line¶
cryptosuite seals, opens, inspects, and rewraps files, for scripts,
operators, and recovery work. Output is always written atomically, status is
available as one JSON object, and exit codes are stable.
A first run¶
The configuration names the keys; the private key is passed separately, never in an argument or an environment variable. This Python snippet creates a key pair, a key configuration, and a context file:
import json
from pathlib import Path
from cryptography_suite.providers.hpke import generate_private_key, private_key_pem, public_key_text
identity = generate_private_key()
Path("identity.pem").write_bytes(private_key_pem(identity)) # protect this file
Path("keys.json").write_text(json.dumps({
"schema_version": "cryptosuite-provider-config/1",
"providers": [{
"type": "hpke",
"recipients": [{"key_id": "archive", "public_key": public_key_text(identity.public_key())}],
"identity": {"key_id": "archive"},
}],
"keys": {"archive": {"provider_id": "cryptography-suite.hpke", "key_id": "archive"}},
"primary_key": "archive",
}, indent=2))
Path("context.json").write_text(json.dumps({
"schema_version": "cryptosuite-context/1",
"values": {"tenant": "acme", "purpose": "reports"},
}))
Path("report.pdf").write_bytes(b"%PDF-1.7 example")
Seal, inspect, and open:
$ cryptosuite --provider-config keys.json encrypt \
--input report.pdf --output report.pdf.cse --context-file context.json
encrypt: ok
streaming envelope, 1 records, 1 recipient(s), not_verified
policy cs-policy-v1:rYoorsHEPr6CMQWgcIBaLNfmmp3wUldtyVrG7rh_pnY
$ cryptosuite inspect --input report.pdf.cse
inspect: ok
streaming envelope, 1 records, 1 recipient(s), not_verified
policy cs-policy-v1:rYoorsHEPr6CMQWgcIBaLNfmmp3wUldtyVrG7rh_pnY
$ cryptosuite --provider-config keys.json decrypt \
--input report.pdf.cse --output report-restored.pdf \
--context-file context.json --secret-stdin < identity.pem
decrypt: ok
streaming envelope, 1 records, 1 recipient(s), verified
policy cs-policy-v1:rYoorsHEPr6CMQWgcIBaLNfmmp3wUldtyVrG7rh_pnY
Sealing needs only public keys, so encrypt reads no secret. If the private
key PEM is password-protected (private_key_pem(identity, password=...)),
decrypt asks for the password on the terminal; with --non-interactive it
fails instead.
On POSIX shells, --secret-fd reads the key from an inherited descriptor and
keeps stdin free for the input:
$ cryptosuite --provider-config keys.json decrypt --input - --output out.pdf \
--context-file context.json --secret-fd 3 3< identity.pem < report.pdf.cse
Commands¶
Command |
Does |
Needs a private key |
|---|---|---|
|
Seals |
No |
|
Verifies and opens |
Yes |
|
Shows unverified metadata, offline. |
No |
|
Moves an envelope to |
Yes |
|
Checks each configured provider. |
No |
|
Checks the |
No |
|
Reports versions, ML-KEM and FIPS availability, filesystem guarantees, and whether the given policy and configuration are valid. |
No |
|
Moves a v3 file into a verified v4 envelope, inventories a v3 key store ( |
To verify a file migration |
Global options go before the command:
Option |
Meaning |
|---|---|
|
The key configuration. |
|
A policy JSON document ( |
|
A short summary, or one |
|
Also write the JSON status to a new file, published atomically like any output: never over an existing file or through a link. |
|
Cancel after this long; the output is rolled back. |
|
Never prompt. |
|
No summary on success. |
|
Diagnostics on stderr. |
Command options: --input PATH (or - for stdin), --output PATH,
--overwrite (also requires allow_overwrite in the policy),
--context-file PATH (repeat to merge files; each key may appear once), and
--secret-fd FD or --secret-stdin.
Files¶
Key configuration (cryptosuite-provider-config/1):
Field |
Meaning |
|---|---|
|
A list of HPKE providers: |
|
Names for keys: |
|
The name of the key every envelope is sealed to first. |
|
Names of further recipients, such as an escrow key. |
Every key named in keys is trusted for opening. Unknown fields are
rejected. Cloud key services are used through the Python API; the command
line never imports a provider by name from a file.
Context (cryptosuite-context/1): values maps keys to text, or to
{"base64url": "..."} for bytes.
Status and exit codes¶
With --output json, stdout carries exactly one object:
{"schema_version": "cryptosuite-status/1", "command": "decrypt", "status": "ok",
"operation_id": "op_...", "result": {"metadata": {"...": "..."}},
"warnings": [], "error": null}
On failure, status is "error" and error holds code, category,
message, retryable, and details. The status never contains paths,
context values, keys, or plaintext.
Exit |
Meaning |
|---|---|
0 |
Success |
2 |
Invalid arguments, configuration, or policy |
3 |
Malformed or unsupported envelope |
4 |
Authentication or context failure |
5 |
Denied by policy or key state |
6 |
Key not found, not trusted, or not capable |
7 |
Key service unavailable, timed out, or throttled |
8 |
I/O failure, or the output already exists |
9 |
Cancelled |
10 |
Migration failure: the new envelope did not verify |
70 |
Internal error |
The complete contract is RFC-0009, as implemented by RFC-0015.