From 32ed5337ad8b51a9dec015d58655254af2602d94 Mon Sep 17 00:00:00 2001 From: marin thiercelin Date: Mon, 20 Dec 2021 12:43:36 +0100 Subject: [PATCH] Remove unused getCreationMethod() --- crypto/signature.go | 14 -------------- crypto/signature_test.go | 20 -------------------- 2 files changed, 34 deletions(-) diff --git a/crypto/signature.go b/crypto/signature.go index 4048e512..67c1d7c2 100644 --- a/crypto/signature.go +++ b/crypto/signature.go @@ -15,7 +15,6 @@ import ( "github.com/ProtonMail/gopenpgp/v2/constants" "github.com/ProtonMail/gopenpgp/v2/internal" - goerrors "github.com/pkg/errors" ) var allowedHashes = []crypto.Hash{ @@ -160,16 +159,3 @@ func verifySignature(pubKeyEntries openpgp.EntityList, origText io.Reader, signa return nil } - -func (sig *PGPSignature) getCreationTime() (int64, error) { - packets := packet.NewReader(bytes.NewReader(sig.Data)) - p, err := packets.Next() - if err != nil { - return 0, goerrors.Wrap(err, "gopenpgp: Can't parse signature") - } - sigPacket, ok := p.(*packet.Signature) - if !ok { - return 0, errors.New("gopenpgp: non signature packet found") - } - return sigPacket.CreationTime.Unix(), nil -} diff --git a/crypto/signature_test.go b/crypto/signature_test.go index 60b1ec39..dea28994 100644 --- a/crypto/signature_test.go +++ b/crypto/signature_test.go @@ -74,26 +74,6 @@ func TestVerifyBinDetachedSig(t *testing.T) { } } -func Test_Signature_getSignatureCreationTime(t *testing.T) { - message := NewPlainMessageFromString("Hello world!") - var time int64 = 1600000000 - pgp.latestServerTime = time - defer func() { - pgp.latestServerTime = testTime - }() - signature, err := keyRingTestPrivate.SignDetached(message) - if err != nil { - t.Errorf("Got an error while generating the signature: %v", err) - } - actualTime, err := signature.getCreationTime() - if err != nil { - t.Errorf("Got an error while parsing the signature creation time: %v", err) - } - if time != actualTime { - t.Errorf("Expected creation time to be %d, got %d", time, actualTime) - } -} - func Test_KeyRing_GetVerifiedSignatureTimestampSuccess(t *testing.T) { message := NewPlainMessageFromString("Hello world!") var time int64 = 1600000000