init: v1.0.0
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package sm2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"xdx.jelly/xgcl/grand"
|
||||
)
|
||||
|
||||
// Test Cipher
|
||||
func TestCipherP7(t *testing.T) {
|
||||
sk, _ := GenerateKey(Curve(), grand.Reader)
|
||||
data := make([]byte, 48)
|
||||
cipher, _ := Encrypt(&sk.PublicKey, data, grand.GetRandom(32))
|
||||
b, err := cipher.MarshalASN1()
|
||||
assert.Nil(t, err)
|
||||
|
||||
var cipher2 Cipher
|
||||
b, err = cipher2.UnmarshalASN1(b)
|
||||
assert.Equal(t, len(b), 0)
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, cipher.String(), cipher2.String())
|
||||
}
|
||||
Reference in New Issue
Block a user