Compress p (a TLSPlaintext instance) using compression algorithm instance
    alg and return a TLSCompressed instance.

def _tls_compress(alg, p):
    """
    Compress p (a TLSPlaintext instance) using compression algorithm instance
    alg and return a TLSCompressed instance.
    """
    c = TLSCompressed()
    c.type = p.type
    c.version = p.version
    c.data = alg.compress(p.data)
    c.len = len(c.data)
    return c