From 24c339e806762622e4e41f2b454f4a1b03e5f72c Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Tue, 22 Nov 2016 15:12:51 +0100 Subject: [PATCH] keep API as v1 for now --- dist/lesspass.js | 14 ++++++------ index.js | 6 ++--- src/v2.js | 8 +++---- tests/v1/api.tests.js | 48 +++++++++++++++++++-------------------- tests/v2/api.tests.js | 16 ++++++------- tests/v2/entropy.tests.js | 12 +++++----- tests/v2/renderPassword.tests.js | 12 +++++----- tests/v2/setOfCharacters.tests.js | 10 ++++---- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/dist/lesspass.js b/dist/lesspass.js index 2608ba9..0a63ff5 100644 --- a/dist/lesspass.js +++ b/dist/lesspass.js @@ -31,7 +31,7 @@ module.exports = { var defaultPasswordProfile = { version: 2, lowercase: true, - digits: true, + numbers: true, uppercase: true, symbols: true, keylen: 32, @@ -45,11 +45,11 @@ function generatePassword(site, login, masterPassword, passwordProfile) { var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); if (_passwordProfile.version === 1) { var options = { - counter: _passwordProfile.index, + counter: _passwordProfile.counter, length: _passwordProfile.length, lowercase: _passwordProfile.lowercase, uppercase: _passwordProfile.uppercase, - numbers: _passwordProfile.digits, + numbers: _passwordProfile.numbers, symbols: _passwordProfile.symbols }; return v1.encryptLogin(login, masterPassword) @@ -8496,20 +8496,20 @@ function generatePassword(site, login, masterPassword, passwordProfile) { } function calcEntropy(site, login, masterPassword, passwordProfile) { - var salt = site + login + passwordProfile.index.toString(16); + var salt = site + login + passwordProfile.counter.toString(16); return pbkdf2(masterPassword, salt, passwordProfile.iterations, passwordProfile.keylen, passwordProfile.digest); } var characterSubsets = { lowercase: 'abcdefghijklmnopqrstuvwxyz', uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - digits: '0123456789', + numbers: '0123456789', symbols: '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' }; function getSetOfCharacters(rules) { if (typeof rules === 'undefined') { - return characterSubsets.lowercase + characterSubsets.uppercase + characterSubsets.digits + characterSubsets.symbols; + return characterSubsets.lowercase + characterSubsets.uppercase + characterSubsets.numbers + characterSubsets.symbols; } var setOfChars = ''; rules.forEach(function (rule) { @@ -8547,7 +8547,7 @@ function getOneCharPerRule(entropy, rules) { } function getConfiguredRules(passwordProfile) { - return ['lowercase', 'uppercase', 'digits', 'symbols'].filter(function (rule) { + return ['lowercase', 'uppercase', 'numbers', 'symbols'].filter(function (rule) { return passwordProfile[rule]; }); } diff --git a/index.js b/index.js index 1596941..effd2ba 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,7 @@ module.exports = { var defaultPasswordProfile = { version: 2, lowercase: true, - digits: true, + numbers: true, uppercase: true, symbols: true, keylen: 32, @@ -44,11 +44,11 @@ function generatePassword(site, login, masterPassword, passwordProfile) { var _passwordProfile = objectAssign({}, defaultPasswordProfile, passwordProfile); if (_passwordProfile.version === 1) { var options = { - counter: _passwordProfile.index, + counter: _passwordProfile.counter, length: _passwordProfile.length, lowercase: _passwordProfile.lowercase, uppercase: _passwordProfile.uppercase, - numbers: _passwordProfile.digits, + numbers: _passwordProfile.numbers, symbols: _passwordProfile.symbols }; return v1.encryptLogin(login, masterPassword) diff --git a/src/v2.js b/src/v2.js index 7881568..d770fd2 100644 --- a/src/v2.js +++ b/src/v2.js @@ -19,20 +19,20 @@ function generatePassword(site, login, masterPassword, passwordProfile) { } function calcEntropy(site, login, masterPassword, passwordProfile) { - var salt = site + login + passwordProfile.index.toString(16); + var salt = site + login + passwordProfile.counter.toString(16); return pbkdf2(masterPassword, salt, passwordProfile.iterations, passwordProfile.keylen, passwordProfile.digest); } var characterSubsets = { lowercase: 'abcdefghijklmnopqrstuvwxyz', uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - digits: '0123456789', + numbers: '0123456789', symbols: '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' }; function getSetOfCharacters(rules) { if (typeof rules === 'undefined') { - return characterSubsets.lowercase + characterSubsets.uppercase + characterSubsets.digits + characterSubsets.symbols; + return characterSubsets.lowercase + characterSubsets.uppercase + characterSubsets.numbers + characterSubsets.symbols; } var setOfChars = ''; rules.forEach(function (rule) { @@ -70,7 +70,7 @@ function getOneCharPerRule(entropy, rules) { } function getConfiguredRules(passwordProfile) { - return ['lowercase', 'uppercase', 'digits', 'symbols'].filter(function (rule) { + return ['lowercase', 'uppercase', 'numbers', 'symbols'].filter(function (rule) { return passwordProfile[rule]; }); } diff --git a/tests/v1/api.tests.js b/tests/v1/api.tests.js index 15213f6..a455edb 100644 --- a/tests/v1/api.tests.js +++ b/tests/v1/api.tests.js @@ -372,10 +372,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -389,10 +389,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -407,10 +407,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 14, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -425,10 +425,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: false, - digits: false, + numbers: false, symbols: false, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -443,10 +443,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: false, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -461,10 +461,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: false, uppercase: false, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -479,10 +479,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: false, uppercase: false, - digits: false, + numbers: false, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -497,10 +497,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: false, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -515,10 +515,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: false, + numbers: false, symbols: false, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -533,10 +533,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 2, + counter: 2, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -551,10 +551,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -569,10 +569,10 @@ describe('LessPass v1', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 12, - index: 1, + counter: 1, version: 1, }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { diff --git a/tests/v2/api.tests.js b/tests/v2/api.tests.js index 2fffb9a..a7231bd 100644 --- a/tests/v2/api.tests.js +++ b/tests/v2/api.tests.js @@ -10,10 +10,10 @@ describe('LessPass v2', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, length: 16, - index: 1, + counter: 1, version: 2 }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -28,10 +28,10 @@ describe('LessPass v2', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: false, length: 14, - index: 2, + counter: 2, version: 2 }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -46,10 +46,10 @@ describe('LessPass v2', function () { var passwordProfile = { lowercase: false, uppercase: false, - digits: true, + numbers: true, symbols: false, length: 6, - index: 3, + counter: 3, version: 2 }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { @@ -64,10 +64,10 @@ describe('LessPass v2', function () { var passwordProfile = { lowercase: true, uppercase: true, - digits: false, + numbers: false, symbols: true, length: 14, - index: 1, + counter: 1, version: 2 }; return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) { diff --git a/tests/v2/entropy.tests.js b/tests/v2/entropy.tests.js index 89c40fe..cfc2814 100644 --- a/tests/v2/entropy.tests.js +++ b/tests/v2/entropy.tests.js @@ -11,7 +11,7 @@ describe('LessPass v2', function () { iterations: 100000, keylen: 32, digest: 'sha256', - index: 1 + counter: 1 }; return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) { assert.equal('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', entropy); @@ -25,26 +25,26 @@ describe('LessPass v2', function () { iterations: 8192, keylen: 16, digest: 'sha512', - index: 1 + counter: 1 }; return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) { assert.equal('fff211c16a4e776b3574c6a5c91fd252', entropy); }); }); - it('calc entropy different if index different 1', function () { + it('calc entropy different if counter different 1', function () { var site = 'example.org'; var login = 'contact@example.org'; var masterPassword = 'password'; - var passwordProfile1 = {iterations: 1, keylen: 16, digest: 'sha256', index: 1}; + var passwordProfile1 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 1}; return LessPass._calcEntropy(site, login, masterPassword, passwordProfile1).then(function (entropy) { assert.equal('d3ec1e988dd0b3640c7491cd2c2a88b5', entropy) }); }); - it('calc entropy different if index different 2', function () { + it('calc entropy different if counter different 2', function () { var site = 'example.org'; var login = 'contact@example.org'; var masterPassword = 'password'; - var passwordProfile2 = {iterations: 1, keylen: 16, digest: 'sha256', index: 2}; + var passwordProfile2 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 2}; return LessPass._calcEntropy(site, login, masterPassword, passwordProfile2).then(function (entropy) { assert.equal('ddfb1136260f930c21f6d72f6eddbd40', entropy) }); diff --git a/tests/v2/renderPassword.tests.js b/tests/v2/renderPassword.tests.js index fb8eaad..ee671ac 100644 --- a/tests/v2/renderPassword.tests.js +++ b/tests/v2/renderPassword.tests.js @@ -5,7 +5,7 @@ describe('LessPass v2', function () { length: 16, lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true }; it('render password use remainder of long division beetween entropy and set of chars length as an index', function () { @@ -26,7 +26,7 @@ describe('LessPass v2', function () { length: 20, lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true }; assert.equal(20, LessPass._renderPassword(entropy, passwordProfile).length); @@ -41,14 +41,14 @@ describe('LessPass v2', function () { length: 6, lowercase: true, uppercase: true, - digits: true, + numbers: true, symbols: true, }; var generatedPassword = LessPass._renderPassword(entropy, passwordProfile); var passwordLength = generatedPassword.length; var lowercaseOk = false; var uppercaseOk = false; - var digitsOk = false; + var numbersOk = false; var symbolsOk = false; while (passwordLength--) { if ('abcdefghijklmnopqrstuvwxyz'.indexOf(generatedPassword[passwordLength]) !== -1) { @@ -58,13 +58,13 @@ describe('LessPass v2', function () { uppercaseOk = true; } if ('0123456789'.indexOf(generatedPassword[passwordLength]) !== -1) { - digitsOk = true; + numbersOk = true; } if ('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.indexOf(generatedPassword[passwordLength]) !== -1) { symbolsOk = true; } } assert.equal(6, generatedPassword.length); - assert(lowercaseOk && uppercaseOk && digitsOk && symbolsOk, 'there is no at least one char in every characters set'); + assert(lowercaseOk && uppercaseOk && numbersOk && symbolsOk, 'there is no at least one char in every characters set'); }); }); \ No newline at end of file diff --git a/tests/v2/setOfCharacters.tests.js b/tests/v2/setOfCharacters.tests.js index 3e36778..ef96c5f 100644 --- a/tests/v2/setOfCharacters.tests.js +++ b/tests/v2/setOfCharacters.tests.js @@ -11,7 +11,7 @@ describe('LessPass v2', function () { assert.equal(26 * 2 + 10 + 32, setOfCharacters.length); }); it('get default set of characters concat rules in order', function () { - var setOfCharacters = LessPass._getSetOfCharacters(['lowercase', 'uppercase', 'digits']); + var setOfCharacters = LessPass._getSetOfCharacters(['lowercase', 'uppercase', 'numbers']); assert.equal('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', setOfCharacters); assert.equal(26 * 2 + 10, setOfCharacters.length); }); @@ -25,8 +25,8 @@ describe('LessPass v2', function () { assert.equal('ABCDEFGHIJKLMNOPQRSTUVWXYZ', setOfCharacters); assert.equal(26, setOfCharacters.length); }); - it('get set of characters only digits', function () { - var setOfCharacters = LessPass._getSetOfCharacters(['digits']); + it('get set of characters only numbers', function () { + var setOfCharacters = LessPass._getSetOfCharacters(['numbers']); assert.equal('0123456789', setOfCharacters); assert.equal(10, setOfCharacters.length); }); @@ -48,11 +48,11 @@ describe('LessPass v2', function () { assert.deepEqual(['uppercase'], LessPass._getConfiguredRules({uppercase: true})); assert.deepEqual(['lowercase', 'uppercase'], LessPass._getConfiguredRules({uppercase: true, lowercase: true})); assert.deepEqual(['lowercase'], LessPass._getConfiguredRules({lowercase: true, symbols: false})); - assert.deepEqual(['lowercase', 'uppercase', 'digits', 'symbols'], LessPass._getConfiguredRules({ + assert.deepEqual(['lowercase', 'uppercase', 'numbers', 'symbols'], LessPass._getConfiguredRules({ lowercase: true, uppercase: true, symbols: true, - digits: true + numbers: true })); }); });