示例#1
0
        private void HandleServerKeyExchange(ReadableBuffer messageBuffer)
        {
            HandshakeHash.HashData(messageBuffer);
            var parser = new ServerKeyExchangeParser(messageBuffer);

            _signatureScheme = parser.SignatureScheme;
            _certificate.CheckSignature(_cryptoProvider.HashProvider, _signatureScheme, parser.Signature, parser.Data);
            KeyExchange.SetPeerKey(parser.Key, _certificate, _signatureScheme);
        }
示例#2
0
 private Span<byte> HandleClientKeyExchange(ReadableBuffer messageBuffer)
 {
     var span = messageBuffer.ToSpan();
     HandshakeHash.HashData(span);
     span = span.Slice(HandshakeFraming.HeaderSize);
     KeyExchange.SetPeerKey(new BigEndianAdvancingSpan(span), _certificate, _signatureScheme);
     _secretSchedule.GenerateMasterSecret(dispose: true);
     _state = HandshakeState.WaitingForChangeCipherSpec;
     return span;
 }
示例#3
0
 protected override void Dispose(bool disposing)
 {
     lock (this)
     {
         base.Dispose(disposing);
         KeyExchange?.Dispose();
         KeyExchange = null;
         _secretSchedule?.Dispose();
         _secretSchedule = null;
     }
 }
示例#4
0
        /// <summary>
        /// Finalize the key exchange, preparing the CipherSuite for actual use.
        /// </summary>
        /// <param name="peer_pk">Our peer's private key/key exchange information.</param>
        /// <returns>The raw shared secret.</returns>
        public byte[] FinalizeKeyExchange(byte[] peer_pk)
        {
            var shared = KeyExchange.FinalizeKeyExchange(peer_pk);

            HKDFAdditionalInfo = string.Format(HKDFAdditionalInfo, Cipher.HumanName, KeyExchange.HumanName);

            Cipher.Initialize(CalculateHKDF(shared, Cipher.SecretBytes));
            MAC.Initialize(CalculateHKDF(shared, MAC.SecretBytes));

            return(shared);
        }
示例#5
0
 private void HandleServerCertificate(ReadableBuffer messageBuffer)
 {
     HandshakeHash.HashData(messageBuffer);
     _certificate = Connection.Listener.CertificateList.CheckCertificate(messageBuffer);
     KeyExchange.SetCertificate(_certificate);
     if (KeyExchange.RequiresServerKeyExchange)
     {
         _state = HandshakeState.WaitingForServerKeyExchange;
     }
     else
     {
         _state = HandshakeState.WaitingForServerHelloDone;
     }
 }
示例#6
0
        public NetworkManager()
        {
            this.keyExchange = new KeyExchange();
            this.keyExchange.InitClient();

            this.worldServers     = new List <ServerInfo>();
            this.pendingFragments = new ConcurrentDictionary <uint, FragmentedPacket>();
            this.packetQueue      = new ConcurrentQueue <PacketQueueEntry>();
            this.packetReady      = new AutoResetEvent(false);

            this.networkThread = new Thread(NetworkThreadStart);

            this.World = "Disconnected";

            Instance = this;
        }
示例#7
0
        public KeyExchangeResponse DoKeyExchange()
        {
            KeyExchangeResponse response = null;

            lock (this)
            {
                if (Connect())
                {
                    Console.WriteLine("connect");
                    KeyExchange keMsg = new KeyExchange(_transactionID);
                    new PANE.ERRORLOG.Error().LogInfo("About to send key Exchange Message: " + keMsg.ToString());
                    Trx.Messaging.Message responseMessage = ProcessRequest(keMsg);
                    response = new KeyExchangeResponse(responseMessage);

                    new PANE.ERRORLOG.Error().LogInfo("Recieved Exchange Message: " + responseMessage.ToString());
                    response.TransactionID = _transactionID;
                }
                else
                {
                    Console.WriteLine("not connected");
                }
            }
            return(response);
        }
示例#8
0
 public TlsServerKeyExchange(KeyExchange keyExchange)
     : base(HandshakeType.ServerKeyExchange)
 {
     KeyExchange = keyExchange;
 }
示例#9
0
 public TlsServerKeyExchange(TlsContext context, TlsBuffer incoming)
     : base(HandshakeType.ServerKeyExchange)
 {
     KeyExchange = KeyExchange.Create(context.NegotiatedProtocol, context.Session.PendingCrypto.Cipher.ExchangeAlgorithmType);
     Read(incoming);
 }
示例#10
0
 public TlsClientKeyExchange(KeyExchange keyExchange)
     : base(HandshakeType.ClientKeyExchange)
 {
     KeyExchange = keyExchange;
 }
示例#11
0
 public TlsClientKeyExchange(TlsContext context, TlsBuffer incoming)
     : base(HandshakeType.ClientKeyExchange)
 {
     KeyExchange = KeyExchange.Create(context.Session.PendingCrypto.Cipher.ExchangeAlgorithmType);
     Read(incoming);
 }
		public TlsServerKeyExchange (KeyExchange keyExchange)
			: base (HandshakeType.ServerKeyExchange)
		{
			KeyExchange = keyExchange;
		}
示例#13
0
 public void Initialize()
 {
     KeyExchange.Initialize();
 }
示例#14
0
 public byte[] GetKeyExchangeData()
 {
     return(KeyExchange.GetPublicKey());
 }
		public TlsClientKeyExchange (KeyExchange keyExchange)
			: base (HandshakeType.ClientKeyExchange)
		{
			KeyExchange = keyExchange;
		}