[Hash] change Digest to use a foundation UArray that have configurable pinnable memory setting

This commit is contained in:
Vincent Hanquez 2017-04-25 14:23:13 +01:00
parent a9fd1f079d
commit 67dd8ed7fc
2 changed files with 9 additions and 3 deletions

View File

@ -18,6 +18,8 @@ import Crypto.Internal.Imports
import Crypto.Internal.ByteArray (ByteArrayAccess, Bytes)
import qualified Crypto.Internal.ByteArray as B
import Foreign.Ptr (Ptr)
import qualified Foundation.Array as F
import qualified Foundation as F
-- | Class representing hashing algorithms.
--
@ -50,8 +52,11 @@ newtype Context a = Context Bytes
deriving (ByteArrayAccess,NFData)
-- | Represent a digest for a given hash algorithm.
newtype Digest a = Digest Bytes
deriving (Eq,Ord,ByteArrayAccess,NFData)
newtype Digest a = Digest (F.UArray Word8)
deriving (Eq,Ord,ByteArrayAccess)
instance NFData (Digest a) where
rnf (Digest u) = u `F.deepseq` ()
instance Show (Digest a) where
show (Digest bs) = map (toEnum . fromIntegral)

View File

@ -220,7 +220,8 @@ Library
Crypto.Internal.Nat
Build-depends: base >= 4.3 && < 5
, bytestring
, memory >= 0.12
, memory >= 0.14.4
, foundation >= 0.0.8
, ghc-prim
ghc-options: -Wall -fwarn-tabs -optc-O3 -fno-warn-unused-imports
default-language: Haskell2010