summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-11-17 12:50:46 +0100
committerJustus Winter <justus@sequoia-pgp.org>2021-11-18 14:10:55 +0100
commitb56ea7ab07626ff37e14f0c15c6252b7627a6b72 (patch)
tree595c6a5d11b2db7e9141384a32762052440193ce /openpgp/src/packet
parent991c759dd710bab903baa32dff8dc1fc18e78e3b (diff)
openpgp: Use a WASM-friendly SystemTime::now wrapper.
- Fixes #769.
Diffstat (limited to 'openpgp/src/packet')
-rw-r--r--openpgp/src/packet/key.rs6
-rw-r--r--openpgp/src/packet/signature.rs6
-rw-r--r--openpgp/src/packet/signature/subpacket.rs8
3 files changed, 10 insertions, 10 deletions
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs
index 07fc9d2d..6e75c604 100644
--- a/openpgp/src/packet/key.rs
+++ b/openpgp/src/packet/key.rs
@@ -952,7 +952,7 @@ impl<R> Key4<key::PublicParts, R>
point.insert(0, 0x40);
Self::new(
- ctime.into().unwrap_or_else(time::SystemTime::now),
+ ctime.into().unwrap_or_else(crate::now),
PublicKeyAlgorithm::ECDH,
mpi::PublicKey::ECDH {
curve: Curve::Cv25519,
@@ -976,7 +976,7 @@ impl<R> Key4<key::PublicParts, R>
point.insert(0, 0x40);
Self::new(
- ctime.into().unwrap_or_else(time::SystemTime::now),
+ ctime.into().unwrap_or_else(crate::now),
PublicKeyAlgorithm::EdDSA,
mpi::PublicKey::EdDSA {
curve: Curve::Ed25519,
@@ -994,7 +994,7 @@ impl<R> Key4<key::PublicParts, R>
-> Result<Self> where T: Into<Option<time::SystemTime>>
{
Self::new(
- ctime.into().unwrap_or_else(time::SystemTime::now),
+ ctime.into().unwrap_or_else(crate::now),
PublicKeyAlgorithm::RSAEncryptSign,
mpi::PublicKey::RSA {
e: mpi::MPI::new(e),
diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs
index aa19c130..e8d81904 100644
--- a/openpgp/src/packet/signature.rs
+++ b/openpgp/src/packet/signature.rs
@@ -1607,10 +1607,10 @@ impl SignatureBuilder {
if let Some(oct) = self.original_creation_time {
let t =
(oct + time::Duration::new(1, 0)).max(
- time::SystemTime::now() -
+ crate::now() -
time::Duration::new(SIG_BACKDATE_BY, 0));
- if t > time::SystemTime::now() {
+ if t > crate::now() {
return Err(Error::InvalidOperation(
"Cannot create valid signature newer than template"
.into()).into());
@@ -1618,7 +1618,7 @@ impl SignatureBuilder {
self.set_signature_creation_time(t)?
} else {
- self.set_signature_creation_time(time::SystemTime::now())?
+ self.set_signature_creation_time(crate::now())?
};
}
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index f8a5873a..e26375bd 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -2500,10 +2500,10 @@ impl SubpacketAreas {
let (time, tolerance)
= match (time.into(), clock_skew_tolerance.into()) {
(None, None) =>
- (time::SystemTime::now(),
+ (crate::now(),
*CLOCK_SKEW_TOLERANCE),
(None, Some(tolerance)) =>
- (time::SystemTime::now(),
+ (crate::now(),
tolerance),
(Some(time), None) =>
(time, time::Duration::new(0, 0)),
@@ -2695,7 +2695,7 @@ impl SubpacketAreas {
R: key::KeyRole,
T: Into<Option<time::SystemTime>>
{
- let t = t.into().unwrap_or_else(time::SystemTime::now);
+ let t = t.into().unwrap_or_else(crate::now);
match self.key_validity_period() {
Some(e) if e.as_secs() > 0 && key.creation_time() + e <= t =>
@@ -7028,7 +7028,7 @@ fn accessors() {
// Cook up a timestamp without ns resolution.
use std::convert::TryFrom;
let now: time::SystemTime =
- Timestamp::try_from(time::SystemTime::now()).unwrap().into();
+ Timestamp::try_from(crate::now()).unwrap().into();
sig = sig.set_signature_creation_time(now).unwrap();
let sig_ =