summaryrefslogtreecommitdiff
path: root/lib/Transforms.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms.hs')
-rw-r--r--lib/Transforms.hs45
1 files changed, 23 insertions, 22 deletions
diff --git a/lib/Transforms.hs b/lib/Transforms.hs
index 990a5b4..c83f427 100644
--- a/lib/Transforms.hs
+++ b/lib/Transforms.hs
@@ -16,7 +16,7 @@ import Data.Ord
16import Data.OpenPGP 16import Data.OpenPGP
17import Data.OpenPGP.Util 17import Data.OpenPGP.Util
18import Data.Word 18import Data.Word
19import Types 19import KeyRing.Types
20import FunctorToMaybe 20import FunctorToMaybe
21import GnuPGAgent ( key_nbits ) 21import GnuPGAgent ( key_nbits )
22import PacketTranscoder 22import PacketTranscoder
@@ -257,10 +257,9 @@ mkUsage tag | Just flags <- lookup tag specials
257 where 257 where
258 flagsets = [Special .. VouchSignEncrypt] 258 flagsets = [Special .. VouchSignEncrypt]
259 specials = map (\f -> (usageString f, f)) flagsets 259 specials = map (\f -> (usageString f, f)) flagsets
260
261mkUsage tag = NotationDataPacket 260mkUsage tag = NotationDataPacket
262 { human_readable = True 261 { human_readable = True
263 , notation_name = "usage@" 262 , notation_name = "usage@"
264 , notation_value = tag 263 , notation_value = tag
265 } 264 }
266 265
@@ -278,6 +277,7 @@ unsig fname isPublic (sig,trustmap) =
278 asMapped n p = let m = mappedPacket fname p 277 asMapped n p = let m = mappedPacket fname p
279 in m { locations = fmap (\x->x {originalNum=n}) (locations m) } 278 in m { locations = fmap (\x->x {originalNum=n}) (locations m) }
280 279
280smallpr :: Packet -> [Char]
281smallpr k = drop 24 $ fingerprint k 281smallpr k = drop 24 $ fingerprint k
282 282
283backsig :: SignatureSubpacket -> Maybe Packet 283backsig :: SignatureSubpacket -> Maybe Packet
@@ -285,16 +285,19 @@ backsig (EmbeddedSignaturePacket s) = Just s
285backsig _ = Nothing 285backsig _ = Nothing
286 286
287 287
288isSubkeySignature :: SignatureOver -> Bool
288isSubkeySignature (SubkeySignature {}) = True 289isSubkeySignature (SubkeySignature {}) = True
289isSubkeySignature _ = False 290isSubkeySignature _ = False
290 291
291 292
293has_tag :: String -> Packet -> Bool
292has_tag tag p = isSignaturePacket p 294has_tag tag p = isSignaturePacket p
293 && or [ tag `elem` mapMaybe usage (hashed_subpackets p) 295 && or [ tag `elem` mapMaybe usage (hashed_subpackets p)
294 , tag `elem` map usageString (mapMaybe keyflags (hashed_subpackets p)) ] 296 , tag `elem` map usageString (mapMaybe keyflags (hashed_subpackets p)) ]
295 297
296 298
297 299
300verifyBindings :: [Packet] -> [Packet] -> ([SignatureOver], [SignatureOver])
298verifyBindings keys nonkeys = (top ++ filter isSubkeySignature embedded,othersigs) 301verifyBindings keys nonkeys = (top ++ filter isSubkeySignature embedded,othersigs)
299 where 302 where
300 verified = do 303 verified = do
@@ -317,7 +320,7 @@ verifyBindings keys nonkeys = (top ++ filter isSubkeySignature embedded,othersig
317 guard (not . null $ signatures_over v) 320 guard (not . null $ signatures_over v)
318 return v 321 return v
319 322
320 323disjoint_fp :: [Packet] -> [[Packet]]
321disjoint_fp ks = {- concatMap group2 $ -} transpose grouped 324disjoint_fp ks = {- concatMap group2 $ -} transpose grouped
322 where 325 where
323 grouped = groupBy samepr . sortBy (comparing smallpr) $ ks 326 grouped = groupBy samepr . sortBy (comparing smallpr) $ ks
@@ -474,22 +477,22 @@ uidkey (UserIDPacket str) = str
474usageString :: PGPKeyFlags -> String 477usageString :: PGPKeyFlags -> String
475usageString flgs = 478usageString flgs =
476 case flgs of 479 case flgs of
477 Special -> "special" 480 Special -> "special"
478 Vouch -> "vouch" -- signkey 481 Vouch -> "vouch" -- signkey
479 Sign -> "sign" 482 Sign -> "sign"
480 VouchSign -> "vouch-sign" 483 VouchSign -> "vouch-sign"
481 Communication -> "communication" 484 Communication -> "communication"
482 VouchCommunication -> "vouch-communication" 485 VouchCommunication -> "vouch-communication"
483 SignCommunication -> "sign-communication" 486 SignCommunication -> "sign-communication"
484 VouchSignCommunication -> "vouch-sign-communication" 487 VouchSignCommunication -> "vouch-sign-communication"
485 Storage -> "storage" 488 Storage -> "storage"
486 VouchStorage -> "vouch-storage" 489 VouchStorage -> "vouch-storage"
487 SignStorage -> "sign-storage" 490 SignStorage -> "sign-storage"
488 VouchSignStorage -> "vouch-sign-storage" 491 VouchSignStorage -> "vouch-sign-storage"
489 Encrypt -> "encrypt" 492 Encrypt -> "encrypt"
490 VouchEncrypt -> "vouch-encrypt" 493 VouchEncrypt -> "vouch-encrypt"
491 SignEncrypt -> "sign-encrypt" 494 SignEncrypt -> "sign-encrypt"
492 VouchSignEncrypt -> "vouch-sign-encrypt" 495 VouchSignEncrypt -> "vouch-sign-encrypt"
493 496
494 497
495 498
@@ -529,7 +532,7 @@ showPacket p | isKey p = (if is_subkey p
529 flags = mapMaybe (fmap usageString . keyflags) xs 532 flags = mapMaybe (fmap usageString . keyflags) xs
530 xs = hashed_subpackets p 533 xs = hashed_subpackets p
531 534
532 535showPacket0 :: Show a => a -> [Char]
533showPacket0 p = dropSuffix "Packet" . concat . take 1 $ words (show p) 536showPacket0 p = dropSuffix "Packet" . concat . take 1 $ words (show p)
534 where 537 where
535 dropSuffix :: String -> String -> String 538 dropSuffix :: String -> String -> String
@@ -588,7 +591,6 @@ keyFlags0 wkun uidsigs = concat
588 , preferredhash 591 , preferredhash
589 , preferredcomp 592 , preferredcomp
590 , features ] 593 , features ]
591
592 where 594 where
593 subs = concatMap hashed_subpackets uidsigs 595 subs = concatMap hashed_subpackets uidsigs
594 keyflags = filterOr isflags subs $ 596 keyflags = filterOr isflags subs $
@@ -650,7 +652,6 @@ rsaKeyFromPacket p | isKey p = do
650 n <- lookup 'n' $ key p 652 n <- lookup 'n' $ key p
651 e <- lookup 'e' $ key p 653 e <- lookup 'e' $ key p
652 return $ RSAKey n e 654 return $ RSAKey n e
653
654rsaKeyFromPacket _ = Nothing 655rsaKeyFromPacket _ = Nothing
655 656
656 657