From efc45ad4c240529913e4f7d4f0c9f880cba6c0f9 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 29 May 2018 02:03:41 +0000 Subject: Show instance for SymmetricKey, more debug prints --- src/Crypto/Tox.hs | 3 +++ src/Network/Tox/Crypto/Handlers.hs | 1 + src/Network/Tox/DHT/Handlers.hs | 1 + 3 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index 9b7e82c0..acb98e3e 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs @@ -515,6 +515,9 @@ newSecretsCache = atomically (SecretsCache <$> newTVar MM.empty) newtype SymmetricKey = SymmetricKey ByteString +instance Show SymmetricKey where + show (SymmetricKey bs) = bin2base64 bs + data TransportCrypto = TransportCrypto { transportSecret :: SecretKey , transportPublic :: PublicKey diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index 2902685c..5a52450b 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs @@ -545,6 +545,7 @@ cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) non seckeys <- map fst <$> atomically (readTVar (userKeys crypto)) symkey <- atomically $ transportSymmetric crypto now <- getPOSIXTime + hPutStrLn stderr ("Decrypt cookie with n24=" ++ show n24 ++ "\n symkey= " ++ show symkey) lr <- fmap join . sequence $ do -- Either Monad -- TODO: XXX: FIXME: -- The following call to decryptSymmetric is failing every time, diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index 327659a9..42937b89 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs @@ -231,6 +231,7 @@ createCookie crypto ni remoteUserKey = do , dhtKey = transportPublic crypto } edta = encryptSymmetric sym n24 dta + hPutStrLn stderr $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym return $ Cookie n24 edta cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie -- cgit v1.2.3