Skip to content

Commit

Permalink
Merge pull request #4 from dgwynne/master
Browse files Browse the repository at this point in the history
simplify readOID by reusing readString
  • Loading branch information
mcavage committed Feb 8, 2012
2 parents 8f5eea9 + b987bca commit a2cb0f6
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions lib/ber/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,28 +183,15 @@ Reader.prototype.readOID = function(tag) {
if (!tag)
tag = ASN1.OID;

var b = this.peek();
var b = this.readString(tag, true);
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;
for (var i = 0; i < b.length; i++) {
var byte = b[i] & 0xff;

value <<= 7;
value += byte & 0x7f;
Expand Down

0 comments on commit a2cb0f6

Please sign in to comment.