diff --git a/Crypto/KDF/Scrypt.hs b/Crypto/KDF/Scrypt.hs index 874dfea..c9956f7 100644 --- a/Crypto/KDF/Scrypt.hs +++ b/Crypto/KDF/Scrypt.hs @@ -9,6 +9,7 @@ -- {-# LANGUAGE BangPatterns #-} {-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE CPP #-} module Crypto.KDF.Scrypt ( Parameters(..) , generate @@ -43,6 +44,12 @@ data Parameters = Parameters foreign import ccall "cryptonite_scrypt_smix" 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 :: Parameters -> B.ByteString generate params