xgm

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DECRYPT 解密模式
	DECRYPT = 0
	// ENCRYPT 加密模式
	ENCRYPT = 1
)
View Source
const Sm4BlockSize = 16

Sm4BlockSize size of GM_SM4 block

Variables

This section is empty.

Functions

func DecryptBytes_CBC added in v1.0.2

func DecryptBytes_CBC(data, key, iv []byte) (out []byte, err error)

func DecryptECB

func DecryptECB(data, key []byte) ([]byte, error)

func Decrypt_CBC added in v1.0.2

func Decrypt_CBC(data, key, iv string) (out string, err error)

func Decrypt_ECB added in v1.0.2

func Decrypt_ECB(data, key string) (out string, err error)

func DiversifyKey added in v1.0.2

func DiversifyKey(key, dvs string) (newkey string, err error)

func EncryptBytes_CBC added in v1.0.2

func EncryptBytes_CBC(data, key, iv []byte) (out []byte, err error)

func EncryptECB

func EncryptECB(data, key []byte) ([]byte, error)

func Encrypt_CBC added in v1.0.2

func Encrypt_CBC(data, key, iv string) (out string, err error)

func Encrypt_ECB added in v1.0.2

func Encrypt_ECB(data, key string) (out string, err error)

func GenerateKeyPair added in v1.0.2

func GenerateKeyPair() ([]byte, error)

func PbocMac added in v1.0.2

func PbocMac(data, key, iv string) (out string, err error)

func Pkcs7Padding added in v1.0.2

func Pkcs7Padding(src []byte, blockSize int) []byte

func Pkcs7UnPadding added in v1.0.2

func Pkcs7UnPadding(src []byte, blockSize int) ([]byte, error)

func SM2_GenerateKeyPair added in v1.0.2

func SM2_GenerateKeyPair() (publicKey string, privateKey string, err error)

func SM2_PrivateKey_Decrypt added in v1.0.2

func SM2_PrivateKey_Decrypt(cipher string, privKey string) (plain string, err error)

func SM2_PublicKey_Encrypt added in v1.0.2

func SM2_PublicKey_Encrypt(plain string, publicKey string) (cipher string, err error)

func SM3_Hash added in v1.0.2

func SM3_Hash(data string) (hash string)

func SM4CryptCbc added in v1.0.2

func SM4CryptCbc(key []byte, in []byte, iv []byte, flag int) ([]byte, error)

SM4CryptEcb SM4加解密CBC flag 0:解密,1:加密

func SM4CryptEcb added in v1.0.2

func SM4CryptEcb(key []byte, in []byte, flag int) ([]byte, error)

SM4CryptEcb SM4加解密ECB flag 0:解密,1:加密

func SM4DiverseKey added in v1.0.2

func SM4DiverseKey(dvsData []byte, dvsDataOffset int, ckKey []byte) ([]byte, error)

func SM4PbocMac added in v1.0.2

func SM4PbocMac(key []byte, iv []byte, msg []byte, macLen int) ([]byte, error)

func SM4_Decrypt_ECB added in v1.0.2

func SM4_Decrypt_ECB(key, cipher string) (plain string, err error)

func SM4_Encrypt_ECB added in v1.0.2

func SM4_Encrypt_ECB(key, plain string) (cipher string, err error)

func SignWithPrivate added in v1.0.2

func SignWithPrivate(key []byte, msg []byte) ([]byte, error)

func VerifyWithPublic added in v1.0.2

func VerifyWithPublic(key []byte, msg []byte, sig []byte) error

Types

type Sm4Cipher added in v1.0.2

type Sm4Cipher struct {
	RK [32]uint32
}

Sm4Cipher GM_SM4 cipher

func SM4SetKey added in v1.0.2

func SM4SetKey(key []byte) (*Sm4Cipher, error)

SM4SetKey set key of GM_SM4

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL