X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FCrypto%2FMacaroon%2FInternal.hs;h=d6e80d3700d4e416858021b987b4bf72c00c1be4;hb=86f3882318d323d1920ca1c7da6e816f0ed376da;hp=ebd25cb4eea0957f4fddb302a2abeb01eda7e278;hpb=30c4b9252064ed044adf1776ff9501841c4de2fe;p=github%2Ffretlink%2Fhmacaroons.git diff --git a/src/Crypto/Macaroon/Internal.hs b/src/Crypto/Macaroon/Internal.hs index ebd25cb..d6e80d3 100644 --- a/src/Crypto/Macaroon/Internal.hs +++ b/src/Crypto/Macaroon/Internal.hs @@ -15,7 +15,6 @@ module Crypto.Macaroon.Internal where import Control.DeepSeq -import Crypto.Cipher.AES import Crypto.Hash import Data.Byteable import qualified Data.ByteString as BS @@ -24,7 +23,11 @@ import qualified Data.ByteString.Char8 as B8 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 @@ -44,6 +47,7 @@ data Macaroon = MkMacaroon { location :: Location -- ^ Macaroon HMAC signature } +-- | Constant-time Eq instance instance Eq Macaroon where (MkMacaroon l1 i1 c1 s1) == (MkMacaroon l2 i2 c2 s2) = (l1 `constEqBytes` l2) &&! @@ -58,7 +62,7 @@ instance Show Macaroon where 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) ] @@ -76,6 +80,7 @@ data Caveat = MkCaveat { cid :: Key -- ^ Caveat target location } +-- | Constant-time Eq instance instance Eq Caveat where (MkCaveat c1 v1 l1) == (MkCaveat c2 v2 l2) = (c1 `constEqBytes` c2) &&!