sm4

package
v0.0.0-...-94cd62a Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 11 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)

func EncryptBlock

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

func NewCipher

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

NewCipher creates and returns a new cipher.Block.

func WriteKeyToPem

func WriteKeyToPem(FileName string, key SM4Key, pwd []byte) (bool, error)

func WriteKeytoMem

func WriteKeytoMem(key SM4Key, pwd []byte) ([]byte, error)

Types

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

type SM4CBCCipher256

type SM4CBCCipher256 struct {
	BufferPool *pkg.LimitedPool
	// contains filtered or unexported fields
}

func NewSM4CBCCipher256

func NewSM4CBCCipher256(key, iv []byte) (*SM4CBCCipher256, error)

func (*SM4CBCCipher256) Decrypt

func (sm4 *SM4CBCCipher256) Decrypt(src []byte) []byte

func (*SM4CBCCipher256) Encrypt

func (sm4 *SM4CBCCipher256) Encrypt(src []byte) []byte

type SM4Key

type SM4Key []byte

func ReadKeyFromMem

func ReadKeyFromMem(data []byte, pwd []byte) (SM4Key, error)

func ReadKeyFromPem

func ReadKeyFromPem(FileName string, pwd []byte) (SM4Key, error)

type Sm4Cipher

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

Cipher is an instance of SM4 encryption.

func (*Sm4Cipher) BlockSize

func (c *Sm4Cipher) BlockSize() int

func (*Sm4Cipher) Decrypt

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

func (*Sm4Cipher) Encrypt

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

Jump to

Keyboard shortcuts

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