]> git.immae.eu Git - github/fretlink/hmacaroons.git/blobdiff - src/Crypto/Macaroon.hs
Use hvr's generated .travis.yml
[github/fretlink/hmacaroons.git] / src / Crypto / Macaroon.hs
index f955ab87c19dec8cf6f80f744494be9bf5c60b24..c9c8c21807eacb0b3a28ce2203950f41cf141012 100644 (file)
@@ -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