From 8039d812b7ea8ae566f8873452ac34597336ddfc Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 5 Nov 2017 01:25:36 -0500 Subject: Adapted computeSharedSecret to a side-effecting interface. This is to ready the tree for a memoizing cache of shared secrets. --- src/Crypto/Tox.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Crypto/Tox.hs') diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index 307a5db5..37725aea 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs @@ -29,7 +29,8 @@ module Crypto.Tox , Plain , encodePlain , decodePlain - , computeSharedSecret + -- , computeSharedSecret + , lookupSharedSecret , encrypt , decrypt , Nonce8(..) @@ -98,6 +99,8 @@ newtype Encrypted8 a = E8 (Encrypted (a,Nonce8)) newtype (f ∘ g) x = Composed { uncomposed :: f (g x) } +infixr ∘ + newtype Auth = Auth Poly1305.Auth deriving (Eq, ByteArrayAccess) instance Ord Auth where compare (Auth a) (Auth b) = comparing (BA.convert :: Poly1305.Auth -> Bytes) a b @@ -246,6 +249,11 @@ computeSharedSecret sk recipient nonce = State hash crypt -- Since rs is 32 bytes, this pattern should never fail... Cryptonite.CryptoPassed hash = Poly1305.initialize rs +lookupSharedSecret :: TransportCrypto -> SecretKey -> PublicKey -> Nonce24 -> IO State +lookupSharedSecret crypto sk recipient nonce = do + -- TODO + return $ computeSharedSecret sk recipient nonce + hsalsa20 :: (ByteArrayAccess t, ByteArrayAccess t1) => t1 -> t -> BA.ScrubbedBytes hsalsa20 k n = BA.append a b where -- cgit v1.2.3