rusticata / asn1-rs

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

Convert UTCTime to datetime should care about century #9

Closed la10736 closed 2 years ago

la10736 commented 2 years ago

Hi, thanks for the great work!!

I noted that the conversion from utc_datetime() don't try to guess the century. As documented in https://www.obj-sys.com/asn1tutorial/node15.html the year is just 2 chars and asn1c use 19 if the year is greater than 0x35 and 20 otherwise.

I guess that the right behavior of asn1-rs should be the same.

I can file a pull request if you are agree.

chifflier commented 2 years ago

Hi, Indeed, this should be added to this crate. Currently, callers must take care of changing the offset (for ex in https://github.com/rusticata/x509-parser/blob/master/src/time.rs#L99-L109). Please submit a PR, I will merge it for the next release (which I plan to do very soon). Thanks!