aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-04-28 15:14:57 -0700
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-04-28 15:14:57 -0700
commit6655ceffe46a642c9379c4327dd9c84e6bfd6977 (patch)
tree3951d9e2a226694d08793ae8dedbdf30ecde1ab1 /src
parent8fc0b121543b742f56f83c9eb74885e04d104778 (diff)
Formatting pass
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.
Diffstat (limited to 'src')
-rw-r--r--src/Data/Digest.hs21
-rw-r--r--src/Data/Digest/Internal.hs3
-rw-r--r--src/Data/Hmac.hs6
-rw-r--r--src/Foreign/Ptr/ConstantTimeEquals.chs4
-rw-r--r--src/Internal/Digest.chs4
-rw-r--r--src/Internal/Hmac.chs4
6 files changed, 12 insertions, 30 deletions
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