[Pkg-javascript-commits] [node-sha.js] 177/237: sha1: unroll conditionals
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:03:52 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-sha.js.
commit f8301422051bd82cdb490881904b4bd418d5049d
Author: Daniel Cousens <github at dcousens.com>
Date: Mon Jan 12 20:05:49 2015 +1100
sha1: unroll conditionals
---
sha1.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 63 insertions(+), 19 deletions(-)
diff --git a/sha1.js b/sha1.js
index 009f1cf..753686e 100644
--- a/sha1.js
+++ b/sha1.js
@@ -47,36 +47,80 @@ Sha1.prototype._update = function (M) {
var d = this._d
var e = this._e
- for (var j = 0; j < 80; j++) {
- var w = W[j] = j < 16
- ? M.readInt32BE(j * 4)
- : rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1)
+ var w, f, k, t, j = 0
+ while (j < 16) {
+ w = W[j] = M.readInt32BE(j * 4)
+ f = (b & c) | ((~b) & d)
+ k = 1518500249
+ t = (rol(a, 5) + f + e + w + k) | 0
- var f, k
- if (j < 20) {
- f = (b & c) | ((~b) & d)
- k = 1518500249
+ e = d
+ d = c
+ c = rol(b, 30)
+ b = a
+ a = t
+
+ j++
+ }
+
+ while (j < 20) {
+ w = W[j] = rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1)
+ f = (b & c) | ((~b) & d)
+ k = 1518500249
+ t = (rol(a, 5) + f + e + w + k) | 0
+
+ e = d
+ d = c
+ c = rol(b, 30)
+ b = a
+ a = t
+
+ j++
+ }
- } else if (j < 40) {
- f = b ^ c ^ d
- k = 1859775393
+ while (j < 40) {
+ w = W[j] = rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1)
+ f = b ^ c ^ d
+ k = 1859775393
+ t = (rol(a, 5) + f + e + w + k) | 0
- } else if (j < 60) {
- f = (b & c) | (b & d) | (c & d)
- k = -1894007588
+ e = d
+ d = c
+ c = rol(b, 30)
+ b = a
+ a = t
+
+ j++
+ }
+
+ while (j < 60) {
+ w = W[j] = rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1)
+ f = (b & c) | (b & d) | (c & d)
+ k = -1894007588
+ t = (rol(a, 5) + f + e + w + k) | 0
- } else {
- f = b ^ c ^ d
- k = -899497514
- }
+ e = d
+ d = c
+ c = rol(b, 30)
+ b = a
+ a = t
+
+ j++
+ }
- var t = (rol(a, 5) + f + e + w + k) | 0
+ while (j < 80) {
+ w = W[j] = rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1)
+ f = b ^ c ^ d
+ k = -899497514
+ t = (rol(a, 5) + f + e + w + k) | 0
e = d
d = c
c = rol(b, 30)
b = a
a = t
+
+ j++
}
this._a = (a + this._a) | 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git
More information about the Pkg-javascript-commits
mailing list