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
Hi,

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:

{exclusive_decode,{ocsp,[
  {decode_basic_ocsp_response,['BasicOCSPResponse',[{certs,parts}]]}
]}}.

But this fails with the following exception:

** exception error: no function clause matching 
                    ocsp:decode_tag_and_length({asn1,"tag failure",16,
                                                         {1,131072,
                                                          <<48,130,4,232,48,130,4,228,48,130,3,204,160,3,2,1,2,2,9,
                                                            0,227,...>>,
                                                          <<>>}}) (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?

Thanks,

Bram


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions