Org.BouncyCastle.Crypto.Engines.VmpcEngine.ProcessBytes C# (CSharp) Метод

ProcessBytes() публичный Метод

public ProcessBytes ( byte input, int inOff, int len, byte output, int outOff ) : void
input byte
inOff int
len int
output byte
outOff int
Результат void
        public virtual void ProcessBytes(
            byte[]	input,
            int		inOff,
            int		len,
            byte[]	output,
            int		outOff)
        {
            if ((inOff + len) > input.Length)
            {
                throw new DataLengthException("input buffer too short");
            }

            if ((outOff + len) > output.Length)
            {
                throw new DataLengthException("output buffer too short");
            }

            for (int i = 0; i < len; i++)
            {
                s = P[(s + P[n & 0xff]) & 0xff];
                byte z = P[(P[(P[s & 0xff]) & 0xff] + 1) & 0xff];
                // encryption
                byte temp = P[n & 0xff];
                P[n & 0xff] = P[s & 0xff];
                P[s & 0xff] = temp;
                n = (byte) ((n + 1) & 0xff);

                // xor
                output[i + outOff] = (byte) (input[i + inOff] ^ z);
            }
        }

Usage Example

Пример #1
0
		public override void PerformTest()
		{
			byte[] key = Hex.Decode("9661410AB797D8A9EB767C21172DF6C7");
			byte[] iv = Hex.Decode("4B5C2F003E67F39557A8D26F3DA2B155");
			ICipherParameters kp = new KeyParameter(key);
			ICipherParameters kpwiv = new ParametersWithIV(kp, iv);

			VmpcEngine engine = new VmpcEngine();

			try
			{
				engine.Init(true, kp);
				Fail("Init failed to throw expected exception");
			}
			catch (ArgumentException)
			{
				// Expected
			}

			engine.Init(true, kpwiv);
			checkEngine(engine);

			engine.Reset();
			byte[] output = checkEngine(engine);

			engine.Init(false, kpwiv);
			byte[] recovered = new byte[output.Length];
			engine.ProcessBytes(output, 0, output.Length, recovered, 0);

			if (!Arrays.AreEqual(input, recovered))
			{
				Fail("decrypted bytes differ from original bytes");
			}
		}
All Usage Examples Of Org.BouncyCastle.Crypto.Engines.VmpcEngine::ProcessBytes