[Pkg-javascript-commits] [node-sha.js] 221/237: Improve performace
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:04:09 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 6b341b73499ce338485a2c813519336f24a39b05
Author: Kirill Fomichev <fanatid at ya.ru>
Date: Mon Feb 15 15:30:09 2016 +0300
Improve performace
* round numbers to int32
* unroll loops
---
sha.js | 71 +++++++++-----------
sha1.js | 70 ++++++++++----------
sha224.js | 16 ++---
sha256.js | 49 ++++++--------
sha384.js | 46 ++++++-------
sha512.js | 219 ++++++++++++++++++++++++++++++--------------------------------
6 files changed, 226 insertions(+), 245 deletions(-)
diff --git a/sha.js b/sha.js
index 2a1e87c..7cde1b0 100644
--- a/sha.js
+++ b/sha.js
@@ -9,6 +9,10 @@
var inherits = require('inherits')
var Hash = require('./hash')
+var K = [
+ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
+]
+
var W = new Array(80)
function Sha () {
@@ -21,62 +25,52 @@ function Sha () {
inherits(Sha, Hash)
Sha.prototype.init = function () {
- this._a = 0x67452301 | 0
- this._b = 0xefcdab89 | 0
- this._c = 0x98badcfe | 0
- this._d = 0x10325476 | 0
- this._e = 0xc3d2e1f0 | 0
+ this._a = 0x67452301
+ this._b = 0xefcdab89
+ this._c = 0x98badcfe
+ this._d = 0x10325476
+ this._e = 0xc3d2e1f0
return this
}
-/*
- * Bitwise rotate a 32-bit number to the left.
- */
-function rol (num, cnt) {
- return (num << cnt) | (num >>> (32 - cnt))
+function rotl5 (num) {
+ return (num << 5) | (num >>> 27)
+}
+
+function rotl30 (num) {
+ return (num << 30) | (num >>> 2)
+}
+
+function ft (s, b, c, d) {
+ if (s === 0) return (b & c) | ((~b) & d)
+ if (s === 2) return (b & c) | (b & d) | (c & d)
+ return b ^ c ^ d
}
Sha.prototype._update = function (M) {
var W = this._w
- var a = this._a
- var b = this._b
- var c = this._c
- var d = this._d
- var e = this._e
-
- var j = 0
- var k
+ var a = this._a | 0
+ var b = this._b | 0
+ var c = this._c | 0
+ var d = this._d | 0
+ var e = this._e | 0
- /*
- * SHA-1 has a bitwise rotate left operation. But, SHA is not
- * function calcW() { return rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1) }
- */
- function calcW () { return W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16] }
- function loop (w, f) {
- W[j] = w
+ for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
+ for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]
- var t = rol(a, 5) + f + e + w + k
+ for (var j = 0; j < 80; ++j) {
+ var s = ~~(j / 20)
+ var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
e = d
d = c
- c = rol(b, 30)
+ c = rotl30(b)
b = a
a = t
- j++
}
- k = 1518500249
- while (j < 16) loop(M.readInt32BE(j * 4), (b & c) | ((~b) & d))
- while (j < 20) loop(calcW(), (b & c) | ((~b) & d))
- k = 1859775393
- while (j < 40) loop(calcW(), b ^ c ^ d)
- k = -1894007588
- while (j < 60) loop(calcW(), (b & c) | (b & d) | (c & d))
- k = -899497514
- while (j < 80) loop(calcW(), b ^ c ^ d)
-
this._a = (a + this._a) | 0
this._b = (b + this._b) | 0
this._c = (c + this._c) | 0
@@ -97,4 +91,3 @@ Sha.prototype._hash = function () {
}
module.exports = Sha
-
diff --git a/sha1.js b/sha1.js
index 6164be7..97f6b14 100644
--- a/sha1.js
+++ b/sha1.js
@@ -10,6 +10,10 @@
var inherits = require('inherits')
var Hash = require('./hash')
+var K = [
+ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0
+]
+
var W = new Array(80)
function Sha1 () {
@@ -22,58 +26,56 @@ function Sha1 () {
inherits(Sha1, Hash)
Sha1.prototype.init = function () {
- this._a = 0x67452301 | 0
- this._b = 0xefcdab89 | 0
- this._c = 0x98badcfe | 0
- this._d = 0x10325476 | 0
- this._e = 0xc3d2e1f0 | 0
+ this._a = 0x67452301
+ this._b = 0xefcdab89
+ this._c = 0x98badcfe
+ this._d = 0x10325476
+ this._e = 0xc3d2e1f0
return this
}
-/*
- * Bitwise rotate a 32-bit number to the left.
- */
-function rol (num, cnt) {
- return (num << cnt) | (num >>> (32 - cnt))
+function rotl1 (num) {
+ return (num << 1) | (num >>> 31)
+}
+
+function rotl5 (num) {
+ return (num << 5) | (num >>> 27)
+}
+
+function rotl30 (num) {
+ return (num << 30) | (num >>> 2)
+}
+
+function ft (s, b, c, d) {
+ if (s === 0) return (b & c) | ((~b) & d)
+ if (s === 2) return (b & c) | (b & d) | (c & d)
+ return b ^ c ^ d
}
Sha1.prototype._update = function (M) {
var W = this._w
- var a = this._a
- var b = this._b
- var c = this._c
- var d = this._d
- var e = this._e
+ var a = this._a | 0
+ var b = this._b | 0
+ var c = this._c | 0
+ var d = this._d | 0
+ var e = this._e | 0
- var j = 0
- var k
+ for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
+ for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16])
- function calcW () { return rol(W[j - 3] ^ W[j - 8] ^ W[j - 14] ^ W[j - 16], 1) }
- function loop (w, f) {
- W[j] = w
-
- var t = rol(a, 5) + f + e + w + k
+ for (var j = 0; j < 80; ++j) {
+ var s = ~~(j / 20)
+ var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0
e = d
d = c
- c = rol(b, 30)
+ c = rotl30(b)
b = a
a = t
- j++
}
- k = 1518500249
- while (j < 16) loop(M.readInt32BE(j * 4), (b & c) | ((~b) & d))
- while (j < 20) loop(calcW(), (b & c) | ((~b) & d))
- k = 1859775393
- while (j < 40) loop(calcW(), b ^ c ^ d)
- k = -1894007588
- while (j < 60) loop(calcW(), (b & c) | (b & d) | (c & d))
- k = -899497514
- while (j < 80) loop(calcW(), b ^ c ^ d)
-
this._a = (a + this._a) | 0
this._b = (b + this._b) | 0
this._c = (c + this._c) | 0
diff --git a/sha224.js b/sha224.js
index f4e776f..31899ef 100644
--- a/sha224.js
+++ b/sha224.js
@@ -23,14 +23,14 @@ function Sha224 () {
inherits(Sha224, Sha256)
Sha224.prototype.init = function () {
- this._a = 0xc1059ed8 | 0
- this._b = 0x367cd507 | 0
- this._c = 0x3070dd17 | 0
- this._d = 0xf70e5939 | 0
- this._e = 0xffc00b31 | 0
- this._f = 0x68581511 | 0
- this._g = 0x64f98fa7 | 0
- this._h = 0xbefa4fa4 | 0
+ this._a = 0xc1059ed8
+ this._b = 0x367cd507
+ this._c = 0x3070dd17
+ this._d = 0xf70e5939
+ this._e = 0xffc00b31
+ this._f = 0x68581511
+ this._g = 0x64f98fa7
+ this._h = 0xbefa4fa4
return this
}
diff --git a/sha256.js b/sha256.js
index 8357d3b..69b60fe 100644
--- a/sha256.js
+++ b/sha256.js
@@ -41,39 +41,39 @@ function Sha256 () {
inherits(Sha256, Hash)
Sha256.prototype.init = function () {
- this._a = 0x6a09e667 | 0
- this._b = 0xbb67ae85 | 0
- this._c = 0x3c6ef372 | 0
- this._d = 0xa54ff53a | 0
- this._e = 0x510e527f | 0
- this._f = 0x9b05688c | 0
- this._g = 0x1f83d9ab | 0
- this._h = 0x5be0cd19 | 0
+ this._a = 0x6a09e667
+ this._b = 0xbb67ae85
+ this._c = 0x3c6ef372
+ this._d = 0xa54ff53a
+ this._e = 0x510e527f
+ this._f = 0x9b05688c
+ this._g = 0x1f83d9ab
+ this._h = 0x5be0cd19
return this
}
-function Ch (x, y, z) {
+function ch (x, y, z) {
return z ^ (x & (y ^ z))
}
-function Maj (x, y, z) {
+function maj (x, y, z) {
return (x & y) | (z & (x | y))
}
-function Sigma0 (x) {
+function sigma0 (x) {
return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10)
}
-function Sigma1 (x) {
+function sigma1 (x) {
return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7)
}
-function Gamma0 (x) {
+function gamma0 (x) {
return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3)
}
-function Gamma1 (x) {
+function gamma1 (x) {
return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10)
}
@@ -89,30 +89,23 @@ Sha256.prototype._update = function (M) {
var g = this._g | 0
var h = this._h | 0
- var j = 0
+ for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4)
+ for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0
- function calcW () { return Gamma1(W[j - 2]) + W[j - 7] + Gamma0(W[j - 15]) + W[j - 16] }
- function loop (w) {
- W[j] = w
-
- var T1 = h + Sigma1(e) + Ch(e, f, g) + K[j] + w
- var T2 = Sigma0(a) + Maj(a, b, c)
+ for (var j = 0; j < 64; ++j) {
+ var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0
+ var T2 = (sigma0(a) + maj(a, b, c)) | 0
h = g
g = f
f = e
- e = d + T1
+ e = (d + T1) | 0
d = c
c = b
b = a
- a = T1 + T2
-
- j++
+ a = (T1 + T2) | 0
}
- while (j < 16) loop(M.readInt32BE(j * 4))
- while (j < 64) loop(calcW())
-
this._a = (a + this._a) | 0
this._b = (b + this._b) | 0
this._c = (c + this._c) | 0
diff --git a/sha384.js b/sha384.js
index 2044e91..dc48312 100644
--- a/sha384.js
+++ b/sha384.js
@@ -14,23 +14,23 @@ function Sha384 () {
inherits(Sha384, SHA512)
Sha384.prototype.init = function () {
- this._a = 0xcbbb9d5d | 0
- this._b = 0x629a292a | 0
- this._c = 0x9159015a | 0
- this._d = 0x152fecd8 | 0
- this._e = 0x67332667 | 0
- this._f = 0x8eb44a87 | 0
- this._g = 0xdb0c2e0d | 0
- this._h = 0x47b5481d | 0
-
- this._al = 0xc1059ed8 | 0
- this._bl = 0x367cd507 | 0
- this._cl = 0x3070dd17 | 0
- this._dl = 0xf70e5939 | 0
- this._el = 0xffc00b31 | 0
- this._fl = 0x68581511 | 0
- this._gl = 0x64f98fa7 | 0
- this._hl = 0xbefa4fa4 | 0
+ this._ah = 0xcbbb9d5d
+ this._bh = 0x629a292a
+ this._ch = 0x9159015a
+ this._dh = 0x152fecd8
+ this._eh = 0x67332667
+ this._fh = 0x8eb44a87
+ this._gh = 0xdb0c2e0d
+ this._hh = 0x47b5481d
+
+ this._al = 0xc1059ed8
+ this._bl = 0x367cd507
+ this._cl = 0x3070dd17
+ this._dl = 0xf70e5939
+ this._el = 0xffc00b31
+ this._fl = 0x68581511
+ this._gl = 0x64f98fa7
+ this._hl = 0xbefa4fa4
return this
}
@@ -43,12 +43,12 @@ Sha384.prototype._hash = function () {
H.writeInt32BE(l, offset + 4)
}
- writeInt64BE(this._a, this._al, 0)
- writeInt64BE(this._b, this._bl, 8)
- writeInt64BE(this._c, this._cl, 16)
- writeInt64BE(this._d, this._dl, 24)
- writeInt64BE(this._e, this._el, 32)
- writeInt64BE(this._f, this._fl, 40)
+ writeInt64BE(this._ah, this._al, 0)
+ writeInt64BE(this._bh, this._bl, 8)
+ writeInt64BE(this._ch, this._cl, 16)
+ writeInt64BE(this._dh, this._dl, 24)
+ writeInt64BE(this._eh, this._el, 32)
+ writeInt64BE(this._fh, this._fl, 40)
return H
}
diff --git a/sha512.js b/sha512.js
index 6ec9f5f..204a7b8 100644
--- a/sha512.js
+++ b/sha512.js
@@ -56,23 +56,23 @@ function Sha512 () {
inherits(Sha512, Hash)
Sha512.prototype.init = function () {
- this._a = 0x6a09e667 | 0
- this._b = 0xbb67ae85 | 0
- this._c = 0x3c6ef372 | 0
- this._d = 0xa54ff53a | 0
- this._e = 0x510e527f | 0
- this._f = 0x9b05688c | 0
- this._g = 0x1f83d9ab | 0
- this._h = 0x5be0cd19 | 0
-
- this._al = 0xf3bcc908 | 0
- this._bl = 0x84caa73b | 0
- this._cl = 0xfe94f82b | 0
- this._dl = 0x5f1d36f1 | 0
- this._el = 0xade682d1 | 0
- this._fl = 0x2b3e6c1f | 0
- this._gl = 0xfb41bd6b | 0
- this._hl = 0x137e2179 | 0
+ this._ah = 0x6a09e667
+ this._bh = 0xbb67ae85
+ this._ch = 0x3c6ef372
+ this._dh = 0xa54ff53a
+ this._eh = 0x510e527f
+ this._fh = 0x9b05688c
+ this._gh = 0x1f83d9ab
+ this._hh = 0x5be0cd19
+
+ this._al = 0xf3bcc908
+ this._bl = 0x84caa73b
+ this._cl = 0xfe94f82b
+ this._dl = 0x5f1d36f1
+ this._el = 0xade682d1
+ this._fl = 0x2b3e6c1f
+ this._gl = 0xfb41bd6b
+ this._hl = 0x137e2179
return this
}
@@ -81,15 +81,15 @@ function Ch (x, y, z) {
return z ^ (x & (y ^ z))
}
-function Maj (x, y, z) {
+function maj (x, y, z) {
return (x & y) | (z & (x | y))
}
-function Sigma0 (x, xl) {
+function sigma0 (x, xl) {
return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25)
}
-function Sigma1 (x, xl) {
+function sigma1 (x, xl) {
return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23)
}
@@ -109,17 +109,21 @@ function Gamma1l (x, xl) {
return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26)
}
+function getCarry (a, b) {
+ return (a >>> 0) < (b >>> 0) ? 1 : 0
+}
+
Sha512.prototype._update = function (M) {
var W = this._w
- var a = this._a | 0
- var b = this._b | 0
- var c = this._c | 0
- var d = this._d | 0
- var e = this._e | 0
- var f = this._f | 0
- var g = this._g | 0
- var h = this._h | 0
+ var ah = this._ah | 0
+ var bh = this._bh | 0
+ var ch = this._ch | 0
+ var dh = this._dh | 0
+ var eh = this._eh | 0
+ var fh = this._fh | 0
+ var gh = this._gh | 0
+ var hh = this._hh | 0
var al = this._al | 0
var bl = this._bl | 0
@@ -130,98 +134,87 @@ Sha512.prototype._update = function (M) {
var gl = this._gl | 0
var hl = this._hl | 0
- var i = 0
- var j = 0
- var Wi, Wil
- function calcW () {
- var x = W[j - 15 * 2]
- var xl = W[j - 15 * 2 + 1]
- var gamma0 = Gamma0(x, xl)
- var gamma0l = Gamma0l(xl, x)
+ for (var i = 0; i < 32; i += 2) {
+ W[i] = M.readInt32BE(i * 4)
+ W[i + 1] = M.readInt32BE(i * 4 + 4)
+ }
+ for (; i < 160; i += 2) {
+ var xh = W[i - 15 * 2]
+ var xl = W[i - 15 * 2 + 1]
+ var gamma0 = Gamma0(xh, xl)
+ var gamma0l = Gamma0l(xl, xh)
- x = W[j - 2 * 2]
- xl = W[j - 2 * 2 + 1]
- var gamma1 = Gamma1(x, xl)
- var gamma1l = Gamma1l(xl, x)
+ xh = W[i - 2 * 2]
+ xl = W[i - 2 * 2 + 1]
+ var gamma1 = Gamma1(xh, xl)
+ var gamma1l = Gamma1l(xl, xh)
// W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
- var Wi7 = W[j - 7 * 2]
- var Wi7l = W[j - 7 * 2 + 1]
-
- var Wi16 = W[j - 16 * 2]
- var Wi16l = W[j - 16 * 2 + 1]
-
- Wil = gamma0l + Wi7l
- Wi = gamma0 + Wi7 + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0)
- Wil = Wil + gamma1l
- Wi = Wi + gamma1 + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0)
- Wil = Wil + Wi16l
- Wi = Wi + Wi16 + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0)
+ var Wi7h = W[i - 7 * 2]
+ var Wi7l = W[i - 7 * 2 + 1]
+
+ var Wi16h = W[i - 16 * 2]
+ var Wi16l = W[i - 16 * 2 + 1]
+
+ var Wil = (gamma0l + Wi7l) | 0
+ var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0
+ Wil = (Wil + gamma1l) | 0
+ Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0
+ Wil = (Wil + Wi16l) | 0
+ Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0
+
+ W[i] = Wih
+ W[i + 1] = Wil
}
- function loop () {
- W[j] = Wi
- W[j + 1] = Wil
+ for (var j = 0; j < 160; j += 2) {
+ Wih = W[j]
+ Wil = W[j + 1]
- var maj = Maj(a, b, c)
- var majl = Maj(al, bl, cl)
+ var majh = maj(ah, bh, ch)
+ var majl = maj(al, bl, cl)
- var sigma0h = Sigma0(a, al)
- var sigma0l = Sigma0(al, a)
- var sigma1h = Sigma1(e, el)
- var sigma1l = Sigma1(el, e)
+ var sigma0h = sigma0(ah, al)
+ var sigma0l = sigma0(al, ah)
+ var sigma1h = sigma1(eh, el)
+ var sigma1l = sigma1(el, eh)
- // t1 = h + sigma1 + ch + K[i] + W[i]
- var Ki = K[j]
+ // t1 = h + sigma1 + ch + K[j] + W[j]
+ var Kih = K[j]
var Kil = K[j + 1]
- var ch = Ch(e, f, g)
+ var chh = Ch(eh, fh, gh)
var chl = Ch(el, fl, gl)
- var t1l = hl + sigma1l
- var t1 = h + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0)
- t1l = t1l + chl
- t1 = t1 + ch + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0)
- t1l = t1l + Kil
- t1 = t1 + Ki + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0)
- t1l = t1l + Wil
- t1 = t1 + Wi + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0)
+ var t1l = (hl + sigma1l) | 0
+ var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0
+ t1l = (t1l + chl) | 0
+ t1h = (t1h + chh + getCarry(t1l, chl)) | 0
+ t1l = (t1l + Kil) | 0
+ t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0
+ t1l = (t1l + Wil) | 0
+ t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0
// t2 = sigma0 + maj
- var t2l = sigma0l + majl
- var t2 = sigma0h + maj + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0)
+ var t2l = (sigma0l + majl) | 0
+ var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0
- h = g
+ hh = gh
hl = gl
- g = f
+ gh = fh
gl = fl
- f = e
+ fh = eh
fl = el
el = (dl + t1l) | 0
- e = (d + t1 + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0
- d = c
+ eh = (dh + t1h + getCarry(el, dl)) | 0
+ dh = ch
dl = cl
- c = b
+ ch = bh
cl = bl
- b = a
+ bh = ah
bl = al
al = (t1l + t2l) | 0
- a = (t1 + t2 + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0
-
- i++
- j += 2
- }
-
- while (i < 16) {
- Wi = M.readInt32BE(j * 4)
- Wil = M.readInt32BE(j * 4 + 4)
-
- loop()
- }
-
- while (i < 80) {
- calcW()
- loop()
+ ah = (t1h + t2h + getCarry(al, t1l)) | 0
}
this._al = (this._al + al) | 0
@@ -233,14 +226,14 @@ Sha512.prototype._update = function (M) {
this._gl = (this._gl + gl) | 0
this._hl = (this._hl + hl) | 0
- this._a = (this._a + a + ((this._al >>> 0) < (al >>> 0) ? 1 : 0)) | 0
- this._b = (this._b + b + ((this._bl >>> 0) < (bl >>> 0) ? 1 : 0)) | 0
- this._c = (this._c + c + ((this._cl >>> 0) < (cl >>> 0) ? 1 : 0)) | 0
- this._d = (this._d + d + ((this._dl >>> 0) < (dl >>> 0) ? 1 : 0)) | 0
- this._e = (this._e + e + ((this._el >>> 0) < (el >>> 0) ? 1 : 0)) | 0
- this._f = (this._f + f + ((this._fl >>> 0) < (fl >>> 0) ? 1 : 0)) | 0
- this._g = (this._g + g + ((this._gl >>> 0) < (gl >>> 0) ? 1 : 0)) | 0
- this._h = (this._h + h + ((this._hl >>> 0) < (hl >>> 0) ? 1 : 0)) | 0
+ this._ah = (this._ah + ah + getCarry(this._al, al)) | 0
+ this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0
+ this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0
+ this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0
+ this._eh = (this._eh + eh + getCarry(this._el, el)) | 0
+ this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0
+ this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0
+ this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0
}
Sha512.prototype._hash = function () {
@@ -251,14 +244,14 @@ Sha512.prototype._hash = function () {
H.writeInt32BE(l, offset + 4)
}
- writeInt64BE(this._a, this._al, 0)
- writeInt64BE(this._b, this._bl, 8)
- writeInt64BE(this._c, this._cl, 16)
- writeInt64BE(this._d, this._dl, 24)
- writeInt64BE(this._e, this._el, 32)
- writeInt64BE(this._f, this._fl, 40)
- writeInt64BE(this._g, this._gl, 48)
- writeInt64BE(this._h, this._hl, 56)
+ writeInt64BE(this._ah, this._al, 0)
+ writeInt64BE(this._bh, this._bl, 8)
+ writeInt64BE(this._ch, this._cl, 16)
+ writeInt64BE(this._dh, this._dl, 24)
+ writeInt64BE(this._eh, this._el, 32)
+ writeInt64BE(this._fh, this._fl, 40)
+ writeInt64BE(this._gh, this._gl, 48)
+ writeInt64BE(this._hh, this._hl, 56)
return H
}
--
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