DecryptKeyExchange() public méthode

public DecryptKeyExchange ( byte rgbIn ) : byte[]
rgbIn byte
Résultat byte[]
        protected override void ProcessAsSsl3()
        {
            AsymmetricAlgorithm privKey = null;
            ServerContext context = (ServerContext)this.Context;

            // Select the private key information
            privKey = context.SslStream.RaisePrivateKeySelection(
                new X509Certificate(context.ServerSettings.Certificates[0].RawData),
                null);

            if (privKey == null)
            {
                throw new TlsException(AlertDescription.UserCancelled, "Server certificate Private Key unavailable.");
            }

            // Read client premaster secret
            byte[] clientSecret = this.ReadBytes((int)this.Length);

            // Decrypt premaster secret
            RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(privKey);

            byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret);

            // Create master secret
            this.Context.Negotiating.Cipher.ComputeMasterSecret(preMasterSecret);

            // Create keys
	    this.Context.Negotiating.Cipher.ComputeKeys ();

            // Initialize Cipher Suite
	    this.Context.Negotiating.Cipher.InitializeCipher ();
        }
        public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
        {
            if (context.InputArc4 != null)
                return;

            if (size < 0x80)
                return;

            // Extract the first 0x80 bytes into a separate array
            var cryptedBlob = new byte[0x80];
            Array.Copy(data, position, cryptedBlob, 0, 0x80);
            Array.Reverse(cryptedBlob);

            // FIXME
            if (Client.RsaCsp == null)
            {
                Client.RsaCsp = new RSACryptoServiceProvider();
                var rsaBlob = File.ReadAllBytes("privateKey.blob");
                Client.RsaCsp.ImportCspBlob(rsaBlob);
            }

            var pkcs = new RSAPKCS1KeyExchangeDeformatter(Client.RsaCsp);
            byte[] decryptedBlob;

            try
            {
                decryptedBlob = pkcs.DecryptKeyExchange(cryptedBlob);
            }
            catch (CryptographicException ex)
            {
                Logger.WriteException("Error occured when decrypting the key exchange", ex);
                context.Socket.Close();
                return;
            }

            // Also a failure.
            if (decryptedBlob.Length < 0x20)
                return;

            // Extract the RC4 key
            var arc4Key = new byte[16];
            Array.Copy(decryptedBlob, 0x10, arc4Key, 0, 0x10);

            // Create three RC4 mungers
            var arc4 = new Arc4Managed {Key = arc4Key};
            context.InputArc4 = arc4.CreateDecryptor();

            arc4 = new Arc4Managed {Key = arc4Key};
            context.OutputArc4 = arc4.CreateEncryptor();

            arc4 = new Arc4Managed {Key = arc4Key};
            var tempDecryptor = arc4.CreateDecryptor();

            // Also, grab the init token for the client
            var decryptedToken = new byte[16];
            tempDecryptor.TransformBlock(decryptedBlob, 0, 0x10, decryptedToken, 0);

            context.SendPacket(0x11, 0xC, 0, decryptedToken);
        }
	public void CapiKeyExchange128 () 
	{
		byte[] M = { 0xd4, 0x36, 0xe9, 0x95, 0x69, 0xfd, 0x32, 0xa7, 0xc8, 0xa0, 0x5b, 0xbc, 0x90, 0xd3, 0x2c, 0x49 };
		byte[] EM = { 0x2D, 0xA3, 0xB0, 0xED, 0x1F, 0x13, 0x13, 0xBA, 0xAA, 0x26, 0xA7, 0x00, 0x76, 0x94, 0x0A, 0xDA, 0xFB, 0x4E, 0x14, 0x98, 0xD3, 0xF6, 0x26, 0x65, 0xCE, 0x7E, 0xB9, 0x23, 0xEF, 0xDE, 0x6E, 0xAB, 0x72, 0x33, 0xF3, 0x6F, 0xA9, 0x9B, 0xEC, 0x18, 0xC9, 0xB7, 0xC7, 0xE8, 0xE8, 0x55, 0xC4, 0x83, 0x1E, 0xF5, 0xDA, 0xCF, 0x5A, 0x53, 0xB0, 0x60, 0x42, 0xF4, 0x55, 0xEE, 0x00, 0x80, 0x92, 0x28, 0xA9, 0x0E, 0x2D, 0x9D, 0x49, 0x10, 0x65, 0x00, 0x21, 0x82, 0xCC, 0x05, 0xA3, 0x62, 0xAD, 0xCC, 0x5B, 0xE3, 0x8E, 0xAE, 0x01, 0x96, 0x81, 0xF6, 0x7B, 0x52, 0xB9, 0x6F, 0xE3, 0x06, 0x3A, 0x48, 0x4D, 0x87, 0xB9, 0xA3, 0xEA, 0x69, 0xD1, 0xFE, 0x8D, 0x82, 0x33, 0xE3, 0x05, 0xEB, 0x00, 0xA2, 0xA6, 0xDC, 0x95, 0xE4, 0xAC, 0x4E, 0xF4, 0x03, 0xC3, 0xFE, 0xA2, 0xE8, 0xB6, 0xBB, 0xBE, 0xD1 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void CapiKeyExchangeMin () 
	{
		byte[] M = { 0x01 };
		byte[] EM = { 0x50, 0x33, 0xF3, 0x42, 0x52, 0x59, 0x71, 0x2D, 0x6E, 0x25, 0x5E, 0x06, 0xC3, 0x27, 0x94, 0xA6, 0xD1, 0x8E, 0x13, 0x90, 0x54, 0x5C, 0x12, 0x58, 0x7A, 0xC9, 0xB6, 0x3F, 0x4D, 0x2E, 0x97, 0xCC, 0x3A, 0x94, 0x24, 0xE8, 0x11, 0x1F, 0xD6, 0x7F, 0x37, 0x36, 0xAB, 0x6F, 0x3F, 0xB4, 0x1B, 0xB8, 0x13, 0x87, 0xC8, 0xBE, 0x00, 0x24, 0x02, 0x0F, 0xF6, 0x2E, 0xEA, 0x48, 0x8A, 0x6F, 0xC8, 0xF6, 0x0B, 0xAB, 0xF4, 0x02, 0xA5, 0xE2, 0x5A, 0xAA, 0xB5, 0x9E, 0xC2, 0x6E, 0xFF, 0xA6, 0xEC, 0xEC, 0xD0, 0xA2, 0x3F, 0x00, 0x93, 0xE9, 0xF3, 0xAA, 0x08, 0xA2, 0xD2, 0x11, 0x1B, 0x3F, 0x3E, 0x59, 0xB0, 0xBA, 0x47, 0x17, 0x8F, 0xF4, 0xEB, 0x34, 0xA5, 0xC4, 0xA4, 0x09, 0x43, 0xC4, 0x7B, 0x71, 0x2C, 0x4B, 0x9E, 0x2D, 0x22, 0x96, 0xBB, 0x52, 0xDD, 0x2B, 0x59, 0xED, 0xD6, 0xCA, 0xEB, 0xE6 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeDeformatter 1", M, Mback);
	}
	public void CapiKeyExchange160 () 
	{
		byte[] M = { 0xd4, 0x36, 0xe9, 0x95, 0x69, 0xfd, 0x32, 0xa7, 0xc8, 0xa0, 0x5b, 0xbc, 0x90, 0xd3, 0x2c, 0x49, 0x00, 0x00, 0x00, 0x00 };
		byte[] EM = { 0x10, 0x79, 0x3A, 0x88, 0x04, 0x4B, 0xA5, 0x18, 0xD6, 0xCE, 0x97, 0x9B, 0xFF, 0xE8, 0xB4, 0xF5, 0x8D, 0x60, 0x07, 0xCD, 0x5F, 0x89, 0xA6, 0xCF, 0x5B, 0x90, 0x96, 0xC7, 0xF6, 0xD7, 0xF2, 0xCA, 0x7C, 0x13, 0x5A, 0x62, 0xB4, 0xED, 0xF4, 0xD7, 0x5C, 0x99, 0x4C, 0x07, 0xF4, 0x9F, 0x96, 0xE6, 0xBF, 0x2B, 0x82, 0x85, 0x38, 0x2C, 0x03, 0xBD, 0x61, 0x07, 0xF6, 0x05, 0x15, 0x55, 0xBF, 0xA9, 0x3B, 0xF5, 0x10, 0x96, 0x81, 0x01, 0x58, 0x5F, 0x61, 0x43, 0x52, 0x77, 0x71, 0x9C, 0x92, 0xEF, 0xD5, 0xE2, 0x60, 0x3F, 0x82, 0x69, 0x9F, 0xAF, 0xC2, 0xE1, 0x68, 0xB7, 0x5E, 0x62, 0xAC, 0x61, 0x6A, 0x1B, 0x46, 0x03, 0xF6, 0x7C, 0x20, 0x47, 0xF7, 0x6E, 0x7D, 0x35, 0x2A, 0xF6, 0x9C, 0xDA, 0x8A, 0xED, 0xAC, 0x1A, 0xC8, 0xF6, 0x4E, 0x7D, 0x21, 0xAC, 0x18, 0xEB, 0xA7, 0x68, 0xE0, 0xE2 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void KeyExchangeMin ()
	{
		AsymmetricKeyExchangeFormatter keyex = new RSAPKCS1KeyExchangeFormatter (key);
		byte[] M = { 0x01 };
		byte[] EM = keyex.CreateKeyExchange (M);

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
		public override void HandleClient (TlsContext ctx, KeyExchange clientExchange)
		{
			// Read client premaster secret
			var encryptedPreMaster = ((RSAKeyExchange)clientExchange).encryptedPreMasterSecret;

			if (!ctx.Configuration.HasCredentials)
				throw new TlsException (AlertDescription.BadCertificate, "Server certificate Private Key unavailable.");

			// Decrypt premaster secret
			var deformatter = new RSAPKCS1KeyExchangeDeformatter (ctx.Configuration.PrivateKey);

			using (var preMasterSecret = new SecureBuffer (deformatter.DecryptKeyExchange (encryptedPreMaster))) {
				// Create master secret
				ComputeMasterSecret (ctx, preMasterSecret);
			}
		}
	public void Bug79320 ()
	{
		string s = "hdphq/mn8goBi43YGPkmOfPj5vXjHrKPJkT4mLT3l+XzLttHMLC4/yBYkuzlXtbrl2jtAJRb6oA8UcQFalUMnCa09LDZrgNU2yySn7YbiG8raSq7u2nfDCbPu+c8T9fyHxrCHrX0zeqqImX33csIn6rIrQZ8HKcMsoQso4qtS2A=";
		byte [] bytes = Convert.FromBase64String (s);
		RSACryptoServiceProvider r = new RSACryptoServiceProvider ();
		r.FromXmlString ("<RSAKeyValue><Modulus>iSObDmmhDgrl4NiLaviFcpv4NdysBWJcqiVz3AQbPdajtXaQQ8VJdfRkixah132yKOFGCWZhHS3EuPMh8dcNwGwta2nh+m2IV6ktzI4+mZ7CSNAsmlDY0JI+H8At1vKvNArlC5jkVGuliYroJeSU/NLPLNYgspi7TtXGy9Rfug8=</Modulus><Exponent>EQ==</Exponent><P>pd4svtxrnTWXVSb151/JFgT9szI6dxQ5pAFPd4A4yuxLLEay2W2z7d9LVk5siMFhZ10uTJGWzNP5pSgLT8wdww==</P><Q>06j6m4cGRc3uoKVuFFGA19JG3Bi4tDBEQHebEc/Y3+eThrOasYIRrQmGUfqWnd9eFitO9GOaVJ0muNDV7NOxxQ==</Q><DP>OoqmYXr4zhLqHg3AM4s36adomZlBz6zJDLUrGx4yKYCTAJFsTL1OkDCxLYUXP1NPjeSm7dkIDA6UWGh8doRGvQ==</DP><DQ>PkDCLb5NI5br1OVcnJBxMGsFyEOBnmiMi2545x8DjSX+Nq1LnZ6555ljvcIsTIz9jgy83nel3KaxCS5dCWtwhQ==</DQ><InverseQ>OrFYaG7wTqim/bub4qY0CvIfhsjG4/4MEabg0UFTf/+tekKas7DDKg2TD5BS2q0O3XEt7xIfp0S6dpOAnrlyGQ==</InverseQ><D>IESc9FUW1iCuj0ICr8IBSCSy3383iMvZkXI5YPHoSskXdf3Hl3m27pPbbAVTQcM4+o9bxfn4u5JMZ8C8sV/G/8Cfl4ss1NVMbZOecvVObRqRpqXaveq5fN2X0EklH1wzm5w3O8cMXdbC/hc0gKUqaMjFVn1zpf3zVjpOkY0eGRE=</D></RSAKeyValue>");
		RSAPKCS1KeyExchangeDeformatter def = new RSAPKCS1KeyExchangeDeformatter (r);
		Assert.IsNotNull (def.DecryptKeyExchange (bytes));
	}
	public void ExchangeNoKey () 
	{
		AsymmetricKeyExchangeDeformatter keyex = new RSAPKCS1KeyExchangeDeformatter ();
		byte[] M = keyex.DecryptKeyExchange (new byte [(key.KeySize >> 3)- 11]);
	}
	public void KeyExchangeTooBig () 
	{
		AsymmetricKeyExchangeDeformatter keyex = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] EM = new byte [(key.KeySize >> 3) + 1];
		// invalid format
		byte[] M = keyex.DecryptKeyExchange (EM);
	}
        // does the reverse of Encrypt		
		static byte[] Decrypt (RSA rsa, byte[] input) 
		{
		     // by default this will create a 128 bits AES (Rijndael) object
		     SymmetricAlgorithm sa = SymmetricAlgorithm.Create ();
		
		     byte[] keyex = new byte [rsa.KeySize >> 3];
		     Buffer.BlockCopy (input, 0, keyex, 0, keyex.Length);
		
		     RSAPKCS1KeyExchangeDeformatter def = new RSAPKCS1KeyExchangeDeformatter (rsa);
		     byte[] key = def.DecryptKeyExchange (keyex);
		
		     byte[] iv = new byte [sa.IV.Length];
		     Buffer.BlockCopy (input, keyex.Length, iv, 0, iv.Length);
		
		     ICryptoTransform ct = sa.CreateDecryptor (key, iv);
		     byte[] decrypt = ct.TransformFinalBlock (input, keyex.Length + iv.Length, input.Length - (keyex.Length + iv.Length));
		     return decrypt;
		}	
Exemple #12
0
        // decrypts the supplied data using an RSA key and specifies whether we want to use OAEP 
        // padding or PKCS#1 v1.5 padding as described in the PKCS specification
        public static byte[] DecryptKey (byte[] keyData, RSA rsa, bool useOAEP) {
            if (keyData == null)
                throw new ArgumentNullException("keyData");
            if (rsa == null)
                throw new ArgumentNullException("rsa");

            if (useOAEP) {
                RSAOAEPKeyExchangeDeformatter rsaDeformatter = new RSAOAEPKeyExchangeDeformatter(rsa);
                return rsaDeformatter.DecryptKeyExchange(keyData);
            } else {
                RSAPKCS1KeyExchangeDeformatter rsaDeformatter = new RSAPKCS1KeyExchangeDeformatter(rsa);
                return rsaDeformatter.DecryptKeyExchange(keyData);
            }
        }
	public void MonoKeyExchange128 () 
	{
		byte[] M = { 0xd4, 0x36, 0xe9, 0x95, 0x69, 0xfd, 0x32, 0xa7, 0xc8, 0xa0, 0x5b, 0xbc, 0x90, 0xd3, 0x2c, 0x49 };
		byte[] EM = { 0xAA, 0x95, 0x6D, 0x40, 0xA7, 0x26, 0x23, 0x4E, 0xA9, 0xCB, 0x83, 0x55, 0xCE, 0x2F, 0xDD, 0x80, 0xEA, 0xC8, 0x61, 0x25, 0x57, 0xF9, 0x86, 0x46, 0x2E, 0xD9, 0xAD, 0xA1, 0x90, 0x22, 0x6A, 0x1F, 0xCF, 0x24, 0x9D, 0x3A, 0x65, 0x75, 0xF6, 0x9E, 0xBD, 0xC0, 0xBB, 0x8F, 0xC0, 0xC3, 0x20, 0x45, 0xC9, 0x8C, 0x5F, 0xEA, 0xF9, 0xE3, 0x1E, 0x95, 0xA0, 0xAD, 0xD6, 0xB6, 0x3C, 0x9B, 0x03, 0x9F, 0xB0, 0x57, 0x32, 0x2F, 0x98, 0x0E, 0x94, 0x8C, 0x6E, 0xA7, 0x9F, 0x40, 0xCF, 0xAD, 0x6E, 0xDB, 0x38, 0x9F, 0xF5, 0x43, 0xD1, 0x70, 0xF9, 0xCA, 0x3A, 0x2E, 0x0B, 0xB9, 0x34, 0x12, 0x0F, 0x09, 0x5B, 0x6B, 0xB9, 0xFD, 0x7E, 0xC6, 0xFC, 0xA1, 0x9A, 0x48, 0xEA, 0x3A, 0xED, 0x77, 0x24, 0xA5, 0x3B, 0x8B, 0xFB, 0xF1, 0x2B, 0x9D, 0xED, 0x0A, 0xB5, 0x05, 0xDC, 0x59, 0xA8, 0x1F, 0x17, 0xC9 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void MonoKeyExchangeMin () 
	{
		byte[] M = { 0x01 };
		byte[] EM = { 0x73, 0x34, 0xAF, 0xE5, 0x45, 0x53, 0x4A, 0x93, 0x25, 0x77, 0x6F, 0x80, 0x06, 0xAD, 0x7C, 0x87, 0xB9, 0xE8, 0x1E, 0x5C, 0xBB, 0x9B, 0x3F, 0xDC, 0x9C, 0x65, 0x71, 0xE6, 0x50, 0x82, 0xDC, 0x77, 0x6C, 0x6B, 0xA6, 0x39, 0x18, 0x0B, 0x33, 0x54, 0x4E, 0x65, 0x32, 0x6C, 0x53, 0x70, 0x9B, 0xEA, 0x7C, 0x83, 0x0D, 0xBF, 0x8B, 0x48, 0x5B, 0x0F, 0xCB, 0x27, 0x7D, 0x8D, 0x18, 0xD7, 0xA5, 0x13, 0x33, 0x3C, 0xC8, 0xB0, 0xF4, 0x12, 0x52, 0x24, 0x3C, 0x2A, 0xD2, 0xDF, 0x7C, 0x0B, 0xCB, 0x7C, 0x26, 0x28, 0x5F, 0x88, 0x1E, 0x22, 0x98, 0x68, 0x04, 0x12, 0x6E, 0x9F, 0x2D, 0xFE, 0x7A, 0xEF, 0xC3, 0x9D, 0x87, 0x44, 0x46, 0xCA, 0xA2, 0x81, 0xF2, 0xE7, 0xBA, 0x9D, 0x17, 0x68, 0x96, 0xA2, 0x3F, 0xB3, 0xB4, 0x43, 0x34, 0x2D, 0x7D, 0x56, 0xF5, 0xFC, 0x40, 0xEB, 0x31, 0xB0, 0x0C, 0x99 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeDeformatter 1", M, Mback);
	}
	public void KeyExchange128bits ()
	{
		AsymmetricKeyExchangeFormatter keyex = new RSAPKCS1KeyExchangeFormatter (key);
		byte[] M = { 0xd4, 0x36, 0xe9, 0x95, 0x69, 0xfd, 0x32, 0xa7, 0xc8, 0xa0, 0x5b, 0xbc, 0x90, 0xd3, 0x2c, 0x49 };
		byte[] EM = keyex.CreateKeyExchange (M, typeof (Rijndael));

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void KeyExchangeMax()
	{
		AsymmetricKeyExchangeFormatter keyex = new RSAPKCS1KeyExchangeFormatter (key);
		byte[] M = new byte [(key.KeySize >> 3)- 11];
		byte[] EM = keyex.CreateKeyExchange (M);

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void CapiKeyExchangeMax () 
	{
		byte[] M = new byte [(key.KeySize >> 3)- 11];
		byte[] EM = { 0x4B, 0x3F, 0x77, 0xE1, 0xA0, 0x6C, 0xD9, 0xFA, 0x19, 0x69, 0x21, 0xC4, 0x67, 0x2B, 0x0F, 0x2A, 0x0E, 0xCB, 0xAF, 0xAD, 0x08, 0xA5, 0xD2, 0x9B, 0xDC, 0x04, 0xDE, 0x8F, 0x13, 0xE4, 0x81, 0x25, 0xAF, 0xC5, 0x82, 0x51, 0xA9, 0x39, 0xAF, 0x82, 0xFF, 0xC7, 0x4F, 0x04, 0xE4, 0x21, 0xAC, 0xEE, 0x2F, 0x44, 0x78, 0x11, 0x29, 0x74, 0x3F, 0x74, 0xC1, 0x38, 0xC5, 0x43, 0x29, 0x2F, 0x0C, 0x7B, 0xDB, 0x2E, 0xE5, 0xA8, 0x6A, 0xEE, 0x6A, 0x14, 0xCC, 0x4E, 0x53, 0x8C, 0x0C, 0xEE, 0x23, 0x24, 0xDC, 0x9B, 0x75, 0x7C, 0xAD, 0x0C, 0xAC, 0x13, 0xC5, 0x02, 0x9E, 0x5D, 0x65, 0x76, 0xCB, 0xD4, 0xBF, 0x70, 0x43, 0xBE, 0x28, 0x67, 0x3F, 0x5D, 0x93, 0x38, 0x67, 0x4B, 0x25, 0x59, 0xF7, 0x8E, 0x4F, 0xCE, 0x2B, 0x2F, 0xA7, 0x4C, 0x68, 0x4C, 0xCC, 0x5F, 0xF3, 0x0A, 0xB7, 0xAA, 0x54, 0x7C };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
	public void MonoKeyExchange160 () 
	{
		byte[] M = { 0xd4, 0x36, 0xe9, 0x95, 0x69, 0xfd, 0x32, 0xa7, 0xc8, 0xa0, 0x5b, 0xbc, 0x90, 0xd3, 0x2c, 0x49, 0x00, 0x00, 0x00, 0x00 };
		byte[] EM = { 0x31, 0x2B, 0x21, 0x0F, 0x1D, 0x75, 0xCE, 0xDF, 0x00, 0xC4, 0xC2, 0x50, 0x59, 0x13, 0xDA, 0xF4, 0xE4, 0x73, 0xD3, 0x26, 0xC7, 0xBD, 0xAF, 0xDC, 0x73, 0xB1, 0xC0, 0x32, 0xE3, 0xE9, 0x91, 0x4C, 0x1F, 0x74, 0x29, 0x8C, 0xD6, 0xFD, 0x4C, 0x8C, 0xD2, 0x30, 0xED, 0xEF, 0x97, 0xF1, 0x91, 0xFF, 0xD8, 0x3D, 0x04, 0xD2, 0x2D, 0xB7, 0x20, 0x25, 0x1D, 0x47, 0xBA, 0xEA, 0x3D, 0xE2, 0x7D, 0x9C, 0x41, 0x0C, 0x5C, 0x63, 0xBC, 0xB7, 0xFA, 0xDD, 0x30, 0x19, 0x3E, 0xD2, 0x5F, 0x1B, 0xBC, 0x59, 0x0A, 0x54, 0x0A, 0xE0, 0x82, 0x5D, 0x05, 0xA4, 0xDC, 0x23, 0x71, 0x33, 0x84, 0x68, 0xDA, 0x8C, 0x7A, 0x23, 0x2E, 0x16, 0x28, 0x3E, 0x43, 0x24, 0x30, 0x69, 0xD4, 0x43, 0x7F, 0x82, 0xA8, 0xAC, 0xFF, 0xCC, 0xA6, 0x62, 0x20, 0x61, 0x5F, 0x03, 0xEE, 0x7C, 0x9E, 0x5C, 0xB2, 0xA0, 0xE4, 0xC6 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}
        /// <inheritdoc />
        protected internal override byte[] Decrypt(byte[] data, byte[] iv)
        {
            AsymmetricKeyExchangeDeformatter keyExchange;
            switch (this.Algorithm)
            {
                case AsymmetricAlgorithm.RsaOaepSha1:
                case AsymmetricAlgorithm.RsaOaepSha256:
                case AsymmetricAlgorithm.RsaOaepSha384:
                case AsymmetricAlgorithm.RsaOaepSha512:
                    keyExchange = new RSAOAEPKeyExchangeDeformatter(this.Rsa);
                    break;
                case AsymmetricAlgorithm.RsaPkcs1:
                    keyExchange = new RSAPKCS1KeyExchangeDeformatter(this.Rsa);
                    break;
                default:
                    throw new NotSupportedException();
            }

            return keyExchange.DecryptKeyExchange(data);
        }
	public void MonoKeyExchangeMax () 
	{
		byte[] M = new byte [(key.KeySize >> 3)- 11];
		byte[] EM = { 0xB4, 0x17, 0xE4, 0x8A, 0x14, 0xB1, 0x9B, 0x08, 0xBE, 0xBF, 0xD3, 0xD1, 0xCD, 0xE5, 0xB1, 0x0D, 0x38, 0x08, 0x01, 0x31, 0x10, 0xDA, 0x8A, 0xB9, 0xE9, 0x4E, 0x2F, 0x94, 0x2F, 0x40, 0x36, 0x04, 0x57, 0x54, 0xAC, 0x22, 0xC1, 0x6B, 0x35, 0x10, 0xF9, 0xA9, 0xEA, 0x36, 0xC9, 0x13, 0x84, 0x95, 0xCB, 0xDE, 0x9C, 0x01, 0x66, 0x32, 0x01, 0xA1, 0xB2, 0xDB, 0x4F, 0x11, 0x10, 0x2D, 0x13, 0x36, 0x52, 0x30, 0x78, 0x65, 0x00, 0x7A, 0xD8, 0x5B, 0x47, 0xA6, 0x19, 0x9C, 0xFA, 0x76, 0x1A, 0x44, 0x92, 0x3E, 0xE3, 0x5A, 0x0B, 0x56, 0x4D, 0x2D, 0x54, 0x7B, 0x07, 0x5C, 0xA7, 0x14, 0x86, 0x52, 0x0A, 0x8F, 0x11, 0xE2, 0x32, 0xED, 0x3C, 0x21, 0xF8, 0x56, 0x0D, 0x38, 0xAC, 0x24, 0x4A, 0x32, 0xB3, 0x4F, 0xA3, 0xB1, 0x02, 0xC7, 0x8A, 0x22, 0xE6, 0x9C, 0x78, 0xEB, 0x98, 0x4B, 0x92, 0x24 };

		AsymmetricKeyExchangeDeformatter keyback = new RSAPKCS1KeyExchangeDeformatter (key);
		byte[] Mback = keyback.DecryptKeyExchange (EM);
		AssertEquals ("RSAPKCS1KeyExchangeFormatter 1", M, Mback);
	}