libpfrng: add extra error checking