Skip to content

Commit

Permalink
adding SHA1 and SHA512 Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cmisare committed May 17, 2016
1 parent fb0c387 commit ef69faf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit ef69faf

Please sign in to comment.