From 6655ceffe46a642c9379c4327dd9c84e6bfd6977 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 28 Apr 2018 15:14:57 -0700 Subject: Formatting pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I don’t always like the output hindent gives, so reformat the project to be a bit closer to what you see in published Haskell books and the like. --- src/Data/Digest.hs | 21 ++++----------------- src/Data/Digest/Internal.hs | 3 +-- src/Data/Hmac.hs | 6 +++--- src/Foreign/Ptr/ConstantTimeEquals.chs | 4 ++-- src/Internal/Digest.chs | 4 +--- src/Internal/Hmac.chs | 4 +--- 6 files changed, 12 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/Data/Digest.hs b/src/Data/Digest.hs index e0e0540..3bd042c 100644 --- a/src/Data/Digest.hs +++ b/src/Data/Digest.hs @@ -18,10 +18,7 @@ module Data.Digest , hash , md5 , sha1 - , sha224 - , sha256 - , sha384 - , sha512 + , sha224, sha256, sha384, sha512 ) where import qualified Data.ByteString as ByteString @@ -37,22 +34,12 @@ import Internal.Digest type LazyByteString = ByteString.Lazy.ByteString -md5 :: Algorithm -md5 = Algorithm evpMd5 - -sha1 :: Algorithm -sha1 = Algorithm evpSha1 - -sha224 :: Algorithm +md5, sha1, sha224, sha256, sha384, sha512 :: Algorithm +md5 = Algorithm evpMd5 +sha1 = Algorithm evpSha1 sha224 = Algorithm evpSha224 - -sha256 :: Algorithm sha256 = Algorithm evpSha256 - -sha384 :: Algorithm sha384 = Algorithm evpSha384 - -sha512 :: Algorithm sha512 = Algorithm evpSha512 -- | Hashes according to the given 'Algorithm'. diff --git a/src/Data/Digest/Internal.hs b/src/Data/Digest/Internal.hs index f8db383..be88e68 100644 --- a/src/Data/Digest/Internal.hs +++ b/src/Data/Digest/Internal.hs @@ -27,8 +27,7 @@ import Internal.Base (EvpMd) newtype Algorithm = Algorithm (Ptr EvpMd) -- | The result of a hash operation. -newtype Digest = - Digest ByteString +newtype Digest = Digest ByteString deriving (Eq, Ord) instance Show Digest where diff --git a/src/Data/Hmac.hs b/src/Data/Hmac.hs index d1124b6..2211248 100644 --- a/src/Data/Hmac.hs +++ b/src/Data/Hmac.hs @@ -46,9 +46,9 @@ newtype Hmac = Hmac ByteString instance Eq Hmac where (Hmac a) == (Hmac b) = unsafeLocalState $ - ByteString.unsafeUseAsCStringLen a $ \(a', size) -> - ByteString.unsafeUseAsCStringLen b $ \(b', _) -> - constantTimeEquals a' b' size + ByteString.unsafeUseAsCStringLen a $ \(a', size) -> + ByteString.unsafeUseAsCStringLen b $ \(b', _) -> + constantTimeEquals a' b' size instance Show Hmac where show (Hmac m) = show (Digest m) diff --git a/src/Foreign/Ptr/ConstantTimeEquals.chs b/src/Foreign/Ptr/ConstantTimeEquals.chs index 6b34e7b..a96fc66 100644 --- a/src/Foreign/Ptr/ConstantTimeEquals.chs +++ b/src/Foreign/Ptr/ConstantTimeEquals.chs @@ -26,5 +26,5 @@ import Foreign.Ptr.Cast (asVoidPtr) -- contents. constantTimeEquals :: Ptr a -> Ptr a -> Int -> IO Bool constantTimeEquals a b size = - let size' = fromIntegral size :: CULong - in (== 0) <$> {#call CRYPTO_memcmp as ^#} (asVoidPtr a) (asVoidPtr b) size' + let size' = fromIntegral size :: CULong in + (== 0) <$> {#call CRYPTO_memcmp as ^#} (asVoidPtr a) (asVoidPtr b) size' diff --git a/src/Internal/Digest.chs b/src/Internal/Digest.chs index 81d5a3b..021de22 100644 --- a/src/Internal/Digest.chs +++ b/src/Internal/Digest.chs @@ -18,9 +18,7 @@ module Internal.Digest ( evpMd5, evpSha1, evpSha224, evpSha256, evpSha384, evpSha512 , mallocEvpMdCtx - , evpDigestInitEx - , evpDigestUpdate - , evpDigestFinalEx + , evpDigestInitEx, evpDigestUpdate, evpDigestFinalEx , evpMaxMdSize ) where diff --git a/src/Internal/Hmac.chs b/src/Internal/Hmac.chs index 69c474e..0ef1e2e 100644 --- a/src/Internal/Hmac.chs +++ b/src/Internal/Hmac.chs @@ -17,9 +17,7 @@ module Internal.Hmac ( mallocHmacCtx - , hmacInitEx - , hmacUpdate - , hmacFinal + , hmacInitEx, hmacUpdate, hmacFinal ) where import Foreign -- cgit v1.2.3