Org.BouncyCastle.Crypto.Engines.AesEngine.Init C# (CSharp) Метод

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

public Init ( bool forEncryption, ICipherParameters parameters ) : void
forEncryption bool
parameters ICipherParameters
Результат void
		public void Init(
			bool				forEncryption,
			ICipherParameters	parameters)
		{
			KeyParameter keyParameter = parameters as KeyParameter;

			if (keyParameter == null)
				throw new ArgumentException("invalid parameter passed to AES init - " + parameters.GetType().Name);

			WorkingKey = GenerateWorkingKey(keyParameter.GetKey(), forEncryption);

			this.forEncryption = forEncryption;
		}

Usage Example

Пример #1
0
        public byte[] TransformKey(byte[] transformSeed, int rounds)
        {
            var block = BufferEx.Clone(_hash);

            var cipher = new AesEngine();
            cipher.Init(true, new KeyParameter(transformSeed));

            var aesEcb = SymmetricKeyAlgorithmProvider
                .OpenAlgorithm(SymmetricAlgorithmNames.AesEcb);
            var key = aesEcb.CreateSymmetricKey(
                CryptographicBuffer.CreateFromByteArray(transformSeed));

            for (int i = 0; i < rounds; i++)
            {
                cipher.ProcessBlock(block, 0, block, 0);
                cipher.ProcessBlock(block, 16, block, 16);
            }

            return BufferEx.GetHash(block);
        }
All Usage Examples Of Org.BouncyCastle.Crypto.Engines.AesEngine::Init