From c604eeb6046c27fefc6eefbf389f21c989a55929 Mon Sep 17 00:00:00 2001 From: joe Date: Wed, 29 Nov 2017 16:56:13 -0500 Subject: Disabled curve 25519 backport for newer cryptonite library. --- Presence/Presence.hs | 5 +++++ dht-client.cabal | 39 ++++++++++++++++++++++++--------------- src/Crypto/Tox.hs | 7 ++++++- src/Network/Tox.hs | 8 +++++++- src/Network/Tox/NodeId.hs | 5 +++++ src/Network/Tox/Onion/Handlers.hs | 5 +++++ 6 files changed, 52 insertions(+), 17 deletions(-) diff --git a/Presence/Presence.hs b/Presence/Presence.hs index ed1c5033..c556a170 100644 --- a/Presence/Presence.hs +++ b/Presence/Presence.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} @@ -38,7 +39,11 @@ import Data.Int (Int8) import Data.XML.Types (Event) import System.Posix.Types (UserID,CPid) import Control.Applicative +#ifdef CRYPTONITE_BACKPORT import Crypto.Error.Types (CryptoFailable (..)) +#else +import Crypto.Error +#endif import Crypto.PubKey.Curve25519 (SecretKey,toPublic) import Text.Read (readMaybe) diff --git a/dht-client.cabal b/dht-client.cabal index 023f837e..b71f75de 100644 --- a/dht-client.cabal +++ b/dht-client.cabal @@ -56,13 +56,17 @@ flag xmpp description: Include code for xmpp clients default: True +flag cryptonite-backport + description: Backport curve 25519 to older cryptonite library. + default: False + library default-language: Haskell2010 default-extensions: PatternGuards , OverloadedStrings , RecordWildCards , NondecreasingIndentation - hs-source-dirs: src, cryptonite-backport, ., Presence + hs-source-dirs: src, ., Presence exposed-modules: Network.SocketLike Data.Digest.CRC32C Data.Bits.ByteString @@ -152,7 +156,6 @@ library , contravariant , xml-types - , cryptonite , memory , time , random @@ -199,20 +202,8 @@ library other-modules: Paths_dht_client - Crypto.Cipher.Salsa - Crypto.Cipher.XSalsa - Crypto.ECC.Class - Crypto.ECC.Simple.Prim - Crypto.ECC.Simple.Types - Crypto.Error.Types - Crypto.Internal.ByteArray - Crypto.Internal.Compat - Crypto.Internal.DeepSeq - Crypto.Internal.Imports - Crypto.PubKey.Curve25519 - C-sources: cbits/cryptonite_xsalsa.c, cbits/cryptonite_salsa.c, - Presence/monitortty.c + C-sources: Presence/monitortty.c -- if flag(aeson) build-depends: aeson, aeson-pretty, unordered-containers, vector @@ -231,6 +222,24 @@ library ghc-options: -fwarn-missing-signatures -fdefer-typed-holes ghc-prof-options: + if flag(cryptonite-backport) + cpp-options: -DCRYPTONITE_BACKPORT + hs-source-dirs: cryptonite-backport + C-sources: cbits/cryptonite_xsalsa.c, cbits/cryptonite_salsa.c, + other-modules: Crypto.Cipher.Salsa + Crypto.Cipher.XSalsa + Crypto.ECC.Class + Crypto.ECC.Simple.Prim + Crypto.ECC.Simple.Types + Crypto.Error.Types + Crypto.Internal.ByteArray + Crypto.Internal.Compat + Crypto.Internal.DeepSeq + Crypto.Internal.Imports + Crypto.PubKey.Curve25519 + build-depends: cryptonite < 0.22 + else + build-depends: cryptonite >= 0.22 executable dht hs-source-dirs: examples diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index a43e3379..8bb822d8 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs @@ -63,7 +63,6 @@ import Control.Monad import qualified Crypto.Cipher.ChaChaPoly1305 as Symmetric import qualified Crypto.Cipher.Salsa as Salsa import qualified Crypto.Cipher.XSalsa as XSalsa -import Crypto.ECC.Class import qualified Crypto.Error as Cryptonite import qualified Crypto.MAC.Poly1305 as Poly1305 import Crypto.PubKey.Curve25519 @@ -90,7 +89,13 @@ import Foreign.Storable import System.Endian import qualified Data.ByteString.Internal import Control.Concurrent.STM +#ifdef CRYPTONITE_BACKPORT +import Crypto.ECC.Class import Crypto.Error.Types (CryptoFailable (..), throwCryptoError) +#else +import Crypto.ECC +import Crypto.Error +#endif import Network.Socket (SockAddr) import GHC.Exts (Word(..),inline) import GHC.Prim diff --git a/src/Network/Tox.hs b/src/Network/Tox.hs index aa95df81..b3c4cedc 100644 --- a/src/Network/Tox.hs +++ b/src/Network/Tox.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-} @@ -25,9 +26,14 @@ import Control.Monad.Fix import qualified Crypto.Cipher.ChaChaPoly1305 as Symmetric import qualified Crypto.Cipher.Salsa as Salsa import qualified Crypto.Cipher.XSalsa as XSalsa -import Crypto.ECC.Class import qualified Crypto.Error as Cryptonite +#ifdef CRYPTONITE_BACKPORT +import Crypto.ECC.Class import Crypto.Error.Types +#else +import Crypto.ECC +import Crypto.Error +#endif import qualified Crypto.MAC.Poly1305 as Poly1305 import Crypto.PubKey.Curve25519 import Crypto.PubKey.ECC.Types diff --git a/src/Network/Tox/NodeId.hs b/src/Network/Tox/NodeId.hs index 0ffc3d22..fbf6702a 100644 --- a/src/Network/Tox/NodeId.hs +++ b/src/Network/Tox/NodeId.hs @@ -37,8 +37,13 @@ import Debug.Trace import Control.Applicative import Control.Arrow import Control.Monad +#ifdef CRYPTONITE_BACKPORT import Crypto.Error.Types (CryptoFailable (..), throwCryptoError) +#else +import Crypto.Error +#endif + import Crypto.PubKey.Curve25519 import qualified Data.Aeson as JSON ;import Data.Aeson (FromJSON, ToJSON, (.=)) diff --git a/src/Network/Tox/Onion/Handlers.hs b/src/Network/Tox/Onion/Handlers.hs index e792aa50..af515315 100644 --- a/src/Network/Tox/Onion/Handlers.hs +++ b/src/Network/Tox/Onion/Handlers.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE PatternSynonyms #-} module Network.Tox.Onion.Handlers where @@ -11,8 +12,12 @@ import qualified Network.QueryResponse as QR (Client) import Crypto.Tox import qualified Data.Wrapper.PSQ as PSQ ;import Data.Wrapper.PSQ (PSQ) +#ifdef CRYPTONITE_BACKPORT import Crypto.Error.Types (CryptoFailable (..), throwCryptoError) +#else +import Crypto.Error +#endif import Control.Arrow import System.IO -- cgit v1.2.3