summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2022-01-21 15:42:59 +0100
committerJustus Winter <justus@sequoia-pgp.org>2022-01-21 15:48:56 +0100
commit827ee8254d194106809aea25090921c8d7802de7 (patch)
tree1ae62eaca5e913bf3b27496490fce55726fe26cb /openpgp/src/parse.rs
parentde209ea8a2593be7a45b81f86a8d82cf441640d2 (diff)
openpgp: Fix parsing and serializing keys on 32-bit time_t systems.
- Previously, during parsing and serialization, OpenPGP's unsigned 32-bit timestamps were converted to Rust's SystemTime, which uses time_t. On platforms where that is a signed 32-bit value, the time was truncated. See #668. - One way to fix that is to make Rust's SystemTime independent of time_t. See https://github.com/rust-lang/rust/issues/44394. - The other way is not to convert to SystemTime at the API boundary. See https://gitlab.com/sequoia-pgp/sequoia/-/issues/806. - This fixes handling during parsing and serialization, but doesn't address the API issue. - Fixes #802.
Diffstat (limited to 'openpgp/src/parse.rs')
-rw-r--r--openpgp/src/parse.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 3afc077c..d1b5a440 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -2229,8 +2229,7 @@ impl Key4<key::UnspecifiedParts, key::UnspecifiedRole>
-> Result<Key4<key::PublicParts, R>>
where R: key::KeyRole
{
- Key4::new(Timestamp::from(creation_time),
- pk_algo, mpis)
+ Key4::make(creation_time, pk_algo, mpis, None)
}
fn s<R>(creation_time: u32,
pk_algo: PublicKeyAlgorithm,
@@ -2239,8 +2238,7 @@ impl Key4<key::UnspecifiedParts, key::UnspecifiedRole>
-> Result<Key4<key::SecretParts, R>>
where R: key::KeyRole
{
- Key4::with_secret(Timestamp::from(creation_time),
- pk_algo, mpis, secret)
+ Key4::make(creation_time, pk_algo, mpis, Some(secret))
}
let tag = php.header.ctb().tag();