Skip to content

Commit

Permalink
fix: rollback to stable go-crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson committed Sep 22, 2023
1 parent 2572819 commit 03adcef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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=
Expand Down
23 changes: 1 addition & 22 deletions openpgp/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
}
11 changes: 11 additions & 0 deletions openpgp/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 03adcef

Please sign in to comment.