aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Crypto/Macaroon/Binder.hs
blob: 3ec3d67d8dafee82e87f7117fe10ad9fb1bee43a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-|
Module      : Crypto.Macaroon.Binder
Copyright   : (c) 2015 Julien Tanguy
License     : BSD3

Maintainer  : julien.tanguy@jhome.fr
Stability   : experimental
Portability : portable



-}
module Crypto.Macaroon.Binder where

import           Crypto.Hash
import           Data.Byteable
import qualified Data.ByteString          as BS

import           Crypto.Macaroon.Internal

-- | Datatype for binding discharging and authorizing macaroons together
newtype Binder = Binder { bind :: Macaroon -> Macaroon -> BS.ByteString }


-- | Binder which concatenates the two signatures and hashes them
hashSigs :: Binder
hashSigs = Binder $ \m m' -> toBytes $ (HMAC . hash $ BS.append (toBytes $ signature m') (toBytes $ signature m) :: HMAC SHA256)