Table of Contents

Class SkeinEngine

Namespace
Org.BouncyCastle.Crypto.Digests
Assembly
BouncyCastle.Cryptography.dll

Implementation of the Skein family of parameterised hash functions in 256, 512 and 1024 bit block sizes, based on the Threefish tweakable block cipher.

public class SkeinEngine : IMemoable
Inheritance
SkeinEngine
Implements
Inherited Members

Remarks

This is the 1.3 version of Skein defined in the Skein hash function submission to the NIST SHA-3 competition in October 2010.

Skein was designed by Niels Ferguson - Stefan Lucks - Bruce Schneier - Doug Whiting - Mihir Bellare - Tadayoshi Kohno - Jon Callas - Jesse Walker.

This implementation is the basis for SkeinDigest and SkeinMac, implementing the parameter based configuration system that allows Skein to be adapted to multiple applications.
Initialising the engine with SkeinParameters allows standard and arbitrary parameters to be applied during the Skein hash function.

Implemented:
  • 256, 512 and 1024 bit internal states.
  • Full 96 bit input length.
  • Parameters defined in the Skein specification, and arbitrary other pre and post message parameters.
  • Arbitrary output size in 1 byte intervals.

Not implemented:
  • Sub-byte length input (bit padding).
  • Tree hashing.

Constructors

SkeinEngine(SkeinEngine)

Creates a SkeinEngine as an exact copy of an existing instance.

public SkeinEngine(SkeinEngine engine)

Parameters

engine SkeinEngine

SkeinEngine(int, int)

Constructs a Skein digest with an internal state size and output size.

public SkeinEngine(int blockSizeBits, int outputSizeBits)

Parameters

blockSizeBits int

the internal state size in bits - one of SKEIN_256 SKEIN_512 or SKEIN_1024.

outputSizeBits int

the output/digest size to produce in bits, which must be an integral number of bytes.

Fields

SKEIN_1024

1024 bit block size - Skein-1024

public const int SKEIN_1024 = 1024

Field Value

int

SKEIN_256

256 bit block size - Skein-256

public const int SKEIN_256 = 256

Field Value

int

SKEIN_512

512 bit block size - Skein-512

public const int SKEIN_512 = 512

Field Value

int

Properties

BlockSize

public int BlockSize { get; }

Property Value

int

OutputSize

public int OutputSize { get; }

Property Value

int

Methods

BlockUpdate(byte[], int, int)

public void BlockUpdate(byte[] inBytes, int inOff, int len)

Parameters

inBytes byte[]
inOff int
len int

BlockUpdate(ReadOnlySpan<byte>)

public void BlockUpdate(ReadOnlySpan<byte> input)

Parameters

input ReadOnlySpan<byte>

Copy()

Produce a copy of this object with its configuration and in its current state.

public IMemoable Copy()

Returns

IMemoable

Remarks

The returned object may be used simply to store the state, or may be used as a similar object starting from the copied state.

DoFinal(byte[], int)

public int DoFinal(byte[] outBytes, int outOff)

Parameters

outBytes byte[]
outOff int

Returns

int

DoFinal(Span<byte>)

public int DoFinal(Span<byte> output)

Parameters

output Span<byte>

Returns

int

Init(SkeinParameters)

Initialises the Skein engine with the provided parameters. See SkeinParameters for details on the parameterisation of the Skein hash function.

public void Init(SkeinParameters parameters)

Parameters

parameters SkeinParameters

the parameters to apply to this engine, or

null
to use no parameters.

Reset()

Reset the engine to the initial state (with the key and any pre-message parameters , ready to accept message input.

public void Reset()

Reset(IMemoable)

Restore a copied object state into this object.

public void Reset(IMemoable other)

Parameters

other IMemoable

an object originally {@link #copy() copied} from an object of the same type as this instance.

Remarks

Implementations of this method should try to avoid or minimise memory allocation to perform the reset.

Exceptions

InvalidCastException

if the provided object is not of the correct type.

MemoableResetException

if the other parameter is in some other way invalid.

Update(byte)

public void Update(byte inByte)

Parameters

inByte byte

See Also