895797725e73d693a301f4c39e6551cf17491981 causes an error in the case of no tag in optional+any.
For example of ECC cert, decoding failed as below.
var fs = require('fs');
var rfc3280 = require('asn1.js/rfc/3280');
var Certificate = rfc3280.Certificate;
var SubjectPublicKeyInfo = rfc3280.SubjectPublicKeyInfo;
var der = fs.readFileSync('./ecc_cert.der');
var cert = Certificate.decode(der, 'der');
console.log(cert.tbsCertificate);
$ node test.js
/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/reporter.js:59
throw err;
^
Error: Failed to decode tag of "null" at: ["tbsCertificate"]["signature"]["parameters"]
at DecoderBuffer.error (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/reporter.js:53:11)
at DecoderBuffer.readUInt8 (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/buffer.js:42:17)
at derDecodeTag (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/decoders/der.js:227:17)
at DERNode.decodeTag [as _decodeTag] (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/decoders/der.js:50:20)
at DERNode.decode [as _decode] (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/node.js:302:23)
at decodeChildren (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/node.js:332:15)
at Array.some (native)
at DERNode.decode [as _decode] (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/node.js:329:33)
at DERNode.decodeGeneric [as _decodeGeneric] (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/node.js:372:62)
at DERNode.decode [as _decode] (/home/ohtsu/tmp/node_modules/asn1.js/lib/asn1/base/node.js:320:21)
This fix is to check if a tag exists even when state.any is true.
895797725e73d693a301f4c39e6551cf17491981 causes an error in the case of no tag in optional+any. For example of ECC cert, decoding failed as below.
This fix is to check if a tag exists even when state.any is true.