System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange C# (CSharp) Method

DecryptKeyExchange() public method

public DecryptKeyExchange ( byte rgbIn ) : byte[]
rgbIn byte
return byte[]
        public override byte[] DecryptKeyExchange(byte[] rgbIn)
        {
            if (_rsaKey == null)
                throw new CryptographicUnexpectedOperationException(SR.Cryptography_MissingKey);

            return _rsaKey.Decrypt(rgbIn, RSAEncryptionPadding.Pkcs1);
        }

Usage Example

        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 ();
        }
All Usage Examples Of System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter::DecryptKeyExchange