Closed Nicceboy closed 11 months ago
asn1rs
produces the same output than asn1tools
. Maybe that is the correct one.
[src/lib.rs:36] &writer.into_bytes_vec() = [
192,
16,
10,
104,
]
After many hours of debugging, the problem seems to be on the invalid range constraint when encoding the integer of Choice
selection.
When there are only two options on Choice
then both options can be described with single bit (either 0 or 1)
Minimum for range constraint was 3 so it always used 2 bits at minimum to encode the selection.
Seems like the issue of infinite recursion was not completely fixed in https://github.com/XAMPPRocky/rasn/issues/148 and https://github.com/XAMPPRocky/rasn/pull/157 .
The fix only works if some parent type is struct or set. In nested choices, the problem still occurs.
I tried fixing it by modifying the function
encode_explicit_prefix
to following:In OER it works, but in PER it works only for two levels, and on third level the values are halved for some reason?
asn1tools
example:Will produce
192, 16, 10, 10
.On
rasn
encoding, the output is exactly half:If I add one nesting level for
asn1tools
, then it produces the same output. Adding one nesting level more torasn
, it changes output to even smaller value (quarter of previous)Any ideas if there is some optimisation in PER which should not happen here?