Exemplo n.º 1
0
        private void AddClientKeyExchange(OutgoingMessageBag outgoingMessages)
        {
            ClientKeyExchangeMessage clientKeyExchangeMessage = new ClientKeyExchangeMessage();

            byte[] premasterSecret = new byte[ClientKeyExchangeMessage.PreMasterSecretLength];
            m_rng.GetBytes(premasterSecret);

            RSACryptoServiceProvider rsa = RemoteCertificate.PublicKey.Key as RSACryptoServiceProvider;

            clientKeyExchangeMessage.EncryptedPreMasterSecret = rsa.Encrypt(premasterSecret, false);

            GenerateMasterSecret(premasterSecret);

            NetMQMessage outgoingMessage = clientKeyExchangeMessage.ToNetMQMessage();

            HashLocalAndRemote(outgoingMessage);
            outgoingMessages.AddHandshakeMessage(outgoingMessage);
            m_lastSentMessage = HandshakeType.ClientKeyExchange;
        }
Exemplo n.º 2
0
        private void AddClientKeyExchange(OutgoingMessageBag outgoingMessages)
        {
            var clientKeyExchangeMessage = new ClientKeyExchangeMessage();

            var premasterSecret = new byte[ClientKeyExchangeMessage.PreMasterSecretLength];

            m_rng.GetBytes(premasterSecret);

            using (var rsa = RemoteCertificate.GetRSAPublicKey())                                                             // .PublicKey.Key as RSA; //RSACryptoServiceProvider;
            {
                clientKeyExchangeMessage.EncryptedPreMasterSecret = rsa.Encrypt(premasterSecret, RSAEncryptionPadding.Pkcs1); // false);
            }

            GenerateMasterSecret(premasterSecret);

            NetMQMessage outgoingMessage = clientKeyExchangeMessage.ToNetMQMessage();

            HashLocalAndRemote(outgoingMessage);
            outgoingMessages.AddHandshakeMessage(outgoingMessage);
            m_lastSentMessage = HandshakeType.ClientKeyExchange;
        }