Skip to content
PlatformMarkdown

Encryption of stored data

What the realm seals under its own storage key, what it keeps only as a one-way hash, and how to seal a field of your own.

AvailableAPIRFC 8439

The realm seals its most sensitive stored data under a key of its own, the storage key, so a copy of the database alone gives none of it away. Passwords and client secrets are never stored at all, only one-way hashes of them. And any field you add to an object type can be sealed the same way.

The storage key is the realm’s own, kept beside its signing keys, and no API returns it.

  • Nothing to do for the data the realm seals itself: every realm seals it from birth.
  • To seal a field of your own: MODIFY on that object type, which RealmOwner gives, through the API at https://foobar.cvyuh.com/api/v0/am/types/v1/<type>. Your session is in $CVYUH_SESSION (Call the API).

The realm seals with ChaCha20-Poly1305 under its storage key, store/encryption. Each sealed value records the key version that sealed it and is bound to its realm and field, so it can’t be moved to another realm or field and still open.

DataHow it is kept
A sign-in in progress, and its deadlineSealed
Tokens a session holds for other servicesSealed, bound to the session and its holder
The private half of the realm’s signing keysSealed
A signal stream’s authorizationHeader, a device’s seed, a directory’s bindPasswordSealed
Sign-in codes, refresh tokens and challenges that travel through the browserSealed, and not stored at all
A sessionStored under a hash of its id, never the id itself
A user’s password, a client’s secret, a registration token’s secretOne-way hash only (bcrypt or PBKDF2)

A value that can’t be sealed is refused, never stored in the clear.

To seal a field of your own, mark it in its object type with x-encrypt, naming the realm key that seals it, and make it private:

"apiKey": {
"type": "string",
"scope": "private",
"x-encrypt": { "key": "store/encryption" }
}

For a value you only ever need to check, never read back, use "x-hash": { "algorithm": "bcrypt" } instead. Send the changed type with PUT https://foobar.cvyuh.com/api/v0/am/types/v1/<type>. From then on, every write seals or hashes the field; values written before stay as they were until they’re written again.

A type change is refused with 400, naming the field, when:

The fieldWhat to do
Isn’t a stringSeal or hash only text fields
Is x-encrypt without "scope": "private"Make it private: a sealed value is never returned
Names a key that isn’t one of the realm’s, or no keyName store/encryption
Is marked both x-encrypt and x-hashChoose one

What users see: nothing. A sealed field never appears in a read; a hashed one is checked, never shown.

WhatDefaultCan it change
CipherChaCha20-Poly1305No
One-way hashesbcrypt or PBKDF2Choose per field with x-hash
Fields that can be sealed or hashedText fields onlyNo
Storage key versionsKept while anything sealed under them may existNo
  • A field you sealed comes back empty in reads. It’s private, so no read returns it. That’s the point: read the value only where your app needs it, through the feature that uses it.
  • Older values aren’t sealed. Sealing applies from the type change on. Write each value again to seal it.

A change to an object type is recorded on the audit trail as an UPDATED record for the type, naming who made it; no API returns type changes yet. Sealed and hashed fields never reach the audit trail: a record of a change to an object leaves them out.

  • The storage key rotates by version. A new version seals from then on; older versions are kept to open what they sealed. GET https://foobar.cvyuh.com/api/v0/am/keys/v1 lists its versions, the newest valid and the rest retained.
  • It is never destroyed while anything sealed under it may exist. A realm’s storage key goes only when the realm itself is purged.
  • Secrets in a vault are sealed separately, under keys per owner: see Sealing per owner.
  • You can’t hold the key that wraps your realm’s stored data in a key store of your own; see Not offered.