summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Data/OpenPGP/Util/DecryptSecretKey.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Data/OpenPGP/Util/DecryptSecretKey.hs b/Data/OpenPGP/Util/DecryptSecretKey.hs
index 4370ffc..b3f5640 100644
--- a/Data/OpenPGP/Util/DecryptSecretKey.hs
+++ b/Data/OpenPGP/Util/DecryptSecretKey.hs
@@ -5,9 +5,8 @@ import qualified Data.ByteString as BS
5import qualified Data.ByteString.Lazy as LZ 5import qualified Data.ByteString.Lazy as LZ
6import Data.Word (Word16) 6import Data.Word (Word16)
7import Control.Monad (foldM) 7import Control.Monad (foldM)
8import Data.Binary (get,Binary,Get) 8import Data.Binary (get,Binary,Get,encode)
9import Data.Binary.Get (runGetOrFail) 9import Data.Binary.Get (runGetOrFail)
10import qualified Data.Serialize as Serialize
11import Control.Applicative ( (<$>) ) 10import Control.Applicative ( (<$>) )
12 11
13import Crypto.Hash.SHA1 as SHA1 12import Crypto.Hash.SHA1 as SHA1
@@ -62,7 +61,8 @@ decryptSecretKey pass k@(OpenPGP.SecretKeyPacket {
62 (material, chk) = LZ.splitAt (LZ.length decd - chkSize) decd 61 (material, chk) = LZ.splitAt (LZ.length decd - chkSize) decd
63 (chkSize, chkF) 62 (chkSize, chkF)
64 | OpenPGP.s2k_useage k == 254 = (20, SHA1.hash . toStrictBS) 63 | OpenPGP.s2k_useage k == 254 = (20, SHA1.hash . toStrictBS)
65 | otherwise = (2, Serialize.encode . checksum . toStrictBS) 64 | otherwise = (2, toStrictBS . encode . checksum . toStrictBS)
65 -- Words16s are written as 2 bytes in big-endian (network) order
66 decd = string2sdecrypt salgo s2k (toLazyBS pass) (EncipheredWithIV encd) 66 decd = string2sdecrypt salgo s2k (toLazyBS pass) (EncipheredWithIV encd)
67 67
68 checksum :: BS.ByteString -> Word16 68 checksum :: BS.ByteString -> Word16