Beispiel #1
0
	// - Test TransformFinalBlock - alone;
	public void CheckD (string testName, byte[] key, byte[] data, byte[] result) 
	{
		algo = new MACTripleDES ();
		algo.Key = key;
		// LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue !
		algo.TransformFinalBlock (data, 0, data.Length);
		AssertEquals (testName + "d", result, algo.Hash);
	}
Beispiel #2
0
	// - Test TransformBlock/TransformFinalBlock
	public void CheckE (string testName, byte[] key, byte[] data, byte[] result) 
	{
		algo = new MACTripleDES ();
		algo.Key = key;
		byte[] copy = new byte [data.Length];
		// LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue !
		for (int i=0; i < data.Length - 1; i++)
			algo.TransformBlock (data, i, 1, copy, i);
		algo.TransformFinalBlock (data, data.Length - 1, 1);
		AssertEquals (testName + "e", result, algo.Hash);
	}
		// MACTripleDES tests
#if NET_2_0
		private string MAC (PaddingMode padding, int length)
		{
			byte[] key = new byte [24] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
			MACTripleDES mac = new MACTripleDES (key);
			mac.Padding = padding;
			byte[] data = new byte [length];
			byte[] hash = mac.TransformFinalBlock (data, 0, data.Length);
			string result = BitConverter.ToString (mac.Hash);
			return result;
		}