def try_read_file(path, length):
    """Try to read the designated file with the specified length. Fill with
       zeroes if it does not exist."""
    try:
        with open(path, "rb") as f:
            bytes = f.read()

            # If the file was as long as expected, return its contents
            if len(bytes) == length:
                return bytes
    except FileNotFoundError:
        pass

    # Otherwise return zeroes
    return bytearray(length)