Esempio n. 1
0
        private List <byte[]> ProcessInitiationRequest(Message message)
        {
            var frames = message.Frames;
            var list   = new List <byte[]>();

            if (frames.Count != 2)
            {
                list.Add(MessageHeader.HandshakeResponseFailure);
                list.Add(_protocol.ComputeHash(_protocol.CryptRand()));
                list.Add(_protocol.ComputeHash(_protocol.CryptRand()));
                _logger.Debug("Protocol initiation failed for {0}.", message.ClientId);
            }
            else
            {
                _clientPublicKey = frames[1].ToRSAParameters();
                using (var rsa = new RSACryptoServiceProvider())
                {
                    _serverPublicPrivateKey = rsa.ExportParameters(true);
                    _serverPublicKey        = rsa.ExportParameters(false);
                }
                list.Add(MessageHeader.InititaionResponseSuccess);
                list.Add(_serverPublicKey.ToBytes());
                _logger.Debug("Protocol initiation completed for {0}.", message.ClientId);
            }
            return(list);
        }
Esempio n. 2
0
        public List <byte[]> CreateInitiationRequest()
        {
            var list = new List <byte[]>();

            list.Add(MessageHeader.InitiationRequest);
            using (var rsa = new RSACryptoServiceProvider())
            {
                _clientPublicPrivateKey = rsa.ExportParameters(true);
                _clientPublicKey        = rsa.ExportParameters(false);
            }
            list.Add(_clientPublicKey.ToBytes());
            return(list);
        }