def increment_byte_string(bs):
    """Return the lexicographically next byte string of the same length.

    Return None if there is none (when the input is all 0xff bytes)."""
    for n in range(1, len(bs) + 1):
        if bs[-n] != 255:
            return bs[:-n] + bytes([bs[-n] + 1]) + bytes(n - 1)
    return None
