From 93644bdbf91e5c4cb23cb6d583ab8cec10fac8a0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 1 Jun 2018 18:28:55 +0200 Subject: [PATCH] Fix: Infinite loop on wrong password Signed-off-by: Knut Ahlers --- decryption.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decryption.go b/decryption.go index 8ed30ed..477a1f4 100644 --- a/decryption.go +++ b/decryption.go @@ -40,7 +40,13 @@ func decryptGPGSymmetric(body []byte, passphrase string) ([]byte, error) { return nil, fmt.Errorf("Unable to read armor: %s", err) } + var passwordRetry bool md, err := openpgp.ReadMessage(msgReader, nil, func(keys []openpgp.Key, symmetric bool) ([]byte, error) { + if passwordRetry { + return nil, fmt.Errorf("Wrong passphrase supplied") + } + + passwordRetry = true return []byte(passphrase), nil }, nil) if err != nil {