Skip to content

Commit

Permalink
can just check the time instead of a new seeded bool
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jun 13, 2024
1 parent 86d6122 commit 3ab2c04
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions crypto/rand/prng.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type PRNG struct {
cipher chacha20.Cipher
read int
t time.Time
seeded bool
}

// NewPRNG returns a seeded PRNG.
Expand All @@ -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
Expand Down

0 comments on commit 3ab2c04

Please sign in to comment.