aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/rlpx.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2018-06-12 21:26:08 +0800
committerGuillaume Ballet <gballet@gmail.com>2018-06-12 21:26:08 +0800
commit0255951587ef0eada5d162f3404bc481f70a2ce2 (patch)
tree6aa0c1c9405df6a88f4cbeb72e170e6e19cf55d5 /p2p/rlpx.go
parent85cd64df0e3331e46f41ec86a647f1b8ff306eda (diff)
downloadgo-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.gz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.bz2
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.lz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.xz
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.tar.zst
go-tangerine-0255951587ef0eada5d162f3404bc481f70a2ce2.zip
crypto: replace ToECDSAPub with error-checking func UnmarshalPubkey (#16932)
ToECDSAPub was unsafe because it returned a non-nil key with nil X, Y in case of invalid input. This change replaces ToECDSAPub with UnmarshalPubkey across the codebase.
Diffstat (limited to 'p2p/rlpx.go')
-rw-r--r--p2p/rlpx.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/p2p/rlpx.go b/p2p/rlpx.go
index a320e81e7..149eda689 100644
--- a/p2p/rlpx.go
+++ b/p2p/rlpx.go
@@ -528,9 +528,9 @@ func importPublicKey(pubKey []byte) (*ecies.PublicKey, error) {
return nil, fmt.Errorf("invalid public key length %v (expect 64/65)", len(pubKey))
}
// TODO: fewer pointless conversions
- pub := crypto.ToECDSAPub(pubKey65)
- if pub.X == nil {
- return nil, fmt.Errorf("invalid public key")
+ pub, err := crypto.UnmarshalPubkey(pubKey65)
+ if err != nil {
+ return nil, err
}
return ecies.ImportECDSAPublic(pub), nil
}