From 07b194e1951e3b82b7bebab6000fafdab4ab31eb Mon Sep 17 00:00:00 2001 From: roblabla Date: Sat, 5 Sep 2026 15:27:12 +0100 Subject: [PATCH] Allow accessing raw created/modified FILETIME This is necessary to correctly compute the authenticode hash of an MSI file[0]. While it's technically possible to get the FILETIME back from the SystemTime, it's a lossy operation (a FILETIME that doesn't fit in a SystemTime returns UNIX_TIME). It'd be nicer to just have access to the raw value so we can guarantee we're hashing the correct value. [0]: http://github.com/ralphje/signify/blob/master/signify/authenticode/signed_file/msi.py --- src/internal/entry.rs | 12 ++++++++++++ src/internal/timestamp.rs | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/internal/entry.rs b/src/internal/entry.rs index 83a1eeb..3d21e45 100644 --- a/src/internal/entry.rs +++ b/src/internal/entry.rs @@ -89,11 +89,23 @@ impl Entry { self.creation_time.to_system_time() } + /// Returns the raw FILETIME value of [`created`], as it is stored in the + /// file. + pub fn created_raw(&self) -> u64 { + self.creation_time.raw_value() + } + /// Returns the time when the object that this entry represents was last /// modified. pub fn modified(&self) -> SystemTime { self.modified_time.to_system_time() } + + /// Returns the raw FILETIME value of [`modified`], as it is stored in the + /// file. + pub fn modified_raw(&self) -> u64 { + self.modified_time.raw_value() + } } impl fmt::Debug for Entry { diff --git a/src/internal/timestamp.rs b/src/internal/timestamp.rs index 4c24147..c61eade 100644 --- a/src/internal/timestamp.rs +++ b/src/internal/timestamp.rs @@ -36,6 +36,11 @@ impl Timestamp { system_time_from_timestamp(self.0) } + /// Returns the raw FILETIME value. + pub fn raw_value(self) -> u64 { + self.0 + } + pub fn read_from(reader: &mut R) -> io::Result { Ok(Timestamp(reader.read_le_u64()?)) }