WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 50aab60

Browse files
committed
use ecdsa.ParseUncompressedPublicKey
1 parent 99c4c65 commit 50aab60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

keys/pem.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ func UnmarshalTrustedKey(b []byte) (TrustedKey, []byte, error) {
170170
if len(k.Bytes) != 65 {
171171
return nil, r, fmt.Errorf("key was not 65 bytes, is invalid P256 public key")
172172
}
173-
174-
x, y := elliptic.Unmarshal(elliptic.P256(), k.Bytes)
175-
return P256TrustedKey{&ecdsa.PublicKey{X: x, Y: y, Curve: elliptic.P256()}}, r, nil
173+
pk, err := ecdsa.ParseUncompressedPublicKey(elliptic.P256(), k.Bytes)
174+
if err != nil {
175+
return nil, r, fmt.Errorf("failed to parse public key: %s", err)
176+
}
177+
return P256TrustedKey{pk}, r, nil
176178
case NebulaEd25519PublicKeyBanner, NebulaX25519PublicKeyBanner:
177179
if len(k.Bytes) != ed25519.PublicKeySize {
178180
return nil, r, fmt.Errorf("key was not 32 bytes, is invalid ed25519 public key")

0 commit comments

Comments
 (0)