Skip to content

Commit

Permalink
Merge pull request #155 from smlx/dependabot/go_modules/golang.org/x/…
Browse files Browse the repository at this point in the history
…crypto-0.7.0

chore: bump golang.org/x/crypto from 0.0.0-20200820211705-5c72a883971a to 0.7.0
  • Loading branch information
smlx authored Mar 24, 2023
2 parents 6d663fd + 56388aa commit bd6437f
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 49 deletions.
6 changes: 3 additions & 3 deletions cmd/piv-agent/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/smlx/piv-agent/internal/pinentry"
"github.com/smlx/piv-agent/internal/securitykey"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

// SetupCmd represents the setup command.
Expand All @@ -24,7 +24,7 @@ type SetupCmd struct {
// interactiveNewPIN prompts twice for a new PIN.
func interactiveNewPIN() (uint64, error) {
fmt.Print("Enter a new PIN/PUK (6-8 digits): ")
rawPIN, err := terminal.ReadPassword(int(os.Stdin.Fd()))
rawPIN, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
if err != nil {
return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err)
Expand All @@ -34,7 +34,7 @@ func interactiveNewPIN() (uint64, error) {
return 0, fmt.Errorf("invalid characters: %w", err)
}
fmt.Print("Repeat PIN/PUK: ")
repeat, err := terminal.ReadPassword(int(os.Stdin.Fd()))
repeat, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
if err != nil {
return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/piv-agent/setupslots.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/smlx/piv-agent/internal/pinentry"
"github.com/smlx/piv-agent/internal/securitykey"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

// SetupSlotsCmd represents the setup command.
Expand All @@ -23,7 +23,7 @@ type SetupSlotsCmd struct {
// interactivePIN prompts once for an existing PIN.
func interactivePIN() (uint64, error) {
fmt.Print("Enter the PIN/PUK (6-8 digits): ")
rawPIN, err := terminal.ReadPassword(int(os.Stdin.Fd()))
rawPIN, err := term.ReadPassword(int(os.Stdin.Fd()))
fmt.Println()
if err != nil {
return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err)
Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/smlx/piv-agent
go 1.19

require (
github.com/ProtonMail/go-crypto v0.0.0-20230316153859-cb82d937a5d9
github.com/alecthomas/kong v0.7.1
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/davecgh/go-spew v1.1.1
Expand All @@ -13,11 +14,13 @@ require (
github.com/twpayne/go-pinentry-minimal v0.0.0-20220113210447-2a5dc4396c2a
github.com/x13a/go-launch v0.0.0-20210715084817-fd409384939b
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/crypto v0.7.0
golang.org/x/sync v0.1.0
golang.org/x/term v0.6.0
)

require (
github.com/cloudflare/circl v1.1.0 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.0.3 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
Expand All @@ -27,5 +30,7 @@ require (
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
)

replace github.com/ProtonMail/go-crypto => github.com/smlx/go-crypto v0.0.0-20230324130354-fc893cd601c2
36 changes: 32 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ github.com/alecthomas/kong v0.7.1 h1:azoTh0IOfwlAX3qN9sHWTxACE2oV8Bg2gAwBsMwDQY4
github.com/alecthomas/kong v0.7.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
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/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -32,6 +35,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/smlx/fsm v0.2.1 h1:JKGqQa7Fmmn9UEK1JDh0BTEoeRfsvKdxlrkY3sBonc8=
github.com/smlx/fsm v0.2.1/go.mod h1:LiXoNZ+m3neHxSVsc8KN7ed0mbiY6K/1MKj+HcZzhkQ=
github.com/smlx/go-crypto v0.0.0-20230324130354-fc893cd601c2 h1:n4enF1jCKh/Rokt4i8gTL0alf6k0vf4BxQSYtokPKPU=
github.com/smlx/go-crypto v0.0.0-20230324130354-fc893cd601c2/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
Expand All @@ -42,6 +47,7 @@ github.com/twpayne/go-pinentry-minimal v0.0.0-20220113210447-2a5dc4396c2a/go.mod
github.com/x13a/go-launch v0.0.0-20210715084817-fd409384939b h1:rpNT9cyxH8nsCM8htO1SLhrehyt74GFczE9s/O6WkfE=
github.com/x13a/go-launch v0.0.0-20210715084817-fd409384939b/go.mod h1:kfVYr1hMcmOVxZt+2kFzCXf/YRX9Cz+F1QkijZQMaMM=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
Expand All @@ -51,14 +57,22 @@ go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
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=
Expand All @@ -67,14 +81,28 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 2 additions & 2 deletions internal/assuan/assuan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"strconv"
"strings"

"github.com/ProtonMail/go-crypto/openpgp"
"github.com/smlx/fsm"
"github.com/smlx/piv-agent/internal/notify"
"go.uber.org/zap"
"golang.org/x/crypto/openpgp/s2k"
)

// version indicates the version of gpg-agent to emulate.
Expand Down Expand Up @@ -162,7 +162,7 @@ func New(rw io.ReadWriter, log *zap.Logger, n *notify.Notify,
return fmt.Errorf("couldn't parse uint %s: %v", assuan.data[0], err)
}
var ok bool
if assuan.hashAlgo, ok = s2k.HashIdToHash(byte(n)); !ok {
if assuan.hashAlgo, ok = openpgp.HashIdToHash(uint8(n)); !ok {
return fmt.Errorf("invalid hash algorithm value: %x", n)
}
hash, err = hexDecode(assuan.data[1:]...)
Expand Down
23 changes: 10 additions & 13 deletions internal/assuan/assuan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"crypto"
"crypto/ecdsa"
"encoding/hex"
"fmt"
"io"
Expand All @@ -13,6 +12,10 @@ import (
"testing"
"time"

"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
"github.com/ProtonMail/go-crypto/openpgp/ecdsa"
"github.com/ProtonMail/go-crypto/openpgp/packet"
"github.com/davecgh/go-spew/spew"
"github.com/golang/mock/gomock"
"github.com/smlx/piv-agent/internal/assuan"
Expand All @@ -23,14 +26,11 @@ import (
"go.uber.org/zap"
"golang.org/x/crypto/cryptobyte"
"golang.org/x/crypto/cryptobyte/asn1"
"golang.org/x/crypto/openpgp"
"golang.org/x/crypto/openpgp/armor"
"golang.org/x/crypto/openpgp/packet"
)

// MockCryptoSigner is a mock type which implements crypto.Signer
type MockCryptoSigner struct {
PubKey crypto.PublicKey
PubKey *ecdsa.PublicKey
Signature []byte
}

Expand Down Expand Up @@ -536,18 +536,15 @@ func TestReadKey(t *testing.T) {
}
// check the responses
for _, expected := range tc.expect {
//spew.Dump(mockConn.WriteBuf.String())
line, err := mockConn.WriteBuf.ReadString(byte('\n'))
if line != expected {
tt.Log("got", spew.Sdump(line))
tt.Log("expected", spew.Sdump(expected))
tt.Fail()
}
if err != nil && err != io.EOF {
tt.Fatal(err)
}
if line != expected {
fmt.Println("got")
spew.Dump(line)
fmt.Println("expected")
spew.Dump(expected)
tt.Fatalf("error")
}
}
})
}
Expand Down
12 changes: 9 additions & 3 deletions internal/keyservice/gpg/havekey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"crypto/ecdsa"
"crypto/rsa"
"fmt"

openpgpecdsa "github.com/ProtonMail/go-crypto/openpgp/ecdsa"
)

// Keygrips returns a slice of keygrip byteslices; one for each cryptographic
Expand All @@ -15,13 +17,17 @@ func (g *KeyService) Keygrips() ([][]byte, error) {
var err error
for _, keyfile := range g.privKeys {
for _, privKey := range keyfile.keys {
switch pubKey := privKey.PublicKey.PublicKey.(type) {
switch openpgpPubKey := privKey.PublicKey.PublicKey.(type) {
case *rsa.PublicKey:
kg, err = keygripRSA(pubKey)
kg, err = keygripRSA(openpgpPubKey)
if err != nil {
return nil, fmt.Errorf("couldn't get keygrip: %w", err)
}
case *ecdsa.PublicKey:
case *openpgpecdsa.PublicKey:
pubKey, err := ecdsaPublicKey(openpgpPubKey)
if err != nil {
return nil, fmt.Errorf("couldn't convert ecdsa public key: %v", err)
}
kg, err = KeygripECDSA(pubKey)
if err != nil {
return nil, fmt.Errorf("couldn't get keygrip: %w", err)
Expand Down
4 changes: 4 additions & 0 deletions internal/keyservice/gpg/helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package gpg

// export functions for test suite
var ECDSAPublicKey = ecdsaPublicKey
4 changes: 2 additions & 2 deletions internal/keyservice/gpg/keyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"path"

"golang.org/x/crypto/openpgp/errors"
"golang.org/x/crypto/openpgp/packet"
"github.com/ProtonMail/go-crypto/openpgp/errors"
"github.com/ProtonMail/go-crypto/openpgp/packet"
)

// keyfilePrivateKeys reads the given path and returns any private keys found.
Expand Down
17 changes: 11 additions & 6 deletions internal/keyservice/gpg/keygrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"strings"
"testing"

"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/armor"
openpgpecdsa "github.com/ProtonMail/go-crypto/openpgp/ecdsa"
"github.com/ProtonMail/go-crypto/openpgp/packet"
"github.com/smlx/piv-agent/internal/keyservice/gpg"
"golang.org/x/crypto/openpgp"
"golang.org/x/crypto/openpgp/armor"
"golang.org/x/crypto/openpgp/packet"
)

func TestTrezorCompat(t *testing.T) {
Expand Down Expand Up @@ -82,15 +83,19 @@ func TestKeyGrip(t *testing.T) {
if !ok {
tt.Fatal("not an openpgp public key")
}
eccKey, ok := key.PublicKey.(*ecdsa.PublicKey)
eccKey, ok := key.PublicKey.(*openpgpecdsa.PublicKey)
if !ok {
tt.Fatal("not an ecdsa public key")
}
if eccKey.Curve != elliptic.P256() {
pubKey, err := gpg.ECDSAPublicKey(eccKey)
if err != nil {
tt.Fatal(err)
}
if pubKey.Curve != elliptic.P256() {
tt.Fatal("wrong curve")
}

keygrip, err := gpg.KeygripECDSA(eccKey)
keygrip, err := gpg.KeygripECDSA(pubKey)
if err != nil {
tt.Fatal(err)
}
Expand Down
Loading

0 comments on commit bd6437f

Please sign in to comment.