lioness

package
v0.0.0-...-15dc43f Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package lioness implements the LIONESS Large Block Cipher with some modifications: Instead of using a standard stream cipher, it only allows usage of block ciphers that implement the cipher.Block interface. Furthermore it does not use the suggested hash operation but instead uses an HMAC everywhere a hash is used in the original design Paper: http://www.cl.cam.ac.uk/~rja14/Papers/bear-lion.pdf In addition, this implementation supports two modes. ModeZero, which uses an all zero IV for the R-operation, and ModeIV, which uses the content of L as the IV.

Index

Examples

Constants

View Source
const (
	// ModeIV uses L as the IV for encryption
	ModeIV = iota
	// ModeZero uses all zeros as the IV for encryption
	ModeZero
)

Variables

View Source
var (
	// ErrConstructed is returned if working with a lioness that hasn't been set up
	ErrConstructed = errors.New("lioness: Missing setup")
	// ErrKeyHashSize is returned if the key size is larger than the hash size
	ErrKeyHashSize = errors.New("lioness: Hash smaller than key")
	// ErrKeyLen is returned when the keys given do not match the key length
	ErrKeyLen = errors.New("lioness: Keys have wrong size")
	// ErrDataSize is returned when the data is too small (<=keylen)
	ErrDataSize = errors.New("lioness: Not enough data")
	// ErrNoKeys is returned if using a lioness without keys
	ErrNoKeys = errors.New("lioness: Keys not set")
)

Functions

This section is empty.

Types

type Lioness

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

Lioness holds internal data

func Construct

func Construct(blockcipher func([]byte) (cipher.Block, error), hash func() hash.Hash, keylen int, key []byte, mode int) (*Lioness, error)

Construct returns a new Lioness. Takes block cipher, hash function and keylen. Key can be nil. mode is either ModeIV or ModeZero

Example
Output:

Data after decryption: Some data to be encrypted. It must be long enough to cover at least one key length.

func New

func New(key []byte) (*Lioness, error)

New is shorthand for Construct with aes256 and sha256 in ModeZero

Example
Output:

Data after decryption: Some data to be encrypted. It must be long enough to cover at least one key length.

func (*Lioness) Decrypt

func (l *Lioness) Decrypt(data []byte) ([]byte, error)

Decrypt the data, return error if too little data is given

func (*Lioness) Encrypt

func (l *Lioness) Encrypt(data []byte) ([]byte, error)

Encrypt the data, return error if too little data is given

func (*Lioness) ExplodeKey

func (l *Lioness) ExplodeKey(key []byte) error

ExplodeKey generates the Lioness keys from a single input key by calculating repeated HMACs (which is of questionable security)

func (*Lioness) Setkeys

func (l *Lioness) Setkeys(k1, k2, k3, k4 []byte) error

Setkeys sets the keys and verifies that they are of keylen length

Example
Output:

Data after setkeys and decryption: Some data to be encrypted. It must be long enough to cover at least one key length.

Jump to

Keyboard shortcuts

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