infrastructure capa

infrastructure-secrets

Application-layer authenticated encryption for secrets at rest (AES-256-GCM). Master key held outside the database in an OS-protected file; sealed values carry nonce + key_id + algo_version for rotation. Decrypt once, hold plaintext only in process memory.

Application-layer authenticated encryption for secrets at rest (AES-256-GCM). Master key held outside the database in an OS-protected file; sealed values carry nonce + key_id + algo_version for rotation. Decrypt once, hold plaintext only in process memory.

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/secrets
Edition2021
Targetsinfrastructure_secrets
Public items13 across 0 modules
Tests14

What it is for

Application-layer authenticated encryption for secrets at rest.

Why this exists (Gate 1.5 consensus, sprint-02): the ecosystem's prior at-rest secret mechanism was pgcrypto pgp_sym_encrypt with the master key held in a Postgres session GUC (app.encryption_key). Both consensus reviewers flagged that pattern for camera credentials: fragile on pooled connections, one leaked master key exposes every row, privileged SQL can invoke decrypt_credential, and rotation means re-encrypting every row. This crate moves the boundary into Rust:

0400/0600; group/other-readable keys are rejected). Callers may instead supply key bytes from a TPM-sealed blob or a systemd credential.

old ciphertext still decrypts. Store ciphertext/nonce as BYTEA, key_id as TEXT, algo_version as INT.

plaintext only in process memory — never persist a credential-bearing URL.

The key material and decrypted plaintext are zeroized on drop.

Capabilities

crate root

Application-layer authenticated encryption for secrets at rest.

Item
pub const ALGO_AES_256_GCM: u16
pub const KEY_LEN: usize
pub const NONCE_LEN: usize

Sealed

Application-layer authenticated encryption for secrets at rest.

Item
pub struct Sealed

SecretCipher

Application-layer authenticated encryption for secrets at rest.

Item
pub struct SecretCipher
SecretCipher :: fn from_key_bytes(key : u8; KEY_LEN, key_id : impl Into <String>) -> Self
SecretCipher :: fn from_key_file(path : impl AsRef <Path>, key_id : impl Into <String>,) -> Result <Self, SecretError>
SecretCipher :: fn key_id(& self) -> & str
SecretCipher :: fn encrypt(& self, plaintext : & u8) -> Result <Sealed, SecretError>
SecretCipher :: fn encrypt_str(& self, plaintext : & str) -> Result <Sealed, SecretError>
SecretCipher :: fn decrypt(& self, sealed : & Sealed) -> Result <Zeroizing <Vec <u8>>, SecretError>
SecretCipher :: fn decrypt_str(& self, sealed : & Sealed) -> Result <Zeroizing <String>, SecretError>

SecretError

Application-layer authenticated encryption for secrets at rest.

Item
pub enum SecretError

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const ALGO_AES_256_GCM: u16AEAD algorithm identifier stamped into every Sealed value
pub const KEY_LEN: usizeLength of an AES-256 key, in bytes.
pub const NONCE_LEN: usizeLength of the AES-GCM nonce, in bytes (96-bit).
pub enum SecretErrorErrors from sealing / unsealing secrets.
pub struct SealedA sealed secret: everything needed to decrypt except the master key
pub struct SecretCipherSeals and unseals secrets with a single AES-256 master key
SecretCipher :: fn from_key_bytes(key : u8; KEY_LEN, key_id : impl Into <String>) -> SelfBuild a cipher from raw key bytes plus a key_id label (used to stamp sealed values and to check the right key is present on decrypt).
SecretCipher :: fn from_key_file(path : impl AsRef <Path>, key_id : impl Into <String>,) -> Result <Self, SecretError>Load the master key from an OS-protected file
SecretCipher :: fn key_id(& self) -> & strThe label identifying this cipher's master key.
SecretCipher :: fn encrypt(& self, plaintext : & u8) -> Result <Sealed, SecretError>Encrypt plaintext, producing a Sealed value with a fresh random nonce and this cipher's key_id/algo_version.
SecretCipher :: fn encrypt_str(& self, plaintext : & str) -> Result <Sealed, SecretError>Convenience: seal a UTF-8 string.
SecretCipher :: fn decrypt(& self, sealed : & Sealed) -> Result <Zeroizing <Vec <u8>>, SecretError>Decrypt a Sealed value
SecretCipher :: fn decrypt_str(& self, sealed : & Sealed) -> Result <Zeroizing <String>, SecretError>Convenience: decrypt to a UTF-8 string (zeroized on drop)

No pub use re-exports: every item above is declared in this crate.

Boundary

Depends on no other workspace tier.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/secrets
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
aes-gcm^0.10aes, alloc, getrandomnoalways
thiserror^2noalways
zeroize^1derivenoalways

Development. None.

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_operations_camera_registry["operations-camera-registry"] -->|uses| SELF
  SELF["infrastructure-secrets"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libinfrastructure_secrets`src/lib.rs`

Error model

Error typeNamed by
SecretErrordeclared, no public signature returns it

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: operations-camera-registry.

Verification

KindCount
Unit tests14
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root604

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1313
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 13
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files1
Source lines398
Code lines283
Public API items13
Public modules0
Tests14
Examples0
Cargo features0
Direct runtime dependencies3
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 3
    "enum" : 1
    "method" : 7
    "struct" : 2
pie showData
    title Rust source composition
    "Code" : 283
    "Blank or comment" : 115

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las infrastructure · Manual