Skip to content

Conversation

@ericchiang
Copy link
Contributor

cc @tschuy

Can you see if this still works? If it does I'll switch the encryption too.

func Decrypt(encoded []byte) ([]byte, error) {
if hasGPG() {
var stderr, stdout bytes.Buffer
cmd := exec.Command("gpg", "--decrypt")
Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer to use gpg --quiet --decrypt --batch and then catch on stderr. Here's what it looks like with a password-based key:

tschuy/projects/gotp → gpg --batch --quiet --decrypt < temp 
gpg: gpg-agent is not available in this session
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
gpg: decryption failed: secret key not available

Copy link
Owner

Choose a reason for hiding this comment

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

my main thing here is that if you're using password based encryption with a local key and the key is in gpg-agent, without batch you get a bunch of error text:

tschuy/projects/gotp → gpg --quiet --decrypt < temp 

You need a passphrase to unlock the secret key for
user: "Evan Tschuy <evan.tschuy@coreos.com>"
4096-bit RSA key, ID 0x0C590A882B35D2A4, created 2017-01-25
         (subkey on main key ID 0xCE8111086BAD4E55)

[decrypted message here]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants