diff --git a/ewpass.js b/ewpass.js index ed0ab23..d4fa3f2 100644 --- a/ewpass.js +++ b/ewpass.js @@ -10,7 +10,7 @@ var settings = { 'checksum': undefined, - 'DEFAULT': [ 16, 1, true ], + 'DEFAULT': [ 16, 1, true, false ], 'domains': {} }; var currentDomain = undefined; @@ -44,6 +44,9 @@ var n = 0; while (m > 0) { + if (!allowBias && m < l) + break; + m = Math.floor(m / l); n++; } @@ -100,6 +103,7 @@ $('#iteration').prop('disabled', 'disabled'); $('#nextiter').prop('disabled', 'disabled'); $('#extended').prop('disabled', 'disabled'); + $('#allowbias').prop('disabled', 'disabled'); $('#storedomain').prop('disabled', 'disabled'); $('#docopy').prop('disabled', 'disabled'); @@ -122,11 +126,18 @@ $('#iteration').val(_settings[1]); $('#extended').prop('checked', _settings[2] ? 'checked' : ''); + if (_settings[3] === undefined) { + $('#allowbias').prop('checked', 'checked'); + } else { + $('#allowbias').prop('checked', _settings[3] ? 'checked' : ''); + } + if (_settings !== settings.DEFAULT) { $('#length').prop('disabled', ''); $('#iteration').prop('disabled', ''); $('#nextiter').prop('disabled', ''); $('#extended').prop('disabled', ''); + $('#allowbias').prop('disabled', ''); $('#storedomain').prop('disabled', ''); $('#docopy').prop('disabled', ''); @@ -138,7 +149,8 @@ _settings = [ parseInt($('#length').val()), parseInt($('#iteration').val()), - $('#extended').prop('checked') + $('#extended').prop('checked'), + $('#allowbias').prop('checked') ]; settings.domains[currentDomain] = _settings; @@ -162,7 +174,7 @@ const ENTROPY_SIZE = 8; const map = settings.domains[currentDomain][2] ? EXTENDED_MAP : BASIC_MAP; - const rounds = calcRounds(map.length); + const rounds = calcRounds(map.length, settings.domains[currentDomain][3] === undefined ? true : settings.domains[currentDomain][3]); if (settings.domains[currentDomain][0] > ENTROPY_SIZE * rounds) { settings.domains[currentDomain][0] = ENTROPY_SIZE * rounds; diff --git a/index.html b/index.html index 710bdd5..01d9657 100644 --- a/index.html +++ b/index.html @@ -51,6 +51,16 @@ + + + + +