diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2014-05-24 04:47:10 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2014-05-24 04:47:10 +0000 |
commit | b3f0f51775ae2e19c62c70e15f77ef991ad4bb49 (patch) | |
tree | 0a779fe20ffead1e8a87ba209ac566829c7ce93a /handshake_ntor.go | |
parent | e77ddddf4d10dbd3387c2e4714c287c546c70512 (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 'handshake_ntor.go')
-rw-r--r-- | handshake_ntor.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/handshake_ntor.go b/handshake_ntor.go index 8baa382..fc107c2 100644 --- a/handshake_ntor.go +++ b/handshake_ntor.go @@ -30,7 +30,6 @@ package obfs4 import ( "bytes" "crypto/hmac" - "crypto/rand" "crypto/sha256" "encoding/hex" "errors" @@ -39,6 +38,7 @@ import ( "strconv" "time" + "github.com/yawning/obfs4/csrand" "github.com/yawning/obfs4/framing" "github.com/yawning/obfs4/ntor" ) @@ -131,7 +131,7 @@ func newClientHandshake(nodeID *ntor.NodeID, serverIdentity *ntor.PublicKey) (*c } hs.nodeID = nodeID hs.serverIdentity = serverIdentity - hs.padLen = randRange(clientMinPadLength, clientMaxPadLength) + hs.padLen = csrand.IntRange(clientMinPadLength, clientMaxPadLength) hs.mac = hmac.New(sha256.New, append(hs.serverIdentity.Bytes()[:], hs.nodeID.Bytes()[:]...)) return hs, nil @@ -245,7 +245,7 @@ func newServerHandshake(nodeID *ntor.NodeID, serverIdentity *ntor.Keypair) *serv hs := new(serverHandshake) hs.nodeID = nodeID hs.serverIdentity = serverIdentity - hs.padLen = randRange(serverMinPadLength, serverMaxPadLength) + hs.padLen = csrand.IntRange(serverMinPadLength, serverMaxPadLength) hs.mac = hmac.New(sha256.New, append(hs.serverIdentity.Public().Bytes()[:], hs.nodeID.Bytes()[:]...)) return hs @@ -428,7 +428,7 @@ func findMarkMac(mark, buf []byte, startPos, maxPos int, fromTail bool) (pos int func makePad(padLen int) ([]byte, error) { pad := make([]byte, padLen) - _, err := rand.Read(pad) + err := csrand.Bytes(pad) if err != nil { return nil, err } |