summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-05-31 03:33:54 -0400
committerjoe <joe@jerkface.net>2018-05-31 03:33:54 -0400
commit330f627516d207a337ce7e5d83e3163af226d6ef (patch)
tree898e5b633736a6ae737f28cad2c6cb3ad856bf24 /src
parentfa03046702a5050c28c87f2e8ca3c86187e47ed1 (diff)
Use user-keys (not DHT-key) when encrypting initial handshake.
Diffstat (limited to 'src')
-rw-r--r--src/Network/Tox.hs23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs
index 5ad9c041..3bf7b6f1 100644
--- a/src/Network/Tox.hs
+++ b/src/Network/Tox.hs
@@ -321,18 +321,17 @@ netCryptoWithBackoff millisecs tox myseckey theirpubkey = do
321 , hpTheirBaseNonce = error "netCrypto: Unreachable! hpTheirBaseNonce" 321 , hpTheirBaseNonce = error "netCrypto: Unreachable! hpTheirBaseNonce"
322 , hpTheirSessionKeyPublic = error "netCrypto: Unreachable! hpTheirSessionKeyPublic" 322 , hpTheirSessionKeyPublic = error "netCrypto: Unreachable! hpTheirSessionKeyPublic"
323 } 323 }
324 n24' <- atomically $ transportNewNonce crypto 324 myhandshake <- do
325 dput XNetCrypto ("Handshake Nonce24: " <> show n24') 325 n24' <- atomically $ transportNewNonce crypto
326 state <- lookupSharedSecret crypto myseckey theirDhtKey n24' 326 dput XNetCrypto ("Handshake Nonce24: " <> show n24')
327 newBaseNonce <- atomically $ transportNewNonce crypto 327 newBaseNonce <- atomically $ transportNewNonce crypto
328 mbMyhandshakeData <- newHandShakeData crypto newBaseNonce hp saddr 328 mbMyhandshakeData <- newHandShakeData crypto newBaseNonce hp saddr
329 let encodeHandshake myhandshakeData = let plain = encodePlain myhandshakeData 329 forM mbMyhandshakeData $ \hsdata -> do
330 encrypted = encrypt state plain 330 state <- lookupSharedSecret crypto myseckey theirpubkey n24'
331 in Handshake { handshakeCookie = cookie 331 return Handshake { handshakeCookie = cookie
332 , handshakeNonce = n24' 332 , handshakeNonce = n24'
333 , handshakeData = encrypted 333 , handshakeData = encrypt state $ encodePlain hsdata
334 } 334 }
335 let myhandshake = encodeHandshake <$> mbMyhandshakeData
336 case myhandshake of 335 case myhandshake of
337 Nothing -> hPutStrLn stderr "netCrypto: failed to create HandshakeData." >> return [] 336 Nothing -> hPutStrLn stderr "netCrypto: failed to create HandshakeData." >> return []
338 Just handshake -> do 337 Just handshake -> do