[Pkg-javascript-commits] [node-browserify-aes] 22/43: aes: isolate keySchedule copy for performance

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 14:41:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browserify-aes.

commit ac3b5230e33da907df61d8ccde56213b8c850564
Author: Daniel Cousens <github at dcousens.com>
Date:   Fri May 19 12:55:51 2017 +1000

    aes: isolate keySchedule copy for performance
---
 aes.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/aes.js b/aes.js
index 6d4b214..997ef4c 100644
--- a/aes.js
+++ b/aes.js
@@ -92,14 +92,19 @@ function AES (key) {
 }
 
 AES.prototype._doReset = function () {
-  var keySize, keyWords, ksRow, ksRows, t
+  var keySize, keyWords, ksRows, t
   keyWords = this._key
   keySize = keyWords.length
   this._nRounds = keySize + 6
   ksRows = (this._nRounds + 1) * 4
   this._keySchedule = []
-  for (ksRow = 0; ksRow < ksRows; ksRow++) {
-    this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._ [...]
+
+  for (var k = 0; k < keySize; k++) {
+    this._keySchedule[k] = keyWords[k]
+  }
+
+  for (k = keySize; k < ksRows; k++) {
+    this._keySchedule[k] = (t = this._keySchedule[k - 1], (k % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(k / keySize) | 0] << 24) : keySize > 6 && k % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[k - keySize] ^ t)
   }
 
   var invKeySchedule = []

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git



More information about the Pkg-javascript-commits mailing list