asn1.js
asn1.js copied to clipboard
Number overflow (32 bits limit?)
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?
Yes, currently cannot handle numbers >=2^31. Proposed fix here: https://github.com/indutny/asn1.js/pull/90