[Pkg-javascript-commits] [node-browserify-aes] 19/43: aes: inline fixup_uint32, and simplify
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 375fcd858a97cabd651102ea62c4714374373eb3
Author: Daniel Cousens <github at dcousens.com>
Date: Fri May 19 12:46:06 2017 +1000
aes: inline fixup_uint32, and simplify
---
aes.js | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/aes.js b/aes.js
index 91d18cf..ecac223 100644
--- a/aes.js
+++ b/aes.js
@@ -4,18 +4,10 @@
// which is in turn based on the one from crypto-js
// https://code.google.com/p/crypto-js/
-var uint_max = Math.pow(2, 32)
-function fixup_uint32 (x) {
- var ret, x_pos
- ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
- return ret
-}
-
-function scrub_vec (v) {
+function scrubVec (v) {
for (var i = 0; i < v.length; v++) {
v[i] = 0
}
- return false
}
function Global () {
@@ -139,9 +131,9 @@ AES.prototype.decryptBlock = function (M) {
}
AES.prototype.scrub = function () {
- scrub_vec(this._keySchedule)
- scrub_vec(this._invKeySchedule)
- scrub_vec(this._key)
+ scrubVec(this._keySchedule)
+ scrubVec(this._invKeySchedule)
+ scrubVec(this._key)
}
AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) {
@@ -166,11 +158,12 @@ AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) {
t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
+
return [
- fixup_uint32(t0),
- fixup_uint32(t1),
- fixup_uint32(t2),
- fixup_uint32(t3)
+ t0 >>> 0,
+ t1 >>> 0,
+ t2 >>> 0,
+ t3 >>> 0
]
}
--
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