zuc

package
v1.0.4019 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const IV_SIZE = 16
View Source
const KEY_SIZE = 16
View Source
const MAC_SIZE = 4
View Source
const ZUC256_IV_SIZE = 23
View Source
const ZUC256_KEY_SIZE = 32
View Source
const ZUC256_MAC128_SIZE = 16
View Source
const ZUC256_MAC32_SIZE = 4
View Source
const ZUC256_MAC64_SIZE = 8
View Source
const ZUC256_MAX_MAC_SIZE = ZUC256_MAC128_SIZE
View Source
const ZUC256_MIN_MAC_SIZE = ZUC256_MAC32_SIZE
View Source
const ZUC_BLOCK_SIZE = 4

Variables

View Source
var KD = [16]uint32{
	0x44D7, 0x26BC, 0x626B, 0x135E, 0x5789, 0x35E2, 0x7135, 0x09AF,
	0x4D78, 0x2F13, 0x6BC4, 0x1AF1, 0x5E26, 0x3C4D, 0x789A, 0x47AC,
}
View Source
var S0 = [256]uint8{}/* 256 elements not displayed */
View Source
var S1 = [256]uint8{}/* 256 elements not displayed */
View Source
var ZUC256_D = [][]uint8{
	{
		0x22, 0x2F, 0x24, 0x2A, 0x6D, 0x40, 0x40, 0x40,
		0x40, 0x40, 0x40, 0x40, 0x40, 0x52, 0x10, 0x30,
	},
	{
		0x22, 0x2F, 0x25, 0x2A, 0x6D, 0x40, 0x40, 0x40,
		0x40, 0x40, 0x40, 0x40, 0x40, 0x52, 0x10, 0x30,
	},
	{
		0x23, 0x2F, 0x24, 0x2A, 0x6D, 0x40, 0x40, 0x40,
		0x40, 0x40, 0x40, 0x40, 0x40, 0x52, 0x10, 0x30,
	},
	{
		0x23, 0x2F, 0x25, 0x2A, 0x6D, 0x40, 0x40, 0x40,
		0x40, 0x40, 0x40, 0x40, 0x40, 0x52, 0x10, 0x30,
	},
}

Functions

func ADD31

func ADD31(a *uint32, b uint32)

func BitReconstruction2

func BitReconstruction2(X1, X2 *uint32, LFSR []uint32)

func BitReconstruction3

func BitReconstruction3(X0, X1, X2 *uint32, LFSR []uint32)

func BitReconstruction4

func BitReconstruction4(X0, X1, X2, X3 *uint32, LFSR []uint32)

func EEA_ENCRYPT_NBYTES

func EEA_ENCRYPT_NBYTES(nbits int) int

func EEA_ENCRYPT_NWORDS

func EEA_ENCRYPT_NWORDS(nbits int) int

func EeaEncrypt

func EeaEncrypt(
	in []uint32,
	out []uint32,
	nbits int,
	key []byte,
	count uint32,
	bearer uint32,
	direction uint32,
)

func EiaGenerateMac

func EiaGenerateMac(
	data []uint32,
	nbits int,
	key [16]byte,
	count uint32,
	bearer uint32,
	direction uint32,
) uint32

func F

func F(R1, R2 *uint32, X0, X1, X2 uint32) uint32

func F_

func F_(R1, R2 *uint32, X1, X2 uint32)

func GETU32

func GETU32(ptr []byte) uint32

func L1

func L1(X uint32) uint32

func L2

func L2(X uint32) uint32

func LFSRWithInitialisationMode

func LFSRWithInitialisationMode(u uint32, LFSR []uint32)

func LFSRWithWorkMode

func LFSRWithWorkMode(LFSR []uint32)

func MAKEU31

func MAKEU31(k uint8, d uint32, iv uint8) uint32

func MAKEU32

func MAKEU32(a, b, c, d uint8) uint32

func MemsetByte

func MemsetByte(a []byte, v byte)

func New256Cipher

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

New256Cipher creates and returns a new cipher.Stream.

func New256CipherWithMacbits

func New256CipherWithMacbits(key []byte, iv []byte, macbits int32) (cipher.Stream, error)

