X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FCrypto%2FMacaroon.hs;h=c9c8c21807eacb0b3a28ce2203950f41cf141012;hb=b1c4109f79dd96e033c9a849328dabe90ee9afe8;hp=f955ab87c19dec8cf6f80f744494be9bf5c60b24;hpb=26d38f73993db56811d198a3e0b5c710722dd472;p=github%2Ffretlink%2Fhmacaroons.git diff --git a/src/Crypto/Macaroon.hs b/src/Crypto/Macaroon.hs index f955ab8..c9c8c21 100644 --- a/src/Crypto/Macaroon.hs +++ b/src/Crypto/Macaroon.hs @@ -23,6 +23,7 @@ module Crypto.Macaroon ( -- * Types Macaroon , Caveat + , Secret , Key , Location , Sig @@ -33,9 +34,9 @@ module Crypto.Macaroon ( , caveats , signature -- ** Caveats - , caveatLoc - , caveatId - , caveatVId + , cl + , cid + , vid -- * Create Macaroons , create @@ -44,7 +45,7 @@ module Crypto.Macaroon ( -- , addThirdPartyCaveat ) where -import Crypto.Cipher.AES +-- import Crypto.Cipher.AES import Crypto.Hash import Data.Byteable import qualified Data.ByteString as BS @@ -54,23 +55,11 @@ import qualified Data.ByteString.Char8 as B8 import Crypto.Macaroon.Internal -- | Create a Macaroon from its key, identifier and location -create :: Key -> Key -> Location -> Macaroon +create :: Secret -> Key -> Location -> Macaroon create secret ident loc = MkMacaroon loc ident [] (toBytes (hmac derivedKey ident :: HMAC SHA256)) where derivedKey = toBytes (hmac "macaroons-key-generator" secret :: HMAC SHA256) --- | Caveat target location -caveatLoc :: Caveat -> Location -caveatLoc = cl - --- | Caveat identifier -caveatId :: Caveat -> Key -caveatId = cid - --- | Caveat verification identifier -caveatVId :: Caveat -> Key -caveatVId = vid - -- | Inspect a macaroon's contents. For debugging purposes. inspect :: Macaroon -> String inspect = show @@ -81,13 +70,13 @@ addFirstPartyCaveat ident m = addCaveat (location m) ident BS.empty m -- |Add a third party Caveat to a Macaroon, using its location, identifier and -- verification key -addThirdPartyCaveat :: Key - -> Key - -> Location - -> Macaroon - -> Macaroon -addThirdPartyCaveat key cid loc m = addCaveat loc cid vid m - where - vid = encryptECB (initAES (signature m)) key +-- addThirdPartyCaveat :: Key +-- -> Key +-- -> Location +-- -> Macaroon +-- -> Macaroon +-- addThirdPartyCaveat key cid loc m = addCaveat loc cid vid m +-- where +-- vid = encryptECB (initAES (signature m)) key