node-forge 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/forge.all.min.js +1 -1
- package/dist/forge.min.js +1 -1
- package/lib/cipherModes.js +18 -6
- package/package.json +1 -1
package/lib/cipherModes.js
CHANGED
|
@@ -119,7 +119,7 @@ modes.cbc.prototype.start = function(options) {
|
|
|
119
119
|
throw new Error('Invalid IV parameter.');
|
|
120
120
|
} else {
|
|
121
121
|
// save IV as "previous" block
|
|
122
|
-
this._iv = transformIV(options.iv);
|
|
122
|
+
this._iv = transformIV(options.iv, this.blockSize);
|
|
123
123
|
this._prev = this._iv.slice(0);
|
|
124
124
|
}
|
|
125
125
|
};
|
|
@@ -215,7 +215,7 @@ modes.cfb.prototype.start = function(options) {
|
|
|
215
215
|
throw new Error('Invalid IV parameter.');
|
|
216
216
|
}
|
|
217
217
|
// use IV as first input
|
|
218
|
-
this._iv = transformIV(options.iv);
|
|
218
|
+
this._iv = transformIV(options.iv, this.blockSize);
|
|
219
219
|
this._inBlock = this._iv.slice(0);
|
|
220
220
|
this._partialBytes = 0;
|
|
221
221
|
};
|
|
@@ -359,7 +359,7 @@ modes.ofb.prototype.start = function(options) {
|
|
|
359
359
|
throw new Error('Invalid IV parameter.');
|
|
360
360
|
}
|
|
361
361
|
// use IV as first input
|
|
362
|
-
this._iv = transformIV(options.iv);
|
|
362
|
+
this._iv = transformIV(options.iv, this.blockSize);
|
|
363
363
|
this._inBlock = this._iv.slice(0);
|
|
364
364
|
this._partialBytes = 0;
|
|
365
365
|
};
|
|
@@ -444,7 +444,7 @@ modes.ctr.prototype.start = function(options) {
|
|
|
444
444
|
throw new Error('Invalid IV parameter.');
|
|
445
445
|
}
|
|
446
446
|
// use IV as first input
|
|
447
|
-
this._iv = transformIV(options.iv);
|
|
447
|
+
this._iv = transformIV(options.iv, this.blockSize);
|
|
448
448
|
this._inBlock = this._iv.slice(0);
|
|
449
449
|
this._partialBytes = 0;
|
|
450
450
|
};
|
|
@@ -954,7 +954,7 @@ modes.gcm.prototype.generateSubHashTable = function(mid, bits) {
|
|
|
954
954
|
|
|
955
955
|
/** Utility functions */
|
|
956
956
|
|
|
957
|
-
function transformIV(iv) {
|
|
957
|
+
function transformIV(iv, blockSize) {
|
|
958
958
|
if(typeof iv === 'string') {
|
|
959
959
|
// convert iv string into byte buffer
|
|
960
960
|
iv = forge.util.createBuffer(iv);
|
|
@@ -968,9 +968,21 @@ function transformIV(iv) {
|
|
|
968
968
|
iv.putByte(tmp[i]);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
+
|
|
972
|
+
if(iv.length() < blockSize) {
|
|
973
|
+
throw new Error(
|
|
974
|
+
'Invalid IV length; got ' + iv.length() +
|
|
975
|
+
' bytes and expected ' + blockSize + ' bytes.');
|
|
976
|
+
}
|
|
977
|
+
|
|
971
978
|
if(!forge.util.isArray(iv)) {
|
|
972
979
|
// convert iv byte buffer into 32-bit integer array
|
|
973
|
-
|
|
980
|
+
var ints = [];
|
|
981
|
+
var blocks = blockSize / 4;
|
|
982
|
+
for(var i = 0; i < blocks; ++i) {
|
|
983
|
+
ints.push(iv.getInt32());
|
|
984
|
+
}
|
|
985
|
+
iv = ints;
|
|
974
986
|
}
|
|
975
987
|
|
|
976
988
|
return iv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-forge",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.",
|
|
5
5
|
"homepage": "https://github.com/digitalbazaar/forge",
|
|
6
6
|
"author": {
|