New256CipherWithMacbits creates and returns a new cipher.Stream.

func NewCipher

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

NewCipher creates and returns a new cipher.Stream.

func NewEEACipher

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

NewEEACipher creates and returns a new cipher.Stream.

func PUTU32

func PUTU32(ptr []byte, a uint32)

func ROT31

func ROT31(a, k uint32) uint32

func ROT32

func ROT32(a, k uint32) uint32

func SetEiaIV

func SetEiaIV(
	iv []byte,
	count uint32,
	bearer uint32,
	direction uint32,
)

func ZUC256_MAKEU31

func ZUC256_MAKEU31(a, b, c, d byte) uint32

Types

type IVSizeError

type IVSizeError int

func (IVSizeError) Error

func (k IVSizeError) Error() string

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

type Zuc

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

func NewZucDecrypt

func NewZucDecrypt(key []byte, iv []byte) *Zuc

func NewZucEncrypt

func NewZucEncrypt(key []byte, iv []byte) *Zuc

func (*Zuc) Sum

func (this *Zuc) Sum(data []byte) []byte

func (*Zuc) Write

func (this *Zuc) Write(in []byte, out []byte) (nn int, err error)

type Zuc256Mac

type Zuc256Mac struct {
	LFSR [16]uint32
	R1   uint32
	R2   uint32
	T    [4]uint32
	K0   [4]uint32
	// contains filtered or unexported fields
}

func NewZuc256Mac

func NewZuc256Mac(key []byte, iv []byte, macbits int32) *Zuc256Mac

func (*Zuc256Mac) BlockSize

func (this *Zuc256Mac) BlockSize() int

func (*Zuc256Mac) Reset

func (this *Zuc256Mac) Reset()

func (*Zuc256Mac) Size

func (this *Zuc256Mac) Size() int

func (*Zuc256Mac) Sum

func (this *Zuc256Mac) Sum(data []byte, nbits int) []byte

func (*Zuc256Mac) Write

func (this *Zuc256Mac) Write(data []byte) (nn int, err error)

type Zuc256State

type Zuc256State struct {
	LFSR [16]uint32
	R1   uint32
	R2   uint32
}

func NewZuc256State

func NewZuc256State(key []byte, iv []byte) *Zuc256State

func NewZuc256StateWithMacbits

func NewZuc256StateWithMacbits(key []byte, iv []byte, macbits int32) *Zuc256State

func (*Zuc256State) Encrypt

func (this *Zuc256State) Encrypt(out []byte, in []byte)

func (*Zuc256State) GenerateKeystream

func (this *Zuc256State) GenerateKeystream(nwords int, keystream []uint32)

func (*Zuc256State) GenerateKeyword

func (this *Zuc256State) GenerateKeyword() uint32

type ZucMac

type ZucMac struct {
	LFSR [16]uint32
	R1   uint32
	R2   uint32
	T    uint32
	K0   uint32
	// contains filtered or unexported fields
}

func NewZucMac

func NewZucMac(key []byte, iv []byte) *ZucMac

func (*ZucMac) BlockSize

func (this *ZucMac) BlockSize() int

func (*ZucMac) Reset

func (this *ZucMac) Reset()

func (*ZucMac) Size

func (this *ZucMac) Size() int

func (*ZucMac) Sum

func (this *ZucMac) Sum(data []byte, nbits int) []byte

func (*ZucMac) Write

func (this *ZucMac) Write(data []byte) (nn int, err error)

type ZucState

type ZucState struct {
	LFSR [16]uint32
	R1   uint32
	R2   uint32
}

func NewZucState

func NewZucState(key []byte, iv []byte) *ZucState

func (*ZucState) Encrypt

func (this *ZucState) Encrypt(out []byte, in []byte)

func (*ZucState) GenerateKeystream

func (this *ZucState) GenerateKeystream(nwords int, keystream []uint32)

func (*ZucState) GenerateKeyword

func (this *ZucState) GenerateKeyword() uint32

func (*ZucState) SetEeaKey

func (this *ZucState) SetEeaKey(userKey []byte, count uint32, bearer uint32, direction uint32)

Jump to

Keyboard shortcuts

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