osrandom add engine fix backported from master

This is an identical changeset to #660.