summaryrefslogtreecommitdiff
path: root/src/Crypto/Tox.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r--src/Crypto/Tox.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs
index a1f40c76..c44282cf 100644
--- a/src/Crypto/Tox.hs
+++ b/src/Crypto/Tox.hs
@@ -4,6 +4,7 @@
4{-# LANGUAGE KindSignatures #-} 4{-# LANGUAGE KindSignatures #-}
5{-# LANGUAGE DeriveDataTypeable #-} 5{-# LANGUAGE DeriveDataTypeable #-}
6{-# LANGUAGE DeriveFunctor #-} 6{-# LANGUAGE DeriveFunctor #-}
7{-# LANGUAGE DeriveGeneric #-}
7{-# LANGUAGE DeriveTraversable #-} 8{-# LANGUAGE DeriveTraversable #-}
8{-# LANGUAGE ExplicitNamespaces #-} 9{-# LANGUAGE ExplicitNamespaces #-}
9{-# LANGUAGE TypeOperators #-} 10{-# LANGUAGE TypeOperators #-}
@@ -99,6 +100,7 @@ import Crypto.Error
99#endif 100#endif
100import Network.Socket (SockAddr) 101import Network.Socket (SockAddr)
101import GHC.Exts (Word(..),inline) 102import GHC.Exts (Word(..),inline)
103import GHC.Generics (Generic)
102import GHC.Prim 104import GHC.Prim
103import Data.Word64Map (fitsInInt) 105import Data.Word64Map (fitsInInt)
104import Data.MinMaxPSQ (MinMaxPSQ') 106import Data.MinMaxPSQ (MinMaxPSQ')
@@ -109,7 +111,7 @@ import System.IO.Unsafe (unsafeDupablePerformIO)
109 111
110-- | A 16-byte mac and an arbitrary-length encrypted stream. 112-- | A 16-byte mac and an arbitrary-length encrypted stream.
111newtype Encrypted a = Encrypted ByteString 113newtype Encrypted a = Encrypted ByteString
112 deriving (Eq,Ord,Data,ByteArrayAccess) 114 deriving (Eq,Ord,Data,ByteArrayAccess,Hashable,Generic)
113 115
114newtype Encrypted8 a = E8 (Encrypted (a,Nonce8)) 116newtype Encrypted8 a = E8 (Encrypted (a,Nonce8))
115 deriving (Serialize, Show) 117 deriving (Serialize, Show)
@@ -358,7 +360,7 @@ hsalsa20 k n = BA.append a b
358 360
359 361
360newtype Nonce24 = Nonce24 ByteString 362newtype Nonce24 = Nonce24 ByteString
361 deriving (Eq, Ord, ByteArrayAccess, Data) 363 deriving (Eq, Ord, ByteArrayAccess, Data, Generic, Hashable)
362 364
363nonce24ToWord16 :: Nonce24 -> Word16 365nonce24ToWord16 :: Nonce24 -> Word16
364nonce24ToWord16 (Nonce24 n24) = fromIntegral (B.index n24 23) + 256 * fromIntegral (B.index n24 22) 366nonce24ToWord16 (Nonce24 n24) = fromIntegral (B.index n24 23) + 256 * fromIntegral (B.index n24 22)
@@ -536,6 +538,7 @@ data TransportCrypto = TransportCrypto
536 , rendezvousPublic :: PublicKey 538 , rendezvousPublic :: PublicKey
537 , transportSymmetric :: STM SymmetricKey 539 , transportSymmetric :: STM SymmetricKey
538 , transportNewNonce :: STM Nonce24 540 , transportNewNonce :: STM Nonce24
541 , transportNewKey :: STM SecretKey
539 , userKeys :: STM [(SecretKey,PublicKey)] 542 , userKeys :: STM [(SecretKey,PublicKey)]
540 , pendingCookies :: TVar [(SockAddr, (Int, PublicKey))] 543 , pendingCookies :: TVar [(SockAddr, (Int, PublicKey))]
541 , secretsCache :: SecretsCache 544 , secretsCache :: SecretsCache