diff options
-rw-r--r-- | openpgp/src/packet/signature/subpacket.rs | 13 | ||||
-rw-r--r-- | openpgp/src/serialize/mod.rs | 2 | ||||
-rw-r--r-- | tool/src/commands/dump.rs | 10 |
3 files changed, 16 insertions, 9 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs index 7737d327..5e1581d8 100644 --- a/openpgp/src/packet/signature/subpacket.rs +++ b/openpgp/src/packet/signature/subpacket.rs @@ -85,6 +85,7 @@ use crate::{ use crate::types::{ AEADAlgorithm, CompressionAlgorithm, + Duration, Features, HashAlgorithm, KeyFlags, @@ -96,7 +97,7 @@ use crate::types::{ }; use crate::conversions::{ Time, - Duration, + Duration as DurationConversion, }; lazy_static!{ @@ -130,8 +131,8 @@ lazy_static!{ /// is probably not what you want. pub static ref CLOCK_SKEW_TOLERANCE: time::Duration = time::Duration::new(30 * 60, 0); -} +} /// The subpacket types specified by [Section 5.2.3.1 of RFC 4880]. /// /// [Section 5.2.3.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.3.1 @@ -706,7 +707,7 @@ pub enum SubpacketValue<'a> { /// 4-octet time field SignatureCreationTime(Timestamp), /// 4-octet time field - SignatureExpirationTime(time::Duration), + SignatureExpirationTime(Duration), /// 1 octet of exportability, 0 for not, 1 for exportable ExportableCertification(bool), /// 1 octet "level" (depth), 1 octet of trust amount @@ -1002,7 +1003,7 @@ impl<'a> From<SubpacketRaw<'a>> for Subpacket<'a> { // The time delta is in big endian format. from_be_u32(raw.value).map(|v| { SubpacketValue::SignatureExpirationTime( - time::Duration::from_pgp(v)) + v.into()) }), SubpacketTag::ExportableCertification => @@ -1362,7 +1363,7 @@ impl SubpacketArea { if let Some(sb) = self.subpacket(SubpacketTag::SignatureExpirationTime) { if let SubpacketValue::SignatureExpirationTime(v) = sb.value { - Some(v) + Some(v.into()) } else { None } @@ -2394,7 +2395,7 @@ impl signature::Builder { -> Result<Self> { if let Some(e) = expiration { self.hashed_area.replace(Subpacket::new( - SubpacketValue::SignatureExpirationTime(e.canonicalize()), + SubpacketValue::SignatureExpirationTime(e.try_into()?), true)?)?; } else { self.hashed_area.remove_all(SubpacketTag::SignatureExpirationTime); diff --git a/openpgp/src/serialize/mod.rs b/openpgp/src/serialize/mod.rs index 5620ba11..6d4fd56c 100644 --- a/openpgp/src/serialize/mod.rs +++ b/openpgp/src/serialize/mod.rs @@ -980,7 +980,7 @@ impl<'a> Serialize for SubpacketValue<'a> { SignatureCreationTime(t) => write_be_u32(o, t.clone().into())?, SignatureExpirationTime(t) => - write_be_u32(o, t.to_pgp()?)?, + write_be_u32(o, t.clone().into())?, ExportableCertification(e) => o.write_all(&[if *e { 1 } else { 0 }])?, TrustSignature { ref level, ref trust } => diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 54aa407b..6b696ff3 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -1,7 +1,7 @@ use std::io::{self, Read}; extern crate sequoia_openpgp as openpgp; -use self::openpgp::types::{Timestamp, SymmetricAlgorithm}; +use self::openpgp::types::{Duration, Timestamp, SymmetricAlgorithm}; use self::openpgp::conversions::hex; use self::openpgp::crypto::mpis; use self::openpgp::{Packet, Result}; @@ -34,6 +34,12 @@ impl Convert<chrono::Duration> for std::time::Duration { } } +impl Convert<chrono::Duration> for Duration { + fn convert(self) -> chrono::Duration { + chrono::Duration::seconds(self.as_secs() as i64) + } +} + impl Convert<chrono::DateTime<chrono::offset::Utc>> for std::time::SystemTime { fn convert(self) -> chrono::DateTime<chrono::offset::Utc> { chrono::DateTime::<chrono::offset::Utc>::from(self) @@ -733,7 +739,7 @@ impl PacketDumper { write!(output, "{} Signature expiration time: {} ({})", i, t.convert(), if let Some(creation) = sig.signature_creation_time() { - (creation + *t).convert().to_string() + (creation + t.clone().into()).convert().to_string() } else { " (no Signature Creation Time subpacket)".into() })?, |