mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-27 12:04:31 +00:00
begin the v2 revolution
svn path=/trunk/kdesupport/qca/; revision=359753
This commit is contained in:
parent
825ffc9229
commit
7989371c0d
52
src/qca.cpp
52
src/qca.cpp
@ -121,7 +121,7 @@ bool haveSecureMemory()
|
||||
}
|
||||
|
||||
bool isSupported(const QStringList &features);
|
||||
|
||||
#if 0
|
||||
bool isSupported(int capabilities)
|
||||
{
|
||||
init();
|
||||
@ -139,7 +139,7 @@ bool isSupported(int capabilities)
|
||||
|
||||
return false;*/
|
||||
}
|
||||
|
||||
#endif
|
||||
bool isSupported(const QStringList &features)
|
||||
{
|
||||
if(!qca_init)
|
||||
@ -157,9 +157,9 @@ bool isSupported(const QStringList &features)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*bool isSupported(const QString &features)
|
||||
bool isSupported(const char *features)
|
||||
{
|
||||
return isSupported(QStringList::split(',', features));
|
||||
return isSupported(QStringList::split(',', QString(features)));
|
||||
}
|
||||
|
||||
QStringList supportedFeatures()
|
||||
@ -175,15 +175,15 @@ QStringList defaultFeatures()
|
||||
{
|
||||
init();
|
||||
return manager->find("default")->features();
|
||||
}*/
|
||||
}
|
||||
|
||||
void insertProvider(QCAProvider *p)
|
||||
/*void insertProvider(QCAProvider *p)
|
||||
{
|
||||
init();
|
||||
manager->add(p);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*bool insertProvider(Provider *p, int priority)
|
||||
bool insertProvider(Provider *p, int priority)
|
||||
{
|
||||
init();
|
||||
return manager->add(p, priority);
|
||||
@ -201,7 +201,7 @@ const ProviderList & providers()
|
||||
{
|
||||
init();
|
||||
return manager->providers();
|
||||
}*/
|
||||
}
|
||||
|
||||
void unloadAllPlugins()
|
||||
{
|
||||
@ -267,7 +267,7 @@ void qca_secure_free(void *p)
|
||||
|
||||
namespace QCA {
|
||||
|
||||
static void *getContext(int cap)
|
||||
/*static void *getContext(int cap)
|
||||
{
|
||||
init();
|
||||
|
||||
@ -276,7 +276,7 @@ static void *getContext(int cap)
|
||||
return 0;
|
||||
|
||||
return manager->findFor(cap)->context(cap);
|
||||
}
|
||||
}*/
|
||||
|
||||
static Provider::Context *getContext(const QString &type, const QString &provider)
|
||||
{
|
||||
@ -313,7 +313,7 @@ static Provider::Context *getContext(const QString &type, const QString &provide
|
||||
|
||||
return p->createContext(type);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static bool detectContext(void *in, Provider::Context **z, void **c)
|
||||
{
|
||||
// format is 'J' + type
|
||||
@ -331,7 +331,7 @@ static bool detectContext(void *in, Provider::Context **z, void **c)
|
||||
|
||||
// try old plugin
|
||||
void *oc = 0;
|
||||
if(type == "sha0")
|
||||
/*if(type == "sha0")
|
||||
oc = getContext(CAP_SHA0);
|
||||
else if(type == "sha1")
|
||||
oc = getContext(CAP_SHA1);
|
||||
@ -344,7 +344,7 @@ static bool detectContext(void *in, Provider::Context **z, void **c)
|
||||
else if(type == "md5")
|
||||
oc = getContext(CAP_MD5);
|
||||
else if(type == "ripemd160")
|
||||
oc = getContext(CAP_RIPEMD160);
|
||||
oc = getContext(CAP_RIPEMD160);*/
|
||||
if(oc)
|
||||
{
|
||||
*z = 0;
|
||||
@ -354,7 +354,7 @@ static bool detectContext(void *in, Provider::Context **z, void **c)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
//----------------------------------------------------------------------------
|
||||
// Initializer
|
||||
//----------------------------------------------------------------------------
|
||||
@ -601,12 +601,9 @@ void Algorithm::change(Provider::Context *c)
|
||||
|
||||
void Algorithm::change(const QString &type, const QString &provider)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
Q_UNUSED(provider);
|
||||
d->delContext();
|
||||
// TODO
|
||||
//if(!type.isEmpty())
|
||||
// d->setContext(getContext(type, provider));
|
||||
if(!type.isEmpty())
|
||||
d->setContext(getContext(type, provider));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -689,7 +686,7 @@ using namespace QCA;
|
||||
//----------------------------------------------------------------------------
|
||||
// Hash
|
||||
//----------------------------------------------------------------------------
|
||||
class Hash::Private
|
||||
/*class Hash::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
@ -770,13 +767,13 @@ QByteArray Hash::final()
|
||||
else
|
||||
buf = d->z->final().toByteArray();
|
||||
return buf;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cipher
|
||||
//----------------------------------------------------------------------------
|
||||
class Cipher::Private
|
||||
/*class Cipher::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
@ -898,8 +895,8 @@ QByteArray Cipher::final(bool *ok)
|
||||
*ok = true;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
//----------------------------------------------------------------------------
|
||||
// SHA0
|
||||
//----------------------------------------------------------------------------
|
||||
@ -960,8 +957,8 @@ RIPEMD160::RIPEMD160()
|
||||
:Hash((QCA_HashContext *)"Jripemd160")//getContext(CAP_RIPEMD160))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
#if 0
|
||||
//----------------------------------------------------------------------------
|
||||
// BlowFish
|
||||
//----------------------------------------------------------------------------
|
||||
@ -1969,3 +1966,4 @@ QByteArray SASL::readOutgoing()
|
||||
d->outbuf.resize(0);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
110
src/qca.h
110
src/qca.h
@ -411,7 +411,7 @@ namespace QCA
|
||||
class Random;
|
||||
typedef QPtrList<Provider> ProviderList;
|
||||
typedef QPtrListIterator<Provider> ProviderListIterator;
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* A list of the capabilities available within QCA
|
||||
*
|
||||
@ -444,7 +444,7 @@ namespace QCA
|
||||
* RFC1320 (MD4) */
|
||||
CAP_RIPEMD160 = 0x4000, /**< RIPEMD digest hash, 160 bits (RIPEMD160)*/
|
||||
}; // to be obsoleted
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Mode settings for cipher algorithms
|
||||
*/
|
||||
@ -454,6 +454,7 @@ namespace QCA
|
||||
CFB = 0x0002 /**< operate in %Cipher FeedBack mode */
|
||||
};
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Direction settings for cipher algorithms
|
||||
*/
|
||||
@ -462,7 +463,7 @@ namespace QCA
|
||||
Encrypt = 0x0001, /**< cipher algorithm should encrypt */
|
||||
Decrypt = 0x0002 /**< cipher algorithm should decrypt */
|
||||
};
|
||||
|
||||
#endif
|
||||
enum MemoryMode
|
||||
{
|
||||
Practical, /**< mlock and drop root if available, else mmap */
|
||||
@ -543,17 +544,17 @@ namespace QCA
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
QCA_EXPORT bool isSupported(int capabilities); // to be obsoleted
|
||||
QCA_EXPORT void insertProvider(QCAProvider *); // to be obsoleted
|
||||
//QCA_EXPORT bool isSupported(int capabilities); // to be obsoleted
|
||||
//QCA_EXPORT void insertProvider(QCAProvider *); // to be obsoleted
|
||||
|
||||
// version 2 global functions
|
||||
//QCA_EXPORT bool isSupported(const QStringList &features);
|
||||
//QCA_EXPORT bool isSupported(const QString &features);
|
||||
//QCA_EXPORT QStringList supportedFeatures();
|
||||
//QCA_EXPORT QStringList defaultFeatures();
|
||||
//QCA_EXPORT bool insertProvider(Provider *p, int priority = 0);
|
||||
//QCA_EXPORT void setProviderPriority(const QString &name, int priority);
|
||||
//QCA_EXPORT const ProviderList & providers();
|
||||
QCA_EXPORT bool isSupported(const QStringList &features);
|
||||
QCA_EXPORT bool isSupported(const char *features);
|
||||
QCA_EXPORT QStringList supportedFeatures();
|
||||
QCA_EXPORT QStringList defaultFeatures();
|
||||
QCA_EXPORT bool insertProvider(Provider *p, int priority = 0);
|
||||
QCA_EXPORT void setProviderPriority(const QString &name, int priority);
|
||||
QCA_EXPORT const ProviderList & providers();
|
||||
QCA_EXPORT void unloadAllPlugins();
|
||||
|
||||
QCA_EXPORT Random & globalRNG();
|
||||
@ -792,6 +793,22 @@ namespace QCA
|
||||
InitializationVector & operator=(const QSecureArray &a);
|
||||
};
|
||||
|
||||
class QCA_EXPORT Hash : public Algorithm, public BufferedComputation
|
||||
{
|
||||
public:
|
||||
virtual void clear();
|
||||
virtual void update(const QSecureArray &a);
|
||||
virtual QSecureArray final();
|
||||
|
||||
QSecureArray hash(const QSecureArray &a);
|
||||
QSecureArray hash(const QCString &cs);
|
||||
QString hashToString(const QSecureArray &a);
|
||||
QString hashToString(const QCString &cs);
|
||||
|
||||
protected:
|
||||
Hash(const QString &type, const QString &provider);
|
||||
};
|
||||
|
||||
/**
|
||||
* General superclass for hashing algorithms.
|
||||
*
|
||||
@ -838,6 +855,7 @@ namespace QCA
|
||||
* QCA::MD5::hash() with the data that you would otherwise
|
||||
* have provided to the update() call.
|
||||
*/
|
||||
#if 0
|
||||
class QCA_EXPORT Hash
|
||||
{
|
||||
public:
|
||||
@ -1008,7 +1026,8 @@ namespace QCA
|
||||
return arrayToHex(hash(cs));
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#if 0
|
||||
class QCA_EXPORT Cipher
|
||||
{
|
||||
public:
|
||||
@ -1072,13 +1091,56 @@ namespace QCA
|
||||
class Private;
|
||||
Private *d;
|
||||
};
|
||||
#endif
|
||||
class QCA_EXPORT SHA0 : public Hash
|
||||
{
|
||||
public:
|
||||
SHA0(const QString &provider="") : Hash("sha0", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT SHA1 : public Hash
|
||||
{
|
||||
public:
|
||||
SHA1(const QString &provider="") : Hash("sha1", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT SHA256 : public Hash
|
||||
{
|
||||
public:
|
||||
SHA256(const QString &provider="") : Hash("sha256", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT MD2 : public Hash
|
||||
{
|
||||
public:
|
||||
MD2(const QString &provider="") : Hash("md2", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT MD4 : public Hash
|
||||
{
|
||||
public:
|
||||
MD4(const QString &provider="") : Hash("md4", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT MD5 : public Hash
|
||||
{
|
||||
public:
|
||||
MD5(const QString &provider="") : Hash("md5", provider) {}
|
||||
};
|
||||
|
||||
class QCA_EXPORT RIPEMD160 : public Hash
|
||||
{
|
||||
public:
|
||||
RIPEMD160(const QString &provider="") : Hash("ripemd160", provider) {}
|
||||
};
|
||||
|
||||
// macs
|
||||
//class QCA_EXPORT HMAC : public MessageAuthenticationCode
|
||||
//{
|
||||
//public:
|
||||
// HMAC(const Hash &h = SHA1(), const SymmetricKey &key = SymmetricKey(), const QString &provider="") : MessageAuthenticationCode(subAlg("hmac", h.type()), key, provider) {}
|
||||
//};
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* SHA-0 cryptographic message digest hash algorithm.
|
||||
*
|
||||
@ -1353,7 +1415,8 @@ namespace QCA
|
||||
*/
|
||||
RIPEMD160();
|
||||
};
|
||||
|
||||
#endif
|
||||
#if 0
|
||||
class QCA_EXPORT BlowFish : public Cipher, public CipherStatic<BlowFish>
|
||||
{
|
||||
public:
|
||||
@ -1429,7 +1492,7 @@ namespace QCA
|
||||
private:
|
||||
RSAKey v_key;
|
||||
};
|
||||
|
||||
#endif
|
||||
// v2 public key handling
|
||||
/*class PublicKey;
|
||||
class PrivateKey;
|
||||
@ -1639,7 +1702,7 @@ namespace QCA
|
||||
QBigInteger x() const;
|
||||
QBigInteger y() const;
|
||||
};*/
|
||||
|
||||
#if 0
|
||||
typedef QMap<QString, QString> CertProperties;
|
||||
|
||||
class QCA_EXPORT Cert
|
||||
@ -1675,9 +1738,9 @@ namespace QCA
|
||||
void fromContext(QCA_CertContext *);
|
||||
};
|
||||
|
||||
class QCA_EXPORT TLS : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
//class QCA_EXPORT TLS : public QObject
|
||||
//{
|
||||
//Q_OBJECT
|
||||
public:
|
||||
enum Validity
|
||||
{
|
||||
@ -1737,9 +1800,9 @@ namespace QCA
|
||||
Private *d;
|
||||
};
|
||||
|
||||
class QCA_EXPORT SASL : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
//class QCA_EXPORT SASL : public QObject
|
||||
//{
|
||||
//Q_OBJECT
|
||||
public:
|
||||
enum Error { ErrAuth, ErrCrypt };
|
||||
enum ErrorCond
|
||||
@ -1827,6 +1890,7 @@ namespace QCA
|
||||
|
||||
void handleServerFirstStep(int r);
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -60,12 +60,12 @@ QSecureArray Random::randomArray(int size, Quality q)
|
||||
{
|
||||
return globalRNG().nextBytes(size, q);
|
||||
}
|
||||
/*
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Hash
|
||||
//----------------------------------------------------------------------------
|
||||
Hash::Hash(int cap, const QString &provider)
|
||||
:Algorithm(cap, provider)
|
||||
Hash::Hash(const QString &type, const QString &provider)
|
||||
:Algorithm(type, provider)
|
||||
{
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ QString Hash::hashToString(const QCString &cs)
|
||||
{
|
||||
return arrayToHex(hash(cs));
|
||||
}
|
||||
|
||||
/*
|
||||
//----------------------------------------------------------------------------
|
||||
// Cipher
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -194,7 +194,7 @@ void ProviderManager::scan()
|
||||
ProviderItem *i = ProviderItem::load(fname);
|
||||
if(!i)
|
||||
continue;
|
||||
if(i->version != QCA_PLUGIN_VERSION && i->version != 1)
|
||||
if(i->version != QCA_PLUGIN_VERSION)// && i->version != 1)
|
||||
{
|
||||
delete i;
|
||||
continue;
|
||||
@ -422,10 +422,10 @@ void ProviderManager::mergeFeatures(QStringList *a, const QStringList &b)
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ProviderManager::capsToStringList(int cap)
|
||||
QStringList ProviderManager::capsToStringList(int)
|
||||
{
|
||||
QStringList list;
|
||||
if(cap & CAP_SHA0)
|
||||
/*if(cap & CAP_SHA0)
|
||||
list.append("sha0");
|
||||
if(cap & CAP_SHA1)
|
||||
list.append("sha1");
|
||||
@ -438,7 +438,7 @@ QStringList ProviderManager::capsToStringList(int cap)
|
||||
if(cap & CAP_MD5)
|
||||
list.append("md5");
|
||||
if(cap & CAP_RIPEMD160)
|
||||
list.append("ripemd160");
|
||||
list.append("ripemd160");*/
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,10 @@
|
||||
|
||||
#define QCA_PLUGIN_VERSION 2
|
||||
|
||||
#define QCA_EXPORT_PLUGIN(P) \
|
||||
QCA_PLUGIN_EXPORT QCA::Provider *createProvider() { return new P; } \
|
||||
QCA_PLUGIN_EXPORT int version() { return QCA_PLUGIN_VERSION; }
|
||||
|
||||
// v2 contexts
|
||||
namespace QCA {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user