Org.BouncyCastle.Crypto.Encodings.ISO9796d1Encoding.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,
			ICipherParameters	parameters)
		{
			RsaKeyParameters kParam;
			if (parameters is ParametersWithRandom)
			{
				ParametersWithRandom rParam = (ParametersWithRandom)parameters;
				kParam = (RsaKeyParameters)rParam.Parameters;
			}
			else
			{
				kParam = (RsaKeyParameters)parameters;
			}

			engine.Init(forEncryption, parameters);

			modulus = kParam.Modulus;
			bitSize = modulus.BitLength;

			this.forEncryption = forEncryption;
		}

Usage Example

示例#1
0
        public virtual void DoTest3()
        {
            RsaKeyParameters pubParameters = new RsaKeyParameters(false, mod2, pub2);
            RsaKeyParameters privParameters = new RsaKeyParameters(true, mod2, pri2);
            RsaEngine rsa = new RsaEngine();
            byte[] data;

            //
            // ISO 9796-1 - public encrypt, private decrypt
            //
            ISO9796d1Encoding eng = new ISO9796d1Encoding(rsa);

            eng.Init(true, privParameters);

            eng.SetPadBits(4);

            data = eng.ProcessBlock(msg3, 0, msg3.Length);

            eng.Init(false, pubParameters);

            if (!IsSameAs(sig3, 1, data))
            {
                Fail("failed ISO9796-1 generation Test 3");
            }

            data = eng.ProcessBlock(data, 0, data.Length);

            if (!IsSameAs(msg3, 0, data))
            {
                Fail("failed ISO9796-1 retrieve Test 3");
            }
        }
All Usage Examples Of Org.BouncyCastle.Crypto.Encodings.ISO9796d1Encoding::Init