From 1651dbed4064605b6ebd0d4258a31ad24952b39b Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Sat, 29 Apr 2023 10:47:32 -0400 Subject: [PATCH] ndp: switch math/rand for crypto/rand Signed-off-by: Matt Layher --- option.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/option.go b/option.go index 869cf30..bec3007 100644 --- a/option.go +++ b/option.go @@ -2,13 +2,13 @@ package ndp import ( "bytes" + "crypto/rand" "crypto/subtle" "encoding/binary" "encoding/hex" "errors" "fmt" "io" - "math/rand" "net" "net/netip" "net/url" @@ -777,7 +777,9 @@ func NewNonce() *Nonce { // recognizes as of kernel 5.17. const n = 6 b := make([]byte, n) - _, _ = rand.Read(b) + if _, err := rand.Read(b); err != nil { + panicf("ndp: failed to generate nonce bytes: %v", err) + } return &Nonce{b: b} }