From 3ab2c040c460400f45fbb548aa533c000a430a38 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 13 Jun 2024 18:21:14 +0000 Subject: [PATCH] can just check the time instead of a new seeded bool --- crypto/rand/prng.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crypto/rand/prng.go b/crypto/rand/prng.go index 9349f12a5..3ca9a625d 100644 --- a/crypto/rand/prng.go +++ b/crypto/rand/prng.go @@ -46,7 +46,6 @@ type PRNG struct { cipher chacha20.Cipher read int t time.Time - seeded bool } // NewPRNG returns a seeded PRNG. @@ -64,10 +63,9 @@ func NewPRNG() (*PRNG, error) { // Only returns an error during initial seeding if a crypto/rand read errors. func (p *PRNG) seed() error { _, err := cryptorand.Read(p.key[:]) - if err != nil && !p.seeded { + if err != nil && p.t.IsZero() { return err } - p.seeded = true p.cipher.XORKeyStream(p.key[:], p.key[:]) // never errors with correct key and nonce sizes