-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto/rand: Documentation for errors #54980
Comments
CC @golang/security |
Prime does mention that its errors comes from rand.Read. It may be confusing to figure out if we're likely to have errors "because CSPRNGs inherently use system calls that may fail", or "because we're accepting any custom io.Reader in Int and Prime", or if "Reader cannot return errors, but we still want to stick to the io.Reader interface". |
In general, there is no safe non-nil error result from |
I would be in favour of having |
Cf. #66821 |
Change https://go.dev/cl/602497 mentions this issue: |
The 3 exported funcs Int, Prime, Read return an error, but the current documentation doesn't say why and when errors might occur. Also their is no guidance about how to deal with a non-nil error: would a caller-side retry policy make sense?
I suggest we write a short explanation about why errors are part of the API at all, what such errors would look like, and how to deal with them.
The text was updated successfully, but these errors were encountered: