librasn / rasn

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

UnbindRequest encodes/decodes incorrectly #225

Closed michaldrabina closed 4 months ago

michaldrabina commented 4 months ago

Encoding rasn-ldap::UnbindRequest into the ber format results in [0x62, 0], but the correct encoding should be [0x42, 0]. This also leads to decoding failures of correctly encoded messages.

The difference is in the 5th bit in tag (primitive/constructed). Since UnbindRequest request is a struct, it gets encoded as a sequence, with the bit set to 1 (constructed). Correctly it should be set to primitive, as it's just NULL with tag (https://datatracker.ietf.org/doc/html/rfc4511#section-4.3).

I've checked the encoding against libldap based tools (e.g. ldapsearch).