summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Silverlock <matt@eatsleeprepeat.net>2015-08-08 14:16:04 +0300
committerMatt Silverlock <matt@eatsleeprepeat.net>2015-08-08 14:16:04 +0300
commit7029a2efc7c689d58e885eb12374b23c578763f9 (patch)
treebac6071e516cdd233842a4dbd767e679d679656c
parentc223d6df5316d3dc8d651d7762ba32dd867d9f69 (diff)
Improved warning around GenerateRandomKey.
-rw-r--r--securecookie.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/securecookie.go b/securecookie.go
index 7dd373d..b1cb144 100644
--- a/securecookie.go
+++ b/securecookie.go
@@ -474,6 +474,9 @@ func decode(value []byte) ([]byte, error) {
// GenerateRandomKey creates a random key with the given length in bytes.
// On failure, returns nil.
+//
+// Callers should explicitly check for the possibility of a nil return, treat
+// it as a failure of the system random number generator, and not continue.
func GenerateRandomKey(length int) []byte {
k := make([]byte, length)
if _, err := io.ReadFull(rand.Reader, k); err != nil {