From 5cb3369e200c72aa23c3f86816cb854c35cc95cb Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Mon, 2 Jun 2014 16:47:30 +0000 Subject: Move the SipHash DRBG off into it's own package. --- obfs4.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'obfs4.go') diff --git a/obfs4.go b/obfs4.go index b34eceb..ec33fb4 100644 --- a/obfs4.go +++ b/obfs4.go @@ -41,6 +41,7 @@ import ( "syscall" "time" + "github.com/yawning/obfs4/drbg" "github.com/yawning/obfs4/framing" "github.com/yawning/obfs4/ntor" ) @@ -561,7 +562,7 @@ func DialObfs4DialFn(dialFn DialFn, network, address, nodeID, publicKey string, } // Generate the initial length obfuscation distribution. - seed, err := NewDrbgSeed() + seed, err := drbg.NewSeed() if err != nil { return nil, err } @@ -571,7 +572,7 @@ func DialObfs4DialFn(dialFn DialFn, network, address, nodeID, publicKey string, c.lenProbDist = newWDist(seed, 0, framing.MaximumSegmentLength) if iatObfuscation { iatSeedSrc := sha256.Sum256(seed.Bytes()[:]) - iatSeed, err := DrbgSeedFromBytes(iatSeedSrc[:]) + iatSeed, err := drbg.SeedFromBytes(iatSeedSrc[:]) if err != nil { return nil, err } @@ -610,8 +611,8 @@ type Obfs4Listener struct { keyPair *ntor.Keypair nodeID *ntor.NodeID - seed *DrbgSeed - iatSeed *DrbgSeed + seed *drbg.Seed + iatSeed *drbg.Seed iatObfuscation bool closeDelayBytes int @@ -715,14 +716,14 @@ func ListenObfs4(network, laddr, nodeID, privateKey, seed string, iatObfuscation if err != nil { return nil, err } - l.seed, err = DrbgSeedFromBase64(seed) + l.seed, err = drbg.SeedFromBase64(seed) if err != nil { return nil, err } l.iatObfuscation = iatObfuscation if l.iatObfuscation { iatSeedSrc := sha256.Sum256(l.seed.Bytes()[:]) - l.iatSeed, err = DrbgSeedFromBytes(iatSeedSrc[:]) + l.iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]) if err != nil { return nil, err } @@ -733,7 +734,7 @@ func ListenObfs4(network, laddr, nodeID, privateKey, seed string, iatObfuscation return nil, err } - rng := rand.New(newHashDrbg(l.seed)) + rng := rand.New(drbg.NewHashDrbg(l.seed)) l.closeDelayBytes = rng.Intn(maxCloseDelayBytes) l.closeDelay = rng.Intn(maxCloseDelay) -- cgit v1.2.3