diff --git a/lib/asn1.js b/lib/asn1.js index 6407bf9..bb40710 100644 --- a/lib/asn1.js +++ b/lib/asn1.js @@ -163,23 +163,27 @@ ASN1.tpl = function (asn1) { var val; if ('number' !== typeof k) { // ignore - } else if (k) { - str += ', '; } else { - str += ' '; + str += ', '; } if (0x02 === asn1.type) { str += "ASN1.UInt("; } else if (0x03 === asn1.type) { str += "ASN1.BitStr("; } else { - str += "ASN1('" + Enc.numToHex(asn1.type) + "', "; + str += "ASN1('" + Enc.numToHex(asn1.type) + "'"; } if (!asn1.children) { - val = Buffer.from(asn1.value || ''); - vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '" + if (0x05 !== asn1.type) { + val = Buffer.from(asn1.value || ''); + vars.push("// 0x" + Enc.numToHex(val.byteLength) + " (" + val.byteLength + " bytes)\nvar tpl" + i + " = '" + Enc.bufToHex(val) + "';"); - str += "tpl" + i + ")"; + if (0x02 !== asn1.type && 0x03 !== asn1.type) { + str += ", "; + } + str += "tpl" + i; + } + str += ")"; return ; } asn1.children.forEach(function (a, j) {