sm4

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 16

BlockSize block size

Variables

This section is empty.

Functions

func DecryptBlock

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

DecryptBlock decrypt block

func EncryptBlock

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

EncryptBlock encrypt block

func NewCipher

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

NewCipher creates and returns a new cipher.Block.

func Sm4DecCBCIV

func Sm4DecCBCIV(key, iv, src []byte) ([]byte, error)

Sm4DecCBCIV decode sm4 cipher with cbc mode and initial vector

func Sm4EncCBCIV

func Sm4EncCBCIV(key, iv, src []byte) ([]byte, error)

Sm4EncCBCIV enc iv length is 16, block length is 128bits

func WriteKeyToPem

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

WriteKeyToPem WriteKeyToPem

func WriteKeytoMem

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

WriteKeytoMem WriteKeytoMem

Types

type KeySizeError

type KeySizeError int

KeySizeError size error

func (KeySizeError) Error

func (k KeySizeError) Error() string

type SM4Key

type SM4Key []byte

SM4Key key of sm4

func ReadKeyFromMem

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

ReadKeyFromMem read key from memory

func ReadKeyFromPem

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

ReadKeyFromPem ReadKeyFromPem

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

BlockSize sm4 BlockSize

func (*Sm4Cipher) Decrypt

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

Decrypt sm4 Decrypt

func (*Sm4Cipher) Encrypt

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

Encrypt sm4 Encrypt

Jump to

Keyboard shortcuts

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