SkeinEngine (Bouncy Castle Library 1.52 API Specification)

org.bouncycastle.crypto.digests

## Class SkeinEngine

- java.lang.Object
- - org.bouncycastle.crypto.digests.SkeinEngine

- All Implemented Interfaces:
    Memoable

      public class SkeinEngine
      extends java.lang.Object
      implements Memoable

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

  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.
  See Also:
    `SkeinParameters`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SkeinEngine.Parameter`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `SKEIN_1024` 1024 bit block size - Skein 1024
    `static int` | `SKEIN_256` 256 bit block size - Skein 256
    `static int` | `SKEIN_512` 512 bit block size - Skein 512

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SkeinEngine(int blockSizeBits, int outputSizeBits)` Constructs a Skein engine.
    `SkeinEngine(SkeinEngine engine)` Creates a SkeinEngine as an exact copy of an existing instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Memoable` | `copy()` Produce a copy of this object with its configuration and in its current state.
    `int` | `doFinal(byte[] out, int outOff)`
    `int` | `getBlockSize()`
    `int` | `getOutputSize()`
    `void` | `init(SkeinParameters params)` Initialises the Skein engine with the provided parameters.
    `void` | `reset()` Reset the engine to the initial state (with the key and any pre-message parameters , ready to accept message input.
    `void` | `reset(Memoable other)` Restore a copied object state into this object.
    `void` | `update(byte in)`
    `void` | `update(byte[] in, int inOff, int len)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SKEIN_256

          public static final int SKEIN_256

      256 bit block size - Skein 256
      See Also:
        Constant Field Values

    - #### SKEIN_512

          public static final int SKEIN_512

      512 bit block size - Skein 512
      See Also:
        Constant Field Values

    - #### SKEIN_1024

          public static final int SKEIN_1024

      1024 bit block size - Skein 1024
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SkeinEngine

          public SkeinEngine(int blockSizeBits,
                     int outputSizeBits)

      Constructs a Skein engine.
      Parameters:
        `blockSizeBits` - the internal state size in bits - one of `SKEIN_256`, `SKEIN_512` or `SKEIN_1024`.
        `outputSizeBits` - the output/digest size to produce in bits, which must be an integral number of bytes.

    - #### SkeinEngine

          public SkeinEngine(SkeinEngine engine)

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

  - ### Method Detail

    - #### copy

          public Memoable copy()

      Description copied from interface: `Memoable`
      Produce a copy of this object with its configuration and in its current state.

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

      Specified by:
        `copy` in interface `Memoable`

    - #### reset

          public void reset(Memoable other)

      Description copied from interface: `Memoable`
      Restore a copied object state into this object.

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

      Specified by:
        `reset` in interface `Memoable`
      Parameters:
        `other` - an object originally `copied` from an object of the same type as this instance.

    - #### getOutputSize

          public int getOutputSize()

    - #### getBlockSize

          public int getBlockSize()

    - #### init

          public void init(SkeinParameters params)

      Initialises the Skein engine with the provided parameters. See `SkeinParameters` for details on the parameterisation of the Skein hash function.
      Parameters:
        `params` - the parameters to apply to this engine, or `null` to use no parameters.

    - #### reset

          public void reset()

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

    - #### update

          public void update(byte in)

    - #### update

          public void update(byte[] in,
                    int inOff,
                    int len)

    - #### doFinal

          public int doFinal(byte[] out,
                    int outOff)