]> Cypherpunks.ru repositories - govpn.git/commitdiff
Ability to append noise to outgoing packets
authorSergey Matveev <stargrave@stargrave.org>
Fri, 1 May 2015 17:01:52 +0000 (20:01 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 1 May 2015 18:56:44 +0000 (21:56 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
cmd/govpn-client/main.go
cmd/govpn-server/main.go
common.go
doc/client.texi
doc/noise.texi [new file with mode: 0644]
doc/overview.texi
doc/server.texi
doc/transport.texi
doc/user.texi
transport.go

index 6b7fac1307e8ba576c08a8aa35b90d8b4ea77017..495c22c73685e7bee678cdb70a0d235c7cf4e2f1 100644 (file)
@@ -40,6 +40,7 @@ var (
        mtu        = flag.Int("mtu", 1452, "MTU for outgoing packets")
        nonceDiff  = flag.Int("noncediff", 1, "Allow nonce difference")
        timeoutP   = flag.Int("timeout", 60, "Timeout seconds")
+       noisy      = flag.Bool("noise", false, "Enable noise appending")
 )
 
 func main() {
@@ -51,6 +52,7 @@ func main() {
        govpn.MTU = *mtu
        govpn.Timeout = timeout
        govpn.Noncediff = *nonceDiff
+       govpn.NoiseEnable = *noisy
 
        id := govpn.IDDecode(*IDRaw)
        govpn.PeersInitDummy(id)
index 43c2722dbd4e6852f32709e634eecb151113b104..032de005acfd7673bec81eda2b0474022f4ef752 100644 (file)
@@ -39,6 +39,7 @@ var (
        mtu       = flag.Int("mtu", 1452, "MTU for outgoing packets")
        nonceDiff = flag.Int("noncediff", 1, "Allow nonce difference")
        timeoutP  = flag.Int("timeout", 60, "Timeout seconds")
+       noisy     = flag.Bool("noise", false, "Enable noise appending")
 )
 
 type PeerReadyEvent struct {
@@ -85,6 +86,7 @@ func main() {
        govpn.MTU = *mtu
        govpn.Timeout = *timeoutP
        govpn.Noncediff = *nonceDiff
+       govpn.NoiseEnable = *noisy
        govpn.PeersInit(*peersPath)
 
        bind, err := net.ResolveUDPAddr("udp", *bindAddr)
index 7eb40600c9fc0a868af4de56b26727a83b228736..5be6db0257f8bfc2417dd8c3bff16567dfe898b6 100644 (file)
--- a/common.go
+++ b/common.go
@@ -28,10 +28,11 @@ import (
 )
 
 var (
-       MTU       int
-       Timeout   int
-       Noncediff int
-       Version   string
+       MTU         int
+       Timeout     int
+       Noncediff   int
+       Version     string
+       NoiseEnable bool = false
 )
 
 // Call external program/script.
index 076937bf97a6c10033a450d9dbc9b3868e1cfdc3..52f6429888f5071121a0b17a298fab72fb4ee22e 100644 (file)
@@ -2,7 +2,7 @@
 @section Client part
 
 Except for common @code{-mtu}, @code{-noncediff}, @code{-timeout},
-@code{-stats} options client has the following ones:
+@code{-stats}, @code{-noise} options client has the following ones:
 
 @table @code
 @item -remote
diff --git a/doc/noise.texi b/doc/noise.texi
new file mode 100644 (file)
index 0000000..9bb27c6
--- /dev/null
@@ -0,0 +1,12 @@
+@node Noise
+@section Noise
+
+You may turn on @code{-noise} option, that forces to fill up all
+outgoing packets to their maximum (MTU) size. Without that option GoVPN
+provides confidentiality and authenticity of payload, but it's size
+leaks to the observer.
+
+As it can be applied only to outgoing traffic, you should enable it on
+both sides in most cases.
+
+Pay attention that this can dramatically increase your traffic!
index 9dfd081c6d6bbc6a2b3bbe82239f25cd70411853..76fac71cd6a2ee55e0f0d6b452a23144591fe97c 100644 (file)
@@ -48,7 +48,7 @@ network interfaces on top of UDP entirely
 @url{https://www.gnu.org/, GNU}/Linux and
 @url{http://www.freebsd.org/, FreeBSD} support
 @item IPv6 compatible
-@item Encrypted and authenticated transport
+@item Encrypted and authenticated payload transport
 @item Relatively fast handshake
 @item
 @url{https://en.wikipedia.org/wiki/Replay_attack, Replay attack} protection
@@ -65,6 +65,7 @@ authentication (pre-shared key is not transmitted in any form between
 the peers, not even it's hash value)
 @item Built-in rehandshake and heartbeat features
 @item Several simultaneous clients support
+@item Optional noise-appending for concealing underlying packet's length
 @item Optional built-in HTTP-server for retrieving information about
 known connected peers in @url{http://json.org/, JSON} format
 @end itemize
index 7541d571c54c05e8dbb0252225c13ce4e7fc9c32..69fee73defacb1319bdb99e56f2eaa46c0694d78 100644 (file)
@@ -2,7 +2,7 @@
 @section Server part
 
 Except for common @code{-mtu}, @code{-noncediff}, @code{-timeout},
-@code{-stats} options server has the following ones:
+@code{-stats}, @code{-noise} options server has the following ones:
 
 @table @code
 @item -bind
index b12a308469d54c840f6c23997c76ca877e3c9e6a..b76286138f63af78bb9f43bc02ec5d774d1e5716 100644 (file)
@@ -2,8 +2,8 @@
 @section Transport protocol
 
 @verbatim
-ENCn(SERIAL) + ENC(KEY, ENCn(SERIAL), DATA_SIZE+DATA) +
-    AUTH(ENCn(SERIAL) + ENC(KEY, ENCn(SERIAL), DATA_SIZE+DATA))
+ENCn(SERIAL) + ENC(KEY, ENCn(SERIAL), DATA_SIZE+DATA+NOISE) +
+    AUTH(ENCn(SERIAL) + ENC(KEY, ENCn(SERIAL), DATA_SIZE+DATA+NOISE))
 @end verbatim
 
 All transport and handshake messages are indistinguishable from
@@ -26,6 +26,9 @@ is always used only once. @code{ENC} is Salsa20 cipher, with established
 session @code{KEY} and encrypted @code{SERIAL} used as a nonce.
 @code{DATA_SIZE} is @emph{uint16} storing length of the @code{DATA}.
 
+@code{NOISE} is optional. It is just some junk data, intended to fill up
+packet to MTU size. This is useful for concealing payload packets length.
+
 @code{AUTH} is Poly1305 authentication function. First 256 bits of
 Salsa20 output are used as a one-time key for @code{AUTH}. Next 256 bits
 of Salsa20 are ignored. All remaining output is XORed with the data,
index dfe9534b5fe68c0f4efe7ab98f9a85fa6a2ad79e..b5ebd8fdd67af90b99411ad514c0962aba07b25e 100644 (file)
@@ -17,6 +17,7 @@ automate it using up and down shell scripts.
 * Client part::
 * Server part::
 * Stats::
+* Noise::
 * Example usage::
 @end menu
 
@@ -32,4 +33,6 @@ automate it using up and down shell scripts.
 
 @include stats.texi
 
+@include noise.texi
+
 @include example.texi
index 4277628b3fb87ab1d9510152a83b31b129d6e946..a595130a6b1d2ffec7a3385033e6439bcc38d696 100644 (file)
@@ -301,7 +301,11 @@ func (p *Peer) EthProcess(ethPkt []byte, conn WriteToer, ready chan struct{}) {
        salsa20.XORKeyStream(p.buf, p.buf, p.nonce, p.Key)
        copy(p.buf[S20BS-NonceSize:S20BS], p.nonce)
        copy(p.keyAuth[:], p.buf[:KeySize])
-       p.frame = p.buf[S20BS-NonceSize : S20BS+PktSizeSize+size]
+       if NoiseEnable {
+               p.frame = p.buf[S20BS-NonceSize : S20BS+MTU-NonceSize-poly1305.TagSize]
+       } else {
+               p.frame = p.buf[S20BS-NonceSize : S20BS+PktSizeSize+size]
+       }
        poly1305.Sum(p.tag, p.frame, p.keyAuth)
 
        p.FramesOut++