{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 710
{-# LANGUAGE StaticPointers #-}
#endif
module Hackage.Security.Trusted (
module Hackage.Security.Trusted.TCB
, (<$$>)
, VerifyRole(..)
, trustedFileInfoEqual
) where
import Data.Function (on)
import Data.Time
import Hackage.Security.TUF
import Hackage.Security.Trusted.TCB hiding (DeclareTrusted)
(<$$>) :: StaticPtr (a -> b) -> Trusted a -> Trusted b
(<$$>) = trustApply . trustStatic
class VerifyRole a where
verifyRole :: Trusted Root
-> TargetPath
-> Maybe FileVersion
-> Maybe UTCTime
-> Signed a
-> Either VerificationError (SignaturesVerified a)
instance VerifyRole Root where
verifyRole = verifyRole' . (static (rootRolesRoot . rootRoles) <$$>)
instance VerifyRole Timestamp where
verifyRole = verifyRole' . (static (rootRolesTimestamp . rootRoles) <$$>)
instance VerifyRole Snapshot where
verifyRole = verifyRole' . (static (rootRolesSnapshot . rootRoles) <$$>)
instance VerifyRole Mirrors where
verifyRole = verifyRole' . (static (rootRolesMirrors . rootRoles) <$$>)
trustedFileInfoEqual :: Trusted FileInfo -> Trusted FileInfo -> Bool
trustedFileInfoEqual = knownFileInfoEqual `on` trusted