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); }
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; }
protected override void Dispose(bool disposing) { lock (this) { base.Dispose(disposing); KeyExchange?.Dispose(); KeyExchange = null; _secretSchedule?.Dispose(); _secretSchedule = null; } }
/// <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); }
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; } }
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; }
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); }
public TlsServerKeyExchange(KeyExchange keyExchange) : base(HandshakeType.ServerKeyExchange) { KeyExchange = keyExchange; }
public TlsServerKeyExchange(TlsContext context, TlsBuffer incoming) : base(HandshakeType.ServerKeyExchange) { KeyExchange = KeyExchange.Create(context.NegotiatedProtocol, context.Session.PendingCrypto.Cipher.ExchangeAlgorithmType); Read(incoming); }
public TlsClientKeyExchange(KeyExchange keyExchange) : base(HandshakeType.ClientKeyExchange) { KeyExchange = keyExchange; }
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; }
public void Initialize() { KeyExchange.Initialize(); }
public byte[] GetKeyExchangeData() { return(KeyExchange.GetPublicKey()); }
public TlsClientKeyExchange (KeyExchange keyExchange) : base (HandshakeType.ClientKeyExchange) { KeyExchange = keyExchange; }