From 03adcef1cc5fb0517ebeb488bef5165aedac1f81 Mon Sep 17 00:00:00 2001 From: Gerson Alexander Pardo Gamez Date: Thu, 21 Sep 2023 19:14:05 -0500 Subject: [PATCH] fix: rollback to stable go-crypto --- go.mod | 4 ++-- go.sum | 12 ++++++------ openpgp/generate.go | 23 +---------------------- openpgp/generate_test.go | 11 +++++++++++ 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index b623aa6..f1bc621 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/jerson/openpgp-mobile go 1.13 require ( - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 + github.com/ProtonMail/go-crypto v0.0.0-20230321124908-8712db92986c github.com/google/flatbuffers v2.0.6+incompatible golang.org/x/crypto v0.12.0 ) -replace github.com/ProtonMail/go-crypto => github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 +replace github.com/ProtonMail/go-crypto => github.com/ProtonMail/go-crypto v0.0.0-20230321124908-8712db92986c replace golang.org/x/crypto => golang.org/x/crypto v0.12.0 diff --git a/go.sum b/go.sum index e067609..1d6c5ea 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -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/ProtonMail/go-crypto v0.0.0-20230321124908-8712db92986c h1:a5rR49GFmrW/Op8K68/3gB7EjHb1BD4kBAfQAiEh/Hk= +github.com/ProtonMail/go-crypto v0.0.0-20230321124908-8712db92986c/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= +github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY= +github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/google/flatbuffers v2.0.6+incompatible h1:XHFReMv7nFFusa+CEokzWbzaYocKXI6C7hdU5Kgh9Lw= github.com/google/flatbuffers v2.0.6+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -19,9 +19,9 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= diff --git a/openpgp/generate.go b/openpgp/generate.go index 8d31eff..40eeb80 100644 --- a/openpgp/generate.go +++ b/openpgp/generate.go @@ -3,10 +3,10 @@ package openpgp import ( "bytes" "fmt" + "github.com/ProtonMail/go-crypto/openpgp" "github.com/ProtonMail/go-crypto/openpgp/armor" "github.com/ProtonMail/go-crypto/openpgp/packet" - "io" ) func (o *FastOpenPGP) Generate(options *Options) (*KeyPair, error) { @@ -87,24 +87,3 @@ func (o *FastOpenPGP) serializePublicKey(entity *openpgp.Entity) (string, error) w.Close() return buf.String(), nil } - -type serializable interface { - Serialize(w io.Writer) (err error) -} - -func serialize(entity serializable) string { - buf := bytes.NewBuffer(nil) - w, err := armor.Encode(buf, openpgp.PublicKeyType, headers) - if err != nil { - return "" - } - defer w.Close() - - err = entity.Serialize(w) - if err != nil { - return "" - } - // this is required to allow close block before String - w.Close() - return buf.String() -} diff --git a/openpgp/generate_test.go b/openpgp/generate_test.go index b8fa42e..c8621a1 100644 --- a/openpgp/generate_test.go +++ b/openpgp/generate_test.go @@ -144,6 +144,17 @@ func TestFastOpenPGP_GenerateWithPassphrase(t *testing.T) { if err != nil { t.Fatal(err) } + t.Log("output:", output) +} + +func TestFastOpenPGP_GenerateEmpty(t *testing.T) { + + options := &Options{KeyOptions: &KeyOptions{}} + openPGP := NewFastOpenPGP() + output, err := openPGP.Generate(options) + if err != nil { + t.Fatal(err) + } t.Log("output:", output) }