* (Optional) remove bias in password generation

This commit is contained in:
2021-03-29 22:39:03 +02:00
parent 374fd74b33
commit 4462e58071
2 changed files with 25 additions and 3 deletions

View File

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

View File

@@ -51,6 +51,16 @@
<label><input type="checkbox" id="extended" checked="checked" /> Use special characters</label>
</td>
</tr>
<tr>
<td colspan="2">
<label>
<input type="checkbox" id="allowbias" /> Use all entropy<br />
<div style="padding-left: 2em; font-size: 70%;">
(Allows for longer passwords, but <br />makes them slightly more predictable)
</div>
</label>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" id="storedomain" value="Store" onclick="ewpass.storeSettingsForDomain();" />