Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
37efd08b
Commit
37efd08b
authored
Jul 14, 2015
by
Ethan Buchman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: validate recovered ephemeral pubkey against checksum in decodeAuthMsg
parent
796c18db
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
rlpx.go
p2p/rlpx.go
+12
-4
No files found.
p2p/rlpx.go
View file @
37efd08b
...
...
@@ -267,6 +267,10 @@ func initiatorEncHandshake(conn io.ReadWriter, prv *ecdsa.PrivateKey, remoteID d
}
func
newInitiatorHandshake
(
remoteID
discover
.
NodeID
)
(
*
encHandshake
,
error
)
{
rpub
,
err
:=
remoteID
.
Pubkey
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"bad remoteID: %v"
,
err
)
}
// generate random initiator nonce
n
:=
make
([]
byte
,
shaLen
)
if
_
,
err
:=
rand
.
Read
(
n
);
err
!=
nil
{
...
...
@@ -277,10 +281,6 @@ func newInitiatorHandshake(remoteID discover.NodeID) (*encHandshake, error) {
if
err
!=
nil
{
return
nil
,
err
}
rpub
,
err
:=
remoteID
.
Pubkey
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"bad remoteID: %v"
,
err
)
}
h
:=
&
encHandshake
{
initiator
:
true
,
remoteID
:
remoteID
,
...
...
@@ -417,6 +417,14 @@ func decodeAuthMsg(prv *ecdsa.PrivateKey, token []byte, auth []byte) (*encHandsh
if
err
!=
nil
{
return
nil
,
err
}
// validate the sha3 of recovered pubkey
remoteRandomPubMAC
:=
msg
[
sigLen
:
sigLen
+
shaLen
]
shaRemoteRandomPub
:=
crypto
.
Sha3
(
remoteRandomPub
[
1
:
])
if
!
bytes
.
Equal
(
remoteRandomPubMAC
,
shaRemoteRandomPub
)
{
return
nil
,
fmt
.
Errorf
(
"sha3 of recovered ephemeral pubkey does not match checksum in auth message"
)
}
h
.
remoteRandomPub
,
_
=
importPublicKey
(
remoteRandomPub
)
return
h
,
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment