hopenpgp-tools 0.19 → 0.19.1
raw patch · 4 files changed
+33/−24 lines, 4 filesdep ~hOpenPGP
Dependency ranges changed: hOpenPGP
Files
- hkt.hs +12/−3
- hokey.hs +12/−17
- hopenpgp-tools.cabal +3/−3
- hot.hs +6/−1
hkt.hs view
@@ -16,6 +16,7 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} import HOpenPGP.Tools.Common (banner, versioner, warranty, keyMatchesFingerprint, keyMatchesEightOctetKeyId, keyMatchesUIDSubString)@@ -26,7 +27,10 @@ import Codec.Encryption.OpenPGP.Serialize () import Codec.Encryption.OpenPGP.Signatures (verifyTKWith, verifySigWith, verifyAgainstKeyring) import Codec.Encryption.OpenPGP.Types-import Control.Applicative ((<$>),(<*>), optional, (<|>), pure)+#if !MIN_VERSION_base(4,8,0)+import Control.Applicative ((<$>),(<*>), pure)+#endif+import Control.Applicative (optional, (<|>)) import Control.Arrow ((&&&)) import Control.Lens ((^.), _1, _2, (^..)) import Control.Monad.Trans.Resource (runResourceT, MonadResource)@@ -57,12 +61,17 @@ import Data.Map (Map) import qualified Data.Map as Map import Data.Maybe (fromMaybe, mapMaybe, listToMaybe)-import Data.Monoid ((<>), mconcat)+#if !MIN_VERSION_base(4,8,0)+import Data.Monoid (mconcat)+#endif+import Data.Monoid ((<>)) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Lazy.IO as TLIO import Data.Time.Clock.POSIX (getPOSIXTime, posixSecondsToUTCTime)+#if !MIN_VERSION_base(4,8,0) import Data.Traversable (traverse)+#endif import Data.Tuple (swap) import qualified Data.Yaml as Y import GHC.Generics@@ -119,7 +128,7 @@ <*> show . _pkalgo <*> pkalgoAbbrev . _pkalgo <*> either (const "unknown") (show . pretty) . eightOctetKeyID- <*> show . fingerprint+ <*> show . pretty . fingerprint showTKey :: TKey -> IO () showTKey key = putDoc $
hokey.hs view
@@ -16,21 +16,25 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. -{-# LANGUAGE DeriveFunctor, DeriveGeneric, FlexibleInstances #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE FlexibleInstances #-} import HOpenPGP.Tools.Common (banner, versioner, warranty) import HOpenPGP.Tools.HKP (fetchKeys, FetchValidationMethod(..), rearmorKeys) import HOpenPGP.Tools.TKUtils (processTK)-import qualified Codec.Encryption.OpenPGP.ASCIIArmor as AA import Codec.Encryption.OpenPGP.Expirations (getKeyExpirationTimesFromSignature) import Codec.Encryption.OpenPGP.Fingerprint (fingerprint, eightOctetKeyID) import Codec.Encryption.OpenPGP.KeyInfo (pubkeySize, pkalgoAbbrev) import Codec.Encryption.OpenPGP.KeySelection (parseFingerprint)+import Codec.Encryption.OpenPGP.Ontology (isCertRevocationSig, isCT, isKUF, isPHA, isPKBindingSig, isSKBindingSig) import Codec.Encryption.OpenPGP.Serialize ()-import Codec.Encryption.OpenPGP.Signatures (verifyTKWith, verifySigWith, verifyAgainstKeys) import Codec.Encryption.OpenPGP.Types+#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>),(<*>), pure)-import Control.Arrow ((***), second)+#endif+import Control.Arrow ((***)) import Control.Error.Util (hush) import Control.Lens ((^.), (&), _1, _2, mapped, over) import Control.Monad.Trans.Except (runExceptT)@@ -52,7 +56,10 @@ import Data.List (elemIndex, findIndex, nub, sort, sortBy, intercalate) import qualified Data.Map as Map import Data.Maybe (fromMaybe, mapMaybe, listToMaybe)-import Data.Monoid ((<>), mconcat, Monoid(..))+#if !MIN_VERSION_base(4,8,0)+import Data.Monoid (mconcat, Monoid(..))+#endif+import Data.Monoid ((<>)) import Data.Ord (comparing, Down(..)) import qualified Data.Set as Set import Data.Text (Text)@@ -190,12 +197,8 @@ | otherwise = Nothing phas (SigV4 _ _ _ xs _ _ _) = colorizePHAs . concatMap (\(SigSubPacket _ (PreferredHashAlgorithms x)) -> x) $ filter isPHA xs phas _ = Colored Nothing Nothing []- isPHA (SigSubPacket _ (PreferredHashAlgorithms _)) = True- isPHA _ = False has = map (colorizeHA . hashAlgo) . alleged colorizeHA ha = uncurry Colored (if ha `elem` [DeprecatedMD5, SHA1] then (Just Red, Just "weak hash algorithm") else (Nothing, Nothing)) ha- isCT (SigSubPacket _ (SigCreationTime _)) = True- isCT _ = False sigcts (SigV4 _ _ _ xs _ _ _) = map (\(SigSubPacket _ (SigCreationTime x)) -> x) $ filter isCT xs alleged = filter (\x -> ((==) <$> sigissuer x <*> eoki (key^.tkKey._1)) == Just True) uatspsToText = T.pack . uatspsToString@@ -223,15 +226,11 @@ | not ('<' `elem` T.unpack u) = Colored (Just Yellow) (Just "no left angle bracket in uid") -- FIXME: be more discerning | otherwise = Colored Nothing Nothing findRevocationReason = concatMap grabReasons . filter isCertRevocationSig- isCertRevocationSig (SigV4 CertRevocationSig _ _ _ _ _ _) = True- isCertRevocationSig _ = False grabReasons (SigV4 CertRevocationSig _ _ has _ _ _) = mapMaybe (grabReasons' . _sspPayload) has grabReasons _ = [] grabReasons' (ReasonForRevocation a b) = Just (RevocationStatus True (show a) b) grabReasons' _ = Nothing kufs s = map (colorizeKUFs s . (\(SigSubPacket _ (KeyFlags x)) -> x) . maybe undefined id . find isKUF . hasheds) . newestWith (any isKUF . hasheds)- isKUF (SigSubPacket _ (KeyFlags _)) = True- isKUF _ = False colorizeKUFs False x = uncurry Colored (if (Set.member EncryptStorageKey x || Set.member EncryptCommunicationsKey x) && (Set.member SignDataKey x || Set.member CertifyKeysKey x) then (Just Yellow, Just "both signing & encryption") else (Just Green, Nothing)) x colorizeKUFs True x = uncurry Colored (if (Set.member CertifyKeysKey x) then (Just Red, Just "certification-capable subkey") else (if (Set.member EncryptStorageKey x || Set.member EncryptCommunicationsKey x) && Set.member SignDataKey x then (Just Yellow, Just "both signing & encryption") else (Just Green, Nothing))) x newestWith p = take 1 . sortBy (comparing (Down . take 1 . sigcts)) . filter p -- FIXME: this is terrible@@ -250,10 +249,6 @@ , skCrossCerts = CrossCertReport (Colored Nothing Nothing False) [] } hasEncryptionCapableSubkey skrs = if any ((\x -> Set.member EncryptStorageKey x || Set.member EncryptCommunicationsKey x) . decolorize) skrs then Colored (Just Green) Nothing True else Colored (Just Red) (Just "no encryption-capable subkey present") False- isSKBindingSig (SigV4 SubkeyBindingSig _ _ _ _ _ _) = True- isSKBindingSig _ = False- isPKBindingSig (SigV4 PrimaryKeyBindingSig _ _ _ _ _ _) = True- isPKBindingSig _ = False embeddedSigs = filter isPKBindingSig . concatMap getEmbeds . filter isSKBindingSig getEmbeds (SigV4 _ _ _ _ xs _ _) = concatMap getEmbed xs getEmbeds _ = []
hopenpgp-tools.cabal view
@@ -1,5 +1,5 @@ name: hopenpgp-tools-version: 0.19+version: 0.19.1 synopsis: hOpenPGP-based command-line tools description: command-line tools for performing some OpenPGP-related operations homepage: http://floss.scru.org/hopenpgp-tools@@ -62,7 +62,7 @@ , cryptohash >= 0.7.7 , directory , errors- , hOpenPGP >= 2.4.1+ , hOpenPGP >= 2.5 , http-client , http-client-tls , http-types@@ -126,4 +126,4 @@ source-repository this type: git location: git://git.debian.org/users/clint/hopenpgp-tools.git- tag: hopenpgp-tools/0.19+ tag: hopenpgp-tools/0.19.1
hot.hs view
@@ -18,6 +18,8 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. +{-# LANGUAGE CPP #-}+ import Paths_hopenpgp_tools (version) import HOpenPGP.Tools.Common (banner, versioner, warranty, prependAuto) import HOpenPGP.Tools.Parser (parsePExp)@@ -25,7 +27,10 @@ import Codec.Encryption.OpenPGP.ASCIIArmor.Types (Armor(..), ArmorType(..)) import Codec.Encryption.OpenPGP.Serialize () import Codec.Encryption.OpenPGP.Types-import Control.Applicative ((<$>), (<*>), optional, pure)+#if !MIN_VERSION_base(4,8,0)+import Control.Applicative ((<$>), (<*>))+#endif+import Control.Applicative (optional) import Control.Error.Util (note) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Resource (runResourceT)