summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-12-05 13:24:56 -0500
committerjoe <joe@jerkface.net>2013-12-05 13:24:56 -0500
commit9ae4277fadfe5764f4d7641c4c25d7370b7b52ee (patch)
treed72386ebc5f96d8836fa96e067026b5eea5ab26e
parentf4ae7656efe48845bd49cc62bfa050df0abfa148 (diff)
Set file modification time when exporting subkey.
-rw-r--r--kiki.hs19
1 files 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
795 bs = encodeASN1 DER asn1 795 bs = encodeASN1 DER asn1
796 dta = Base64.encode (L.unpack bs) 796 dta = Base64.encode (L.unpack bs)
797 output = writePEM "RSA PRIVATE KEY" dta 797 output = writePEM "RSA PRIVATE KEY" dta
798 stamp = timestamp packet 798 stamp = toEnum . fromEnum $ timestamp packet
799 writeFile fname output 799 writeFile fname output
800 -- TODO: set modificaiton time 800 -- Note: The key's timestamp is included in it's fingerprint.
801 -- see UTIMENSAT(2) 801 -- Therefore, we should attempt to preserve it.
802 -- utimensat or futimens 802 setFileTimes fname stamp stamp
803 803
804readKeyFromFile False "PEM" fname = do 804readKeyFromFile False "PEM" fname = do
805 -- Note: The key's timestamp is included in it's fingerprint.
806 -- Therefore, we should attempt to preserve it.
805 timestamp <- modificationTime <$> getFileStatus fname 807 timestamp <- modificationTime <$> getFileStatus fname
806 input <- L.readFile fname 808 input <- L.readFile fname
807 let dta = extractPEM "RSA PRIVATE KEY" input 809 let dta = extractPEM "RSA PRIVATE KEY" input
@@ -908,7 +910,14 @@ data KeyData = KeyData MappedPacket -- main key
908 910
909type KeyDB = Map.Map KeyKey KeyData 911type KeyDB = Map.Map KeyKey KeyData
910 912
911keykey key = fingerprint_material key -- TODO: smaller key? 913keykey key =
914 -- Note: The key's timestamp is included in it's fingerprint.
915 -- Therefore, the same key with a different timestamp is
916 -- considered distinct using this keykey implementation.
917 fingerprint_material key -- TODO: smaller key?
918
919
920
912uidkey (UserIDPacket str) = str 921uidkey (UserIDPacket str) = str
913 922
914-- Compare master keys, LT is prefered for merging 923-- Compare master keys, LT is prefered for merging