Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-routing
Commits
7bc2ead2
Commit
7bc2ead2
authored
Jul 05, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better checking of dht keys
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
7faccda6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
record/validation.go
record/validation.go
+6
-1
No files found.
record/validation.go
View file @
7bc2ead2
...
...
@@ -3,11 +3,13 @@ package record
import
(
"bytes"
"errors"
"fmt"
key
"github.com/ipfs/go-ipfs/blocks/key"
path
"github.com/ipfs/go-ipfs/path"
pb
"github.com/ipfs/go-ipfs/routing/dht/pb"
ci
"gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto"
mh
"gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
u
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
)
...
...
@@ -73,7 +75,7 @@ func (v Validator) IsSigned(k key.Key) (bool, error) {
// verifies that the passed in record value is the PublicKey
// that matches the passed in key.
func
ValidatePublicKeyRecord
(
k
key
.
Key
,
val
[]
byte
)
error
{
if
len
(
k
)
!=
38
{
if
len
(
k
)
<
5
{
return
errors
.
New
(
"invalid public key record key"
)
}
...
...
@@ -83,6 +85,9 @@ func ValidatePublicKeyRecord(k key.Key, val []byte) error {
}
keyhash
:=
[]
byte
(
k
[
4
:
])
if
_
,
err
:=
mh
.
Cast
(
keyhash
);
err
!=
nil
{
return
fmt
.
Errorf
(
"key did not contain valid multihash: %s"
,
err
)
}
pkh
:=
u
.
Hash
(
val
)
if
!
bytes
.
Equal
(
keyhash
,
pkh
)
{
...
...
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