def METHOD_NAME(alg, p, write_seq_num):
    """
    Provided with a TLSCompressed instance p, the function applies AEAD
    cipher alg to p.data and builds a new TLSCiphertext instance. Unlike
    for block and stream ciphers, for which the authentication step is done
    separately, AEAD alg does it simultaneously: this is the reason why
    write_seq_num is passed to the function, to be incorporated in
    authenticated data. Note that it is the caller's responsibility to increment  # noqa: E501
    write_seq_num afterwards.
    """
    P = bytes(p)
    write_seq_num = struct.pack("!Q", write_seq_num)
    A = write_seq_num + P[:5]
    c = TLSCiphertext()
    c.type = p.type
    c.version = p.version
    c.data = alg.auth_encrypt(P, A, write_seq_num)
    c.len = len(c.data)
    return c