Add missing NFData instances

This commit is contained in:
Olivier Chéron 2017-07-11 20:32:36 +02:00
parent 2a60551e34
commit 3aaa89d52e
4 changed files with 11 additions and 7 deletions

View File

@ -49,7 +49,7 @@ data KeyPair curve = KeyPair
} }
newtype SharedSecret = SharedSecret ScrubbedBytes newtype SharedSecret = SharedSecret ScrubbedBytes
deriving (Eq, ByteArrayAccess) deriving (Eq, ByteArrayAccess, NFData)
class EllipticCurve curve where class EllipticCurve curve where
-- | Point on an Elliptic Curve -- | Point on an Elliptic Curve

View File

@ -1,4 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- | -- |
-- Module : Crypto.ECC.Simple.Types -- Module : Crypto.ECC.Simple.Types
-- License : BSD-style -- License : BSD-style
@ -98,7 +99,7 @@ data CurveType =
-- | ECC Private Number -- | ECC Private Number
newtype Scalar curve = Scalar Integer newtype Scalar curve = Scalar Integer
deriving (Show,Read,Eq,Data,Typeable) deriving (Show,Read,Eq,Data,Typeable,NFData)
-- | Define a point on a curve. -- | Define a point on a curve.
data Point curve = data Point curve =

View File

@ -35,17 +35,20 @@ data Params = Params
, params_bits :: Int , params_bits :: Int
} deriving (Show,Read,Eq,Data,Typeable) } 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. -- | Represent Diffie Hellman public number Y.
newtype PublicNumber = PublicNumber Integer 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. -- | Represent Diffie Hellman private number X.
newtype PrivateNumber = PrivateNumber Integer 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. -- | Represent Diffie Hellman shared secret.
newtype SharedKey = SharedKey ScrubbedBytes 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) -- | 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) -- we generate a safe prime (a prime number of the form 2p+1 where p is also prime)

View File

@ -58,11 +58,11 @@ import qualified Crypto.Number.Serialize as S (os2ip, i2ospOf)
-- | A P256 scalar -- | A P256 scalar
newtype Scalar = Scalar ScrubbedBytes newtype Scalar = Scalar ScrubbedBytes
deriving (Show,Eq,ByteArrayAccess) deriving (Show,Eq,ByteArrayAccess,NFData)
-- | A P256 point -- | A P256 point
newtype Point = Point Bytes newtype Point = Point Bytes
deriving (Show,Eq) deriving (Show,Eq,NFData)
scalarSize :: Int scalarSize :: Int
scalarSize = 32 scalarSize = 32