diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 10:54:16 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 10:54:16 -0500 |
commit | 5b1532529dd4850e5b94730c628f8285c30d1771 (patch) | |
tree | 5a2a5db5630ae1512966047ea18b0f1d3d579a9e /Data | |
parent | 016decabcc3644dfbe16eaba35ec69d6c2b8bad2 (diff) |
Hide internal stuff that is used by tests
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 20 | ||||
-rw-r--r-- | Data/OpenPGP/Internal.hs | 20 |
2 files changed, 22 insertions, 18 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs index 7c3e8ba..e48dcf6 100644 --- a/Data/OpenPGP.hs +++ b/Data/OpenPGP.hs | |||
@@ -51,8 +51,7 @@ module Data.OpenPGP ( | |||
51 | find_key, | 51 | find_key, |
52 | fingerprint_material, | 52 | fingerprint_material, |
53 | signatures_and_data, | 53 | signatures_and_data, |
54 | signature_issuer, | 54 | signature_issuer |
55 | decode_s2k_count, encode_s2k_count | ||
56 | ) where | 55 | ) where |
57 | 56 | ||
58 | import Numeric | 57 | import Numeric |
@@ -61,6 +60,7 @@ import Data.Bits | |||
61 | import Data.Word | 60 | import Data.Word |
62 | import Data.Char | 61 | import Data.Char |
63 | import Data.Maybe | 62 | import Data.Maybe |
63 | import Data.OpenPGP.Internal | ||
64 | import qualified Data.ByteString.Lazy as LZ | 64 | import qualified Data.ByteString.Lazy as LZ |
65 | 65 | ||
66 | #ifdef CEREAL | 66 | #ifdef CEREAL |
@@ -710,22 +710,6 @@ parse_signature_subpacket 16 = do | |||
710 | parse_signature_subpacket tag = | 710 | parse_signature_subpacket tag = |
711 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString | 711 | fmap (UnsupportedSignatureSubpacket tag) getRemainingByteString |
712 | 712 | ||
713 | decode_s2k_count :: Word8 -> Word32 | ||
714 | decode_s2k_count c = (16 + (fromIntegral c .&. 15)) `shiftL` | ||
715 | ((fromIntegral c `shiftR` 4) + 6) | ||
716 | |||
717 | encode_s2k_count :: Word32 -> Word8 | ||
718 | encode_s2k_count iterations | ||
719 | | iterations >= 65011712 = 255 | ||
720 | | decode_s2k_count result < iterations = result+1 | ||
721 | | otherwise = result | ||
722 | where | ||
723 | result = fromIntegral $ (fromIntegral c `shiftL` 4) .|. (count - 16) | ||
724 | (count, c) = encode_s2k_count' (iterations `shiftR` 6) (0::Word8) | ||
725 | encode_s2k_count' count c | ||
726 | | count < 32 = (count, c) | ||
727 | | otherwise = encode_s2k_count' (count `shiftR` 1) (c+1) | ||
728 | |||
729 | find_key :: (Packet -> String) -> Message -> String -> Maybe Packet | 713 | find_key :: (Packet -> String) -> Message -> String -> Maybe Packet |
730 | find_key fpr (Message (x@(PublicKeyPacket {}):xs)) keyid = | 714 | find_key fpr (Message (x@(PublicKeyPacket {}):xs)) keyid = |
731 | find_key' fpr x xs keyid | 715 | find_key' fpr x xs keyid |
diff --git a/Data/OpenPGP/Internal.hs b/Data/OpenPGP/Internal.hs new file mode 100644 index 0000000..b2bd506 --- /dev/null +++ b/Data/OpenPGP/Internal.hs | |||
@@ -0,0 +1,20 @@ | |||
1 | module Data.OpenPGP.Internal where | ||
2 | |||
3 | import Data.Word | ||
4 | import Data.Bits | ||
5 | |||
6 | decode_s2k_count :: Word8 -> Word32 | ||
7 | decode_s2k_count c = (16 + (fromIntegral c .&. 15)) `shiftL` | ||
8 | ((fromIntegral c `shiftR` 4) + 6) | ||
9 | |||
10 | encode_s2k_count :: Word32 -> Word8 | ||
11 | encode_s2k_count iterations | ||
12 | | iterations >= 65011712 = 255 | ||
13 | | decode_s2k_count result < iterations = result+1 | ||
14 | | otherwise = result | ||
15 | where | ||
16 | result = fromIntegral $ (fromIntegral c `shiftL` 4) .|. (count - 16) | ||
17 | (count, c) = encode_s2k_count' (iterations `shiftR` 6) (0::Word8) | ||
18 | encode_s2k_count' count c | ||
19 | | count < 32 = (count, c) | ||
20 | | otherwise = encode_s2k_count' (count `shiftR` 1) (c+1) | ||