correctly check RAND_bytes error code

See http://jbp.io/2014/01/16/openssl-rand-api/ (4. Recommendations and patches)