diff options
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 14 |
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) | |||
50 | import Network.Tox.NodeId | 50 | import Network.Tox.NodeId |
51 | 51 | ||
52 | import Network.Socket | 52 | import Network.Socket |
53 | import Data.ByteArray | ||
54 | |||
53 | import Data.ByteString as B | 55 | import Data.ByteString as B |
56 | import Data.Maybe | ||
54 | import Data.Monoid | 57 | import Data.Monoid |
55 | import Data.Word | 58 | import Data.Word |
56 | import Crypto.Hash | 59 | import 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 | ||
112 | instance 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 | |||
109 | data CryptoPacket (f :: * -> *) = CryptoPacket | 123 | data 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 |