zuc

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package zuc handle shangmi zuc stream cipher, experimental/poc implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCipher

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

NewCipher create a stream cipher based on key and iv aguments.

func NewEEACipher

func NewEEACipher(key []byte, count, bearer, direction uint32) (cipher.Stream, error)

NewEEACipher create a stream cipher based on key, count, bearer and direction arguments according specification.

Types

type ZUC128Mac

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

func NewEIAHash

func NewEIAHash(key []byte, count, bearer, direction uint32) (*ZUC128Mac, error)

NewEIAHash create hash for zuc-128 eia, with arguments key, count, bearer and direction

func NewHash

func NewHash(key, iv []byte) (*ZUC128Mac, error)

NewHash create hash for zuc-128 eia, with arguments key and iv. Both key/iv size are 16 in bytes.

func (*ZUC128Mac) BlockSize

func (m *ZUC128Mac) BlockSize() int

func (*ZUC128Mac) Finish

func (m *ZUC128Mac) Finish(p []byte, nbits int) []byte

Finish this function hash nbits data in p and return mac value In general, we will use byte level function, this is just for test/verify.

func (*ZUC128Mac) Reset

func (m *ZUC128Mac) Reset()

func (*ZUC128Mac) Size

func (m *ZUC128Mac) Size() int

func (*ZUC128Mac) Sum

func (m *ZUC128Mac) Sum(in []byte) []byte

func (*ZUC128Mac) Write

func (m *ZUC128Mac) Write(p []byte) (nn int, err error)

func (*ZUC128Mac) XORKeyStream

func (c *ZUC128Mac) XORKeyStream(dst, src []byte)

Per test, even we generate key stream first, and then XOR once, the performance improvement is NOT significant.

type ZUC256Mac

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

func NewHash256

func NewHash256(key, iv []byte, tagSize int) (*ZUC256Mac, error)

NewHash256 create hash for zuc-256 eia, with arguments key, iv and tagSize. Key size is 32 in bytes, iv size is 23 in bytes, tagSize supports 4/8/16 in bytes. The larger the tag size, the worse the performance.

func (*ZUC256Mac) BlockSize

func (m *ZUC256Mac) BlockSize() int

func (*ZUC256Mac) Finish

func (m *ZUC256Mac) Finish(p []byte, nbits int) []byte

Finish this function hash nbits data in p and return mac value In general, we will use byte level function, this is just for test/verify.

func (*ZUC256Mac) Reset

func (m *ZUC256Mac) Reset()

func (*ZUC256Mac) Size

func (m *ZUC256Mac) Size() int

func (*ZUC256Mac) Sum

func (m *ZUC256Mac) Sum(in []byte) []byte

func (*ZUC256Mac) Write

func (m *ZUC256Mac) Write(p []byte) (nn int, err error)

func (*ZUC256Mac) XORKeyStream

func (c *ZUC256Mac) XORKeyStream(dst, src []byte)

Per test, even we generate key stream first, and then XOR once, the performance improvement is NOT significant.

Jump to

Keyboard shortcuts

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