-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GeneralizedTime #492
Add GeneralizedTime #492
Conversation
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
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
And the X.690-0207 spec only says that the
However, the Quick ASN1 reference uses a What would be the best option here? |
Grumble. Nanosecond precision is fine. But this also means the prohibition
on leading 0s is wrong, right?
…On Fri, Oct 25, 2024 at 8:19 AM dm ***@***.***> wrote:
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
<https://www.itu.int/rec/T-REC-X.680-202102-I>, 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
<https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference/generalizedtime.html>
uses a 3 digit representation for the floating part.
What would be the best option here?
—
Reply to this email directly, view it on GitHub
<#492 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBCFKLSONPCZY5IQESTZ5IZLJAVCNFSM6AAAAABQS5DC5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZXGYZTGNRRGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
I think this one is still valid as it stems from :
|
Trailing and leading zeros are the opposite :-)
…On Fri, Oct 25, 2024 at 9:04 AM dm ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
|
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Signed-off-by: Alexis <alexis.challande@trailofbits.com>
Apologies in advance, but For simplicity of review, I think pulling the "rename GeneralizedTime" into its own PR probably is the best path. |
ace99a6
to
031bfb4
Compare
Signed-off-by: William Woodruff <william@trailofbits.com>
@@ -914,7 +915,8 @@ fn push_four_digits(dest: &mut WriteBuf, val: u16) -> WriteResult { | |||
} | |||
|
|||
/// A structure representing a (UTC timezone) date and time. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime`. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in | |||
/// `GeneralizedTime`. | |||
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)] | |||
pub struct DateTime { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts here?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last open question
@@ -914,7 +915,8 @@ fn push_four_digits(dest: &mut WriteBuf, val: u16) -> WriteResult { | |||
} | |||
|
|||
/// A structure representing a (UTC timezone) date and time. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime`. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in | |||
/// `GeneralizedTime`. | |||
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)] | |||
pub struct DateTime { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts here?
src/types.rs
Outdated
@@ -1088,6 +1089,125 @@ impl SimpleAsn1Writable for X509GeneralizedTime { | |||
} | |||
} | |||
|
|||
/// 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -914,7 +915,8 @@ fn push_four_digits(dest: &mut WriteBuf, val: u16) -> WriteResult { | |||
} | |||
|
|||
/// A structure representing a (UTC timezone) date and time. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime`. | |||
/// Wrapped by `UtcTime` and `X509GeneralizedTime` and used in | |||
/// `GeneralizedTime`. | |||
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd)] | |||
pub struct DateTime { |
There was a problem hiding this comment.
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)
Fixes #491
/cc @woodruffw