Skip to content

Commit b7f5ef3

Browse files
committed
CipherDialog: Improve password fields validation
For RawKey key format, password length must at least 3 symbols. '0x' is just a placeholder and the real key begins at the third symbol
1 parent 1e77bc7 commit b7f5ef3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/CipherDialog.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ CipherSettings CipherDialog::getCipherSettings() const
7979

8080
void CipherDialog::checkInputFields()
8181
{
82+
CipherSettings::KeyFormats keyFormat = CipherSettings::getKeyFormat(ui->comboKeyFormat->currentIndex());
8283
if(sender() == ui->comboKeyFormat)
8384
{
84-
CipherSettings::KeyFormats keyFormat = CipherSettings::getKeyFormat(ui->comboKeyFormat->currentIndex());
85-
8685
if(keyFormat == CipherSettings::KeyFormats::Passphrase)
8786
{
8887
ui->editPassword->setValidator(nullptr);
@@ -99,8 +98,14 @@ void CipherDialog::checkInputFields()
9998
}
10099

101100
bool valid = true;
102-
if(encryptMode)
103-
valid = ui->editPassword->text() == ui->editPassword2->text();
101+
if(encryptMode) {
102+
const QString password1 = ui->editPassword->text();
103+
valid = password1 == ui->editPassword2->text();
104+
105+
if (keyFormat == CipherSettings::KeyFormats::RawKey) {
106+
valid &= password1.isEmpty() || password1.length() > 2;
107+
}
108+
}
104109

105110
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
106111
}

0 commit comments

Comments
 (0)