[Pkg-privacy-commits] [obfs4proxy] 59/151: Don't use math/big when generating random numbers.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:59:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository obfs4proxy.
commit 3e3b07c4e8b619918a6ece624c7072754cab0707
Author: Yawning Angel <yawning at schwanenlied.me>
Date: Sat May 24 16:46:59 2014 +0000
Don't use math/big when generating random numbers.
---
csrand/csrand.go | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/csrand/csrand.go b/csrand/csrand.go
index 1700b02..5a86da0 100644
--- a/csrand/csrand.go
+++ b/csrand/csrand.go
@@ -35,8 +35,8 @@ package csrand
import (
cryptRand "crypto/rand"
+ "encoding/binary"
"fmt"
- "math/big"
"math/rand"
)
@@ -52,12 +52,15 @@ type csRandSource struct {
}
func (r csRandSource) Int63() int64 {
- ret, err := cryptRand.Int(cryptRand.Reader, big.NewInt(int64((1<<63)-1)))
+ var src [8]byte
+ err := Bytes(src[:])
if err != nil {
panic(err)
}
+ val := binary.BigEndian.Uint64(src[:])
+ val &= (1<<63 - 1)
- return ret.Int64()
+ return int64(val)
}
func (r csRandSource) Seed(seed int64) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfs4proxy.git
More information about the Pkg-privacy-commits
mailing list