Skip to content

Commit

Permalink
ssh-key: set maximum UnixTime to i64::MAX (#175)
Browse files Browse the repository at this point in the history
`ssh-keygen` uses `i64::MAX` as its placeholder value for certificates
which last "forever".

This allows such certificates to parse, albeit at the cost of allowing
all sorts of bogus timestamps.

Closes #174
  • Loading branch information
tarcieri authored Nov 18, 2023
1 parent fc0195b commit dd25fab
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ssh-key/src/certificate/unix_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ use encoding::{Decode, Encode, Reader, Writer};
#[cfg(feature = "std")]
use std::time::{Duration, SystemTime, UNIX_EPOCH};

/// Maximum allowed value for a Unix timestamp:
///
/// 9999-12-31 23:59:59 UTC
///
/// This is a sanity limit intended to catch nonsense values which are
/// excessively far in the future. Otherwise the limit is `i64::MAX`.
pub const MAX_SECS: u64 = 253402300799;
/// Maximum allowed value for a Unix timestamp.
pub const MAX_SECS: u64 = i64::MAX as u64;

/// Unix timestamps as used in OpenSSH certificates.
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord)]
Expand Down

0 comments on commit dd25fab

Please sign in to comment.