adding SHA1 and SHA512 Methods

This commit is contained in:
Colin Misare 2016-05-17 17:38:34 -06:00
parent fb0c387e74
commit ef69faf59b
2 changed files with 19 additions and 0 deletions

2
key.go
View File

@ -53,7 +53,9 @@ import (
type Method *C.EVP_MD
var (
SHA1_Method Method = C.EVP_sha1()
SHA256_Method Method = C.EVP_sha256()
SHA512_Method Method = C.EVP_sha512()
)
type PublicKey interface {

View File

@ -147,3 +147,20 @@ func TestGenerate(t *testing.T) {
t.Fatal(err)
}
}
func TestSign(t *testing.T) {
key, _ := GenerateRSAKey(1024)
data := []byte("the quick brown fox jumps over the lazy dog")
_, err := key.SignPKCS1v15(SHA1_Method, data)
if err != nil {
t.Fatal(err)
}
_, err = key.SignPKCS1v15(SHA256_Method, data)
if err != nil {
t.Fatal(err)
}
_, err = key.SignPKCS1v15(SHA512_Method, data)
if err != nil {
t.Fatal(err)
}
}