Skip to content

Allow TstInfo to read GeneralizedTime with subseconds - #2063

Merged
baloo merged 1 commit into
RustCrypto:masterfrom
roblabla:generalized-time-subsecs-tsp
Oct 11, 2025
Merged

Allow TstInfo to read GeneralizedTime with subseconds#2063
baloo merged 1 commit into
RustCrypto:masterfrom
roblabla:generalized-time-subsecs-tsp

Conversation

@roblabla

Copy link
Copy Markdown
Contributor

Adds a new type GeneralizedTimeWithSubseconds which allows parsing a GeneralizedTime according to the DER restrictions and not the RFC5280 restrictions - meaning it can get subseconds.

The type is added to x509-tsp since that is the only known user of the type, though maybe it'd be more appropriate to move it to der? (That would allow it to share some of the decoder functions with GeneralizedTime).

Internally, it's represented as a DateTime (The same internal type used by GeneralizedTime) and an additional nanoseconds u32. We don't parse subseconds more precise than NS precision - that felt like an appropriate cutoff point.

CC #365

@roblabla
roblablaforce-pushed the generalized-time-subsecs-tsp branch 2 times, most recently from 1a9b484 to c503b72CompareOctober 10, 2025 11:36
Comment threadx509-tsp/src/generalized_time_with_subseconds.rs Outdated
@dishmaker

dishmaker commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

What about GeneralizedTimeNanos or GeneralizedTimePrecise ?

Comment threadx509-tsp/src/generalized_time_with_subseconds.rs Outdated
Comment threadx509-tsp/src/generalized_time_with_subseconds.rs Outdated
@dishmaker

dishmaker commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Also test:

  • 20241007145010.Z
  • 20241007145010.1Z
  • 20241007145010.123Z
  • ...
  • 20241007145010.123456789Z

@tarcieri

Copy link
Copy Markdown
Member

I’d agree the GeneralizedTimeWithSubseconds name feels a little long

@roblabla

Copy link
Copy Markdown
ContributorAuthor

Yeah I expected some bikeshedding around the name ^^. GeneralizedTimeNanos sounds good to me.

@roblabla
roblablaforce-pushed the generalized-time-subsecs-tsp branch 2 times, most recently from 35af114 to a6aa469CompareOctober 10, 2025 15:33
Comment threadx509-tsp/src/generalized_time_nanos.rs
@dishmaker

Copy link
Copy Markdown
Contributor

Oh. I thought you'd make a test loop 0..=9 😅

@roblabla
roblablaforce-pushed the generalized-time-subsecs-tsp branch 3 times, most recently from 38bcbb8 to c71a7e7CompareOctober 10, 2025 18:56
@roblabla
roblablaforce-pushed the generalized-time-subsecs-tsp branch from c71a7e7 to 132c9c9CompareOctober 10, 2025 18:58
@baloo
baloo merged commit a3c8934 into RustCrypto:masterOct 11, 2025
11 checks passed
roblabla added a commit to JustRustThings/formats that referenced this pull request Oct 14, 2025
roblabla added a commit to JustRustThings/formats that referenced this pull request Oct 14, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@roblabla@dishmaker@tarcieri@baloo