summaryrefslogtreecommitdiff
path: root/obfs4.go
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-16 03:56:08 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-16 03:56:08 +0000
commit08439afd13ec47e20a2ea61763cfd6961a89b71d (patch)
tree2b7eef49a82b26c0645c66e75a678de8b0edfaae /obfs4.go
parent8a431a64cb6eb05addc8d0373ebf7f4e5bc683e7 (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.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/obfs4.go b/obfs4.go
index f13e14a..52e1b02 100644
--- a/obfs4.go
+++ b/obfs4.go
@@ -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
}