Closed jblestang closed 3 years ago
Thank you for your feedback. As you might have understood, ITUT X.680 is saying many things that are rarely used in practice. And this case of string characters noted by their numerical value is one of this that, I never met and did not implement in pycrate.
The code that parses alphabet constraint is here: https://github.com/P1sec/pycrate/blob/bb67b3f95454c65de9131a258589349dfaf7b3b9/pycrate_asn1c/asnobj.py#L4163 It relies on parsing string value, implemented here: https://github.com/P1sec/pycrate/blob/bb67b3f95454c65de9131a258589349dfaf7b3b9/pycrate_asn1c/asnobj.py#L5128
Parsing characters by their numerical value may be easy for basic ascii-based strings, but may get more complex for special string objects relying on custom character tables.
Using and hexadecimal approach and double quotes instead of single quotes seems to let me validate my ASN.1 using pycrate.
emitterId IA5String (FROM(“\x00”|”0”..”9”|”A”..”Z”))
This is nice, thanks for your feedback.
From the existing ASN.1 directories in pycrate, it seems double-quote is the way to go for alphabet constraints. E.g.:
./ITUT_H225_2009-12/H323-MESSAGES.asn:719:TBCD-STRING ::= IA5String(FROM ("0123456789#*abc"))
./ITUT_H225_2009-12/H323-MESSAGES.asn:808:IsupDigits ::= IA5String(SIZE (1..128))(FROM ("0123456789ABCDE"))
./ITUT_H245_2011-05/MULTIMEDIA-SYSTEM-CONTROL.asn:1784: e164Address IA5String(SIZE(1..128)) (FROM ("0123456789#*,")),
./ITUT_H245_2011-05/MULTIMEDIA-SYSTEM-CONTROL.asn:4185: signalType IA5String (SIZE (1) ^ FROM ("0123456789#*ABCD!")),
./OMA_LPPe/LPPe.asn:311:OMA-LPPe-CharArray ::= VisibleString(FROM ("a".."z" | "A".."Z" | "0".."9" | ".-"))(SIZE (1..31))
./OMA_ULP/ULP-Components.asn:731: ims-public-identity VisibleString(FROM ("a".."z" | "A".."Z" | "0".."9" | ":./-_~#@?")) (SIZE (1..255)),
I'm trying to add constraints on an IA5String which shall allow from my understanding all values in the range [0;127]
Pycrate is giving me the following error when I'm trying to validate my ASN.1 :
§43.8 of X.680 states that any value in the range [0;127] are authorized. I'm wondering wether my syntax/understanding of how to specify control characters is correct or if pycrate does not support expressing characters using the 'cell/row' notation.