From 056d9c9d2f79843264672c5c84395746e965da02 Mon Sep 17 00:00:00 2001 From: Brett Dargan Date: Tue, 17 Jan 2017 06:34:52 +1000 Subject: [PATCH 1/7] Box.decrypt uses nonce parameter --- lib/box.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/box.js b/lib/box.js index aa2c8245..a9315061 100644 --- a/lib/box.js +++ b/lib/box.js @@ -144,17 +144,17 @@ module.exports = function Box(publicKey, secretKey, easy) { * @param {Buffer|String|Array} nonce the nonce used to encrypt * @param {String} [encoding] the encoding to used in cipherText, nonce, plainText */ - self.decrypt = function (cipherBox, encoding) { + self.decrypt = function (cipherBox, nonce, encoding) { encoding = String(encoding || self.defaultEncoding); assert(typeof cipherBox == 'object' && cipherBox.hasOwnProperty('cipherText') && cipherBox.hasOwnProperty('nonce'), 'cipherBox is an object with properties `cipherText` and `nonce`.'); assert(cipherBox.cipherText instanceof Buffer, 'cipherBox should have a cipherText property that is a buffer') ; - var nonce = new Nonce(cipherBox.nonce); + //var nonce = new Nonce(cipherBox.nonce); nonce.get() var plainText = (self.easy ? binding.crypto_box_open_easy : binding.crypto_box_open)( cipherBox.cipherText, - nonce.get(), + nonce, self.boxKey.getPublicKey().get(), self.boxKey.getSecretKey().get() ); @@ -170,4 +170,3 @@ module.exports = function Box(publicKey, secretKey, easy) { self.close = self.encrypt; self.open = self.decrypt; }; - From 08167ba65e82c8c4ed8c5bd0fb2209c5a1589e5b Mon Sep 17 00:00:00 2001 From: Brett Dargan Date: Tue, 17 Jan 2017 06:53:08 +1000 Subject: [PATCH 2/7] Box decrypt assertion change --- lib/box.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/box.js b/lib/box.js index a9315061..bbb1419d 100644 --- a/lib/box.js +++ b/lib/box.js @@ -15,8 +15,8 @@ var assert = require('assert'); /** * Public-key authenticated encryption: Box * - * @param {String|Buffer|Array} secretKey sender's private key. * @param {String|Buffer|Array} publicKey recipient's public key. + * @param {String|Buffer|Array} secretKey sender's private key. * @param {Boolean} easy Use regular or easy mode. Defaults to regular * * @see Keys @@ -147,13 +147,13 @@ module.exports = function Box(publicKey, secretKey, easy) { self.decrypt = function (cipherBox, nonce, encoding) { encoding = String(encoding || self.defaultEncoding); - assert(typeof cipherBox == 'object' && cipherBox.hasOwnProperty('cipherText') && cipherBox.hasOwnProperty('nonce'), 'cipherBox is an object with properties `cipherText` and `nonce`.'); - assert(cipherBox.cipherText instanceof Buffer, 'cipherBox should have a cipherText property that is a buffer') ; + assert(cipherText instanceof Buffer, 'cipherText property that is a buffer') ; + assert(nonce instanceof Buffer, 'nonce property that is a buffer') ; //var nonce = new Nonce(cipherBox.nonce); nonce.get() var plainText = (self.easy ? binding.crypto_box_open_easy : binding.crypto_box_open)( - cipherBox.cipherText, + cipherText, nonce, self.boxKey.getPublicKey().get(), self.boxKey.getSecretKey().get() From 4ae6f0f70e6bc129474e7ccff75e777488890185 Mon Sep 17 00:00:00 2001 From: Brett Dargan Date: Tue, 17 Jan 2017 06:57:18 +1000 Subject: [PATCH 3/7] param typo --- lib/box.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/box.js b/lib/box.js index bbb1419d..25e49801 100644 --- a/lib/box.js +++ b/lib/box.js @@ -144,7 +144,7 @@ module.exports = function Box(publicKey, secretKey, easy) { * @param {Buffer|String|Array} nonce the nonce used to encrypt * @param {String} [encoding] the encoding to used in cipherText, nonce, plainText */ - self.decrypt = function (cipherBox, nonce, encoding) { + self.decrypt = function (cipherText, nonce, encoding) { encoding = String(encoding || self.defaultEncoding); assert(cipherText instanceof Buffer, 'cipherText property that is a buffer') ; From 1b3de5f93e7b0e9ee250e2933ab014184a28df71 Mon Sep 17 00:00:00 2001 From: Damien Hill Date: Mon, 5 Nov 2018 16:27:55 +1000 Subject: [PATCH 4/7] Attempted fix for libsodium build issue Based on recommendation here: https://github.com/paixaop/node-sodium/issues/124#issuecomment-345090082 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed08ea5c..4ac939df 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "description": "Lib Sodium port for node.js", "dependencies": { - "nan": "^2.2.1" + "nan": ">=2.2.1 <2.8.0" }, "devDependencies": { "mdextract": "^1.0.0", From 02c63000af02a5ba36e5df4d42708b93484b684a Mon Sep 17 00:00:00 2001 From: Damien Hill Date: Tue, 6 Nov 2018 09:10:29 +1000 Subject: [PATCH 5/7] Fix version for dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ac939df..90ef1320 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "description": "Lib Sodium port for node.js", "dependencies": { - "nan": ">=2.2.1 <2.8.0" + "nan": "2.7.0" }, "devDependencies": { "mdextract": "^1.0.0", From dfce85b5b4762a93873013804c662db2477423a5 Mon Sep 17 00:00:00 2001 From: Damien Hill Date: Tue, 6 Nov 2018 09:16:51 +1000 Subject: [PATCH 6/7] =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90ef1320..da034406 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "main": "index.js", "description": "Lib Sodium port for node.js", "dependencies": { - "nan": "2.7.0" + "nan": "2.2.1" }, "devDependencies": { "mdextract": "^1.0.0", From fbab79ad4dca3e0401b09aea19d6b6c6b7394314 Mon Sep 17 00:00:00 2001 From: Damien Hill Date: Tue, 6 Nov 2018 09:45:29 +1000 Subject: [PATCH 7/7] Attempt to fix install issue on Ubuntu 14.04 --- install.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/install.js b/install.js index 58cdc066..7d64638f 100644 --- a/install.js +++ b/install.js @@ -10,6 +10,7 @@ var https = require('https'); var fs = require('fs'); var path = require('path'); var exec = require('child_process').exec; +var spawn = require('child_process').spawn; var os = require('os'); var libFiles = [ @@ -270,8 +271,8 @@ function doDownloads(next) { }); } -function run(cmdLine, expectedExitCode, next) { - var child = exec(cmdLine); +function run(cmdLine, args, expectedExitCode, next) { + var child = spawn(cmdLine, { shell: true }); if (typeof expectedExitCode === 'undefined') { expectedExitCode = 0; @@ -340,9 +341,9 @@ function isPreInstallMode() { // Start if (os.platform() !== 'win32') { if (isPreInstallMode()) { - run('make libsodium'); + run('make', ['libsodium']); } else { - run('make nodesodium'); + run('make', ['nodesodium']); } } else { checkMSVSVersion(); @@ -357,7 +358,7 @@ if (os.platform() !== 'win32') { }); } else { console.log('Install Mode'); - run('node-gyp rebuild', 0, function() { + run('node-gyp', ['rebuild'], 0, function() { console.log('Copy lib files to Release folder'); files = libFiles.slice(0); // clone array copyFiles(files, function() { @@ -366,4 +367,4 @@ if (os.platform() !== 'win32') { }); }); } -} \ No newline at end of file +}