PBKDF2 0.2 → 0.3
raw patch · 2 files changed
+17/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Crypto.PBKDF2: HashedPass :: [Word8] -> HashedPass
+ Crypto.PBKDF2: Password :: [Word8] -> Password
+ Crypto.PBKDF2: Salt :: [Word8] -> Salt
+ Crypto.PBKDF2: fromOctets :: Binary a => [Word8] -> a
+ Crypto.PBKDF2: instance Eq HashedPass
+ Crypto.PBKDF2: instance Eq Password
+ Crypto.PBKDF2: instance Eq Salt
+ Crypto.PBKDF2: instance Ord HashedPass
+ Crypto.PBKDF2: instance Ord Password
+ Crypto.PBKDF2: instance Ord Salt
+ Crypto.PBKDF2: instance Read HashedPass
+ Crypto.PBKDF2: instance Read Password
+ Crypto.PBKDF2: instance Read Salt
+ Crypto.PBKDF2: instance Show Password
+ Crypto.PBKDF2: instance Show Salt
+ Crypto.PBKDF2: newtype HashedPass
+ Crypto.PBKDF2: newtype Password
+ Crypto.PBKDF2: newtype Salt
+ Crypto.PBKDF2: toOctets :: Binary a => a -> [Word8]
Files
- Crypto/PBKDF2.hs +16/−8
- PBKDF2.cabal +1/−2
Crypto/PBKDF2.hs view
@@ -4,8 +4,10 @@ > http://www.ietf.org/rfc/rfc2898.txt > http://groups.google.com/group/fa.haskell/browse_thread/thread/66c7aeeb6e47764a/b15d9d74d68c002c++> hashedpass = pbkdf2 ( Password . toOctets $ "password" ) ( Salt . toOctets $ "salt" ) -}-module Crypto.PBKDF2 (pbkdf2, pbkdf2') where+module Crypto.PBKDF2 (pbkdf2, pbkdf2', Password(..), Salt(..), HashedPass(..),toOctets,fromOctets ) where import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as L@@ -18,12 +20,14 @@ import Data.Binary newtype Password = Password [Word8]+ deriving (Read,Show,Ord,Eq) newtype Salt = Salt [Word8]+ deriving (Read,Show,Ord,Eq) newtype HashedPass = HashedPass [Word8]- deriving Show+ deriving (Read,Show,Ord,Eq) -t = pbkdf2 ( Password . toWord8s $ "meh" ) ( Salt . toWord8s $ "moo" )+t = pbkdf2 (Password . toOctets $ "blee") (Salt . toOctets $ "blah") {- | A reasonable default for rsa pbkdf2. @@ -71,13 +75,17 @@ ts = map (f pass salt cIters) ( [1..l] ) in HashedPass . take (fromIntegral dklen) . concat $ ts +toOctets :: (Binary a) => a -> [Word8]+toOctets x = L.unpack . encode $ x++fromOctets :: (Binary a) => [Word8] -> a+fromOctets = decode . L.pack+ -- The spec says -- Here, INT (i) is a four-octet encoding of the integer i, most significant octet first.--- I'm reading from the right... is this the right thing?-toWord8s x = L.unpack . encode $ x-+-- I'm reading from the right, which I think is the right thing. --intToFourWord8s :: Integer -> [Word8]-intToFourWord8s i = let w8s = toWord8s $ i+intToFourWord8s i = let w8s = toOctets $ i in drop (length w8s -4) w8s myxor :: [Word8] -> [Word8] -> [Word8]@@ -95,4 +103,4 @@ prfSHA512 :: [Word8] -> [Word8] -> [Word8] prfSHA512 seed pass = hash $ seed ++ pass -t2 = prfSHA512 (toWord8s "asdf") (toWord8s "jkl; asdfjl; asjdfnkl;ajsdfl;jk;sn")+t2 = prfSHA512 (toOctets "asdf") (toOctets "jkl; asdfjl; asjdfnkl;ajsdfl;jk;sn")
PBKDF2.cabal view
@@ -1,9 +1,8 @@ Name: PBKDF2-Version: 0.2+Version: 0.3 License: BSD3 License-file: bsd3.txt Description: Implementation of Password-Based Key Derivation Function, aka pbkdf2, from RSA labs.- http://tools.ietf.org/html/rfc2898#section-5.2 I'll deprecate this if it gets folded into an already-existing crypto package. Synopsis: Make password-based security schemes more secure.