diff options
Diffstat (limited to 'lib/OpenPGP.hs')
-rw-r--r-- | lib/OpenPGP.hs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/OpenPGP.hs b/lib/OpenPGP.hs index 25a93d2..4889a23 100644 --- a/lib/OpenPGP.hs +++ b/lib/OpenPGP.hs | |||
@@ -1,8 +1,6 @@ | |||
1 | module OpenPGP (Message(..), Packet(..), SignatureSubpacket(..), HashAlgorithm, KeyAlgorithm, CompressionAlgorithm, MPI, fingerprint, signatures_and_data, signature_issuer) where | 1 | module OpenPGP (Message(..), Packet(..), SignatureSubpacket(..), HashAlgorithm(..), KeyAlgorithm(..), CompressionAlgorithm(..), MPI(..), fingerprint_material, signatures_and_data, signature_issuer) where |
2 | 2 | ||
3 | import Control.Monad | 3 | import Control.Monad |
4 | import Data.Binary | ||
5 | import Data.Binary.Get | ||
6 | import Data.Bits | 4 | import Data.Bits |
7 | import Data.Word | 5 | import Data.Word |
8 | import Data.Map (Map, (!)) | 6 | import Data.Map (Map, (!)) |
@@ -10,11 +8,11 @@ import qualified Data.Map as Map | |||
10 | import qualified Data.ByteString.Lazy as LZ | 8 | import qualified Data.ByteString.Lazy as LZ |
11 | import qualified Data.ByteString.Lazy.UTF8 as LZ (toString) | 9 | import qualified Data.ByteString.Lazy.UTF8 as LZ (toString) |
12 | 10 | ||
11 | import Data.Binary | ||
12 | import Data.Binary.Get | ||
13 | import qualified Codec.Compression.Zlib.Raw as Zip | 13 | import qualified Codec.Compression.Zlib.Raw as Zip |
14 | import qualified Codec.Compression.Zlib as Zlib | 14 | import qualified Codec.Compression.Zlib as Zlib |
15 | import qualified Codec.Compression.BZip as BZip2 | 15 | import qualified Codec.Compression.BZip as BZip2 |
16 | import qualified Data.Digest.MD5 as MD5 | ||
17 | import qualified Data.Digest.SHA1 as SHA1 | ||
18 | 16 | ||
19 | import qualified BaseConvert as BaseConvert | 17 | import qualified BaseConvert as BaseConvert |
20 | 18 | ||
@@ -279,15 +277,6 @@ fingerprint_material p | version p == 2 || version p == 3 = [n, e] | |||
279 | where n = LZ.drop 2 (encode (key p ! 'n')) | 277 | where n = LZ.drop 2 (encode (key p ! 'n')) |
280 | e = LZ.drop 2 (encode (key p ! 'e')) | 278 | e = LZ.drop 2 (encode (key p ! 'e')) |
281 | 279 | ||
282 | -- http://tools.ietf.org/html/rfc4880#section-12.2 | ||
283 | fingerprint :: Packet -> String | ||
284 | fingerprint p | version p == 4 = | ||
285 | BaseConvert.toString 16 $ SHA1.toInteger $ SHA1.hash $ | ||
286 | LZ.unpack (LZ.concat (fingerprint_material p)) | ||
287 | fingerprint p | version p == 2 || version p == 3 = | ||
288 | concat $ map (BaseConvert.toString 16) $ | ||
289 | MD5.hash $ LZ.unpack (LZ.concat (fingerprint_material p)) | ||
290 | |||
291 | data HashAlgorithm = MD5 | SHA1 | RIPEMD160 | SHA256 | SHA384 | SHA512 | SHA224 | 280 | data HashAlgorithm = MD5 | SHA1 | RIPEMD160 | SHA256 | SHA384 | SHA512 | SHA224 |
292 | deriving (Show, Read, Eq) | 281 | deriving (Show, Read, Eq) |
293 | instance Binary HashAlgorithm where | 282 | instance Binary HashAlgorithm where |