summaryrefslogtreecommitdiff
path: root/weighted_dist.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-24 04:47:10 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-24 04:47:10 +0000
commitb3f0f51775ae2e19c62c70e15f77ef991ad4bb49 (patch)
tree0a779fe20ffead1e8a87ba209ac566829c7ce93a /weighted_dist.go
parente77ddddf4d10dbd3387c2e4714c287c546c70512 (diff)
Move utils.go to csrand/csrand.go, and clean up the interface.
All of the obfs4 code except unit tests now uses the csrand wrapper routines.
Diffstat (limited to 'weighted_dist.go')
-rw-r--r--weighted_dist.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/weighted_dist.go b/weighted_dist.go
index af0fa7d..04b0d2d 100644
--- a/weighted_dist.go
+++ b/weighted_dist.go
@@ -28,7 +28,6 @@
package obfs4
import (
- csrand "crypto/rand"
"encoding/base64"
"encoding/binary"
"fmt"
@@ -36,6 +35,8 @@ import (
"math/rand"
"github.com/dchest/siphash"
+
+ "github.com/yawning/obfs4/csrand"
)
// DrbgSeedLength is the length of the hashDrbg seed.
@@ -58,7 +59,7 @@ func (seed *DrbgSeed) Base64() string {
// NewDrbgSeed returns a DrbgSeed initialized with the runtime CSPRNG.
func NewDrbgSeed() (seed *DrbgSeed, err error) {
seed = new(DrbgSeed)
- _, err = csrand.Read(seed.Bytes()[:])
+ err = csrand.Bytes(seed.Bytes()[:])
if err != nil {
return nil, err
}
@@ -160,7 +161,7 @@ func newWDist(seed *DrbgSeed, min, max int) (w *wDist) {
func (w *wDist) sample() int {
retIdx := 0
totalProb := 0.0
- prob := csRandInstance.Float64()
+ prob := csrand.Float64()
for i, bucketProb := range w.buckets {
totalProb += bucketProb
if prob <= totalProb {