librasn / compiler

An ASN1 compiler producing Rust bindings for the rasn framework
Other
10 stars 7 forks source link

add support for asn type DATE #27

Closed AMCON-Chenet closed 2 months ago

AMCON-Chenet commented 2 months ago

Hello,

is it possible to support the ASN1-type DATE? I have a sequence like this and can't generate code with the rasn-compiler.

common DEFINITIONS IMPLICIT TAGS ::=
BEGIN
EXPORTS ALL;
     Subject ::= [1] SEQUENCE {
         subjectName [1] UTF8String OPTIONAL,
         -- YYYY-MM-DD
         dateOfBirth [2] DATE OPTIONAL
    }
END
6d7a commented 2 months ago

Thank you for your issue. Currently the rasn framework does not support the DATE type, so the compiler does neither. Please feel free to open an issue here to request DATE support in rasn. Also, PRs are always welcome in case you want to contribute. As far as your example is concerned, the tags make me assume you are using BER, CER, or DER as encoding rules. As a dirty workaround, you could try changing the DATE type to UTF8String, since BER, CER, and DER encode DATEs as UTF8 strings, if I'm not mistaken.