librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
183 stars 43 forks source link

fix(per): encoding extensible string types #179

Closed 6d7a closed 8 months ago

6d7a commented 8 months ago

This PR fixes a couple of issues with PER-encoding extensible string types, such as BIT STRING, OCTET STRING or VisibleString. Before, extensible string types were in some cases encoded with a duplicate extension marker, in some cases with a wrong length determinant. I also refactored the string encoders so that extension bits are always written using the encode_extensible_bit function, and removed some code duplication by having encode_length call the encode_string_length function, which is largely identical.

XAMPPRocky commented 8 months ago

Thank you for your PR! Could you add some test cases for this, to prevent future regressions?

6d7a commented 8 months ago

Sure, will do.

XAMPPRocky commented 8 months ago

Thank you for your PR!