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
p2p
go-p2p-core
Commits
652a852e
Commit
652a852e
authored
Jul 12, 2019
by
Cole Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use short-circuiting comparisons for public keys
parent
2726b649
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
crypto/ed25519.go
crypto/ed25519.go
+3
-2
No files found.
crypto/ed25519.go
View file @
652a852e
package
crypto
import
(
"bytes"
"crypto/subtle"
"errors"
"fmt"
...
...
@@ -105,7 +106,7 @@ func (k *Ed25519PublicKey) Equals(o Key) bool {
return
false
}
return
subtle
.
ConstantTimeCompare
(
k
.
k
,
edk
.
k
)
==
1
return
bytes
.
Equal
(
k
.
k
,
edk
.
k
)
}
// Verify checks a signature agains the input data.
...
...
@@ -131,7 +132,7 @@ func UnmarshalEd25519PrivateKey(data []byte) (PrivKey, error) {
// Remove the redundant public key. See issue #36.
redundantPk
:=
data
[
ed25519
.
PrivateKeySize
:
]
pk
:=
data
[
ed25519
.
PrivateKeySize
-
ed25519
.
PublicKeySize
:
ed25519
.
PrivateKeySize
]
if
subtle
.
ConstantTimeCompare
(
pk
,
redundantPk
)
!=
1
{
if
!
bytes
.
Equal
(
pk
,
redundantPk
)
{
return
nil
,
errors
.
New
(
"expected redundant ed25519 public key to be redundant"
)
}
...
...
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