packages feed

Lazy-Pbkdf2 1.0.1 → 1.0.2

raw patch · 2 files changed

+17/−6 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Crypto/Pbkdf2.hs view
@@ -18,22 +18,33 @@   | B.length x == B.length y = B.pack $ B.zipWith xor x y   | otherwise = error "xor bytestrings are not of equal length" -pbkdf2 :: (ByteString -> ByteString -> ByteString) -> ByteString -> ByteString -> Integer -> ByteString-pbkdf2 hmac password salt count = B.concat $ pbkdf2' 1 True+pbkdf2 :: (ByteString -> ByteString -> ByteString)+           -- ^ @PRF@, the PRF function to be used for PBKDF2. The first+           -- argument is secret, the second argument is not.+       -> ByteString -- ^ @Password@, the secret to use in the PBKDF2 computations.+       -> ByteString -- ^ @Salt@, the not neccesarily secret data to use in the PBKDF2 computations.+       -> Integer -- ^ @c@, number of iterations for the the PBKDF2 computations.+       -> ByteString -- ^ @DK@, the output data in the format of an unlimited lazy ByteString.+pbkdf2 prf password salt iterations = B.concat $ pbkdf2' 1 True   where-    hash' = hmac password+    hash' = prf password     pbkdf2' :: Word32 -> Bool -> [ByteString]     pbkdf2' 1 False = error "Hashing algorithm looped, stopping to maintain security of data" -- Paranoia, but that's useful when doing crypto     pbkdf2' i _ = (pbkdf2'' (hash' $ B.concat [salt, B.pack $ octetsBE i])):(pbkdf2' (i + 1) False)     pbkdf2'' hash = pbkdf2''' hash hash 1     pbkdf2''' prev_hash prev_result i-      | i == count = prev_result-      | i > count = error "Count must be at least 1"+      | i == iterations = prev_result+      | i > iterations = error "Count must be at least 1"       | otherwise = pbkdf2''' current_hash result (i + 1)         where           current_hash = (hash' prev_hash)           result = xorByteStrings current_hash prev_result +-- |Example of the pbkdf2 function using SHA512. See `pbkdf2` for usage.+hmacSha512Pbkdf2 :: ByteString -- ^ @Password@+                 -> ByteString -- ^ @Salt@+                 -> Integer -- ^ @c@+                 -> ByteString -- ^ @DK@ hmacSha512Pbkdf2 = pbkdf2 hash   where     hash password salt = bytestringDigest $ hmacSha512 password salt
Lazy-Pbkdf2.cabal view
@@ -1,5 +1,5 @@ Name:           Lazy-Pbkdf2-Version:        1.0.1+Version:        1.0.2 Author:         Marcus Ofenhed <marcus@conditionraise.se> Maintainer:     Marcus Ofenhed <marcus@conditionraise.se> License:        MIT