rusticata / asn1-rs

Parsers/Encoders for ASN.1 BER/DER data
Apache License 2.0
9 stars 14 forks source link

Introduce utc_adjusted_date() to handle 2 digit years #10

Closed la10736 closed 2 years ago

la10736 commented 2 years ago

Hi, I see that BouncyCastle Java lib use adjusted date to distinguish from the raw encoded date and a date that can have sense.

So instead modify utc_datetime() I've introduced utc_adjusted_datetime().

Sorry, I add for mistake .vscode conf file and then removed it.

Finally I saw a lot of duplication and tests with bunch of asserts that should be in separated tests... If you are interested I can introduce rstest and start to rewrite some tests... disclaimer: I'm the rstest maintainer :smile:

la10736 commented 2 years ago

I forget to mention that this fix #9

la10736 commented 2 years ago

Ok, I'll fix it ASAP.

p.s. I've checked the section is 42.3 in X.680 specification: thanks to point it out.

chifflier commented 2 years ago

Ok, I'll fix it ASAP.

Thanks!

p.s. I've checked the section is 42.3 in X.680 specification: thanks to point it out.

Here, I have the following: 42.3 is for GeneralizedTime, which uses 4-digits notation for year 43.3 is for UniversalTime and mentions "two low-order digits of the Christian year"

Anyway, this was more to mention that this is an ASN.1 rule, not especially X.509

la10736 commented 2 years ago

Ok ... I'll put 43.3 but in https://www.itu.int/ITU-T/studygroups/com10/languages/X.680_1297.pdf it is referenced in 42.3... I guess that's just a dettail

chifflier commented 2 years ago

Ok ... I'll put 43.3 but in https://www.itu.int/ITU-T/studygroups/com10/languages/X.680_1297.pdf it is referenced in 42.3... I guess that's just a dettail

Oh, I see. We were not referring to the same revision of the X.680 document :)

According to the latest version pointed here, latest revision is 02/2021, in which the section is now ... 47.3!

Can we just refer to something generic like "Universal time definition in X.680"?

chifflier commented 2 years ago

Merged, thanks!