Skip to content

Commit c4161f4

Browse files
committed
Use a constant-time compare for the signature.
Both inputs are public so there's no obvious point, but it's what NaCl does.
1 parent f5d0dc5 commit c4161f4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ed25519.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ package ed25519
1010
// from SUPERCOP.
1111

1212
import (
13-
"bytes"
1413
"crypto/sha512"
14+
"crypto/subtle"
1515
"io"
1616

1717
"github.com/agl/ed25519/edwards25519"
@@ -121,5 +121,5 @@ func Verify(publicKey *[PublicKeySize]byte, message []byte, sig *[SignatureSize]
121121

122122
var checkR [32]byte
123123
R.ToBytes(&checkR)
124-
return bytes.Equal(sig[:32], checkR[:])
124+
return subtle.ConstantTimeCompare(sig[:32], checkR[:]) == 1
125125
}

0 commit comments

Comments
 (0)