diff options
Diffstat (limited to 'vendor/github.com/sjtug/cerberus/internal/randpool/randpool.go')
| -rw-r--r-- | vendor/github.com/sjtug/cerberus/internal/randpool/randpool.go | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/vendor/github.com/sjtug/cerberus/internal/randpool/randpool.go b/vendor/github.com/sjtug/cerberus/internal/randpool/randpool.go deleted file mode 100644 index ef772fd..0000000 --- a/vendor/github.com/sjtug/cerberus/internal/randpool/randpool.go +++ /dev/null @@ -1,35 +0,0 @@ -package randpool - -import ( - "crypto/rand" - "encoding/binary" - "io" - "sync" -) - -const ( - poolSize = 16 * 16 -) - -var ( - poolMu sync.Mutex - pool [poolSize]byte - poolPos = poolSize -) - -func ReadUint32() uint32 { - poolMu.Lock() - defer poolMu.Unlock() - - if poolPos == poolSize { - _, err := io.ReadFull(rand.Reader, pool[:]) - if err != nil { - panic(err) - } - poolPos = 0 - } - - poolPos += 4 - - return binary.BigEndian.Uint32(pool[poolPos-4 : poolPos]) -} |
