indutny / asn1.js

ASN.1 Decoder/Encoder/DSL
MIT License
181 stars 64 forks source link

Number overflow (32 bits limit?) #97

Open b-zee opened 6 years ago

b-zee commented 6 years ago

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?

killerstorm commented 6 years ago

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