diff options
author | joe <joe@jerkface.net> | 2013-12-14 23:52:47 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-12-14 23:52:47 -0500 |
commit | 74015df96f6483d1cd541813a65fa56beb44428e (patch) | |
tree | ba644263930fb927cc267031e402c30287484e93 /Data/OpenPGP/Util/DecryptSecretKey.hs | |
parent | 6b42fc6904d05979c409c0043d6d7b2eed22b58c (diff) |
use toStrictBS with Data.Binary in order to drop cereal dependency.
Diffstat (limited to 'Data/OpenPGP/Util/DecryptSecretKey.hs')
-rw-r--r-- | Data/OpenPGP/Util/DecryptSecretKey.hs | 6 |
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 | |||
5 | import qualified Data.ByteString.Lazy as LZ | 5 | import qualified Data.ByteString.Lazy as LZ |
6 | import Data.Word (Word16) | 6 | import Data.Word (Word16) |
7 | import Control.Monad (foldM) | 7 | import Control.Monad (foldM) |
8 | import Data.Binary (get,Binary,Get) | 8 | import Data.Binary (get,Binary,Get,encode) |
9 | import Data.Binary.Get (runGetOrFail) | 9 | import Data.Binary.Get (runGetOrFail) |
10 | import qualified Data.Serialize as Serialize | ||
11 | import Control.Applicative ( (<$>) ) | 10 | import Control.Applicative ( (<$>) ) |
12 | 11 | ||
13 | import Crypto.Hash.SHA1 as SHA1 | 12 | import 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 |