예제 #1
0
        private void CheckReset(IStreamCipher cipher, ICipherParameters cipherParams,
                                bool encrypt, byte[] pretext, byte[] posttext)
        {
            // Do initial run
            byte[] output = new byte[posttext.Length];
            cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);

            // Check encrypt resets cipher
            cipher.Init(encrypt, cipherParams);

            try
            {
                cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);
            }
            catch (Exception e)
            {
                Fail(cipher.AlgorithmName + " init did not reset: " + e.Message);
            }
            if (!Arrays.AreEqual(output, posttext))
            {
                Fail(cipher.AlgorithmName + " init did not reset.", Hex.ToHexString(posttext), Hex.ToHexString(output));
            }

            // Check reset resets data
            cipher.Reset();

            try
            {
                cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);
            }
            catch (Exception e)
            {
                Fail(cipher.AlgorithmName + " reset did not reset: " + e.Message);
            }
            if (!Arrays.AreEqual(output, posttext))
            {
                Fail(cipher.AlgorithmName + " reset did not reset.");
            }
        }
예제 #2
0
		public override void Reset()
		{
			cipher.Reset();
		}
예제 #3
0
        private void CheckReset(IStreamCipher cipher, ICipherParameters cipherParams,
            bool encrypt, byte[] pretext, byte[] posttext)
        {
            // Do initial run
            byte[] output = new byte[posttext.Length];
            cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);

            // Check encrypt resets cipher
            cipher.Init(encrypt, cipherParams);

            try
            {
                cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);
            }
            catch (Exception e)
            {
                Fail(cipher.AlgorithmName + " init did not reset: " + e.Message);
            }
            if (!Arrays.AreEqual(output, posttext))
            {
                Fail(cipher.AlgorithmName + " init did not reset.", Hex.ToHexString(posttext), Hex.ToHexString(output));
            }

            // Check reset resets data
            cipher.Reset();

            try
            {
                cipher.ProcessBytes(pretext, 0, pretext.Length, output, 0);
            }
            catch (Exception e)
            {
                Fail(cipher.AlgorithmName + " reset did not reset: " + e.Message);
            }
            if (!Arrays.AreEqual(output, posttext))
            {
                Fail(cipher.AlgorithmName + " reset did not reset.");
            }
        }