use md5 from cryptohash package instead of nano-md5 to remove dependency on OpenSSL
This commit is contained in:
parent
a1b47687e8
commit
db58a9c4ca
2 changed files with 16 additions and 5 deletions
|
@ -32,14 +32,17 @@ import Data.Int
|
|||
import Data.Bits
|
||||
import Data.IORef
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import Data.Digest.OpenSSL.MD5 (md5sum)
|
||||
import qualified Crypto.Hash.MD5 as MD5 (hash)
|
||||
import Data.UString as U (pack, append, toByteString)
|
||||
import qualified Data.ByteString as BS (ByteString, unpack)
|
||||
import Data.Word (Word8)
|
||||
import System.IO.Error as E (try)
|
||||
import Control.Monad.Error
|
||||
import Control.Monad.Util (whenJust)
|
||||
import Network.Abstract hiding (send)
|
||||
import System.IO (hFlush)
|
||||
import Database.MongoDB.Internal.Util (hGetN, bitOr)
|
||||
import Numeric (showHex)
|
||||
|
||||
-- Network -> Server -> (Sink, Source)
|
||||
-- (Sink, Source) -> Pipeline
|
||||
|
@ -306,7 +309,15 @@ type Password = UString
|
|||
type Nonce = UString
|
||||
|
||||
pwHash :: Username -> Password -> UString
|
||||
pwHash u p = pack . md5sum . toByteString $ u `U.append` ":mongo:" `U.append` p
|
||||
pwHash u p = pack . byteStringHex . MD5.hash . toByteString $ u `U.append` ":mongo:" `U.append` p
|
||||
|
||||
pwKey :: Nonce -> Username -> Password -> UString
|
||||
pwKey n u p = pack . md5sum . toByteString . U.append n . U.append u $ pwHash u p
|
||||
pwKey n u p = pack . byteStringHex . MD5.hash . toByteString . U.append n . U.append u $ pwHash u p
|
||||
|
||||
byteStringHex :: BS.ByteString -> String
|
||||
-- ^ Hexadecimal string representation of a byte string. Each byte yields two hexadecimal characters.
|
||||
byteStringHex = concatMap byteHex . BS.unpack
|
||||
|
||||
byteHex :: Word8 -> String
|
||||
-- ^ Two char hexadecimal representation of byte
|
||||
byteHex b = (if b < 16 then ('0' :) else id) (showHex b "")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: mongoDB
|
||||
version: 0.9.4
|
||||
version: 0.9.5
|
||||
build-type: Simple
|
||||
license: OtherLicense
|
||||
license-file: LICENSE
|
||||
|
@ -13,7 +13,7 @@ build-depends:
|
|||
bytestring -any,
|
||||
containers -any,
|
||||
mtl >= 2,
|
||||
nano-md5 -any,
|
||||
cryptohash -any,
|
||||
network -any,
|
||||
parsec -any,
|
||||
random -any
|
||||
|
|
Loading…
Reference in a new issue