go-cryptopro
go-cryptopro copied to clipboard
Getting an error when trying to sign message
On my ubuntu 20 machine I have already installed and configured CryptoPro. So now I am trying to sign message using number571/go-cryptopro but getting the following error:
E[-2146893792][CreateContainer: CryptGenKey]
panic: error code: -3
goroutine 1 [running]:
github.com/number571/go-cryptopro/gost_r_34_10_2012.GenPrivKey(0xc000048cb0, 0x4b99e0, 0xc0000ac401)
/root/go/pkg/mod/github.com/number571/[email protected]/gost_r_34_10_2012/gost.go:92 +0x25a
github.com/number571/go-cryptopro/gost_r_34_10_2012.init.0()
/root/go/pkg/mod/github.com/number571/[email protected]/gost_r_34_10_2012/gost.go:18 +0x69
exit status 2
Here is the code
cfg := gkeys.NewConfig(gkeys.K256, "mkk", "password")
priv, err := gkeys.NewPrivKey(cfg)
if err != nil {
fmt.Println(err)
return
}
msg := []byte("hello, world!")
sign, err := priv.Sign(msg)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(msg)