threefish

package
v0.0.0-...-c9cf022 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package threefish implements the Threefish tweakable block cipher. Threefish is designed to be the core function of the Skein hash function family. There are three versions of Threefish

  • Threefish256 processes 256 bit blocks
  • Threefish512 processes 512 bit blocks
  • Threefish1024 processes 1024 bit blocks

Index

Constants

View Source
const (
	// The size of the tweak in bytes.
	TweakSize = 16
	// C240 is the key schedule constant
	C240 = 0x1bd11bdaa9fc1a22
	// The block size of Threefish-256 in bytes.
	BlockSize256 = 32
	// The block size of Threefish-512 in bytes.
	BlockSize512 = 64
	// The block size of Threefish-1024 in bytes.
	BlockSize1024 = 128
)

Variables

This section is empty.

Functions

func Decrypt1024

func Decrypt1024(block *[16]uint64, keys *[17]uint64, tweak *[3]uint64)

Decrypt1024 decrypts the 16 words of block using the expanded 1024 bit key and the 128 bit tweak. The keys[16] must be keys[0] xor keys[1] xor ... keys[15] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func Decrypt256

func Decrypt256(block *[4]uint64, keys *[5]uint64, tweak *[3]uint64)

Decrypt256 decrypts the 4 words of block using the expanded 256 bit key and the 128 bit tweak. The keys[4] must be keys[0] xor keys[1] xor ... keys[3] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func Decrypt512

func Decrypt512(block *[8]uint64, keys *[9]uint64, tweak *[3]uint64)

Decrypt512 decrypts the 8 words of block using the expanded 512 bit key and the 128 bit tweak. The keys[8] must be keys[0] xor keys[1] xor ... keys[8] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func Encrypt1024

func Encrypt1024(block *[16]uint64, keys *[17]uint64, tweak *[3]uint64)

Encrypt1024 encrypts the 16 words of block using the expanded 1024 bit key and the 128 bit tweak. The keys[16] must be keys[0] xor keys[1] xor ... keys[15] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func Encrypt256

func Encrypt256(block *[4]uint64, keys *[5]uint64, tweak *[3]uint64)

Encrypt256 encrypts the 4 words of block using the expanded 256 bit key and the 128 bit tweak. The keys[4] must be keys[0] xor keys[1] xor ... keys[3] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func Encrypt512

func Encrypt512(block *[8]uint64, keys *[9]uint64, tweak *[3]uint64)

Encrypt512 encrypts the 8 words of block using the expanded 512 bit key and the 128 bit tweak. The keys[8] must be keys[0] xor keys[1] xor ... keys[8] xor C240. The tweak[2] must be tweak[0] xor tweak[1].

func IncrementTweak

func IncrementTweak(tweak *[3]uint64, ctr uint64)

Increment the tweak by the ctr argument. Skein can consume messages up to 2^96 -1 bytes.

func NewCipher

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

NewCipher returns a cipher.Block implementing the Threefish cipher. The length of the key must be 32, 64 or 128 byte. The length of the tweak must be TweakSize. The returned cipher implements:

  • Threefish-256 - if len(key) = 32
  • Threefish-512 - if len(key) = 64
  • Threefish-1024 - if len(key) = 128

func UBI1024

func UBI1024(block *[16]uint64, hVal *[17]uint64, tweak *[3]uint64)

UBI1024 does a Threefish1024 encryption of the given block using the chain values hVal and the tweak. The chain values are updated through hVal[i] = block[i] ^ Enc(block)[i]

func UBI256

func UBI256(block *[4]uint64, hVal *[5]uint64, tweak *[3]uint64)

UBI256 does a Threefish256 encryption of the given block using the chain values hVal and the tweak. The chain values are updated through hVal[i] = block[i] ^ Enc(block)[i]

func UBI512

func UBI512(block *[8]uint64, hVal *[9]uint64, tweak *[3]uint64)

UBI512 does a Threefish512 encryption of the given block using the chain values hVal and the tweak. The chain values are updated through hVal[i] = block[i] ^ Enc(block)[i]

Types

This section is empty.

Jump to

Keyboard shortcuts

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