mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
97 stars 71 forks source link

Continuous OCTET STRING JER string #137

Closed v0-e closed 1 year ago

v0-e commented 1 year ago

Per X.697 (section 25.3), a JER-encoded OCTET STRING must be a JSON string with continuous hexadecimal digits. To be a valid JSON string, the output also cannot have line breaks. This PR fixes both of these issues.

Consider the definition TEST,

TEST ::= SEQUENCE {
   i1 INTEGER,
   os OCTET STRING,
   i2 INTEGER
}

With i1=1, os={1,2,...,32}, and i2=2, this currently encodes to,

{
"TEST":{

    "i1": 1,
    "os":
        00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
        "02 00 00 00 00 00 00 00 18 19 1A 1B 1C 1D 1E 1F"
    ,
    "i2": 2}
}

With this PR the above becomes,

{
"TEST":{

    "i1": 1,
    "os": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F",
    "i2": 2}
}