Class SkeinEngine

java.lang.Object
org.bouncycastle.crypto.digests.SkeinEngine
All Implemented Interfaces:
Memoable

public class SkeinEngine extends 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:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    1024 bit block size - Skein 1024
    static final int
    256 bit block size - Skein 256
    static final int
    512 bit block size - Skein 512
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    Produce a copy of this object with its configuration and in its current state.
    int
    doFinal(byte[] out, int outOff)
     
    int
     
    int
     
    void
    Initialises the Skein engine with the provided parameters.
    void
    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 Details

    • SKEIN_256

      public static final int SKEIN_256
      256 bit block size - Skein 256
      See Also:
    • SKEIN_512

      public static final int SKEIN_512
      512 bit block size - Skein 512
      See Also:
    • SKEIN_1024

      public static final int SKEIN_1024
      1024 bit block size - Skein 1024
      See Also:
  • Constructor Details

    • 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 Details

    • 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)