ProcessBytes() public method

public ProcessBytes ( byte inBytes, int inOff, int len, byte outBytes, int outOff ) : void
inBytes byte
inOff int
len int
outBytes byte
outOff int
return void
Esempio n. 1
0
		private void salsa20Test2(
			ICipherParameters	parameters,
			string				v0,
			string				v65472,
			string				v65536)
		{
			IStreamCipher salsa = new Salsa20Engine();
			byte[]       buf = new byte[64];

			salsa.Init(true, parameters);

			for (int i = 0; i != 1025; i++)
			{
				salsa.ProcessBytes(zeroes, 0, 64, buf, 0);
				switch (i)
				{
				case 0:
					if (!AreEqual(buf, Hex.Decode(v0)))
					{
						mismatch("v0", v0, buf);
					}
					break;
				case 1023:
					if (!AreEqual(buf, Hex.Decode(v65472)))
					{
						mismatch("v65472", v65472, buf);
					}
					break;
				case 1024:
					if (!AreEqual(buf, Hex.Decode(v65536)))
					{
						mismatch("v65536", v65536, buf);
					}
					break;
				default:
					// ignore
					break;
				}
			}
		}
Esempio n. 2
0
		private void salsa20Test1(
			int rounds,
			ICipherParameters	parameters,
			string				v0,
			string				v192,
			string				v256,
			string				v448)
		{
			IStreamCipher salsa = new Salsa20Engine(rounds);
			byte[]       buf = new byte[64];

			salsa.Init(true, parameters);

			for (int i = 0; i != 7; i++)
			{
				salsa.ProcessBytes(zeroes, 0, 64, buf, 0);
				switch (i)
				{
				case 0:
					if (!AreEqual(buf, Hex.Decode(v0)))
					{
						mismatch("v0/" + rounds, v0, buf);
					}
					break;
				case 3:
					if (!AreEqual(buf, Hex.Decode(v192)))
					{
						mismatch("v192/" + rounds, v192, buf);
					}
					break;
				case 4:
					if (!AreEqual(buf, Hex.Decode(v256)))
					{
						mismatch("v256/" + rounds, v256, buf);
					}
					break;
				default:
					// ignore
					break;
				}
			}

			for (int i = 0; i != 64; i++)
			{
				buf[i] = salsa.ReturnByte(zeroes[i]);
			}

			if (!AreEqual(buf, Hex.Decode(v448)))
			{
				mismatch("v448", v448, buf);
			}       
		}