Setting up Qt4 and Qt Cryptography Architecture developer environment on Mac OSX Lion and Snow Leopard, Part 2.
QCA provides Cryptography functions through a set of Qt4 plugins called Providers. The main provider of functionality is via the qca-ossl plugin which provides OpenSSL’s ciphers and functionality in a clean Qt4 API for ease of use and portability. In this “Part 2″ setup of QCA on OSX is covered.
Required Reading and Prerequisites: Qt4 and QCA Developer Environment on OSX Lion (Pt. 1)
With Qt4 all setup from the previous guide, we are ready to move on to some more command line heavy steps to get QCA up and running. Qt Cryptographic Architecture (QCA) can be found at http://delta.affinix.com/qca/. In many attempts to get QCA working with the QtSDK 1.1.3 and OSX I finally decided the best course of action was to use the svn repos.
The tar.gz distribution doesn’t cleanly compile for version 2.0.3, and I couldn’t get any of the plugins to install from the tar.gz files listed as downloads on the main site. I ended up going to http://delta.affinix.com/source/ and following the instructions there. Here is what we will need.
- Xcode 4.x
- Qt4 Developer SDK : Instructions here.
- qmake in /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qmake
- A temp directory that isn’t backed up my TimeMachine if you prefer
Getting the Sources
Start out by grabbing a svn checkout of each code base we’ll need. QCA and qconf. In OSX Terminal (Applications -> Utilities -> Terminal). Use the command cd to change your working directory to your temp directory that isn’t TimeMachine backed up (if you wish). I keep my Downloads directory out of TimeMachine.
Last login: Tue Nov 1 15:51:23 on ttys005 Toms-iMac:~ tom$ cd ~/Downloads svn checkout https://delta.affinix.com/svn/trunk/qconf <.... lots of text ....> Checked out revision 812. svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/qca <.... lots of text ....> Checked out revision 1262186. Toms-iMac:Downloads tom$
Installing QConf
First, we need the tool to generate the QCA build files. This tool is called qconf and is the first svn source code checked out above. The install is pretty easy, just run configure specifying prefix and Qt location, then make, and sudo make install. (The \ means new line you can leave it in or not, i just do it for display purposes.
Toms-iMac:Downloads tom$ cd qconf qconf tom$ ./configure --qtdir=/Developer/QtSDK/Desktop/Qt/474/gcc/ \ --prefix=/Developer/QtSDK/Desktop/Qt/474/gcc/ qconf tom$ make qconf tom$ sudo make install
Installing QCA
qconf is now installed in /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qconf and is a great place for it along with all the other Qt4 tools. Next up is building QCA. Use cd to back out of the qconf dir and go into qca’s source dir:
:qconf tom$ cd ../qca :qca tom$
In this directory notice there is no configure script. First we need to build the ./configure application that will setup the qca build system. We’ll use qconf to do this, and then run configure the same way as when installing qconf only adding –debug-and-release so we can get both frameworks.
qca tom$ /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qconf Project name: Qt Cryptographic Architecture (QCA) Profile: qca.pro Deps: qt42* buildmode* buildmode_framework* universal* extra* certstore* 'configure' written. 'configure.exe' written. qca tom$ ./configure --qtdir=/Developer/QtSDK/Desktop/Qt/474/gcc/ \ --prefix=/Developer/QtSDK/Desktop/Qt/474/gcc/ --debug-and-release qca tom$ make qca tom$ sudo make install qca tom$
Installing QCA Provider Plugins
QCA is now setup, but we’ll find we only have the basic utilities such as MD5 and SHA hashing. To get the full Cryptography functionality we must install a QCA Provider Plugin. Several plugins exit, but I’ve had limited success in getting them to build. So far the only plugin/provider I’ve needed is qca-ossl. The qca-ossl provider plugin provides cryptography functions via the OSX SSL libraries. To install it we cd into the plugins directory that is in the QCA source code. Then configure and compile like with the QCA sources only this time without the –prefix.
qca tom$ cd plugins qca tom$ qca-ossl qca-ossl tom$ /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qconf Project name: qca-ossl Profile: qca-ossl.pro Deps: buildmode* universal* qca* openssl* qcapluginpath* 'configure' written. 'configure.exe' written. qca-ossl tom$ ./configure --qtdir=/Developer/QtSDK/Desktop/Qt/474/gcc/ --debug-and-release qca-ossl tom$ make qca-ossl tom$ sudo make install
Test it all out!
You should now have QCA and its OpenSSL cryptography plugin installed! You can test it out by compiling the source I have attached. Running the app will print out all the available Ciphers.
Download
~ tom$ tar -jxvf cryptotest.tar.bz2
~ tom$ cd cryptotest
cryptotest tom$ /Developer/QtSDK/Desktop/Qt/474/gcc/bin/qmake
cryptotest tom$ make
cryptotest tom$ ./CryptoTest
("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")
cryptotest tom$
Thats all, You’re good to go. Dive into the QCA documentation and have some fun!
Docs: http://delta.affinix.com/docs/qca/
Special Thanks:
To the wonderful developers who have worked to bring us QCA, OpenSSL, and the QCA Plugins.
Sources:
Qt Cryptography Architecture: http://delta.affinix.com/qca/
Nokia Qt4 SDK: http://qt.nokia.com
K Desktop: http://www.kde.org


