This commit is contained in:
AJ ONeal 2018-11-21 19:08:08 -07:00
parent f804728831
commit 41312c53ac

View file

@ -23,13 +23,11 @@ ASN1.parse = function parseAsn1(buf, depth) {
asn1.lengthSize = 0x7f & asn1.length; asn1.lengthSize = 0x7f & asn1.length;
// I think that buf->hex->int solves the problem of Endianness... not sure // I think that buf->hex->int solves the problem of Endianness... not sure
asn1.length = parseInt(buf.slice(index, index + asn1.lengthSize).toString('hex'), 16); asn1.length = parseInt(buf.slice(index, index + asn1.lengthSize).toString('hex'), 16);
//index += 1; // add back the original byte indicating lengthSize
index += asn1.lengthSize; index += asn1.lengthSize;
} }
// this is a primitive value type // this is a primitive value type
if (-1 !== VTYPES.indexOf(asn1.type)) { if (-1 !== VTYPES.indexOf(asn1.type)) {
//console.log('t', asn1.type);
asn1.value = buf.slice(index, index + asn1.length); asn1.value = buf.slice(index, index + asn1.length);
return asn1; return asn1;
} }
@ -39,7 +37,6 @@ ASN1.parse = function parseAsn1(buf, depth) {
iters += 1; iters += 1;
child = ASN1.parse(buf.slice(index, index + asn1.length), (depth || 0) + 1); child = ASN1.parse(buf.slice(index, index + asn1.length), (depth || 0) + 1);
index += (2 + child.lengthSize + child.length); index += (2 + child.lengthSize + child.length);
//console.log('buflen', buf.byteLength, 'index', index);
asn1.children.push(child); asn1.children.push(child);
} }
if (iters >= 100) { throw new Error(ELOOP); } if (iters >= 100) { throw new Error(ELOOP); }