diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-12-29 14:51:58 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-12-29 14:51:58 -0500 |
commit | 133b04ccbf83bab6406898b3906c0851d740fa67 (patch) | |
tree | 98adc80a92950b7333b92325e9006ccf9d468056 /Data | |
parent | 60b8c7b116681349fa5bdbe3703094539e8c2eeb (diff) |
Fingerprint must always be 20 octets
Diffstat (limited to 'Data')
-rw-r--r-- | Data/OpenPGP.hs | 5 |
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 | |||
158 | pad :: Int -> String -> String | 158 | pad :: Int -> String -> String |
159 | pad l s = replicate (l - length s) '0' ++ s | 159 | pad l s = replicate (l - length s) '0' ++ s |
160 | 160 | ||
161 | padBS :: Int -> B.ByteString -> B.ByteString | ||
162 | padBS l s = B.replicate (fromIntegral l - B.length s) 0 `B.append` s | ||
163 | |||
161 | data Packet = | 164 | data 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 |
969 | put_signature_subpacket (IssuerPacket keyid) = | 972 | put_signature_subpacket (IssuerPacket keyid) = |
970 | (encode (fst $ head $ readHex keyid :: Word64), 16) | 973 | (encode (fst $ head $ readHex keyid :: Word64), 16) |