Check rand

Checking the return value of rand.Read in case of err.