Org.BouncyCastle.Crypto.Modes.SicBlockCipher.Init C# (CSharp) Method

Init() public method

public Init ( bool forEncryption, ICipherParameters parameters ) : void
forEncryption bool
parameters ICipherParameters
return void
		public void Init(
			bool				forEncryption, //ignored by this CTR mode
			ICipherParameters	parameters)
		{
			if (parameters is ParametersWithIV)
			{
				ParametersWithIV ivParam = (ParametersWithIV) parameters;
				byte[] iv = ivParam.GetIV();
				Array.Copy(iv, 0, IV, 0, IV.Length);

                Reset();

                // if null it's an IV changed only.
                if (ivParam.Parameters != null)
                {
                    cipher.Init(true, ivParam.Parameters);
                }
			}
	        else
	        {
	            throw new ArgumentException("SIC mode requires ParametersWithIV", "parameters");
	        }
		}

Usage Example

 private SicBlockCipher CreateDecryptor(string key)
 {
     SicBlockCipher decryptor = new SicBlockCipher(aes);
     
     decryptor.Init(false, new ParametersWithIV(new KeyParameter(DecodeKey(key)), new byte[aes.GetBlockSize()]));
     
     return decryptor;
 }
All Usage Examples Of Org.BouncyCastle.Crypto.Modes.SicBlockCipher::Init