summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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