ldap - BER Encoding of a "Choice" -


i trying parse ldap bind request using apache harmony asn.1/ber classes (could use library, chose has apache license).

my question on encoding of "choice" in asn.1. rfc defines ldap asn.1 schema (http://www.rfc-editor.org/rfc/rfc2251.txt) gives following part bind request:

   bindrequest ::= [application 0] sequence {             version                 integer (1 .. 127),             name                    ldapdn,             authentication          authenticationchoice }      authenticationchoice ::= choice {             simple                  [0] octet string,                                      -- 1 , 2 reserved             sasl                    [3] saslcredentials }      saslcredentials ::= sequence {             mechanism               ldapstring,             credentials             octet string optional } 

how choice there encoded?

i generated sample bind request using jxplorer , captured raw data sent. looks this:

00000000  30 31 02 01 01 60 2c 02  01 03 04 1b 75 69 64 3d  |01...`,.....uid=| 00000010  74 65 73 74 75 73 65 72  2c 64 63 3d 74 65 73 74  |testuser,dc=test| 00000020  2c 64 63 3d 63 6f 6d 80  0a 74 65 73 74 69 6e 67  |,dc=com..testing| 00000030  31 32 33                                          |123| 

the 80 there (at offset 0x27) seems represent choice. fair enough - , (per http://en.wikipedia.org/wiki/basic_encoding_rules#ber_encoding) last bit set in order indicate it's "context specific" (i.e. defined application/protocol) how know if "simple" or "sasl" auth? indicates option of choice being used? in case looks next byte (0x0a) length of string - octetstring or of sort - don't see here indicates actual other 0x80...

i'm not sure [0] , [3] mean in choice section above. saying there 4 options options numbered 0 , 3 in use?

below can see output of openssl asn1parse command. choice members encoded using called context specific tags - means normal tag value replaced 1 specified in asn.1 definition respective item in choice. tag has value 0 implicates first item in choice selected. first choice item of type octet string. value 0 of context specific tag gives information value type. if there no context tag, normal octet string tag used.

 0:d=0  hl=2 l=  49 cons: sequence            2:d=1  hl=2 l=   1 prim:  integer           :01  5:d=1  hl=2 l=  44 cons:  appl [ 0 ]          7:d=2  hl=2 l=   1 prim:   integer           :03 10:d=2  hl=2 l=  27 prim:   octet string      :uid=testuser,dc=test,dc=com 39:d=2  hl=2 l=  10 prim:   cont [ 0 ]         

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -