예제 #1
0
        private void PerformTest()
        {
            _engine.Init(true, _key);

            byte[] outBytes = new byte[_input.Length];

            Array.Copy(_input, 0, outBytes, 0, outBytes.Length);

            for (int i = 0; i != _iterations; i++)
            {
                _engine.ProcessBlock(outBytes, 0, outBytes, 0);
            }

            if (!outBytes.SequenceEqual(_output))
            {
                throw new Exception("Arrays are not equal!");
            }

            _engine.Init(false, _key);

            for (int i = 0; i != _iterations; i++)
            {
                _engine.ProcessBlock(outBytes, 0, outBytes, 0);
            }

            if (!outBytes.SequenceEqual(_input))
            {
                throw new Exception("Arrays are not equal!");
            }
        }
예제 #2
0
        private byte[] DecryptAesFast(byte[] Key, byte[] Data)
        {
            int blocks = Data.Length / 16;
            byte[] outputData = new byte[Data.Length];

            AesFastEngine transform = new AesFastEngine();
            transform.Init(false, Key);

            for (int i = 0; i < blocks; i++)
                transform.ProcessBlock(Data, i * 16, outputData, i * 16);

            return outputData;
        }
예제 #3
0
        private byte[] EncryptAesFast(byte[] Key, byte[] Data)
        {
            int blocks = Data.Length / 16;

            byte[] outputData = new byte[Data.Length];

            AesFastEngine transform = new AesFastEngine();

            transform.Init(true, Key);

            for (int i = 0; i < blocks; i++)
            {
                transform.ProcessBlock(Data, i * 16, outputData, i * 16);
            }

            return(outputData);
        }
예제 #4
0
        /// <summary>
        /// Creates a new instance of the mabi cipher
        /// </summary>
        /// <param name="forEncryption">True if the cipher will be used to encrypt data, false otherwise</param>
        /// <param name="key">The key, in little endian form</param>
        public MabiAesEngine(bool forEncryption, byte[] key)
        {
            _aesEngine = new AesFastEngine();

            _aesEngine.Init(forEncryption, key);
        }
예제 #5
0
 public SeededGenerator(byte[] key)
 {
     _engine.Init(true, new KeyParameter(key));
     MakeBytes();
 }
예제 #6
0
		/// <summary>
		/// Creates a new instance of the mabi cipher
		/// </summary>
		/// <param name="forEncryption">True if the cipher will be used to encrypt data, false otherwise</param>
		/// <param name="key">The key, in little endian form</param>
		public MabiAesEngine(bool forEncryption, byte[] key)
		{
			_aesEngine = new AesFastEngine();

			_aesEngine.Init(forEncryption, key);
		}