summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index 5b9a0661..d89ac80d 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -50,7 +50,10 @@ import Network.Tox.DHT.Transport (Cookie)
50import Network.Tox.NodeId 50import Network.Tox.NodeId
51 51
52import Network.Socket 52import Network.Socket
53import Data.ByteArray
54
53import Data.ByteString as B 55import Data.ByteString as B
56import Data.Maybe
54import Data.Monoid 57import Data.Monoid
55import Data.Word 58import Data.Word
56import Crypto.Hash 59import Crypto.Hash
@@ -106,6 +109,17 @@ instance Sized HandshakeData where
106 <> ConstSize 64 -- contramap cookieHash size -- missing instance Sized (Digest SHA512) 109 <> ConstSize 64 -- contramap cookieHash size -- missing instance Sized (Digest SHA512)
107 <> contramap otherCookie size 110 <> contramap otherCookie size
108 111
112instance Serialize HandshakeData where
113 get = HandshakeData <$> get
114 <*> (id2key <$> get)
115 <*> (fromJust . digestFromByteString <$> getBytes 64)
116 <*> get
117 put (HandshakeData n k h c) = do
118 put n
119 put $ key2id k
120 putByteString (convert h)
121 put c
122
109data CryptoPacket (f :: * -> *) = CryptoPacket 123data CryptoPacket (f :: * -> *) = CryptoPacket
110 { -- | The last 2 bytes of the nonce used to encrypt 'pktData' 124 { -- | The last 2 bytes of the nonce used to encrypt 'pktData'
111 pktNonce :: Word16 125 pktNonce :: Word16