diff options
Diffstat (limited to 'lib/Transforms.hs')
-rw-r--r-- | lib/Transforms.hs | 45 |
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 | |||
16 | import Data.OpenPGP | 16 | import Data.OpenPGP |
17 | import Data.OpenPGP.Util | 17 | import Data.OpenPGP.Util |
18 | import Data.Word | 18 | import Data.Word |
19 | import Types | 19 | import KeyRing.Types |
20 | import FunctorToMaybe | 20 | import FunctorToMaybe |
21 | import GnuPGAgent ( key_nbits ) | 21 | import GnuPGAgent ( key_nbits ) |
22 | import PacketTranscoder | 22 | import 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 | |||
261 | mkUsage tag = NotationDataPacket | 260 | mkUsage 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 | ||
280 | smallpr :: Packet -> [Char] | ||
281 | smallpr k = drop 24 $ fingerprint k | 281 | smallpr k = drop 24 $ fingerprint k |
282 | 282 | ||
283 | backsig :: SignatureSubpacket -> Maybe Packet | 283 | backsig :: SignatureSubpacket -> Maybe Packet |
@@ -285,16 +285,19 @@ backsig (EmbeddedSignaturePacket s) = Just s | |||
285 | backsig _ = Nothing | 285 | backsig _ = Nothing |
286 | 286 | ||
287 | 287 | ||
288 | isSubkeySignature :: SignatureOver -> Bool | ||
288 | isSubkeySignature (SubkeySignature {}) = True | 289 | isSubkeySignature (SubkeySignature {}) = True |
289 | isSubkeySignature _ = False | 290 | isSubkeySignature _ = False |
290 | 291 | ||
291 | 292 | ||
293 | has_tag :: String -> Packet -> Bool | ||
292 | has_tag tag p = isSignaturePacket p | 294 | has_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 | ||
300 | verifyBindings :: [Packet] -> [Packet] -> ([SignatureOver], [SignatureOver]) | ||
298 | verifyBindings keys nonkeys = (top ++ filter isSubkeySignature embedded,othersigs) | 301 | verifyBindings 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 | 323 | disjoint_fp :: [Packet] -> [[Packet]] | |
321 | disjoint_fp ks = {- concatMap group2 $ -} transpose grouped | 324 | disjoint_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 | |||
474 | usageString :: PGPKeyFlags -> String | 477 | usageString :: PGPKeyFlags -> String |
475 | usageString flgs = | 478 | usageString 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 | 535 | showPacket0 :: Show a => a -> [Char] | |
533 | showPacket0 p = dropSuffix "Packet" . concat . take 1 $ words (show p) | 536 | showPacket0 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 | |||
654 | rsaKeyFromPacket _ = Nothing | 655 | rsaKeyFromPacket _ = Nothing |
655 | 656 | ||
656 | 657 | ||