Fix keepassxc-browser password entropy display (#3107)
* Pass correct entropy amount to keepassxc-browser instead of amount of bits for both password and passphrase. * Rename json key from "login" to "entropy" (keeping "login" key for backwards compatibility). * Also make some changes to entropy calculation methods: - Rename PassphraseGenerator::calculateEntropy to estimateEntropy - Rename PasswordGenerator::calculateEntropy to estimateEntropy
This commit is contained in:
committed by
Jonathan White
parent
7ceca8ff3c
commit
e40f10657d
@@ -278,18 +278,18 @@ QJsonObject BrowserAction::handleGetLogins(const QJsonObject& json, const QStrin
|
||||
|
||||
QJsonObject BrowserAction::handleGeneratePassword(const QJsonObject& json, const QString& action)
|
||||
{
|
||||
const QString nonce = json.value("nonce").toString();
|
||||
const QString password = browserSettings()->generatePassword();
|
||||
auto nonce = json.value("nonce").toString();
|
||||
auto password = browserSettings()->generatePassword();
|
||||
|
||||
if (nonce.isEmpty() || password.isEmpty()) {
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
// For backwards compatibility
|
||||
password["login"] = password["entropy"];
|
||||
|
||||
QJsonArray arr;
|
||||
QJsonObject passwd;
|
||||
passwd["login"] = QString::number(password.length() * 8); // bits;
|
||||
passwd["password"] = password;
|
||||
arr.append(passwd);
|
||||
arr.append(password);
|
||||
|
||||
const QString newNonce = incrementNonce(nonce);
|
||||
|
||||
|
||||
@@ -512,18 +512,23 @@ PasswordGenerator::GeneratorFlags BrowserSettings::passwordGeneratorFlags()
|
||||
return flags;
|
||||
}
|
||||
|
||||
QString BrowserSettings::generatePassword()
|
||||
QJsonObject BrowserSettings::generatePassword()
|
||||
{
|
||||
QJsonObject password;
|
||||
if (generatorType() == 0) {
|
||||
m_passwordGenerator.setLength(passwordLength());
|
||||
m_passwordGenerator.setCharClasses(passwordCharClasses());
|
||||
m_passwordGenerator.setFlags(passwordGeneratorFlags());
|
||||
return m_passwordGenerator.generatePassword();
|
||||
const QString pw = m_passwordGenerator.generatePassword();
|
||||
password["entropy"] = m_passwordGenerator.estimateEntropy(pw);
|
||||
password["password"] = pw;
|
||||
} else {
|
||||
m_passPhraseGenerator.setWordCount(passPhraseWordCount());
|
||||
m_passPhraseGenerator.setWordSeparator(passPhraseWordSeparator());
|
||||
return m_passPhraseGenerator.generatePassphrase();
|
||||
password["entropy"] = m_passPhraseGenerator.estimateEntropy();
|
||||
password["password"] = m_passPhraseGenerator.generatePassphrase();
|
||||
}
|
||||
return password;
|
||||
}
|
||||
|
||||
void BrowserSettings::updateBinaryPaths(const QString& customProxyLocation)
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
void setPasswordLength(int length);
|
||||
PasswordGenerator::CharClasses passwordCharClasses();
|
||||
PasswordGenerator::GeneratorFlags passwordGeneratorFlags();
|
||||
QString generatePassword();
|
||||
QJsonObject generatePassword();
|
||||
void updateBinaryPaths(const QString& customProxyLocation = QString());
|
||||
bool checkIfProxyExists(QString& path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user