jwe encrypt: add --password-file flag for PBES2#1657
Open
tashian wants to merge 1 commit into
Open
Conversation
step crypto jwe decrypt already accepts --password-file, but the matching encrypt command did not, so encrypting with a PBES2 (password-based) algorithm could only read the password interactively from the TTY. This made automation impossible. Mirror decrypt: add the --password-file flag and seed the password prompt from the file via ui.WithValue when it is set, falling back to the interactive prompt otherwise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
step crypto jwe decryptaccepts--password-file, butstep crypto jwe encryptdoes not. Both commands support the PBES2 password-based key algorithms (PBES2-HS256+A128KW,PBES2-HS384+A192KW,PBES2-HS512+A256KW), where the password is the key material. Because encrypt could only read the password interactively from the TTY, encrypting with a shared password was impossible to automate — even though decrypting already was.Fix
Mirror the existing decrypt implementation:
--password-fileflag tojwe encrypt.utils.ReadStringPasswordFromFileand seed the prompt withui.WithValue(...). When the flag is omitted, behavior is unchanged (interactive prompt).UsageText.This parallels
command/crypto/jwe/decrypt.goexactly. No tests were added because thejwecommand package has no existing unit or integration tests to parallel.Testing
Manual round-trip, fully non-interactive:
go build ./...andgo vet ./command/crypto/jwe/pass.🤖 Generated with Claude Code