summaryrefslogtreecommitdiff
path: root/lib/OpenPGP.hs
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2011-08-07 16:41:03 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2011-08-07 16:41:03 -0500
commit78c1bb25abdb182fdb96be5626c7b816de42aa38 (patch)
tree63915d4436f1b4a004cc55d721d296201058dc1d /lib/OpenPGP.hs
parenta6a2db8e24c90ca19abd8cd83ab6ef1d5e290f5c (diff)
Reorganise imports and exports
fingerprint will reappear in crypto-specific submodules
Diffstat (limited to 'lib/OpenPGP.hs')
-rw-r--r--lib/OpenPGP.hs17
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 @@
1module OpenPGP (Message(..), Packet(..), SignatureSubpacket(..), HashAlgorithm, KeyAlgorithm, CompressionAlgorithm, MPI, fingerprint, signatures_and_data, signature_issuer) where 1module OpenPGP (Message(..), Packet(..), SignatureSubpacket(..), HashAlgorithm(..), KeyAlgorithm(..), CompressionAlgorithm(..), MPI(..), fingerprint_material, signatures_and_data, signature_issuer) where
2 2
3import Control.Monad 3import Control.Monad
4import Data.Binary
5import Data.Binary.Get
6import Data.Bits 4import Data.Bits
7import Data.Word 5import Data.Word
8import Data.Map (Map, (!)) 6import Data.Map (Map, (!))
@@ -10,11 +8,11 @@ import qualified Data.Map as Map
10import qualified Data.ByteString.Lazy as LZ 8import qualified Data.ByteString.Lazy as LZ
11import qualified Data.ByteString.Lazy.UTF8 as LZ (toString) 9import qualified Data.ByteString.Lazy.UTF8 as LZ (toString)
12 10
11import Data.Binary
12import Data.Binary.Get
13import qualified Codec.Compression.Zlib.Raw as Zip 13import qualified Codec.Compression.Zlib.Raw as Zip
14import qualified Codec.Compression.Zlib as Zlib 14import qualified Codec.Compression.Zlib as Zlib
15import qualified Codec.Compression.BZip as BZip2 15import qualified Codec.Compression.BZip as BZip2
16import qualified Data.Digest.MD5 as MD5
17import qualified Data.Digest.SHA1 as SHA1
18 16
19import qualified BaseConvert as BaseConvert 17import 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
283fingerprint :: Packet -> String
284fingerprint p | version p == 4 =
285 BaseConvert.toString 16 $ SHA1.toInteger $ SHA1.hash $
286 LZ.unpack (LZ.concat (fingerprint_material p))
287fingerprint p | version p == 2 || version p == 3 =
288 concat $ map (BaseConvert.toString 16) $
289 MD5.hash $ LZ.unpack (LZ.concat (fingerprint_material p))
290
291data HashAlgorithm = MD5 | SHA1 | RIPEMD160 | SHA256 | SHA384 | SHA512 | SHA224 280data HashAlgorithm = MD5 | SHA1 | RIPEMD160 | SHA256 | SHA384 | SHA512 | SHA224
292 deriving (Show, Read, Eq) 281 deriving (Show, Read, Eq)
293instance Binary HashAlgorithm where 282instance Binary HashAlgorithm where