diff options
Diffstat (limited to 'src/Crypto/Tox.hs')
-rw-r--r-- | src/Crypto/Tox.hs | 7 |
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 |
100 | import Network.Socket (SockAddr) | 101 | import Network.Socket (SockAddr) |
101 | import GHC.Exts (Word(..),inline) | 102 | import GHC.Exts (Word(..),inline) |
103 | import GHC.Generics (Generic) | ||
102 | import GHC.Prim | 104 | import GHC.Prim |
103 | import Data.Word64Map (fitsInInt) | 105 | import Data.Word64Map (fitsInInt) |
104 | import Data.MinMaxPSQ (MinMaxPSQ') | 106 | import 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. |
111 | newtype Encrypted a = Encrypted ByteString | 113 | newtype Encrypted a = Encrypted ByteString |
112 | deriving (Eq,Ord,Data,ByteArrayAccess) | 114 | deriving (Eq,Ord,Data,ByteArrayAccess,Hashable,Generic) |
113 | 115 | ||
114 | newtype Encrypted8 a = E8 (Encrypted (a,Nonce8)) | 116 | newtype 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 | ||
360 | newtype Nonce24 = Nonce24 ByteString | 362 | newtype Nonce24 = Nonce24 ByteString |
361 | deriving (Eq, Ord, ByteArrayAccess, Data) | 363 | deriving (Eq, Ord, ByteArrayAccess, Data, Generic, Hashable) |
362 | 364 | ||
363 | nonce24ToWord16 :: Nonce24 -> Word16 | 365 | nonce24ToWord16 :: Nonce24 -> Word16 |
364 | nonce24ToWord16 (Nonce24 n24) = fromIntegral (B.index n24 23) + 256 * fromIntegral (B.index n24 22) | 366 | nonce24ToWord16 (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 |