aboutsummaryrefslogtreecommitdiff
path: root/private_key_test.go
diff options
context:
space:
mode:
authorGibheer <gibheer@gmail.com>2015-02-18 22:55:29 +0100
committerGibheer <gibheer@gmail.com>2015-02-18 22:55:29 +0100
commit639a5379e9abf4a3f0d88464d1a229f8d5df14ae (patch)
tree3d05c242b4eaf8e17548c4ebe877a5765c52c0ed /private_key_test.go
parent577538a5ffb21b402b7ed53279d4b4dce30ace24 (diff)
add sign and verification to ecdsa
This commit adds support to sign and verify messages using ecdsa.
Diffstat (limited to 'private_key_test.go')
-rw-r--r--private_key_test.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/private_key_test.go b/private_key_test.go
index 1d8f5ba..a563f50 100644
--- a/private_key_test.go
+++ b/private_key_test.go
@@ -1,6 +1,7 @@
package pki
import (
+ "crypto"
"crypto/elliptic"
"encoding/pem"
"testing"
@@ -8,6 +9,7 @@ import (
var (
SignatureMessage = []byte("foobar")
+ SignatureHash = crypto.SHA512
)
// run the marshal test
@@ -34,10 +36,10 @@ func RunPrivateKeyTests(pk_type string, pk PrivateKey, t *testing.T) {
_, err := RunMarshalTest(pk_type + "-public", pu, PemLabelPublic, t)
if err != nil { return }
- signature, err := pk.Sign(SignatureMessage)
+ signature, err := pk.Sign(SignatureMessage, SignatureHash)
if err != nil { t.Errorf("%s: error creating a signature: %s", pk_type, err) }
- valid, err := pu.Verify(SignatureMessage, signature)
+ valid, err := pu.Verify(SignatureMessage, signature, SignatureHash)
if err != nil { t.Errorf("%s: could not verify message: %s", pk_type, err) }
if !valid { t.Errorf("%s: signature invalid, but should be valid!", pk_type) }
}