Skip to content

Commit 738e08a

Browse files
committed
Use cryptohash-sha1
1 parent a9a5e85 commit 738e08a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Changes for next
2+
3+
- Allow http-client-0.6
4+
5+
- Change to use `cryptohash-sha1` (before `cryptohash`)
6+
17
## Changes for 0.20
28

39
- Add ratelimit endpoint

github.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ Library
149149
base-compat >=0.10.4 && <0.11,
150150
base16-bytestring >=0.1.1.6 && <0.2,
151151
binary-orphans >=0.1.8.0 && <0.2,
152-
byteable >=0.1.1 && <0.2,
153-
cryptohash >=0.11.9 && <0.12,
152+
cryptohash-sha1 >=0.11.100.1 && <0.12,
154153
deepseq-generics >=0.2.0.0 && <0.3,
155154
exceptions >=0.10.0 && <0.11,
156155
hashable >=1.2.7.0 && <1.3,

src/GitHub/Data/Webhooks/Validate.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ module GitHub.Data.Webhooks.Validate (
1212
import GitHub.Internal.Prelude
1313
import Prelude ()
1414

15-
import Crypto.Hash (HMAC, SHA1, hmac, hmacGetDigest)
16-
import Data.Byteable (constEqBytes, toBytes)
17-
import Data.ByteString (ByteString)
15+
import Crypto.Hash.SHA1 (hmac)
16+
import Data.ByteString (ByteString)
1817

1918
import qualified Data.ByteString.Base16 as Hex
2019
import qualified Data.Text.Encoding as TE
@@ -30,10 +29,9 @@ isValidPayload
3029
-- including the 'sha1=...' prefix
3130
-> ByteString -- ^ the body
3231
-> Bool
33-
isValidPayload secret shaOpt payload = maybe False (constEqBytes sign) shaOptBS
32+
isValidPayload secret shaOpt payload = maybe False (sign ==) shaOptBS
3433
where
3534
shaOptBS = TE.encodeUtf8 <$> shaOpt
36-
hexDigest = Hex.encode . toBytes . hmacGetDigest
37-
38-
hm = hmac (TE.encodeUtf8 secret) payload :: HMAC SHA1
35+
hexDigest = Hex.encode
36+
hm = hmac (TE.encodeUtf8 secret) payload
3937
sign = "sha1=" <> hexDigest hm

0 commit comments

Comments
 (0)