mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-28 20:44:31 +00:00
plugin should work now
svn path=/trunk/kdesupport/qca/; revision=235135
This commit is contained in:
parent
33d3b5565a
commit
59fc5620ba
@ -3,6 +3,10 @@
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCA::init();
|
||||
if(!QCA::isSupported(QCA::CAP_SHA1)) {
|
||||
printf("SHA1 not supported!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
QCString cs = (argc >= 2) ? argv[1] : "hello";
|
||||
QString result = QCA::SHA1::hashToString(cs);
|
||||
|
@ -6,8 +6,8 @@ SOURCES += hashtest.cpp src/qca.cpp
|
||||
TARGET = hashtest
|
||||
|
||||
# compile in openssl?
|
||||
DEFINES += USE_OPENSSL
|
||||
HEADERS += plugins/qcaopenssl.h plugins/qcaopenssl_p.h
|
||||
SOURCES += plugins/qcaopenssl.cpp
|
||||
LIBS += -lssl -lcrypto
|
||||
#DEFINES += USE_OPENSSL
|
||||
#HEADERS += plugins/qcaopenssl.h plugins/qcaopenssl_p.h
|
||||
#SOURCES += plugins/qcaopenssl.cpp
|
||||
#LIBS += -lssl -lcrypto
|
||||
|
||||
|
@ -3,6 +3,13 @@
|
||||
#include<qptrlist.h>
|
||||
#include<openssl/sha.h>
|
||||
|
||||
#ifdef QCA_PLUGIN
|
||||
QCAProvider *createProvider()
|
||||
{
|
||||
return (new _QCAOpenSSL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int sha1_create();
|
||||
static void sha1_destroy(int ctx);
|
||||
static void sha1_update(int ctx, const char *in, unsigned int len);
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
#include"qcaprovider.h"
|
||||
|
||||
#ifdef QCA_PLUGIN
|
||||
QCA_EXPORT QCAProvider *createProvider();
|
||||
#endif
|
||||
|
||||
class QCAOpenSSL : public QCAProvider
|
||||
{
|
||||
public:
|
||||
|
33
src/qca.cpp
33
src/qca.cpp
@ -1,6 +1,9 @@
|
||||
#include"qca.h"
|
||||
|
||||
#include<qptrlist.h>
|
||||
#include<qdir.h>
|
||||
#include<qstringlist.h>
|
||||
#include<qlibrary.h>
|
||||
#include"qcaprovider.h"
|
||||
#include<stdio.h>
|
||||
|
||||
@ -30,6 +33,29 @@ void QCA::init()
|
||||
#ifdef USE_OPENSSL
|
||||
providerList.append(new _QCAOpenSSL);
|
||||
#endif
|
||||
|
||||
// load plugins
|
||||
QDir dir("plugins");
|
||||
QStringList list = dir.entryList("*.so");
|
||||
for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
||||
QLibrary *lib = new QLibrary(dir.filePath(*it));
|
||||
if(!lib->load()) {
|
||||
delete lib;
|
||||
continue;
|
||||
}
|
||||
void *s = lib->resolve("createProvider");
|
||||
if(!s) {
|
||||
delete lib;
|
||||
continue;
|
||||
}
|
||||
QCAProvider *(*createProvider)() = (QCAProvider *(*)())s;
|
||||
QCAProvider *p = createProvider();
|
||||
if(!p) {
|
||||
delete lib;
|
||||
continue;
|
||||
}
|
||||
providerList.append(p);
|
||||
}
|
||||
}
|
||||
|
||||
bool QCA::isSupported(int capabilities)
|
||||
@ -105,11 +131,6 @@ void Cipher::setIV(const QByteArray &a)
|
||||
SHA1::SHA1()
|
||||
{
|
||||
f = (QCA_SHA1Functions *)getFunctions(CAP_SHA1);
|
||||
if(!f) {
|
||||
printf("SHA1: can't initialize!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = f->create();
|
||||
}
|
||||
|
||||
@ -158,7 +179,6 @@ void SHA256::update(const QByteArray &a)
|
||||
|
||||
QByteArray SHA256::final()
|
||||
{
|
||||
printf("sha256 finalizing\n");
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
@ -168,7 +188,6 @@ QByteArray SHA256::final()
|
||||
//----------------------------------------------------------------------------
|
||||
MD5::MD5()
|
||||
{
|
||||
printf("MD5: initialized\n");
|
||||
}
|
||||
|
||||
MD5::~MD5()
|
||||
|
@ -1,8 +1,15 @@
|
||||
#ifndef QCAPROVIDER_H
|
||||
#define QCAPROVIDER_H
|
||||
|
||||
#include<qglobal.h>
|
||||
#include"qca.h"
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#define QCA_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define QCA_EXPORT extern "C"
|
||||
#endif
|
||||
|
||||
class QCAProvider
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user