def iso7816_4_pad(message, total_len):
    """
    Pads a message according as specified in ISO 7816-4:
     - Append byte 0x80
     - Pad the message to requested length with NULL bytes
    """

    if len(message) >= total_len:
        raise ValueError(
            f'Padded message is at least {len(message) + 1} bytes long'
        )
    return (message + b'\x80').ljust(total_len, b'\x00')