def is_pkcs7(bs, block_size):
    """
    Determines if a byte array is pkcs7 padded.
    """
    # Length must be a multiple of the block size.
    if len(bs) % block_size != 0:
        return False

    # Last byte cannot be greater than 15 or less than 1.
    last = ord(bs[-1])
    if last < 1 or last > block_size-1 or last > len(bs):
        return False

    # Check whether all padding is the same byte.
    return len([i for i in bs[-last:] if ord(i) != last]) == 0