class ClientTlsSession {

  public AEAD handleServerHello(final byte[] msg) {
    if (clientHello == null) {
      throw new IllegalStateException("Not started");
    }

    serverHello = msg;

    final ByteBuf bb = Unpooled.wrappedBuffer(msg);
    final ServerHello hello = ServerHello.parse(bb, true);

    final SupportedVersions version =
        (SupportedVersions)
            hello
                .geExtension(ExtensionType.SUPPORTED_VERSIONS)
                .orElseThrow(IllegalArgumentException::new);
    if (!version.equals(SupportedVersions.TLS13)) {
      throw new IllegalArgumentException("Illegal version");
    }

    final KeyShare keyShareExtension =
        (KeyShare)
            hello.geExtension(ExtensionType.KEY_SHARE).orElseThrow(IllegalArgumentException::new);
    final byte[] peerPublicKey = keyShareExtension.getKey(Group.X25519).get();
    final byte[] sharedSecret = kek.generateSharedSecret(peerPublicKey);

    final byte[] helloHash = Hash.sha256(clientHello, serverHello);

    handshakeSecret = HKDF.calculateHandshakeSecret(sharedSecret);

    return HandshakeAEAD.create(handshakeSecret, helloHash, true);
  }

  public  ClientTlsSession(
      final AEAD initialAEAD,
      final TransportParameters transportParameters,
      final CertificateValidator certificateValidator);

}