diff --git a/README.md b/README.md index ed2a388..ffdd6b6 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ All password hashing algorithms for Django implemented in javascript for nodejs 6. MD5PasswordHasher 7. UnsaltedSHA1PasswordHasher 8. UnsaltedMD5PasswordHasher -9. Argon2PasswordHasher # Usage diff --git a/index.js b/index.js index 76620cf..8afc3e9 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,6 @@ const bcrypt = require('bcryptjs'); const crypto = require('crypto'); -const argon2 = require('argon2-ffi').argon2i; const util = require('util'); const randomBytes = util.promisify(crypto.randomBytes); @@ -50,10 +49,6 @@ module.exports.getHasher = function(algorithm) { return new this.PBKDF2PasswordHasher(); } - case "argon2": { - return new this.Argon2PasswordHasher(); - } - case "pbkdf2_sha1": { return new this.PBKDF2SHA1PasswordHasher(); } @@ -88,57 +83,6 @@ module.exports.getHasher = function(algorithm) { } }; - -module.exports.Argon2PasswordHasher = function() { - this.algorithm = "argon2"; - this.version = 19; - this.time_cost = 2; - this.memory_cost = 512; - this.parallelism_value = 2; - this.hash_length = 16; - - this.salt = async function() { - return await randomBytes(32) - } - - this.encode = async function(password) { - const options = { - timeCost: this.time_cost, - memoryCost: this.memory_cost, - parallelism: this.parallelism_value, - hashLength: this.hash_length - }; - - const salt = await this.salt(); - const hash = await argon2.hash(password, salt, options); - return this.algorithm + hash; - } - - this.verify = async function(password, hash_password) { - hash_password = hash_password.substring(this.algorithm.length, hash_password.length); - return await argon2.verify(hash_password, password); - } - - this.mustUpdate = function(hash_password) { - const parts = hash_password.split('$'); - if (parts[0] !== this.algorithm) { - return true; - } - - if (parts[2] !== this.version) { - return true; - } - - const options = "m=" + this.memory_cost + ",t=" + this.time_cost + ",p=" + this.parallelism_value; - if (options !== parts[3]) { - return true; - } - - return false; - } -}; - - module.exports.PBKDF2PasswordHasher = function() { this.algorithm = "pbkdf2_sha256"; this.iterations = 120000; diff --git a/package.json b/package.json index 1ab8bfd..9b6ca70 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "node-django-hashers", "version": "1.1.6", "dependencies": { - "argon2-ffi": "^1.1.0", "assert": "^1.4.1", "bcryptjs": "^2.3.0", "node-gyp": "^3.7.0" diff --git a/test/index.test.js b/test/index.test.js index 5cb80bb..4cd73d2 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -34,12 +34,6 @@ describe('getHashers test with all hashing algorithms', () => { assert.strictEqual(h, 'pbkdf2_sha256', 'Testing pbkdf2_sha256 from Django'); }); - it ('testing argon2', () => { - const hash_password = "argon2$argon2i$v=19$m=512,t=2,p=2$UXZPOFhoSUxrWmhQ$CCPcRG8t+LOJB8H1zL+Prw"; - const h = hashers.identifyHasher(hash_password); - assert.strictEqual(h, 'argon2', 'Testing argon2 from Django'); - }); - it ('testing pbkdf2_sha1', () => { const hash_password = "pbkdf2_sha1$36000$P6Y4I7YXzZpB$LrWCTPqWtIdPFYY5jt+w56QJGR0="; const h = hashers.identifyHasher(hash_password); @@ -94,14 +88,7 @@ describe('Test all password hashing algorithms encode and verify methods', () => const verify = await h.verify('password', hashPassword); assert.strictEqual(verify, true, 'Testing pbkdf2_sha256 encode and verify from Django'); }); - - it ('testing argon2 encode', async () => { - const h = new hashers.Argon2PasswordHasher(); - const hashPassword = await h.encode('password'); - const verify = await h.verify('password', hashPassword); - assert.strictEqual(verify, true, 'Testing argon2 encode and verify from Django'); - }); - + it ('testing pbkdf2_sha1 encode', async () => { const h = new hashers.PBKDF2SHA1PasswordHasher(); const hashPassword = await h.encode('password');