From 54794806e4b6ab51ffc5879a7dd286bcb9ac2bbc Mon Sep 17 00:00:00 2001 From: yahtoo Date: Sat, 12 Oct 2019 20:29:08 +0800 Subject: [PATCH] Only allow ed25519 pubkeys when connecting (#1789) --- p2p/connection/secret_connection.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/p2p/connection/secret_connection.go b/p2p/connection/secret_connection.go index 69d175ea..788a015d 100644 --- a/p2p/connection/secret_connection.go +++ b/p2p/connection/secret_connection.go @@ -87,7 +87,12 @@ func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKeyEd25 if err != nil { return nil, err } + remPubKey, remSignature := authSigMsg.Key, authSigMsg.Sig + if _, ok := remPubKey.PubKeyInner.(crypto.PubKeyEd25519); !ok { + return nil, errors.New("peer sent a nil public key") + } + if !remPubKey.VerifyBytes(challenge[:], remSignature) { return nil, errors.New("Challenge verification failed") } -- 2.11.0