From 9ae4277fadfe5764f4d7641c4c25d7370b7b52ee Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 5 Dec 2013 13:24:56 -0500 Subject: Set file modification time when exporting subkey. --- kiki.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kiki.hs b/kiki.hs index 997ba3f..a87a1b7 100644 --- a/kiki.hs +++ b/kiki.hs @@ -795,13 +795,15 @@ writeKeyToFile False "PEM" fname packet = do bs = encodeASN1 DER asn1 dta = Base64.encode (L.unpack bs) output = writePEM "RSA PRIVATE KEY" dta - stamp = timestamp packet + stamp = toEnum . fromEnum $ timestamp packet writeFile fname output - -- TODO: set modificaiton time - -- see UTIMENSAT(2) - -- utimensat or futimens + -- Note: The key's timestamp is included in it's fingerprint. + -- Therefore, we should attempt to preserve it. + setFileTimes fname stamp stamp readKeyFromFile False "PEM" fname = do + -- Note: The key's timestamp is included in it's fingerprint. + -- Therefore, we should attempt to preserve it. timestamp <- modificationTime <$> getFileStatus fname input <- L.readFile fname let dta = extractPEM "RSA PRIVATE KEY" input @@ -908,7 +910,14 @@ data KeyData = KeyData MappedPacket -- main key type KeyDB = Map.Map KeyKey KeyData -keykey key = fingerprint_material key -- TODO: smaller key? +keykey key = + -- Note: The key's timestamp is included in it's fingerprint. + -- Therefore, the same key with a different timestamp is + -- considered distinct using this keykey implementation. + fingerprint_material key -- TODO: smaller key? + + + uidkey (UserIDPacket str) = str -- Compare master keys, LT is prefered for merging -- cgit v1.2.3