Skip to content

atc: add base64 and hex encryption key flags - #9542

Merged
taylorsilva merged 2 commits into
concourse:masterfrom
samuelBarreto:feature/1410-add-base64-hex-encryption-flags
Apr 21, 2026
Merged

taylorsilva merged 2 commits into
concourse:masterfrom
samuelBarreto:feature/1410-add-base64-hex-encryption-flags

Conversation

@samuelBarreto

@samuelBarreto samuelBarreto commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor

Changes proposed by this PR

closes #1410

  • Added --encryption-key-base64 and --encryption-key-hex flags to RunCommand struct
  • Added --old-encryption-key-base64 and --old-encryption-key-hex flags to RunCommand struct
  • Added the same flags to Migration struct
  • Updated RunCommand.newKey() and RunCommand.oldKey() to resolve keys from all three formats (raw → base64 → hex)
  • Added Migration.resolveNewKey() and Migration.resolveOldKey() helper functions
  • Updated atc/scripts/db_decrypt.go to support the new key formats

Reasoning: The existing --encryption-key flag interprets the key as raw bytes ([]byte(val)), limiting entropy to ~95 printable ASCII characters per byte. A nominally 256-bit key only provides ~208 bits of entropy. The new flags allow users to supply keys encoded in base64 or hex, enabling the full byte range (0x00-0xFF) and full 256-bit entropy.

The CipherBase64 and CipherHex types used by these flags were already merged into flag/cipher.go via #9541.

Notes to reviewer

  • Backward compatible: the existing --encryption-key and --old-encryption-key flags are unchanged
  • Key resolution priority: raw → base64 → hex (first non-nil wins)
  • Only one format should be provided at a time; if multiple are set, the priority order above applies an error is returned
  • Validated locally via docker compose up --build — new flags appear in concourse web --help

Release Note

Added --encryption-key-base64, --encryption-key-hex, --old-encryption-key-base64, and --old-encryption-key-hex flags, allowing encryption keys to be provided in base64 or hex encoding for full 256-bit entropy support.

Add --encryption-key-base64, --encryption-key-hex and their --old-
variants to the CLI, allowing users to supply encryption keys with
full byte range (0x00-0xFF) instead of being limited to printable
ASCII characters.

Closes concourse#1410

Signed-off-by: samuel.andrade <[email protected]>
consolidated duplicate logic into one function in the db/encryption
package. Also made sure we error if multiple keys are passed in.

Signed-off-by: Taylor Silva <[email protected]>

@taylorsilva taylorsilva left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I pushed a commit that refactors some of the code from command.go into encryption_key.go. I also made one behavioural change: if multiple key formats are provided an error is returned instead of just picking the first one. We don't want to assume things and potentially confuse operators about which key the db was encrypted with.

Thanks for working on this! Once the PR checks pass again I'll merge it.

@taylorsilva

Copy link
Copy Markdown
Member

TODO: will need to add these env vars to the helm chart and bosh packaging

@taylorsilva
taylorsilva merged commit f5ab675 into concourse:master Apr 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--encryption-key and --old-encryption-key flags are interpreted as RAW bytes, limiting available entropy

2 participants