summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-12-29 14:51:58 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-12-29 14:51:58 -0500
commit133b04ccbf83bab6406898b3906c0851d740fa67 (patch)
tree98adc80a92950b7333b92325e9006ccf9d468056
parent60b8c7b116681349fa5bdbe3703094539e8c2eeb (diff)
Fingerprint must always be 20 octets
-rw-r--r--Data/OpenPGP.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 98622a1..02b4a1a 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -158,6 +158,9 @@ assertProp f x = assert (f x) x
158pad :: Int -> String -> String 158pad :: Int -> String -> String
159pad l s = replicate (l - length s) '0' ++ s 159pad l s = replicate (l - length s) '0' ++ s
160 160
161padBS :: Int -> B.ByteString -> B.ByteString
162padBS l s = B.replicate (fromIntegral l - B.length s) 0 `B.append` s
163
161data Packet = 164data Packet =
162 AsymmetricSessionKeyPacket { 165 AsymmetricSessionKeyPacket {
163 version::Word8, 166 version::Word8,
@@ -964,7 +967,7 @@ put_signature_subpacket (RevocationKeyPacket sensitive kalgo fpr) =
964 (B.concat [encode bitfield, encode kalgo, fprb], 12) 967 (B.concat [encode bitfield, encode kalgo, fprb], 12)
965 where 968 where
966 bitfield = 0x80 .|. (if sensitive then 0x40 else 0x0) :: Word8 969 bitfield = 0x80 .|. (if sensitive then 0x40 else 0x0) :: Word8
967 fprb = B.drop 2 $ encode (MPI fpri) 970 fprb = padBS 20 $ B.drop 2 $ encode (MPI fpri)
968 fpri = fst $ head $ readHex fpr 971 fpri = fst $ head $ readHex fpr
969put_signature_subpacket (IssuerPacket keyid) = 972put_signature_subpacket (IssuerPacket keyid) =
970 (encode (fst $ head $ readHex keyid :: Word64), 16) 973 (encode (fst $ head $ readHex keyid :: Word64), 16)