2003-09-17 01:02:09 +00:00
|
|
|
/*
|
|
|
|
* qcaprovider.h - QCA Plugin API
|
2007-07-20 01:05:05 +00:00
|
|
|
* Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
|
2005-01-01 02:44:28 +00:00
|
|
|
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
|
2003-09-17 01:02:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
2007-01-02 05:10:11 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-09-17 01:02:09 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
\file qcaprovider.h
|
|
|
|
|
2007-07-31 04:11:42 +00:00
|
|
|
Header file for provider implementation classes (plugins)
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
\note You should not use this header directly from an
|
|
|
|
application. You should just use <tt> \#include \<QtCrypto>
|
|
|
|
</tt> instead.
|
|
|
|
*/
|
|
|
|
|
2003-07-02 03:34:11 +00:00
|
|
|
#ifndef QCAPROVIDER_H
|
|
|
|
#define QCAPROVIDER_H
|
|
|
|
|
2005-01-01 02:44:28 +00:00
|
|
|
#include "qca_core.h"
|
|
|
|
#include "qca_basic.h"
|
2005-03-03 21:56:23 +00:00
|
|
|
#include "qca_publickey.h"
|
2005-01-25 13:01:45 +00:00
|
|
|
#include "qca_cert.h"
|
2005-04-09 07:43:15 +00:00
|
|
|
#include "qca_keystore.h"
|
2005-04-22 12:46:55 +00:00
|
|
|
#include "qca_securelayer.h"
|
|
|
|
#include "qca_securemessage.h"
|
2003-07-02 03:34:11 +00:00
|
|
|
|
2004-11-09 08:02:13 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2007-08-04 12:00:23 +00:00
|
|
|
#ifndef DOXYGEN_NO_PROVIDER_API
|
|
|
|
|
2007-07-30 23:40:24 +00:00
|
|
|
/**
|
|
|
|
\defgroup ProviderAPI QCA provider API
|
|
|
|
|
2007-07-31 04:11:42 +00:00
|
|
|
This group of classes is not normally needed
|
2007-07-30 23:40:24 +00:00
|
|
|
by application writers, but can be used to extend QCA if
|
|
|
|
required
|
|
|
|
*/
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class QCAPlugin qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Provider plugin base class
|
|
|
|
|
|
|
|
QCA loads cryptographic provider plugins with QPluginLoader. The QObject
|
|
|
|
obtained when loading the plugin must implement the QCAPlugin interface.
|
|
|
|
This is done by inheriting QCAPlugin, and including
|
|
|
|
Q_INTERFACES(QCAPlugin) in your class declaration.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
\code
|
|
|
|
class MyPlugin : public QObject, public QCAPlugin
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(QCAPlugin)
|
|
|
|
public:
|
|
|
|
virtual Provider *createProvider() { ... }
|
|
|
|
};
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
There is only one function to reimplement, called createProvider(). This
|
|
|
|
function should return a newly allocated Provider instance.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2007-04-13 00:42:19 +00:00
|
|
|
class QCA_EXPORT QCAPlugin
|
2005-02-28 02:28:23 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Destructs the object
|
|
|
|
*/
|
2007-04-13 00:42:19 +00:00
|
|
|
virtual ~QCAPlugin() {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a newly allocated Provider instance.
|
|
|
|
*/
|
2005-02-28 02:28:23 +00:00
|
|
|
virtual QCA::Provider *createProvider() = 0;
|
|
|
|
};
|
|
|
|
|
2006-02-24 08:08:43 +00:00
|
|
|
Q_DECLARE_INTERFACE(QCAPlugin, "com.affinix.qca.Plugin/1.0")
|
|
|
|
|
2004-10-28 04:28:20 +00:00
|
|
|
namespace QCA {
|
|
|
|
|
2007-08-28 17:11:40 +00:00
|
|
|
/**
|
|
|
|
\class InfoContext qcaprovider.h QtCrypto
|
|
|
|
|
|
|
|
Extended provider information
|
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications.
|
|
|
|
|
|
|
|
\ingroup ProviderAPI
|
|
|
|
*/
|
|
|
|
class QCA_EXPORT InfoContext : public BasicContext
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
|
|
|
InfoContext(Provider *p) : BasicContext(p, "info") {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
The hash algorithms supported by the provider
|
|
|
|
*/
|
|
|
|
virtual QStringList supportedHashTypes() const;
|
2007-08-28 18:03:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The cipher algorithms supported by the provider
|
|
|
|
*/
|
|
|
|
virtual QStringList supportedCipherTypes() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The mac algorithms supported by the provider
|
|
|
|
*/
|
|
|
|
virtual QStringList supportedMACTypes() const;
|
2007-08-28 17:11:40 +00:00
|
|
|
};
|
|
|
|
|
2007-07-30 23:40:24 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class RandomContext qcaprovider.h QtCrypto
|
2007-07-30 23:40:24 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Random provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Random instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT RandomContext : public BasicContext
|
2004-10-28 04:28:20 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-28 04:28:20 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
RandomContext(Provider *p) : BasicContext(p, "random") {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return an array of random bytes
|
|
|
|
|
|
|
|
\param size the number of random bytes to return
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual SecureArray nextBytes(int size) = 0;
|
2004-10-28 04:28:20 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class HashContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Hash provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Hash instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT HashContext : public BasicContext
|
2004-10-28 04:28:20 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-28 04:28:20 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
HashContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Reset the object to its initial state
|
|
|
|
*/
|
2004-10-28 04:28:20 +00:00
|
|
|
virtual void clear() = 0;
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Process a chunk of data
|
|
|
|
|
|
|
|
\param a the input data to process
|
|
|
|
*/
|
2007-06-18 21:31:14 +00:00
|
|
|
virtual void update(const MemoryRegion &a) = 0;
|
2007-07-20 01:05:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return the computed hash
|
|
|
|
*/
|
2007-06-18 21:31:14 +00:00
|
|
|
virtual MemoryRegion final() = 0;
|
2004-10-28 04:28:20 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CipherContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Cipher provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Cipher instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT CipherContext : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
CipherContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Set up the object for encrypt/decrypt
|
|
|
|
*/
|
2005-03-02 08:04:56 +00:00
|
|
|
virtual void setup(Direction dir, const SymmetricKey &key, const InitializationVector &iv) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the KeyLength for this cipher
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual KeyLength keyLength() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the block size for this cipher
|
|
|
|
*/
|
2007-06-02 11:22:26 +00:00
|
|
|
virtual int blockSize() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Process a chunk of data. Returns true if successful.
|
|
|
|
|
|
|
|
\param in the input data to process
|
|
|
|
\param out pointer to an array that should store the result
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual bool update(const SecureArray &in, SecureArray *out) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finish the cipher processing. Returns true if successful.
|
|
|
|
|
|
|
|
\param out pointer to an array that should store the result
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual bool final(SecureArray *out) = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class MACContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Message authentication code provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want
|
|
|
|
MessageAuthenticationCode instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT MACContext : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
MACContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Set up the object for hashing
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual void setup(const SymmetricKey &key) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the KeyLength for this MAC algorithm
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual KeyLength keyLength() const = 0;
|
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Process a chunk of data
|
|
|
|
|
|
|
|
\param in the input data to process
|
|
|
|
*/
|
2007-06-18 21:31:14 +00:00
|
|
|
virtual void update(const MemoryRegion &in) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Compute the result after processing all data
|
|
|
|
|
|
|
|
\param out pointer to an array that should store the result
|
|
|
|
*/
|
2007-06-18 21:31:14 +00:00
|
|
|
virtual void final(MemoryRegion *out) = 0;
|
2005-03-01 10:21:21 +00:00
|
|
|
|
2004-11-09 08:02:13 +00:00
|
|
|
protected:
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Returns a KeyLength that supports any length
|
|
|
|
*/
|
2004-11-09 08:02:13 +00:00
|
|
|
KeyLength anyKeyLength() const
|
|
|
|
{
|
|
|
|
// this is used instead of a default implementation to make sure that
|
|
|
|
// provider authors think about it, at least a bit.
|
|
|
|
// See Meyers, Effective C++, Effective C++ (2nd Ed), Item 36
|
2005-07-06 21:37:45 +00:00
|
|
|
return KeyLength( 0, INT_MAX, 1 );
|
2004-11-09 08:02:13 +00:00
|
|
|
}
|
2005-03-01 10:21:21 +00:00
|
|
|
};
|
2004-11-09 08:02:13 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class KDFContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Key derivation function provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want KeyDerivationFunction
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT KDFContext : public BasicContext
|
2005-03-01 10:21:21 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-01 10:21:21 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Create a key and return it
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class DLGroupContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Discrete logarithm provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want DLGroup instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT DLGroupContext : public Provider::Context
|
2005-03-07 10:23:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
DLGroupContext(Provider *p) : Provider::Context(p, "dlgroup") {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
The DLGroupSets supported by this object
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual QList<DLGroupSet> supportedGroupSets() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if there is a result to obtain
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual bool isNull() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Attempt to create P, Q, and G values from the specified group set
|
|
|
|
|
|
|
|
If \a block is true, then this function blocks until completion.
|
|
|
|
Otherwise, this function returns immediately and finished() is
|
|
|
|
emitted when the operation completes.
|
|
|
|
|
|
|
|
If an error occurs during generation, then the operation will
|
|
|
|
complete and isNull() will return true.
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual void fetchGroup(DLGroupSet set, bool block) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Obtain the result of the operation. Ensure isNull() returns false
|
|
|
|
before calling this function.
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;
|
2005-03-07 10:23:45 +00:00
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Emitted when the fetchGroup() operation completes in non-blocking
|
|
|
|
mode.
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
void finished();
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class PKeyBase qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Public key implementation provider base
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want PKey, PublicKey, or
|
|
|
|
PrivateKey instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT PKeyBase : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-03-03 21:56:23 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
PKeyBase(Provider *p, const QString &type);
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Returns true if this object is not valid. This is the default
|
|
|
|
state, and the object may also become this state if a conversion
|
|
|
|
or generation function fails.
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual bool isNull() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the type of public key
|
|
|
|
*/
|
2005-04-12 10:25:35 +00:00
|
|
|
virtual PKey::Type type() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if this is a private key, otherwise false
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual bool isPrivate() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the components of this key are accessible and
|
|
|
|
whether it can be serialized into an output format. Private keys
|
|
|
|
from a smart card device will often not be exportable.
|
|
|
|
*/
|
2005-04-12 10:25:35 +00:00
|
|
|
virtual bool canExport() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
If the key is a private key, this function will convert it into a
|
|
|
|
public key (all private key data includes the public data as well,
|
|
|
|
which is why this is possible). If the key is already a public
|
|
|
|
key, then this function has no effect.
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual void convertToPublic() = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of bits in the key
|
|
|
|
*/
|
2005-04-04 00:34:13 +00:00
|
|
|
virtual int bits() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Returns the maximum number of bytes that can be encrypted by this
|
|
|
|
key
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Encrypt data
|
|
|
|
|
|
|
|
\param in the input data to encrypt
|
|
|
|
\param alg the encryption algorithm to use
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Decrypt data
|
|
|
|
|
|
|
|
\param in the input data to decrypt
|
|
|
|
\param out pointer to an array to store the plaintext result
|
|
|
|
\param alg the encryption algorithm used to generate the input
|
|
|
|
data
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Begin a signing operation
|
|
|
|
|
|
|
|
\param alg the signature algorithm to use
|
|
|
|
\param format the signature format to use
|
|
|
|
*/
|
2005-03-05 20:50:49 +00:00
|
|
|
virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Begin a verify operation
|
|
|
|
|
|
|
|
\param alg the signature algorithm used by the input signature
|
|
|
|
\param format the signature format used by the input signature
|
|
|
|
*/
|
2005-03-05 20:50:49 +00:00
|
|
|
virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Process the plaintext input data for either signing or verifying,
|
|
|
|
whichever operation is active.
|
|
|
|
|
|
|
|
\param in the input data to process
|
|
|
|
*/
|
2007-06-18 21:31:14 +00:00
|
|
|
virtual void update(const MemoryRegion &in);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Complete a signing operation, and return the signature value
|
|
|
|
|
|
|
|
If there is an error signing, an empty array is returned.
|
|
|
|
*/
|
2007-06-12 23:49:25 +00:00
|
|
|
virtual QByteArray endSign();
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Complete a verify operation, and return true if successful
|
|
|
|
|
|
|
|
If there is an error verifying, this function returns false.
|
|
|
|
|
|
|
|
\param sig the signature to verify with the input data
|
|
|
|
*/
|
2007-06-12 23:49:25 +00:00
|
|
|
virtual bool endVerify(const QByteArray &sig);
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Compute a symmetric key based on this private key and some other
|
|
|
|
public key
|
|
|
|
|
|
|
|
Essentially for Diffie-Hellman only.
|
|
|
|
*/
|
2006-03-31 09:13:50 +00:00
|
|
|
virtual SymmetricKey deriveKey(const PKeyBase &theirs);
|
2005-03-03 21:56:23 +00:00
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Emitted when an asynchronous operation completes on this key.
|
|
|
|
Such operations will be documented that they emit this signal.
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
void finished();
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class RSAContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
RSA provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want RSAPublicKey or
|
|
|
|
RSAPrivateKey instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT RSAContext : public PKeyBase
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-03-03 21:56:23 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
RSAContext(Provider *p) : PKeyBase(p, "rsa") {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Generate an RSA private key
|
|
|
|
|
|
|
|
If \a block is true, then this function blocks until completion.
|
|
|
|
Otherwise, this function returns immediately and finished() is
|
|
|
|
emitted when the operation completes.
|
|
|
|
|
|
|
|
If an error occurs during generation, then the operation will
|
|
|
|
complete and isNull() will return true.
|
|
|
|
|
|
|
|
\param bits the length of the key to generate, in bits
|
|
|
|
\param exp the exponent to use for generation
|
|
|
|
\param block whether to use blocking mode
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual void createPrivate(int bits, int exp, bool block) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create an RSA private key based on the five components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create an RSA public key based on the two public components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public N component of this RSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger n() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public E component of this RSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger e() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the private P component of this RSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger p() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the private Q component of this RSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger q() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the private D component of this RSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger d() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class DSAContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
DSA provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want DSAPublicKey or
|
|
|
|
DSAPrivateKey instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT DSAContext : public PKeyBase
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-03-03 21:56:23 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
DSAContext(Provider *p) : PKeyBase(p, "dsa") {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Generate a DSA private key
|
|
|
|
|
|
|
|
If \a block is true, then this function blocks until completion.
|
|
|
|
Otherwise, this function returns immediately and finished() is
|
|
|
|
emitted when the operation completes.
|
|
|
|
|
|
|
|
If an error occurs during generation, then the operation will
|
|
|
|
complete and isNull() will return true.
|
|
|
|
|
|
|
|
\param domain the domain values to use for generation
|
|
|
|
\param block whether to use blocking mode
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual void createPrivate(const DLGroup &domain, bool block) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a DSA private key based on its numeric components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a DSA public key based on its numeric components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public domain component of this DSA key
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual DLGroup domain() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public Y component of this DSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger y() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the private X component of this DSA key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger x() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class DHContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Diffie-Hellman provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want DHPublicKey or
|
|
|
|
DHPrivateKey instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT DHContext : public PKeyBase
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-03-03 21:56:23 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
DHContext(Provider *p) : PKeyBase(p, "dh") {}
|
2007-07-20 01:05:05 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Generate a Diffie-Hellman private key
|
|
|
|
|
|
|
|
If \a block is true, then this function blocks until completion.
|
|
|
|
Otherwise, this function returns immediately and finished() is
|
|
|
|
emitted when the operation completes.
|
|
|
|
|
|
|
|
If an error occurs during generation, then the operation will
|
|
|
|
complete and isNull() will return true.
|
|
|
|
|
|
|
|
\param domain the domain values to use for generation
|
|
|
|
\param block whether to use blocking mode
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual void createPrivate(const DLGroup &domain, bool block) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a Diffie-Hellman private key based on its numeric
|
|
|
|
components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a Diffie-Hellman public key based on its numeric
|
|
|
|
components
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public domain component of this Diffie-Hellman key
|
|
|
|
*/
|
2005-03-07 10:23:45 +00:00
|
|
|
virtual DLGroup domain() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the public Y component of this Diffie-Hellman key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger y() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the private X component of this Diffie-Hellman key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual BigInteger x() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class PKeyContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
Public key container provider
|
2007-07-27 02:28:52 +00:00
|
|
|
|
2007-07-28 00:04:02 +00:00
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want PKey, PublicKey, or
|
|
|
|
PrivateKey instead.
|
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
This object "holds" a public key object. By default it contains no key
|
|
|
|
(key() returns 0), but you can put a key into it with setKey(), or you
|
|
|
|
can call an import function such as publicFromDER().
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT PKeyContext : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
PKeyContext(Provider *p) : BasicContext(p, "pkey") {}
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Returns a list of supported public key types
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual QList<PKey::Type> supportedTypes() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a list of public key types that can be serialized and
|
|
|
|
deserialized into DER and PEM format
|
|
|
|
*/
|
2005-03-08 03:17:37 +00:00
|
|
|
virtual QList<PKey::Type> supportedIOTypes() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a list of password-based encryption algorithms that are
|
|
|
|
supported for private key serialization and deserialization
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual QList<PBEAlgorithm> supportedPBEAlgorithms() const = 0;
|
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Returns the key held by this object, or 0 if there is no key
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual PKeyBase *key() = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the key held by this object, or 0 if there is no key
|
|
|
|
*/
|
2005-03-03 21:56:23 +00:00
|
|
|
virtual const PKeyBase *key() const = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the key for this object. If this object already had a key,
|
|
|
|
then the old one is destructed. This object takes ownership of
|
|
|
|
the key.
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual void setKey(PKeyBase *key) = 0;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Attempt to import a key from another provider. Returns true if
|
|
|
|
successful, otherwise false.
|
|
|
|
|
|
|
|
Generally this function is used if the specified key's provider
|
|
|
|
does not support serialization, but your provider does. The call
|
|
|
|
to this function would then be followed by an export function,
|
|
|
|
such as publicToDER().
|
|
|
|
*/
|
2005-04-12 10:25:35 +00:00
|
|
|
virtual bool importKey(const PKeyBase *key) = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
/**
|
|
|
|
Convert a public key to DER format, and return the value
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
Returns an empty array on error.
|
2007-07-27 02:28:52 +00:00
|
|
|
*/
|
2007-06-12 23:49:25 +00:00
|
|
|
virtual QByteArray publicToDER() const;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert a public key to PEM format, and return the value
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
Returns an empty string on error.
|
2007-07-27 02:28:52 +00:00
|
|
|
*/
|
2006-11-13 01:44:41 +00:00
|
|
|
virtual QString publicToPEM() const;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read DER-formatted input and convert it into a public key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param a the input data
|
|
|
|
*/
|
2007-06-12 23:49:25 +00:00
|
|
|
virtual ConvertResult publicFromDER(const QByteArray &a);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read PEM-formatted input and convert it into a public key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param s the input data
|
|
|
|
*/
|
2006-11-13 01:44:41 +00:00
|
|
|
virtual ConvertResult publicFromPEM(const QString &s);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert a private key to DER format, and return the value
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
Returns an empty array on error.
|
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
\param passphrase the passphrase to encode the result with, or an
|
|
|
|
empty array if no encryption is desired
|
|
|
|
\param pbe the encryption algorithm to use, if applicable
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert a private key to PEM format, and return the value
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
Returns an empty string on error.
|
|
|
|
|
2007-07-27 02:28:52 +00:00
|
|
|
\param passphrase the passphrase to encode the result with, or an
|
|
|
|
empty array if no encryption is desired
|
|
|
|
\param pbe the encryption algorithm to use, if applicable
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read DER-formatted input and convert it into a private key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param a the input data
|
|
|
|
\param passphrase the passphrase needed to decrypt, if applicable
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);
|
2007-07-27 02:28:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read PEM-formatted input and convert it into a private key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param s the input data
|
|
|
|
\param passphrase the passphrase needed to decrypt, if applicable
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CertBase qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate and certificate request provider base
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Certificate,
|
|
|
|
CertificateRequest, or CRL instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT CertBase : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Convert this object to DER format, and return the value
|
|
|
|
|
|
|
|
Returns an empty array on error.
|
|
|
|
*/
|
2007-06-12 02:30:58 +00:00
|
|
|
virtual QByteArray toDER() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert this object to PEM format, and return the value
|
|
|
|
|
|
|
|
Returns an empty string on error.
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual QString toPEM() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read DER-formatted input and convert it into this object
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param a the input data
|
|
|
|
*/
|
2007-06-12 02:30:58 +00:00
|
|
|
virtual ConvertResult fromDER(const QByteArray &a) = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read PEM-formatted input and convert it into this object
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param s the input data
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual ConvertResult fromPEM(const QString &s) = 0;
|
|
|
|
};
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CertContextProps qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
X.509 certificate or certificate request properties
|
|
|
|
|
2007-07-28 00:04:02 +00:00
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Certificate or
|
|
|
|
CertificateRequest instead.
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
Some fields are only for certificates or only for certificate requests,
|
|
|
|
and these fields are noted.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-27 23:17:01 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT CertContextProps
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
The X.509 certificate version, usually 3
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
int version;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The time the certificate becomes valid (often the time of create)
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QDateTime start;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The time the certificate expires
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QDateTime end;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The subject information
|
|
|
|
*/
|
2006-11-15 05:21:41 +00:00
|
|
|
CertificateInfoOrdered subject;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The issuer information
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
CertificateInfoOrdered issuer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The constraints
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
Constraints constraints;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The policies
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
QStringList policies;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
A list of URIs for CRLs
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QStringList crlLocations;
|
|
|
|
|
|
|
|
/**
|
|
|
|
A list of URIs for issuer certificates
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QStringList issuerLocations;
|
|
|
|
|
|
|
|
/**
|
|
|
|
A list of URIs for OCSP services
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QStringList ocspLocations;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The certificate serial number
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
BigInteger serial;
|
|
|
|
|
|
|
|
/**
|
|
|
|
True if the certificate is a CA or the certificate request is
|
|
|
|
requesting to be a CA, otherwise false
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
bool isCA;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
True if the certificate is self-signed
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
bool isSelfSigned;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The path limit
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
int pathLimit;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature data
|
|
|
|
*/
|
2007-06-12 02:30:58 +00:00
|
|
|
QByteArray sig;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature algorithm used to create the signature
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
SignatureAlgorithm sigalgo;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The subject id
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QByteArray subjectId;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The issuer id
|
|
|
|
|
|
|
|
This field is for certificates only.
|
|
|
|
*/
|
|
|
|
QByteArray issuerId;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The SPKAC challenge value
|
|
|
|
|
|
|
|
This field is for certificate requests only.
|
|
|
|
*/
|
|
|
|
QString challenge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The format used for the certificate request
|
|
|
|
|
|
|
|
This field is for certificate requests only.
|
|
|
|
*/
|
|
|
|
CertificateRequestFormat format;
|
2005-03-04 21:50:57 +00:00
|
|
|
};
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CRLContextProps qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
X.509 certificate revocation list properties
|
|
|
|
|
2007-07-28 00:04:02 +00:00
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want CRL instead.
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
For efficiency and simplicity, the members are directly accessed.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-27 23:17:01 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT CRLContextProps
|
2005-03-04 21:50:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
The issuer information of the CRL
|
|
|
|
*/
|
2006-11-15 05:21:41 +00:00
|
|
|
CertificateInfoOrdered issuer;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The CRL number, which increases at each update
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
int number;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The time this CRL was created
|
|
|
|
*/
|
|
|
|
QDateTime thisUpdate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The time this CRL expires, and the next CRL should be fetched
|
|
|
|
*/
|
|
|
|
QDateTime nextUpdate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The revoked entries
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
QList<CRLEntry> revoked;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature data of the CRL
|
|
|
|
*/
|
2007-06-12 02:30:58 +00:00
|
|
|
QByteArray sig;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The signature algorithm used by the issuer to sign the CRL
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
SignatureAlgorithm sigalgo;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The issuer id
|
|
|
|
*/
|
2005-04-04 03:20:20 +00:00
|
|
|
QByteArray issuerId;
|
2005-03-04 21:50:57 +00:00
|
|
|
};
|
|
|
|
|
2005-03-28 07:11:58 +00:00
|
|
|
class CRLContext;
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CertContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want Certificate instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT CertContext : public CertBase
|
2005-03-04 21:50:57 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-04 21:50:57 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
CertContext(Provider *p) : CertBase(p, "cert") {}
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Create a self-signed certificate based on the given options and
|
|
|
|
private key. Returns true if successful, otherwise false.
|
|
|
|
|
|
|
|
If successful, this object becomes the self-signed certificate.
|
|
|
|
If unsuccessful, this object is considered to be in an
|
|
|
|
uninitialized state.
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual bool createSelfSigned(const CertificateOptions &opts, const PKeyContext &priv) = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the properties of this certificate
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual const CertContextProps *props() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if this certificate is equal to another certificate,
|
|
|
|
otherwise false
|
|
|
|
|
|
|
|
\param other the certificate to compare with
|
|
|
|
*/
|
2007-06-08 21:57:32 +00:00
|
|
|
virtual bool compare(const CertContext *other) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a copy of this certificate's public key. The caller is
|
|
|
|
responsible for deleting it.
|
|
|
|
*/
|
|
|
|
virtual PKeyContext *subjectPublicKey() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if this certificate is an issuer of another
|
|
|
|
certificate, otherwise false
|
|
|
|
|
|
|
|
\param other the issued certificate to check
|
|
|
|
*/
|
2006-03-30 07:25:14 +00:00
|
|
|
virtual bool isIssuerOf(const CertContext *other) const = 0;
|
2005-03-28 07:11:58 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Validate this certificate
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
|
|
|
|
\param trusted list of trusted certificates
|
|
|
|
\param untrusted list of untrusted certificates (can be empty)
|
|
|
|
\param crls list of CRLs (can be empty)
|
|
|
|
\param u the desired usage for this certificate
|
|
|
|
\param vf validation options
|
|
|
|
*/
|
2007-06-28 18:53:41 +00:00
|
|
|
virtual Validity validate(const QList<CertContext*> &trusted, const QList<CertContext*> &untrusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Validate a certificate chain. This function makes no use of the
|
|
|
|
certificate represented by this object, and it can be used even
|
|
|
|
if this object is in an uninitialized state.
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
|
|
|
|
\param chain list of certificates in the chain, starting with the
|
|
|
|
user certificate. It is not necessary for the chain to contain
|
|
|
|
the final root certificate.
|
|
|
|
\param trusted list of trusted certificates
|
|
|
|
\param crls list of CRLs (can be empty)
|
|
|
|
\param u the desired usage for the user certificate in the chain
|
|
|
|
\param vf validation options
|
|
|
|
*/
|
2007-06-28 18:53:41 +00:00
|
|
|
virtual Validity validate_chain(const QList<CertContext*> &chain, const QList<CertContext*> &trusted, const QList<CRLContext*> &crls, UsageMode u, ValidateFlags vf) const = 0;
|
2005-03-04 21:50:57 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CSRContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate request provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want CertificateRequest
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT CSRContext : public CertBase
|
2005-03-04 21:50:57 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-04 21:50:57 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
CSRContext(Provider *p) : CertBase(p, "csr") {}
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Returns true if the provider of this object supports the specified
|
|
|
|
format, otherwise false
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual bool canUseFormat(CertificateRequestFormat f) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a certificate request based on the given options and
|
|
|
|
private key. Returns true if successful, otherwise false.
|
|
|
|
|
|
|
|
If successful, this object becomes the certificate request.
|
|
|
|
If unsuccessful, this object is considered to be in an
|
|
|
|
uninitialized state.
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual bool createRequest(const CertificateOptions &opts, const PKeyContext &priv) = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the properties of this certificate request
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual const CertContextProps *props() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if this certificate request is equal to another
|
|
|
|
certificate request, otherwise false
|
|
|
|
|
|
|
|
\param other the certificate request to compare with
|
|
|
|
*/
|
2007-06-08 21:57:32 +00:00
|
|
|
virtual bool compare(const CSRContext *other) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a copy of this certificate request's public key. The
|
|
|
|
caller is responsible for deleting it.
|
|
|
|
*/
|
|
|
|
virtual PKeyContext *subjectPublicKey() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Convert this certificate request to Netscape SPKAC format, and
|
|
|
|
return the value
|
|
|
|
|
|
|
|
Returns an empty string on error.
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual QString toSPKAC() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read Netscape SPKAC input and convert it into a certificate
|
|
|
|
request
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param s the input data
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual ConvertResult fromSPKAC(const QString &s) = 0;
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CRLContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate revocation list provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want CRL instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-06-25 02:48:53 +00:00
|
|
|
class QCA_EXPORT CRLContext : public CertBase
|
2005-03-04 21:50:57 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-04 21:50:57 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
CRLContext(Provider *p) : CertBase(p, "crl") {}
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Returns a pointer to the properties of this CRL
|
|
|
|
*/
|
2005-03-04 21:50:57 +00:00
|
|
|
virtual const CRLContextProps *props() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if this CRL is equal to another CRL, otherwise false
|
|
|
|
|
|
|
|
\param other the CRL to compare with
|
|
|
|
*/
|
2007-06-08 21:57:32 +00:00
|
|
|
virtual bool compare(const CRLContext *other) const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CertCollectionContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate collection provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want CertificateCollection
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT CertCollectionContext : public BasicContext
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
CertCollectionContext(Provider *p) : BasicContext(p, "certcollection") {}
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Create PKCS#7 DER output based on the input certificates and CRLs
|
|
|
|
|
|
|
|
Returns an empty array on error.
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
virtual QByteArray toPKCS7(const QList<CertContext*> &certs, const QList<CRLContext*> &crls) const = 0;
|
2005-03-04 23:54:03 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Read PKCS#7 DER input and convert it into a list of certificates
|
|
|
|
and CRLs
|
|
|
|
|
|
|
|
The caller is responsible for deleting the returned items.
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param a the input data
|
|
|
|
\param certs the destination list for the certificates
|
|
|
|
\param crls the destination list for the CRLs
|
|
|
|
*/
|
2005-03-28 07:11:58 +00:00
|
|
|
virtual ConvertResult fromPKCS7(const QByteArray &a, QList<CertContext*> *certs, QList<CRLContext*> *crls) const = 0;
|
2004-10-31 10:04:44 +00:00
|
|
|
};
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class CAContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
X.509 certificate authority provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want CertificateAuthority
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT CAContext : public BasicContext
|
2005-03-05 01:10:14 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-05 01:10:14 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
CAContext(Provider *p) : BasicContext(p, "ca") {}
|
2005-03-05 01:10:14 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Prepare the object for usage
|
|
|
|
|
|
|
|
This must be called before any CA operations are performed.
|
|
|
|
|
|
|
|
\param cert the certificate of the CA
|
|
|
|
\param priv the private key of the CA
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual void setup(const CertContext &cert, const PKeyContext &priv) = 0;
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Returns a copy of the CA's certificate. The caller is responsible
|
|
|
|
for deleting it.
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual CertContext *certificate() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Issue a certificate based on a certificate request, and return
|
|
|
|
the certificate. The caller is responsible for deleting it.
|
|
|
|
|
|
|
|
\param req the certificate request
|
|
|
|
\param notValidAfter the expiration date
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual CertContext *signRequest(const CSRContext &req, const QDateTime ¬ValidAfter) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Issue a certificate based on a public key and options, and return
|
|
|
|
the certificate. The caller is responsible for deleting it.
|
|
|
|
|
|
|
|
\param pub the public key of the certificate
|
|
|
|
\param opts the options to use for generation
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual CertContext *createCertificate(const PKeyContext &pub, const CertificateOptions &opts) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a new CRL and return it. The caller is responsible for
|
|
|
|
deleting it.
|
|
|
|
|
|
|
|
The CRL has no entries in it.
|
|
|
|
|
|
|
|
\param nextUpdate the expiration date of the CRL
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual CRLContext *createCRL(const QDateTime &nextUpdate) const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Update an existing CRL, by examining an old one and creating a new
|
|
|
|
one based on it. The new CRL is returned, and the caller is
|
|
|
|
responsible for deleting it.
|
|
|
|
|
|
|
|
\param crl an existing CRL issued by this CA
|
|
|
|
\param entries the list of revoked entries
|
|
|
|
\param nextUpdate the expiration date of the new CRL
|
|
|
|
*/
|
2005-03-05 01:10:14 +00:00
|
|
|
virtual CRLContext *updateCRL(const CRLContext &crl, const QList<CRLEntry> &entries, const QDateTime &nextUpdate) const = 0;
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class PKCS12Context qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
PKCS#12 provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want KeyBundle instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT PKCS12Context : public BasicContext
|
2005-03-05 01:10:14 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-03-05 01:10:14 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
PKCS12Context(Provider *p) : BasicContext(p, "pkcs12") {}
|
2005-03-05 01:10:14 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Create PKCS#12 DER output based on a set of input items
|
|
|
|
|
|
|
|
Returns an empty array on error.
|
|
|
|
|
|
|
|
\param name the friendly name of the data
|
|
|
|
\param chain the certificate chain to store
|
|
|
|
\param priv the private key to store
|
|
|
|
\param passphrase the passphrase to encrypt the PKCS#12 data with
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;
|
2005-03-05 01:10:14 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Read PKCS#12 DER input and convert it into a set of output items
|
|
|
|
|
|
|
|
The caller is responsible for deleting the returned items.
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param in the input data
|
|
|
|
\param passphrase the passphrase needed to decrypt the input data
|
|
|
|
\param name the destination string for the friendly name
|
|
|
|
\param chain the destination list for the certificate chain
|
|
|
|
\param priv address of a pointer to accept the private key
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
|
2005-03-05 01:10:14 +00:00
|
|
|
};
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class PGPKeyContextProps qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
OpenPGP key properties
|
|
|
|
|
2007-07-28 00:04:02 +00:00
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want PGPKey instead.
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
For efficiency and simplicity, the members are directly accessed.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-27 23:17:01 +00:00
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
class QCA_EXPORT PGPKeyContextProps
|
|
|
|
{
|
|
|
|
public:
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
The key id
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
QString keyId;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
List of user id strings for the key, the first one being the
|
|
|
|
primary user id
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
QStringList userIds;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
True if this key is a secret key, otherwise false
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
bool isSecret;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The time the key was created
|
|
|
|
*/
|
|
|
|
QDateTime creationDate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The time the key expires
|
|
|
|
*/
|
|
|
|
QDateTime expirationDate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The hex fingerprint of the key
|
|
|
|
|
|
|
|
The format is all lowercase with no spaces.
|
|
|
|
*/
|
|
|
|
QString fingerprint;
|
|
|
|
|
|
|
|
/**
|
|
|
|
True if this key is in a keyring (and thus usable), otherwise
|
|
|
|
false
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
bool inKeyring;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
True if this key is trusted (e.g. signed by the keyring owner or
|
|
|
|
via some web-of-trust), otherwise false
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
bool isTrusted;
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class PGPKeyContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
OpenPGP key provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want PGPKey instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT PGPKeyContext : public BasicContext
|
2005-06-25 02:48:53 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-06-25 02:48:53 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
PGPKeyContext(Provider *p) : BasicContext(p, "pgpkey") {}
|
2005-06-25 02:48:53 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Returns a pointer to the properties of this key
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
virtual const PGPKeyContextProps *props() const = 0;
|
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Convert the key to binary format, and return the value
|
|
|
|
*/
|
2007-06-13 00:34:06 +00:00
|
|
|
virtual QByteArray toBinary() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Convert the key to ascii-armored format, and return the value
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
virtual QString toAscii() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read binary input and convert it into a key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param a the input data
|
|
|
|
*/
|
2007-06-13 00:34:06 +00:00
|
|
|
virtual ConvertResult fromBinary(const QByteArray &a) = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Read ascii-armored input and convert it into a key
|
|
|
|
|
|
|
|
Returns QCA::ConvertGood if successful, otherwise some error
|
|
|
|
value.
|
|
|
|
|
|
|
|
\param s the input data
|
|
|
|
*/
|
2005-07-06 22:27:02 +00:00
|
|
|
virtual ConvertResult fromAscii(const QString &s) = 0;
|
2005-06-25 02:48:53 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class KeyStoreEntryContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
KeyStoreEntry provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want KeyStoreEntry
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT KeyStoreEntryContext : public BasicContext
|
2005-03-28 07:11:58 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-04-09 07:43:15 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
KeyStoreEntryContext(Provider *p) : BasicContext(p, "keystoreentry") {}
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Returns the entry type
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual KeyStoreEntry::Type type() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the entry id
|
|
|
|
|
|
|
|
This id must be unique among all other entries in the same store.
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual QString id() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the name of this entry
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual QString name() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the id of the store that contains this entry
|
|
|
|
*/
|
2006-03-21 07:55:54 +00:00
|
|
|
virtual QString storeId() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the name of the store that contains this entry
|
|
|
|
*/
|
2006-03-21 07:55:54 +00:00
|
|
|
virtual QString storeName() const = 0;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the private key of this entry is present for use
|
|
|
|
*/
|
2007-06-19 02:36:21 +00:00
|
|
|
virtual bool isAvailable() const;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Serialize the information about this entry
|
|
|
|
|
|
|
|
This allows the entry object to be restored later, even if the
|
|
|
|
store that contains it is not present.
|
|
|
|
|
|
|
|
\sa KeyStoreListContext::entryPassive()
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual QString serialize() const = 0;
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
If this entry is of type KeyStoreEntry::TypeKeyBundle, this
|
|
|
|
function returns the KeyBundle of the entry
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual KeyBundle keyBundle() const;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
If this entry is of type KeyStoreEntry::TypeCertificate, this
|
|
|
|
function returns the Certificate of the entry
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual Certificate certificate() const;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
If this entry is of type KeyStoreEntry::TypeCRL, this function
|
|
|
|
returns the CRL of the entry
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual CRL crl() const;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
If this entry is of type KeyStoreEntry::TypePGPSecretKey, this
|
|
|
|
function returns the secret PGPKey of the entry
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual PGPKey pgpSecretKey() const;
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
If this entry is of type KeyStoreEntry::TypePGPPublicKey or
|
|
|
|
KeyStoreEntry::TypePGPSecretKey, this function returns the public
|
|
|
|
PGPKey of the entry
|
|
|
|
*/
|
2005-04-09 07:43:15 +00:00
|
|
|
virtual PGPKey pgpPublicKey() const;
|
2006-03-30 09:11:00 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Attempt to ensure the private key of this entry is usable and
|
|
|
|
accessible, potentially prompting the user and/or performing a
|
|
|
|
login to a token device. Returns true if the entry is now
|
|
|
|
accessible, or false if the entry cannot be made accessible.
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
*/
|
2006-03-30 09:11:00 +00:00
|
|
|
virtual bool ensureAccess();
|
2005-04-09 07:43:15 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class KeyStoreListContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
KeyStore provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want KeyStore instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT KeyStoreListContext : public Provider::Context
|
2005-04-09 07:43:15 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2005-03-28 07:11:58 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
KeyStoreListContext(Provider *p) : Provider::Context(p, "keystorelist") {}
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Starts the keystore provider
|
|
|
|
*/
|
2006-03-30 09:11:00 +00:00
|
|
|
virtual void start();
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Enables or disables update events
|
|
|
|
|
|
|
|
The updated() and storeUpdated() signals might not be emitted if
|
|
|
|
updates are not enabled.
|
|
|
|
*/
|
2006-03-30 09:11:00 +00:00
|
|
|
virtual void setUpdatesEnabled(bool enabled);
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns a list of integer context ids, each representing a
|
|
|
|
keystore instance
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
If a keystore becomes unavailable and then later becomes
|
|
|
|
available again (for example, if a smart card is removed and
|
|
|
|
then the same one is inserted again), the integer context id
|
|
|
|
must be different than last time.
|
|
|
|
*/
|
|
|
|
virtual QList<int> keyStores() = 0;
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the type of the specified store, or -1 if the integer
|
|
|
|
context id is invalid
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual KeyStore::Type type(int id) const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string id of the store, or an empty string if the
|
|
|
|
integer context id is invalid
|
|
|
|
|
|
|
|
The string id of the store should be unique to a single store, and
|
|
|
|
it should persist between availability/unavailability. For
|
|
|
|
example, a smart card that is removed and inserted again should
|
|
|
|
have the same string id (despite having a new integer context id).
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual QString storeId(int id) const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the friendly name of the store, or an empty string if the
|
|
|
|
integer context id is invalid
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual QString name(int id) const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the store is read-only
|
|
|
|
|
|
|
|
If the integer context id is invalid, this function should return
|
|
|
|
true.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual bool isReadOnly(int id) const;
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the types supported by the store, or an empty list if the
|
|
|
|
integer context id is invalid
|
|
|
|
|
|
|
|
This function should return all supported types, even if the store
|
|
|
|
doesn't actually contain entries for all of the types.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual QList<KeyStoreEntry::Type> entryTypes(int id) const = 0;
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the entries of the store, or an empty list if the integer
|
|
|
|
context id is invalid
|
2006-03-21 07:55:54 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
The caller is responsible for deleting the returned entry objects.
|
|
|
|
*/
|
2006-03-30 09:11:00 +00:00
|
|
|
virtual QList<KeyStoreEntryContext*> entryList(int id) = 0;
|
2005-03-28 07:11:58 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns a single entry in the store, if the entry id is already
|
|
|
|
known. If the entry does not exist, the function returns 0.
|
|
|
|
|
|
|
|
The caller is responsible for deleting the returned entry object.
|
|
|
|
*/
|
2006-03-30 09:11:00 +00:00
|
|
|
virtual KeyStoreEntryContext *entry(int id, const QString &entryId);
|
2006-03-21 07:55:54 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns a single entry, created from the serialization string of
|
|
|
|
a previous entry (using KeyStoreEntryContext::serialize()). If
|
|
|
|
the serialization string cannot be parsed by this provider, or the
|
|
|
|
entry cannot otherwise be created, the function returns 0.
|
|
|
|
|
|
|
|
The caller is responsible for deleting the returned entry object.
|
|
|
|
|
|
|
|
This function must be thread-safe.
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual KeyStoreEntryContext *entryPassive(const QString &serialized);
|
2006-03-21 07:55:54 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Write a KeyBundle to the store
|
|
|
|
|
|
|
|
Returns the entry id of the new item, or an empty string if there
|
|
|
|
was an error writing the item.
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual QString writeEntry(int id, const KeyBundle &kb);
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Write a Certificate to the store
|
|
|
|
|
|
|
|
Returns the entry id of the new item, or an empty string if there
|
|
|
|
was an error writing the item.
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual QString writeEntry(int id, const Certificate &cert);
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Write a CRL to the store
|
|
|
|
|
|
|
|
Returns the entry id of the new item, or an empty string if there
|
|
|
|
was an error writing the item.
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual QString writeEntry(int id, const CRL &crl);
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Write a PGPKey to the store
|
|
|
|
|
|
|
|
Returns the entry id of the new item, or an empty string if there
|
|
|
|
was an error writing the item.
|
|
|
|
*/
|
2007-04-13 06:32:02 +00:00
|
|
|
virtual QString writeEntry(int id, const PGPKey &key);
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Remove an entry from the store
|
|
|
|
|
|
|
|
Returns true if the entry is successfully removed, otherwise
|
|
|
|
false.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual bool removeEntry(int id, const QString &entryId);
|
2005-04-09 07:43:15 +00:00
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Emit this when the provider is busy looking for keystores. The
|
|
|
|
provider goes into a busy state when it has reason to believe
|
|
|
|
there are keystores present, but it still needs to check or query
|
|
|
|
some devices to see for sure.
|
|
|
|
|
|
|
|
For example, if a smart card is inserted, then the provider may
|
|
|
|
immediately go into a busy state upon detecting the insert.
|
|
|
|
However, it may take some seconds before the smart card
|
|
|
|
information can be queried and reported by the provider. Once
|
|
|
|
the card is queried successfully, the provider would leave the
|
|
|
|
busy state and report the new keystore.
|
|
|
|
|
|
|
|
When this object is first started with start(), it is assumed to
|
|
|
|
be in the busy state, so there is no need to emit this signal at
|
|
|
|
the beginning.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
void busyStart();
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Emit this to leave the busy state
|
|
|
|
|
|
|
|
When this object is first started with start(), it is assumed to
|
|
|
|
be in the busy state. You must emit busyEnd() at some point, or
|
|
|
|
QCA will never ask you about keystores.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
void busyEnd();
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Indicates the list of keystores has changed, and that QCA should
|
|
|
|
call keyStores() to obtain the latest list
|
|
|
|
*/
|
2005-07-31 05:12:42 +00:00
|
|
|
void updated();
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Emitted when there is diagnostic text to report
|
|
|
|
*/
|
2005-07-31 05:12:42 +00:00
|
|
|
void diagnosticText(const QString &str);
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Indicates that the entry list of a keystore has changed (entries
|
|
|
|
added, removed, or modified)
|
|
|
|
*/
|
2005-07-31 05:12:42 +00:00
|
|
|
void storeUpdated(int id);
|
2005-03-28 07:11:58 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class TLSSessionContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
TLS "session" provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want TLSSession instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2007-07-06 18:57:03 +00:00
|
|
|
class QCA_EXPORT TLSSessionContext : public BasicContext
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2007-07-06 18:57:03 +00:00
|
|
|
TLSSessionContext(Provider *p) : BasicContext(p, "tlssession") {}
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class TLSContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
TLS provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want TLS instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT TLSContext : public Provider::Context
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-07-28 12:17:09 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class QCA::TLSContext::SessionInfo qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-28 00:15:18 +00:00
|
|
|
Information about an active TLS connection
|
|
|
|
|
|
|
|
For efficiency and simplicity, the members are directly accessed.
|
2007-08-04 08:09:02 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-28 00:15:18 +00:00
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
class SessionInfo
|
|
|
|
{
|
|
|
|
public:
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
|
|
|
True if the TLS connection is compressed, otherwise false
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
bool isCompressed;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The TLS protocol version being used for this connection
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
TLS::Version version;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The cipher suite being used for this connection
|
|
|
|
|
|
|
|
\sa TLSContext::supportedCipherSuites()
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
QString cipherSuite;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The bit size of the cipher used for this connection
|
|
|
|
*/
|
2007-07-27 23:17:01 +00:00
|
|
|
int cipherBits;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The maximum bit size possible of the cipher used for this
|
|
|
|
connection
|
|
|
|
*/
|
2007-07-27 23:17:01 +00:00
|
|
|
int cipherMaxBits;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Pointer to the id of this TLS session, for use with
|
|
|
|
resuming
|
|
|
|
*/
|
2007-07-06 18:57:03 +00:00
|
|
|
TLSSessionContext *id;
|
2005-04-22 12:46:55 +00:00
|
|
|
};
|
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Result of a TLS operation
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
enum Result
|
|
|
|
{
|
2007-08-02 07:52:53 +00:00
|
|
|
Success, ///< Operation completed
|
|
|
|
Error, ///< Operation failed
|
|
|
|
Continue ///< More data needed to complete operation
|
2005-04-22 12:46:55 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
TLSContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
|
|
|
Reset the object to its initial state
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual void reset() = 0;
|
|
|
|
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
|
|
|
Returns a list of supported cipher suites for the specified
|
|
|
|
SSL/TLS version. The cipher suites are specified as strings, for
|
|
|
|
example: "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" (without quotes).
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param version the version of TLS to search for
|
2007-07-28 00:15:18 +00:00
|
|
|
*/
|
2006-03-17 11:16:23 +00:00
|
|
|
virtual QStringList supportedCipherSuites(const TLS::Version &version) const = 0;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Returns true if the provider supports compression
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
virtual bool canCompress() const = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the provider supports server name indication
|
|
|
|
*/
|
2007-04-11 02:13:20 +00:00
|
|
|
virtual bool canSetHostName() const = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum SSF supported by this provider
|
|
|
|
*/
|
2005-04-24 19:09:06 +00:00
|
|
|
virtual int maxSSF() const = 0;
|
2005-04-22 12:46:55 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Configure a new session
|
|
|
|
|
|
|
|
This function will be called before any other configuration
|
|
|
|
functions.
|
|
|
|
*/
|
|
|
|
virtual void setup(bool serverMode, const QString &hostName, bool compress) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the constraints of the session using SSF values
|
|
|
|
|
|
|
|
This function will be called before start().
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
virtual void setConstraints(int minSSF, int maxSSF) = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
\overload
|
|
|
|
|
|
|
|
Set the constraints of the session using a cipher suite list
|
|
|
|
|
|
|
|
This function will be called before start().
|
|
|
|
|
|
|
|
\sa supportedCipherSuites
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
virtual void setConstraints(const QStringList &cipherSuiteList) = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the list of trusted certificates
|
|
|
|
|
|
|
|
This function may be called at any time.
|
|
|
|
*/
|
2007-06-25 19:08:05 +00:00
|
|
|
virtual void setTrustedCertificates(const CertificateCollection &trusted) = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the list of acceptable issuers
|
|
|
|
|
|
|
|
This function may be called at any time.
|
|
|
|
|
|
|
|
This function is for server mode only.
|
|
|
|
*/
|
2007-06-25 19:08:05 +00:00
|
|
|
virtual void setIssuerList(const QList<CertificateInfoOrdered> &issuerList) = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the local certificate
|
|
|
|
|
|
|
|
This function may be called at any time.
|
|
|
|
*/
|
2007-04-11 02:13:20 +00:00
|
|
|
virtual void setCertificate(const CertificateChain &cert, const PrivateKey &key) = 0;
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the TLS session id, for session resuming
|
|
|
|
|
|
|
|
This function will be called before start().
|
|
|
|
*/
|
2007-07-06 18:57:03 +00:00
|
|
|
virtual void setSessionId(const TLSSessionContext &id) = 0;
|
2005-04-22 12:46:55 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Sets the session to the shutdown state.
|
2005-07-30 09:16:05 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
The actual shutdown operation will happen at a future call to
|
|
|
|
update().
|
|
|
|
|
|
|
|
This function is for normal TLS only (not DTLS).
|
|
|
|
*/
|
|
|
|
virtual void shutdown() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the maximum transmission unit size
|
|
|
|
|
|
|
|
This function is for DTLS only.
|
|
|
|
*/
|
|
|
|
virtual void setMTU(int size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Begins the session, starting with the handshake
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, the result() function will return Success if the
|
|
|
|
TLS session is able to begin, or Error if there is a failure to
|
|
|
|
initialize the TLS subsystem. If successful, the session is now
|
|
|
|
in the handshake state, and update() will be called repeatedly
|
|
|
|
until the session ends.
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual void start() = 0;
|
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Performs one iteration of the TLS session processing
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
If the session is in a handshake state, result() and to_net() will
|
|
|
|
be valid. If result() is Success, then the session is now in the
|
|
|
|
connected state.
|
|
|
|
|
|
|
|
If the session is in a shutdown state, result() and to_net() will
|
|
|
|
be valid. If result() is Success, then the session has ended.
|
|
|
|
|
|
|
|
If the session is in a connected state, result(), to_net(),
|
|
|
|
encoded(), to_app(), and eof() are valid. The result() function
|
|
|
|
will return Success or Error. Note that eof() does not apply
|
|
|
|
to DTLS.
|
|
|
|
|
|
|
|
For DTLS, this function operates with single packets. Many
|
|
|
|
update() operations must be performed repeatedly to exchange
|
|
|
|
multiple packets.
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
|
2005-07-28 12:17:09 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Waits for a start() or update() operation to complete. In this
|
|
|
|
case, the resultsReady() signal is not emitted. Returns true if
|
|
|
|
the operation completed or false if this function times out.
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
|
|
|
|
\param msecs number of milliseconds to wait (-1 to wait forever)
|
|
|
|
*/
|
|
|
|
virtual bool waitForResultsReady(int msecs) = 0;
|
2005-04-22 12:46:55 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the result code of an operation
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual Result result() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns data that should be sent across the network
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual QByteArray to_net() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of bytes of plaintext data that is encoded
|
|
|
|
inside of to_net()
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual int encoded() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns data that is decoded from the network and should be
|
|
|
|
processed by the application
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual QByteArray to_app() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the peer has closed the stream
|
|
|
|
*/
|
2005-07-30 09:16:05 +00:00
|
|
|
virtual bool eof() const = 0;
|
2005-07-28 12:17:09 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns true if the TLS client hello has been received
|
|
|
|
|
|
|
|
This is only valid if a handshake is in progress or
|
|
|
|
completed.
|
|
|
|
*/
|
2007-06-25 19:08:05 +00:00
|
|
|
virtual bool clientHelloReceived() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the TLS server hello has been received
|
|
|
|
|
|
|
|
This is only valid if a handshake is in progress or completed.
|
|
|
|
*/
|
2007-04-11 02:13:20 +00:00
|
|
|
virtual bool serverHelloReceived() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the host name sent by the client using server name
|
|
|
|
indication (server mode only)
|
|
|
|
|
|
|
|
This is only valid if a handshake is in progress or completed.
|
|
|
|
*/
|
2007-06-25 19:08:05 +00:00
|
|
|
virtual QString hostName() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the peer is requesting a certificate
|
|
|
|
|
|
|
|
This is only valid if a handshake is in progress or completed.
|
|
|
|
*/
|
2007-07-06 18:03:29 +00:00
|
|
|
virtual bool certificateRequested() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the issuer list sent by the server (client mode only)
|
|
|
|
|
|
|
|
This is only valid if a handshake is in progress or completed.
|
|
|
|
*/
|
2007-04-11 02:13:20 +00:00
|
|
|
virtual QList<CertificateInfoOrdered> issuerList() const = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the QCA::Validity of the peer certificate
|
|
|
|
|
|
|
|
This is only valid if a handshake is completed.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual Validity peerCertificateValidity() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the peer certificate chain
|
|
|
|
|
|
|
|
This is only valid if a handshake is completed.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
virtual CertificateChain peerCertificateChain() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns information about the active TLS session
|
|
|
|
|
|
|
|
This is only valid if a handshake is completed.
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
virtual SessionInfo sessionInfo() const = 0;
|
2005-07-30 09:16:05 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns any unprocessed network input data
|
|
|
|
|
|
|
|
This is only valid after a successful shutdown.
|
|
|
|
*/
|
2005-04-24 19:09:06 +00:00
|
|
|
virtual QByteArray unprocessed() = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Emit this when a start() or update() operation has completed.
|
|
|
|
*/
|
2005-07-28 12:17:09 +00:00
|
|
|
void resultsReady();
|
2007-08-02 07:52:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Emit this to force the application to call update(), even with
|
|
|
|
empty arguments.
|
|
|
|
*/
|
|
|
|
void dtlsTimeout();
|
2004-10-29 22:51:30 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class SASLContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
SASL provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want SASL instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT SASLContext : public Provider::Context
|
2004-10-29 22:51:30 +00:00
|
|
|
{
|
2005-07-31 01:27:27 +00:00
|
|
|
Q_OBJECT
|
2004-10-29 22:51:30 +00:00
|
|
|
public:
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class QCA::SASLContext::HostPort qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-28 00:15:18 +00:00
|
|
|
Convenience class to hold an IP address and an associated port
|
|
|
|
|
|
|
|
For efficiency and simplicity, the members are directly accessed.
|
2007-08-04 08:09:02 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-28 00:15:18 +00:00
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
class HostPort
|
2004-10-31 10:04:44 +00:00
|
|
|
{
|
2005-04-22 12:46:55 +00:00
|
|
|
public:
|
2007-07-28 00:15:18 +00:00
|
|
|
/**
|
|
|
|
The IP address
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
QString addr;
|
2007-07-28 00:15:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The port
|
|
|
|
*/
|
2005-04-22 12:46:55 +00:00
|
|
|
quint16 port;
|
2004-10-31 10:04:44 +00:00
|
|
|
};
|
2005-04-22 12:46:55 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Result of a SASL operation
|
|
|
|
*/
|
2004-10-31 10:04:44 +00:00
|
|
|
enum Result
|
|
|
|
{
|
2007-08-02 07:52:53 +00:00
|
|
|
Success, ///< Operation completed
|
|
|
|
Error, ///< Operation failed
|
|
|
|
Params, ///< Parameters are needed to complete authentication
|
|
|
|
AuthCheck, ///< Client login can be inspected (server only)
|
|
|
|
Continue ///< More steps needed to complete authentication
|
2004-10-31 10:04:44 +00:00
|
|
|
};
|
2005-04-22 12:46:55 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2004-10-31 10:04:44 +00:00
|
|
|
SASLContext(Provider *p) : Provider::Context(p, "sasl") {}
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Reset the object to its initial state
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual void reset() = 0;
|
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Configure a new session
|
|
|
|
|
|
|
|
This function will be called before any other configuration
|
|
|
|
functions.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void setup(const QString &service, const QString &host, const HostPort *local, const HostPort *remote, const QString &ext_id, int ext_ssf) = 0;
|
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Set the constraints of the session using SSF values
|
|
|
|
|
|
|
|
This function will be called before startClient() or
|
|
|
|
startServer().
|
|
|
|
*/
|
|
|
|
virtual void setConstraints(SASL::AuthFlags f, int minSSF, int maxSSF) = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Begins the session in client mode, starting with the
|
|
|
|
authentication
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result(), mech(), haveClientInit(), and stepData()
|
|
|
|
will be valid. If result() is Success, then the session is now in
|
|
|
|
the connected state.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Begins the session in server mode, starting with the
|
|
|
|
authentication
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result() and mechlist() will be valid. The
|
|
|
|
result() function will return Success or Error. If the result is
|
|
|
|
Success, then serverFirstStep() will be called next.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void startServer(const QString &realm, bool disableServerSendLast) = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Finishes server startup
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result() and stepData() will be valid. If result()
|
|
|
|
is Success, then the session is now in the connected state.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void serverFirstStep(const QString &mech, const QByteArray *clientInit) = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Perform another step of the SASL authentication
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result() and stepData() will be valid.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void nextStep(const QByteArray &from_net) = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Attempt the most recent operation again. This is used if the
|
|
|
|
result() of an operation is Params or AuthCheck.
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result() and stepData() will be valid.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void tryAgain() = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Performs one iteration of the SASL security layer processing
|
|
|
|
|
|
|
|
This function returns immediately, and completion is signaled with
|
|
|
|
the resultsReady() signal.
|
|
|
|
|
|
|
|
On completion, result(), to_net(), encoded(), and to_app() will be
|
|
|
|
valid. The result() function will return Success or Error.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual void update(const QByteArray &from_net, const QByteArray &from_app) = 0;
|
|
|
|
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Waits for a startClient(), startServer(), serverFirstStep(),
|
|
|
|
nextStep(), tryAgain(), or update() operation to complete. In
|
|
|
|
this case, the resultsReady() signal is not emitted. Returns true
|
|
|
|
if the operation completed or false if this function times out.
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
|
|
|
|
\param msecs number of milliseconds to wait (-1 to wait forever)
|
|
|
|
*/
|
|
|
|
virtual bool waitForResultsReady(int msecs) = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the result code of an operation
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual Result result() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the mechanism list (server mode only)
|
|
|
|
*/
|
2007-06-08 22:08:57 +00:00
|
|
|
virtual QStringList mechlist() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the mechanism selected
|
|
|
|
*/
|
2004-10-29 22:51:30 +00:00
|
|
|
virtual QString mech() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the client has initialization data
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual bool haveClientInit() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns an authentication payload for to be transmitted over the
|
|
|
|
network
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual QByteArray stepData() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns data that should be sent across the network (for the
|
|
|
|
security layer)
|
|
|
|
*/
|
2006-11-13 01:44:41 +00:00
|
|
|
virtual QByteArray to_net() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of bytes of plaintext data that is encoded
|
|
|
|
inside of to_net()
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual int encoded() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns data that is decoded from the network and should be
|
|
|
|
processed by the application
|
|
|
|
*/
|
2006-11-13 01:44:41 +00:00
|
|
|
virtual QByteArray to_app() = 0;
|
2005-07-31 01:27:27 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the SSF of the active SASL session
|
|
|
|
|
|
|
|
This is only valid after authentication success.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual int ssf() const = 0;
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the reason for failure, if the authentication was not
|
|
|
|
successful.
|
|
|
|
|
|
|
|
This is only valid after authentication failure.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual SASL::AuthCondition authCondition() const = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the needed/optional client parameters
|
|
|
|
|
|
|
|
This is only valid after receiving the Params result code.
|
|
|
|
*/
|
2007-06-11 23:18:19 +00:00
|
|
|
virtual SASL::Params clientParams() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set some of the client parameters (pass 0 to not set a field)
|
|
|
|
*/
|
2007-04-13 19:04:16 +00:00
|
|
|
virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;
|
2005-07-31 01:27:27 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the realm list (client mode only)
|
|
|
|
|
|
|
|
This is only valid after receiving the Params result code and
|
|
|
|
SASL::Params::canSendRealm is set to true.
|
|
|
|
*/
|
2007-06-11 23:18:19 +00:00
|
|
|
virtual QStringList realmlist() const = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns the username attempting to authenticate (server mode only)
|
|
|
|
|
|
|
|
This is only valid after receiving the AuthCheck result code.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual QString username() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the authzid attempting to authorize (server mode only)
|
|
|
|
|
|
|
|
This is only valid after receiving the AuthCheck result code.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
virtual QString authzid() const = 0;
|
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-08-02 07:52:53 +00:00
|
|
|
/**
|
|
|
|
Emit this when a startClient(), startServer(), serverFirstStep(),
|
|
|
|
nextStep(), tryAgain(), or update() operation has completed.
|
|
|
|
*/
|
2005-07-31 01:27:27 +00:00
|
|
|
void resultsReady();
|
2004-10-31 10:04:44 +00:00
|
|
|
};
|
2004-10-29 22:51:30 +00:00
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class MessageContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
SecureMessage provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want SecureMessage
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT MessageContext : public Provider::Context
|
2005-05-06 07:13:23 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
The type of operation being performed
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
enum Operation
|
|
|
|
{
|
2007-08-02 20:18:17 +00:00
|
|
|
Encrypt, ///< Encrypt operation
|
|
|
|
Decrypt, ///< Decrypt (or Decrypt and Verify) operation
|
|
|
|
Sign, ///< Sign operation
|
|
|
|
Verify, ///< Verify operation
|
|
|
|
SignAndEncrypt ///< Sign and Encrypt operation
|
2005-05-06 07:13:23 +00:00
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param p the Provider associated with this context
|
|
|
|
\param type the name of the type of secure message to be created
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
MessageContext(Provider *p, const QString &type) : Provider::Context(p, type) {}
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns true if the provider supports multiple signers for
|
|
|
|
signature creation or signature verification
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual bool canSignMultiple() const = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
The type of secure message (e.g. PGP or CMS)
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual SecureMessage::Type type() const = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Reset the object to its initial state
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual void reset() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Configure a new encrypting operation
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param keys the keys to be used for encryption.
|
2007-08-02 20:18:17 +00:00
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual void setupEncrypt(const SecureMessageKeyList &keys) = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Configure a new signing operation
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual void setupSign(const SecureMessageKeyList &keys, SecureMessage::SignMode m, bool bundleSigner, bool smime) = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Configure a new verify operation
|
2007-09-03 12:04:55 +00:00
|
|
|
|
|
|
|
\param detachedSig the detached signature to use (if applicable) for verification
|
2007-08-02 20:18:17 +00:00
|
|
|
*/
|
2005-06-24 23:41:25 +00:00
|
|
|
virtual void setupVerify(const QByteArray &detachedSig) = 0;
|
2005-05-06 07:13:23 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Begins the secure message operation
|
|
|
|
|
|
|
|
This function returns immediately.
|
|
|
|
|
|
|
|
If there is input data, update() will be called (potentially
|
|
|
|
repeatedly) afterwards. Emit updated() if there is data to
|
|
|
|
read, if input data has been accepted, or if the operation has
|
|
|
|
finished.
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual void start(SecureMessage::Format f, Operation op) = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Provide input to the message operation
|
|
|
|
*/
|
2005-06-24 23:41:25 +00:00
|
|
|
virtual void update(const QByteArray &in) = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Extract output from the message operation
|
|
|
|
*/
|
2005-06-24 23:41:25 +00:00
|
|
|
virtual QByteArray read() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of input bytes accepted since the last call to
|
|
|
|
update()
|
|
|
|
*/
|
2007-06-25 22:02:34 +00:00
|
|
|
virtual int written() = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Indicates the end of input
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual void end() = 0;
|
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Returns true if the operation has finished, otherwise false
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual bool finished() const = 0;
|
2005-05-06 07:13:23 +00:00
|
|
|
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Waits for the secure message operation to complete. In this case,
|
|
|
|
the updated() signal is not emitted. Returns true if the
|
|
|
|
operation completed or false if this function times out.
|
|
|
|
|
|
|
|
This function is blocking.
|
|
|
|
|
|
|
|
\param msecs number of milliseconds to wait (-1 to wait forever)
|
|
|
|
*/
|
|
|
|
virtual bool waitForFinished(int msecs) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns true if the operation was successful
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual bool success() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the reason for failure, if the operation was not
|
|
|
|
successful
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual SecureMessage::Error errorCode() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the signature, in the case of a detached signature
|
|
|
|
operation
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2005-06-24 23:41:25 +00:00
|
|
|
virtual QByteArray signature() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the name of the hash used to generate the signature, in
|
|
|
|
the case of a signature operation
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual QString hashName() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a list of signatures, in the case of a verify or decrypt
|
|
|
|
and verify operation
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2005-05-10 07:04:41 +00:00
|
|
|
virtual SecureMessageSignatureList signers() const = 0;
|
2007-08-02 20:18:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns any diagnostic text for the operation, potentially useful
|
|
|
|
to show the user in the event the operation is unsuccessful. For
|
|
|
|
example, this could be the stderr output of gpg.
|
|
|
|
|
|
|
|
This is only valid if the operation has finished.
|
|
|
|
*/
|
2007-07-20 17:51:10 +00:00
|
|
|
virtual QString diagnosticText() const;
|
2005-05-06 07:13:23 +00:00
|
|
|
|
2007-04-03 11:03:38 +00:00
|
|
|
Q_SIGNALS:
|
2007-08-02 20:18:17 +00:00
|
|
|
/**
|
|
|
|
Emitted when there is data to read, if input data has been
|
|
|
|
accepted, or if the operation has finished
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
void updated();
|
|
|
|
};
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
2007-08-04 11:43:17 +00:00
|
|
|
\class SMSContext qcaprovider.h QtCrypto
|
|
|
|
|
2007-07-20 01:05:05 +00:00
|
|
|
SecureMessageSystem provider
|
2007-07-28 00:04:02 +00:00
|
|
|
|
|
|
|
\note This class is part of the provider plugin interface and should not
|
|
|
|
be used directly by applications. You probably want SecureMessageSystem
|
|
|
|
instead.
|
2007-08-04 11:43:17 +00:00
|
|
|
|
2007-08-28 01:36:27 +00:00
|
|
|
\ingroup ProviderAPI
|
2007-07-20 01:05:05 +00:00
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
class QCA_EXPORT SMSContext : public BasicContext
|
2005-05-06 07:13:23 +00:00
|
|
|
{
|
2006-11-13 00:47:46 +00:00
|
|
|
Q_OBJECT
|
2005-05-06 07:13:23 +00:00
|
|
|
public:
|
2007-07-20 01:05:05 +00:00
|
|
|
/**
|
|
|
|
Standard constructor
|
|
|
|
*/
|
2006-11-13 00:47:46 +00:00
|
|
|
SMSContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
2005-05-06 07:13:23 +00:00
|
|
|
|
2007-07-27 23:17:01 +00:00
|
|
|
/**
|
|
|
|
Set the trusted certificates and for this secure message system,
|
|
|
|
to be used for validation
|
|
|
|
|
|
|
|
The collection may also contain CRLs.
|
|
|
|
|
|
|
|
This function is only valid for CMS.
|
|
|
|
*/
|
2005-05-06 07:13:23 +00:00
|
|
|
virtual void setTrustedCertificates(const CertificateCollection &trusted);
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the untrusted certificates and CRLs for this secure message
|
|
|
|
system, to be used for validation
|
|
|
|
|
|
|
|
This function is only valid for CMS.
|
|
|
|
*/
|
2007-05-14 23:16:31 +00:00
|
|
|
virtual void setUntrustedCertificates(const CertificateCollection &untrusted);
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the private keys for this secure message system, to be used
|
|
|
|
for decryption
|
|
|
|
|
|
|
|
This function is only valid for CMS.
|
|
|
|
*/
|
2005-06-25 20:25:52 +00:00
|
|
|
virtual void setPrivateKeys(const QList<SecureMessageKey> &keys);
|
2007-07-27 23:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Create a new message object for this system. The caller is
|
|
|
|
responsible for deleting it.
|
|
|
|
*/
|
2005-06-25 20:25:52 +00:00
|
|
|
virtual MessageContext *createMessage() = 0;
|
2005-05-06 07:13:23 +00:00
|
|
|
};
|
|
|
|
|
2004-10-28 04:28:20 +00:00
|
|
|
}
|
2007-08-04 12:00:23 +00:00
|
|
|
#endif
|
2007-07-30 23:40:24 +00:00
|
|
|
|
2003-07-02 03:34:11 +00:00
|
|
|
#endif
|