protonmail: make SRP modulus signature failures fatal

In 93c8007, SRP signature errors were made non-fatal because many
users got the following error:

    openpgp: unsupported feature: public key algorithm 22

This is because Protonmail started signing these messages with an
EDDSA key, an algorithm which the Go OpenPGP library does not
support. The switch to github.com/protonmail/crypto introduces this
algorithm, so messages that haven't been tampered with should pass
the verification.
This commit is contained in:
Daniel Bertalan 2020-06-30 17:21:19 +02:00 committed by Simon Ser
parent 06f6d5b8e9
commit fe6f0a620f
1 changed files with 2 additions and 5 deletions

View File

@ -8,12 +8,10 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"log"
"math/big" "math/big"
"golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp"
"golang.org/x/crypto/openpgp/clearsign" "golang.org/x/crypto/openpgp/clearsign"
openpgperrors "golang.org/x/crypto/openpgp/errors"
) )
var randReader io.Reader = rand.Reader var randReader io.Reader = rand.Reader
@ -45,9 +43,8 @@ func decodeModulus(msg string) ([]byte, error) {
} }
_, err = openpgp.CheckDetachedSignature(modulusKeyring, bytes.NewReader(block.Bytes), block.ArmoredSignature.Body, nil) _, err = openpgp.CheckDetachedSignature(modulusKeyring, bytes.NewReader(block.Bytes), block.ArmoredSignature.Body, nil)
if err != nil && err != openpgperrors.ErrUnknownIssuer { if err != nil {
//return nil, fmt.Errorf("failed to decode modulus: %v", err) return nil, fmt.Errorf("failed to check modulus signature: %v", err)
log.Println("warning: failed to check SRP modulus signature:", err)
} }
b, err := base64.StdEncoding.DecodeString(string(block.Plaintext)) b, err := base64.StdEncoding.DecodeString(string(block.Plaintext))