-- Ontology.hs: OpenPGP (RFC4880) "is" functions
-- Copyright © 2012-2019  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).
module Codec.Encryption.OpenPGP.Ontology
  (
 -- * for signature payloads
    isCertRevocationSig
  , isRevokerP
  , isPKBindingSig
  , isSKBindingSig
  , isSubkeyBindingSig
  , isSubkeyRevocation
  , isTrustPkt
 -- * for signature subpackets
  , isCT
  , isIssuerSSP
  , isIssuerFPSSP
  , isKET
  , isKUF
  , isPHA
  , isRevocationKeySSP
  , isSigCreationTime
  ) where

import Codec.Encryption.OpenPGP.Types

isCertRevocationSig :: SignaturePayload -> Bool
isCertRevocationSig :: SignaturePayload -> Bool
isCertRevocationSig (SigV4 CertRevocationSig _ _ _ _ _ _) = Bool
True
isCertRevocationSig _ = Bool
False

isRevokerP :: SignaturePayload -> Bool
isRevokerP :: SignaturePayload -> Bool
isRevokerP (SigV4 SignatureDirectlyOnAKey _ _ h :: [SigSubPacket]
h u :: [SigSubPacket]
u _ _) =
  (SigSubPacket -> Bool) -> [SigSubPacket] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any SigSubPacket -> Bool
isRevocationKeySSP [SigSubPacket]
h Bool -> Bool -> Bool
&& (SigSubPacket -> Bool) -> [SigSubPacket] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any SigSubPacket -> Bool
isIssuerSSP [SigSubPacket]
u
isRevokerP _ = Bool
False

isPKBindingSig :: SignaturePayload -> Bool
isPKBindingSig :: SignaturePayload -> Bool
isPKBindingSig (SigV4 PrimaryKeyBindingSig _ _ _ _ _ _) = Bool
True
isPKBindingSig _ = Bool
False

isSKBindingSig :: SignaturePayload -> Bool
isSKBindingSig :: SignaturePayload -> Bool
isSKBindingSig (SigV4 SubkeyBindingSig _ _ _ _ _ _) = Bool
True
isSKBindingSig _ = Bool
False

isSubkeyRevocation :: SignaturePayload -> Bool
isSubkeyRevocation :: SignaturePayload -> Bool
isSubkeyRevocation (SigV4 SubkeyRevocationSig _ _ _ _ _ _) = Bool
True
isSubkeyRevocation _ = Bool
False

isSubkeyBindingSig :: SignaturePayload -> Bool
isSubkeyBindingSig :: SignaturePayload -> Bool
isSubkeyBindingSig (SigV4 SubkeyBindingSig _ _ _ _ _ _) = Bool
True
isSubkeyBindingSig _ = Bool
False

isTrustPkt :: Pkt -> Bool
isTrustPkt :: Pkt -> Bool
isTrustPkt (TrustPkt _) = Bool
True
isTrustPkt _ = Bool
False

isCT :: SigSubPacket -> Bool
isCT :: SigSubPacket -> Bool
isCT (SigSubPacket _ (SigCreationTime _)) = Bool
True
isCT _ = Bool
False

isIssuerSSP :: SigSubPacket -> Bool
isIssuerSSP :: SigSubPacket -> Bool
isIssuerSSP (SigSubPacket _ (Issuer _)) = Bool
True
isIssuerSSP _ = Bool
False

isIssuerFPSSP :: SigSubPacket -> Bool
isIssuerFPSSP :: SigSubPacket -> Bool
isIssuerFPSSP (SigSubPacket _ (IssuerFingerprint _ _)) = Bool
True
isIssuerFPSSP _ = Bool
False

isKET :: SigSubPacket -> Bool
isKET :: SigSubPacket -> Bool
isKET (SigSubPacket _ (KeyExpirationTime _)) = Bool
True
isKET _ = Bool
False

isKUF :: SigSubPacket -> Bool
isKUF :: SigSubPacket -> Bool
isKUF (SigSubPacket _ (KeyFlags _)) = Bool
True
isKUF _ = Bool
False

isPHA :: SigSubPacket -> Bool
isPHA :: SigSubPacket -> Bool
isPHA (SigSubPacket _ (PreferredHashAlgorithms _)) = Bool
True
isPHA _ = Bool
False

isRevocationKeySSP :: SigSubPacket -> Bool
isRevocationKeySSP :: SigSubPacket -> Bool
isRevocationKeySSP (SigSubPacket _ RevocationKey {}) = Bool
True
isRevocationKeySSP _ = Bool
False

isSigCreationTime :: SigSubPacket -> Bool
isSigCreationTime :: SigSubPacket -> Bool
isSigCreationTime (SigSubPacket _ (SigCreationTime _)) = Bool
True
isSigCreationTime _ = Bool
False