From 639a5379e9abf4a3f0d88464d1a229f8d5df14ae Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 18 Feb 2015 22:55:29 +0100 Subject: add sign and verification to ecdsa This commit adds support to sign and verify messages using ecdsa. --- private_key_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'private_key_test.go') 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) } } -- cgit v1.2.3-70-g09d2