def tagToByte(value):
    """
    Converts an ASN1 Tag into the corresponding byte representation
    :param value: The tag to convert
    :return: The integer array
    """

    if value <= 0xff:
        return [value]

    elif value <= 0xffff:
        return [(value >> 8), (value & 0xff)]

    elif value <= 0xffffff:
        return [(value >> 16), ((value >> 8) & 0xff), (value & 0xff)]

    elif value <= 0xffffffff:
        return [(value >> 24), ((value >> 16) & 0xff), ((value >> 8) & 0xff), (value & 0xff)]

    raise Exception("tagToByte: tag is too big")