-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Static Mandatory Access Control in Haskell -- @package mac @version 0.1.0.0 -- | It defines main data structures for security, i.e., monad family -- MAC and labeled resources Res. module MAC.Core -- | Labeling expressions of type a with label l. newtype Res l a MkRes :: a -> Res l a unRes :: Res l a -> a -- | Label of resources labelOf :: Res l a -> l -- | This monad labels the results of the computation (of type a) -- with label l. newtype MAC l a MkMAC :: (IO a) -> MAC l a -- | Execute secure computations. runMAC :: MAC l a -> IO a -- | It lifts arbitrary IO-actions. ioTCB :: IO a -> MAC l a instance Monad (MAC l) instance Applicative (MAC l) instance Functor (MAC l) -- | Exceptions module MAC.Exception -- | Throwing exceptions throwMAC :: Exception e => e -> MAC l a -- | Throwing and catching exceptions are done among family members with -- the same labels catchMAC :: Exception e => MAC l a -> (e -> MAC l a) -> MAC l a -- | A safe interface for module Core.hs module MAC.MAC -- | Labeling expressions of type a with label l. data Res l a -- | Label of resources labelOf :: Res l a -> l -- | This monad labels the results of the computation (of type a) -- with label l. data MAC l a -- | Execute secure computations. runMAC :: MAC l a -> IO a -- | To help the type-system fix :: l -> MAC l () -- | Encodes a security lattice. module MAC.Lattice -- | Type class encoding security lattices class CanFlowTo l l' => Less l l' -- | Label for secrets data H -- | Label for public data data L instance [safe] Less H H instance [safe] Less L H instance [safe] Less L L instance [safe] CanFlowTo H H instance [safe] CanFlowTo L H instance [safe] CanFlowTo L L -- | It provides functions which map read and write effects into security -- checks. module MAC.Effects -- | It lifts functions which create resources into secure functions which -- create labeled resources create :: Less l l' => IO (d a) -> MAC l (Res l' (d a)) -- | It lifts an IO-action which writes into a data type d -- a into a secure function which writes into a labeled resource writeup :: Less l l' => (d a -> IO ()) -> Res l' (d a) -> MAC l () -- | It lifts an IO-action which reads from a data type d a -- into a secure function which reads from a labeled resource readdown :: Less l' l => (d a -> IO a) -> Res l' (d a) -> MAC l a -- | Proxy function to set the index of the family member MAC fix :: l -> MAC l () -- | Auxiliary function. A combination of fix and readdown. read_and_fix :: Less l l => (d a -> IO a) -> Res l (d a) -> MAC l a -- | Auxiliary function. A combination of fix and readdown. write_and_fix :: Less l' l' => (d a -> IO ()) -> Res l' (d a) -> MAC l' () -- | It lifts an operation which perform a read on data type d a, -- but it also performs a write on it as side-effect rw_read :: (Less l l', Less l' l) => (d a -> IO a) -> Res l' (d a) -> MAC l a -- | It lifts an operation which perform a write on data type d a, -- but it also performs a read on it as side-effect rw_write :: (Less l l', Less l' l) => (d a -> IO ()) -> Res l' (d a) -> MAC l () -- | Labeled expressions. module MAC.Labeled -- | Labeled expressions type Labeled l a = Res l (Id a) -- | Type denoting values of type a data Id a MkId :: a -> Id a -- | Creation of labeled expressions label :: Less l l' => a -> MAC l (Labeled l' a) -- | Observing labeled expressions unlabel :: Less l' l => Labeled l' a -> MAC l a -- | Synchronization primitives module MAC.MVar -- | Labeled MVars type MACMVar l a = Res l (MVar a) -- | Creation of a labeled MVar newMACMVar :: Less l l' => a -> MAC l (MACMVar l' a) -- | Creation of an empty labeled MVar newMACEmptyMVar :: Less l l' => MAC l (MACMVar l' a) -- | Securely taking a labeled MVar takeMACMVar :: Less l l => MACMVar l a -> MAC l a -- | Securely writing into a labeled MVar putMACMVar :: Less l l => MACMVar l a -> a -> MAC l () -- | Provide primitives to communicate among family members. It provides an -- API for sequential joinMAC and concurrent (forkMAC) -- setting module MAC.Control -- | Primitive which allows family members to safely communicate. The -- function finishes even if an exception is raised---the exception is -- rethrown when the returned value gets inspected. This function must -- not be used in a concurrent setting. joinMAC :: Less l l' => MAC l' a -> MAC l (Labeled l' a) -- | Safely spawning new threads forkMAC :: Less l l' => MAC l' () -> MAC l () -- | Safely spawning new threads. The function returns a labeled -- MVar where the outcome of the thread is stored forkMACMVar :: (Less l' l', Less l l') => MAC l' a -> MAC l (MACMVar l' a) -- | Mutuable state (references) module MAC.Ref -- | Labeled references type MACRef l a = Res l (IORef a) -- | Creation of labeled references newMACRef :: Less l l' => a -> MAC l (MACRef l' a) -- | Reading labeled references readMACRef :: Less l' l => MACRef l' a -> MAC l a -- | Writing labeled references writeMACRef :: Less l l' => MACRef l' a -> a -> MAC l ()