From ae23a04951780377a7d7ede6af476eaee9efa49e Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 3 Aug 2025 13:40:49 +0200 Subject: cryptocore: add note about crypto/rand.Read errors --- internal/cryptocore/nonce.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/cryptocore/nonce.go b/internal/cryptocore/nonce.go index 9df094c..c800807 100644 --- a/internal/cryptocore/nonce.go +++ b/internal/cryptocore/nonce.go @@ -11,6 +11,8 @@ func RandBytes(n int) []byte { b := make([]byte, n) _, err := rand.Read(b) if err != nil { + // crypto/rand.Read() is documented to never return an + // error, so this should never happen. Still, better safe than sorry. log.Panic("Failed to read random bytes: " + err.Error()) } return b -- cgit v1.2.3