diff options
author | joe <joe@jerkface.net> | 2013-12-05 13:24:56 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-12-05 13:24:56 -0500 |
commit | 9ae4277fadfe5764f4d7641c4c25d7370b7b52ee (patch) | |
tree | d72386ebc5f96d8836fa96e067026b5eea5ab26e | |
parent | f4ae7656efe48845bd49cc62bfa050df0abfa148 (diff) |
Set file modification time when exporting subkey.
-rw-r--r-- | kiki.hs | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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 | ||
804 | readKeyFromFile False "PEM" fname = do | 804 | readKeyFromFile 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 | ||
909 | type KeyDB = Map.Map KeyKey KeyData | 911 | type KeyDB = Map.Map KeyKey KeyData |
910 | 912 | ||
911 | keykey key = fingerprint_material key -- TODO: smaller key? | 913 | keykey 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 | |||
912 | uidkey (UserIDPacket str) = str | 921 | uidkey (UserIDPacket str) = str |
913 | 922 | ||
914 | -- Compare master keys, LT is prefered for merging | 923 | -- Compare master keys, LT is prefered for merging |