[Pkg-javascript-commits] [node-sha.js] 04/31: Fix digesting of large data

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 30 11:23:25 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 aee24f1e0d7fefca68633e6c1be52670fb65a1a5
Author: Guido Lorenz <guido.lorenz at artcom.de>
Date:   Thu May 4 13:08:43 2017 +0200

    Fix digesting of large data
    
    Based on crypto-browserify/sha.js#39 by @samKamerer.
---
 hash.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hash.js b/hash.js
index 09579d2..72d8df2 100644
--- a/hash.js
+++ b/hash.js
@@ -54,8 +54,13 @@ Hash.prototype.digest = function (enc) {
   }
 
   // to this append the block which is equal to the number l written in binary
-  // TODO: handle case where l is > Math.pow(2, 29)
-  this._block.writeInt32BE(l, this._blockSize - 4)
+  if (l <= 0xffffffff) {
+    this._block.writeUInt32BE(l, this._blockSize - 4)
+  } else {
+    var ll = l & 0xffffffff
+    this._block.writeUInt32BE((l - ll) / 0x100000000, this._blockSize - 8)
+    this._block.writeUInt32BE(ll, this._blockSize - 4)
+  }
 
   var hash = this._update(this._block) || this._hash()
 

-- 
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