feat(encryption): client-side encryption works, from the plan to the restore #55

Merged
james.maes merged 1 commits from feature/client-side-encryption into develop 2026-11-24 10:41:03 +00:00
1 Commits
Author SHA1 Message Date
James MaesandClaude Fable 5.2 478bd4363b feat(encryption): client-side encryption works, from the plan to the restore
maven / build (push) Successful in 2m2s
build / maven (push) Successful in 2m2s
A plan could ask for CLIENT_AES256_GCM and was refused: the transform
plumbing was there, but nothing installed a cipher and nothing handed one
to a run.

- BackupsQBitConfig.withKeyProvider installs the streaming cipher of the
  QQQ crypto package (StreamingCipherTransform: Tink streaming AEAD, a
  fresh data key per object, wrapped by the referenced key)
- a run of a plan that asks for encryption gets the cipher for the plan's
  key reference; with no key for it the run is refused and nothing is
  written in the clear
- a plan is not saved when the provider has no key for its reference
- verification and restore read through the same provider; a rotated key
  still reads what its older version wrote
- a run records the key reference and a fingerprint (v<version>:<16 hex
  of a labelled hash), never the key

Fixed on the way: the file index of an encrypted run was written in the
clear while the catalog recorded it as encrypted, and a restore from an
encrypted run could not read it. It is encrypted like every other object
of the run. No release could encrypt before this, so no stored run is
affected.

Tests: StreamingCipherTransformTest (6: round trip, tampering and
truncation refused, another key refused, no key gives no transform,
rotation, the fingerprint is not the key); an encrypted run from the plan
(objects are ciphertext, verified by content and by test restore, rotated,
refused without the key with nothing written); a restore from an encrypted
backup, rows and a file, and its refusal without the key; plan validation
with a key provider. ./mvnw verify: 225 tests, guardrails and coverage
pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 04:38:25 -06:00