Commit 652a852e authored by Cole Brown's avatar Cole Brown

Use short-circuiting comparisons for public keys

parent 2726b649
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")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment