Skip to content

Add GeneralizedTime#492

Merged
alex merged 15 commits into
alex:mainfrom
trail-of-forks:dm/add-generalized-time-fractional
Nov 3, 2024
Merged

Add GeneralizedTime#492
alex merged 15 commits into
alex:mainfrom
trail-of-forks:dm/add-generalized-time-fractional

Conversation

@DarkaMaul

Copy link
Copy Markdown
Contributor

Fixes #491

/cc @woodruffw

Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Comment thread src/types.rs Outdated
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
@DarkaMaul

Copy link
Copy Markdown
Contributor Author

I've used a nanoseconds precision for the fractional time ( from 1 to 10^9) but I can't find a reference saying that the value is bounded (or not).

From T-REC-X.680-202102-I!!PDF-E.pdf, it seems the precision is arbitrary

2) a string representing the time of day to an accuracy of one hour, one minute, one second, or
fractions of a second (to any degree of accuracy), using either comma or full stop as the decimal sign (as
specified in ISO 8601, 4.2.2.2 and 4.2.2.3 – Basic format); optionally followed by:

And the X.690-0207 spec only says that the second is required:

11.7.2 The seconds element shall always be present. 

However, the Quick ASN1 reference uses a 3 digit representation for the floating part.

What would be the best option here?

@alex

alex commented Oct 25, 2024 via email

Copy link
Copy Markdown
Owner

Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
@DarkaMaul

Copy link
Copy Markdown
Contributor Author

Grumble. Nanosecond precision is fine. But this also means the prohibition on leading 0s is wrong, right?

I think this one is still valid as it stems from :

11.7.3 The fractional-seconds elements, if present, shall omit all trailing zeros; if the elements correspond to 0, they
shall be wholly omitted, and the decimal point element also shall be omitted. 

@alex

alex commented Oct 25, 2024 via email

Copy link
Copy Markdown
Owner

@DarkaMaul

Copy link
Copy Markdown
Contributor Author

Trailing and leading zeros are the opposite :-)
😮‍💨 Yes indeed - let me update the PR ...

Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Comment thread src/types.rs Outdated
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
@alex

alex commented Oct 25, 2024

Copy link
Copy Markdown
Owner

Apologies in advance, but For simplicity of review, I think pulling the "rename GeneralizedTime" into its own PR probably is the best path.

@DarkaMaul DarkaMaul force-pushed the dm/add-generalized-time-fractional branch from ace99a6 to 031bfb4 Compare October 25, 2024 15:35
@DarkaMaul DarkaMaul changed the title Add GeneralizedTimeFractional Add GeneralizedTime Oct 29, 2024
Comment thread README.md Outdated
Signed-off-by: William Woodruff <william@trailofbits.com>
Comment thread src/types.rs
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in
/// `GeneralizedTime`.
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)]
pub struct DateTime {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should DateTime just have an optional nanoseconds field?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, missed this earlier. I don't have a super strong opinion -- I think @DarkaMaul put the nanos on GeneralizedTime since UTCTime has no fractional time support at all, so having it on the top-level DateTime used by both seems (slightly) off.

OTOH having it on GeneralizedTime also seems slightly off, since it's now (DateTime, nanos). So I'm happy to move if you'd prefer.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, let's get the docs right on the generalized tiem strcut and that'll be good enough. (See my other comment)

Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Signed-off-by: William Woodruff <william@trailofbits.com>
Keeps us in a stack buf.

Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>

@alex alex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last open question

Comment thread src/types.rs
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in
/// `GeneralizedTime`.
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)]
pub struct DateTime {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts here?

Comment thread src/types.rs Outdated

/// Used for parsing and writing ASN.1 `GENERALIZED TIME` values accepting
/// fractional seconds value.
/// See https://github.com/alex/rust-asn1/issues/491 for discussion.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be updated to just describe the type, not reference an issue about how things used to be.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment thread src/types.rs
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in
/// `GeneralizedTime`.
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)]
pub struct DateTime {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, let's get the docs right on the generalized tiem strcut and that'll be good enough. (See my other comment)

Comment thread src/types.rs Outdated
@alex alex merged commit e37fa65 into alex:main Nov 3, 2024
@woodruffw woodruffw deleted the dm/add-generalized-time-fractional branch November 3, 2024 20:41
Sign up for free to 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.

GeneralizedTime: support for fractional seconds?

3 participants