Org.BouncyCastle.Crypto.Engines.IsaacEngine.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 void ProcessBytes(
            byte[]	input, 
            int		inOff, 
            int		len, 
            byte[]	output, 
            int		outOff)
        {
            if (!initialised)
                throw new InvalidOperationException(AlgorithmName + " not initialised");
            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++)
            {
                if (index == 0) 
                {
                    isaac();
                    keyStream = Pack.UInt32_To_BE(results);
                }
                output[i+outOff] = (byte)(keyStream[index]^input[i+inOff]);
                index = (index + 1) & 1023;
            }
        }

Usage Example

Пример #1
0
		private void doTest(
			IsaacEngine	engine,
			byte[]		key,
			byte[]		output)
		{
			byte[] input = new byte[output.Length];
			byte[] enc = new byte[output.Length];
			engine.Init(true, new KeyParameter(key));
			engine.ProcessBytes(input, 0, input.Length, enc, 0);
			if (!AreEqual(enc, output))
			{
				Fail("ciphertext mismatch");
			}
			engine.Init(false, new KeyParameter(key));
			engine.ProcessBytes(enc, 0, enc.Length, enc, 0);
			if (!AreEqual(enc, input))
			{
				Fail("plaintext mismatch");
			}
		}