private bool HandleClientHello(ReadableBuffer messageBuffer) { _secretSchedule = new SecretSchedule12(this); var helloParser = new ClientHelloParser(messageBuffer, Connection); var version = GetVersion(ref helloParser); if (version != TlsVersion.Tls12) { Alerts.AlertException.ThrowAlert(Alerts.AlertLevel.Fatal, Alerts.AlertDescription.protocol_version, "Invalid protocol version"); } return HandleClientHello(ref helloParser); }
private void SendFirstFlightAbbreviated(ClientHelloParser clientHello) { WriteServerHello(clientHello.SessionId); _secretSchedule.WriteSessionTicket(); RecordHandler.WriteRecords(Connection.HandshakeOutput.Reader, RecordType.Handshake); _requiresTicket = false; WriteChangeCipherSpec(); (_storedKey, _writeKey) = _secretSchedule.GenerateKeys(); _secretSchedule.GenerateAndWriteServerVerify(); _state = HandshakeState.WaitingForClientFinishedAbbreviated; RecordHandler.WriteRecords(Connection.HandshakeOutput.Reader, RecordType.Handshake); }
public bool HandleClientHello(ref ClientHelloParser clientHello) { CipherSuite = _cryptoProvider.CipherSuites.GetCipherSuite(TlsVersion.Tls12, clientHello.CipherSuites); HandshakeHash = _cryptoProvider.HashProvider.GetHash(CipherSuite.HashType); HandshakeHash.HashData(clientHello.OriginalMessage); _certificate = Connection.Listener.CertificateList.GetCertificate(null, CipherSuite.CertificateType.Value); _secretSchedule.SetClientRandom(clientHello.ClientRandom); _negotiatedAlpn = clientHello.NegotiatedAlpn; _hostName = clientHello.HostName; KeyExchange = _cryptoProvider.KeyExchangeProvider.GetKeyExchange(CipherSuite.KeyExchange, clientHello.SupportedGroups); if (_certificate == null) { (_certificate, _signatureScheme) = Connection.Listener.CertificateList.GetCertificate(clientHello.SignatureAlgos); } else { _signatureScheme = _certificate.SelectAlgorithm(clientHello.SignatureAlgos); } if (clientHello.SessionTicket.Length > 0) { ProcessSessionTicket(clientHello.SessionTicket); } if (_abbreviatedHandshake) { SendFirstFlightAbbreviated(clientHello); } else { SendFirstFlightFull(); } return true; }