PDA

View Full Version : QtCrypto (qca-ossl) problem loading plugins



m3rlin
26th December 2011, 06:28
Hi,

I'd appreciate some help with qca-ossl plugins.

Problem:
QCA::ProviderList... lists: "default" as list of plugin providers (which 'could' refer to the collection of qca-ossl plugins)
BUT when I run e.g. the ciphertest (found at http://delta.affinix.com/qca/ (in file:: qca-ossl-2.0.0-beta3.tar.bz2) or any other tests, the result is always e.g.: AES128-CBC not supported!

Question: to me it looks like a path or linker problem. But where and what needs to be included o linked to be able to use e.g. AES128-CBC??

Configuration:
System: Linux Ubuntu 11.04
Software installed: Qt3, Qt4 SDK 4.74, OpenSSL 1.0.0e 6 Sep 2011, qca-2.0.3, qca-ossl-2.0.0-beta-3.
Patches Applied: 1 to qca-ossl.cpp (remove MD2 support to install with openSSL 1.0.0e )
Qt Creator Project file: (test.pro) contains includepath to libs, libs -L<path> -lqca and config += crypto
Qt Creator main.cpp: all necessary includes e.g. <QtCrypto> work

qcatool2 plugins --debug reports:

Qt Library Paths:
/usr/lib/qt4/plugins
/usr/local/bin
plugin: Checking Qt static plugins:
plugin: (none)
plugin: Checking Qt Library Path: /usr/lib/qt4/plugins
plugin: libqca-ossl.so: (class: opensslPlugin) loaded as qca-ossl
plugin: libqca-ossl.so.debug: not a library, skipping
plugin: Checking Qt Library Path: /usr/local/bin
plugin: (No 'crypto' subdirectory)
Available Providers:
qca-ossl
This product includes cryptographic software written by Eric Young
(eay@cryptsoft.com)
*sha1
*sha0
*ripemd160
*md4
*md5
*sha224
*sha256
*sha384
*sha512
*hmac(md5)
*hmac(sha1)
*hmac(sha224)
*hmac(sha256)
*hmac(sha384)
*hmac(sha512)
*hmac(ripemd160)
*aes128-ecb
*aes128-cfb
*aes128-cbc
*aes128-cbc-pkcs7
*aes128-ofb
*aes192-ecb
*aes192-cfb
*aes192-cbc
*aes192-cbc-pkcs7
*aes192-ofb
*aes256-ecb
*aes256-cbc
*aes256-cbc-pkcs7
*aes256-cfb
*aes256-ofb
*blowfish-ecb
*blowfish-cbc-pkcs7
*blowfish-cbc
*blowfish-cfb
*blowfish-ofb
*tripledes-ecb
*tripledes-cbc
*des-ecb
*des-ecb-pkcs7
*des-cbc
*des-cbc-pkcs7
*des-cfb
*des-ofb
*cast5-ecb
*cast5-cbc
*cast5-cbc-pkcs7
*cast5-cfb
*cast5-ofb
*pbkdf1(sha1)
*pbkdf2(sha1)
*pkey
*dlgroup
*rsa
*dsa
*dh
*cert
*csr
*crl
*certcollection
*pkcs12
*tls
*cms
*ca
plugin: Unloaded: qca-ossl



main.cpp example:

#include <QtCrypto>
#include <QDebug>
#include <cstdio>

int main(int argc, char **argv)
{
QCA::Initializer init;
QCA::SecureArray arg = (argc >= 2) ? argv[1] : "hello";
if(!QCA::isSupported("aes128-cbc-pkcs7"))
printf("AES128-CBC not supported!\n");
else {
QCA::SymmetricKey key(16);
QCA::InitializationVector iv(16);
QCA::Cipher cipher(QString("aes128"),QCA::Cipher::CBC, QCA::Cipher::DefaultPadding,QCA::Encode,key,iv);
QCA::SecureArray u = cipher.update(arg);
if (!cipher.ok())
{
printf("Update failed\n");
}
printf("AES128 encryption of %s is [%s]\n",arg.data(),qPrintable(QCA::arrayToHex(u.toByteArr ay())) );
QCA::SecureArray f = cipher.final();
if (!cipher.ok())
{
printf("Final failed\n");
}
printf("Final block for AES128 encryption is [0x%s]\n", qPrintable(QCA::arrayToHex(f.toByteArray())) );
cipher.setup( QCA::Decode, key, iv );
QCA::SecureArray cipherText = u.append(f);
QCA::SecureArray plainText = cipher.update(cipherText);
if (!cipher.ok())
{
printf("Update failed\n");
}
printf("Decryption using AES128 of [0x%s] is %s\n",qPrintable(QCA::arrayToHex(cipherText.toByteArray ())), plainText.data());
plainText = cipher.final();
if (!cipher.ok())
{
printf("Final failed\n");
}
printf("Final decryption block using AES128 is %s\n", plainText.data());
printf("One step decryption using AES128: %s\n",QCA::SecureArray(cipher.process(cipherText)).data () );
}
return 0;
}

norobro
27th December 2011, 01:20
Just FYI, your app runs fine on my Debian Sid box:

AES128 encryption of hello is []
Final block for AES128 encryption is [0x6941a6aebe7f0ff0a1559f65c9a1ce81]
Decryption using AES128 of [0x6941a6aebe7f0ff0a1559f65c9a1ce81] is (null)
Final decryption block using AES128 is hello
One step decryption using AES128: hello
The only difference that I see in our setups is that I have qca-ossl-2.0.0-beta-3-1 from the Debian repositories installed. The Debian package is in the Ubuntu repositories also: link (http://packages.ubuntu.com/search?keywords=libqca2-plugin-ossl)


In addition to the patch that you applied (detect_md2_available.diff) the beta-3-1 package contains two others:
detect_ssl2_available.diff
remove_whirlpool_algo.diff

If you can't install the Ubuntu package, try applying the above patches and recompiling.

m3rlin
27th December 2011, 07:32
Thx NoRoBro for you quick reply.
The additional patching didn't solve the problem reinstalling did.
Here is what I did on Natty's version of Ubuntu to make it work:

Uninstall:
I uninstalled all the aforementioned programs (Qt3, Qt4 SDK 4.74, OpenSSL 1.0.0e 6 Sep 2011, qca-2.0.3, qca-ossl-2.0.0-beta-3), then I made sure to clean all my directories (/usr/local and such).
Reinstall:
First openssl, then QT Creator from Ubuntu's software repositories.
Note that I deliberately removed my path to <QTDIR> from bashrc, and I deliberately left out QT3, to make sure that both QCA's will find qmake-qt4 in the /usr/bin and not qmake-qt3.
I installed qca-2.0.3 without any problems.
After the installation of QCA-2.0.3, I patched CMakelist and qca-ossl.cpp. I encountered 1 setback with the .configure from qca-ossl, it would'nt recognize the qca-2.0.3 install. Even after feeding argument --with-qca=/usr/local/qca-2.0.3 directory to the qca-ossl configure file, it would not recognize the installation. I needed to run sudo /sbin/ldconfig before the qca-ossl installation.
After installation I ran qcatool2 plugin --debug. It provide the same results as my first post.
I altered the .pro file to find the newly installed libraries (INCLUDEPATH =/usr/local/qca-2.0.3/) and (LIBS += -L/usr/local/lib -lqca) and CONFIG += crypto
Then somehow my code (main.cpp) started working.
Conclusion:
It must have been a linker problem, maybe even a permission problem on a library or a missing library (I have small kids playing on my computer).