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

Remove PIVCard-specific keyGrip()

Use the more generic Card::keyInfo().grip.
parent 02b63bb5
...@@ -94,7 +94,7 @@ namespace { ...@@ -94,7 +94,7 @@ namespace {
static Key getCertificateToWriteToPIVCard(const std::string &cardSlot, const std::shared_ptr<PIVCard> &card) static Key getCertificateToWriteToPIVCard(const std::string &cardSlot, const std::shared_ptr<PIVCard> &card)
{ {
if (!cardSlot.empty()) { if (!cardSlot.empty()) {
const std::string cardKeygrip = card->keyGrip(cardSlot); const std::string cardKeygrip = card->keyInfo(cardSlot).grip;
const auto certificate = KeyCache::instance()->findSubkeyByKeyGrip(cardKeygrip).parent(); const auto certificate = KeyCache::instance()->findSubkeyByKeyGrip(cardKeygrip).parent();
if (certificate.isNull() || certificate.protocol() != GpgME::CMS) { if (certificate.isNull() || certificate.protocol() != GpgME::CMS) {
return Key(); return Key();
......
...@@ -364,7 +364,7 @@ void KeyToCardCommand::Private::startKeyToPIVCard() ...@@ -364,7 +364,7 @@ void KeyToCardCommand::Private::startKeyToPIVCard()
// Check if we need to do the overwrite warning. // Check if we need to do the overwrite warning.
if (!overwriteExistingAlreadyApproved) { if (!overwriteExistingAlreadyApproved) {
const std::string existingKey = pivCard->keyGrip(cardSlot); const std::string existingKey = pivCard->keyInfo(cardSlot).grip;
if (!existingKey.empty() && (existingKey != subkey.keyGrip())) { if (!existingKey.empty() && (existingKey != subkey.keyGrip())) {
const QString decryptionWarning = (cardSlot == PIVCard::keyManagementKeyRef()) ? const QString decryptionWarning = (cardSlot == PIVCard::keyManagementKeyRef()) ?
i18n("It will no longer be possible to decrypt past communication encrypted for the existing key.") : i18n("It will no longer be possible to decrypt past communication encrypted for the existing key.") :
......
...@@ -122,7 +122,7 @@ void PIVGenerateCardKeyCommand::doStart() ...@@ -122,7 +122,7 @@ void PIVGenerateCardKeyCommand::doStart()
return; return;
} }
auto existingKey = pivCard->keyGrip(d->keyRef); auto existingKey = pivCard->keyInfo(d->keyRef).grip;
if (!existingKey.empty()) { if (!existingKey.empty()) {
const QString warningText = i18nc("@info", const QString warningText = i18nc("@info",
"<p>This card already contains a key in this slot. Continuing will <b>overwrite</b> that key.</p>" "<p>This card already contains a key in this slot. Continuing will <b>overwrite</b> that key.</p>"
......
...@@ -113,11 +113,6 @@ std::vector< std::pair<std::string, QString> > PIVCard::supportedAlgorithms(cons ...@@ -113,11 +113,6 @@ std::vector< std::pair<std::string, QString> > PIVCard::supportedAlgorithms(cons
}; };
} }
std::string PIVCard::keyGrip(const std::string& keyRef) const
{
return keyInfo(keyRef).grip;
}
void PIVCard::setCardInfo(const std::vector< std::pair<std::string, std::string> > &infos) void PIVCard::setCardInfo(const std::vector< std::pair<std::string, std::string> > &infos)
{ {
qCDebug(KLEOPATRA_LOG) << "Card" << serialNumber().c_str() << "info:"; qCDebug(KLEOPATRA_LOG) << "Card" << serialNumber().c_str() << "info:";
......
...@@ -37,8 +37,6 @@ public: ...@@ -37,8 +37,6 @@ public:
static QString keyDisplayName(const std::string &keyRef); static QString keyDisplayName(const std::string &keyRef);
static std::vector< std::pair<std::string, QString> > supportedAlgorithms(const std::string &keyRef); static std::vector< std::pair<std::string, QString> > supportedAlgorithms(const std::string &keyRef);
std::string keyGrip(const std::string &keyRef) const;
void setCardInfo(const std::vector< std::pair<std::string, std::string> > &infos); void setCardInfo(const std::vector< std::pair<std::string, std::string> > &infos);
std::string keyAlgorithm(const std::string &keyRef) const; std::string keyAlgorithm(const std::string &keyRef) const;
......
...@@ -500,7 +500,7 @@ static void handle_piv_card(std::shared_ptr<Card> &ci, std::shared_ptr<Context> ...@@ -500,7 +500,7 @@ static void handle_piv_card(std::shared_ptr<Card> &ci, std::shared_ptr<Context>
setDisplaySerialNumber(pivCard, gpg_agent); setDisplaySerialNumber(pivCard, gpg_agent);
for (const std::string &keyRef : PIVCard::supportedKeys()) { for (const std::string &keyRef : PIVCard::supportedKeys()) {
if (!pivCard->keyGrip(keyRef).empty()) { if (!pivCard->keyInfo(keyRef).grip.empty()) {
readKeyPairInfoFromPIVCard(keyRef, pivCard, gpg_agent); readKeyPairInfoFromPIVCard(keyRef, pivCard, gpg_agent);
readCertificateFromPIVCard(keyRef, pivCard, gpg_agent); readCertificateFromPIVCard(keyRef, pivCard, gpg_agent);
} }
......
...@@ -234,7 +234,7 @@ void PIVCardWidget::setCard(const PIVCard *card) ...@@ -234,7 +234,7 @@ void PIVCardWidget::setCard(const PIVCard *card)
void PIVCardWidget::updateKeyWidgets(const std::string &keyRef, const PIVCard *card) void PIVCardWidget::updateKeyWidgets(const std::string &keyRef, const PIVCard *card)
{ {
KeyWidgets widgets = mKeyWidgets.value(keyRef); KeyWidgets widgets = mKeyWidgets.value(keyRef);
const std::string grip = card ? card->keyGrip(keyRef) : widgets.keyGrip->text().toStdString(); const std::string grip = card ? card->keyInfo(keyRef).grip : widgets.keyGrip->text().toStdString();
if (grip.empty()) { if (grip.empty()) {
widgets.certificateInfo->setText(i18nc("@info", "<em>slot empty</em>")); widgets.certificateInfo->setText(i18nc("@info", "<em>slot empty</em>"));
widgets.certificateInfo->setToolTip(QString()); widgets.certificateInfo->setToolTip(QString());
......
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