mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-26 19:44:32 +00:00
qca_export,tools,qpipe.h,support,provider,core,qca.h,textfilter and
private headers have been de-indented 1 tab and their documentation formatting have been made consistent svn path=/trunk/kdesupport/qca/; revision=670321
This commit is contained in:
parent
24c38e3217
commit
ff8b982fb6
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* qca_core.h - Qt Cryptographic Architecture
|
||||
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -59,10 +59,10 @@
|
||||
QCA_EXPORT int qcaVersion();
|
||||
|
||||
/**
|
||||
* QCA - the Qt Cryptographic Architecture
|
||||
QCA - the Qt Cryptographic Architecture
|
||||
*/
|
||||
namespace QCA
|
||||
{
|
||||
namespace QCA {
|
||||
|
||||
class Provider;
|
||||
class Random;
|
||||
class CertificateCollection;
|
||||
@ -74,29 +74,29 @@ namespace QCA
|
||||
class Logger;
|
||||
|
||||
/**
|
||||
* Convenience representation for the plugin providers
|
||||
*
|
||||
* You can get a list of providers using the providers()
|
||||
* function
|
||||
*
|
||||
* \sa ProviderListIterator
|
||||
* \sa providers()
|
||||
Convenience representation for the plugin providers
|
||||
|
||||
You can get a list of providers using the providers()
|
||||
function
|
||||
|
||||
\sa ProviderListIterator
|
||||
\sa providers()
|
||||
*/
|
||||
typedef QList<Provider*> ProviderList;
|
||||
|
||||
/**
|
||||
* Mode settings for memory allocation
|
||||
*
|
||||
* QCA can use secure memory, however most operating systems
|
||||
* restrict the amount of memory that can be pinned by user
|
||||
* applications, to prevent a denial-of-service attack.
|
||||
*
|
||||
* QCA supports two approaches to getting memory - the mlock
|
||||
* method, which generally requires root (administrator) level
|
||||
* privileges, and the mmap method which is not as secure, but
|
||||
* which should be able to be used by any process.
|
||||
*
|
||||
* \sa Initializer
|
||||
Mode settings for memory allocation
|
||||
|
||||
QCA can use secure memory, however most operating systems
|
||||
restrict the amount of memory that can be pinned by user
|
||||
applications, to prevent a denial-of-service attack.
|
||||
|
||||
QCA supports two approaches to getting memory - the mlock
|
||||
method, which generally requires root (administrator) level
|
||||
privileges, and the mmap method which is not as secure, but
|
||||
which should be able to be used by any process.
|
||||
|
||||
\sa Initializer
|
||||
*/
|
||||
enum MemoryMode
|
||||
{
|
||||
@ -106,10 +106,10 @@ namespace QCA
|
||||
};
|
||||
|
||||
/**
|
||||
* Direction settings for symmetric algorithms
|
||||
*
|
||||
* For some algorithms, it makes sense to have a "direction", such
|
||||
* as Cipher algorithms which can be used to encrypt or decrypt.
|
||||
Direction settings for symmetric algorithms
|
||||
|
||||
For some algorithms, it makes sense to have a "direction", such
|
||||
as Cipher algorithms which can be used to encrypt or decrypt.
|
||||
*/
|
||||
enum Direction
|
||||
{
|
||||
@ -118,77 +118,77 @@ namespace QCA
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise %QCA.
|
||||
* This call is not normally required, because it is cleaner
|
||||
* to use an Initializer.
|
||||
Initialise %QCA.
|
||||
This call is not normally required, because it is cleaner
|
||||
to use an Initializer.
|
||||
*/
|
||||
QCA_EXPORT void init();
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param m the MemoryMode to use
|
||||
* \param prealloc the amount of memory in kilobytes to allocate
|
||||
* for secure storage
|
||||
\overload
|
||||
|
||||
\param m the MemoryMode to use
|
||||
\param prealloc the amount of memory in kilobytes to allocate
|
||||
for secure storage
|
||||
*/
|
||||
QCA_EXPORT void init(MemoryMode m, int prealloc);
|
||||
|
||||
/**
|
||||
* Clean up routine
|
||||
*
|
||||
* This routine cleans up %QCA, including memory allocations
|
||||
* This call is not normally required, because it is cleaner
|
||||
* to use an Initializer
|
||||
Clean up routine
|
||||
|
||||
This routine cleans up %QCA, including memory allocations
|
||||
This call is not normally required, because it is cleaner
|
||||
to use an Initializer
|
||||
*/
|
||||
QCA_EXPORT void deinit();
|
||||
|
||||
/**
|
||||
* Test if secure storage memory is available
|
||||
*
|
||||
* \return true if secure storage memory is available
|
||||
Test if secure storage memory is available
|
||||
|
||||
\return true if secure storage memory is available
|
||||
*/
|
||||
QCA_EXPORT bool haveSecureMemory();
|
||||
|
||||
/**
|
||||
* Test if secure random is available
|
||||
*
|
||||
* Secure random is considered available if the global random
|
||||
* provider is not the default provider.
|
||||
*
|
||||
* \return true if secure random is available
|
||||
Test if secure random is available
|
||||
|
||||
Secure random is considered available if the global random
|
||||
provider is not the default provider.
|
||||
|
||||
\return true if secure random is available
|
||||
*/
|
||||
QCA_EXPORT bool haveSecureRandom();
|
||||
|
||||
/**
|
||||
* Test if a capability (algorithm) is available.
|
||||
*
|
||||
* Since capabilities are made available at runtime, you
|
||||
* should always check before using a capability the first
|
||||
* time, as shown below.
|
||||
* \code
|
||||
* QCA::init();
|
||||
* if(!QCA::isSupported("sha1"))
|
||||
* printf("SHA1 not supported!\n");
|
||||
* else {
|
||||
* QString result = QCA::SHA1::hashToString(myString);
|
||||
* printf("sha1(\"%s\") = [%s]\n", myString.data(), qPrintable(result));
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \param features the name of the capability to test for
|
||||
* \param provider if specified, only check for the capability in that
|
||||
Test if a capability (algorithm) is available.
|
||||
|
||||
Since capabilities are made available at runtime, you
|
||||
should always check before using a capability the first
|
||||
time, as shown below.
|
||||
\code
|
||||
QCA::init();
|
||||
if(!QCA::isSupported("sha1"))
|
||||
printf("SHA1 not supported!\n");
|
||||
else
|
||||
{
|
||||
QString result = QCA::SHA1::hashToString(myString);
|
||||
printf("sha1(\"%s\") = [%s]\n", myString.data(), qPrintable(result));
|
||||
}
|
||||
\endcode
|
||||
|
||||
\param features the name of the capability to test for
|
||||
\param provider if specified, only check for the capability in that
|
||||
specific provider. If not provided, or provided as an empty
|
||||
string, then check for capabilities in all available providers
|
||||
* \return true if the capability is available, otherwise false
|
||||
*
|
||||
* Note that you can test for a combination of capabilities,
|
||||
* using a comma delimited list:
|
||||
* \code
|
||||
* QCA::isSupported("sha1,md5"):
|
||||
* \endcode
|
||||
* which will return true if all of the capabilities listed
|
||||
* are present.
|
||||
*
|
||||
\return true if the capability is available, otherwise false
|
||||
|
||||
Note that you can test for a combination of capabilities,
|
||||
using a comma delimited list:
|
||||
\code
|
||||
QCA::isSupported("sha1,md5"):
|
||||
\endcode
|
||||
which will return true if all of the capabilities listed
|
||||
are present.
|
||||
*/
|
||||
QCA_EXPORT bool isSupported(const char *features, const QString &provider = QString());
|
||||
|
||||
@ -203,195 +203,192 @@ namespace QCA
|
||||
QCA_EXPORT bool isSupported(const QStringList &features, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
* Generate a list of all the supported features in plugins,
|
||||
* and in built in capabilities
|
||||
*
|
||||
* \return a list containing the names of the features
|
||||
*
|
||||
* The following code writes a list of features to standard out
|
||||
* \code
|
||||
* QStringList capabilities;
|
||||
* capabilities = QCA::supportedFeatures();
|
||||
* std::cout << "Supported:" << capabilities.join(",") << std::endl;
|
||||
* \endcode
|
||||
*
|
||||
* \sa isSupported(const char *features)
|
||||
* \sa isSupported(const QStringList &features)
|
||||
* \sa defaultFeatures()
|
||||
Generate a list of all the supported features in plugins,
|
||||
and in built in capabilities
|
||||
|
||||
\return a list containing the names of the features
|
||||
|
||||
The following code writes a list of features to standard out
|
||||
\code
|
||||
QStringList capabilities;
|
||||
capabilities = QCA::supportedFeatures();
|
||||
std::cout << "Supported:" << capabilities.join(",") << std::endl;
|
||||
\endcode
|
||||
\sa isSupported(const char *features)
|
||||
\sa isSupported(const QStringList &features)
|
||||
\sa defaultFeatures()
|
||||
*/
|
||||
QCA_EXPORT QStringList supportedFeatures();
|
||||
|
||||
/**
|
||||
* Generate a list of the built in features. This differs from
|
||||
* supportedFeatures() in that it does not include features provided
|
||||
* by plugins.
|
||||
*
|
||||
* \return a list containing the names of the features
|
||||
*
|
||||
* The following code writes a list of features to standard out
|
||||
* \code
|
||||
* QStringList capabilities;
|
||||
* capabilities = QCA::defaultFeatures();
|
||||
* std::cout << "Default:" << capabilities.join(",") << std::endl;
|
||||
* \endcode
|
||||
*
|
||||
* \sa isSupported(const char *features)
|
||||
* \sa isSupported(const QStringList &features)
|
||||
* \sa supportedFeatures()
|
||||
Generate a list of the built in features. This differs from
|
||||
supportedFeatures() in that it does not include features provided
|
||||
by plugins.
|
||||
|
||||
\return a list containing the names of the features
|
||||
|
||||
The following code writes a list of features to standard out
|
||||
\code
|
||||
QStringList capabilities;
|
||||
capabilities = QCA::defaultFeatures();
|
||||
std::cout << "Default:" << capabilities.join(",") << std::endl;
|
||||
\endcode
|
||||
|
||||
\sa isSupported
|
||||
\sa supportedFeatures()
|
||||
*/
|
||||
QCA_EXPORT QStringList defaultFeatures();
|
||||
|
||||
/**
|
||||
* Add a provider to the current list of providers
|
||||
*
|
||||
* This function allows you to add a provider to the
|
||||
* current plugin providers at a specified priority. If
|
||||
* a provider with the name already exists, this call fails.
|
||||
*
|
||||
* \param p a pointer to a Provider object, which must be
|
||||
* set up.
|
||||
* \param priority the priority level to set the provider to
|
||||
*
|
||||
* \return true if the provider is added, and false if the
|
||||
* provider is not added (failure)
|
||||
*
|
||||
* \sa setProviderPriority for a description of the provider priority system
|
||||
Add a provider to the current list of providers
|
||||
|
||||
This function allows you to add a provider to the
|
||||
current plugin providers at a specified priority. If
|
||||
a provider with the name already exists, this call fails.
|
||||
|
||||
\param p a pointer to a Provider object, which must be
|
||||
set up.
|
||||
\param priority the priority level to set the provider to
|
||||
\return true if the provider is added, and false if the
|
||||
provider is not added (failure)
|
||||
|
||||
\sa setProviderPriority for a description of the provider priority system
|
||||
*/
|
||||
QCA_EXPORT bool insertProvider(Provider *p, int priority = 0);
|
||||
|
||||
/**
|
||||
* Change the priority of a specified provider
|
||||
*
|
||||
* QCA supports a number of providers, and if a number of providers
|
||||
* support the same algorithm, it needs to choose between them. You
|
||||
* can do this at object instantiation time (by specifying the name
|
||||
* of the provider that should be used). Alternatively, you can provide a
|
||||
* relative priority level at an application level, using this call.
|
||||
*
|
||||
* Priority is used at object instantiation time. The provider is selected
|
||||
* according to the following logic:
|
||||
* - if a particular provider is nominated, and that provider supports
|
||||
* the required algorithm, then the nominated provider is used
|
||||
* - if no provider is nominated, or it doesn't support the required
|
||||
* algorithm, then the provider with the lowest priority number will be used,
|
||||
* if that provider supports the algorithm.
|
||||
* - if the provider with the lowest priority number doesn't support
|
||||
* the required algorithm, the provider with the next lowest priority number
|
||||
* will be tried,and so on through to the provider with the largest priority number
|
||||
* - if none of the plugin providers support the required algorithm, then
|
||||
* the default (built-in) provider will be tried.
|
||||
*
|
||||
* \param name the name of the provider
|
||||
* \param priority the new priority of the provider. As a special case, if
|
||||
* you pass in -1, then this provider gets the same priority as the
|
||||
* the last provider that was added or had its priority set using this
|
||||
* call.
|
||||
*
|
||||
* \sa providerPriority
|
||||
Change the priority of a specified provider
|
||||
|
||||
QCA supports a number of providers, and if a number of providers
|
||||
support the same algorithm, it needs to choose between them. You
|
||||
can do this at object instantiation time (by specifying the name
|
||||
of the provider that should be used). Alternatively, you can provide a
|
||||
relative priority level at an application level, using this call.
|
||||
|
||||
Priority is used at object instantiation time. The provider is selected
|
||||
according to the following logic:
|
||||
- if a particular provider is nominated, and that provider supports
|
||||
the required algorithm, then the nominated provider is used
|
||||
- if no provider is nominated, or it doesn't support the required
|
||||
algorithm, then the provider with the lowest priority number will be used,
|
||||
if that provider supports the algorithm.
|
||||
- if the provider with the lowest priority number doesn't support
|
||||
the required algorithm, the provider with the next lowest priority number
|
||||
will be tried,and so on through to the provider with the largest priority number
|
||||
- if none of the plugin providers support the required algorithm, then
|
||||
the default (built-in) provider will be tried.
|
||||
|
||||
\param name the name of the provider
|
||||
\param priority the new priority of the provider. As a special case, if
|
||||
you pass in -1, then this provider gets the same priority as the
|
||||
the last provider that was added or had its priority set using this
|
||||
call.
|
||||
|
||||
\sa providerPriority
|
||||
*/
|
||||
QCA_EXPORT void setProviderPriority(const QString &name, int priority);
|
||||
|
||||
/**
|
||||
* Return the priority of a specified provider
|
||||
*
|
||||
* The name of the provider (eg "qca-openssl") is used to look up the
|
||||
* current priority associated with that provider. If the provider
|
||||
* is not found (or something else went wrong), -1 is returned.
|
||||
*
|
||||
* \param name the name of the provider
|
||||
*
|
||||
* \return the current priority level
|
||||
*
|
||||
* \sa setProviderPriority for a description of the provider priority system
|
||||
Return the priority of a specified provider
|
||||
|
||||
The name of the provider (eg "qca-openssl") is used to look up the
|
||||
current priority associated with that provider. If the provider
|
||||
is not found (or something else went wrong), -1 is returned.
|
||||
|
||||
\param name the name of the provider
|
||||
|
||||
\return the current priority level
|
||||
|
||||
\sa setProviderPriority for a description of the provider priority system
|
||||
*/
|
||||
QCA_EXPORT int providerPriority(const QString &name);
|
||||
|
||||
/**
|
||||
* Return a list of the current providers
|
||||
*
|
||||
* The current plugin providers are provided as a list, which you
|
||||
* can iterate over using ProviderListIterator.
|
||||
*
|
||||
* \sa ProviderList
|
||||
* \sa ProviderListIterator
|
||||
Return a list of the current providers
|
||||
|
||||
The current plugin providers are provided as a list, which you
|
||||
can iterate over using ProviderListIterator.
|
||||
|
||||
\sa ProviderList
|
||||
\sa ProviderListIterator
|
||||
*/
|
||||
QCA_EXPORT ProviderList providers();
|
||||
|
||||
/**
|
||||
* Return the named provider, or 0 if not found
|
||||
Return the named provider, or 0 if not found
|
||||
*/
|
||||
QCA_EXPORT Provider *findProvider(const QString &name);
|
||||
|
||||
/**
|
||||
* Return the default provider
|
||||
Return the default provider
|
||||
*/
|
||||
QCA_EXPORT Provider *defaultProvider();
|
||||
|
||||
/**
|
||||
* Scan for new plugins
|
||||
Scan for new plugins
|
||||
*/
|
||||
QCA_EXPORT void scanForPlugins();
|
||||
|
||||
/**
|
||||
* Unload the current plugins
|
||||
Unload the current plugins
|
||||
*/
|
||||
QCA_EXPORT void unloadAllPlugins();
|
||||
|
||||
/**
|
||||
* Retrieve plugin diagnostic text
|
||||
Retrieve plugin diagnostic text
|
||||
*/
|
||||
QCA_EXPORT QString pluginDiagnosticText();
|
||||
|
||||
/**
|
||||
* Clear plugin diagnostic text
|
||||
Clear plugin diagnostic text
|
||||
*/
|
||||
QCA_EXPORT void clearPluginDiagnosticText();
|
||||
|
||||
/**
|
||||
* Add plugin diagnostic text
|
||||
*
|
||||
* This function should only be called by providers.
|
||||
Add plugin diagnostic text
|
||||
|
||||
This function should only be called by providers.
|
||||
*/
|
||||
QCA_EXPORT void appendPluginDiagnosticText(const QString &text);
|
||||
|
||||
/**
|
||||
* Set a global property
|
||||
Set a global property
|
||||
*/
|
||||
QCA_EXPORT void setProperty(const QString &name, const QVariant &value);
|
||||
|
||||
/**
|
||||
* Retrieve a global property
|
||||
Retrieve a global property
|
||||
*/
|
||||
QCA_EXPORT QVariant getProperty(const QString &name);
|
||||
|
||||
/**
|
||||
* Set provider configuration
|
||||
*
|
||||
* Allowed value types: QString, int, bool
|
||||
Set provider configuration
|
||||
|
||||
Allowed value types: QString, int, bool
|
||||
*/
|
||||
QCA_EXPORT void setProviderConfig(const QString &name, const QVariantMap &config);
|
||||
|
||||
/**
|
||||
* Retrieve provider configuration
|
||||
Retrieve provider configuration
|
||||
*/
|
||||
QCA_EXPORT QVariantMap getProviderConfig(const QString &name);
|
||||
|
||||
/**
|
||||
* Save provider configuration to persistent storage
|
||||
Save provider configuration to persistent storage
|
||||
*/
|
||||
QCA_EXPORT void saveProviderConfig(const QString &name);
|
||||
|
||||
/**
|
||||
* Return the name of the global random number provider
|
||||
Return the name of the global random number provider
|
||||
*/
|
||||
QCA_EXPORT QString globalRandomProvider();
|
||||
|
||||
/**
|
||||
* Change the global random number provider
|
||||
*
|
||||
* The Random capabilities of %QCA are provided as part of the
|
||||
* built in capabilities, however the generator can be changed
|
||||
* if required.
|
||||
Change the global random number provider
|
||||
|
||||
The Random capabilities of %QCA are provided as part of the
|
||||
built in capabilities, however the generator can be changed
|
||||
if required.
|
||||
*/
|
||||
QCA_EXPORT void setGlobalRandomProvider(const QString &provider);
|
||||
|
||||
@ -459,70 +456,71 @@ namespace QCA
|
||||
QCA_EXPORT CertificateCollection systemStore();
|
||||
|
||||
/**
|
||||
* Get the application name that will be used by SASL server mode
|
||||
*
|
||||
* The application name is used by SASL in server mode, as some systems might
|
||||
* have different security policies depending on the app.
|
||||
* The default application name is 'qca'
|
||||
Get the application name that will be used by SASL server mode
|
||||
|
||||
The application name is used by SASL in server mode, as some systems might
|
||||
have different security policies depending on the app.
|
||||
The default application name is 'qca'
|
||||
*/
|
||||
QCA_EXPORT QString appName();
|
||||
|
||||
/**
|
||||
* Set the application name that will be used by SASL server mode
|
||||
*
|
||||
* The application name is used by SASL in server mode, as some systems might
|
||||
* have different security policies depending on the app. This should be set
|
||||
* before using SASL objects, and it cannot be changed later.
|
||||
*
|
||||
* \param name the name string to use for SASL server mode
|
||||
Set the application name that will be used by SASL server mode
|
||||
|
||||
The application name is used by SASL in server mode, as some systems might
|
||||
have different security policies depending on the app. This should be set
|
||||
before using SASL objects, and it cannot be changed later.
|
||||
|
||||
\param name the name string to use for SASL server mode
|
||||
*/
|
||||
QCA_EXPORT void setAppName(const QString &name);
|
||||
|
||||
/**
|
||||
* Convert a byte array to printable hexadecimal
|
||||
* representation.
|
||||
*
|
||||
* This is a convenience function to convert an arbitrary
|
||||
* SecureArray to a printable representation.
|
||||
*
|
||||
* \code
|
||||
* SecureArray test(10);
|
||||
* test.fill('a');
|
||||
* // 0x61 is 'a' in ASCII
|
||||
* if (QString("61616161616161616161") == QCA::arrayToHex(test) ) {
|
||||
* printf ("arrayToHex passed\n");
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \param array the array to be converted
|
||||
* \return a printable representation
|
||||
Convert a byte array to printable hexadecimal
|
||||
representation.
|
||||
|
||||
This is a convenience function to convert an arbitrary
|
||||
SecureArray to a printable representation.
|
||||
|
||||
\code
|
||||
SecureArray test(10);
|
||||
test.fill('a');
|
||||
// 0x61 is 'a' in ASCII
|
||||
if (QString("61616161616161616161") == QCA::arrayToHex(test) )
|
||||
{
|
||||
printf ("arrayToHex passed\n");
|
||||
}
|
||||
\endcode
|
||||
|
||||
\param array the array to be converted
|
||||
\return a printable representation
|
||||
*/
|
||||
QCA_EXPORT QString arrayToHex(const SecureArray &array);
|
||||
|
||||
/**
|
||||
* Convert a QString containing a hexadecimal representation
|
||||
* of a byte array into a QByteArray
|
||||
*
|
||||
* This is a convenience function to convert a printable
|
||||
* representation into a QByteArray - effectively the inverse
|
||||
* of QCA::arrayToHex.
|
||||
*
|
||||
* \code
|
||||
* QCA::init();
|
||||
* QByteArray test(10);
|
||||
*
|
||||
* test.fill('b'); // 0x62 in hexadecimal
|
||||
* test[7] = 0x00; // can handle strings with nulls
|
||||
*
|
||||
* if (QCA::hexToArray(QString("62626262626262006262") ) == test ) {
|
||||
* printf ("hexToArray passed\n");
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \param hexString the string containing a printable
|
||||
* representation to be converted
|
||||
* \return the equivalent QByteArray
|
||||
*
|
||||
Convert a QString containing a hexadecimal representation
|
||||
of a byte array into a QByteArray
|
||||
|
||||
This is a convenience function to convert a printable
|
||||
representation into a QByteArray - effectively the inverse
|
||||
of QCA::arrayToHex.
|
||||
|
||||
\code
|
||||
QCA::init();
|
||||
QByteArray test(10);
|
||||
|
||||
test.fill('b'); // 0x62 in hexadecimal
|
||||
test[7] = 0x00; // can handle strings with nulls
|
||||
|
||||
if (QCA::hexToArray(QString("62626262626262006262") ) == test )
|
||||
{
|
||||
printf ("hexToArray passed\n");
|
||||
}
|
||||
\endcode
|
||||
|
||||
\param hexString the string containing a printable
|
||||
representation to be converted
|
||||
\return the equivalent QByteArray
|
||||
*/
|
||||
QCA_EXPORT QByteArray hexToArray(const QString &hexString);
|
||||
|
||||
@ -539,11 +537,11 @@ namespace QCA
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Standard constructor
|
||||
*
|
||||
* \param m the MemoryMode to use for secure memory
|
||||
* \param prealloc the amount of secure memory to pre-allocate,
|
||||
* in units of 1024 bytes (1K).
|
||||
Standard constructor
|
||||
|
||||
\param m the MemoryMode to use for secure memory
|
||||
\param prealloc the amount of secure memory to pre-allocate,
|
||||
in units of 1024 bytes (1K).
|
||||
*/
|
||||
explicit Initializer(MemoryMode m = Practical, int prealloc = 64);
|
||||
~Initializer();
|
||||
@ -575,32 +573,32 @@ namespace QCA
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a %KeyLength object
|
||||
*
|
||||
* \param min the minimum length of the key, in bytes
|
||||
* \param max the maximum length of the key, in bytes
|
||||
* \param multiple the number of bytes that the key must be a
|
||||
* multiple of.
|
||||
Construct a %KeyLength object
|
||||
|
||||
\param min the minimum length of the key, in bytes
|
||||
\param max the maximum length of the key, in bytes
|
||||
\param multiple the number of bytes that the key must be a
|
||||
multiple of.
|
||||
*/
|
||||
KeyLength(int min, int max, int multiple)
|
||||
: _min( min ), _max(max), _multiple( multiple )
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Obtain the minimum length for the key, in bytes
|
||||
Obtain the minimum length for the key, in bytes
|
||||
*/
|
||||
int minimum() const { return _min; }
|
||||
|
||||
/**
|
||||
* Obtain the maximum length for the key, in bytes
|
||||
Obtain the maximum length for the key, in bytes
|
||||
*/
|
||||
int maximum() const { return _max; }
|
||||
|
||||
/**
|
||||
* Return the number of bytes that the key must be a multiple of
|
||||
*
|
||||
* If this is one, then anything between minimum and maximum (inclusive)
|
||||
* is acceptable.
|
||||
Return the number of bytes that the key must be a multiple of
|
||||
|
||||
If this is one, then anything between minimum and maximum (inclusive)
|
||||
is acceptable.
|
||||
*/
|
||||
int multiple() const { return _multiple; }
|
||||
|
||||
@ -629,99 +627,99 @@ namespace QCA
|
||||
class Context;
|
||||
|
||||
/**
|
||||
* Initialisation routine.
|
||||
*
|
||||
* This routine will be called when your plugin
|
||||
* is loaded, so this is a good place to do any
|
||||
* one-off initialisation tasks. If you don't need
|
||||
* any initialisation, just implement it as an empty
|
||||
* routine.
|
||||
Initialisation routine.
|
||||
|
||||
This routine will be called when your plugin
|
||||
is loaded, so this is a good place to do any
|
||||
one-off initialisation tasks. If you don't need
|
||||
any initialisation, just implement it as an empty
|
||||
routine.
|
||||
*/
|
||||
virtual void init();
|
||||
|
||||
/**
|
||||
* Target QCA version for the provider.
|
||||
*
|
||||
* This is used to verify compatibility between the
|
||||
* provider and QCA. For a provider to be used, it
|
||||
* must have major and minor version numbers that are
|
||||
* less-than or equal to the QCA version (the patch
|
||||
* version number is ignored). This means an older
|
||||
* provider may be used with a newer QCA, but a newer
|
||||
* provider cannot be used with an older QCA.
|
||||
Target QCA version for the provider.
|
||||
|
||||
This is used to verify compatibility between the
|
||||
provider and QCA. For a provider to be used, it
|
||||
must have major and minor version numbers that are
|
||||
less-than or equal to the QCA version (the patch
|
||||
version number is ignored). This means an older
|
||||
provider may be used with a newer QCA, but a newer
|
||||
provider cannot be used with an older QCA.
|
||||
*/
|
||||
virtual int version() const = 0;
|
||||
|
||||
/**
|
||||
* The name of the provider.
|
||||
*
|
||||
* Typically you just return a string containing a
|
||||
* convenient name.
|
||||
*
|
||||
* \code
|
||||
* QString name() const
|
||||
* {
|
||||
* return "qca-myplugin";
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \note The name is used to tell if a provider is
|
||||
* already loaded, so you need to make sure it is
|
||||
* unique amongst the various plugins.
|
||||
The name of the provider.
|
||||
|
||||
Typically you just return a string containing a
|
||||
convenient name.
|
||||
|
||||
\code
|
||||
QString name() const
|
||||
{
|
||||
return "qca-myplugin";
|
||||
}
|
||||
\endcode
|
||||
|
||||
\note The name is used to tell if a provider is
|
||||
already loaded, so you need to make sure it is
|
||||
unique amongst the various plugins.
|
||||
*/
|
||||
virtual QString name() const = 0;
|
||||
|
||||
/**
|
||||
* The capabilities (algorithms) of the provider.
|
||||
*
|
||||
* Typically you just return a fixed QStringList:
|
||||
* \code
|
||||
* QStringList features() const
|
||||
* {
|
||||
* QStringList list;
|
||||
* list += "sha1";
|
||||
* list += "sha256";
|
||||
* list += "hmac(md5)";
|
||||
* return list;
|
||||
* }
|
||||
* \endcode
|
||||
The capabilities (algorithms) of the provider.
|
||||
|
||||
Typically you just return a fixed QStringList:
|
||||
\code
|
||||
QStringList features() const
|
||||
{
|
||||
QStringList list;
|
||||
list += "sha1";
|
||||
list += "sha256";
|
||||
list += "hmac(md5)";
|
||||
return list;
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
virtual QStringList features() const = 0;
|
||||
|
||||
/**
|
||||
* Optional credit text for the provider.
|
||||
*
|
||||
* You might display this information in a credits or
|
||||
* "About" dialog. Returns an empty string if the
|
||||
* provider has no credit text.
|
||||
Optional credit text for the provider.
|
||||
|
||||
You might display this information in a credits or
|
||||
"About" dialog. Returns an empty string if the
|
||||
provider has no credit text.
|
||||
*/
|
||||
virtual QString credit() const;
|
||||
|
||||
/**
|
||||
* Routine to create a plugin context
|
||||
*
|
||||
* You need to return a pointer to an algorithm
|
||||
* Context that corresponds with the algorithm
|
||||
* name specified.
|
||||
*
|
||||
* \param type the name of the algorithm required
|
||||
*
|
||||
* \code
|
||||
* Context *createContext(const QString &type)
|
||||
* {
|
||||
* if ( type == "sha1" )
|
||||
* return new SHA1Context( this );
|
||||
* else if ( type == "sha256" )
|
||||
* return new SHA0256Context( this );
|
||||
* else if ( type == "hmac(sha1)" )
|
||||
* return new HMACSHA1Context( this );
|
||||
* else
|
||||
* return 0;
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* Naturally you also need to implement
|
||||
* the specified Context subclasses as well.
|
||||
Routine to create a plugin context
|
||||
|
||||
You need to return a pointer to an algorithm
|
||||
Context that corresponds with the algorithm
|
||||
name specified.
|
||||
|
||||
\param type the name of the algorithm required
|
||||
|
||||
\code
|
||||
Context *createContext(const QString &type)
|
||||
{
|
||||
if ( type == "sha1" )
|
||||
return new SHA1Context( this );
|
||||
else if ( type == "sha256" )
|
||||
return new SHA0256Context( this );
|
||||
else if ( type == "hmac(sha1)" )
|
||||
return new HMACSHA1Context( this );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Naturally you also need to implement
|
||||
the specified Context subclasses as well.
|
||||
*/
|
||||
virtual Context *createContext(const QString &type) = 0;
|
||||
|
||||
@ -1021,38 +1019,37 @@ namespace QCA
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct an empty (zero length) key
|
||||
Construct an empty (zero length) key
|
||||
*/
|
||||
SymmetricKey();
|
||||
|
||||
/**
|
||||
* Construct an key of specified size, with random contents
|
||||
*
|
||||
* This is intended to be used as a random session key.
|
||||
*
|
||||
* \param size the number of bytes for the key
|
||||
*
|
||||
Construct an key of specified size, with random contents
|
||||
|
||||
This is intended to be used as a random session key.
|
||||
|
||||
\param size the number of bytes for the key
|
||||
*/
|
||||
SymmetricKey(int size);
|
||||
|
||||
/**
|
||||
* Construct a key from a provided byte array
|
||||
*
|
||||
* \param a the byte array to copy
|
||||
Construct a key from a provided byte array
|
||||
|
||||
\param a the byte array to copy
|
||||
*/
|
||||
SymmetricKey(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* Construct a key from a provided byte array
|
||||
*
|
||||
* \param a the byte array to copy
|
||||
Construct a key from a provided byte array
|
||||
|
||||
\param a the byte array to copy
|
||||
*/
|
||||
SymmetricKey(const QByteArray &a);
|
||||
|
||||
/**
|
||||
* Test for weak DES keys
|
||||
*
|
||||
* \return true if the key is a weak key for DES
|
||||
Test for weak DES keys
|
||||
|
||||
\return true if the key is a weak key for DES
|
||||
*/
|
||||
bool isWeakDESKey();
|
||||
};
|
||||
@ -1491,6 +1488,7 @@ namespace QCA
|
||||
friend class Private;
|
||||
Private *d;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -47,8 +47,8 @@
|
||||
#include "qca_export.h"
|
||||
#include "qca_tools.h"
|
||||
|
||||
namespace QCA
|
||||
{
|
||||
namespace QCA {
|
||||
|
||||
QCA_EXPORT QByteArray methodReturnType(const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> argTypes);
|
||||
QCA_EXPORT bool invokeMethodWithVariants(QObject *obj, const QByteArray &method, const QVariantList &args, QVariant *ret, Qt::ConnectionType type = Qt::AutoConnection);
|
||||
|
||||
@ -371,9 +371,7 @@ namespace QCA
|
||||
|
||||
\return Current level
|
||||
*/
|
||||
inline Logger::Severity level () const {
|
||||
return m_logLevel;
|
||||
}
|
||||
inline Logger::Severity level () const { return m_logLevel; }
|
||||
|
||||
/**
|
||||
Set the current logging level
|
||||
@ -489,6 +487,7 @@ namespace QCA
|
||||
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,8 +34,8 @@
|
||||
|
||||
#include "qca_core.h"
|
||||
|
||||
namespace QCA
|
||||
{
|
||||
namespace QCA {
|
||||
|
||||
/**
|
||||
\class TextFilter qca_textfilter.h QtCrypto
|
||||
|
||||
@ -288,6 +288,7 @@ namespace QCA
|
||||
bool _lb_enabled;
|
||||
int _lb_column;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -87,199 +87,193 @@ namespace QCA {
|
||||
cleared first.
|
||||
|
||||
Note that this class is implicitly shared (that is, copy on write).
|
||||
**/
|
||||
*/
|
||||
class QCA_EXPORT SecureArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a secure byte array, zero length
|
||||
Construct a secure byte array, zero length
|
||||
*/
|
||||
SecureArray();
|
||||
|
||||
/**
|
||||
* Construct a secure byte array of the specified length
|
||||
*
|
||||
* \param size the number of bytes in the array
|
||||
* \param ch the value every byte should be set to
|
||||
Construct a secure byte array of the specified length
|
||||
|
||||
\param size the number of bytes in the array
|
||||
\param ch the value every byte should be set to
|
||||
*/
|
||||
explicit SecureArray(int size, char ch = 0);
|
||||
|
||||
/**
|
||||
* Construct a secure byte array from a string
|
||||
*
|
||||
* Note that this copies, rather than references the source array
|
||||
Construct a secure byte array from a string
|
||||
|
||||
Note that this copies, rather than references the source array
|
||||
*/
|
||||
SecureArray(const char *str);
|
||||
|
||||
/**
|
||||
* Construct a secure byte array from a QByteArray
|
||||
*
|
||||
* Note that this copies, rather than references the source array
|
||||
*
|
||||
* \sa operator=()
|
||||
Construct a secure byte array from a QByteArray
|
||||
|
||||
Note that this copies, rather than references the source array
|
||||
|
||||
\sa operator=()
|
||||
*/
|
||||
SecureArray(const QByteArray &a);
|
||||
|
||||
/**
|
||||
* Construct a (shallow) copy of another secure byte array
|
||||
*
|
||||
* \param from the source of the data and length.
|
||||
Construct a (shallow) copy of another secure byte array
|
||||
|
||||
\param from the source of the data and length.
|
||||
*/
|
||||
SecureArray(const SecureArray &from);
|
||||
|
||||
~SecureArray();
|
||||
|
||||
/**
|
||||
* Creates a reference, rather than a deep copy.
|
||||
* if you want a deep copy then you should use copy()
|
||||
* instead, or use operator=(), then call detach() when required.
|
||||
Creates a reference, rather than a deep copy.
|
||||
*/
|
||||
SecureArray & operator=(const SecureArray &from);
|
||||
|
||||
/**
|
||||
* Creates a copy, rather than references
|
||||
*
|
||||
* \param a the array to copy from
|
||||
Creates a copy, rather than references
|
||||
|
||||
\param a the array to copy from
|
||||
*/
|
||||
SecureArray & operator=(const QByteArray &a);
|
||||
|
||||
/**
|
||||
* Clears the contents of the array and makes it empty
|
||||
Clears the contents of the array and makes it empty
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Returns a reference to the byte at the index position
|
||||
*
|
||||
* \param index the zero-based offset to obtain
|
||||
Returns a reference to the byte at the index position
|
||||
|
||||
\param index the zero-based offset to obtain
|
||||
*/
|
||||
char & operator[](int index);
|
||||
|
||||
/**
|
||||
* Returns a reference to the byte at the index position
|
||||
*
|
||||
* \param index the zero-based offset to obtain
|
||||
Returns a reference to the byte at the index position
|
||||
|
||||
\param index the zero-based offset to obtain
|
||||
*/
|
||||
const char & operator[](int index) const;
|
||||
|
||||
/**
|
||||
* Pointer to the data in the secure array
|
||||
*
|
||||
* You can use this for memcpy and similar functions. If you are trying
|
||||
* to obtain data at a particular offset, you might be better off using
|
||||
* at() or operator[]
|
||||
*
|
||||
Pointer to the data in the secure array
|
||||
|
||||
You can use this for memcpy and similar functions. If you are trying
|
||||
to obtain data at a particular offset, you might be better off using
|
||||
at() or operator[]
|
||||
*/
|
||||
char *data();
|
||||
|
||||
/**
|
||||
* Pointer to the data in the secure array
|
||||
*
|
||||
* You can use this for memcpy and similar functions. If you are trying
|
||||
* to obtain data at a particular offset, you might be better off using
|
||||
* at() or operator[]
|
||||
*
|
||||
Pointer to the data in the secure array
|
||||
|
||||
You can use this for memcpy and similar functions. If you are trying
|
||||
to obtain data at a particular offset, you might be better off using
|
||||
at() or operator[]
|
||||
*/
|
||||
const char *data() const;
|
||||
|
||||
/**
|
||||
* Pointer to the data in the secure array
|
||||
*
|
||||
* You can use this for memcpy and similar functions. If you are trying
|
||||
* to obtain data at a particular offset, you might be better off using
|
||||
* at() or operator[]
|
||||
*
|
||||
Pointer to the data in the secure array
|
||||
|
||||
You can use this for memcpy and similar functions. If you are trying
|
||||
to obtain data at a particular offset, you might be better off using
|
||||
at() or operator[]
|
||||
*/
|
||||
const char *constData() const;
|
||||
|
||||
/**
|
||||
* Returns a reference to the byte at the index position
|
||||
*
|
||||
* \param index the zero-based offset to obtain
|
||||
Returns a reference to the byte at the index position
|
||||
|
||||
\param index the zero-based offset to obtain
|
||||
*/
|
||||
char & at(int index);
|
||||
|
||||
/**
|
||||
* Returns a reference to the byte at the index position
|
||||
*
|
||||
* \param index the zero-based offset to obtain
|
||||
Returns a reference to the byte at the index position
|
||||
|
||||
\param index the zero-based offset to obtain
|
||||
*/
|
||||
const char & at(int index) const;
|
||||
|
||||
/**
|
||||
* Returns the number of bytes in the array
|
||||
Returns the number of bytes in the array
|
||||
*/
|
||||
int size() const;
|
||||
|
||||
/**
|
||||
* Test if the array contains any bytes.
|
||||
*
|
||||
* This is equivalent to testing (size() != 0). Note that if
|
||||
* the array is allocated, isEmpty() is false (even if no data
|
||||
* has been added)
|
||||
*
|
||||
* \return true if the array has zero length, otherwise false
|
||||
Test if the array contains any bytes.
|
||||
|
||||
This is equivalent to testing (size() != 0). Note that if
|
||||
the array is allocated, isEmpty() is false (even if no data
|
||||
has been added)
|
||||
|
||||
\return true if the array has zero length, otherwise false
|
||||
*/
|
||||
bool isEmpty() const;
|
||||
|
||||
/**
|
||||
* Change the length of this array
|
||||
* If the new length is less than the old length, the extra information
|
||||
* is (safely) discarded. If the new length is equal to or greater than
|
||||
* the old length, the existing data is copied into the array.
|
||||
*
|
||||
* \param size the new length
|
||||
Change the length of this array
|
||||
If the new length is less than the old length, the extra information
|
||||
is (safely) discarded. If the new length is equal to or greater than
|
||||
the old length, the existing data is copied into the array.
|
||||
|
||||
\param size the new length
|
||||
*/
|
||||
bool resize(int size);
|
||||
|
||||
/**
|
||||
* Fill the data array with a specified character
|
||||
*
|
||||
* \param fillChar the character to use as the fill
|
||||
* \param fillToPosition the number of characters to fill
|
||||
* to. If not specified (or -1), fills array to
|
||||
* current length.
|
||||
*
|
||||
* \note This function does not extend the array - if
|
||||
* you ask for fill beyond the current length, only
|
||||
* the current length will be used.
|
||||
* \note The number of characters is 1 based, so if
|
||||
* you ask for fill('x', 10), it will fill from
|
||||
*
|
||||
Fill the data array with a specified character
|
||||
|
||||
\param fillChar the character to use as the fill
|
||||
\param fillToPosition the number of characters to fill
|
||||
to. If not specified (or -1), fills array to
|
||||
current length.
|
||||
|
||||
\note This function does not extend the array - if
|
||||
you ask for fill beyond the current length, only
|
||||
the current length will be used.
|
||||
\note The number of characters is 1 based, so if
|
||||
you ask for fill('x', 10), it will fill from
|
||||
*/
|
||||
void fill(char fillChar, int fillToPosition = -1);
|
||||
|
||||
/**
|
||||
* Copy the contents of the secure array out to a
|
||||
* standard QByteArray. Note that this performs a deep copy
|
||||
* of the data.
|
||||
Copy the contents of the secure array out to a
|
||||
standard QByteArray. Note that this performs a deep copy
|
||||
of the data.
|
||||
*/
|
||||
QByteArray toByteArray() const;
|
||||
|
||||
/**
|
||||
* Append a secure byte array to the end of this array
|
||||
Append a secure byte array to the end of this array
|
||||
*/
|
||||
SecureArray & append(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* Append a secure byte array to the end of this array
|
||||
Append a secure byte array to the end of this array
|
||||
*/
|
||||
SecureArray & operator+=(const SecureArray &a);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Assign the contents of a provided byte array to this
|
||||
* object.
|
||||
*
|
||||
* \param from the byte array to copy
|
||||
Assign the contents of a provided byte array to this
|
||||
object.
|
||||
|
||||
\param from the byte array to copy
|
||||
*/
|
||||
void set(const SecureArray &from);
|
||||
|
||||
/**
|
||||
* Assign the contents of a provided byte array to this
|
||||
* object.
|
||||
*
|
||||
* \param from the byte array to copy
|
||||
Assign the contents of a provided byte array to this
|
||||
object.
|
||||
|
||||
\param from the byte array to copy
|
||||
*/
|
||||
void set(const QByteArray &from);
|
||||
|
||||
@ -289,27 +283,27 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true if the two SecureArray
|
||||
* arguments have the same data (and the same length, of course).
|
||||
*
|
||||
* \relates SecureArray
|
||||
**/
|
||||
Equality operator. Returns true if the two SecureArray
|
||||
arguments have the same data (and the same length, of course).
|
||||
|
||||
\relates SecureArray
|
||||
*/
|
||||
QCA_EXPORT bool operator==(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
* Inequality operator. Returns true if the two SecureArray
|
||||
* arguments have different length, or the same length but
|
||||
* different data
|
||||
*
|
||||
* \relates SecureArray
|
||||
**/
|
||||
Inequality operator. Returns true if the two SecureArray
|
||||
arguments have different length, or the same length but
|
||||
different data
|
||||
|
||||
\relates SecureArray
|
||||
*/
|
||||
QCA_EXPORT bool operator!=(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
* Returns an array that is the result of concatenating a and b
|
||||
*
|
||||
* \relates SecureArray
|
||||
**/
|
||||
Returns an array that is the result of concatenating a and b
|
||||
|
||||
\relates SecureArray
|
||||
*/
|
||||
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
@ -325,178 +319,177 @@ QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &
|
||||
// do something
|
||||
}
|
||||
\endcode
|
||||
**/
|
||||
*/
|
||||
class QCA_EXPORT BigInteger
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Creates a new BigInteger, initialised to zero.
|
||||
Constructor. Creates a new BigInteger, initialised to zero.
|
||||
*/
|
||||
BigInteger();
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param n an alternative integer initialisation value.
|
||||
\overload
|
||||
|
||||
\param n an alternative integer initialisation value.
|
||||
*/
|
||||
BigInteger(int n);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param c an alternative initialisation value, encoded as a character array
|
||||
*
|
||||
* \code
|
||||
* BigInteger b ( "9890343" );
|
||||
* \endcode
|
||||
\overload
|
||||
|
||||
\param c an alternative initialisation value, encoded as a character array
|
||||
|
||||
\code
|
||||
BigInteger b ( "9890343" );
|
||||
\endcode
|
||||
*/
|
||||
BigInteger(const char *c);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param s an alternative initialisation value, encoded as a string
|
||||
\overload
|
||||
|
||||
\param s an alternative initialisation value, encoded as a string
|
||||
*/
|
||||
BigInteger(const QString &s);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param a an alternative initialisation value, encoded as SecureArray
|
||||
\overload
|
||||
|
||||
\param a an alternative initialisation value, encoded as SecureArray
|
||||
*/
|
||||
BigInteger(const QCA::SecureArray &a);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param from an alternative initialisation value, encoded as a %BigInteger
|
||||
\overload
|
||||
|
||||
\param from an alternative initialisation value, encoded as a %BigInteger
|
||||
*/
|
||||
BigInteger(const BigInteger &from);
|
||||
|
||||
~BigInteger();
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*
|
||||
* \param from the BigInteger to copy from
|
||||
*
|
||||
* \code
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a = b; // a is now 500
|
||||
* \endcode
|
||||
Assignment operator
|
||||
|
||||
\param from the BigInteger to copy from
|
||||
|
||||
\code
|
||||
BigInteger a; // a is zero
|
||||
BigInteger b( 500 );
|
||||
a = b; // a is now 500
|
||||
\endcode
|
||||
*/
|
||||
BigInteger & operator=(const BigInteger &from);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param s the QString containing an integer representation
|
||||
*
|
||||
* \sa bool fromString(const QString &s)
|
||||
*
|
||||
* \note it is the application's responsibility to make sure
|
||||
* that the QString represents a valid integer (ie it only
|
||||
* contains numbers and an optional minus sign at the start)
|
||||
*
|
||||
**/
|
||||
\overload
|
||||
|
||||
\param s the QString containing an integer representation
|
||||
|
||||
\sa bool fromString(const QString &s)
|
||||
|
||||
\note it is the application's responsibility to make sure
|
||||
that the QString represents a valid integer (ie it only
|
||||
contains numbers and an optional minus sign at the start)
|
||||
*/
|
||||
BigInteger & operator=(const QString &s);
|
||||
|
||||
/**
|
||||
* Increment in place operator
|
||||
*
|
||||
* \param b the amount to increment by
|
||||
*
|
||||
* \code
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a += b; // a is now 500
|
||||
* a += b; // a is now 1000
|
||||
* \endcode
|
||||
**/
|
||||
Increment in place operator
|
||||
|
||||
\param b the amount to increment by
|
||||
|
||||
\code
|
||||
BigInteger a; // a is zero
|
||||
BigInteger b( 500 );
|
||||
a += b; // a is now 500
|
||||
a += b; // a is now 1000
|
||||
\endcode
|
||||
*/
|
||||
BigInteger & operator+=(const BigInteger &b);
|
||||
|
||||
/**
|
||||
* Decrement in place operator
|
||||
*
|
||||
* \param b the amount to decrement by
|
||||
*
|
||||
* \code
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a -= b; // a is now -500
|
||||
* a -= b; // a is now -1000
|
||||
* \endcode
|
||||
**/
|
||||
Decrement in place operator
|
||||
|
||||
\param b the amount to decrement by
|
||||
|
||||
\code
|
||||
BigInteger a; // a is zero
|
||||
BigInteger b( 500 );
|
||||
a -= b; // a is now -500
|
||||
a -= b; // a is now -1000
|
||||
\endcode
|
||||
*/
|
||||
BigInteger & operator-=(const BigInteger &b);
|
||||
|
||||
/**
|
||||
* Output %BigInteger as a byte array, useful for storage or
|
||||
* transmission. The format is a binary integer in sign-extended
|
||||
* network-byte-order.
|
||||
*
|
||||
* \sa void fromArray(const SecureArray &a);
|
||||
Output %BigInteger as a byte array, useful for storage or
|
||||
transmission. The format is a binary integer in sign-extended
|
||||
network-byte-order.
|
||||
|
||||
\sa void fromArray(const SecureArray &a);
|
||||
*/
|
||||
QCA::SecureArray toArray() const;
|
||||
|
||||
/**
|
||||
* Assign from an array. The input is expected to be a binary integer
|
||||
* in sign-extended network-byte-order.
|
||||
*
|
||||
* \param a a SecureArray that represents an integer
|
||||
*
|
||||
* \sa BigInteger(const SecureArray &a);
|
||||
* \sa SecureArray toArray() const;
|
||||
Assign from an array. The input is expected to be a binary integer
|
||||
in sign-extended network-byte-order.
|
||||
|
||||
\param a a SecureArray that represents an integer
|
||||
|
||||
\sa BigInteger(const SecureArray &a);
|
||||
\sa SecureArray toArray() const;
|
||||
*/
|
||||
void fromArray(const QCA::SecureArray &a);
|
||||
|
||||
/**
|
||||
* Convert %BigInteger to a QString
|
||||
*
|
||||
* \code
|
||||
* QString aString;
|
||||
* BigInteger aBiggishInteger( 5878990 );
|
||||
* aString = aBiggishInteger.toString(); // aString is now "5878990"
|
||||
* \endcode
|
||||
Convert %BigInteger to a QString
|
||||
|
||||
\code
|
||||
QString aString;
|
||||
BigInteger aBiggishInteger( 5878990 );
|
||||
aString = aBiggishInteger.toString(); // aString is now "5878990"
|
||||
\endcode
|
||||
*/
|
||||
QString toString() const;
|
||||
|
||||
/**
|
||||
* Assign from a QString
|
||||
*
|
||||
* \param s a QString that represents an integer
|
||||
*
|
||||
* \note it is the application's responsibility to make sure
|
||||
* that the QString represents a valid integer (ie it only
|
||||
* contains numbers and an optional minus sign at the start)
|
||||
*
|
||||
* \sa BigInteger(const QString &s)
|
||||
* \sa BigInteger & operator=(const QString &s)
|
||||
Assign from a QString
|
||||
|
||||
\param s a QString that represents an integer
|
||||
|
||||
\note it is the application's responsibility to make sure
|
||||
that the QString represents a valid integer (ie it only
|
||||
contains numbers and an optional minus sign at the start)
|
||||
|
||||
\sa BigInteger(const QString &s)
|
||||
\sa BigInteger & operator=(const QString &s)
|
||||
*/
|
||||
bool fromString(const QString &s);
|
||||
|
||||
/**
|
||||
* Compare this value with another %BigInteger
|
||||
*
|
||||
* Normally it is more readable to use one of the operator overloads,
|
||||
* so you don't need to use this method directly.
|
||||
*
|
||||
* \param n the BigInteger to compare with
|
||||
*
|
||||
* \return zero if the values are the same, negative if the argument
|
||||
* is less than the value of this BigInteger, and positive if the argument
|
||||
* value is greater than this BigInteger
|
||||
*
|
||||
* \code
|
||||
* BigInteger a( "400" );
|
||||
* BigInteger b( "-400" );
|
||||
* BigInteger c( " 200 " );
|
||||
* int result;
|
||||
* result = a.compare( b ); // return positive 400 > -400
|
||||
* result = a.compare( c ); // return positive, 400 > 200
|
||||
* result = b.compare( c ); // return negative, -400 < 200
|
||||
* \endcode
|
||||
**/
|
||||
Compare this value with another %BigInteger
|
||||
|
||||
Normally it is more readable to use one of the operator overloads,
|
||||
so you don't need to use this method directly.
|
||||
|
||||
\param n the BigInteger to compare with
|
||||
|
||||
\return zero if the values are the same, negative if the argument
|
||||
is less than the value of this BigInteger, and positive if the argument
|
||||
value is greater than this BigInteger
|
||||
|
||||
\code
|
||||
BigInteger a( "400" );
|
||||
BigInteger b( "-400" );
|
||||
BigInteger c( " 200 " );
|
||||
int result;
|
||||
result = a.compare( b ); // return positive 400 > -400
|
||||
result = a.compare( c ); // return positive, 400 > 200
|
||||
result = b.compare( c ); // return negative, -400 < 200
|
||||
\endcode
|
||||
*/
|
||||
int compare(const BigInteger &n) const;
|
||||
|
||||
private:
|
||||
@ -505,80 +498,80 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true if the two BigInteger values
|
||||
* are the same, including having the same sign.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Equality operator. Returns true if the two BigInteger values
|
||||
are the same, including having the same sign
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator==(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (0 == a.compare( b ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Inequality operator. Returns true if the two BigInteger values
|
||||
* are different in magnitude, sign or both
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Inequality operator. Returns true if the two BigInteger values
|
||||
are different in magnitude, sign or both
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator!=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (0 != a.compare( b ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Less than or equal operator. Returns true if the BigInteger value
|
||||
* on the left hand side is equal to or less than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Less than or equal operator. Returns true if the BigInteger value
|
||||
on the left hand side is equal to or less than the BigInteger value
|
||||
on the right hand side.
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator<=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) <= 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater than or equal operator. Returns true if the BigInteger value
|
||||
* on the left hand side is equal to or greater than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Greater than or equal operator. Returns true if the BigInteger value
|
||||
on the left hand side is equal to or greater than the BigInteger value
|
||||
on the right hand side.
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator>=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) >= 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Less than operator. Returns true if the BigInteger value
|
||||
* on the left hand side is less than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Less than operator. Returns true if the BigInteger value
|
||||
on the left hand side is less than the BigInteger value
|
||||
on the right hand side.
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator<(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) < 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater than operator. Returns true if the BigInteger value
|
||||
* on the left hand side is greater than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Greater than operator. Returns true if the BigInteger value
|
||||
on the left hand side is greater than the BigInteger value
|
||||
on the right hand side.
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
inline bool operator>(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) > 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream operator.
|
||||
*
|
||||
* \relates BigInteger
|
||||
**/
|
||||
Stream operator
|
||||
|
||||
\relates BigInteger
|
||||
*/
|
||||
QCA_EXPORT QTextStream &operator<<(QTextStream &stream, const BigInteger &b);
|
||||
|
||||
}
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "qca_core.h"
|
||||
#include <QMutex>
|
||||
|
||||
namespace QCA
|
||||
{
|
||||
namespace QCA {
|
||||
|
||||
class ProviderItem;
|
||||
|
||||
class ProviderManager
|
||||
@ -66,6 +66,7 @@ namespace QCA
|
||||
void addItem(ProviderItem *i, int priority);
|
||||
bool haveAlready(const QString &name) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -25,10 +25,11 @@
|
||||
|
||||
#include "qca_cert.h"
|
||||
|
||||
namespace QCA
|
||||
{
|
||||
namespace QCA {
|
||||
|
||||
bool qca_have_systemstore();
|
||||
CertificateCollection qca_get_systemstore(const QString &provider);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user