Org.BouncyCastle.Crypto.Digests.WhirlpoolDigest.finish C# (CSharp) Method

finish() private method

private finish ( ) : void
return void
		private void finish()
		{
			/*
				* this makes a copy of the current bit length. at the expense of an
				* object creation of 32 bytes rather than providing a _stopCounting
				* boolean which was the alternative I could think of.
				*/
			byte[] bitLength = copyBitLength();

			_buffer[_bufferPos++] |= 0x80;

			if (_bufferPos == _buffer.Length)
			{
				processFilledBuffer();
			}

			/*
				* Final block contains
				* [ ... data .... ][0][0][0][ length ]
				*
				* if [ length ] cannot fit.  Need to create a new block.
				*/
			if (_bufferPos > 32)
			{
				while (_bufferPos != 0)
				{
					Update((byte)0);
				}
			}

			while (_bufferPos <= 32)
			{
				Update((byte)0);
			}

			// copy the length information to the final 32 bytes of the
			// 64 byte block....
			Array.Copy(bitLength, 0, _buffer, 32, bitLength.Length);

			processFilledBuffer();
		}