asn1.js icon indicating copy to clipboard operation
asn1.js copied to clipboard

Number overflow (32 bits limit?)

Open b-zee opened this issue 7 years ago • 1 comments

The following snippet yields 63744:

var asn = require('asn1.js');
 
var Human = asn.define('Human', function() {
  this.seq().obj(
    this.key('firstName').int(),
  );
});

var output = Human.encode({
  firstName: 2500000000,
}, 'der');

var human = Human.decode(output, 'der');
console.log(human.firstName.toNumber());

It seems like an integer overflow. Shouldn't it allow more than 32 bits?

b-zee avatar Nov 16 '17 16:11 b-zee

Yes, currently cannot handle numbers >=2^31. Proposed fix here: https://github.com/indutny/asn1.js/pull/90

killerstorm avatar Dec 01 '17 00:12 killerstorm