public static void ReadServerHello(ReadableBuffer readable, IConnectionStateTls13 connectionState) { var original = readable; ushort version, cipherCode; readable = readable.Slice(HandshakeProcessor.HandshakeHeaderSize); readable = readable.SliceBigEndian(out version); //skip random readable = readable.Slice(RandomLength); readable = readable.SliceBigEndian(out cipherCode); connectionState.CipherSuite = connectionState.CryptoProvider.GetCipherSuiteFromCode(cipherCode, connectionState.Version); if (connectionState.CipherSuite == null) { Alerts.AlertException.ThrowAlert(Alerts.AlertLevel.Fatal, Alerts.AlertDescription.illegal_parameter, "Could not get a cipher suite during server hello"); } connectionState.StartHandshakeHash(original); readable = BufferExtensions.SliceVector <ushort>(ref readable); ExtensionType ext; readable = readable.SliceBigEndian(out ext); if (ext != ExtensionType.key_share) { Alerts.AlertException.ThrowAlert(Alerts.AlertLevel.Fatal, Alerts.AlertDescription.illegal_parameter, "There was no keyshare on the server hello"); } readable = BufferExtensions.SliceVector <ushort>(ref readable); NamedGroup group; readable = readable.SliceBigEndian(out group); if (group != connectionState.KeyShare.NamedGroup) { Alerts.AlertException.ThrowAlert(Alerts.AlertLevel.Fatal, Alerts.AlertDescription.illegal_parameter, "The named group didn't match the keyshare during server hello"); } readable = BufferExtensions.SliceVector <ushort>(ref readable); connectionState.KeyShare.SetPeerKey(readable); }