Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Aug 28, 2024
1 parent 4cddcc9 commit 3cf8ae9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gm/sm2/sm2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func decodePEM(pubPEM string) *pem.Block {
return block
}

func fromHex(s string) []byte {
h, _ := hex.DecodeString(s)
return h
}

func Test_Sm2(t *testing.T) {
priv, err := sm2.GenerateKey(rand.Reader) // 生成密钥对
if err != nil {
Expand Down Expand Up @@ -1110,3 +1115,13 @@ func Test_Sign_Func_Encoding(t *testing.T) {
})
})
}

func Test_CheckPrivKey(t *testing.T) {
pri := "00377febf6f6fd530121d471ec27db463c63df6a38c94a75618a57ee48824fa0"

_, err := sm2.NewPrivateKey(fromHex(pri))
if err != nil {
t.Fatal(err)
}

}

0 comments on commit 3cf8ae9

Please sign in to comment.