[Hash] change Digest to use a foundation UArray that have configurable pinnable memory setting
This commit is contained in:
parent
a9fd1f079d
commit
67dd8ed7fc
@ -18,6 +18,8 @@ import Crypto.Internal.Imports
|
|||||||
import Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
|
import Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
|
||||||
import qualified Crypto.Internal.ByteArray as B
|
import qualified Crypto.Internal.ByteArray as B
|
||||||
import Foreign.Ptr (Ptr)
|
import Foreign.Ptr (Ptr)
|
||||||
|
import qualified Foundation.Array as F
|
||||||
|
import qualified Foundation as F
|
||||||
|
|
||||||
-- | Class representing hashing algorithms.
|
-- | Class representing hashing algorithms.
|
||||||
--
|
--
|
||||||
@ -50,8 +52,11 @@ newtype Context a = Context Bytes
|
|||||||
deriving (ByteArrayAccess,NFData)
|
deriving (ByteArrayAccess,NFData)
|
||||||
|
|
||||||
-- | Represent a digest for a given hash algorithm.
|
-- | Represent a digest for a given hash algorithm.
|
||||||
newtype Digest a = Digest Bytes
|
newtype Digest a = Digest (F.UArray Word8)
|
||||||
deriving (Eq,Ord,ByteArrayAccess,NFData)
|
deriving (Eq,Ord,ByteArrayAccess)
|
||||||
|
|
||||||
|
instance NFData (Digest a) where
|
||||||
|
rnf (Digest u) = u `F.deepseq` ()
|
||||||
|
|
||||||
instance Show (Digest a) where
|
instance Show (Digest a) where
|
||||||
show (Digest bs) = map (toEnum . fromIntegral)
|
show (Digest bs) = map (toEnum . fromIntegral)
|
||||||
|
|||||||
@ -220,7 +220,8 @@ Library
|
|||||||
Crypto.Internal.Nat
|
Crypto.Internal.Nat
|
||||||
Build-depends: base >= 4.3 && < 5
|
Build-depends: base >= 4.3 && < 5
|
||||||
, bytestring
|
, bytestring
|
||||||
, memory >= 0.12
|
, memory >= 0.14.4
|
||||||
|
, foundation >= 0.0.8
|
||||||
, ghc-prim
|
, ghc-prim
|
||||||
ghc-options: -Wall -fwarn-tabs -optc-O3 -fno-warn-unused-imports
|
ghc-options: -Wall -fwarn-tabs -optc-O3 -fno-warn-unused-imports
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user