Commit f5d3e324 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix setting initial SigG PIN

Note: Setting the initial NKS PIN would also fail, but as long as the
NKS NullPIN is active a different code path is used.

GnuPG-bug-id: 5220
parent 35f24bc6
......@@ -126,6 +126,8 @@ void ChangePinCommand::Private::changePin()
command << "SCD PASSWD";
if (mode == ResetMode) {
command << "--reset";
} else if (mode == NullPinMode) {
command << "--nullpin";
}
command << QByteArray::fromStdString(keyRef);
ReaderStatus::mutableInstance()->startSimpleTransaction(card, command.join(' '), q, "slotResult");
......
......@@ -27,7 +27,8 @@ class ChangePinCommand : public CardCommand
public:
enum ChangePinMode {
NormalMode = 0,
ResetMode = 1
ResetMode = 1,
NullPinMode = 2
};
explicit ChangePinCommand(const std::string &serialNumber, const std::string &appName, QWidget *parent);
......
......@@ -241,6 +241,13 @@ void NetKeyWidget::setCard(const NetKeyCard* card)
void NetKeyWidget::doChangePin(const std::string &keyRef)
{
const auto netKeyCard = ReaderStatus::instance()->getCard<NetKeyCard>(mSerialNumber);
if (!netKeyCard) {
KMessageBox::error(this,
i18n("Failed to find the smartcard with the serial number: %1", QString::fromStdString(mSerialNumber)));
return;
}
auto cmd = new ChangePinCommand(mSerialNumber, NetKeyCard::AppName, this);
this->setEnabled(false);
connect(cmd, &ChangePinCommand::finished,
......@@ -248,6 +255,10 @@ void NetKeyWidget::doChangePin(const std::string &keyRef)
this->setEnabled(true);
});
cmd->setKeyRef(keyRef);
if ((keyRef == NetKeyCard::nksPinKeyRef() && netKeyCard->hasNKSNullPin())
|| (keyRef == NetKeyCard::sigGPinKeyRef() && netKeyCard->hasSigGNullPin())) {
cmd->setMode(ChangePinCommand::NullPinMode);
}
cmd->start();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment