mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-03-29 14:10:07 +08:00
adding SHA1 and SHA512 Methods
This commit is contained in:
parent
fb0c387e74
commit
ef69faf59b
2
key.go
2
key.go
@ -53,7 +53,9 @@ import (
|
|||||||
type Method *C.EVP_MD
|
type Method *C.EVP_MD
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
SHA1_Method Method = C.EVP_sha1()
|
||||||
SHA256_Method Method = C.EVP_sha256()
|
SHA256_Method Method = C.EVP_sha256()
|
||||||
|
SHA512_Method Method = C.EVP_sha512()
|
||||||
)
|
)
|
||||||
|
|
||||||
type PublicKey interface {
|
type PublicKey interface {
|
||||||
|
17
key_test.go
17
key_test.go
@ -147,3 +147,20 @@ func TestGenerate(t *testing.T) {
|
|||||||
t.Fatal(err)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user