replace golang.org/x/crypto/openpgp with github.com/ProtonMail/go-crypto/openpgp

This commit is contained in:
Paul Cacheux
2023-10-31 11:21:40 +01:00
committed by Benj Fassbind
parent f1649a647b
commit cfcab13c2a
4 changed files with 49 additions and 21 deletions

View File

@@ -13,12 +13,10 @@ import (
"github.com/pkg/errors"
// TODO: replace crypto/openpgp since it is deprecated
// https://github.com/golang/go/issues/44226
"golang.org/x/crypto/openpgp" //nolint:staticcheck
"golang.org/x/crypto/openpgp/clearsign" //nolint:staticcheck
openpgp_errors "golang.org/x/crypto/openpgp/errors" //nolint:staticcheck
"golang.org/x/crypto/openpgp/packet" //nolint:staticcheck
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/clearsign"
openpgp_errors "github.com/ProtonMail/go-crypto/openpgp/errors"
"github.com/ProtonMail/go-crypto/openpgp/packet"
"golang.org/x/term"
)

View File

@@ -11,12 +11,10 @@ import (
"strconv"
"time"
// TODO: replace crypto/openpgp since it is deprecated
// https://github.com/golang/go/issues/44226
"golang.org/x/crypto/openpgp" //nolint:staticcheck
"golang.org/x/crypto/openpgp/armor" //nolint:staticcheck
"golang.org/x/crypto/openpgp/errors" //nolint:staticcheck
"golang.org/x/crypto/openpgp/packet" //nolint:staticcheck
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
"github.com/ProtonMail/go-crypto/openpgp/errors"
"github.com/ProtonMail/go-crypto/openpgp/packet"
)
// hashForSignature returns a pair of hashes that can be used to verify a
@@ -94,12 +92,6 @@ func checkDetachedSignature(keyring openpgp.KeyRing, signed, signature io.Reader
sigType = sig.SigType
creationTime = sig.CreationTime
pubKeyAlgo = sig.PubKeyAlgo
case *packet.SignatureV3:
issuerKeyID = sig.IssuerKeyId
hashFunc = sig.Hash
sigType = sig.SigType
creationTime = sig.CreationTime
pubKeyAlgo = sig.PubKeyAlgo
default:
return nil, 0, errors.StructuralError("non signature packet found")
}
@@ -129,8 +121,6 @@ func checkDetachedSignature(keyring openpgp.KeyRing, signed, signature io.Reader
switch sig := p.(type) {
case *packet.Signature:
err = key.PublicKey.VerifySignature(h, sig)
case *packet.SignatureV3:
err = key.PublicKey.VerifySignatureV3(h, sig)
default:
panic("unreachable")
}