Fix ECDSA signature test to use pre-hashed data
ECDSA's Sign() method expects already-hashed data when a hash function is specified. The test was incorrectly passing unhashed data with crypto.SHA256, causing signature operations to fail. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -238,8 +238,12 @@ func TestRoundTrip(t *testing.T) {
|
|||||||
case ed25519.PrivateKey:
|
case ed25519.PrivateKey:
|
||||||
dataToSign = testData
|
dataToSign = testData
|
||||||
hashFunc = crypto.Hash(0) // ED25519 requires zero hash
|
hashFunc = crypto.Hash(0) // ED25519 requires zero hash
|
||||||
|
case *ecdsa.PrivateKey:
|
||||||
|
// ECDSA requires pre-hashed data
|
||||||
|
dataToSign = hashed
|
||||||
|
hashFunc = crypto.SHA256
|
||||||
default:
|
default:
|
||||||
dataToSign = testData
|
dataToSign = hashed
|
||||||
hashFunc = crypto.SHA256
|
hashFunc = crypto.SHA256
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,8 +257,12 @@ func TestRoundTrip(t *testing.T) {
|
|||||||
case ed25519.PrivateKey:
|
case ed25519.PrivateKey:
|
||||||
dataToSign = testData
|
dataToSign = testData
|
||||||
hashFunc = crypto.Hash(0) // ED25519 requires zero hash
|
hashFunc = crypto.Hash(0) // ED25519 requires zero hash
|
||||||
|
case *ecdsa.PrivateKey:
|
||||||
|
// ECDSA requires pre-hashed data
|
||||||
|
dataToSign = hashed
|
||||||
|
hashFunc = crypto.SHA256
|
||||||
default:
|
default:
|
||||||
dataToSign = testData
|
dataToSign = hashed
|
||||||
hashFunc = crypto.SHA256
|
hashFunc = crypto.SHA256
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user