* Avoid creating passwords longer than amount of entropy
This commit is contained in:
16
ewpass.js
16
ewpass.js
@@ -160,14 +160,20 @@
|
|||||||
$docopy = $('#docopy');
|
$docopy = $('#docopy');
|
||||||
$docopy.prop('disabled', 'disabled');
|
$docopy.prop('disabled', 'disabled');
|
||||||
|
|
||||||
sha256(DERIVE_PREFIX + $('#seed').val() + '/' + settings.domains[currentDomain][1] + '/' + currentDomain).then(hash => {
|
const ENTROPY_SIZE = 8;
|
||||||
const map = settings.domains[currentDomain][2] ? EXTENDED_MAP : BASIC_MAP;
|
const map = settings.domains[currentDomain][2] ? EXTENDED_MAP : BASIC_MAP;
|
||||||
|
const rounds = calcRounds(map.length);
|
||||||
|
|
||||||
const rounds = calcRounds(map.length);
|
if (settings.domains[currentDomain][0] > ENTROPY_SIZE * rounds) {
|
||||||
|
settings.domains[currentDomain][0] = ENTROPY_SIZE * rounds;
|
||||||
|
ns.loadSettingsForDomain();
|
||||||
|
}
|
||||||
|
|
||||||
|
sha256(DERIVE_PREFIX + $('#seed').val() + '/' + settings.domains[currentDomain][1] + '/' + currentDomain).then(hash => {
|
||||||
var pw = '';
|
var pw = '';
|
||||||
|
|
||||||
for (var i = 0; i < 8; i++) {
|
for (var i = 0; i < ENTROPY_SIZE; i++) {
|
||||||
var x = parseInt(hash.substring(i * 8, (i+1) * 8), 16);
|
var x = parseInt(hash.substring(i * ENTROPY_SIZE, (i+1) * ENTROPY_SIZE), 16);
|
||||||
for (var j = 0; j < rounds; j++) {
|
for (var j = 0; j < rounds; j++) {
|
||||||
pw += map.substring(x % map.length, x % map.length + 1);
|
pw += map.substring(x % map.length, x % map.length + 1);
|
||||||
x = Math.floor(x / map.length);
|
x = Math.floor(x / map.length);
|
||||||
|
|||||||
Reference in New Issue
Block a user