--- Convert-BER-XS/XS.pm 2019/04/20 15:27:28 1.27 +++ Convert-BER-XS/XS.pm 2019/04/20 15:37:27 1.28 @@ -102,7 +102,7 @@ The BER tuple array index constants: - BER_CLASS BER_TAG BER_CONSTRUCTED BER_DATA + BER_CLASS BER_TAG BER_FLAGS BER_DATA =item C<:const_asn> @@ -184,7 +184,7 @@ This module represents every BER value as a 4-element tuple (actually an array-reference): - [CLASS, TAG, CONSTRUCTED, DATA] + [CLASS, TAG, FLAGS, DATA] For example: @@ -195,7 +195,7 @@ To avoid non-descriptive hardcoded array index numbers, this module defines symbolic constants to access these members: C, -C, C and C. +C, C and C. Also, the first three members are integers with a little caveat: for performance reasons, these are readonly and shared, so you must not modify @@ -205,7 +205,7 @@ $ber = ber_decode $binbuf; # the following is NOT legal: - $ber->[BER_CLASS] = ASN_PRIVATE; # ERROR, CLASS/TAG/CONSTRUCTED are READ ONLY(!) + $ber->[BER_CLASS] = ASN_PRIVATE; # ERROR, CLASS/TAG/FLAGS are READ ONLY(!) # but all of the following are fine: $ber->[BER_DATA] = "string"; @@ -233,16 +233,16 @@ C, C, C and C. -The I flag is really just a boolean - if it is false, -the value is "primitive" and contains no subvalues, kind of like a -non-reference perl scalar. If it is true, then the value is "constructed" -which just means it contains a list of subvalues which this module will -en-/decode as BER tuples themselves. - -The I value is either a reference to an array of further tuples (if -the value is I), some decoded representation of the value, -if this module knows how to decode it (e.g. for the integer types above) -or a binary string with the raw octets if this module doesn't know how to +The I value is really just a boolean at this time (but might +get extended) - if it is C<0>, the value is "primitive" and contains +no subvalues, kind of like a non-reference perl scalar. If it is C<1>, +then the value is "constructed" which just means it contains a list of +subvalues which this module will en-/decode as BER tuples themselves. + +The I value is either a reference to an array of further tuples +(if the value is I), some decoded representation of the value, if +this module knows how to decode it (e.g. for the integer types above) or +a binary string with the raw octets if this module doesn't know how to interpret the namespace/tag. Thus, you can always decode a BER data structure and at worst you get a @@ -282,6 +282,9 @@ Encodes the BER tuple into a BER/DER data structure. AS with Cyber_decode>, an optional profile can be given. +The encoded data should be both BER and DER ("shortest form") compliant +unless the input says otherwise (e.g. it uses constructed strings). + =back =head2 HELPER FUNCTIONS @@ -398,7 +401,7 @@ our %EXPORT_TAGS = ( const_index => [qw( - BER_CLASS BER_TAG BER_CONSTRUCTED BER_DATA + BER_CLASS BER_TAG BER_FLAGS BER_DATA )], const_asn => [qw( ASN_BOOLEAN ASN_INTEGER ASN_BIT_STRING ASN_OCTET_STRING ASN_NULL ASN_OBJECT_IDENTIFIER @@ -611,6 +614,11 @@ much larger than e.g. the one imposed by SNMP or other protocols,a nd is about 4kB. +Indefinite length encoding is not supported. + +Constructed strings are decoded just fine, but there should be a way to +join them for convenience. + REAL values are not supported and will currently croak. This module has undergone little to no testing so far.