You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like the issue of infinite recursion was not completely fixed in #148 and #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:
fnencode_explicit_prefix<V:Encode>(&mutself,tag:Tag,value:&V,) -> Result<Self::Ok,Self::Error>{ifletSome((_,true)) = self.field_bitfield.get(&tag){
value.encode(self)}elseifself.field_bitfield.get(&tag).is_none(){// There is no bitfield if none of the parent objects is struct/set// But we still need to handle nested choices explicitly
value.encode(self)}else{self.set_bit(tag,true)?;
value.encode_with_tag(self, tag)}}
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:
importasn1toolsdefmain():
# Compile the ASN.1 modulespec=asn1tools.compile_string(
"""MyModule DEFINITIONS AUTOMATIC TAGS ::= BEGIN Choice ::= CHOICE { normal INTEGER, high INTEGER, medium INTEGER } BoolChoice ::= CHOICE { a BOOLEAN, b BOOLEAN, c Choice } TripleChoice ::= CHOICE { a BOOLEAN, b BoolChoice } END""",
codec="uper",
)
# Encode a value# value = {'c': {'normal': 333}}value= ("b", ("c", ("normal", 333)))
encoded=spec.encode("TripleChoice", value)
# Print the encoded valueforeinencoded:
print(f"{e}, ", end="")
if__name__=="__main__":
main()
Will produce 192, 16, 10, 10.
On rasn encoding, the output is exactly half:
thread 'uper::tests::only_nested_choice' panicked at 'assertion failed: `(left == right)`Diff < left / right > : [< 192,< 16,< 10,< 104,
> 96,
> 8,
> 5,
> 52, ]
If I add one nesting level for asn1tools, then it produces the same output.
Adding one nesting level more to rasn, it changes output to even smaller value (quarter of previous)
Any ideas if there is some optimisation in PER which should not happen here?
The text was updated successfully, but these errors were encountered:
Seems like the issue of infinite recursion was not completely fixed in #148 and #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 to
rasn
, it changes output to even smaller value (quarter of previous)Any ideas if there is some optimisation in PER which should not happen here?
The text was updated successfully, but these errors were encountered: