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

Add support for unblocking the PIN/card with the reset code

GnuPG-bug-id: 5138
parent 1020fcd7
Pipeline #44519 passed with stage
in 19 minutes and 29 seconds
......@@ -132,31 +132,37 @@ void ChangePinCommand::Private::changePin()
}
namespace {
static QString errorMessage(const std::string &keyRef, const QString &errorText)
static QString errorMessage(const std::string &keyRef, ChangePinCommand::ChangePinMode mode, const QString &errorText)
{
// see cmd_passwd() in gpg-card.c
if (keyRef == PIVCard::pukKeyRef()) {
return i18nc("@info", "Changing the PUK failed: %1", errorText);
}
if (keyRef == OpenPGPCard::resetCodeKeyRef()) {
return i18nc("@info", "Unblocking the PIN failed: %1", errorText);
}
if (keyRef == OpenPGPCard::adminPinKeyRef()) {
return i18nc("@info", "Changing the Admin PIN failed: %1", errorText);
}
if (keyRef == OpenPGPCard::resetCodeKeyRef()) {
if (keyRef == OpenPGPCard::resetCodeKeyRef() && mode == ChangePinCommand::ResetMode) {
return i18nc("@info", "Changing the Reset Code failed: %1", errorText);
}
return i18nc("@info", "Changing the PIN failed: %1", errorText);
}
static QString successMessage(const std::string &keyRef)
static QString successMessage(const std::string &keyRef, ChangePinCommand::ChangePinMode mode)
{
// see cmd_passwd() in gpg-card.c
if (keyRef == PIVCard::pukKeyRef()) {
return i18nc("@info", "PUK successfully changed.");
}
if (keyRef == OpenPGPCard::resetCodeKeyRef()) {
return i18nc("@info", "Unblocked and set a new PIN successfully.");
}
if (keyRef == OpenPGPCard::adminPinKeyRef()) {
return i18nc("@info", "Admin PIN changed successfully.");
}
if (keyRef == OpenPGPCard::resetCodeKeyRef()) {
if (keyRef == OpenPGPCard::resetCodeKeyRef() && mode == ChangePinCommand::ResetMode) {
return i18nc("@info", "Reset Code changed successfully.");
}
return i18nc("@info", "PIN changed successfully.");
......@@ -168,10 +174,10 @@ void ChangePinCommand::Private::slotResult(const GpgME::Error& err)
qCDebug(KLEOPATRA_LOG) << "ChangePinCommand::slotResult():"
<< err.asString() << "(" << err.code() << ")";
if (err) {
error(errorMessage(keyRef, QString::fromLatin1(err.asString())),
error(errorMessage(keyRef, mode, QString::fromLatin1(err.asString())),
i18nc("@title", "Error"));
} else if (!err.isCanceled()) {
information(successMessage(keyRef), i18nc("@title", "Success"));
information(successMessage(keyRef, mode), i18nc("@title", "Success"));
ReaderStatus::mutableInstance()->updateStatus();
}
finished();
......
......@@ -197,7 +197,7 @@ PGPCardWidget::PGPCardWidget(QWidget *parent):
auto actionLayout = new QHBoxLayout;
{
auto generateButton = new QPushButton(i18n("Generate new Keys"));
auto generateButton = new QPushButton(i18n("Generate New Keys"));
generateButton->setToolTip(i18n("Create a new primary key and generate subkeys on the card."));
actionLayout->addWidget(generateButton);
connect(generateButton, &QPushButton::clicked, this, &PGPCardWidget::genkeyRequested);
......@@ -208,6 +208,12 @@ PGPCardWidget::PGPCardWidget(QWidget *parent):
actionLayout->addWidget(pinButton);
connect(pinButton, &QPushButton::clicked, this, [this] () { doChangePin(OpenPGPCard::pinKeyRef()); });
}
{
auto unblockButton = new QPushButton(i18n("Unblock Card"));
unblockButton->setToolTip(i18n("Unblock the smartcard and set a new PIN."));
actionLayout->addWidget(unblockButton);
connect(unblockButton, &QPushButton::clicked, this, [this] () { doChangePin(OpenPGPCard::resetCodeKeyRef()); });
}
{
auto pukButton = new QPushButton(i18n("Change Admin PIN"));
pukButton->setToolTip(i18n("Change the PIN required for administrative operations."));
......
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