/// <summary> /// /// </summary> /// <param name="bytes"></param> /// <param name="length"></param> protected virtual void Absorb(byte[] bytes, int length) { State.Clear(); Bitstring message = new Bitstring(bytes, length); int rate = State.Rate; message.Append(Suffix()); message.Append(GetPadding(rate, message.Length)); int n = message.Length / rate; Bitstring zeroes = new Bitstring(Capacity); Bitstring chunk; for (int i = 0; i < n; i++) { chunk = message.Substring(rate * i, rate); chunk.Append(zeroes); State.Bitstring.Xor(chunk); Function(); } }
/// <summary> /// Squeezes internal state until at least specified number of bits is produced, and returns these bits. /// </summary> /// <param name="outputLength">The number of desired output bits.</param> /// <returns>The byte array holding resulting bits.</returns> protected virtual byte[] Squeeze(int outputLength) { int rate = State.Rate; Bitstring q = new Bitstring(); while (true) { q.Append(State.Bitstring.Truncate(rate)); if (q.Length >= outputLength) { return((q.Length == outputLength) ? q.Bytes : q.Truncate(outputLength).Bytes); } Function(); } }
protected override void HashCore(byte[] array, int ibStart, int cbSize) { byte[] data = new byte[cbSize]; Array.Copy(array, ibStart, data, 0, cbSize); _hash.Append(data); }