add popCount for old version
This commit is contained in:
parent
09e8670b70
commit
d2a119d1ad
@ -9,6 +9,7 @@
|
|||||||
--
|
--
|
||||||
{-# LANGUAGE BangPatterns #-}
|
{-# LANGUAGE BangPatterns #-}
|
||||||
{-# LANGUAGE ForeignFunctionInterface #-}
|
{-# LANGUAGE ForeignFunctionInterface #-}
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
module Crypto.KDF.Scrypt
|
module Crypto.KDF.Scrypt
|
||||||
( Parameters(..)
|
( Parameters(..)
|
||||||
, generate
|
, generate
|
||||||
@ -43,6 +44,12 @@ data Parameters = Parameters
|
|||||||
foreign import ccall "cryptonite_scrypt_smix"
|
foreign import ccall "cryptonite_scrypt_smix"
|
||||||
ccryptonite_scrypt_smix :: Ptr Word8 -> Word32 -> Word64 -> Ptr Word8 -> Ptr Word8 -> IO ()
|
ccryptonite_scrypt_smix :: Ptr Word8 -> Word32 -> Word64 -> Ptr Word8 -> Ptr Word8 -> IO ()
|
||||||
|
|
||||||
|
#if !(MIN_VERSION_base(4,5,0))
|
||||||
|
popCount n = loop 0 n
|
||||||
|
where loop c 0 = c
|
||||||
|
loop c i = loop (c + if testBit c 0 then 1 else 0) (i `shiftR` 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
-- | Generate the scrypt key derivation data
|
-- | Generate the scrypt key derivation data
|
||||||
generate :: Parameters -> B.ByteString
|
generate :: Parameters -> B.ByteString
|
||||||
generate params
|
generate params
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user