core: make the checksum assert more robust against illegal input.