diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a6dc3399..04542d94c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,214 +1,228 @@ # target_include_directories does not handle empty include paths include_directories(${GPGME_INCLUDES}) add_definitions(-DTRANSLATION_DOMAIN=\"libkleopatra\") #add_definitions( -DQT_NO_CAST_FROM_ASCII ) #add_definitions( -DQT_NO_CAST_TO_ASCII ) kde_enable_exceptions() add_definitions( -DGPGMEPP_ERR_SOURCE_DEFAULT=13 ) # 13 is GPG_ERR_SOURCE_KLEO, even if gpg-error's too old to know about add_subdirectory( pics ) if (BUILD_TESTING) add_subdirectory( tests ) endif() ########### next target ############### set(libkleo_core_SRCS kleo/checksumdefinition.cpp kleo/defaultkeyfilter.cpp kleo/defaultkeygenerationjob.cpp kleo/dn.cpp kleo/enum.cpp kleo/exception.cpp kleo/kconfigbasedkeyfilter.cpp kleo/keyfiltermanager.cpp kleo/keyresolver.cpp models/keycache.cpp models/keylistmodel.cpp models/keylistsortfilterproxymodel.cpp models/keyrearrangecolumnsproxymodel.cpp models/subkeylistmodel.cpp models/useridlistmodel.cpp utils/filesystemwatcher.cpp utils/formatting.cpp utils/classify.cpp utils/gnupg.cpp utils/hex.cpp smartcard/card.cpp smartcard/openpgpcard.cpp smartcard/netkeycard.cpp + smartcard/cardmanager.cpp ) ecm_qt_declare_logging_category(libkleo_core_SRCS HEADER libkleo_debug.h IDENTIFIER LIBKLEO_LOG CATEGORY_NAME org.kde.pim.libkleo) set(libkleo_ui_common_SRCS ui/dnattributeorderconfigwidget.cpp ui/kdhorizontalline.cpp ui/filenamerequester.cpp ui/messagebox.cpp ui/cryptoconfigmodule.cpp ui/cryptoconfigdialog.cpp ui/directoryserviceswidget.cpp ui/progressbar.cpp ui/progressdialog.cpp ui/auditlogviewer.cpp ) ecm_qt_declare_logging_category(libkleo_ui_common_SRCS HEADER kleo_ui_debug.h IDENTIFIER KLEO_UI_LOG CATEGORY_NAME org.kde.pim.kleo_ui) set(libkleo_ui_SRCS # make this a separate lib. ui/keylistview.cpp ui/keyselectiondialog.cpp ui/keyrequester.cpp ui/keyapprovaldialog.cpp ui/newkeyapprovaldialog.cpp ui/keyselectioncombo.cpp ) ki18n_wrap_ui(libkleo_ui_common_SRCS ui/directoryserviceswidget.ui ) set(kleo_LIB_SRCS ${libkleo_core_SRCS} ${libkleo_ui_SRCS} ${libkleo_ui_common_SRCS}) set(kleo_LIB_LIBS PUBLIC QGpgme Gpgmepp PRIVATE Qt5::Widgets KF5::I18n KF5::Completion KF5::ConfigCore KF5::CoreAddons KF5::WidgetsAddons KF5::ItemModels KF5::Codecs) if (KF5PimTextEdit_FOUND) add_definitions(-DHAVE_PIMTEXTEDIT) set(kleo_LIB_LIBS ${kleo_LIB_LIBS} PRIVATE KF5::PimTextEdit) endif() add_library(KF5Libkleo ${kleo_LIB_SRCS}) generate_export_header(KF5Libkleo BASE_NAME kleo) add_library(KF5::Libkleo ALIAS KF5Libkleo) if(WIN32) target_link_libraries(KF5Libkleo ${kleo_LIB_LIBS} ${GPGME_VANILLA_LIBRARIES} ) else() target_link_libraries(KF5Libkleo ${kleo_LIB_LIBS} ) endif() set_target_properties(KF5Libkleo PROPERTIES VERSION ${LIBKLEO_VERSION_STRING} SOVERSION ${LIBKLEO_SOVERSION} EXPORT_NAME Libkleo ) install(TARGETS KF5Libkleo EXPORT KF5LibkleoTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) target_include_directories(KF5Libkleo PUBLIC "$") target_include_directories(KF5Libkleo INTERFACE "$") ecm_generate_headers(libkleo_CamelCase_HEADERS HEADER_NAMES ChecksumDefinition DefaultKeyFilter DefaultKeyGenerationJob Dn Enum Exception KConfigBasedKeyFilter KeyFilter KeyFilterManager KeyResolver OidMap Predicates Stl_Util REQUIRED_HEADERS libkleo_HEADERS PREFIX Libkleo RELATIVE kleo ) ecm_generate_headers(libkleo_CamelCase_models_HEADERS HEADER_NAMES KeyCache KeyListModel KeyListModelInterface KeyListSortFilterProxyModel KeyRearrangeColumnsProxyModel SubkeyListModel UserIDListModel REQUIRED_HEADERS libkleo_models_HEADERS PREFIX Libkleo RELATIVE models ) ecm_generate_headers(libkleo_CamelCase_utils_HEADERS HEADER_NAMES Classify FileSystemWatcher Formatting GnuPG REQUIRED_HEADERS libkleo_utils_HEADERS PREFIX Libkleo RELATIVE utils ) +ecm_generate_headers(libkleo_CamelCase_smartcard_HEADERS + HEADER_NAMES + Card + NetKeyCard + OpenPGPCard + CardManager + REQUIRED_HEADERS libkleo_smartcard_HEADERS + PREFIX Libkleo + RELATIVE smartcard +) + ecm_generate_headers(libkleo_CamelCase_ui_HEADERS HEADER_NAMES CryptoConfigDialog CryptoConfigModule DNAttributeOrderConfigWidget DirectoryServicesWidget FileNameRequester KDHorizontalLine KeyApprovalDialog NewKeyApprovalDialog KeyRequester KeySelectionCombo KeySelectionDialog MessageBox ProgressDialog REQUIRED_HEADERS libkleo_ui_HEADERS PREFIX Libkleo RELATIVE ui ) ecm_generate_pri_file(BASE_NAME Libkleo LIB_NAME KF5Libkleo DEPS "QGpgme" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/Libkleo ) install(FILES ${libkleo_CamelCase_HEADERS} ${libkleo_CamelCase_models_HEADERS} ${libkleo_CamelCase_ui_HEADERS} ${libkleo_CamelCase_utils_HEADERS} + ${libkleo_CamelCase_smartcard_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/Libkleo COMPONENT Devel ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kleo_export.h ${libkleo_HEADERS} ${libkleo_models_HEADERS} ${libkleo_ui_HEADERS} ${libkleo_utils_HEADERS} + ${libkleo_smartcard_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/libkleo COMPONENT Devel ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) if ( WIN32 ) install ( FILES libkleopatrarc-win32.desktop DESTINATION ${KDE_INSTALL_CONFDIR} RENAME libkleopatrarc ) else () install ( FILES libkleopatrarc.desktop DESTINATION ${KDE_INSTALL_CONFDIR} RENAME libkleopatrarc ) endif () diff --git a/src/smartcard/card.cpp b/src/smartcard/card.cpp index b3947ca2f..2b50a57e3 100644 --- a/src/smartcard/card.cpp +++ b/src/smartcard/card.cpp @@ -1,169 +1,226 @@ /* smartcard/card.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH Copyright (c) 2020 by g10 Code GmbH Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "card.h" +#include +#include +#include +#include + +#include "libkleo_debug.h" + using namespace Kleo; using namespace Kleo::SmartCard; class Card::Private { public: Private(): mCanLearn(false), mHasNullPin(false), mStatus(Status::NoCard), mAppType(UnknownApplication), mAppVersion(-1) { } + Private(const QString &gpgOutput) + { + const auto lines = gpgOutput.split(QRegExp("[\r\n]"), + QString::SkipEmptyParts); + for (const auto &line: lines) { + auto words = line.split(QLatin1Char(':')); + if (words.size () < 2) { + qCDebug(LIBKLEO_LOG) << "Failed to parse line:" << line; + continue; + } + QString key = words.takeFirst (); + if (key.startsWith(QLatin1Char(' '))) { + qCDebug(LIBKLEO_LOG) << "Ignoring subline:" << line; + continue; + } + key.remove(QRegExp(" \\.*$")); + mProperties.insert(key, words); + } + + mReader = getSingleProperty("Reader"); + mSerialNumber = getSingleProperty("Serial number").toStdString(); + } + + QString getSingleProperty(const char *val) const + { + if (!val) { + return QString(); + } + const auto list = mProperties.value(QLatin1String(val)); + if (list.empty()) { + return QString(); + } + return list.first(); + } + + QString mReader; bool mCanLearn; bool mHasNullPin; Status mStatus; std::string mSerialNumber; AppType mAppType; int mAppVersion; std::vector mPinStates; int mSlot; QString mErrMsg; + QMap mProperties; }; Card::Card(): d(new Private()) { } +Card::Card(const QString &gpgOutput): d(new Private(gpgOutput)) { +} + +QString Card::getSingleProperty(const char *propName) const +{ + return d->getSingleProperty(propName); +} + void Card::setStatus(Status s) { d->mStatus = s; } Card::Status Card::status() const { return d->mStatus; } void Card::setSerialNumber(const std::string &sn) { d->mSerialNumber = sn; } std::string Card::serialNumber() const { return d->mSerialNumber; } Card::AppType Card::appType() const { return d->mAppType; } void Card::setAppType(AppType t) { d->mAppType = t; } void Card::setAppVersion(int version) { d->mAppVersion = version; } int Card::appVersion() const { return d->mAppVersion; } std::vector Card::pinStates() const { return d->mPinStates; } void Card::setPinStates(const std::vector &pinStates) { d->mPinStates = pinStates; } void Card::setSlot(int slot) { d->mSlot = slot; } int Card::slot() const { return d->mSlot; } bool Card::hasNullPin() const { return d->mHasNullPin; } void Card::setHasNullPin(bool value) { d->mHasNullPin = value; } bool Card::canLearnKeys() const { return d->mCanLearn; } void Card::setCanLearnKeys(bool value) { d->mCanLearn = value; } bool Card::operator == (const Card& other) const { return d->mStatus == other.status() && d->mSerialNumber == other.serialNumber() && d->mAppType == other.appType() && d->mAppVersion == other.appVersion() && d->mPinStates == other.pinStates() && d->mSlot == other.slot() && d->mCanLearn == other.canLearnKeys() && d->mHasNullPin == other.hasNullPin(); } bool Card::operator != (const Card& other) const { return !operator==(other); } void Card::setErrorMsg(const QString &msg) { d->mErrMsg = msg; } QString Card::errorMsg() const { return d->mErrMsg; } + +QString Card::reader() const +{ + return d->mReader; +} diff --git a/src/smartcard/card.h b/src/smartcard/card.h index 235d88c2e..d691131f8 100644 --- a/src/smartcard/card.h +++ b/src/smartcard/card.h @@ -1,124 +1,130 @@ #ifndef SMARTCARD_CARD_H #define SMARTCARD_CARD_H /* smartcard/card.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include #include #include #include +#include "kleo_export.h" namespace Kleo { namespace SmartCard { -class ReaderStatus; /** Class to work with Smartcards or other Hardware tokens. */ -class Card +class KLEO_EXPORT Card { public: enum AppType { UnknownApplication, OpenPGPApplication, NksApplication, P15Application, DinSigApplication, GeldkarteApplication, + PIVApplication, NumAppTypes }; enum PinState { UnknownPinState, NullPin, PinBlocked, NoPin, PinOk, NumPinStates }; enum Status { NoCard, CardPresent, CardActive, CardUsable, _NumScdStates, CardError = _NumScdStates, NumStates }; Card(); + Card(const QString &gpgCardOutput); virtual ~Card() {} virtual bool operator == (const Card& other) const; bool operator != (const Card& other) const; void setStatus(Status s); Status status() const; virtual void setSerialNumber(const std::string &sn); std::string serialNumber() const; AppType appType() const; void setAppType(AppType type); void setAppVersion(int version); int appVersion() const; std::vector pinStates() const; void setPinStates(const std::vector &pinStates); void setSlot(int slot); int slot() const; bool hasNullPin() const; void setHasNullPin(bool value); bool canLearnKeys() const; void setCanLearnKeys(bool value); QString errorMsg() const; void setErrorMsg(const QString &msg); + QString reader() const; + + QString getSingleProperty(const char *name) const; + private: class Private; std::shared_ptr d; }; } // namespace Smartcard } // namespace Kleopatra #endif // SMARTCARD_CARD_H diff --git a/src/smartcard/cardmanager.cpp b/src/smartcard/cardmanager.cpp new file mode 100644 index 000000000..e1b0dbc82 --- /dev/null +++ b/src/smartcard/cardmanager.cpp @@ -0,0 +1,168 @@ +/* + This file is part of libkleopatra, the KDE keymanagement library + Copyright (c) 2020 g10 Code GmbH + + Libkleopatra is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + Libkleopatra is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#include "cardmanager.h" + +#include "libkleo_debug.h" + +#include + +#include + +#if GPGMEPP_VERSION < 0x10E00 // 1.14.0 +# define GPGMEPP_TOO_OLD +#else +# include +#endif + +using namespace Kleo; +using namespace SmartCard; + +class CardManager::Private +{ +public: + Private(CardManager *qq): q(qq), mErrCode(0) + { + + } + + void addCard(const QString &std_out) + { + Card *genericCard = new Card(std_out); + /* TODO Specialize */ + + mCards << std::shared_ptr(genericCard); + } + + void cardListDone (const QString &std_out, const QString &std_err, + int exitCode) + { + mErrorStr = std_err; + mErrCode = exitCode; + mCards.clear(); + if (exitCode) { + qCDebug(LIBKLEO_LOG) << "Card list failed with code:" << exitCode; + Q_EMIT q->cardsMayHaveChanged (); + return; + } + + mCardsToApps.clear(); + const auto lines = std_out.split(QRegExp("[\r\n]"), + QString::SkipEmptyParts); + for (const auto &line: lines) { + auto words = line.split(QLatin1Char(' ')); + /* The first word is the selection */ + words.pop_front (); + const auto key = words.takeFirst(); + mCardsToApps.insert(key, words); + } + int i = 0; + for (const auto &id: mCardsToApps.keys()) { + const auto apps = mCardsToApps.value(id); + + /* Now for each card start a specific listing */ + auto cmd = QGpgME::gpgCardJob(); + QString std_out; + QString std_err; + int exitCode = 0; + + if (apps.empty()) { + GpgME::Error err = cmd->exec(QStringList() << QStringLiteral("--") + << QStringLiteral("list") + << QStringLiteral("--no-key-lookup") + << QString::number(i), std_out, std_err, + exitCode); + if (err || exitCode) { + qCDebug(LIBKLEO_LOG) << "Card list failed with code:" << exitCode; + qCDebug(LIBKLEO_LOG) << "Error:" << std_err; + } else { + addCard(std_out); + } + } else { + for (const auto &app: apps) { + GpgME::Error err = cmd->exec(QStringList() << QStringLiteral("--") + << QStringLiteral("list") + << QStringLiteral("--no-key-lookup") + << QString::number(i) + << app, + std_out, std_err, + exitCode); + if (err || exitCode) { + qCDebug(LIBKLEO_LOG) << "Card list failed with code:" << exitCode; + qCDebug(LIBKLEO_LOG) << "Error:" << std_err; + } else { + addCard(std_out); + } + } + } + i++; + } + Q_EMIT q->cardsMayHaveChanged (); + } + + QList > mCards; + +private: + /* A map of available card ID's to the apps they support */ + QMap mCardsToApps; + CardManager *q; + QString mErrorStr; + int mErrCode; +}; + +CardManager::CardManager(): d(new Private(this)) +{ + +} + +void CardManager::startCardList() const +{ +#ifdef GPGMEPP_TOO_OLD + qCWarning(LIBKLEO_LOG) << "GPGME Version too old"; + return; +#else + auto cmd = QGpgME::gpgCardJob(); + + connect(cmd, &QGpgME::GpgCardJob::result, this, + [this] (const QString &std_out, const QString &std_err, int exitCode, const QString&, const GpgME::Error &) { + d->cardListDone(std_out, std_err, exitCode); + }); + + cmd->start(QStringList() << QStringLiteral("--") + << QStringLiteral("list") + << QStringLiteral("--cards") + << QStringLiteral("--apps")); +#endif +} + +QList > CardManager::cards() const +{ + return d->mCards; +} diff --git a/src/smartcard/cardmanager.h b/src/smartcard/cardmanager.h new file mode 100644 index 000000000..55ee1ada1 --- /dev/null +++ b/src/smartcard/cardmanager.h @@ -0,0 +1,70 @@ +#ifndef CARDMANAGER_H +#define CARDMANAGER_H +/* + This file is part of libkleopatra, the KDE keymanagement library + Copyright (c) 2020 g10 Code GmbH + + Libkleopatra is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + Libkleopatra is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#include "kleo_export.h" + +#include +#include +#include "card.h" +#include "QObject" + +namespace Kleo +{ +namespace SmartCard +{ + +/** Management of multiple smartcards */ +class KLEO_EXPORT CardManager: public QObject +{ + Q_OBJECT +public: + CardManager(); + + /* Start a listing of all available cards. */ + void startCardList() const; + + /* Get references to all the cards we know about. */ + QList > cards() const; + +Q_SIGNALS: + /* This is emitted when the list is done or a change + * is detected otherwise. Should invalidate a GUI */ + void cardsMayHaveChanged(); + +private: + class Private; + std::shared_ptr d; +}; +} // namespace SmartCard +} // namespace Kleo + +#endif // CARDMANAGER_H diff --git a/src/smartcard/netkeycard.h b/src/smartcard/netkeycard.h index d8706cbc5..3c80dd24d 100644 --- a/src/smartcard/netkeycard.h +++ b/src/smartcard/netkeycard.h @@ -1,65 +1,67 @@ #ifndef SMARTCARD_NETKEYCARD_H #define SMARTCARD_NETKEYCARD_H /* smartcard/openpgpcard.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2017 Intevation GmbH Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "card.h" #include #include +#include "kleo_export.h" + namespace Kleo { namespace SmartCard { /** Class to work with OpenPGP Smartcards or compatible tokens */ -class NetKeyCard: public Card +class KLEO_EXPORT NetKeyCard: public Card { public: NetKeyCard (); void setKeyPairInfo (const std::vector &infos); bool hasSigGNullPin() const; bool hasNKSNullPin() const; std::vector keys() const; private: class Private; std::shared_ptr d; }; } // namespace Smartcard } // namespace Kleopatra #endif // SMARTCARD_CARD_H diff --git a/src/smartcard/openpgpcard.h b/src/smartcard/openpgpcard.h index f03050f4f..e96d3e1d3 100644 --- a/src/smartcard/openpgpcard.h +++ b/src/smartcard/openpgpcard.h @@ -1,73 +1,75 @@ #ifndef SMARTCARD_OPENPGPCARD_H #define SMARTCARD_OPENPGPCARD_H /* smartcard/openpgpcard.h This file is part of Kleopatra, the KDE keymanager Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH Kleopatra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Kleopatra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include #include #include "card.h" +#include "kleo_export.h" + namespace Kleo { namespace SmartCard { /** Class to work with OpenPGP Smartcards or compatible tokens */ -class OpenPGPCard: public Card +class KLEO_EXPORT OpenPGPCard: public Card { public: OpenPGPCard (); OpenPGPCard (const std::string &serialno); void setSerialNumber(const std::string &sn) override; std::string encFpr() const; std::string sigFpr() const; std::string authFpr() const; void setKeyPairInfo (const std::vector< std::pair > &infos); bool operator == (const Card& other) const override; std::string manufacturer() const; std::string cardVersion() const; std::string cardHolder() const; std::string pubkeyUrl() const; private: class Private; std::shared_ptr d; }; } // namespace Smartcard } // namespace Kleopatra #endif // SMARTCARD_CARD_H