Skip to content

Commit d887ede

Browse files
authored
Merge pull request brix#69 from pkaminski/soft-encryptor-reset
On BlockCipher reset, don't recreate _mode, just re-init.
2 parents 7eff3bc + 39f543f commit d887ede

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cipher-core.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,15 @@ CryptoJS.lib.Cipher || (function (undefined) {
451451
var modeCreator = mode.createEncryptor;
452452
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
453453
var modeCreator = mode.createDecryptor;
454-
455454
// Keep at least one block in the buffer for unpadding
456455
this._minBufferSize = 1;
457456
}
458-
this._mode = modeCreator.call(mode, this, iv && iv.words);
457+
if (this._mode && this._modeCreator == modeCreator) {
458+
this._mode.init(this, iv && iv.words);
459+
} else {
460+
this._mode = modeCreator.call(mode, this, iv && iv.words);
461+
this._modeCreator = modeCreator;
462+
}
459463
},
460464

461465
_doProcessBlock: function (words, offset) {

0 commit comments

Comments
 (0)