diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2014-05-16 03:56:08 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2014-05-16 03:56:08 +0000 |
commit | 08439afd13ec47e20a2ea61763cfd6961a89b71d (patch) | |
tree | 2b7eef49a82b26c0645c66e75a678de8b0edfaae /obfs4.go | |
parent | 8a431a64cb6eb05addc8d0373ebf7f4e5bc683e7 (diff) |
Treat the PrngSeed frame as part of the handshake.
Clients will now always add 87 bytes of padding to the clientRequest,
and Servers will always send the PRNG seed frame unpadded, and bundled
with the serverResponse.
Why 87 bytes? The amount of data that the server sends is 87.
This fixes #5.
Diffstat (limited to 'obfs4.go')
-rw-r--r-- | obfs4.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -263,29 +263,39 @@ func (c *Obfs4Conn) serverHandshake(nodeID *ntor.NodeID, keypair *ntor.Keypair) break } + // + // Since the current and only implementation always sends a PRNG seed for + // the length obfuscation, this makes the amount of data received from the + // server inconsistent with the length sent from the client. + // + // Rebalance this by tweaking the client mimimum padding/server maximum + // padding, and sending the PRNG seed unpadded (As in, treat the PRNG seed + // as part of the server response). See inlineSeedFrameLength in + // handshake_ntor.go. + // + // Generate/send the response. var blob []byte blob, err = hs.generateHandshake() if err != nil { return } - _, err = c.conn.Write(blob) + var frameBuf bytes.Buffer + _, err = frameBuf.Write(blob) if err != nil { return } c.state = stateEstablished // Send the PRNG seed as the first packet. - var frameBuf bytes.Buffer err = c.producePacket(&frameBuf, packetTypePrngSeed, c.listener.seed.Bytes()[:], 0) if err != nil { return } - err = c.padBurst(&frameBuf) + _, err = c.conn.Write(frameBuf.Bytes()) if err != nil { return } - _, err = c.conn.Write(frameBuf.Bytes()) return } |