Skip to content

Commit

Permalink
chore: Resolve rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Dec 7, 2023
1 parent 57f73cf commit 0d044f3
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 186 deletions.
52 changes: 0 additions & 52 deletions crypto/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import (
"io/ioutil"
"regexp"
"testing"
"time"

"github.com/ProtonMail/go-crypto/openpgp/packet"
"github.com/ProtonMail/gopenpgp/v3/armor"
"github.com/ProtonMail/gopenpgp/v3/constants"
"github.com/ProtonMail/gopenpgp/v3/internal"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"

"github.com/ProtonMail/gopenpgp/v2/constants"
)

const signedPlainText = "Signed message\n"
Expand Down Expand Up @@ -673,52 +670,3 @@ func Test_VerifyWithDoubleContext(t *testing.T) {
// then
checkVerificationError(t, result.SignatureError(), constants.SIGNATURE_BAD_CONTEXT)
}

func Test_verifySignaturExpire(t *testing.T) {
defer func(t int64) { pgp.latestServerTime = t }(pgp.latestServerTime)
pgp.latestServerTime = 0

const lifetime = uint32(time.Hour / time.Second)

cfg := &packet.Config{
Algorithm: packet.PubKeyAlgoEdDSA,
DefaultHash: crypto.SHA256,
DefaultCipher: packet.CipherAES256,
DefaultCompressionAlgo: packet.CompressionZLIB,
KeyLifetimeSecs: lifetime,
SigLifetimeSecs: lifetime,
}

entity, err := openpgp.NewEntity("John Smith", "Linux", "[email protected]", cfg)
if err != nil {
t.Fatal(err)
}

key, err := NewKeyFromEntity(entity)
if err != nil {
t.Fatal(err)
}

keyRing, err := NewKeyRing(key)
if err != nil {
t.Fatal(err)
}

data := []byte("Hello, World!")
message := NewPlainMessage(data)

signature, err := keyRing.SignDetached(message)
if err != nil {
t.Fatalf("%#+v", err)
}

sig := NewPGPSignature(signature.GetBinary())

// packet.PublicKey.KeyExpired will return false here because PublicKey CreationTime has
// nanosecond precision, while pgpcrypto.GetUnixTime() has only second precision.
// Adjust the check time to be in the future to ensure that the key is not expired.
err = keyRing.VerifyDetached(message, sig, GetUnixTime()+1)
if err != nil {
t.Fatal(err)
}
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.15
require (
github.com/ProtonMail/go-crypto v0.0.0-20231130142838-f5a3bd6c529f
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
Expand Down
5 changes: 1 addition & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
github.com/ProtonMail/go-crypto v0.0.0-20231122163255-f0a31d287aac h1:DUark25n/K1Pc7HYg2b+u66uZbxOCcbSU2rEx8epRZw=
github.com/ProtonMail/go-crypto v0.0.0-20231122163255-f0a31d287aac/go.mod h1:K4vciqCJaZ1Ghw/SvtJbEAM4soEtwDCNVqkdQIIujwU=
github.com/ProtonMail/go-crypto v0.0.0-20231130142838-f5a3bd6c529f h1:xCljVH5H3DndCB6GwnIXMKbxI56SD1WkQQwwqSWP4V0=
github.com/ProtonMail/go-crypto v0.0.0-20231130142838-f5a3bd6c529f/go.mod h1:K4vciqCJaZ1Ghw/SvtJbEAM4soEtwDCNVqkdQIIujwU=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down
86 changes: 0 additions & 86 deletions helper/decrypt_check.go

This file was deleted.

43 changes: 0 additions & 43 deletions helper/decrypt_check_test.go

This file was deleted.

0 comments on commit 0d044f3

Please sign in to comment.