packages feed

hOpenPGP 1.6 → 1.7

raw patch · 2 files changed

+31/−10 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.Conduit.OpenPGP.Filter: OInteger :: Integer -> OValue
+ Data.Conduit.OpenPGP.Filter: OVLength :: OVar
+ Data.Conduit.OpenPGP.Filter: UOP :: OPredicate -> UPredicate
+ Data.Conduit.OpenPGP.Filter: UPKPP :: PKPPredicate -> UPredicate
+ Data.Conduit.OpenPGP.Filter: USPP :: SPPredicate -> UPredicate
+ Data.Conduit.OpenPGP.Filter: UnifiedFilterPredicate :: (Expr UPredicate) -> FilterPredicates
+ Data.Conduit.OpenPGP.Filter: data UPredicate

Files

Data/Conduit/OpenPGP/Filter.hs view
@@ -3,6 +3,8 @@ -- This software is released under the terms of the Expat license. -- (See the LICENSE file). +{-# LANGUAGE RecordWildCards #-}+ module Data.Conduit.OpenPGP.Filter (    conduitFilter  , FilterPredicates(..)@@ -19,6 +21,7 @@  , OVar(..)  , OOp(..)  , OValue(..)+ , UPredicate(..) ) where  import Control.Error.Util (hush)@@ -27,17 +30,20 @@ import Data.Conduit import qualified Data.Conduit.List as CL import Data.Maybe (fromMaybe)+import Data.Serialize (runPut, put)  import Codec.Encryption.OpenPGP.Fingerprint (eightOctetKeyID, fingerprint) import Codec.Encryption.OpenPGP.Internal (sigType, sigPKA, sigHA) import Codec.Encryption.OpenPGP.KeyInfo (pubkeySize) import Codec.Encryption.OpenPGP.Types +{-# DEPRECATED PKPPredicate, SPPredicate, OPredicate "Use UPredicate instead" #-}+ data FilterPredicates = FilterPredicates {     _pubKeyPktPredicate :: Expr PKPPredicate   , _sigPktPredicate :: Expr SPPredicate   , _otherPredicate :: Expr OPredicate-}+} | UnifiedFilterPredicate (Expr UPredicate)  data Expr a = EAny             | E a@@ -104,23 +110,31 @@  data OPredicate = OPredicate OVar OOp OValue -data OVar = OVTag   -- ^ OpenPGP packet tag+data OVar = OVTag    -- ^ OpenPGP packet tag+          | OVLength -- ^ packet length (length of what, though?)  data OValue = OInt Int+            | OInteger Integer     deriving Eq  instance Ord OValue where-    compare i j = compare (ovToInt i) (ovToInt j)+    compare i j = compare (ovToInteger i) (ovToInteger j) -ovToInt (OInt i) = i+ovToInteger (OInt i) = fromIntegral i+ovToInteger (OInteger i) = i +data UPredicate = UPKPP PKPPredicate+                | USPP SPPredicate+                | UOP OPredicate+ conduitFilter :: Monad m => FilterPredicates -> Conduit Pkt m Pkt conduitFilter = CL.filter . superPredicate  superPredicate :: FilterPredicates -> Pkt -> Bool-superPredicate fp (PublicKeyPkt pkp) = eval pkpEval (_pubKeyPktPredicate fp) pkp-superPredicate fp (SignaturePkt sp) = eval spEval (_sigPktPredicate fp) sp-superPredicate fp p = eval oEval (_otherPredicate fp) p+superPredicate fp@FilterPredicates{..} (PublicKeyPkt pkp) = eval pkpEval _pubKeyPktPredicate pkp+superPredicate fp@FilterPredicates{..} (SignaturePkt sp) = eval spEval _sigPktPredicate sp+superPredicate fp@FilterPredicates{..} p = eval oEval _otherPredicate p+superPredicate (UnifiedFilterPredicate ufp) p = eval uEval ufp p  pkpEval :: PKPPredicate -> PKPayload -> Bool pkpEval (PKPPredicate lhs o rhs) pkp = uncurry (opreduce o) (vreduce (lhs,pkp),rhs)@@ -159,4 +173,11 @@         opreduce OEquals = (==)         opreduce OLessThan = (<)         opreduce OGreaterThan = (>)-        vreduce (OVTag, p) = OInt (fromIntegral (pktTag p))+        vreduce (OVTag, p) = OInteger (fromIntegral (pktTag p))+        vreduce (OVLength, p) = OInteger (fromIntegral (B.length (runPut $ put p)))  -- FIXME: this should be a length that makes sense++uEval :: UPredicate -> Pkt -> Bool+uEval (UPKPP pred) (PublicKeyPkt p) = pkpEval pred p+uEval (USPP pred) (SignaturePkt s) = spEval pred s+uEval (UOP pred) pkt = oEval pred pkt+uEval _ _ = False  -- do not match packets of wrong type
hOpenPGP.cabal view
@@ -1,5 +1,5 @@ Name:                hOpenPGP-Version:             1.6+Version:             1.7 Synopsis:            native Haskell implementation of OpenPGP (RFC4880) Description:         native Haskell implementation of OpenPGP (RFC4880) Homepage:            http://floss.scru.org/hOpenPGP/@@ -255,4 +255,4 @@ source-repository this   type:     git   location: git://git.debian.org/users/clint/hOpenPGP.git-  tag:      v1.6+  tag:      v1.7