def _encode_identifier(asn1_class, constructed, tag):
    """Encode a DER object's identifier"""
    flags = asn1_class << 6 | (32 if constructed else 0)
    if tag < 32:
        identifier = [flags | tag]
    else:
        identifier = [tag & 127]
        while tag >= 128:
            tag >>= 7
            identifier.append(128 | tag & 127)
        identifier.append(flags | 31)
    return bytes(identifier[::-1])
