Skip to content

Commit

Permalink
Added tests for signature
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrokhtar committed Apr 1, 2022
1 parent 3d8d953 commit e5a036e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions rsam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ func TestPublicKeySignature(t *testing.T) {
}
}

func TestPublicKeySignatureInvalid(t *testing.T) {
priv, pub, err := rsam.GeneratePairKeys(1024)
if err != nil {
t.Error(err)
}
signature, err := rsam.SignWithPublicKey([]byte("test"), pub)
if err != nil {
t.Error(err)
}
err = rsam.VerifyWithPrivateKey([]byte("test2"), signature, priv)
if err == nil {
t.Error(err)
}
}

func TestPrivateKeySignature(t *testing.T) {
priv, pub, err := rsam.GeneratePairKeys(1024)
if err != nil {
Expand All @@ -39,6 +54,21 @@ func TestPrivateKeySignature(t *testing.T) {
}
}

func TestPrivateKeySignatureInvalid(t *testing.T) {
priv, pub, err := rsam.GeneratePairKeys(1024)
if err != nil {
t.Error()
}
signature, err := rsam.SignWithPrivateKey([]byte("test"), priv)
if err != nil {
t.Error()
}
err = rsam.VerifyWithPublicKey([]byte("te2st"), signature, pub)
if err == nil {
t.Error()
}
}

func TestGeneratePairKeys(t *testing.T) {
priv, pub, err := rsam.GeneratePairKeys(1024)
if err != nil {
Expand Down

0 comments on commit e5a036e

Please sign in to comment.