diff --git a/Crypto/ECC.hs b/Crypto/ECC.hs index 576247d..5629bc4 100644 --- a/Crypto/ECC.hs +++ b/Crypto/ECC.hs @@ -49,7 +49,7 @@ data KeyPair curve = KeyPair } newtype SharedSecret = SharedSecret ScrubbedBytes - deriving (Eq, ByteArrayAccess) + deriving (Eq, ByteArrayAccess, NFData) class EllipticCurve curve where -- | Point on an Elliptic Curve diff --git a/Crypto/ECC/Simple/Types.hs b/Crypto/ECC/Simple/Types.hs index 653f4c2..814c256 100644 --- a/Crypto/ECC/Simple/Types.hs +++ b/Crypto/ECC/Simple/Types.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} -- | -- Module : Crypto.ECC.Simple.Types -- License : BSD-style @@ -98,7 +99,7 @@ data CurveType = -- | ECC Private Number newtype Scalar curve = Scalar Integer - deriving (Show,Read,Eq,Data,Typeable) + deriving (Show,Read,Eq,Data,Typeable,NFData) -- | Define a point on a curve. data Point curve = diff --git a/Crypto/PubKey/DH.hs b/Crypto/PubKey/DH.hs index d066944..152b1b5 100644 --- a/Crypto/PubKey/DH.hs +++ b/Crypto/PubKey/DH.hs @@ -35,17 +35,20 @@ data Params = Params , params_bits :: Int } deriving (Show,Read,Eq,Data,Typeable) +instance NFData Params where + rnf (Params p g bits) = rnf p `seq` rnf g `seq` bits `seq` () + -- | Represent Diffie Hellman public number Y. newtype PublicNumber = PublicNumber Integer - deriving (Show,Read,Eq,Enum,Real,Num,Ord) + deriving (Show,Read,Eq,Enum,Real,Num,Ord,NFData) -- | Represent Diffie Hellman private number X. newtype PrivateNumber = PrivateNumber Integer - deriving (Show,Read,Eq,Enum,Real,Num,Ord) + deriving (Show,Read,Eq,Enum,Real,Num,Ord,NFData) -- | Represent Diffie Hellman shared secret. newtype SharedKey = SharedKey ScrubbedBytes - deriving (Show,Eq,ByteArrayAccess) + deriving (Show,Eq,ByteArrayAccess,NFData) -- | generate params from a specific generator (2 or 5 are common values) -- we generate a safe prime (a prime number of the form 2p+1 where p is also prime) diff --git a/Crypto/PubKey/ECC/P256.hs b/Crypto/PubKey/ECC/P256.hs index f1d8c32..e227c51 100644 --- a/Crypto/PubKey/ECC/P256.hs +++ b/Crypto/PubKey/ECC/P256.hs @@ -58,11 +58,11 @@ import qualified Crypto.Number.Serialize as S (os2ip, i2ospOf) -- | A P256 scalar newtype Scalar = Scalar ScrubbedBytes - deriving (Show,Eq,ByteArrayAccess) + deriving (Show,Eq,ByteArrayAccess,NFData) -- | A P256 point newtype Point = Point Bytes - deriving (Show,Eq) + deriving (Show,Eq,NFData) scalarSize :: Int scalarSize = 32