sm4

package
v0.0.0-...-cdcb8f3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 16

Variables

This section is empty.

Functions

func DecryptBlock

func DecryptBlock(key Sm4Key, dst, src []byte)

*

*@description:this function use to decrypt 128 bits data,and the decrypted data will be return in the param output
*@param key sm4密钥
*@param src 128bits crypto text
*@param dst 128bits plain text
*@return void

func EncryptBlock

func EncryptBlock(key Sm4Key, dst, src []byte)

*

*@description:this function use to encrypt 128 bits data,and the encrypted data will be return in the param output
*@param key sm4密钥
*@param src 128bits plain text
*@param dst 128bits crypto text
*@return void

func NewCipher

func NewCipher(key []byte) (cipher.Block, error)

NewCipher creates and returns a new cipher.Block.

func SM4GCM

func SM4GCM(key []byte, IV, in, A []byte, mode bool) ([]byte, []byte, error)

SM4GCM SM4 GCM 加解密模式 key: 对称加密密钥 IV: IV向量 in: A: 附加的可鉴别数据(ADD) mode: true - 加密; false - 解密验证 return: 密文C, 鉴别标签T, 错误

Types

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

判断错误

type Sm4Cipher

type Sm4Cipher struct {
	// contains filtered or unexported fields
}

Sm4Cipher is an instance of SM4 encryption.

func (*Sm4Cipher) BlockSize

func (c *Sm4Cipher) BlockSize() int

func (*Sm4Cipher) Decrypt

func (c *Sm4Cipher) Decrypt(dst, src []byte)

*

*@description:SM4解密函数
*@param src 密文数据
*@param dst 明文数据
*@return void

func (*Sm4Cipher) Encrypt

func (c *Sm4Cipher) Encrypt(dst, src []byte)

*

*@description:SM4加密函数
*@param src 明文数据
*@param dst 密文数据
*@return void

type Sm4Key

type Sm4Key []byte

Jump to

Keyboard shortcuts

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