packages feed

bcrypt 0.0.8 → 0.0.9

raw patch · 2 files changed

+21/−8 lines, 2 filesdep +data-defaultPVP ok

version bump matches the API change (PVP)

Dependencies added: data-default

API changes (from Hackage documentation)

+ Crypto.BCrypt: defaultHashAlgorithm :: ByteString
+ Crypto.BCrypt: instance Data.Default.Class.Default Crypto.BCrypt.HashingPolicy
+ Crypto.BCrypt: instance GHC.Classes.Eq Crypto.BCrypt.HashingPolicy
+ Crypto.BCrypt: instance GHC.Show.Show Crypto.BCrypt.HashingPolicy

Files

Crypto/BCrypt.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE OverloadedStrings #-}+ {- | A module for hashing passwords with bcrypt.       >>> import Crypto.BCrypt@@ -16,7 +18,8 @@  -} module Crypto.BCrypt (HashingPolicy(..), hashPasswordUsingPolicy, validatePassword,                       fastBcryptHashingPolicy, slowerBcryptHashingPolicy,-                      hashUsesPolicy, hashPassword, genSalt, genSaltUsingPolicy)+                      hashUsesPolicy, hashPassword, genSalt, genSaltUsingPolicy,+                      defaultHashAlgorithm) where  import Foreign@@ -27,6 +30,7 @@ import qualified System.IO.Unsafe as U import Control.Monad import Data.ByteArray (constEq)+import Data.Default import System.Entropy  foreign import ccall "crypt_ra" c_crypt_ra :: CString -> CString -> Ptr CString -> Ptr CInt -> IO CString@@ -63,8 +67,16 @@     --   The default is $2y$ (compatible with other Openwall-based     --   libraries). The most up-to-date version is $2b$.     preferredHashAlgorithm :: BS.ByteString-  }+  } deriving (Show, Eq) +instance Default HashingPolicy where+  -- Slower hashing seems like a decent default.+  def = slowerBcryptHashingPolicy++-- | Default is compatible with other Openwall-based libraries.+defaultHashAlgorithm :: BS.ByteString+defaultHashAlgorithm = "$2y$"+ -- | Hashes a password, using a hashing policy. hashPasswordUsingPolicy :: HashingPolicy -> BS.ByteString -> IO (Maybe BS.ByteString) hashPasswordUsingPolicy hp pw = do@@ -88,7 +100,7 @@ -- | A policy that allows passwords to be hashed reasonably quickly, but for that --   reason isn't suitable for high security applications. fastBcryptHashingPolicy :: HashingPolicy-fastBcryptHashingPolicy = HashingPolicy 4 (BS.pack "$2y$")+fastBcryptHashingPolicy = HashingPolicy 4 defaultHashAlgorithm  -- | A policy which makes password hashing substantially slower than --   fastBcryptHashingPolicy, and so makes it more difficult for an adversary to
bcrypt.cabal view
@@ -1,5 +1,5 @@ Name: bcrypt-Version: 0.0.8+Version: 0.0.9 Cabal-Version: >= 1.6 Build-Type: Simple License: BSD3@@ -24,10 +24,11 @@   exposed-modules: Crypto.BCrypt   include-dirs: csrc   c-sources: csrc/crypt_blowfish.c csrc/crypt_blowfish_wrapper.c csrc/crypt_gensalt.c-  build-depends: bytestring >= 0.9,-                 entropy < 0.4,-                 base >= 3 && < 5,-                 memory >= 0.9 && < 1.0+  build-depends: base >= 3 && < 5+               , bytestring >= 0.9+               , data-default >= 0.6.0+               , entropy < 0.4+               , memory >= 0.9 && < 1.0  source-repository head   type: git