mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add support for Diceware wordlists in numbered and/or PGP-signed formats (#6791)
This allows one to directly use Diceware-compatible wordlists without having to convert the file to the plain wordlist format. The accepted formats are described in the Diceware documentation: https://diceware.readthedocs.io/en/stable/wordlists.html
This commit is contained in:
parent
5ec2686024
commit
e660802fac
@ -256,6 +256,7 @@ The same password generation options as documented for the generate command can
|
||||
Sets the Path of the wordlist for the diceware generator.
|
||||
The wordlist must have > 1000 words, otherwise the program will fail.
|
||||
If the wordlist has < 4000 words a warning will be printed to STDERR.
|
||||
Any *diceware*-compatible wordlist can used. Note however that *KeePassXC* will NOT verify the PGP signature of signed wordlists.
|
||||
|
||||
=== Export options
|
||||
*-f*, *--format*::
|
||||
|
@ -68,8 +68,28 @@ void PassphraseGenerator::setWordList(const QString& path)
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd()) {
|
||||
m_wordlist.append(in.readLine());
|
||||
QString line = in.readLine();
|
||||
bool isSigned = line.startsWith("-----BEGIN PGP SIGNED MESSAGE-----");
|
||||
if (isSigned) {
|
||||
while (!line.isNull() && !line.trimmed().isEmpty()) {
|
||||
line = in.readLine();
|
||||
}
|
||||
}
|
||||
QRegExp rx("^[0-9]+(-[0-9]+)*\\s+([^\\s]+)$");
|
||||
while (!line.isNull()) {
|
||||
if (isSigned && line.startsWith("-----BEGIN PGP SIGNATURE-----")) {
|
||||
break;
|
||||
}
|
||||
// Handle dash-escaped lines (if the wordlist is signed)
|
||||
if (isSigned && line.startsWith("- ")) {
|
||||
line.remove(0, 2);
|
||||
}
|
||||
line = line.trimmed();
|
||||
line.replace(rx, "\\2");
|
||||
if (!line.isEmpty()) {
|
||||
m_wordlist.append(line);
|
||||
}
|
||||
line = in.readLine();
|
||||
}
|
||||
|
||||
if (m_wordlist.size() < 4000) {
|
||||
|
Loading…
Reference in New Issue
Block a user