qca_keystore.h
Go to the documentation of this file.
/*
* qca_keystore.h - Qt Cryptographic Architecture
* Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef QCA_KEYSTORE_H
#define QCA_KEYSTORE_H
#include "qca_cert.h"
#include "qca_core.h"
namespace QCA {
class KeyStoreTracker;
class KeyStoreManagerPrivate;
class KeyStorePrivate;
class QCA_EXPORT KeyStoreEntry : public Algorithm
{
public:
enum Type
{
TypeKeyBundle,
TypeCertificate,
TypeCRL,
TypePGPSecretKey,
TypePGPPublicKey
};
KeyStoreEntry();
KeyStoreEntry(const QString &serialized);
KeyStoreEntry(const KeyStoreEntry &from);
~KeyStoreEntry() override;
KeyStoreEntry &operator=(const KeyStoreEntry &from);
bool isNull() const;
bool isAvailable() const;
bool isAccessible() const;
Type type() const;
QString name() const;
QString id() const;
QString storeName() const;
QString storeId() const;
QString toString() const;
static KeyStoreEntry fromString(const QString &serialized);
KeyBundle keyBundle() const;
Certificate certificate() const;
CRL crl() const;
PGPKey pgpSecretKey() const;
PGPKey pgpPublicKey() const;
bool ensureAvailable();
bool ensureAccess();
private:
class Private;
Private *d;
friend class KeyStoreTracker;
};
class QCA_EXPORT KeyStoreEntryWatcher : public QObject
{
Q_OBJECT
public:
explicit KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent = nullptr);
~KeyStoreEntryWatcher() override;
KeyStoreEntry entry() const;
Q_SIGNALS:
void available();
void unavailable();
private:
Q_DISABLE_COPY(KeyStoreEntryWatcher)
class Private;
friend class Private;
Private *d;
};
class QCA_EXPORT KeyStore : public QObject, public Algorithm
{
Q_OBJECT
public:
enum Type
{
System,
User,
Application,
SmartCard,
PGPKeyring
};
KeyStore(const QString &id, KeyStoreManager *keyStoreManager);
~KeyStore() override;
bool isValid() const;
Type type() const;
QString name() const;
QString id() const;
bool isReadOnly() const;
void startAsynchronousMode();
QList<KeyStoreEntry> entryList() const;
bool holdsTrustedCertificates() const;
bool holdsIdentities() const;
bool holdsPGPPublicKeys() const;
QString writeEntry(const KeyBundle &kb);
QString writeEntry(const Certificate &cert);
QString writeEntry(const CRL &crl);
QString writeEntry(const PGPKey &key);
bool removeEntry(const QString &id);
Q_SIGNALS:
void updated();
void unavailable();
void entryWritten(const QString &entryId);
void entryRemoved(bool success);
private:
Q_DISABLE_COPY(KeyStore)
friend class KeyStorePrivate;
KeyStorePrivate *d;
friend class KeyStoreManagerPrivate;
};
class QCA_EXPORT KeyStoreInfo
{
public:
KeyStoreInfo();
KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name);
KeyStoreInfo(const KeyStoreInfo &from);
~KeyStoreInfo();
KeyStoreInfo &operator=(const KeyStoreInfo &from);
bool isNull() const;
KeyStore::Type type() const;
QString id() const;
QString name() const;
private:
class Private;
QSharedDataPointer<Private> d;
};
class QCA_EXPORT KeyStoreManager : public QObject
{
Q_OBJECT
public:
KeyStoreManager(QObject *parent = nullptr);
~KeyStoreManager() override;
static void start();
static void start(const QString &provider);
bool isBusy() const;
void waitForBusyFinished();
QStringList keyStores() const;
static QString diagnosticText();
static void clearDiagnosticText();
void sync();
Q_SIGNALS:
void busyStarted();
void busyFinished();
void keyStoreAvailable(const QString &id);
private:
Q_DISABLE_COPY(KeyStoreManager)
friend class KeyStoreManagerPrivate;
KeyStoreManagerPrivate *d;
friend class Global;
friend class KeyStorePrivate;
static void scan();
static void shutdown();
};
}
#endif
QCA::Algorithm::Algorithm
Algorithm(const Algorithm &from)
Standard copy constructor.
QCA::CRL
Certificate Revocation List
Definition qca_cert.h:1740
QCA::Certificate
Public Key (X.509) certificate.
Definition qca_cert.h:857
QCA::KeyBundle
Certificate chain and private key pair.
Definition qca_cert.h:2176
QCA::KeyStoreEntryWatcher::KeyStoreEntryWatcher
KeyStoreEntryWatcher(const KeyStoreEntry &e, QObject *parent=nullptr)
Standard constructor.
QCA::KeyStoreEntryWatcher::unavailable
void unavailable()
This signal is emitted when the entry that is being monitored becomes unavailble.
QCA::KeyStoreEntryWatcher::entry
KeyStoreEntry entry() const
The KeyStoreEntry that is being monitored.
QCA::KeyStoreEntryWatcher::available
void available()
This signal is emitted when the entry that is being monitored becomes available.
QCA::KeyStoreEntry
Single entry in a KeyStore.
Definition qca_keystore.h:141
QCA::KeyStoreEntry::KeyStoreEntry
KeyStoreEntry(const KeyStoreEntry &from)
Standard copy constructor.
QCA::KeyStoreEntry::KeyStoreEntry
KeyStoreEntry()
Create an empty KeyStoreEntry.
QCA::KeyStoreEntry::ensureAvailable
bool ensureAvailable()
Returns true if the entry is available, otherwise false.
QCA::KeyStoreEntry::Type
Type
The type of entry in the KeyStore.
Definition qca_keystore.h:147
QCA::KeyStoreEntry::toString
QString toString() const
Serialize into a string for use as a passive entry.
QCA::KeyStoreEntry::crl
CRL crl() const
If a CRL is stored in this object, return the value of the CRL.
QCA::KeyStoreEntry::isAccessible
bool isAccessible() const
Test if the key is currently accessible.
QCA::KeyStoreEntry::type
Type type() const
Determine the type of key stored in this object.
QCA::KeyStoreEntry::isAvailable
bool isAvailable() const
Test if the key is available for use.
QCA::KeyStoreEntry::keyBundle
KeyBundle keyBundle() const
If a KeyBundle is stored in this object, return that bundle.
QCA::KeyStoreEntry::certificate
Certificate certificate() const
If a Certificate is stored in this object, return that certificate.
QCA::KeyStoreEntry::fromString
static KeyStoreEntry fromString(const QString &serialized)
Load a passive entry by using a serialized string as input.
QCA::KeyStoreEntry::name
QString name() const
The name associated with the key stored in this object.
QCA::KeyStoreEntry::storeName
QString storeName() const
The name of the KeyStore for this key object.
QCA::KeyStoreEntry::KeyStoreEntry
KeyStoreEntry(const QString &serialized)
Create a passive KeyStoreEntry based on a serialized string.
QCA::KeyStoreEntry::ensureAccess
bool ensureAccess()
Like ensureAvailable, but will also ensure that the PIN is provided if needed.
QCA::KeyStoreEntry::id
QString id() const
The ID associated with the key stored in this object.
QCA::KeyStoreEntry::pgpPublicKey
PGPKey pgpPublicKey() const
If the key stored in this object is either an public or private PGP key, extract the public key part ...
QCA::KeyStoreEntry::storeId
QString storeId() const
The id of the KeyStore for this key object.
QCA::KeyStoreEntry::pgpSecretKey
PGPKey pgpSecretKey() const
If the key stored in this object is a private PGP key, return the contents of that key.
QCA::KeyStoreEntry::isNull
bool isNull() const
Test if this key is empty (null).
QCA::KeyStoreEntry::operator=
KeyStoreEntry & operator=(const KeyStoreEntry &from)
Standard assignment operator.
QCA::KeyStoreInfo::KeyStoreInfo
KeyStoreInfo()
Constructor.
QCA::KeyStoreInfo::type
KeyStore::Type type() const
The Type of KeyStore that this KeyStoreInfo object describes.
QCA::KeyStoreInfo::name
QString name() const
The descriptive name of the KeyStore that this KeyStoreInfo object describes.
QCA::KeyStoreInfo::operator=
KeyStoreInfo & operator=(const KeyStoreInfo &from)
Assignment operator.
QCA::KeyStoreInfo::KeyStoreInfo
KeyStoreInfo(KeyStore::Type type, const QString &id, const QString &name)
Standard constructor.
QCA::KeyStoreInfo::KeyStoreInfo
KeyStoreInfo(const KeyStoreInfo &from)
Copy constructor.
QCA::KeyStoreInfo::isNull
bool isNull() const
Test if this object is valid.
QCA::KeyStoreInfo::id
QString id() const
The unique identification of the KeyStore that this KeyStoreInfo object describes.
QCA::KeyStoreManager
Access keystores, and monitor keystores for changes.
Definition qca_keystore.h:710
QCA::KeyStoreManager::keyStores
QStringList keyStores() const
A list of all the key stores.
QCA::KeyStoreManager::diagnosticText
static QString diagnosticText()
The diagnostic result of key store operations, such as warnings and errors.
QCA::KeyStoreManager::KeyStoreManager
KeyStoreManager(QObject *parent=nullptr)
Create a new KeyStoreManager.
QCA::KeyStoreManager::keyStoreAvailable
void keyStoreAvailable(const QString &id)
emitted when a new key store becomes available
QCA::KeyStoreManager::busyStarted
void busyStarted()
emitted when the manager has started looking for key stores
QCA::KeyStoreManager::isBusy
bool isBusy() const
Indicates if the manager is busy looking for key stores.
QCA::KeyStoreManager::clearDiagnosticText
static void clearDiagnosticText()
Clears the diagnostic result log.
QCA::KeyStoreManager::start
static void start(const QString &provider)
Initialize a specific key store provider.
QCA::KeyStoreManager::waitForBusyFinished
void waitForBusyFinished()
Blocks until the manager is done looking for key stores.
QCA::KeyStoreManager::sync
void sync()
If you are not using the eventloop, call this to update the object state to the present.
QCA::KeyStoreManager::busyFinished
void busyFinished()
emitted when the manager has finished looking for key stores
QCA::KeyStoreManager::start
static void start()
Initialize all key store providers.
QCA::KeyStore::entryRemoved
void entryRemoved(bool success)
Emitted when an entry has been removed, in asynchronous mode.
QCA::KeyStore::holdsPGPPublicKeys
bool holdsPGPPublicKeys() const
test if the KeyStore holds PGPPublicKey objects
QCA::KeyStore::writeEntry
QString writeEntry(const CRL &crl)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QCA::KeyStore::unavailable
void unavailable()
Emitted when the KeyStore becomes unavailable.
QCA::KeyStore::isValid
bool isValid() const
Check if this KeyStore is valid.
QCA::KeyStore::name
QString name() const
The name associated with the KeyStore.
QCA::KeyStore::writeEntry
QString writeEntry(const KeyBundle &kb)
Add a entry to the KeyStore.
QCA::KeyStore::entryWritten
void entryWritten(const QString &entryId)
Emitted when an entry has been written, in asynchronous mode.
QCA::KeyStore::id
QString id() const
The ID associated with the KeyStore.
QCA::KeyStore::holdsTrustedCertificates
bool holdsTrustedCertificates() const
test if the KeyStore holds trusted certificates (and CRLs)
QCA::KeyStore::updated
void updated()
Emitted when the KeyStore is changed.
QCA::KeyStore::entryList
QList< KeyStoreEntry > entryList() const
A list of the KeyStoreEntry objects in this store.
QCA::KeyStore::writeEntry
QString writeEntry(const PGPKey &key)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QCA::KeyStore::writeEntry
QString writeEntry(const Certificate &cert)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QCA::KeyStore::isReadOnly
bool isReadOnly() const
Test if the KeyStore is writeable or not.
QCA::KeyStore::KeyStore
KeyStore(const QString &id, KeyStoreManager *keyStoreManager)
Obtain a specific KeyStore.
QCA::KeyStore::removeEntry
bool removeEntry(const QString &id)
Delete the a specified KeyStoreEntry from this KeyStore.
QCA::KeyStore::type
Type type() const
The KeyStore Type.
QCA::KeyStore::startAsynchronousMode
void startAsynchronousMode()
Turns on asynchronous mode for this KeyStore instance.
QCA::KeyStore::Type
Type
The type of keystore.
Definition qca_keystore.h:424
QCA::KeyStore::User
@ User
objects such as Apple Keychain, KDE Wallet
Definition qca_keystore.h:426
QCA::KeyStore::System
@ System
objects such as root certificates
Definition qca_keystore.h:425
QCA::KeyStore::SmartCard
@ SmartCard
for smartcards
Definition qca_keystore.h:428
QCA::KeyStore::PGPKeyring
@ PGPKeyring
for a PGP keyring
Definition qca_keystore.h:429
QCA::KeyStore::Application
@ Application
for caching accepted self-signed certificates
Definition qca_keystore.h:427
QCA::KeyStore::holdsIdentities
bool holdsIdentities() const
test if the KeyStore holds identities (eg KeyBundle or PGPSecretKey)
QCA::PGPKey
Pretty Good Privacy key.
Definition qca_cert.h:2407
QList
QObject
QCA
QCA - the Qt Cryptographic Architecture.
Definition qca_basic.h:41
qca_cert.h
Header file for PGP key and X.509 certificate related classes.
qca_core.h
Header file for core QCA infrastructure.