With the new support for IMPLICIT
tags such as used by LDAP, many things now work better. But there are exceptions not yet solved. Take this LDAPMessage
for instance,
SEQUENCE (OF): tag 0x30 #12 @0 ^0, Universal, Constructed
INTEGER: tag 0x02 #1 @2 ^1, Universal, Primitive
01 == 1
[APPLICATION 0]: tag 0x60 #7 @5 ^1, Application, Constructed
INTEGER: tag 0x02 #1 @7 ^2, Universal, Primitive
03 == 3
OCTETSTRING: tag 0x04 #0 @10 ^2, Universal, Primitive
[0]: tag 0x80 #0 @12 ^2, Contextual, Primitive
Note how nothing is contained in the [0]
tag on the last line. This is possible when the contained information is elementary, empty and implicitly tagged. This is indeed the case, if we look at the definitions:
BindRequest ::= [APPLICATION 0] SEQUENCE {
version INTEGER (1 .. 127),
name LDAPDN,
authentication AuthenticationChoice }
AuthenticationChoice ::= CHOICE {
simple [0] OCTET STRING,
-- 1 and 2 reserved
sasl [3] SaslCredentials,
... }
This however, translates to:
#define DER_PACK_rfc4511_BindRequest \
DER_PACK_ENTER | DER_TAG_APPLICATION(0), \
DER_PACK_STORE | DER_TAG_INTEGER, \
DER_PACK_rfc4511_LDAPDN, \
DER_PACK_rfc4511_AuthenticationChoice, \
DER_PACK_LEAVE
#define DER_PACK_rfc4511_AuthenticationChoice \
DER_PACK_CHOICE_BEGIN, \
DER_PACK_ENTER | DER_TAG_CONTEXT(0), \
DER_PACK_STORE | DER_PACK_ANY, \
DER_PACK_LEAVE, \
DER_PACK_ENTER | DER_TAG_CONTEXT(3), \
DER_PIMP_rfc4511_SaslCredentials, \
DER_PACK_LEAVE/* ...ASN.1 extensions... */, \
DER_PACK_CHOICE_END
The problem lies in the DER_PACK_STORE | DER_PACK_ANY
nested within the DER_PACK_ENTER | DER_TAG_CONTEXT(0)
of DER_PACK_rfc4511_AuthenticationChoice
. This does not seem to capture an empty string (and probably nothing that is not proper DER-encoded data, so header / length / value format.
What needs to be done, is replace these three lines
DER_PACK_ENTER | DER_TAG_CONTEXT(0), \
DER_PACK_STORE | DER_PACK_ANY, \
DER_PACK_LEAVE, \
with the single line
DER_PACK_STORE | DER_TAG_CONTEXT(0), \
This way, the structure is stored without any attempt to entering it -- which is the intention.