threefish

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 2 Imported by: 3

Documentation

Overview

This package implements the Threefish cipher as specified in the Skein V1.3 specification. The Skein digest algorithm uses Threefish to generate the digests.

NOTE: Threefish is a new cipher algorithm - use with care until fully analysed.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Authors: Werner Dittmann <Werner.Dittmann@t-online.de>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Authors: Werner Dittmann <Werner.Dittmann@t-online.de>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Authors: Werner Dittmann <Werner.Dittmann@t-online.de>

Index

Constants

View Source
const (
	KEY_SCHEDULE_CONST  = uint64(0x1BD11BDAA9FC1A22)
	EXPANDED_TWEAK_SIZE = 3
)

General Threefish constants

View Source
const (
	CIPHER_SIZE_1024       = 1024
	CIPHER_QWORDS_1024     = CIPHER_SIZE_1024 / 64
	EXPANDED_KEY_SIZE_1024 = CIPHER_QWORDS_1024 + 1
)

Constants for Threefish 1024 implementation

View Source
const (
	CIPHER_SIZE_256       = 256
	CIPHER_QWORDS_256     = CIPHER_SIZE_256 / 64
	EXPANDED_KEY_SIZE_256 = CIPHER_QWORDS_256 + 1
)

Constants for Threefish 256 implementation

View Source
const (
	CIPHER_SIZE_512       = 512
	CIPHER_QWORDS_512     = CIPHER_SIZE_512 / 64
	EXPANDED_KEY_SIZE_512 = CIPHER_QWORDS_512 + 1
)

Constants for Threefish 512 implementation

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

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

A Cipher is an instance of Threefish using a particular key and state size.

func New

func New(key []byte, tweak []uint64) (*Cipher, error)

NewCipher creates and returns a Cipher.

The key length can be 32, 64 or 128 bytes and must match the Threefish state size. The blocksize is the same as the key length (state size). The tweak is a uint64 array with two elements.

key

Key data, key length selects the internal state size

tweak

The initial Tweak data for this threefish instance

func New64

func New64(key, tweak []uint64) (*Cipher, error)

New64 creates and returns a Cipher.

The key is a uint64 array of 4, 8 or 16 elements. The key length must match the Threefish state size. The blocksize is the same as the key length (state size). The tweak is a uint64 array with two elements.

key

Key data, key length selects the internal state size

tweak

The initial Tweak data for this threefish instance

func NewSize

func NewSize(size int) (*Cipher, error)

NewSize creates and returns a Cipher.

The size argument is the requested Threefish state size which is also the key and block size. Supported sizes see constants section.

func (*Cipher) BlockSize

func (c *Cipher) BlockSize() int

BlockSize returns the cipher's block size in bytes.

func (*Cipher) Decrypt

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

Decrypt a block. Dst and src may point at the same memory.

dst

Destination of encypted data (cipher data)

src

Contains a block of plain data

func (*Cipher) Decrypt64

func (c *Cipher) Decrypt64(dst, src []uint64)

Decrypt a block. Blocks are unit64 arrays. Dst and src may point at the same memory.

dst

Destination of decrypted data (plain data)

src

Contains a block of encrypted data (cipher data)

func (*Cipher) Encrypt

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

Encrypt a block. Dst and src may point at the same memory.

dst

Destination of encypted data (cipher data)

src

Contains a block of plain data

func (*Cipher) Encrypt64

func (c *Cipher) Encrypt64(dst, src []uint64)

Encrypt a block. Blocks are unit64 arrays. Dst and src may point at the same memory.

dst

Destination of encypted data (cipher data)

src

Contains a block of plain data

func (*Cipher) SetKey

func (c *Cipher) SetKey(key []uint64)

Set the key.

The key must have the same length as the Threefish state size.

func (*Cipher) SetTweak

func (c *Cipher) SetTweak(tweak []uint64)

Set the tweak data.

The tweak is a uint64 array with two elements.

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (k KeySizeError) Error() string

Jump to

Keyboard shortcuts

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