Comparing version 3.0.0 to 3.1.0
@@ -635,5 +635,10 @@ "use strict"; | ||
// We cannot safely handle numbers beyond the safe range for integers | ||
if (value > Number.MAX_SAFE_INTEGER) { | ||
throw new Error('integer value out of safe range'); | ||
} | ||
for (var index = 15; index >= 0; --index) { | ||
this._counter[index] = value % 256; | ||
value = value >> 8; | ||
value = parseInt(value / 256); | ||
} | ||
@@ -640,0 +645,0 @@ } |
{ | ||
"name": "aes-js", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"bugs": { | ||
@@ -5,0 +5,0 @@ "url": "http://github.com/ricmoo/aes-js/issues", |
@@ -68,2 +68,4 @@ var nodeunit = require('nodeunit'); | ||
'test-counter-number-256': makeTest({number: 256, incrementResult: "00000000000000000000000000000101"}), | ||
'test-counter-number-large': makeTest({number: 1099511627774, incrementResult: "0000000000000000000000ffffffffff"}), | ||
'test-counter-number-max': makeTest({number: 9007199254740991, incrementResult: "00000000000000000020000000000000"}), | ||
'test-counter-bytes-0000': makeTest({bytes: "00000000000000000000000000000000", incrementResult: "00000000000000000000000000000001"}), | ||
@@ -70,0 +72,0 @@ 'test-counter-bytes-00ff': makeTest({bytes: "000000000000000000000000000000ff", incrementResult: "00000000000000000000000000000100"}), |
@@ -166,2 +166,9 @@ 'use strict'; | ||
test.throws(function() { | ||
var counter = new aes.Counter(Number.MAX_SAFE_INTEGER + 1); | ||
}, function(error) { | ||
return (error.message === 'integer value out of safe range'); | ||
}, | ||
'invalid counter value (out of range) failed to throw an error'); | ||
var badThings = [0, 1.5, 1]; | ||
@@ -168,0 +175,0 @@ for (var i = 0; i < badThings.length; i++) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2430982
9582