summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Paul Weber <singpolyma@singpolyma.net>2012-12-31 12:54:41 -0500
committerStephen Paul Weber <singpolyma@singpolyma.net>2012-12-31 12:54:41 -0500
commit06f96ec8d862e43d12cfb4c3ad8650395cfc662c (patch)
tree98326ccf9b6824f5ba3b8ef4d564c26489d0d124
parentae07fedd5976d0d57961a1d825487c4c9c50341f (diff)
Safe to put full fingerprint in packet
We don't type restrict the length of the key ids, so we shouldn't assume the length is the one we wanted.
-rw-r--r--Data/OpenPGP.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Data/OpenPGP.hs b/Data/OpenPGP.hs
index 6ffeba4..4dad404 100644
--- a/Data/OpenPGP.hs
+++ b/Data/OpenPGP.hs
@@ -383,7 +383,7 @@ put_packet :: Packet -> (B.ByteString, Word8)
383put_packet (AsymmetricSessionKeyPacket version key_id key_algorithm dta) = 383put_packet (AsymmetricSessionKeyPacket version key_id key_algorithm dta) =
384 (B.concat [ 384 (B.concat [
385 encode version, 385 encode version,
386 encode (fst $ head $ readHex key_id :: Word64), 386 encode (fst $ head $ readHex $ takeFromEnd 16 key_id :: Word64),
387 encode key_algorithm, 387 encode key_algorithm,
388 dta 388 dta
389 ], 1) 389 ], 1)
@@ -431,7 +431,7 @@ put_packet (OnePassSignaturePacket { version = version,
431 (B.concat [ 431 (B.concat [
432 encode version, encode signature_type, 432 encode version, encode signature_type,
433 encode hash_algorithm, encode key_algorithm, 433 encode hash_algorithm, encode key_algorithm,
434 encode (fst $ head $ readHex key_id :: Word64), 434 encode (fst $ head $ readHex $ takeFromEnd 16 key_id :: Word64),
435 encode nested 435 encode nested
436 ], 4) 436 ], 4)
437put_packet (SecretKeyPacket { version = version, timestamp = timestamp, 437put_packet (SecretKeyPacket { version = version, timestamp = timestamp,
@@ -988,7 +988,7 @@ put_signature_subpacket (RevocationKeyPacket sensitive kalgo fpr) =
988 fprb = padBS 20 $ B.drop 2 $ encode (MPI fpri) 988 fprb = padBS 20 $ B.drop 2 $ encode (MPI fpri)
989 fpri = fst $ head $ readHex fpr 989 fpri = fst $ head $ readHex fpr
990put_signature_subpacket (IssuerPacket keyid) = 990put_signature_subpacket (IssuerPacket keyid) =
991 (encode (fst $ head $ readHex keyid :: Word64), 16) 991 (encode (fst $ head $ readHex $ takeFromEnd 16 keyid :: Word64), 16)
992put_signature_subpacket (NotationDataPacket human_readable name value) = 992put_signature_subpacket (NotationDataPacket human_readable name value) =
993 (B.concat [ 993 (B.concat [
994 B.pack [flag1,0,0,0], 994 B.pack [flag1,0,0,0],
@@ -1188,7 +1188,10 @@ find_key' fpr x xs keyid
1188 | thisid == keyid = Just x 1188 | thisid == keyid = Just x
1189 | otherwise = find_key fpr (Message xs) keyid 1189 | otherwise = find_key fpr (Message xs) keyid
1190 where 1190 where
1191 thisid = reverse $ take (length keyid) (reverse (fpr x)) 1191 thisid = takeFromEnd (length keyid) (fpr x)
1192
1193takeFromEnd :: Int -> String -> String
1194takeFromEnd l = reverse . take l . reverse
1192 1195
1193-- | SignaturePacket smart constructor 1196-- | SignaturePacket smart constructor
1194-- 1197--