ASN1 exclusive decode failure

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

ASN1 exclusive decode failure

Bram Verburg

I'm trying to decode an OCSP basic response:

BasicOCSPResponse ::= SEQUENCE {
  tbsResponseData          ResponseData,
  signatureAlgorithm       AlgorithmIdentifier,
  signature                BIT STRING,
  certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }

I would like the 'certs' element to be returned as-is, basically as a list of DER certificates which I may or may not decode later. I was hoping I could use 'exclusive_decode', with the following asn1config:


But this fails with the following exception:

** exception error: no function clause matching 
                    ocsp:decode_tag_and_length({asn1,"tag failure",16,
                                                          <<>>}}) (ocsp.erl, line 2051)
     in function  ocsp:decode_primitive_incomplete/2 (ocsp.erl, line 2026)
     in call from ocsp:decode_constructed_incomplete/2 (ocsp.erl, line 1828)
     in call from ocsp:decode_constructed_incomplete/2 (ocsp.erl, line 1830)
     in call from ocsp:decode_constructed_incomplete/2 (ocsp.erl, line 1808)
     in call from ocsp:decode_incomplete2/5 (ocsp.erl, line 21848)
     in call from ocsp:decode_partial_incomplete/3 (ocsp.erl, line 1190)

A full BasicOCSPResponse decode of the same binary works fine, returning a list of Certificate records in the certs element, so the source data is valid.

Is there any reason why the exclusive_decode 'parts' action might not work for this particular SEQUENCE, perhaps because it is explicit + optional?



erlang-questions mailing list
[hidden email]