summaryrefslogtreecommitdiff
path: root/packet.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-28 04:22:36 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-28 04:22:36 +0000
commit9fe9959c76c96ec3284f43c692cbb099230dcb73 (patch)
treeac51a41928f56e94a51f686bcb4cba9dbe2ef7b5 /packet.go
parentbd2bef2ead3e535d64a233fa1a772fee9041519a (diff)
Change the weighted distribution algorithm be uniform.
The old way was biasted towards the earlier values. Thanks to asn for pointing this out and suggesting an alternative. As an additional tweak, do not reuse the drbg seed when calculating the IAT distribution, but instead run the seed through SHA256 first, for extra tinfoil goodness.
Diffstat (limited to 'packet.go')
-rw-r--r--packet.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/packet.go b/packet.go
index 78f6697..61ed981 100644
--- a/packet.go
+++ b/packet.go
@@ -28,6 +28,7 @@
package obfs4
import (
+ "crypto/sha256"
"encoding/binary"
"fmt"
"io"
@@ -182,7 +183,12 @@ func (c *Obfs4Conn) consumeFramedPackets(w io.Writer) (n int, err error) {
}
c.lenProbDist.reset(seed)
if c.iatProbDist != nil {
- c.iatProbDist.reset(seed)
+ iatSeedSrc := sha256.Sum256(seed.Bytes()[:])
+ iatSeed, err := DrbgSeedFromBytes(iatSeedSrc[:])
+ if err != nil {
+ break
+ }
+ c.iatProbDist.reset(iatSeed)
}
}
default: