diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-08-06 10:49:21 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-08-06 10:49:21 -0500 |
commit | 30a9a7735ce2dd4f25c92c6beeb5ae927c01958d (patch) | |
tree | 387d7086313ecf6be1d62e14622b30cc06471bea /Data | |
parent | 1934db51341286a76cb623c0d84c06f9869794b4 (diff) |
Cleaner fingerprint material extractor
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 23e2bbb..70bd29a 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -628,28 +628,16 @@ parse_packet tag = fmap (UnsupportedPacket tag) getRemainingByteString | |||
628 | 628 | ||
629 | -- | Helper method for fingerprints and such | 629 | -- | Helper method for fingerprints and such |
630 | fingerprint_material :: Packet -> [B.ByteString] | 630 | fingerprint_material :: Packet -> [B.ByteString] |
631 | fingerprint_material (PublicKeyPacket {version = 4, | 631 | fingerprint_material p | version p == 4 = |
632 | timestamp = timestamp, | ||
633 | key_algorithm = algorithm, | ||
634 | key = key}) = | ||
635 | [ | 632 | [ |
636 | B.singleton 0x99, | 633 | B.singleton 0x99, |
637 | encode (6 + fromIntegral (B.length material) :: Word16), | 634 | encode (6 + fromIntegral (B.length material) :: Word16), |
638 | B.singleton 4, encode timestamp, encode algorithm, | 635 | B.singleton 4, encode (timestamp p), encode (key_algorithm p), |
639 | material | 636 | material |
640 | ] | 637 | ] |
641 | where | 638 | where |
642 | material = | 639 | material = B.concat $ map (encode . (key p !)) |
643 | B.concat $ map (encode . (key !)) (public_key_fields algorithm) | 640 | (public_key_fields $ key_algorithm p) |
644 | -- Proxy to make SecretKeyPacket work | ||
645 | fingerprint_material (SecretKeyPacket {version = 4, | ||
646 | timestamp = timestamp, | ||
647 | key_algorithm = algorithm, | ||
648 | key = key}) = | ||
649 | fingerprint_material PublicKeyPacket {version = 4, | ||
650 | timestamp = timestamp, | ||
651 | key_algorithm = algorithm, | ||
652 | key = key, is_subkey = False} | ||
653 | fingerprint_material p | version p `elem` [2, 3] = [n, e] | 641 | fingerprint_material p | version p `elem` [2, 3] = [n, e] |
654 | where | 642 | where |
655 | n = B.drop 2 (encode (key p ! 'n')) | 643 | n = B.drop 2 (encode (key p ! 'n')) |