diff --git a/gm/sm2/sm2_test.go b/gm/sm2/sm2_test.go index a7838262..42768363 100644 --- a/gm/sm2/sm2_test.go +++ b/gm/sm2/sm2_test.go @@ -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 { @@ -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) + } + +}