#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR) #pragma warning disable using System; using System.Collections; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests { /// /// Implementation of the Skein parameterised hash function 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. /// /// /// public class SkeinDigest : IDigest, IMemoable { ///

/// 256 bit block size - Skein-256 /// public const int SKEIN_256 = SkeinEngine.SKEIN_256; /// /// 512 bit block size - Skein-512 /// public const int SKEIN_512 = SkeinEngine.SKEIN_512; /// /// 1024 bit block size - Skein-1024 /// public const int SKEIN_1024 = SkeinEngine.SKEIN_1024; private readonly SkeinEngine engine; /// /// Constructs a Skein digest with an internal state size and output size. /// /// the internal state size in bits - one of or /// . /// the output/digest size to produce in bits, which must be an integral number of /// bytes. public SkeinDigest(int stateSizeBits, int digestSizeBits) { this.engine = new SkeinEngine(stateSizeBits, digestSizeBits); Init(null); } public SkeinDigest(SkeinDigest digest) { this.engine = new SkeinEngine(digest.engine); } public void Reset(IMemoable other) { SkeinDigest d = (SkeinDigest)other; engine.Reset(d.engine); } public IMemoable Copy() { return new SkeinDigest(this); } public String AlgorithmName { get { return "Skein-" + (engine.BlockSize * 8) + "-" + (engine.OutputSize * 8); } } public int GetDigestSize() { return engine.OutputSize; } public int GetByteLength() { return engine.BlockSize; } /// /// Optionally initialises the Skein digest with the provided parameters. /// /// See for details on the parameterisation of the Skein hash function. /// the parameters to apply to this engine, or null to use no parameters. public void Init(SkeinParameters parameters) { engine.Init(parameters); } public void Reset() { engine.Reset(); } public void Update(byte inByte) { engine.Update(inByte); } public void BlockUpdate(byte[] inBytes, int inOff, int len) { engine.Update(inBytes, inOff, len); } public int DoFinal(byte[] outBytes, int outOff) { return engine.DoFinal(outBytes, outOff); } } } #pragma warning restore #endif