Comparing version 0.1.10 to 0.1.11
@@ -182,3 +182,45 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
Reader.prototype.readOID = function(tag) { | ||
if (!tag) | ||
tag = ASN1.OID; | ||
var b = this.peek(); | ||
if (b === null) | ||
return null; | ||
if (b !== tag) | ||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) + | ||
': got 0x' + b.toString(16)); | ||
var o = this.readLength(this._offset + 1); // stored in `length` | ||
if (o === null) | ||
return null; | ||
if (this.length > this._size - o) | ||
return null; | ||
this._offset = o; | ||
var values = []; | ||
var value = 0; | ||
for (var i = 0; i < this.length; i++) { | ||
var byte = this._buf[this._offset++] & 0xff; | ||
value <<= 7; | ||
value += byte & 0x7f; | ||
if ((byte & 0x80) == 0) { | ||
values.push(value); | ||
value = 0; | ||
} | ||
} | ||
value = values.shift(); | ||
values.unshift(value % 40); | ||
values.unshift((value / 40) >> 0); | ||
return values.join('.'); | ||
}; | ||
Reader.prototype._readTag = function(tag) { | ||
@@ -185,0 +227,0 @@ assert.ok(tag !== undefined); |
@@ -12,3 +12,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
OID: 6, | ||
ObjectDescritor: 7, | ||
ObjectDescriptor: 7, | ||
External: 8, | ||
@@ -15,0 +15,0 @@ Real: 9, // float |
@@ -148,3 +148,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
Writer.prototype.writeBuffer = function (buf, tag) { | ||
Writer.prototype.writeBuffer = function(buf, tag) { | ||
if (typeof(tag) !== 'number') | ||
@@ -193,3 +193,3 @@ throw new TypeError('tag must be a number'); | ||
bytes.push(octet & 0x7F); | ||
} else if (id < 268435456) { | ||
} else if (octet < 268435456) { | ||
bytes.push((octet >>> 21) | 0x80); | ||
@@ -199,2 +199,8 @@ bytes.push(((octet >>> 14) | 0x80) & 0xFF); | ||
bytes.push(octet & 0x7F); | ||
} else { | ||
bytes.push(((octet >>> 28) | 0x80) & 0xFF); | ||
bytes.push(((octet >>> 21) | 0x80) & 0xFF); | ||
bytes.push(((octet >>> 14) | 0x80) & 0xFF); | ||
bytes.push(((octet >>> 7) | 0x80) & 0xFF); | ||
bytes.push(octet & 0x7F); | ||
} | ||
@@ -201,0 +207,0 @@ } |
{ | ||
"author": "Mark Cavage <mcavage@gmail.com>", | ||
"contributors": [ | ||
"David Gwynne <loki@animata.net>", | ||
"Yunong Xiao <yunong@joyent.com>" | ||
], | ||
"name": "asn1", | ||
"description": "Contains parsers and serializers for ASN.1 (currently BER only)", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"repository": { | ||
@@ -16,3 +20,3 @@ "type": "git", | ||
"devDependencies": { | ||
"tap": "0.1.2" | ||
"tap": "0.1.4" | ||
}, | ||
@@ -19,0 +23,0 @@ "scripts": { |
30489
870