mpi: Improve gcry_mpi_invm to detect bad input.