Skip to content

Commit

Permalink
Only skip _doReset if _key has not been changed since last reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
evanvosberg committed Oct 27, 2016
1 parent f643619 commit 7ff3a3c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@
*/
var AES = C_algo.AES = BlockCipher.extend({
_doReset: function () {
if (this._nRounds) return;
// Skip reset of nRounds has been set before and key did not change
if (this._nRounds && this._keyPriorReset === this._key) {
return;
}

// Shortcuts
var key = this._key;
var key = this._keyPriorReset = this._key;
var keyWords = key.words;
var keySize = key.sigBytes / 4;

// Compute number of rounds
var nRounds = this._nRounds = keySize + 6
var nRounds = this._nRounds = keySize + 6;

// Compute number of key schedule rows
var ksRows = (nRounds + 1) * 4;
Expand Down

0 comments on commit 7ff3a3c

Please sign in to comment.