import Control.DeepSeq
-import Crypto.Cipher.AES
import Crypto.Hash
import Data.Byteable
import qualified Data.ByteString as BS
import Data.Hex
import Data.List
--- |Type alias for Macaroons and Caveat keys and identifiers
+
+-- |Type alias for Macaroons secret keys
+type Secret = BS.ByteString
+
+-- |Type alias for Macaroons and Caveat and identifiers
type Key = BS.ByteString
-- |Type alias for Macaroons and Caveat locations
-- ^ Macaroon HMAC signature
}
+-- | Constant-time Eq instance
instance Eq Macaroon where
(MkMacaroon l1 i1 c1 s1) == (MkMacaroon l2 i2 c2 s2) =
(l1 `constEqBytes` l2) &&!
show (MkMacaroon l i c s) = intercalate "\n" [
"location " ++ B8.unpack l
, "identifier " ++ B8.unpack i
- , concatMap show c
+ , intercalate "\n" (map show c)
, "signature " ++ B8.unpack (hex s)
]
-- ^ Caveat target location
}
+-- | Constant-time Eq instance
instance Eq Caveat where
(MkCaveat c1 v1 l1) == (MkCaveat c2 v2 l2) =
(c1 `constEqBytes` c2) &&!