mirror of
https://github.com/QuasarApp/qca.git
synced 2025-05-08 00:39:33 +00:00
update tls provider, update build system
svn path=/trunk/kdesupport/qca/; revision=441828
This commit is contained in:
parent
a4e58108b3
commit
cb0311b6f0
@ -1,16 +1,34 @@
|
||||
QCA OpenSSL plugin
|
||||
------------------
|
||||
Author: Brad Hards <bradh@frogmouth.net>
|
||||
Authors: Justin Karneges <justin@affinix.com>
|
||||
Brad Hards <bradh@frogmouth.net>
|
||||
|
||||
This plugin provides features based on OpenSSL. It implements:
|
||||
* Hashing - SHA1, SHA0, RIPEMD160, MD2, MD4, MD5
|
||||
* Block Ciphers
|
||||
* Keyed Hash Message Authentication Code (HMAC), using SHA1, MD5, RIPEMD160
|
||||
* Public keys - RSA, DSA, Diffie-Hellman
|
||||
* PKCS#12
|
||||
* SSL/TLS
|
||||
* CMS (for S/MIME)
|
||||
|
||||
Requirements:
|
||||
OpenSSL Library (http://www.openssl.org/)
|
||||
|
||||
Installation procedure:
|
||||
Installing
|
||||
----------
|
||||
|
||||
For Unix/Linux/Mac:
|
||||
|
||||
./configure
|
||||
make
|
||||
su -c "make install"
|
||||
make install
|
||||
|
||||
For Windows:
|
||||
|
||||
edit qca-openssl.pro
|
||||
qmake qca-openssl.pro
|
||||
nmake (or make)
|
||||
|
||||
copy [debug|release]\qca-openssl.dll qtdir\plugins\crypto
|
||||
|
||||
|
28
plugins/qca-openssl/extra.qcm
Normal file
28
plugins/qca-openssl/extra.qcm
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
-----BEGIN QCMOD-----
|
||||
name: extra
|
||||
-----END QCMOD-----
|
||||
*/
|
||||
|
||||
class qc_extra : public ConfObj
|
||||
{
|
||||
public:
|
||||
qc_extra(Conf *c) : ConfObj(c) {}
|
||||
QString name() const { return "extra"; }
|
||||
QString shortname() const { return "extra"; }
|
||||
|
||||
// no output
|
||||
QString checkString() const { return QString(); }
|
||||
|
||||
bool exec()
|
||||
{
|
||||
// install into plugins path
|
||||
QString str;
|
||||
str += QString(
|
||||
"target.path=%1/crypto\n"
|
||||
"INSTALLS += target\n"
|
||||
).arg(QLibraryInfo::location(QLibraryInfo::PluginsPath));
|
||||
conf->addExtra(str);
|
||||
return true;
|
||||
}
|
||||
};
|
@ -62,7 +62,7 @@ public:
|
||||
if(!lib.isEmpty())
|
||||
ext += QString("-L") + lib + " -lssl -lcrypto ";
|
||||
int ret;
|
||||
if(!conf->doCompileAndLink(str, ext, &ret))
|
||||
if(!conf->doCompileAndLink(str, QStringList(), ext, QString(), &ret))
|
||||
return false;
|
||||
if(ret == 0)
|
||||
conf->addDefine("OSSL_097");
|
||||
|
@ -3645,8 +3645,7 @@ public:
|
||||
Certificate cert, peercert; // TODO: support cert chains
|
||||
PrivateKey key;
|
||||
|
||||
bool result_success;
|
||||
Result result_handshakeResult;
|
||||
Result result_result;
|
||||
QByteArray result_to_net;
|
||||
int result_encoded;
|
||||
QByteArray result_plain;
|
||||
@ -3658,7 +3657,7 @@ public:
|
||||
Validity vr;
|
||||
bool v_eof;
|
||||
|
||||
MyTLSContext(Provider *p) : TLSContext(p)
|
||||
MyTLSContext(Provider *p) : TLSContext(p, "tls")
|
||||
{
|
||||
if(!ssl_init)
|
||||
{
|
||||
@ -3737,52 +3736,55 @@ public:
|
||||
Q_UNUSED(cipherSuiteList);
|
||||
}
|
||||
|
||||
virtual void setup(const CertificateCollection &_trusted, const CertificateChain &_cert, const PrivateKey &_key, bool compress)
|
||||
virtual void setup(const CertificateCollection &_trusted, const CertificateChain &_cert, const PrivateKey &_key, bool serverMode, bool compress, bool)
|
||||
{
|
||||
trusted = _trusted;
|
||||
if(!_cert.isEmpty())
|
||||
cert = _cert.primary(); // TODO: take the whole chain
|
||||
key = _key;
|
||||
serv = serverMode;
|
||||
Q_UNUSED(compress); // TODO
|
||||
}
|
||||
|
||||
virtual void startClient()
|
||||
virtual void shutdown()
|
||||
{
|
||||
result_success = priv_startClient();
|
||||
mode = Closing;
|
||||
}
|
||||
|
||||
virtual void startServer()
|
||||
virtual void start()
|
||||
{
|
||||
result_success = priv_startServer();
|
||||
bool ok;
|
||||
if(serv)
|
||||
ok = priv_startServer();
|
||||
else
|
||||
ok = priv_startClient();
|
||||
result_result = ok ? Success : Error;
|
||||
}
|
||||
|
||||
virtual void handshake(const QByteArray &from_net)
|
||||
virtual void update(const QByteArray &from_net, const QByteArray &from_app)
|
||||
{
|
||||
result_handshakeResult = priv_handshake(from_net, &result_to_net);
|
||||
doResultsReady();
|
||||
}
|
||||
if(mode == Active)
|
||||
{
|
||||
bool ok;
|
||||
if(!from_app.isEmpty())
|
||||
ok = priv_encode(from_app, &result_to_net, &result_encoded);
|
||||
else
|
||||
ok = priv_decode(from_net, &result_plain, &result_to_net);
|
||||
result_result = ok ? Success : Error;
|
||||
}
|
||||
else if(mode == Closing)
|
||||
result_result = priv_shutdown(from_net, &result_to_net);
|
||||
else
|
||||
result_result = priv_handshake(from_net, &result_to_net);
|
||||
|
||||
virtual void shutdown(const QByteArray &from_net)
|
||||
{
|
||||
result_handshakeResult = priv_shutdown(from_net, &result_to_net);
|
||||
doResultsReady();
|
||||
}
|
||||
//printf("update (from_net=%d, to_net=%d, from_app=%d, to_app=%d)\n", from_net.size(), result_to_net.size(), from_app.size(), result_plain.size());
|
||||
|
||||
virtual void encode(const QByteArray &from_net)
|
||||
{
|
||||
result_success = priv_encode(from_net, &result_to_net, &result_encoded);
|
||||
doResultsReady();
|
||||
}
|
||||
|
||||
virtual void decode(const QByteArray &from_net)
|
||||
{
|
||||
result_success = priv_decode(from_net, &result_plain, &result_to_net);
|
||||
doResultsReady();
|
||||
}
|
||||
|
||||
bool priv_startClient()
|
||||
{
|
||||
serv = false;
|
||||
//serv = false;
|
||||
method = SSLv23_client_method();
|
||||
if(!init())
|
||||
return false;
|
||||
@ -3792,7 +3794,7 @@ public:
|
||||
|
||||
bool priv_startServer()
|
||||
{
|
||||
serv = true;
|
||||
//serv = true;
|
||||
method = SSLv23_server_method();
|
||||
if(!init())
|
||||
return false;
|
||||
@ -3879,7 +3881,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
mode = Closing;
|
||||
//mode = Closing;
|
||||
return Continue;
|
||||
}
|
||||
}
|
||||
@ -3946,15 +3948,19 @@ public:
|
||||
while(!v_eof) {
|
||||
a.resize(8192);
|
||||
int ret = SSL_read(ssl, a.data(), a.size());
|
||||
//printf("SSL_read = %d\n", ret);
|
||||
if(ret > 0)
|
||||
{
|
||||
if(ret != (int)a.size())
|
||||
a.resize(ret);
|
||||
//printf("SSL_read chunk: [%s]\n", qPrintable(arrayToHex(a)));
|
||||
recvQueue.append(a);
|
||||
}
|
||||
else if(ret <= 0)
|
||||
{
|
||||
ERR_print_errors_fp(stdout);
|
||||
int x = SSL_get_error(ssl, ret);
|
||||
//printf("SSL_read error = %d\n", x);
|
||||
if(x == SSL_ERROR_WANT_READ || x == SSL_ERROR_WANT_WRITE)
|
||||
break;
|
||||
else if(x == SSL_ERROR_ZERO_RETURN)
|
||||
@ -3978,14 +3984,9 @@ public:
|
||||
Q_UNUSED(msecs);
|
||||
}
|
||||
|
||||
virtual bool success() const
|
||||
virtual Result result() const
|
||||
{
|
||||
return result_success;
|
||||
}
|
||||
|
||||
virtual Result handshakeResult() const
|
||||
{
|
||||
return result_handshakeResult;
|
||||
return result_result;
|
||||
}
|
||||
|
||||
virtual QByteArray to_net()
|
||||
@ -4000,7 +4001,7 @@ public:
|
||||
return result_encoded;
|
||||
}
|
||||
|
||||
virtual QByteArray plain()
|
||||
virtual QByteArray to_app()
|
||||
{
|
||||
QByteArray a = result_plain;
|
||||
result_plain.clear();
|
||||
|
@ -1,26 +1,22 @@
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
QT -= gui
|
||||
|
||||
#CONFIG += release
|
||||
CONFIG += debug
|
||||
|
||||
QCA_INC = ../../include/QtCrypto
|
||||
QCA_LIB = ../..
|
||||
|
||||
INCLUDEPATH += $$QCA_INC
|
||||
LIBS += -L$$QCA_LIB -lqca
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
QT -= gui
|
||||
CONFIG += crypto
|
||||
|
||||
SOURCES = qca-openssl.cpp
|
||||
#SOURCES += main.cpp
|
||||
|
||||
# temp hack
|
||||
DEFINES += OSSL_097
|
||||
unix:LIBS += -lssl -lcrypto
|
||||
windows:{
|
||||
INCLUDEPATH += /local/include
|
||||
LIBS += -L/local/lib -llibeay32 -lssleay32
|
||||
# hardcoded openssl location
|
||||
OPENSSL_PREFIX = /local
|
||||
|
||||
INCLUDEPATH += $$OPENSSL_PREFIX/include
|
||||
LIBS += -L$$OPENSSL_PREFIX/lib
|
||||
LIBS += -llibeay32 -lssleay32
|
||||
LIBS += -lgdi32 -lwsock32
|
||||
}
|
||||
|
||||
#include(conf.pri)
|
||||
#include(extra.pri)
|
||||
include(conf.pri)
|
||||
|
@ -2,8 +2,14 @@
|
||||
<name>qca-openssl</name>
|
||||
<profile>qca-openssl.pro</profile>
|
||||
<noprefix/>
|
||||
<dep type='qca'>
|
||||
<required/>
|
||||
</dep>
|
||||
<dep type='openssl'>
|
||||
<required/>
|
||||
</dep>
|
||||
<dep type='extra'>
|
||||
<required/>
|
||||
</dep>
|
||||
<moddir>.</moddir>
|
||||
</qconf>
|
||||
|
41
plugins/qca-openssl/qca.qcm
Normal file
41
plugins/qca-openssl/qca.qcm
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
-----BEGIN QCMOD-----
|
||||
name: QCA 2.0
|
||||
-----END QCMOD-----
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// qc_qca
|
||||
//----------------------------------------------------------------------------
|
||||
class qc_qca : public ConfObj
|
||||
{
|
||||
public:
|
||||
qc_qca(Conf *c) : ConfObj(c) {}
|
||||
QString name() const { return "QCA 2.0"; }
|
||||
QString shortname() const { return "qca"; }
|
||||
bool exec()
|
||||
{
|
||||
// test for "crypto" feature and check qca version number
|
||||
|
||||
QString proextra =
|
||||
"CONFIG += qt crypto\n"
|
||||
"QT -= gui\n";
|
||||
|
||||
QString str =
|
||||
"#include <QtCrypto>\n"
|
||||
"\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" unsigned long x = QCA_VERSION;\n"
|
||||
" if(x >= 0x020000) return 0; else return 1;\n"
|
||||
"}\n";
|
||||
|
||||
int ret;
|
||||
if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra, &ret))
|
||||
return false;
|
||||
if(ret != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user