Compare commits

...

464 Commits

Author SHA1 Message Date
45f2312979 remove depricated features 2021-09-09 15:14:19 +03:00
a602142dcb disable doc target 2021-09-02 11:48:08 +03:00
5b49c00168
Merge pull request #1 from KDE/master
refresh
2021-09-02 09:56:29 +03:00
Albert Astals Cid
e9fd31b4a1 Fix wrong condition protecting test execution 2021-08-06 17:15:30 +02:00
Christophe Giboudeaux
7ead054437 Don't create pkgconfig files for Qt 6 builds
Qt 6 doesn't provide pkgconfig files.
2021-06-05 08:35:27 +02:00
Albert Astals Cid
b2e54520a3 Increase version 2021-05-31 23:12:57 +02:00
Tobias Junghans
5cc26f77f0 CI: add job for Qt 6 build/test 2021-05-29 22:28:27 +00:00
Tobias Junghans
2c3992f075 Add Qt 6 build support
The Core5Compat module is still required for QTextCodec and some
difficult remaining QRegExp -> QRegularExpression migrations.
2021-05-29 22:28:27 +00:00
Tobias Junghans
0c3db8a062 Start Qt 6 port
Still a few occurrences of QRegExp and QTextCodec need to be replaced
in order to drop the dependency on the Core5Compat module. Besides this
QCA builds fine with Qt 6.1 and passes all tests.
2021-05-29 22:28:27 +00:00
Tobias Junghans
974f8ec8d0 Migrate from QScopedPointer to std::unique_ptr
QScopedPointer::take() is deprecated since Qt 6.1 so we can switch
to std::unique_ptr everywhere to be consistent.
2021-05-29 22:28:27 +00:00
Tobias Junghans
040d7d6348 Use QVariant::fromValue() for custom types 2021-05-29 22:28:27 +00:00
Tobias Junghans
d8f1e6cb9c Remove QChar::Null from latin1 strings
QString::fromLatin1(QByteArray) includes the null characters from the
byte array which makes BigInteger and Certificate tests fail since
QCOMPARE distinguishes between QString("123") and QString("123\u0000").
2021-05-29 22:28:27 +00:00
Tobias Junghans
9443ba76ba Migrate from qrand() to std::rand()
qrand() is deprecated since Qt 5.15.
2021-05-29 22:28:27 +00:00
Tobias Junghans
effbe387a0 Use QDateTime::to/fromSecsSinceEpoch()
QDateTime::to/fromTime_t() are deprecated since Qt 5.8.
2021-05-29 22:28:27 +00:00
Tobias Junghans
e6a15466ae Make retval of size()/count() match format string
Starting with Qt 6 qsizetype is returned (equals size_t).
2021-05-29 22:28:27 +00:00
Tobias Junghans
35366fea78 Use QStringView for Qt >= 5.15.2
QStringView::mid() behaves identically to QString::mid() starting with
Qt 5.15.2.
2021-05-29 22:28:27 +00:00
Tobias Junghans
3e90e13d5e Use Qt::endl 2021-05-29 22:28:27 +00:00
Tobias Junghans
91ff0aa0db Use new QAbstractSocket::errorOccurred() signal
It's in Qt 5.15 already.
2021-05-29 22:28:27 +00:00
Tobias Junghans
564e906dd1 Use QString::split(..., Qt::SplitBehavior, ...)
It's in Qt 5.14 already.
2021-05-29 22:28:27 +00:00
Tobias Junghans
d3d16fcc17 CI: switch to Ubuntu 20.10 to have Qt >= 5.14
KDE Frameworks requires Qt 5.14 already so we should adopt that. This
will also save quite a few #ifdefs when migrating to Qt 6.
2021-05-29 22:28:27 +00:00
Mark Nalimov
797b430540 Minor docs fix 2021-05-24 11:01:43 +03:00
Albert Astals Cid
ecdd0538dd Fix CMSut::signverify_message_invalid failing "randomly"
Once in a blue moon it happens that signedResult1[signedResult1.size() -
2] is a 0, so setting it to 0 doesn't break the signature validation, so
   check if it's a 0 and if it is, set it to 1
2021-02-05 16:45:07 +00:00
Albert Astals Cid
aa26b43be2 CI: give the plugin path for tests, otherwise some are not found
also run the tests on the debian:unstable CI to have testing with
different versions of dependencies
2021-02-05 16:47:13 +01:00
Albert Astals Cid
bc94cc08e1 openssl 1.1.1i made verification of empty messages always succeed
BUGS: 432519
2021-02-05 16:40:19 +01:00
Albert Astals Cid
2d7e7e8242 increase version 2021-02-02 23:51:45 +01:00
Albert Astals Cid
32275f1a74 Move moc include outside the QCA namespace
It's the right thing to do and also fixes build with gcc 11
2021-01-24 20:07:09 +00:00
Albert Astals Cid
1bcde93efc CI: Switch to new clang-format 2021-01-24 17:54:53 +00:00
Albert Astals Cid
e9e0f2085d Update the Qt requirement to what we actually test on CI 2020-12-10 19:51:38 +01:00
Albert Astals Cid
bd31ef1587 gitlab-ci: use eatmydata in apt-get
apt-get uses several fsync() calls on each package it installs, and that's
very slow, especially on non-SSD. eatmydata turns fsync into no-op, which
makes package installation much faster (it can cause corruption if there's
power loss or similar, but that doesn't matter in CI where we throw away
the whole container anyway).
2020-12-09 22:32:13 +00:00
Albert Astals Cid
7174e6ed70 Disable performance-no-automatic-move
It's too noisy with Qt classes
2020-12-09 21:33:05 +01:00
Albert Astals Cid
0684db8255 Add .git-blame-ignore-revs and some instructions for clang-format 2020-09-07 02:29:40 +02:00
Albert Astals Cid
dfb96ac596 Check clang-format at CI stage 2020-09-07 02:29:36 +02:00
Albert Astals Cid
f62a8ee8f7 Run clang-format
find . \( -name "*.cpp" -or -name "*.h"  -or -name "*.c"  -or -name "*.cc" \) -exec clang-format -i {} \;

If you reached this file doing a git blame, please see README.clang-format (added 2 commits in the future of this one)
2020-09-07 02:13:47 +02:00
Sergey Ilinykh
04dbe5ca7d Add clang-format file 2020-09-07 02:13:09 +02:00
Albert Astals Cid
db8ff052a9 Add a clang-format off marker
Otherwise clang-format unoptimizes the code
2020-09-07 02:13:09 +02:00
Albert Astals Cid
f88abb0697 Rewrite code a bit so clang-format doesn't break exceptions
clazy and clang-tidy comments needs to in the proper place
2020-09-07 02:11:39 +02:00
Sergey Ilinykh
0fd3c4cb26 Fixed windows.h auto ordering 2020-09-06 23:46:15 +02:00
Albert Astals Cid
0d174fea58 More values().contains() -> contains() 2020-09-06 23:41:53 +02:00
Albert Astals Cid
fb926ae7b2 Rewrite the values().contains() with a single contains() 2020-09-06 21:31:10 +02:00
Albert Astals Cid
6f4e01f92d qca-gcrypt: mark functions only used in one file as static 2020-07-13 18:59:28 +02:00
Alexander Volkov
71a1f95cba qca-gcrypt: Add support for HKDF 2020-07-13 16:55:56 +00:00
Larry Shaffer
f899a6aaad
Add macOS framework major version
- Use of major is like Qt, Qwt, etc.

Signed-off-by: Yurii Kolesnykov <root@yurikoles.com>
2020-07-06 14:25:24 +03:00
Albert Astals Cid
6c5486c227 Increase version 2020-07-04 10:51:52 +02:00
Albert Astals Cid
dd323fb8dc Update rootcerts.pem 2020-07-04 10:51:30 +02:00
Albert Astals Cid
6ee845ba60 ossl: Fix memory leak when querying for tls supported cipher suites 2020-06-22 22:55:29 +02:00
Albert Astals Cid
5d027c8012 tlsunittest: Fix memory leak 2020-06-22 22:53:55 +02:00
Albert Astals Cid
e23bf00919 pipeunittest: Fix memory leak 2020-06-22 22:52:44 +02:00
Albert Astals Cid
cfc80a9d6e ossl: Fix memory leak in CRL handling
ASN1_INTEGER_to_BN returns memory that needs to be freed
2020-06-22 22:46:13 +02:00
Albert Astals Cid
a014df24c5 ossl: Fix memory leak in fromPKCS12 2020-06-22 22:03:39 +02:00
Albert Astals Cid
c68a5e449f Fix memory leak in keybundle unittest 2020-06-22 22:03:39 +02:00
Albert Astals Cid
3242caee6a ossl: pkcs12: Don't crash on unknown private key type
BUGS: 423355
2020-06-22 22:03:35 +02:00
Friedrich W. H. Kossebau
ae5dec259f API dox: update some links in main page 2020-05-29 16:28:48 +02:00
Friedrich W. H. Kossebau
3b35392d13 API dox: fix generation of example tlssocket.cpp 2020-05-29 16:28:08 +02:00
Friedrich W. H. Kossebau
27dcf14de4 Add support for API docs generation with kapidox 2020-05-29 16:27:19 +02:00
Ivan Romanov
cabc7d32da Fix OpenSSL cipher names
OpenSSL provides own function to get cipher suite name by id.
No any sense to support own cipher suites list. Also now
this plugin will provide not just all available cipher suites.
But only these which enabled and can be used.

For old SSLv3 protocol ciphers have TLS variant names. It changes
prefix SSL with TLS.
2020-05-20 20:41:00 +05:00
Ivan Romanov
26af53173e Set minimum OpenSSL version in CMake 2020-05-20 19:07:01 +05:00
Ivan Romanov
b69aab2431 Fix KDE Licensing Policy problem
Added csv from https://www.iana.org/assignments/tls-parameters/tls-parameters-4.csv.
Also applied GPL license to gen-tls-parameters.sh and tls-parameters.cpp.
2020-05-19 20:08:41 +05:00
Ivan Romanov
cf929ce541 Add sh script to generate tls cipher strings 2020-05-18 14:45:48 +05:00
Ivan Romanov
bb9c771f4f Update TLS ClientCertificateType Identifiers 2020-05-18 00:18:21 +05:00
Albert Astals Cid
886d37792c Wrap char * in QStringLiteral
Compile++ for mac
2020-04-05 16:05:12 +00:00
Harald Sitter
77d127249c make memset easier to read
instead of manually calculating the size, just use sizeof on the members.
they are arrays, so the compiler can do the work for us.

Reviewers: sitter, vonreth

Reviewed By: sitter

Differential Revision: https://phabricator.kde.org/D9447

Diff By: Aleksey Nikolaev
2020-03-19 14:36:39 +01:00
Albert Astals Cid
cfea73392b Fix cross-compile under fedora mingw 2020-03-10 17:41:56 +01:00
Albert Astals Cid
02585a58e3 add a few const 2020-02-28 13:45:30 +01:00
Albert Astals Cid
4cf5d1965f Add more const qualifiers 2020-02-24 16:24:46 +01:00
Albert Astals Cid
06ad9c62b5 Increase version 2020-02-24 15:31:51 +01:00
Albert Astals Cid
30a9249dd9 Mark a few byte arrays as const 2020-02-17 17:39:40 +01:00
Albert Astals Cid
c1a028c345 Add const to a few lists 2020-02-16 12:11:57 +01:00
Albert Astals Cid
4100770e32 clang: Also enable the compile warnings
and turn some casts to reinterpret cast to make it clear "we know what
we're doing"
2020-02-15 12:29:54 +01:00
Albert Astals Cid
f944220634 Modernize cmake a bit: Remove confusing else and endif text 2020-02-15 12:29:54 +01:00
Albert Astals Cid
ad1b9e1b07 Enable QT_NO_CAST_FROM_ASCII 2020-02-15 10:21:12 +00:00
Albert Astals Cid
197b49677d openssl: Access NID_crl_number more correctly 2020-02-15 10:48:43 +01:00
Albert Astals Cid
9582a7970e openssl: Access NID_crl_reason more correctly 2020-02-15 10:47:03 +01:00
Albert Astals Cid
957e8ab4be test: Remove unused variable 2020-02-15 09:15:35 +00:00
Albert Astals Cid
8b171279e9 clazy: enable qstring allocation warning 2020-02-13 01:07:24 +01:00
Albert Astals Cid
4a98dbdcd9 Increase version for beta release 2020-02-12 18:53:56 +01:00
Albert Astals Cid
e2029649b9 clang-tidy: enable modernize-deprecated-headers and modernize-use-nullptr 2020-02-12 17:14:33 +01:00
Albert Astals Cid
c0ac498159 clazy: Enable container-anti-pattern
Except in the tests where being slow and convenient is better than fast
2020-02-12 16:55:18 +01:00
Albert Astals Cid
a29518b978 Add operator= to BigInt
Also make it just be implemented with the default as the tests
show that is enough

Fixes warning in newer gcc
2020-02-11 16:31:11 +01:00
Albert Astals Cid
001f827a4f Drop support for openssl <= 1.1 2020-02-11 14:09:19 +01:00
Albert Astals Cid
24e702e6cd Update rootcerts.pem 2020-02-10 00:36:27 +01:00
Albert Astals Cid
d26d7a7959 Add more override
And fix okular -> qca copy&paste typo ^_^
2020-02-09 01:21:32 +01:00
Albert Astals Cid
5ddf120260 More modern NSS/cmake 2020-01-30 18:23:59 +01:00
Albert Astals Cid
93336bb110 Enable more clang-tidy modernize checks 2020-01-30 18:02:17 +01:00
Albert Astals Cid
8ee19a09e2 Add a few modernize clang-tidy checks 2020-01-30 17:37:15 +01:00
Albert Astals Cid
0398e228de Add clang-tidy to the clazy CI 2020-01-30 16:55:33 +01:00
Albert Astals Cid
a177dbaae4 Remove QPROC_SIGNAL_RELAY define
It was always defined anyway, so makes the code easier to understand
2020-01-30 16:29:56 +01:00
Albert Astals Cid
4c31e0c81f static -> static const 2020-01-30 13:52:21 +01:00
Albert Astals Cid
c5f5a4c038 clazy: Enable level2 except a few checks
also a few of the manual checks
2020-01-29 17:36:23 +01:00
Albert Astals Cid
5e2751fe85 clazy: enable level1 2020-01-29 16:53:08 +01:00
Albert Astals Cid
294cf98f59 Enable all clazy level 0 tests except one
one: containter-anti-pattern, needs some bigger rework
2020-01-29 15:16:08 +01:00
Albert Astals Cid
dce16514fe Enable a clazy CI
Starting with only missing-qobject-macro check enabled
2020-01-29 14:31:55 +01:00
Albert Astals Cid
7df8f7e215 Move to the new connect syntax
QProcess::errorOccurred is since 5.6 so increase min version
2020-01-29 08:34:13 +00:00
Albert Astals Cid
9e9366bbef Add .gitlab-ci 2020-01-27 16:07:05 +01:00
Albert Astals Cid
c685525849 Fix compilation with older Qt 2020-01-27 15:21:03 +01:00
Albert Astals Cid
32c6eb989c Link only to invent as repo 2020-01-25 00:56:36 +01:00
Albert Astals Cid
e8a7e1f12b affinix.com is dead 2020-01-25 00:56:03 +01:00
Albert Astals Cid
987e447551 We don't work with Qt4 anymore 2020-01-25 00:55:47 +01:00
Albert Astals Cid
d61a1ce875 Rearrange README a bit 2020-01-25 00:54:38 +01:00
Albert Astals Cid
f9fc3f356f remove unused variables 2020-01-24 10:46:27 +01:00
Albert Astals Cid
d298a11af7 SASL_AUTH_EXTERNAL wants a char * not a char **
Reviewers: sitter

Reviewed By: sitter

Differential Revision: https://phabricator.kde.org/D26879
2020-01-23 23:33:03 +01:00
Albert Astals Cid
d3fd2d9a10 Don't store the char * of a bytearray.toLatin1().data()
It's dangling memory
2020-01-23 17:45:05 +01:00
Albert Astals Cid
d3f8ea684e QString::mid -> midRef 2020-01-23 17:40:59 +01:00
Albert Astals Cid
3d6e4e7c2e Enable QT_NO_URL_CAST_FROM_STRING 2020-01-23 17:29:27 +01:00
Albert Astals Cid
6a1d268315 Enable QT_NO_CAST_FROM_BYTEARRAY 2020-01-23 17:26:29 +01:00
Albert Astals Cid
2a988a2021 Add QT_NO_CAST_TO_ASCII 2020-01-23 17:19:49 +01:00
Albert Astals Cid
6b229c3ae2 Add QT_STRICT_ITERATORS 2020-01-23 17:18:46 +01:00
Albert Astals Cid
79af2e7fdf Enable QT_USE_QSTRINGBUILDER and QT_NO_NARROWING_CONVERSIONS_IN_CONNECT 2020-01-22 19:31:37 +01:00
Albert Astals Cid
dbef5838d4 Enable QT_NO_SIGNALS_SLOTS_KEYWORDS 2020-01-22 19:31:28 +01:00
Albert Astals Cid
80f58d05f0 Fix BotanHKDFContext::clone
And excercise it in the unittest
2020-01-21 17:41:24 +01:00
Albert Astals Cid
4449dd088b Fix KDFContex clone in botan/gcrypt
And excercise that from the unittest
2020-01-21 01:19:50 +01:00
Albert Astals Cid
29c7d98898 Fix MACContext clone in botan/gcrypt/nss
And excercise that from the unittest
2020-01-21 01:12:07 +01:00
Albert Astals Cid
0ce2b3927e Fix HashContext in botan/gcrypt/nss
And make sure the hashunittest exercises them
2020-01-21 00:54:10 +01:00
Albert Astals Cid
501a539c22 botan: Require botan2
It's already 2 years old, more than sensible to ask for uptodate crypto
stuff
2020-01-20 23:32:04 +01:00
Albert Astals Cid
156dd01575 hashunittest: Make finding the files easier 2020-01-20 23:16:15 +01:00
Albert Astals Cid
24df5ea742 hashunittest: Fail not warn if test files can't be found 2020-01-20 23:12:30 +01:00
Albert Astals Cid
c0d8f1807d botan: remove stdout here
This gets called on initialization and most people won't even probably
will be asking for this particular method so no need to be annoying
2020-01-20 23:04:36 +01:00
Albert Astals Cid
bdb0e9d37d hashunittest: test all providers 2020-01-20 23:03:31 +01:00
Albert Astals Cid
c1a4ad1ab1 botan: check md2 is supported before saying it is 2020-01-20 23:03:28 +01:00
Albert Astals Cid
61daaffee6 openssl: Reenable whirpool
If that means ancient openssl don't work, that's the problem of people
using ancient openssl
2020-01-20 22:49:09 +01:00
Albert Astals Cid
416d89268e ciphertest: Test all providers 2020-01-20 20:02:02 +01:00
Albert Astals Cid
391360f145 gcrypt: disable des, seems it fails on some cases 2020-01-20 20:02:02 +01:00
Albert Astals Cid
f429960d58 qcrypt: Fix crash on platforms where uint and size_t are different 2020-01-20 20:02:02 +01:00
Albert Astals Cid
a77ea02b8d botan: Check if ciphers are supported before saying they are
Now all tests pass :)
2020-01-20 20:02:02 +01:00
Laurent Montel
acb45eeb84 Use nullptr 2020-01-20 13:37:51 +01:00
Albert Astals Cid
694abbcafa kdfunittest: Test all the backends
and be less verbose when a backend doesn't support what we're testing,
it's fine if the some other one does
2020-01-20 01:01:02 +01:00
Albert Astals Cid
5105fc4981 botan: Make sure it supports pbkdf1(md2) before saying we to
At least my version (2.13.0) doesn't seem to support it

"Fixes" kdfunittest
2020-01-20 00:46:41 +01:00
Albert Astals Cid
b9d80939c6 botan: Fix crash if asking for something botan doesn't provide
Fixes crash in KDFUnitTest with my botan installation
2020-01-19 22:32:32 +01:00
Albert Astals Cid
1b061d63a8 gpg: use the loopback pinentry
otherwise we don't get asked back for passphrase like we want to
2020-01-19 22:17:53 +01:00
Albert Astals Cid
8adde8d9c7 Add file i forgot to commit, sorry ^_^ 2020-01-19 22:16:08 +01:00
Albert Astals Cid
a0194d7ffd qFind -> std::find 2020-01-19 18:01:15 +01:00
Albert Astals Cid
ba3fb44b49 qVariantSetValue -> QVariant::setValue 2020-01-19 17:59:03 +01:00
Albert Astals Cid
70406170f5 Cleanup Qt version checks 2020-01-19 17:57:35 +01:00
Albert Astals Cid
4ad7e911d9 QString::sprintf -> QString::asprintf 2020-01-19 17:45:25 +01:00
Albert Astals Cid
0816a04f42 qSort -> std::sort 2020-01-19 17:35:06 +01:00
Albert Astals Cid
83c23c7a3a QTime -> QElapsedTimer 2020-01-19 17:32:15 +01:00
Albert Astals Cid
d71f4c279b Drop Qt4 support 2020-01-19 17:19:23 +01:00
Albert Astals Cid
3293100c42 remove slot that was declared but never implemented 2020-01-19 17:01:19 +01:00
Albert Astals Cid
00d311d90f Add override 2020-01-19 16:28:44 +01:00
Albert Astals Cid
326399794e qca-botan: Don't crash if BotanCipherContext fails
Makes the cipher unit test at least not crash (even if it doesn't pass)
2020-01-19 16:27:09 +01:00
Albert Astals Cid
691395e193 BigInteger: Test the toArray/fromArray 2020-01-19 12:16:37 +01:00
Nicolas Fella
c167627675 Don't use obsolete qVariantFromValue
Test Plan: Same tests as before pass

Reviewers: iromanov, sitter, dfaure, #frameworks

Reviewed By: sitter

Differential Revision: https://phabricator.kde.org/D25802
2019-12-07 23:27:42 +01:00
Harald Sitter
4b11437f7a change the android condition to a getuid check
it's unclear if anyone would ever run a qca app as root on android, but
in case they do we'd still want to drop

discussed in D23289
2019-09-07 17:26:31 +02:00
Peter Petrik
2895ca34dd Fix QCA android build
Summary:
to be able to run Input App (Android), we have to avoid calls to setuid. Otherwise the application coredumps on this call during runtime.

see https://github.com/lutraconsulting/input-sdk/blob/master/android/recipes/qca/recipe.sh

Reviewers: sitter, dfaure

Reviewed By: sitter

Differential Revision: https://phabricator.kde.org/D23289
2019-09-07 17:26:28 +02:00
R.J.V. Bertin
0be2a2ced3 Call cmake_minimum_required() before project()
Also correct a typo.

Differential revision: https://phabricator.kde.org/D8510
2019-06-08 17:20:00 +02:00
R.J.V. Bertin
b614cdbd6e also set the INSTALL_NAME_DIR for regular Mac libs
Failing to do so can cause linker/loader failures when installing
the QCA library to a non-standard location (e.g. the Qt install tree).
2019-06-08 16:18:03 +02:00
Harald Sitter
db5f82be2a bump version to 2.2.1 2019-04-23 14:04:15 +02:00
Harald Sitter
b38e904a4e Partially revert "Require CMake 3.4 and use the OpenSSL imported libs"
Summary:
This reverts the QcaMacro changes of
commit 1137ed5f07d137296874f7dd1ee629f903507161 as they seem fairly
unrelated to the actual openssl change and proof to cause persistent issues
with buildability.

Further revert "unbreak build by moving away from deprecated exec_program"
This reverts commit 32419c899c77b8f5ece374d2453ee37e89af7c10.
Which was done in an attempt to remidy the build problems.

Further revert "Actually abort after the message that tells people to set CMAKE_INSTALL_PREFIX"
This reverts commit 63fd27fbce780bccb9c9b3ff6649888cfd809c6a.
Which was also done in an attempt to fix the problems.

BUG: 406353

Test Plan:
- when configuring without any arguments the qmake derived paths are used and correct
- when configuring with CMAKE_INSTALL_PREFIX the paths are accordingly reported below that

QCA prefix is /opt
Plugins will be installed to /opt/lib/qca-qt5
Binary will be installed to /opt/bin
Library will be installed to /opt/lib
Public headers will be installed to /opt/include/Qca-qt5
Private headers will be installed to /opt/include/Qca-qt5
Feature file will be installed to /opt/mkspecs/features
Documentation will be installed to /opt/share/doc/qca-qt5/html
Man page will be installed to /opt/share/man
Pkg-config file will be installed to /opt/lib/pkgconfig

Reviewers: dfaure, arojas, vonreth

Reviewed By: dfaure, arojas

Differential Revision: https://phabricator.kde.org/D20408
2019-04-23 14:03:50 +02:00
Harald Sitter
32419c899c unbreak build by moving away from deprecated exec_program
Summary:
since 1137ed5f07d137296874f7dd1ee629f903507161 which bumped cmake and
started using TARGET_FILE for the qmake calls qca failed to build for me.
I fail to understand why exactly that is but I suspect it has to do with
the fact that exec_program is deprecated and may not be working
(correctly?) with generator expressions.

moving to the not deprecated execute_process fixes clean builds on my
system and is at the very least a move away from deprecated tech with
no downsides

Test Plan: rm -rf * && cmake -DCMAKE_INSTALL_PREFIX=/usr ..

Reviewers: asturmlechner, dfaure, vonreth

Reviewed By: dfaure

Differential Revision: https://phabricator.kde.org/D20228
2019-04-08 11:32:48 +02:00
David Faure
63fd27fbce Actually abort after the message that tells people to set CMAKE_INSTALL_PREFIX
Test Plan:
`mkdir build ; cd build ; cmake ..` no longer prints out weird stuff after
the "!!!!" error message, it actually stops there as intended (AFAICS).
2019-03-29 09:17:38 +01:00
David Faure
7b03a01b18 Fix compilation error due to QByteArray/QString mixup
main.cpp:4251:35: error: no matching function for call to ‘QByteArray::indexOf(QString&)’
2019-03-17 00:09:21 +01:00
Hannah von Reth
1137ed5f07 Require CMake 3.4 and use the OpenSSL imported libs
Summary:
Fixes
 00:09:45.140 [162/278] Linking CXX shared module lib/qca-qt5/crypto/libqca-ossl.dylib
00:09:45.140 FAILED: lib/qca-qt5/crypto/libqca-ossl.dylib
00:09:45.140 : && /usr/bin/clang++ -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-headerpad_max_install_names  -o lib/qca-qt5/crypto/libqca-ossl.dylib plugins/qca-ossl/CMakeFiles/qca-ossl.dir/qca-ossl.cpp.o  lib/qca-qt5.framework/Versions/2.2.0/qca-qt5 /Users/packaging/Craft/BinaryCache/macos-64-clang/lib/libssl.dylib /Users/packaging/Craft/BinaryCache/macos-64-clang/lib/libcrypto.dylib -lcrypto /Users/packaging/Craft/BinaryCache/macos-64-clang/lib/QtCore.framework/QtCore -framework CoreFoundation -framework Security && :
00:09:45.140 ld: library not found for -lcrypto
00:09:45.140 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reviewers: dfaure, bcooksley, volkov

Reviewed By: dfaure

Differential Revision: https://phabricator.kde.org/D17913
2019-03-04 12:16:36 +01:00
Alexander Volkov
32343842d3 Fix build with botan < 2 and openssl < 1.1
Summary:
This commit amends f57d661416ecbdfbf9c16d8116c296cfdcbeb7d6.
HKDF support was added only in the new versions of the libs.

Reviewers: dfaure, bcooksley

Reviewed By: dfaure

Differential Revision: https://phabricator.kde.org/D16248
2018-10-17 14:54:34 +03:00
Nicolás Alvarez
ad50594cb2 Fix repeated 'the the' in comments. 2018-10-15 10:26:08 -03:00
Alexander Volkov
f57d661416 Introduce HKDF
Summary:
It's needed for implementation of Secret Service:
https://specifications.freedesktop.org/secret-service/ch07s03.html

Reviewers: iromanov, sitter, #frameworks, dfaure

Reviewed By: dfaure

Subscribers: dfaure

Differential Revision: https://phabricator.kde.org/D15510
2018-10-15 14:30:05 +03:00
Alexander Volkov
98eead0058 Add .arcconfig 2018-09-14 19:20:10 +03:00
Harald Sitter
da4d1d06d4 Openssl fix deprecation warnings
Summary:
Openssl fix deprecation warnings

Removed unused function: X509_SIG_getm

deprecated warnings for:
ASN1_STRING_data
DSA_generate_parameters
RSA_generate_key
RAND_pseudo_bytes

Tested with openssl-1.0.2l on ubuntu:14.04
Deprecation warning spotted with openssl-1.1.0.g-1

one deprecation warning left: TLSv1_client_method

Reviewers: sitter, fvogt

Reviewed By: fvogt

Differential Revision: https://phabricator.kde.org/D11616
2018-06-19 11:46:09 +02:00
Andreas Sturmlechner
e854f357f4 Make Qt5Network conditional on BUILD_TESTS
Summary: I did not find it in use somewhere else.

Reviewers: iromanov, sitter, rjvbb

Reviewed By: rjvbb

Subscribers: fvogt

Differential Revision: https://phabricator.kde.org/D12129
2018-06-06 11:21:17 +02:00
Antonio Rojas
78503bf574 Recommit botan 2 support without making botan mandatory
Differential Revision: https://phabricator.kde.org/D11997
2018-04-12 10:03:12 +02:00
Ben Cooksley
01cbb31770 Revert "Add botan 2 support"
This change adds a mandatory dependency on Botan, which is not available at this time within Craft.
As this change was not notified to Sysadmin and because it has left us in a state whereby we are unable to get the Windows CI system back up and running, this is being reverted so it can be brought back online.

Please reintroduce this change once support for having Botan as optional is restored

This reverts commit 47163784d74232e3a844fc42897bffc7eff817b4.
2018-04-12 19:48:32 +12:00
Antonio Rojas
47163784d7 Add botan 2 support
Botan 1.10 will be EOL'd this year. This patch is a rough port to botan 2 API. Also:

- Removes support for botan < 1.10 to simplify code (1.10 was released 7 years ago)
- Ports the cmake module to use pkgconfig, since botan-config doesn't exist anymore in v2.
- To minimize ifdef'd code, botan2 unique_ptr's are release'd
- Removes -ansi C(XX)FLAGS, botan 2 requires C++11

Differential Revision: https://phabricator.kde.org/D11997
2018-04-11 21:43:57 +02:00
Harald Sitter
3e6a86b6b8 Merge branch 'v2.1' 2018-03-22 12:16:44 +01:00
Harald Sitter
b1abd13319 Qca: fix cypto.prf on MacOs
Summary: Fixed crypto.prf for frameworks build with qt5

Reviewers: iromanov, sitter, rjvbb

Reviewed By: sitter, rjvbb

Differential Revision: https://phabricator.kde.org/D11480
2018-03-22 12:15:57 +01:00
Harald Sitter
ee536fd995 Merge remote-tracking branch 'origin/v2.1' 2018-03-22 12:02:31 +01:00
Fabian Vogt
d58e20ee65 Add support for OpenSSL 1.1.0
Test Plan:
Ran the testsuite with OpenSSL 1.1.0g and 1.0.2j, all passed.
Using this code with kdeconnect and okteta successfully on my system now.

Reviewers: iromanov

Subscribers: anthonyfieroni, alonbl, heikobecker, cfeck, asturmlechner, bero, rdieter

Differential Revision: https://phabricator.kde.org/D9416
2018-01-04 20:02:38 +01:00
Ivan Romanov
159e144abf Disable missed openssl cipher suites
Fedora 26 has no them.
2017-09-30 15:45:59 +05:00
Ivan Romanov
8871dcd2e1 Fix CMake warning
CMP 0020 is deprecated. Avoid using of old behaviour.
2017-09-18 22:28:00 +05:00
Ivan Romanov
df794c0181 Remove deprecated keyword 2017-07-08 09:53:45 +05:00
Alon Bar-Lev
5f18ebc705 build: fix C++11 throwing distructors
For >=C++11, explicitly mark throwing destructors `noexcept(false)`

Thanks: Peter-Levine <plevine457@gmail.com>
2017-03-21 12:34:29 +02:00
Ivan Romanov
be55b9c98d Fix Qt5.7 warning 2017-03-01 13:22:48 +05:00
Ivan Romanov
aec63cd2e6 Bump version to 2.1.3 2017-02-06 17:29:44 +05:00
Ivan Romanov
89800d4341 tlsunittest: disable some ciphers 2017-02-06 17:29:01 +05:00
Ivan Romanov
f4b2eb0ced Fix previous commit 2017-01-29 15:20:17 +05:00
Ivan Romanov
b435c1b87b Avoid @rpath on Mac OS 2017-01-29 14:06:08 +05:00
Samuel Gaist
7ba0ee591e OS X build and warning fix
Revert "Add missed file"

This reverts commit 4c9f27270e0a7c00c10cbc56ce5c6842b47e5ab2.

FindCoreFoundation.cmake is not needed since CoreFoundation
is a system framework. Its use has been removed by
commit f223ce03d4b94ffbb093fc8be5adf8d968f54434

Acked by: Ivan Čukić

REVIEW: 126285
2016-10-20 13:34:23 +02:00
Ivan Romanov
d320ef4fdb Add some missed headers to Qt Creator project 2016-10-10 21:50:18 +05:00
Ivan Romanov
28245c731e Add base64 convenience functions 2016-09-19 10:48:11 +05:00
Ivan Romanov
19ec49f89a Bump version to 2.2.0 2016-09-19 10:48:11 +05:00
Ivan Romanov
57878ff44f Add support for AES GCM and AES CCM modes
Only qca-openssl now can use GCM and CCM. CCM is not tested and
planed for future.
2016-09-19 10:48:11 +05:00
Ivan Romanov
4efa158c31 Improve documentation 2016-09-19 10:47:25 +05:00
Ivan Romanov
fdf961cfa3 Require CMake 3.0 on Mac OS X 2016-08-26 08:53:37 +05:00
Raphael Kubo da Costa
84f53aea25 qca-ossl: Remove SHA0 from all_hash_types() when it is not available.
Commit 0dbed8e ("qca-ossl: Fix build without support for SHA-0") forgot
to add an #ifdef check for SHA0 support in all_hash_types().

REVIEW: 128700
2016-08-18 08:52:57 +02:00
Ivan Romanov
6a685d6b0b Refactor cipherunittest 2016-08-09 11:26:47 +05:00
Ivan Romanov
759ff45dba Fix indents in cipherunittest 2016-08-09 10:48:36 +05:00
Rolf Eike Beer
eb5eeca609 fix the mkspecs install directory when cross-compiling using Qt5
REVIEW:128308
2016-07-02 19:05:19 +02:00
Rolf Eike Beer
601fd3a051 fix base64 decoding on ARM
This code was broken on ARM and other architectures where "char" is unsigned by
default.

First, it breaks with newer compilers with errors like:

  .../src/qca_textfilter.cpp:314:2: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing]

Second, if the compiler would just allow this conversion then the unsigned char
would hold 255, which would not be sign extended when cast to an int later, so
all the checks "< 0" will never trigger, and so invalid input characters cannot
be detected.

REVIEW:128295
BUG:364495
2016-06-27 18:24:02 +02:00
Ivan Romanov
a0c9a28728 Fix imported target name 2016-05-27 15:52:47 +05:00
Ivan Romanov
9e4bf79543 Fix install framework 2016-05-27 15:41:25 +05:00
Patrizio Bekerle
583d450885 fixed a typo 2016-03-17 11:03:42 +01:00
Samuel Gaist
f223ce03d4 OS X build and warning fix
The cmake find file was missing, but CoreFoundation being a system
framework, no need to search for it.

Update code to not use deprecated functions/data structure

CSSM_DATA and SecCertificateGetData have been deprecated since 10.7.
This patch uses SecCertificateCopyData which is the official
replacement.

Reviewed at https://git.reviewboard.kde.org/r/125800/
2015-12-08 21:32:39 +01:00
Rex Dieter
1ff36f4030 use _DEFAULT_SOURCE instead of _BSD_SOURCE
the former is used in other kde software in general, and
the latter is generally deprecated on modern glibc's
2015-11-19 13:23:16 -06:00
Ivan Romanov
4c9f27270e Add missed file
This file must be a part of 4fd11c444a51e8d317b0d68c7b90a8e0f2c6af9f
commit.

REVIEW: 121703
2015-11-18 23:54:14 +05:00
Ivan Romanov
69d8e070f0 Delete dead variable
className is not used. Furthemore it leads to possible crash when no _instance.
2015-11-11 12:35:10 +05:00
Ivan Romanov
da14be6f1b Fix empty strings in pluginPaths
Empty strings lead to strange behaviour and crashes.
2015-11-11 01:54:33 +05:00
Ivan Romanov
558f819819 gnupg: use utf-8 for keys output 2015-10-29 10:52:11 +05:00
Ivan Romanov
bf61f35cb4 gnupg: fixed keys is not updating
On Windows gpg uses ANSI codepage to output homedir and keyrings
paths. No way to output in utf-8. Gpg returns utf-8 strings output
only when --with-colons option is used.
2015-10-29 10:52:11 +05:00
Ivan Romanov
7e4192b70e gnupg: resolve symbolic links
Keyrings watcher can gets paths in any format. To avoid possible
problems try to use unified names for paths.
2015-10-29 10:52:11 +05:00
Ivan Romanov
7a76a9c027 qca-gnupg: default path to keyrings
When no keys 'gpg --list-keys' doesn't return path to keyring file.
Path is needest for watching to know when keys added or removed.
Use default keyrings path based on GnuPG home directory. This
directory gets with output 'gpg --version'. Line which starts with
'Home: ' contains GnuPG home directory. I believe it is correct
for GnuPG always and won't be changed in the future.
2015-10-29 10:52:11 +05:00
Heiko Becker
0dbed8eb38 qca-ossl: Fix build without support for SHA-0
LibreSSL >= 2.3.0 removed support for SHA-0, so there's no EVP_sha
anymore.
Wikipedia says about SHA-0: "160-bit hash function published in 1993
under the name SHA. It was withdrawn shortly after publication due to
an undisclosed "significant flaw" and replaced by the slightly revised
version SHA-1.'

REVIEW: 125387
2015-10-28 22:06:21 +01:00
Heiko Becker
20a587d776 qca-ossl: Fix build without SSLv3
This fixes building with LibreSSL >= 2.3.0 which has removed support
for SSLv3 completely. As far as I know OpenSSL can be configured to
build without it, so it might be helpful there as well.

REVIEW: 125386
2015-10-28 22:05:59 +01:00
Alon Bar-Lev
db17d5969b plugins: qca-logger: README: fix typo
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2015-10-23 22:32:07 +03:00
Harald Sitter
e44d0a335e bump version to 2.1.1 2015-10-02 11:35:20 +02:00
Harald Sitter
4f966b0217 Merge branch 'master' into qt5 2015-09-24 10:49:28 +02:00
Jan Grulich
66b9754170 Use Q_SLOTS/Q_SIGNALS instead of slots/signals in all headers from include dir
REVIEW:125289
2015-09-17 16:14:24 +02:00
Harald Sitter
088ff642fc Merge branch 'master' into qt5 2015-04-22 13:07:32 +02:00
Samuel Gaist
4fd11c444a Link against CoreFoundation rather than Carbon
Currently qca links to the Carbon framework for building however the mac
specific code don't use any Carbon classes but CoreFoundation. This patch
aims to update the code and build script to link to the more generic
CoreFoundation framework which may also allow to build it on iOS (not
verified).

REVIEW: 121703
2015-04-22 13:06:26 +02:00
Hrvoje Senjan
cc418554ad Merge remote-tracking branch 'origin/master' into qt5 2015-01-17 20:13:00 +01:00
Hrvoje Senjan
7207e6285e Add missing QIODevice include
Fixes build with Qt 5.5
2015-01-17 20:12:18 +01:00
Raphael Kubo da Costa
d4e9444f9d Do not end Cipher::Mode with a comma.
This solves a build failure with compilers such as GCC 4.2:
/usr/local/include/QtCrypto/qca_basic.h:598: error: comma at end of enumerator list

REVIEW: 122107
2015-01-17 15:21:20 +02:00
Harald Sitter
e40307d108 Merge remote-tracking branch 'origin/master' into qt5 2015-01-15 00:25:32 +01:00
Raphael Kubo da Costa
19aeaedd54 cmake: Make the check for QC_CERTSTORE_PATH actually work.
The previous code (present since the file was created) mixed different
checks that required different expansions:

* `if (ENV{foo})' will always evaluate to false even if $ENV{foo} is
  set, and may even be a CMake bug.
* `if (EXISTS ...)' expects an actual string, not an variable that has
  not been expanded.

It is not clear why the code expects QC_CERTSTORE_PATH to be an
environment variable instead of a regular variable passed to CMake in
the first place, but that can be changed in another commit.

REVIEW: 122062
2015-01-15 00:31:45 +02:00
Harald Sitter
b596e937b8 Revert "Revert "initialize QCA_SUFFIX cache with the possibly previously set SUFFIX""
This reverts commit c9f85b4dcab920d97a0959336ec71bc155209ccf.
2015-01-14 13:51:10 +01:00
Harald Sitter
b7f47694f8 Revert "Revert "properly support co-existing qt4 and qt5 versions""
This reverts commit 99128312fb91bc5f8e6320fe052bbaf7648102fe.
2015-01-14 13:51:07 +01:00
Ivan Romanov
99128312fb Revert "properly support co-existing qt4 and qt5 versions"
It's not properly. Martin Klapetek is not QCA developer. So it's not
correct that he said "Ship it!".

Properly way

cmake -DQCA_SUFFIX=qt5 ...

and in CMakeLists.txt of your project.

find_package(Qca NAMES Qca-qt5)

This reverts commit c32bc6f1bc9befe5f89d3572eb28e0d591a2e3b2.
2015-01-14 15:26:33 +05:00
Ivan Romanov
c9f85b4dca Revert "initialize QCA_SUFFIX cache with the possibly previously set SUFFIX"
I don't agree with this changes see https://git.reviewboard.kde.org/r/121168/
for details.

This reverts commit 3e3533b2753c8e47f0d22b77b564a0a6332cd5b8.
2015-01-14 15:24:11 +05:00
Harald Sitter
3e3533b275 initialize QCA_SUFFIX cache with the possibly previously set SUFFIX
this prevents us from unsetting what was previously set, making sure
the suffix is applied
2015-01-13 17:22:06 +01:00
Harald Sitter
c32bc6f1bc properly support co-existing qt4 and qt5 versions
- if QT4_BUILD is not defined *and* Qt5Core is found build with soname
  qca-qt5
- rename cmake package to reflect the suffix i.e. with a Qt5 build it is
  find_package(Qca-qt5) rather than find_package(Qca)
- the imported cmake target also reflects suffix so "Qca-qt5" is the
  cmake link target for qt5 and "Qca" for qt4 builds

this retains 100% compatibility with regular qca while also offering 100%
coinstallability of the qt5 build.

REVIEW: 121633
2014-12-28 14:26:50 +01:00
Harald Sitter
ffc53703ad put headers of a suffixed build in a suffixed directory
this makes the headers co-installable between a suffixed and regular
version

reviewed as part of r121323
2014-12-22 12:50:18 +01:00
Harald Sitter
4aae2dee34 prevent filewatches from emitting changes when there is no file
(this also fixes the flaky filewatch test that would fail for example on
 ubuntu launchpad builds)

it can happen that (supposedly for filesystem reasons) there are two
changes signals arriving in the watcher code, by the time the first arrives
the file would however already be deleted, by the time the second arrives
it would thus notify of changes to a file that does not exist which is
silly and causes problems with the filewatchtest as it uses signal emission
counting to verify the behavior.
to prevent this problem from popping up there is an additional save guard
in the file_changed slot that will ignore a change if the path in question
doesn't exist AND there is no file being watched by the watcher.

REVIEW: 121588
2014-12-19 16:47:40 +01:00
Harald Sitter
3b1bb19c7c add a reviewboardrc
REVIEW: 121325
2014-12-18 12:27:04 +01:00
Ivan Romanov
e57f8e7795 fixed array size checking
BUG: 341827
2014-12-13 01:54:53 +05:00
Harald Sitter
a67d31b1ec move QCA_CONFIG_NAME_BASE definition in the regular suffix if
(reviewed as part of r121323)
2014-12-02 13:32:09 +01:00
Harald Sitter
02be30908f fix library name in prf file to use the lib name variable
the lib name might be suffixed

(reviewed as part of r121323)
2014-12-02 13:29:52 +01:00
Ivan Romanov
9a9c16dfd1 cmake: fixed cmake config module when used QCA_SUFFIX 2014-11-29 00:57:31 +05:00
Ivan Romanov
98be0a1234 docs: fixed no images in docs when build out of source 2014-11-28 23:50:13 +05:00
Ivan Romanov
95223e9ee3 cmake: fixed warnings on android
do not use -Wcast-align on arm
2014-11-27 01:57:24 +05:00
Ivan Romanov
c8008de37b simplified md5_state_t and SHA1_CONTEXT internal structs
On arm is not correct to do int* = char* and throw warning. int must
be aligned unlike i686 and x86_64 archs. Anyway the old way to init
structs is not sane.
2014-11-27 01:55:47 +05:00
Ivan Romanov
20686e955c fixed compilation on android 2014-11-27 01:55:47 +05:00
Ivan Romanov
5d311c9219 cmake: build for android
Android uses .so as shared library suffix without version
2014-11-27 01:55:46 +05:00
Ivan Romanov
66447d0454 cmake: apply QCA_SUFFIX for cmake config module names 2014-11-22 06:30:07 +05:00
Ivan Romanov
2c58be171e cmake: warn user when QCA_SUFFIX is not set
Many linux distribution provides both version of Qt: Qt4 and Qt5.
These versions are binary is incompatible and any qt-based library
compiled against such Qt versions will be binary incompatible with
one another. In common case library name must not be related with
based libraries. In our case Linux users want to have both versions
QCA installed in their system. I will do not implicity rename Qt5
based QCA but just warn user and allow him explicity set QCA_SUFFIX.
2014-11-22 06:10:16 +05:00
Ivan Romanov
25860ff244 increased minimum cmake version
INCLUDE DESTINATION in install command was introduced only in CMake 2.8.12
2014-11-14 14:32:16 +05:00
Heiko Becker
593de6855a Fix build with libressl
libressl removed the SSL Compression functionality (which might
be considered insecure) and thus also compress_meth.
SSL_SESSION_get_compress_id is just a stub in libressl which always
returns 0 and in openssl it returns compress_meth.

REVIEW: 121107
2014-11-13 14:23:54 +05:00
Ivan Romanov
f8fe237c3c cmake: dropped dead variable 2014-11-13 02:13:50 +05:00
Ivan Romanov
72457bee3a qca-ossl: fixed compilation warnings 2014-11-13 02:13:50 +05:00
Ivan Romanov
8ffb52b439 cmake: pkg-config is not REQUIRED 2014-11-13 02:13:50 +05:00
Ivan Romanov
ca1667c118 dropped unused #include 2014-11-13 02:13:50 +05:00
Ivan Romanov
ef1b4b8eb0 Added myself to README 2014-11-06 13:15:45 +05:00
Ivan Romanov
f1b2a891c3 Updated changelog 2014-11-06 12:58:21 +05:00
Ivan Romanov
ba970ea670 added new note to TODO 2014-11-06 12:21:36 +05:00
Ivan Romanov
58e9539513 qca-ossl: added missed signatures 2014-11-06 12:16:27 +05:00
Ivan Romanov
f214d9c2a6 added frameworks support to crypto.prf 2014-11-05 22:42:32 +05:00
Ivan Romanov
0311beb5e5 cmake: do not use trailing slash for normalized paths 2014-11-05 22:42:32 +05:00
Ivan Romanov
13050bf00d cmake: plugins on Mac OS must use .dylib suffix 2014-11-05 22:42:32 +05:00
Ivan Romanov
de67ebfc8d cmake: USE_RELATIVE_PATHS now is option 2014-11-05 22:42:32 +05:00
Ivan Romanov
5de8ea800d cmake: added new option OSX_FRAMEWORK 2014-11-05 22:42:28 +05:00
Ivan Romanov
2445411897 cmake: added to previous commit 2014-11-05 22:34:22 +05:00
Ivan Romanov
35c678bee2 Revert "cmake: fixed path to qt mkspecs dir"
This reverts commit 2df13c85e866c7fc289cac867279bfc155a6307a.

It was wrong commit. Read http://qt-project.org/doc/qt-5/qmake-advanced-usage.html#adding-new-configuration-features
for detailes.
2014-11-05 22:29:35 +05:00
Ivan Romanov
d045cd7324 TODO: added plan for 2.2.0 version 2014-11-05 12:24:28 +05:00
Ivan Romanov
4694e4f1d7 dsaunittest: check for DSA_1024 is supported 2014-11-05 12:12:47 +05:00
Ivan Romanov
8ca9ddb56b keygenunittest: check that DLGroup supports DSA_* algorythmes 2014-11-05 12:06:58 +05:00
Ivan Romanov
ec8f991143 DLGroup: added extra checks 2014-11-05 11:57:35 +05:00
Ivan Romanov
638a8aff5c qca-ossl: no DSA_* dl groups in FIPS specification 2014-11-05 11:49:14 +05:00
Ivan Romanov
2e0fb206f9 cmake: do not use rpath
Distros often do not allow use rpath in packages (Fedora and Debian for example).
If need to have rpath CMAKE_INSTALL_RPATH can be set in command line.
2014-11-05 02:08:02 +05:00
Ivan Romanov
7f8346bbae cmake: fixed paths in crypto.prf when qca is relocatable 2014-11-05 01:52:48 +05:00
Ivan Romanov
2df13c85e8 cmake: fixed path to qt mkspecs dir 2014-11-05 01:40:02 +05:00
Ivan Romanov
a8240df544 dropped trash file 2014-10-21 12:29:05 +06:00
Ivan Romanov
6ee6f7f22a qca-gnupg: more refactoring 2014-10-07 04:26:33 +06:00
Ivan Romanov
9b8f978bff qca-gnupg: refactoring
Moved GpgAction to separate file.
2014-10-07 04:26:30 +06:00
Ivan Romanov
90b1287e52 qca-gnupg: some optimization in LineConverter 2014-10-07 02:01:17 +06:00
Ivan Romanov
5d28790cb5 qca-gnupg: refactoring
Moved LineConverter class to separate file
2014-10-07 01:14:14 +06:00
Ivan Romanov
47fc70af6e qca-gnupg: correct way to reset gpg proccess 2014-10-05 22:08:05 +06:00
Ivan Romanov
de02538aaf qca-gnupg: try to fix SIGPIPE again 2014-09-30 17:20:27 +06:00
Ivan Romanov
38eae11512 qca-gnupg: fixed SIGPIPE
need always close stding only after all data will be written
2014-09-30 04:58:15 +06:00
Ivan Romanov
f38eee2d18 qca-gnupg: refactoring 2014-09-29 15:20:13 +06:00
Ivan Romanov
380710aae0 qca-gnupg: refactoring
Moved find_bin, escape_string and unescape_string to separated source
file.
2014-09-29 02:24:13 +06:00
Ivan Romanov
fe0d1ad5c0 qca-gnupg: dropped ugly hack 2014-09-29 01:47:47 +06:00
Ivan Romanov
efb8da2402 qca-gnupg: dropped workaround for old unsupported Qt 2014-09-29 01:35:52 +06:00
Ivan Romanov
54e8363ddf qca-gnupg: cleaned trash 2014-09-29 01:21:24 +06:00
Ivan Romanov
13e7660ffb cmake: binary tree layout should be like normal HFS 2014-09-28 21:18:40 +06:00
Ivan Romanov
d598c689b7 cmake: no install target in developer mode 2014-09-28 21:14:26 +06:00
Ivan Romanov
686c8cac9a qca-gnupg: cleaned trash 2014-09-28 18:28:04 +06:00
Ivan Romanov
f0a5b957fc qca-gnupg: good debug message
Output diagnostic text to console if defined GPGOP_DEBUG
2014-09-28 18:22:59 +06:00
Pino Toscano
3548ee76e9 remove reference to (now) non-existing qt.tag
Commit a021c500edf9939eace2c7bbae6b9290b430f7be removed the qt.tag copy
in the qca sources, so don't point the Doxyfile to it.

Its usage was not optimal anyway, since the references to Qt classes
where still considered within the qca apidox.
2014-09-28 12:11:37 +02:00
Pino Toscano
a021c500ed remove qt4 tag file
Do not ship a copy of the tag file of Qt4, which increases archive size
and gives no benefits over using the upstream qt.tags.
2014-09-28 11:28:47 +02:00
Ivan Romanov
e8050ebbc1 fixed linking on Windows 2014-09-27 01:06:37 +06:00
Ivan Romanov
c00da86463 cmake: don't check for gpg program
gpg program is runtime dependency. Plugin can be built without it.
2014-09-27 00:53:47 +06:00
Ivan Romanov
0ef16c3837 cmake: some fixes with cached and advanced vars 2014-09-26 04:31:30 +06:00
Ivan Romanov
c9576b7c16 fixed compilation warnings on Windows 2014-09-25 15:42:30 +06:00
Ivan Romanov
ac8b8acd37 dropped fixpaths.include
Use qt.conf to set plugin paths for unittests and qcatool in buildtree
2014-09-25 14:27:44 +06:00
Ivan Romanov
3ebc9c14e2 SafeTimer: many fixes
1. SafeTimer now is common and public class. All plugins use this
   implementation.
2. Added debug messages in SafeTimer. Uncomment SAFETIMER_DEBUG to
   enable.
3. TimerFixer skips SafeTimer objects. No need extra fixes for
   SafeTimer. But can be problems with children of SafeTimer I
   believe no such.
2014-09-25 07:26:24 +06:00
Ivan Romanov
3cd0db9841 use native dir separator in diagnostic text 2014-09-24 18:12:03 +06:00
Ivan Romanov
ed4a05f674 qcatool: use native dir separators for output on console 2014-09-24 18:03:37 +06:00
Ivan Romanov
4b8e2214cd added new functiion pluginPaths
Retrieve plugin paths. It consists of:
1. QCA_PLUGIN_PATH environment if set.
2. QCoreApplication::libraryPaths() .
3. Directory where plugins were installed.

QCA_PLUGIN_PATH is paths list like PATH or QT_PLUGIN_PATH.
It uses system path separator. ";" on Windows and ":" on Unix.

Also qcatool now uses this function.
2014-09-24 17:47:35 +06:00
Ivan Romanov
192243d4bd cmake: fixed QCA_PLUGINS_INSTALL_DIR meaning
Plugins must be in crypto subdir. It is used internally in providers
finding algorythm. So now QCA_PLUGINS_INSTALL_DIR it is path to
crypto directory.
2014-09-24 16:00:39 +06:00
Ivan Romanov
2950458c77 qcatool: prevent crash when only options on command line without any commands 2014-09-23 18:32:25 +06:00
Ivan Romanov
2cdd6c4bd1 tlsunittest: disable more ciphers 2014-09-20 01:02:52 +06:00
Ivan Romanov
a8a26e0bf7 pgpunittests: increase timeout for crypting operations 2014-09-20 00:44:51 +06:00
Ivan Romanov
7268472226 pgpunittests: gpg keyring supports writing. See commit b6db383609d6b017dd2b9ae3809fc259c6397501 2014-09-20 00:02:21 +06:00
Ivan Romanov
1f155f4c55 KeyStoreTracker: initialize all data members of inner Item class in constructor 2014-09-19 23:30:50 +06:00
Ivan Romanov
bd0390b11c SafeTimer: new implementation
Old SafeTimer is not safe. QTimer dies when it changes thread. New
SafeTimer uses old-level timers which also sensetive for thread
change events. To handle this is here special trick which ressurect
timer in new thread.
2014-09-19 23:09:01 +06:00
Ivan Romanov
fe4971ccf1 pgpunittest: fixed start from any directory 2014-09-18 23:24:51 +06:00
Ivan Romanov
0e4e55f5bb Synchronizer: fixed new registration of timers
Since Qt 4.5 or 4.6 registerTimer with id argument is wrong. In really
registerTimer always generates new id. And version of the function
with id argument must be protected.

I didn't tested this fix. build.ko will do this for me.
2014-09-18 22:28:46 +06:00
Ivan Romanov
867ae093eb Syncronizer: fixed compilation when defined TIMERFIXER_DEBUG 2014-09-18 22:06:21 +06:00
Sune Vuorela
93f60f1626 Initialize memory is a class.
REVIEW: 120101
2014-09-12 21:58:10 +02:00
Sune Vuorela
a94f59da17 Fix some possible nullpointer dereferences
REVIEW: 120100
2014-09-09 09:20:13 +02:00
Sune Vuorela
df6e7a2377 Fix qt4 build 2014-09-08 15:41:07 +02:00
Florian Fieber
869b20e64b Add unit tests for expired subkey issue
If a key has a non-related, expired signing subkey, any operation on this key
previously would fail, claiming the key is expired.

REVIEW: 118567
2014-09-08 18:15:20 +06:00
Florian Fieber
2559f1779a Fix operating on keys with unrelated expired subkeys
Ignore KEYEXPIRED which will be thrown for any expired subkey regardless
of being related to the current operation. Instead, use EXPKEYSIG,
REVKEYSIG, EXPSIG and INV_RECP accordingly.

Add new errors QCA::SecureMessage::{ErrorSignerRevoked,
                                    ErrorSignatureExpired,
                                    ErrorEncryptRevoked}.

Due to GnuPG bug #1650 <https://bugs.g10code.com/gnupg/issue1650>
encrypting to an expired or revoked key will omit the reason for failing,
resulting in the error code QCA::SecureMessage::ErrorEncryptInvalid.

REVIEW: 118567
2014-09-08 18:14:40 +06:00
Sune Vuorela
1acc18cf38 Fix a couple of crashes where all plugins might not be available.
REVIEW: 120094
2014-09-08 10:16:57 +02:00
Aleix Pol
1563886480 Clean plugin lookup code
Do the proper query rather than use the default and blindly filter things
out
2014-09-01 17:35:07 +02:00
Ivan Romanov
bfe0784fde cmake: fixed when set empty CMAKE_INSTALL_PREFIX in command line 2014-08-26 16:24:59 +06:00
Ivan Romanov
c30f5d2455 cmake: fixed typo 2014-08-22 21:48:20 +06:00
Ivan Romanov
da1f8190ac cmake: use FindPkcConfig module instead of obsoletes PKGCONFIG 2014-08-21 03:10:34 +06:00
Ivan Romanov
6ee2797689 cmake: fixed paths in qca2.pc
After the latest commit cmake is trying to use relative paths.
But in pc file can be used only absolutes. So it is need to
generate this file before relative paths will be calculated.
2014-08-21 02:04:49 +06:00
Ivan Romanov
c42227f927 cmake: copy images for html docs in build tree 2014-08-12 13:23:28 +06:00
Ivan Romanov
101b99a657 docs: fixed repository place 2014-08-12 13:23:28 +06:00
Ivan Romanov
efd70c659e cmake: rewritten config package
Fixed algorythm to check for relocatable package.
On Windows when installing to Qt5 prefix QCA will not be relocatable.
2014-08-12 13:22:23 +06:00
Ivan Romanov
f3b284f565 cmake: install export targets to lib dir
share/cmake is wrong place for generated cmake files. For such files
should be used lib/cmake dir.

CCMAIL: aleixpol@kde.org
CCMAIL: kde-core-devel@kde.org
CCMAIL: kde-frameworks-devel@kde.org
2014-08-10 16:42:46 +06:00
Ben Cooksley
c8b445b04a Revert "Fix plugins lookup when not building in the Qt prefix"
This reverts commit 38e0665127650b3db5676c1dd5f0ffeb8cdb176f.

This change is incorrect, as Qt/QCA does not look within $pluginDir/qca/crypto when loading it's plugins.
Instead, it expects to find them within the $pluginDir/crypto/ subdirectory which no longer exists with this change.

While the use of lib/qca/ is non-standard for plugins, existing code within the CI scripts is able to handle this abnormality.
Normal Qt libraries which use plugins also function normally on the CI system.

The change as it stands does not work with Qt 4 and breaks all tests which are reliant upon QCA on the CI system.
As it appears a decision needs to be made on where QCA plugins should live and how they should be loaded i'm reverting this change to allow the tests to pass again.

CCMAIL: aleixpol@kde.org
CCMAIL: drizt@land.ru
CCMAIL: stephane@mankowski.fr
CCMAIL: kde-core-devel@kde.org
CCMAIL: kde-frameworks-devel@kde.org
2014-08-10 00:00:35 +12:00
Aleix Pol
38e0665127 Fix plugins lookup when not building in the Qt prefix
QCoreApplication::libraryPaths points to the QT_PLUGIN_PATH, these
usually point to the lib/plugins directory, rather than lib/ itself.
2014-08-01 01:48:23 +02:00
Aleix Pol
55093770df Export QCA targets
Makes it easier to adopt QCA by a cmake project by exporting the targets' include paths with the target.

REVIEW: 119231
2014-07-17 17:03:13 +02:00
Teo Mrnjavac
2c69c724d5 Wrap string literals in QStringLiteral in headers 2014-02-10 18:32:34 +01:00
Ivan Romanov
fbdf57f843 cmake: install .PDB files
On Windows when compiling with Visual Studio will be produced special
.pdb files for debuggins purposes. It must be put next to target
runtime (.dll or .exe) file.
2014-02-03 02:05:54 +06:00
Ivan Romanov
01bf129066 fix previous commit 2014-02-02 02:39:32 +06:00
Ivan Romanov
9504d1c8e0 cmake: put all runtime to bin when compiling
The most it is need for windows where no rpath and all dll's must be
in the same dir (or in PATH environment)
2014-02-02 02:35:55 +06:00
Ivan Romanov
e42df7e95c cmake: use standard BUILD_SHARED_LIBS instead of own SHARED_LIBRARY
BUILD_SHARED_LIBS is internally defined is cmake. So it is a
preferable way to choose shared or static library will be built.
2014-02-01 03:36:57 +06:00
Ivan Romanov
2502aad59d cmake: after compiling put all static libs to lib directory 2014-02-01 03:33:29 +06:00
Ivan Romanov
d9cbbf906d Supress cmake policy warnings on Windows 2014-02-01 01:26:15 +06:00
Ivan Romanov
dc42b9713f fix windows compilation warning
qca_systemstore_win.cpp hasn't Q_OBJECT macro.
It is regular C++ sources file.
2014-02-01 00:53:38 +06:00
Ivan Romanov
a917dc3a93 cipherunittest: check result after finish()
In common case update() function can not returns data.
So it is not a wrong. But after finish() all data must be returned.
2014-01-30 00:47:06 +06:00
Ivan Romanov
b049c59588 qca-botan: fixed getting result size for ciphers
Do not try to guess the result size. It rely with particular
algo and some other factors and so can be any. Just use
Pipe::remaining() for this purpose.
2014-01-30 00:33:50 +06:00
Ivan Romanov
184db75d4b cmake: use QT_HEADER_DIR instead of QT_INCLUDE_DIR
Qt/Mac frameworks has two include dirs.
One is the framework include for which CMake will add a -F flag
and the other is an include dir for non-framework Qt modules.
QT_INCLUDE_DIR contains both.
QT_HEADER_DIR is for non-framework Qt modules.
2014-01-28 17:33:58 +06:00
Ivan Romanov
eb54373946 cmake: use install(FILES ...) instead of old style install_files 2014-01-26 03:32:07 +06:00
Adnan RIHAN
71f932186b Fixed "unused variable" warning in qca-gcrypt plugin 2014-01-22 11:10:19 +01:00
Bartosz Brachaczek
0e2dd07cd1 Remove pointer to deinit() routine from QCoreApplication at deinitialization
REVIEW: 115159
2014-01-21 13:23:11 +06:00
Uwe L. Korn
9537815da5 Declare correct Qt version for pkg-config
REVIEW: 115050
2014-01-17 13:56:50 +06:00
Ivan Romanov
e2ff4f0a61 new cmake option DEVELOPER_MODE
DEVELOPER_MODE is designed for various developer issues. Now this mode
forced to use plugins only from build tree. To avoid excess plugins
from system QCA. Also now not need to set QT_PLUGIN_PATH to use plugins
from QCA build tree.
2014-01-07 04:47:18 +06:00
Ivan Romanov
e5ec390625 fix hardcoded plugins path for unittests 2014-01-07 00:24:49 +06:00
Adnan RIHAN
9e0ddb716d Overloaded "makeKey" to derive a password depending on a time factor
Overloaded "makeKey" in QCA::KeyDerivationFunction + botan/gcrypt/ossl plugins
to allow deriving a master password depending on a time factor in addition to
only giving an arbitrary iteration count.
Deriving with a time delays exhaustive research on master passwords by
increasing the time needed to try each password (the derivation time)
Added corresponding unittests.

REVIEW: 114503
2014-01-06 18:38:21 +01:00
Ivan Romanov
2817b31e06 pgpunittest: copy keys* folders to keys*_work
gpg changes trustdb.gpg. But this file under vcs. So just copy this
file to another folder.
2014-01-06 00:42:44 +06:00
Ivan Romanov
b0c8788d9a tlsunittest: don't check some cipher suites
openssl very configurable. There is no any guarantee that this
or another cipher suite will be in current building. So I just
took that Fedora cipher suites is minimal default list and
I believe that it will be true in every case.
2014-01-05 01:54:18 +06:00
Ivan Romanov
7d7535216a cipherunittest: disable qca-gcrypt for some tests
Seems Cipher support is not finished in qca-gcrypt. When it will be
done need to enable them again.
2014-01-03 22:33:43 +06:00
Ivan Romanov
80048dc7b9 qca-nss: fixed KeyLenght for Cipher
Before was KeyLength(0, 0, 0). Seems it is dummy.
2014-01-03 22:14:14 +06:00
Ivan Romanov
c820094625 filewatchunittest: show 'please wait' message 2014-01-03 19:43:45 +06:00
Ivan Romanov
01e2b1d1cd enabled filewatchunittest
also fixed cmake building of this unittest
2014-01-03 19:34:19 +06:00
Ivan Romanov
6dd10a4e91 Dropped useless script 2014-01-03 19:02:50 +06:00
Ivan Romanov
8098fc925f Added cmake doc target
Do not use doxygen directly. Often cmake build out-of-source.
So it usefult to have doc make target. It is required to generate
documentation for generating header file (qca_version.h) which places
in build tree.
2014-01-03 15:53:19 +06:00
Ivan Romanov
5bfb2dc9bf bump version to 2.1.0 2014-01-03 15:19:40 +06:00
Ivan Romanov
6bf4e5213e Define QCA version only in cmake rules
Added new generated public include qca_version.h.
Also add new version DEFINES
  QCA_MAJOR_VERSION
  QCA_MINOR_VERSION
  QCA_PATCH_VERSION
  QCA_VERSION_STR
  QCA_VERSION_CHECK(major, minor, patch)

and new version functions
  const char *qcaVersionStr()
  int qcaMajorVersion()
  int qcaMinorVersion()
  int qcaPatchVersion()
2014-01-03 14:37:00 +06:00
Bartosz Brachaczek
506d9ef311 Add unloadProvider() function for symmetry with insertProvider()
REVIEW: 114690
2014-01-02 17:23:42 +06:00
Ivan Romanov
6d690c0070 Build static QCA
Added new cmake variable SHARED_LIBRARY. By default is on.
When it is off QCA library, plugins, tools, examples and unittests
will be built as static. Also if is used static Qt plugins will be
built as static. Tested with Qt4.
2014-01-02 03:50:18 +06:00
Ivan Romanov
4edfa3fcba fixed previous commit 2014-01-02 00:02:12 +06:00
Ivan Romanov
1c09b7b8b1 Dropped own FindQt4 cmake module use system one 2014-01-01 22:32:10 +06:00
Ivan Romanov
94ab628411 Added botan-config-1.10 to list possible botan-config names
Such name is used on Fedora 20.
2014-01-01 21:26:43 +06:00
Ivan Romanov
dc5af5c374 fixed mozcerts building rules
Use QCA_SUFFIX when building mozcerts.
Place mozcerts binary in ./bin after linking.
2014-01-01 05:47:55 +06:00
Ivan Romanov
087357a810 Added cmake BUILD_TOOLS option
By default is 'on'. With this option will be compiled mozcerts
and qcatool.
2014-01-01 05:37:40 +06:00
Ivan Romanov
5d06579605 Use internal cache vars to choose plugins for building
It allow to know will be particular plugin build or no
in any place of cmake rules.
2014-01-01 02:10:15 +06:00
Adnan RIHAN
17cf1841f7 RSA Keys are permutable, can encrypt with private and decrypt with public
[REVIEW]: 114416
2013-12-17 06:57:26 +01:00
Ivan Romanov
9ea9d6203f [certunittest] fixed certs time zone
This certs time uses GMT.
2013-12-09 03:41:39 +06:00
Ivan Romanov
ea239aaf96 [ossl] fixed certs time zone 2013-12-09 03:32:59 +06:00
Ivan Romanov
31c9e2a76f added make uninstall target
thanks for Adnan RIHAN
2013-12-08 02:34:34 +06:00
Ivan Romanov
3048e63aa3 updated pkits certs
Also added README file which explain how certs ware got.
2013-12-07 22:08:39 +06:00
Ivan Romanov
d8993df06a small fix for previous commit 2013-12-05 01:34:56 +06:00
Ivan Romanov
7868e79a64 Mac OS X debug postfix 2013-12-04 22:51:32 +06:00
Ivan Romanov
7fd427f0c6 Corrected INSTALL file 2013-12-01 01:53:36 +06:00
Ivan Romanov
60b96878d7 fixed tab 2013-11-21 11:34:50 +06:00
Ivan Romanov
4e535d25e5 Fixed IID for all plugins
In Qt5 plugin IID is the same as identifier from Q_DECLARE_INTERFACE
2013-11-21 11:31:13 +06:00
Ivan Romanov
c7ccfc6749 dropped randomunittest
Captain Obvious suggests no way to check random numbers.
2013-11-18 02:11:22 +06:00
Ivan Romanov
2d1d815ab2 less warnings 2013-11-17 16:22:35 +06:00
Ivan Romanov
ab7ec14047 fixed rsa decription when no e or d
When private key has no Public Exponent (e) or Private Exponent (d)
need to disable blinding. Otherwise decryption will be broken.
http://www.mail-archive.com/openssl-users@openssl.org/msg63530.html
2013-11-17 16:09:14 +06:00
Ivan Romanov
e2ab61c10e Implement EME_PKCS1v15_SSL and EME_NO_PADDING in qca-ossl plugin 2013-11-17 02:33:26 +06:00
Ivan Romanov
3aafc9c4e3 added EME_PKCS1v15_SSL Encryption Algorithm
OpenSSL defines four encryption algorithms for RSA encryption. Added
new algorithm EME_PKCS1v15_SSL which identical with RSA_SSLV23_PADDING
2013-11-17 02:06:12 +06:00
Ivan Romanov
0b363c4048 Do not link against QtConcurrent 2013-11-16 20:19:31 +06:00
Ivan Romanov
094899a00c Optional plugins build
Now possible to build only required plugins and skip all others.
Also can get fail if required plugins can't be built.
By default will be build all possible plugins.

New cmake cache variables:

ENABLE_PLUGINS - list plugins to build (botan;ossl;gnupg for example).
                 Also possible values is none, auto or all
                 (by default: "auto")

WITH_${PLUGIN}_PLUGIN - to build particular plugin. Can be no, yes or
                        auto (WITH_ossl_PLUGIN=auto for example)
2013-11-11 21:08:56 +06:00
Ivan Romanov
a74aa82269 fix no watch file warnings in FileWatch
Don't start FileWatch object if no parent forlder non-existent.
Don't add file to Qt watcher class if the file non-existent.
It will be added after file creating
2013-10-18 23:49:33 +06:00
Ivan Romanov
239a0718d2 No CMAKE_INSTALL_PREFIX attention in red 2013-10-17 17:40:32 +06:00
Ivan Romanov
1b3249c6e2 changed plugins directory in build tree 2013-10-02 23:21:43 +06:00
Ivan Romanov
cb46853ffd Some directory layout fixes
In accordance with HFS applications may use a single subdirectory
under /usr/lib. If an application uses a subdirectory, all
architecture-dependent data exclusively used by the application
must be placed within that subdirectory.
2013-10-02 23:11:10 +06:00
Ivan Romanov
094929f903 renamed QCA_LIB_SUFFIX to QCA_SUFFIX
also anothers cmake optimizations
2013-10-02 22:49:27 +06:00
Ivan Romanov
013d6846fc oops, some changes for previous commit
forgot fix qcatool usage
forgot rename qcatool manpage
2013-10-02 22:23:33 +06:00
Ivan Romanov
49f312505c no digit postffix in qcatool2 name 2013-10-02 22:12:32 +06:00
Ivan Romanov
c97846b994 moved LIB_SUFFIX
LIB_SUFFIX has sense only when is using CMAKE_INSTALL_PREFIX
2013-10-02 01:45:15 +06:00
Ivan Romanov
76f0643e55 project name in lower case 2013-10-02 00:54:23 +06:00
Ivan Romanov
1bd99826d5 Revert "cmake: use GNUInstallDirs module"
It was a bad idea by default autotools uses /usr/local/lib
for installing libraries on ANY architecture. But GNUInstallDirs
uses some rules to detect a some lib suffix. Anyway seems
LIB_SUFFIX is a standard de facto way to specify this suffix
when it is need.

This reverts commit d594caf7f3285fc3be056c27079011b48b290587.
2013-10-02 00:51:42 +06:00
Ivan Romanov
f55fab268d cmake: some optimization with binary tree
plugins now is in lib/plugins/crypto
qcatool now is in bin
2013-10-01 08:01:50 +06:00
Ivan Romanov
d594caf7f3 cmake: use GNUInstallDirs module 2013-10-01 07:44:12 +06:00
Ivan Romanov
9ad63089fe Changed LIBRARY_OUTPUT_PATH to new-style
LIBRARY_OUTPUT_PATH is now documented as old-style and
should no longer be used. Should be used
CMAKE_LIBRARY_OUTPUT_DIRECTORY instead of.

Also dropped LIB_SUFFIX. I don't understand any sense
of this variable and it has no any comments.
Also googling no clear answer. So I just dropped it.
2013-10-01 07:14:49 +06:00
Ivan Romanov
728a2de655 cmake: put APPLE block after basic variables 2013-10-01 07:10:34 +06:00
Ivan Romanov
0a03235ade Fixed plugins install path when defined CMAKE_INSTALL_PREFIX
Now it is ${LIB_INSTALL_DIR}/plugins/crypto without qt folder
2013-09-24 23:28:46 +06:00
Ivan Romanov
638cf2aac7 cmake minumum version is 2.6.0 2013-09-24 18:23:38 +06:00
Ivan Romanov
25cbeefcb7 do not use QCA_INSTALL_IN_QT_PREFIX
This cache entry dropped. Now Qt prefix will be used only
if user explicity don't define CMAKE_INSTALL_PREFIX.
Also show attention for user if he didn't define CMAKE_INSTALL_PREFIX
2013-09-24 17:14:36 +06:00
Ivan Romanov
4362678874 Revert "Use qt5 suffix by default when installing a Qt5 version of QCA"
I don't agree with this patch. See my comments on
https://git.reviewboard.kde.org/r/111938/

This reverts commit bfeabc149ed64abc1a6186b9cd3cdd57f89fa5ec.
2013-09-24 01:37:03 +06:00
Ivan Romanov
0768474121 Remove ECM from INSTALL instructions
Now ECM not needest for Qt5 building. So this obsoletes.
2013-09-09 21:39:48 +06:00
Alex Richardson
cadbbd4f4f Also check for /etc/ssl/ca-bundle.pem as a system certificate store
This path is used at least for openSuSE
2013-09-03 14:41:15 +02:00
Alex Richardson
bfeabc149e Use qt5 suffix by default when installing a Qt5 version of QCA
This way coinstallation of Qt4 and Qt5 based QCA is possible by default

REVIEW: 111938
2013-09-03 14:38:32 +02:00
Ivan Romanov
034f873f68 use Qt5 C++ flags for examples, tools and unittests 2013-08-30 20:22:59 +06:00
Ivan Romanov
bd2c474039 no ECM 2013-08-30 20:18:00 +06:00
Ivan Romanov
b9b3f8045a cmake rules cosmetic 2013-08-28 14:51:43 +06:00
Ivan Romanov
e44dd906cd added description of PKGCONFIG_INSTALL_PREFIX to INSTALL instructions 2013-08-28 12:52:16 +06:00
Ivan Romanov
5700a5e2e5 On Windows dll is installing in bin dir 2013-08-28 03:59:20 +06:00
Ivan Romanov
eb011df617 fixed previous commit 2013-08-27 03:50:45 +06:00
Ivan Romanov
1c6dbab41a fix Qt5 mkspecs install dir 2013-08-27 03:41:39 +06:00
Ivan Romanov
a23f035f55 Added ECM requires to INSTALL instructions 2013-08-27 01:52:49 +06:00
Ivan Romanov
55e6545949 Added useful links to INSTALL 2013-08-26 01:28:47 +06:00
Ivan Romanov
0bfa3bf749 updated INSTALL instructions 2013-08-26 01:18:55 +06:00
Ivan Romanov
9462469bb5 dropped bat, qconf and qmake rules
Now cmake rules fully works.
2013-08-26 00:55:17 +06:00
Ivan Romanov
13d0dc5e6d added cmake variable QCA_LIB_SUFFIX
QCA_LIB_SUFFIX intended to replace workaround
3 major version. For building for Qt5 can be used
-DQCA_LIB_SUFFIX=qt5 for example. Result will be
named libqca2-qt5.so.2.0.3 library for Linux.
Also this suffix will be applied for qca2 pkg config file,
qcatool2 binary and qcatool2 manpage.

I hope that is a good way to resolve the building conflict
against qt4 and qt5.
2013-08-26 00:55:01 +06:00
Ivan Romanov
fc315c5bba added no padding encryption algorithm to qca core 2013-08-25 16:50:51 +06:00
Ivan Romanov
0a8b9db661 [qca-ossl] compiling without AES CTR
Actual openssl versions might have no AES CTR.
In this case qca-ossl will be compiled without AES CTR.

Also dropped own obsoletes FindOpenSSL.cmake.
System version is better choice.
2013-08-25 14:47:36 +06:00
Ivan Romanov
be172d527a fixed previous commit 2013-08-25 13:05:48 +06:00
Ivan Romanov
4320c6532b [qca-ossl] added support for aes ctr 128, 192 and 256 2013-08-25 03:36:58 +06:00
Ivan Romanov
affef9fc80 added CTR symetric cipher support to qca core 2013-08-25 00:23:19 +06:00
Ivan Romanov
7bee81cf0d fix with previous commit 2013-08-24 21:31:28 +06:00
Ivan Romanov
5f6e1759ed install in qt5 prefix 2013-08-24 21:27:08 +06:00
Ivan Romanov
44c7fbb74f install qca to prefix or qt_prefix
Added option QCA_INSTALL_IN_QT_PREFIX to provide a way to choose
default prefix for installing qca. By default is ON.
Also added a cache vars.
  QCA_PREFIX_INSTALL_DIR
  QCA_PLUGINS_INSTALL_DIR
  QCA_BINARY_INSTALL_DIR
  QCA_LIBRARY_INSTALL_DIR
  QCA_FEATURE_INSTALL_DIR
  QCA_INCLUDE_INSTALL_DIR
  QCA_PRIVATE_INCLUDE_INSTALL_DIR
  QCA_DOC_INSTALL_DIR
  QCA_MAN_INSTALL_DIR
2013-08-24 21:26:40 +06:00
Ivan Romanov
f2e705c9dd updated certs in cms unittests again 2013-08-07 18:31:25 +06:00
Ivan Romanov
1c0a8d987e updated certificates in smc unit tests 2013-08-01 22:37:09 +06:00
Ivan Romanov
917c314926 updated QcaTest* certificates in certunittest
old certificates expired in 2012 and this unittest failed.
2013-07-31 21:29:33 +06:00
Ivan Romanov
d4f444ec20 less warnings 2013-07-28 23:36:00 +06:00
Ivan Romanov
0423163ed6 fix pgp unit test
pgp unit test crashed with weird qFatal
I couldn't find a reason of this.
But this fix resolve that crash. I will hope
that is a good fix.
2013-07-28 23:03:33 +06:00
Ivan Romanov
e0cdd5db40 Revert "install qca to prefix or qt_prefix"
This reverts commit f5cb5b04dcb37ab4a62943c19646bcfa3d7d3b23.
2013-07-25 14:23:16 +06:00
Ivan Romanov
57aa7db0e3 less warnings 2013-07-24 23:52:37 +06:00
Ivan Romanov
f5cb5b04dc install qca to prefix or qt_prefix
Added option QCA_INSTALL_IN_QT_PREFIX to provide a way to choose
default prefix for installing qca. By default is ON.
Also added a cache vars.
  QCA_PREFIX_INSTALL_DIR
  QCA_PLUGINS_INSTALL_DIR
  QCA_BINARY_INSTALL_DIR
  QCA_LIBRARY_INSTALL_DIR
  QCA_FEATURE_INSTALL_DIR
  QCA_INCLUDE_INSTALL_DIR
  QCA_PRIVATE_INCLUDE_INSTALL_DIR
  QCA_DOC_INSTALL_DIR
  QCA_MAN_INSTALL_DIR
2013-07-24 22:08:12 +06:00
Ivan Romanov
c6aab53822 added placeholding files to restore empty folders from svn repo 2013-07-21 03:30:17 +06:00
Ivan Romanov
4f55e9b680 fix Windows line endings 2013-07-20 23:06:21 +06:00
Ben Cooksley
72fd118a27 Install QCA plugins in the correct location by default
svn path=/trunk/kdesupport/qca/; revision=1359069
2013-07-06 14:58:41 +00:00
Ivan Romanov
4dcfaae8ab [qca-ossl] tabify sources
svn path=/trunk/kdesupport/qca/; revision=1358066
2013-06-21 14:36:30 +00:00
Ivan Romanov
b5e5481ca5 [qca-gnupg] small fix with encodings
svn path=/trunk/kdesupport/qca/; revision=1357735
2013-06-14 16:16:45 +00:00
Ivan Romanov
1b67ea10b0 [qca] improved cmake modules
gpg executable now can be gpg2 too
FindLibGcrypt now will be worked on MinGW/MSYS

svn path=/trunk/kdesupport/qca/; revision=1357722
2013-06-14 10:02:14 +00:00
Ivan Romanov
21d951e5de [qca-gnupg] fixed encodings
svn path=/trunk/kdesupport/qca/; revision=1357715
2013-06-14 08:30:12 +00:00
Ivan Romanov
cf825de1cf [qca-gnupg] some optimization in find gpg binary code
svn path=/trunk/kdesupport/qca/; revision=1357646
2013-06-13 06:01:45 +00:00
Ivan Romanov
49b303a9cf [qca-gnupg] small fix with previous commit
svn path=/trunk/kdesupport/qca/; revision=1357591
2013-06-12 09:37:22 +00:00
Ivan Romanov
3156ab625f [qca-gnupg] improved gpg binary search
gpg binary can be named gpg or gpg2 name (gpg.exe or gpg2.exe on Windows)
First search in application directory. Then on Windows lookup for
'Install Directory' key in paths:
HKCU\Software\GNU\GnuPG
HKCU\Software\Wow6432Node\GNU\GnuPG
HKLM\Software\GNU\GnuPG
HKLM\Software\Wow6432Node\GNU\GnuPG.
In the last search in PATH environment. On Mac OS X also check
/usr/loca/bin and /opt/local/bin.

svn path=/trunk/kdesupport/qca/; revision=1357590
2013-06-12 08:17:24 +00:00
Ivan Romanov
f3315b6913 minor fix in Hash documentation
svn path=/trunk/kdesupport/qca/; revision=1356091
2013-05-23 10:19:50 +00:00
Ivan Romanov
7f1d1743d5 use QMAKE_MACOSX_DEPLOYMENT_TARGET from environment
svn path=/trunk/kdesupport/qca/; revision=1354734
2013-05-15 12:17:54 +00:00
David Faure
26bbdc2cf1 Make crypto.prf file reflect reality: this is where QCA is getting installed, which is not necessarily the Qt prefix.
svn path=/trunk/kdesupport/qca/; revision=1352135
2013-05-02 12:11:05 +00:00
David Faure
73ae6a3fc1 increase major version number when building with Qt5
svn path=/trunk/kdesupport/qca/; revision=1351800
2013-04-30 22:45:20 +00:00
David Faure
a765b0f1df Add option QT4_BUILD
svn path=/trunk/kdesupport/qca/; revision=1351793
2013-04-30 21:17:51 +00:00
Ivan Romanov
e4092537e6 [qca] porting to Qt5
http://qt-project.org/doc/qt-5.0/qtdoc/sourcebreaks.html
The QObject::connectNotify() and QObject::disconnectNotify() functions now need a QMetaMethod argument that identifies the signal, rather than a const char pointer.

svn path=/trunk/kdesupport/qca/; revision=1348086
2013-04-06 06:52:54 +00:00
Ivan Romanov
be81ce4bd5 enable examples and unittests for Qt5
svn path=/trunk/kdesupport/qca/; revision=1348032
2013-04-05 06:48:10 +00:00
David Faure
7d073db453 Finish port to Qt5: plugins. Patch by Ivan Romanov.
svn path=/trunk/kdesupport/qca/; revision=1347518
2013-04-02 12:41:12 +00:00
David Faure
e00ed4ce20 flatfile.cpp is for "other unixes", not for "X11" (which isn't set with qt5)
svn path=/trunk/kdesupport/qca/; revision=1347517
2013-04-02 12:37:47 +00:00
David Faure
57ce5c3bc9 Port to Qt5 by Ivan Romanov <drizt@land.ru>
svn path=/trunk/kdesupport/qca/; revision=1347515
2013-04-02 11:00:43 +00:00
David Faure
6e0134f3b3 Port to Qt5 (when Qt5 is found, otherwise use Qt4)
The unittests are disabled (because of QSKIP)
and the plugins currently break compilation (because of Q_EXPORT_PLUGIN2)

svn path=/trunk/kdesupport/qca/; revision=1338378
2013-02-07 20:19:00 +00:00
Justin Karneges
d349189b84 retrieve peer certificate chain. on mac, attempt to workaround openssl bugs
that apple introduced by validating the peer chain independent of ssl.

svn path=/trunk/kdesupport/qca/; revision=1311233
2012-08-17 01:05:56 +00:00
André Wöbbeking
312b693de0 compile with GCC 4.7
svn path=/trunk/kdesupport/qca/; revision=1273508
2012-01-14 17:12:15 +00:00
Justin Karneges
748af8203e fix compile when openssl doesn't support ssl2
svn path=/trunk/kdesupport/qca/; revision=1230301
2011-05-03 19:03:10 +00:00
Bernhard Rosenkraenzer
5618306b94 Support Botan 1.9.15 (AKA 1.10-rc1)
svn path=/trunk/kdesupport/qca/; revision=1225570
2011-03-21 17:20:41 +00:00
Justin Karneges
1df0a8e5d9 fix return value warnings
svn path=/trunk/kdesupport/qca/; revision=1201472
2010-11-27 20:38:00 +00:00
Justin Karneges
b982fe98f0 prepare for 2.0.3 release
svn path=/trunk/kdesupport/qca/; revision=1201470
2010-11-27 20:34:37 +00:00
Andre Heinecke
352e9bffbf Explicitly add an entry to link with ws2_32 on Windows.
Otherwise the build would fail if the Qt libraries do not pull
in ws2_32.

svn path=/trunk/kdesupport/qca/; revision=1196710
2010-11-13 23:16:29 +00:00
Justin Karneges
6f02652a99 fix bug in dsa signature generation when using IEEE_1363 format
svn path=/trunk/kdesupport/qca/; revision=1190163
2010-10-27 07:40:01 +00:00
Justin Karneges
54fe377ee0 support for rsa decryption with keys of other providers (e.g. pkcs11)
svn path=/trunk/kdesupport/qca/; revision=1179193
2010-09-24 19:42:02 +00:00
David Faure
e8059de1f6 Fix error with -Werror=return-type: not returning anything is undefined behavior here.
Please check what should be returned instead, though.
CCMAIL: bradh@frogmouth.net

svn path=/trunk/kdesupport/qca/; revision=1156630
2010-07-29 12:11:19 +00:00
Justin Karneges
34e8bed74f include stdlib even on windows
svn path=/trunk/kdesupport/qca/; revision=1131167
2010-05-27 14:38:53 +00:00
Justin Karneges
835d757b71 return null event if waitForCondition times out
svn path=/trunk/kdesupport/qca/; revision=1127606
2010-05-17 05:02:18 +00:00
Justin Karneges
b6db383609 gpg keyring supports writing
svn path=/trunk/kdesupport/qca/; revision=1127605
2010-05-17 05:01:28 +00:00
Patrick von Reth
0e7e3ada8f added definition to not include winsock.h automaticly with windows.h
svn path=/trunk/kdesupport/qca/; revision=1126324
2010-05-13 17:08:42 +00:00
Justin Karneges
e305fb28ba note about securebuffer
svn path=/trunk/kdesupport/qca/; revision=1125932
2010-05-12 17:55:50 +00:00
Maciej Mrozowski
38a76161a3 Actually detect whether MD2 is avalable for OpenSSL plugin
CCMAIL: fundawang@linux.net.cn

svn path=/trunk/kdesupport/qca/; revision=1115936
2010-04-18 01:59:31 +00:00
Funda Wang
4c9afd56cc build modules rather than shared libs for really modules
svn path=/trunk/kdesupport/qca/; revision=1111903
2010-04-07 00:26:26 +00:00
Funda Wang
ddbc7a0da5 conditional build md2 support
svn path=/trunk/kdesupport/qca/; revision=1111902
2010-04-07 00:24:14 +00:00
Alon Bar-Lev
2203a7aaab @DOC Modify qcatool usage thanks to Juha Tuomala
svn path=/trunk/kdesupport/qca/; revision=1081513
2010-01-28 15:11:29 +00:00
Justin Karneges
177149f8b4 in the docs, explain that signatures are more than just hash+pubkey operations
svn path=/trunk/kdesupport/qca/; revision=1062589
2009-12-15 09:48:04 +00:00
Urs Wolfer
014595173f optimizegraphics: Losslessly optimized PNG and SVGZ files with "optipng -o5" and "advdef -z -4".
Reduced disk space: 10144KB (9MB)

svn path=/trunk/kdesupport/qca/; revision=1062098
2009-12-13 19:51:03 +00:00
Bernhard Rosenkraenzer
311784a999 Make it build with current versions of Botan
(tested 1.8.8)

svn path=/trunk/kdesupport/qca/; revision=1058526
2009-12-04 16:02:11 +00:00
Justin Karneges
9576352278 update todo file
svn path=/trunk/kdesupport/qca/; revision=1046950
2009-11-10 00:52:08 +00:00
Bernhard Rosenkraenzer
07af05d41e Don't link qcatool to QtGui
svn path=/trunk/kdesupport/qca/; revision=1029338
2009-09-29 15:11:47 +00:00
Brad Hards
d6774e9a57 Display the list of capabilities of each provider for the "plugins" command, if we're in debug mode.
svn path=/trunk/kdesupport/qca/; revision=1024107
2009-09-16 02:51:43 +00:00
David Faure
c0eaef5f69 fix compilation with strict iterators
svn path=/trunk/kdesupport/qca/; revision=1017717
2009-08-31 09:31:02 +00:00
David Faure
221fb75106 Fix compilation with strict iterators
svn path=/trunk/kdesupport/qca/; revision=1010011
2009-08-11 12:28:55 +00:00
Justin Karneges
0e18d679bd make sure EVPKey does not use uninitialized data
svn path=/trunk/kdesupport/qca/; revision=997267
2009-07-15 17:13:37 +00:00
Brad Hards
5af426b83a Add support for certificates with SHA2 family digest algorithms.
svn path=/trunk/kdesupport/qca/; revision=992617
2009-07-07 12:24:51 +00:00
Bernhard Rosenkraenzer
0ce797a909 Make it build (and work) with OpenSSL 1.0 betas
svn path=/trunk/kdesupport/qca/; revision=978853
2009-06-08 11:08:43 +00:00
497 changed files with 66008 additions and 127593 deletions

3
.arcconfig Normal file
View File

@ -0,0 +1,3 @@
{
"phabricator.uri" : "https://phabricator.kde.org/"
}

99
.clang-format Normal file
View File

@ -0,0 +1,99 @@
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2019 Christoph Cullmann <cullmann@kde.org>
# Copyright (C) 2019 Gernot Gebhard <gebhard@absint.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Style for C++
Language: Cpp
# base is WebKit coding style: https://webkit.org/code-style-guidelines/
# below are only things set that diverge from this style!
BasedOnStyle: WebKit
# enforce C++11 (e.g. for std::vector<std::vector<lala>>
Standard: Cpp11
# 4 spaces indent
TabWidth: 4
# good enough for 2 panes
ColumnLimit: 120
# sort includes inside line separated groups
SortIncludes: true
# Mostly 'Linux' style but with different enums
BreakBeforeBraces: Custom
BraceWrapping:
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterCaseLabel: true
AfterFunction: true
# CrlInstruction *a;
PointerAlignment: Right
# horizontally aligns arguments after an open bracket.
AlignAfterOpenBracket: Align
# align trailing comments
AlignTrailingComments: true
# don't move all parameters to new line
AllowAllParametersOfDeclarationOnNextLine: false
# no single line functions
AllowShortFunctionsOnASingleLine: None
# always break before you encounter multi line strings
AlwaysBreakBeforeMultilineStrings: true
# don't move arguments to own lines if they are not all on the same
BinPackArguments: false
# don't move parameters to own lines if they are not all on the same
BinPackParameters: false
# don't break binary ops
BreakBeforeBinaryOperators: None
# format C++11 braced lists like function calls
Cpp11BracedListStyle: true
# remove empty lines
KeepEmptyLinesAtTheStartOfBlocks: false
# no namespace indentation to keep indent level low
NamespaceIndentation: None
# we use template< without space.
SpaceAfterTemplateKeyword: false
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
# put all '=' in one column for consecutive lines
AlignConsecutiveAssignments: true
# put all the variables/constants names on the same column
AlignConsecutiveDeclarations: true

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# _clang_format added
f62a8ee8f7e81a1b573c335ded3326d8ee985ab4

50
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,50 @@
build_ubuntu_20_10:
stage: build
image: ubuntu:groovy
before_script:
- sed -i -e 's/# deb-src/deb-src/g' /etc/apt/sources.list
- apt update
- apt install --yes eatmydata
- eatmydata apt build-dep --yes --no-install-recommends qca2
- eatmydata apt install --yes --no-install-recommends ninja-build libbotan-2-dev libnss3-dev libgcrypt20-dev libpkcs11-helper1-dev gnupg
script:
- mkdir -p build && cd build
- cmake -G Ninja ..
- ninja
- QT_PLUGIN_PATH=`pwd`/lib/qca-qt5/ ctest -V
build_fedora_34:
stage: build
image: fedora:34
before_script:
- dnf -y --setopt=install_weak_deps=False install git gcc-c++ make cmake ninja-build qt6-qtbase-devel qt6-qt5compat-devel botan2-devel cyrus-sasl-devel nss-devel libgcrypt-devel pkcs11-helper-devel gnupg
script:
- mkdir -p build && cd build
- cmake -G Ninja -DQT6=ON ..
- ninja
- QT_PLUGIN_PATH=`pwd`/lib/qca-qt6/ ctest -V
build_clazy_clang_tidy:
stage: build
image: debian:unstable
before_script:
- echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
- apt-get update
- apt-get install --yes eatmydata
- eatmydata apt-get build-dep --yes --no-install-recommends qca2
- eatmydata apt-get install --yes --no-install-recommends ninja-build libbotan-2-dev libnss3-dev libgcrypt20-dev libpkcs11-helper1-dev clazy clang clang-tidy jq gnupg
script:
- srcdir=`pwd` && mkdir -p /tmp/qca_build && cd /tmp/qca_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && mv compile_commands.aux.json compile_commands.json
- CLAZY_CHECKS="level0,level1,level2,no-copyable-polymorphic,no-ctor-missing-parent-argument,isempty-vs-count,qhash-with-char-pointer-key,qproperty-type-mismatch,qrequiredresult-candidates,signal-with-return-value,thread-with-slots,tr-non-literal,unneeded-cast" ninja
- "run-clang-tidy -header-filter='.*/qca/.*' -checks='-*,performance-*,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-use-bool-literals,modernize-redundant-void-arg,modernize-loop-convert,modernize-use-nullptr,-performance-no-automatic-move' -config=\"{WarningsAsErrors: '*'}\""
- QT_PLUGIN_PATH=`pwd`/lib/qca-qt5/ ctest -V
clang_format:
stage: build
image: debian:testing
before_script:
- apt-get update
- apt-get install --yes --no-install-recommends git clang-format-11
script:
- find . \( -name "*.cpp" -or -name "*.h" -or -name "*.c" -or -name "*.cc" \) -exec clang-format-11 -i {} \;
- git diff --exit-code

4
.reviewboardrc Normal file
View File

@ -0,0 +1,4 @@
REPOSITORY = "git://anongit.kde.org/qca"
REVIEWBOARD_URL = "https://git.reviewboard.kde.org"
TARGET_PEOPLE = "iromanov"
BRANCH = "master"

View File

@ -1,55 +1,155 @@
project(QCA)
# Checking for user explicitly defined CMAKE_INSTALL_PREFIX
# It must be done before project(...)
if(NOT CMAKE_INSTALL_PREFIX)
set(QCA_INSTALL_IN_QT_PREFIX ON)
# If CMAKE_INSTALL_PREFIX is set in cmake arguments
unset(CMAKE_INSTALL_PREFIX CACHE)
endif()
cmake_minimum_required(VERSION 2.4.5)
# The cmake min. version should be set before calling project(...) too
cmake_minimum_required(VERSION 3.4)
project(qca)
set(QCA_LIB_MAJOR_VERSION "2")
set(QCA_LIB_MINOR_VERSION "3")
set(QCA_LIB_PATCH_VERSION "3")
#if(POLICY CMP0042)
# cmake_policy(SET CMP0042 OLD)
#endif()
option(QT6 "Build with Qt 6" OFF)
option(BUILD_TESTS "Create test" ON)
option(BUILD_TOOLS "Compile mozcerts and qcatool" ON)
set(BUILD_PLUGINS "auto" CACHE STRING "Plugins for building (also possible values: none, all and auto)")
# BUILD_SHARED_LIBS is cmake variable. Need to change default value.
option(BUILD_SHARED_LIBS "Build shared library" ON)
option(DEVELOPER_MODE "Special developer mode" OFF)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
if(APPLE)
option(OSX_FRAMEWORK "Build a Mac OS X Framework" ON)
else()
set(OSX_FRAMEWORK OFF)
endif()
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where lib will install")
find_package(Doxygen)
set(PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files")
string(TOLOWER "${BUILD_PLUGINS}" BUILD_PLUGINS)
if(NOT BUILD_PLUGINS)
set(BUILD_PLUGINS "none")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
find_package(Qt4 REQUIRED)
# properly set up compile flags (QT_DEBUG/QT_NO_DEBUG, ...)
include(${QT_USE_FILE})
# Do not automatically link Qt executables to qtmain target on Windows.
# QCA exucatables use console mode only. Not need to link against qtmain.lib.
if(QT6)
message(STATUS "Building Qt 6 version")
find_package(Qt6 COMPONENTS Core Test Core5Compat REQUIRED)
else()
message(STATUS "Building Qt 5 version")
set(Qt5_NO_LINK_QTMAIN ON)
find_package(Qt5 5.14 REQUIRED Core)
endif()
set(QCA_LIB_MAJOR_VERSION "2")
set(QCA_LIB_MINOR_VERSION "0")
set(QCA_LIB_PATCH_VERSION "2")
set(CMAKE_AUTOMOC ON)
include(QcaMacro)
include(GNUInstallDirs)
setup_qt_dirs()
if(QT6)
set(QCA_QT_PC_VERSION "Qt6Core")
set(QCA_SUFFIX "qt6")
else()
set(QCA_QT_PC_VERSION "Qt5Core")
set(QCA_SUFFIX "qt5")
endif()
# QCA can be shared but plugins will be static
# if Qt is static.
if(NOT BUILD_SHARED_LIBS OR QT_IS_STATIC)
set(STATIC_PLUGINS ON)
add_definitions(-DQT_STATICPLUGIN)
set(PLUGIN_TYPE "STATIC")
else()
set(PLUGIN_TYPE "MODULE")
endif()
set(QCA_SUFFIX "${QCA_SUFFIX}" CACHE STRING "QCA common suffix")
if(QCA_SUFFIX)
set(QCA_LIB_NAME qca-${QCA_SUFFIX})
set(QCA_TOOL_NAME qcatool-${QCA_SUFFIX})
set(MOZCERTS_NAME mozcerts-${QCA_SUFFIX})
set(QCA_PC_NAME qca2-${QCA_SUFFIX}.pc)
set(QCA_CONFIG_NAME_BASE "Qca-${QCA_SUFFIX}")
else()
set(QCA_LIB_NAME qca)
set(QCA_TOOL_NAME qcatool)
set(MOZCERTS_NAME mozcerts)
set(QCA_PC_NAME qca2.pc)
set(QCA_CONFIG_NAME_BASE "Qca")
endif()
set(QCA_LIB_VERSION_STRING "${QCA_LIB_MAJOR_VERSION}.${QCA_LIB_MINOR_VERSION}.${QCA_LIB_PATCH_VERSION}")
if (APPLE)
find_package(Carbon REQUIRED)
set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif (APPLE)
# set up RPATH handling, so the libs are found if they are installed to a non-standard location, Alex
if (UNIX AND NOT APPLE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}" )
endif (UNIX AND NOT APPLE)
configure_file("include/QtCrypto/qca_version.h.in" "${CMAKE_BINARY_DIR}/qca_version.h")
if (WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
endif (WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
elseif (APPLE)
set(CMAKE_DEBUG_POSTFIX "_debug")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_SYSTEM_NAME MATCHES Linux)
add_definitions (-D_BSD_SOURCE)
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common")
endif (CMAKE_SYSTEM_NAME MATCHES Linux)
endif (CMAKE_COMPILER_IS_GNUCXX)
add_definitions (-D_DEFAULT_SOURCE)
# on arm -Wcast-align throws many internal qt warning
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
endif()
add_definitions (${QT_DEFINITIONS})
include_directories(include/QtCrypto/ ${QT_INCLUDES})
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -Wundef -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-check-new -fno-common")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -Wlogical-op" )
endif()
endif()
endif()
add_definitions(-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
if (NOT WIN32)
# Strict iterators can't be used on Windows, they lead to a link error
# when application code iterates over a QVector<QPoint> for instance, unless
# Qt itself was also built with strict iterators.
# See example at https://bugreports.qt.io/browse/AUTOSUITE-946
add_definitions(-DQT_STRICT_ITERATORS)
endif()
include_directories("include/QtCrypto/")
# for generated files
include_directories(${CMAKE_BINARY_DIR})
if(NOT DEVELOPER_MODE)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
# Always include srcdir and builddir in include path
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in about every subdir
@ -61,55 +161,179 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
set(qca_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/include" )
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}" )
set(qca_PLUGINSDIR "${QT_PLUGINS_DIR}/crypto/")
message(STATUS "Plugins will be installed to " ${qca_PLUGINSDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
# Use the same path for shared and static library
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
include(QcaMacro)
if( QCA_INSTALL_IN_QT_PREFIX )
set(QCA_PREFIX_INSTALL_DIR "${QT_PREFIX_DIR}" CACHE PATH "Directory where qca will install")
set(QCA_PLUGINS_INSTALL_DIR "${QT_PLUGINS_DIR}" CACHE PATH "Directory where qca plugins will install")
set(QCA_BINARY_INSTALL_DIR "${QT_BINARY_DIR}" CACHE PATH "Directory where qca plugins will install")
set(QCA_LIBRARY_INSTALL_DIR "${QT_LIBRARY_DIR}" CACHE PATH "Directory where qca library will install")
set(QCA_FEATURE_INSTALL_DIR "${QT_MKSPECS_DIR}/features" CACHE PATH "Directory where qca feature file will install")
if(NOT QCA_SUFFIX)
set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca public headers will install")
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}" CACHE PATH "Directory where qca headers will install")
else()
set(QCA_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install")
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${QT_HEADERS_DIR}/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install")
endif()
set(QCA_DOC_INSTALL_DIR "${QT_DOC_DIR}/html/qca/" CACHE PATH "Directory where qca documentation will install")
set(QCA_MAN_INSTALL_DIR "${QT_DATA_DIR}/man" CACHE PATH "Directory where qca man pages will install")
else()
# Cmake says nothing about LIB_SUFFIX
# de facto it is a standard way to specify lib suffix on many distros
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Directory where lib will install")
set(QCA_PREFIX_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Directory where qca will install")
set(QCA_PLUGINS_INSTALL_DIR "${LIB_INSTALL_DIR}/${QCA_LIB_NAME}" CACHE PATH "Directory where qca plugins will install")
set(QCA_BINARY_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Directory where qca plugins will install")
set(QCA_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}" CACHE PATH "Directory where qca library will install")
set(QCA_FEATURE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/mkspecs/features" CACHE PATH "Directory where qca feature file will install")
if(NOT QCA_SUFFIX)
set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca public headers will install")
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Directory where qca headers will install")
else()
set(QCA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca public headers will install")
set(QCA_PRIVATE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${QCA_CONFIG_NAME_BASE}" CACHE PATH "Directory where qca headers will install")
endif()
set(QCA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${QCA_LIB_NAME}/html" CACHE PATH "Directory where qca documentation will install")
set(QCA_MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Directory where qca man pages will install")
endif()
set(PKGCONFIG_INSTALL_PREFIX "${QCA_LIBRARY_INSTALL_DIR}/pkgconfig" CACHE PATH "Base directory for pkgconfig files")
normalize_path(QCA_PREFIX_INSTALL_DIR)
if(OSX_FRAMEWORK)
set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_LIBRARY_INSTALL_DIR}/${QCA_LIB_NAME}.framework/Headers")
else()
set(QCA_FULL_INCLUDE_INSTALL_DIR "${QCA_INCLUDE_INSTALL_DIR}/QtCrypto")
endif()
# check for oportunity to use relative paths
option(USE_RELATIVE_PATHS "Try to make relocatable package")
foreach(PATH QCA_PLUGINS_INSTALL_DIR
QCA_BINARY_INSTALL_DIR
QCA_LIBRARY_INSTALL_DIR
QCA_FEATURE_INSTALL_DIR
QCA_INCLUDE_INSTALL_DIR
QCA_PRIVATE_INCLUDE_INSTALL_DIR
QCA_DOC_INSTALL_DIR
QCA_MAN_INSTALL_DIR
PKGCONFIG_INSTALL_PREFIX)
# Normalize path before comparsion
normalize_path(${PATH})
# if all paths are subdirs of CMAKE_INSTALL_PREFIX it is possible to use relative paths
string(FIND "${${PATH}}" "${QCA_PREFIX_INSTALL_DIR}/" POS)
if(NOT "${POS}" STREQUAL "0")
set(USE_RELATIVE_PATHS OFF)
endif()
endforeach()
if(NOT WIN32)
if(OSX_FRAMEWORK)
set(PKGCONFIG_CFLAGS "-F\${libdir} -I\${includedir}")
set(PKGCONFIG_LIBS "-F\${libdir} -framework ${QCA_LIB_NAME}")
else()
set(PKGCONFIG_CFLAGS "-I\${includedir}")
set(PKGCONFIG_LIBS "-L\${libdir} -l${QCA_LIB_NAME}")
endif()
if(NOT QT6)
# qca2.pc uses absolute paths. So it must be there. Don't rellocate this.
configure_file("qca2.pc.cmake" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" @ONLY)
if(NOT DEVELOPER_MODE)
install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pkgconfig/${QCA_PC_NAME}" DESTINATION ${PKGCONFIG_INSTALL_PREFIX})
endif()
endif()
endif()
# strip CMAKE_INSTALL_PREFIX in all paths
if(USE_RELATIVE_PATHS)
message(STATUS "Installed package is relocatable")
file(RELATIVE_PATH CRYPTO_PRF_RELATIVE_PATH "${QCA_FEATURE_INSTALL_DIR}" ${CMAKE_INSTALL_PREFIX})
set(CRYPTO_PRF_RELATIVE_PATH "$$PWD/${CRYPTO_PRF_RELATIVE_PATH}")
foreach(PATH QCA_PLUGINS_INSTALL_DIR
QCA_BINARY_INSTALL_DIR
QCA_LIBRARY_INSTALL_DIR
QCA_FEATURE_INSTALL_DIR
QCA_INCLUDE_INSTALL_DIR
QCA_PRIVATE_INCLUDE_INSTALL_DIR
QCA_DOC_INSTALL_DIR
QCA_MAN_INSTALL_DIR
PKGCONFIG_INSTALL_PREFIX)
file(RELATIVE_PATH ${PATH} ${CMAKE_INSTALL_PREFIX} "${${PATH}}")
endforeach()
else()
message(STATUS "Installed package is NOT relocatable")
set(CRYPTO_PRF_RELATIVE_PATH "")
endif()
if(DEVELOPER_MODE)
add_definitions(-DDEVELOPER_MODE)
# To prefer plugins from build tree when run qca from build tree
file(WRITE ${CMAKE_BINARY_DIR}/bin/qt.conf
"[Paths]
Plugins=${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME}
")
endif()
if (APPLE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
message(STATUS "Checking for certstore..")
# fixme add OR mac
if( WIN32 )
# USE BUILTIN
else ( WIN32 )
if ( ENV{QC_CERTSTORE_PATH} )
if(EXISTS ENV{QC_CERTSTORE_PATH})
# USE BUILTIN
else()
if ( DEFINED ENV{QC_CERTSTORE_PATH} )
if(EXISTS $ENV{QC_CERTSTORE_PATH})
set( qca_CERTSTORE $ENV{QC_CERTSTORE_PATH})
else(EXISTS ENV{QC_CERTSTORE_PATH})
# path to try
endif(EXISTS ENV{QC_CERTSTORE_PATH})
else( ENV{QC_CERTSTORE_PATH} )
endif()
else()
set( toTry
"/etc/ssl/certs/ca-certificates.crt"
"/usr/share/ssl/cert.pem"
"/usr/share/ssl/certs/ca-bundle.crt"
"/etc/pki/tls/cert.pem"
"/etc/ssl/ca-bundle.pem"
"/usr/share/curl/curl-ca-bundle.crt"
)
foreach (_current_try ${toTry})
if(EXISTS ${_current_try})
set( qca_CERTSTORE ${_current_try})
endif(EXISTS ${_current_try})
endif()
endforeach (_current_try)
endif( ENV{QC_CERTSTORE_PATH} )
endif(WIN32)
endif()
endif()
if (qca_CERTSTORE)
message(STATUS "Found system certstore")
else (qca_CERTSTORE)
else()
message(STATUS "Using built in certstore.")
set( qca_CERTSTORE "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem")
# note that INSTALL_FILES targets are relative to the current installation prefix...
install_files( "/certs" FILES "${CMAKE_CURRENT_SOURCE_DIR}/certs/rootcerts.pem" )
endif (qca_CERTSTORE)
if(NOT DEVELOPER_MODE)
install(FILES "${qca_CERTSTORE}" DESTINATION "${QCA_PREFIX_INSTALL_DIR}/certs")
endif()
endif()
message(STATUS "certstore path: " ${qca_CERTSTORE})
add_definitions( -DQCA_SYSTEMSTORE_PATH="\\\"${qca_CERTSTORE}\\\"" )
add_definitions( -DQCA_SYSTEMSTORE_PATH="${qca_CERTSTORE}" )
set( private_HEADERS ${qca_INCLUDEDIR}/QtCrypto/qca_plugin.h ${qca_INCLUDEDIR}/QtCrypto/qca_systemstore.h )
set( public_HEADERS
set( public_HEADERS
${qca_INCLUDEDIR}/QtCrypto/qca.h
${qca_INCLUDEDIR}/QtCrypto/qcaprovider.h
${qca_INCLUDEDIR}/QtCrypto/QtCrypto
@ -124,32 +348,145 @@ set( public_HEADERS
${qca_INCLUDEDIR}/QtCrypto/qca_keystore.h
${qca_INCLUDEDIR}/QtCrypto/qca_securelayer.h
${qca_INCLUDEDIR}/QtCrypto/qca_securemessage.h
${qca_INCLUDEDIR}/QtCrypto/qpipe.h )
${CMAKE_BINARY_DIR}/qca_version.h
${qca_INCLUDEDIR}/QtCrypto/qpipe.h
${qca_INCLUDEDIR}/QtCrypto/qca_safetimer.h)
set( qca_HEADERS ${private_HEADERS} ${public_HEADERS} )
#install public headers only
install(FILES ${public_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/QtCrypto")
include_directories("${qca_INCLUDEDIR}/QtCrypto")
include_directories(${QT_QTCORE_INCLUDE_DIR} "${qca_INCLUDEDIR}/QtCrypto")
if(NOT QT6)
configure_file("crypto.prf.cmake" "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" @ONLY)
if(NOT DEVELOPER_MODE)
install(FILES "${CMAKE_BINARY_DIR}/mkspecs/features/crypto.prf" DESTINATION "${QCA_FEATURE_INSTALL_DIR}")
endif()
endif()
if(NOT WIN32)
configure_file("qca2.pc.cmake" "${CMAKE_BINARY_DIR}/qca2.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/qca2.pc" DESTINATION ${PKGCONFIG_INSTALL_PREFIX})
endif(NOT WIN32)
configure_file(man/qcatool.1 "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" COPYONLY)
if(NOT DEVELOPER_MODE)
install(FILES "${CMAKE_BINARY_DIR}/share/man/man1/${QCA_TOOL_NAME}.1" DESTINATION "${QCA_MAN_INSTALL_DIR}/man1")
endif()
configure_file("crypto.prf.cmake" "${CMAKE_BINARY_DIR}/crypto.prf" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/crypto.prf" DESTINATION ${CMAKE_INSTALL_PREFIX}/mkspecs/features)
install(FILES man/qcatool2.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
set(QCA_CRYPTO_INSTALL_DIR "${QCA_PLUGINS_INSTALL_DIR}/crypto")
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(plugins)
if(STATIC_PLUGINS)
# Generate header with static plugins list
file(WRITE "${CMAKE_BINARY_DIR}/import_plugins.h" "#include <QtPlugin>\n")
foreach(PLUGIN IN LISTS PLUGINS)
if(WITH_${PLUGIN}_PLUGIN_INTERNAL)
string(REPLACE "-" "_" IMPORT_NAME "qca-${PLUGIN}")
file(APPEND "${CMAKE_BINARY_DIR}/import_plugins.h" "Q_IMPORT_PLUGIN(${IMPORT_NAME})\n")
endif()
endforeach(PLUGIN IN LISTS PLUGINS)
endif()
if(BUILD_TESTS)
enable_testing()
add_subdirectory(unittest)
add_subdirectory(examples)
endif(BUILD_TESTS)
endif()
if(BUILD_TOOLS)
add_subdirectory(tools)
endif()
#if(DOXYGEN_FOUND)
# configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
# add_custom_target(doc
# ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
# COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs/pics
# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/docs/pics/qca-arch.eps ${CMAKE_BINARY_DIR}/docs/pics/qca-arch.eps
# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/docs/pics/qca-arch.png ${CMAKE_BINARY_DIR}/docs/pics/qca-arch.png
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# COMMENT "Generating API documentation with Doxygen" VERBATIM)
#endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/QcaConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake"
INSTALL_DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE}
)
write_basic_config_version_file("${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" VERSION ${QCA_LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion)
if(NOT DEVELOPER_MODE)
# /usr/local is traditional path for installing apps on POSIX-systems.
# I consciously break this. Qt by default looks plugins and features only in
# own directory. So by default install libs in Qt prefix it is a best choice.
# This can be unwanted behaviour for users who don't read INSTALL file or/and
# not read cmake reports. I just try to warn their.
# In really anybody who do cmake . && make && sudo make install do it for own risk.
if(QCA_INSTALL_IN_QT_PREFIX)
string(ASCII 27 ESCAPE)
message("")
message("${ESCAPE}[31m")
message("!!!!!!!!!!!!!!!!!!!!!ATTENTION!!!!!!!!!!!!!!!!!!!!!!")
message("!! QCA will be installed in Qt prefix !!")
message("!! If you want to install in /usr/local !!")
message("!! you MUST explicity define CMAKE_INSTALL_PREFIX !!")
message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
message("${ESCAPE}[0m")
endif()
message("")
if(USE_RELATIVE_PATHS)
message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}")
message("Plugins will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PLUGINS_INSTALL_DIR}")
message("Binary will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_BINARY_INSTALL_DIR}")
if(OSX_FRAMEWORK)
message("Framework will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}")
else()
message("Library will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_LIBRARY_INSTALL_DIR}")
message("Public headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_INCLUDE_INSTALL_DIR}")
message("Private headers will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_PRIVATE_INCLUDE_INSTALL_DIR}")
endif()
message("Feature file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_FEATURE_INSTALL_DIR}")
message("Documentation will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_DOC_INSTALL_DIR}")
message("Man page will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${QCA_MAN_INSTALL_DIR}")
message("Pkg-config file will be installed to " "${QCA_PREFIX_INSTALL_DIR}/${PKGCONFIG_INSTALL_PREFIX}")
else()
message("QCA prefix is " "${QCA_PREFIX_INSTALL_DIR}")
message("Plugins will be installed to " "${QCA_PLUGINS_INSTALL_DIR}")
message("Binary will be installed to " "${QCA_BINARY_INSTALL_DIR}")
if(OSX_FRAMEWORK)
message("Framework will be installed to " "${QCA_LIBRARY_INSTALL_DIR}")
else()
message("Library will be installed to " "${QCA_LIBRARY_INSTALL_DIR}")
message("Public headers will be installed to " "${QCA_INCLUDE_INSTALL_DIR}")
message("Private headers will be installed to " "${QCA_PRIVATE_INCLUDE_INSTALL_DIR}")
endif()
message("Feature file will be installed to " "${QCA_FEATURE_INSTALL_DIR}")
message("Documentation will be installed to " "${QCA_DOC_INSTALL_DIR}")
message("Man page will be installed to " "${QCA_MAN_INSTALL_DIR}")
message("Pkg-config file will be installed to " "${PKGCONFIG_INSTALL_PREFIX}")
endif()
message("")
if(UNIX AND NOT APPLE)
if(NOT QCA_SUFFIX)
message("${ESCAPE}[31mYou don't have QCA_SUFFIX set. Please note that the recommended way of")
if(QT6)
message("building Qt6 version of qca for Linux distributions is to set")
message("QCA_SUFFIX to qt6 (-DQCA_SUFFIX=qt6).")
else()
message("building Qt5 version of qca for Linux distributions is to set")
message("QCA_SUFFIX to qt5 (-DQCA_SUFFIX=qt5).")
endif()
message("${ESCAPE}[0m")
endif()
endif()
install(EXPORT ${QCA_CONFIG_NAME_BASE}Targets DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} FILE ${QCA_CONFIG_NAME_BASE}Targets.cmake)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake"
DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE}
)
endif()

View File

@ -462,9 +462,10 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = examples \
. \
include/QtCrypto
INPUT = @CMAKE_SOURCE_DIR@/examples \
@CMAKE_SOURCE_DIR@ \
@CMAKE_SOURCE_DIR@/include/QtCrypto \
@CMAKE_BINARY_DIR@/qca_version.h
# This tag can be used to specify the character encoding of the source files that
# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
@ -494,7 +495,7 @@ RECURSIVE = NO
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
EXCLUDE = @CMAKE_BINARY_DIR@/import_plugins.h
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
@ -526,27 +527,27 @@ EXCLUDE_SYMBOLS =
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH = examples/aes-cmac \
examples/base64test \
examples/certtest \
examples/ciphertest \
examples/cms \
examples/cmssigner \
examples/eventhandlerdemo \
examples/hashtest \
examples/hextest \
examples/keyloader \
examples/mactest \
examples/md5crypt \
examples/providertest \
examples/publickeyexample \
examples/randomtest \
examples/rsatest \
examples/saslclient \
examples/saslserver \
examples/ssltest \
examples/sslservtest \
examples/tlssocket
EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/examples/aes-cmac \
@CMAKE_SOURCE_DIR@/examples/base64test \
@CMAKE_SOURCE_DIR@/examples/certtest \
@CMAKE_SOURCE_DIR@/examples/ciphertest \
@CMAKE_SOURCE_DIR@/examples/cms \
@CMAKE_SOURCE_DIR@/examples/cmssigner \
@CMAKE_SOURCE_DIR@/examples/eventhandlerdemo \
@CMAKE_SOURCE_DIR@/examples/hashtest \
@CMAKE_SOURCE_DIR@/examples/hextest \
@CMAKE_SOURCE_DIR@/examples/keyloader \
@CMAKE_SOURCE_DIR@/examples/mactest \
@CMAKE_SOURCE_DIR@/examples/md5crypt \
@CMAKE_SOURCE_DIR@/examples/providertest \
@CMAKE_SOURCE_DIR@/examples/publickeyexample \
@CMAKE_SOURCE_DIR@/examples/randomtest \
@CMAKE_SOURCE_DIR@/examples/rsatest \
@CMAKE_SOURCE_DIR@/examples/saslclient \
@CMAKE_SOURCE_DIR@/examples/saslserver \
@CMAKE_SOURCE_DIR@/examples/ssltest \
@CMAKE_SOURCE_DIR@/examples/sslservtest \
@CMAKE_SOURCE_DIR@/examples/tlssocket
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@ -566,7 +567,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH = images
IMAGE_PATH = @CMAKE_SOURCE_DIR@/docs/pics
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
@ -1069,7 +1070,7 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED = QCA_EXPORT
EXPAND_AS_DEFINED = QCA_EXPORT QCA_NOEXCEPT
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
@ -1098,7 +1099,7 @@ SKIP_FUNCTION_MACROS = YES
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
TAGFILES = src/qt.tag
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.

57
INSTALL
View File

@ -1,36 +1,55 @@
Installing QCA
--------------
QCA requires Qt 4.2 or greater.
QCA requires Qt 5.5 or greater.
For Unix/Linux/Mac:
For Unix/Linux/Mac/Windows:
./configure
cmake .
make
make install
/sbin/ldconfig, if necessary
For Windows:
configure
nmake (or make)
installwin
Notes
-----
- On unix, use --prefix=$PWD to build in-place
Use cmake cache entries
Building from SVN
------------------
First, install the 'qconf' program, at least version 1.5. You can download
the source here:
http://delta.affinix.com/qconf/
CMAKE_INSTALL_PREFIX - must be defined otherwise QCA will be installed
in Qt prefix (by default: "")
BUILD_TESTS - build unittests (by default: ON)
BUILD_TOOLS - build mozcerts and qcatool (by default: ON)
QCA_SUFFIX - suffix will be used for library, qcatool binary,
qcatool manpage and qca pkg-config file (by default: "")
LIB_SUFFIX - library directory suffix (by default: "")
LIB_INSTALL_DIR - path to library directory
(by default: ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
BUILD_PLUGINS - list plugins to build (botan;ossl;gnupg for example).
Also possible values is none, auto or all
(by default: "auto")
WITH_${PLUGIN}_PLUGIN - to build particular plugin. Can be no, yes or
auto (WITH_ossl_PLUGIN=auto for example)
DEVELOPER_MODE - mode to enable features for developers. If ON
will be used hardcoded path to 'crypto'
(by default: OFF)
OSX_FRAMEWORK - build an OS X framework (by default: ON)
USE_RELATIVE_PATHS - make relocatable package if possible (by default: OFF)
Then, go into the QCA source tree and type 'qconf'. You should now have a
configure program to execute, just like from a normal source package.
Finally install paths can be override with:
QCA_PREFIX_INSTALL_DIR - qca prefix, just a origin to make other paths
QCA_PLUGINS_INSTALL_DIR - qt plugins path
QCA_BINARY_INSTALL_DIR - qcatool will be installed to
QCA_LIBRARY_INSTALL_DIR - qca library will be installed to
QCA_FEATURE_INSTALL_DIR - path to qt mkspecs dir
QCA_INCLUDE_INSTALL_DIR - path for QtCrypto dir with includes
QCA_PRIVATE_INCLUDE_INSTALL_DIR - for future implementation
QCA_DOC_INSTALL_DIR - for html documentation
QCA_MAN_INSTALL_DIR - for qcatool manpage
PKGCONFIG_INSTALL_PREFIX - path to install pkg config file
Please report problems to:
delta@lists.affinix.com
http://bugs.kde.org
Official git repo:
https://invent.kde.org/kde/qca

View File

@ -14,7 +14,7 @@
application!
%QCA should work everywhere %Qt does, including Windows/Unix/MacOSX. This
version of %QCA is for Qt4, and requires no Qt3 compatibility code.
version of %QCA is for Qt4 or Qt5, and requires no Qt3 compatibility code.
\section features Features
@ -150,26 +150,27 @@
\subsection qca2code Releases
The latest release packages can be found in the
<a href="http://delta.affinix.com/download/qca/2.0/">%QCA 2.0 download area</a>.
<a href="https://download.kde.org/stable/qca/">%QCA 2.x download area</a>.
See the <a href="http://delta.affinix.com/qca/">project web site</a> for
See the <a href="https://userbase.kde.org/QCA/">project web site</a> for
further information about %QCA releases.
\subsection qca2dev Current development
The latest version of the code is available from the KDE Subversion
server (there is no formal release of the current version at this time). See
<a href="http://developer.kde.org/source/anonsvn.html">
http://developer.kde.org/source/anonsvn.html
</a> for general instructions. You do <i>not</i> need kdelibs or
arts modules for %QCA - just pull down kdesupport/qca. The plugins
are in the same tree. Naturally you will need %Qt properly set up
and configured in order to build and use %QCA.
The latest version of the code is available from the KDE Git server
(there is no formal release of the current version at this time).
Naturally you will need %Qt properly set up and configured in order
to build and use %QCA.
The Subversion code can also be browsed
<a href="http://websvn.kde.org/trunk/kdesupport/qca/">
The Git code can be browsed
<a href="https://commits.kde.org/qca">
via the web</a>
Use
\verbatim
git clone https://invent.kde.org/libraries/qca.git
\endverbatim
to get the latest sources.
*/
/** \page architecture Architecture

7
QcaConfig.cmake.in Normal file
View File

@ -0,0 +1,7 @@
@PACKAGE_INIT@
if(NOT TARGET @QCA_LIB_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@QCA_CONFIG_NAME_BASE@Targets.cmake")
endif()
set(Qca_LIBRARY @QCA_LIB_NAME@)

110
README
View File

@ -1,23 +1,19 @@
Qt Cryptographic Architecture (QCA) version 2.0.2
-------------------------------------------------
Date: April 24th, 2009
Website: http://delta.affinix.com/qca/
Mailing List: Delta Project <delta@lists.affinix.com>
Qt Cryptographic Architecture (QCA)
-----------------------------------
Project Lead/Maintainer (2003-current):
Justin Karneges <justin@affinix.com>
(March 2007 - August 2007 under Barracuda Networks employment)
Description
-----------
Development, Documentation, Unittests (2004-current):
Brad Hards <bradh@frogmouth.net>
QCA is a library that provides an easy API for a range of cryptographic
features, including SSL/TLS, X.509 certificates, SASL, OpenPGP, smartcards,
and much more.
Special Thanks:
Portugal Telecom (SAPO division), for sponsorship
Alon Bar-Lev, for smart card and design assistance
Jack Lloyd, for Botan and X.509 mentoring
L. Peter Deutsch, for the public domain MD5 implementation
Steve Reid, for the public domain SHA1 implementation
Jason Kim, for the CMS Signer graphics
Functionality is supplied via plugins. This is useful for avoiding
dependence on a particular crypto library and makes upgrading easier,
as there is no need to recompile your application when adding or
upgrading a crypto plugin.
In order for QCA to be of much use, you'll want to install some plugins.
Install
@ -31,8 +27,52 @@ License
the COPYING file for more information.
Changes
History
-------
QCA was originally created to support the security needs of the
Psi XMPP/Jabber client project ( http://psi-im.org/ ).
Old Changes list
----------------
New in 2.1.0
- Ported to Qt5 (Qt4 also supported)
- New building system. CMake instead of qmake
- Added CTR symetric cipher support to qca core
- Added no padding encryption algorithm to qca core
- qcatool2 renamed to qcatool
- fixed crash in qcatool when only options provided on command line without any commands
- Use plugins installation path as hard-coded runtime plugins search path
- Added new functiion pluginPaths
- Added functions to get runtime QCA version
- Fixed 'no watch file' warnings in FileWatch
- Added EME_PKCS1v15_SSL Encryption Algorithm
- New implementation of SafeTimer to prevent crashes
- Updated certificates for unittests
- RSA Keys are permutable, can encrypt with private and decrypt with public
- Add unloadProvider() function for symmetry with insertProvider()
- Overloaded "makeKey" to derive a password depending on a time factor
- Remove pointer to deinit() routine from QCoreApplication at deinitialization
- Fix a couple of crashes where all plugins might not be available
- Fix operating on keys with unrelated expired subkeys
- Fixed timers in Synchronizer class
- Dropped randomunittest
- Fixed many unittests
- qca-gnupg: internal refactoring
- qca-gnupg: try both gpg and gpg2 to find gnupg executable
- qca-gnupg: fixed some encodings problem
- qca-ossl: no DSA_* dl groups in FIPS specification
- qca-ossl: added missed signatures to CRLContext
- qca-ossl: fixed certs time zone
- qca-nss: fixed KeyLenght for Cipher
- qca-botan: fixed getting result size for ciphers
New in 2.0.3
- Bugfix release, forward and backward compatible with 2.0.x
- Fix compilation when using Qt/Windows SDK
New in 2.0.2
- Bugfix release, forward and backward compatible with 2.0.x
- Fix compatibility with Qt 4.5 when QCA::Initializer appears before QApp
@ -51,25 +91,23 @@ Changes
- Windows version can be configured/installed using paths with spaces
Description
-----------
Old Developer list
------------------
QCA is a library that provides an easy API for a range of cryptographic
features, including SSL/TLS, X.509 certificates, SASL, OpenPGP, smartcards,
and much more.
Project Lead/Maintainer (2003-2012):
Justin Karneges <justin@affinix.com>
(March 2007 - August 2007 under Barracuda Networks employment)
Functionality is supplied via plugins. This is useful for avoiding
dependence on a particular crypto library and makes upgrading easier,
as there is no need to recompile your application when adding or
upgrading a crypto plugin.
Development, Documentation, Unittests (2004-2009):
Brad Hards <bradh@frogmouth.net>
In order for QCA to be of much use, you'll want to install some plugins.
Development (2013-2017)
Ivan Romanov <drizt@land.ru>
QCA was originally created to support the security needs of the
Psi XMPP/Jabber client project ( http://psi-im.org/ ).
API Documentation is located in the 'apidocs' subdirectory.
Have fun,
-Justin
Special Thanks:
Portugal Telecom (SAPO division), for sponsorship
Alon Bar-Lev, for smart card and design assistance
Jack Lloyd, for Botan and X.509 mentoring
L. Peter Deutsch, for the public domain MD5 implementation
Steve Reid, for the public domain SHA1 implementation
Jason Kim, for the CMS Signer graphics

14
README.clang-format Normal file
View File

@ -0,0 +1,14 @@
We introduced clang-format mandatory usage in September 2020.
If you want git blame to ignore the revision in which we did the mass change you can do
git config blame.ignoreRevsFile .git-blame-ignore-revs
on your clone
To get the clang-format warnings locally instead at CI time we recommend you
to copy the hooks/pre-commit to your .git
cp hooks/pre-commit .git/hooks/
We are using clang-format 11 on CI. Unfortunately clang-format is not totally
compatible with older versions of itself. If CI gives you trouble but your local
clang-format disagrees, just apply the changes suggested by CI and then commit
with the --no-verify flag. If you get stuck, don't hesitate to ask the reviewer
to help and they will reformat your commits :)

17
TODO
View File

@ -1,4 +1,17 @@
* 2.0.3
* 2.2.0
- New plugin qca-gpgme to replace current qca-gnupg. qca-gnupg requires
to have gpg binary which can be any 1.4.x or 2.x. Them behaviour is
different. gpg2 requires gpg-agent to ask user for passphrase. No
correct way to check that key requires passphrase.
- Add an interface for gnupg to handle keys (create and remove, maybe
something else).
- Add ECDSA support to qca-ossl plugin
-- Obsoletes
* 2.0.4
handle mac universal builds for arches besides x86 and ppc (e.g. x86_64)
use rpath?
cms example: User.pem expired. probably other certs need regen also?
fix publickeyexample. it encrypts with cms, decrypts with raw rsa??
@ -16,6 +29,8 @@
* 2.1.0
CertificateAuthority constructor provider argument should have default value
CertificateAuthority::createCertificate declared but not implemented!
CertificateCollection: ability to remove certs/crls?
pull kwallet's SecureBuffer?
* possibilities for the future:
abort if feature requested but not found, rather than crashing

11
app.pri
View File

@ -1,11 +0,0 @@
include(confapp.pri)
mac:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3
exists(crypto.prf) {
# our apps should build against the qca in this tree
include(crypto.prf)
} else {
# attempt to use system-wide qca
CONFIG *= crypto
}

View File

@ -1,5 +1,5 @@
rootcerts.pem is created by qca/tools/mozcerts
File: mozilla/security/nss/lib/ckfw/builtins/certdata.txt
Date: January 15th, 2009
File: https://hg.mozilla.org/mozilla-central/log/tip/security/nss/lib/ckfw/builtins/certdata.txt
Date: July 4, 2020

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
# - Try to find the Gcrypt library
# Once run this will define
#
# BOTAN_FOUND - set if the system has the gcrypt library
# BOTAN_CFLAGS - the required gcrypt compilation flags
# BOTAN_LIBRARIES - the linker libraries needed to use the gcrypt library
#
# Copyright (c) 2006 Brad Hards <bradh@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# libgcrypt is moving to pkg-config, but earlier version don't have it
#search in typical paths for libgcrypt-config
FIND_PROGRAM(BOTANCONFIG_EXECUTABLE NAMES botan-config)
#reset variables
set(BOTAN_LIBRARIES)
set(BOTAN_CFLAGS)
# if botan-config has been found
IF(BOTANCONFIG_EXECUTABLE)
EXEC_PROGRAM(${BOTANCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE BOTAN_LIBRARIES)
EXEC_PROGRAM(${BOTANCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE BOTAN_CFLAGS)
IF(BOTAN_LIBRARIES)
SET(BOTAN_FOUND TRUE)
ENDIF(BOTAN_LIBRARIES)
MARK_AS_ADVANCED(BOTAN_CFLAGS BOTAN_LIBRARIES)
ENDIF(BOTANCONFIG_EXECUTABLE)
if (BOTAN_FOUND)
if (NOT Botan_FIND_QUIETLY)
message(STATUS "Found Botan: ${BOTAN_LIBRARIES}")
endif (NOT Botan_FIND_QUIETLY)
else (BOTAN_FOUND)
if (Botan_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Botan libraries")
endif (Botan_FIND_REQUIRED)
endif (BOTAN_FOUND)

View File

@ -1,13 +0,0 @@
# Copyright (c) 2006, Benjamin Reed, <ranger@befunk.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
INCLUDE(CMakeFindFrameworks)
CMAKE_FIND_FRAMEWORKS(Carbon)
if (Carbon_FRAMEWORKS)
set(CARBON_LIBRARY "-framework Carbon" CACHE FILEPATH "Carbon framework" FORCE)
set(CARBON_FOUND 1)
endif (Carbon_FRAMEWORKS)

View File

@ -15,6 +15,7 @@
#search in typical paths for libgcrypt-config
FIND_PROGRAM(LIBGCRYPTCONFIG_EXECUTABLE NAMES libgcrypt-config)
mark_as_advanced(LIBGCRYPTCONFIG_EXECUTABLE)
#reset variables
set(LIBGCRYPT_LIBRARIES)
@ -23,13 +24,14 @@ set(LIBGCRYPT_CFLAGS)
# if libgcrypt-config has been found
IF(LIBGCRYPTCONFIG_EXECUTABLE)
EXEC_PROGRAM(${LIBGCRYPTCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE LIBGCRYPT_LIBRARIES)
# workaround for MinGW/MSYS
# CMake can't starts shell scripts on windows so it need to use sh.exe
EXECUTE_PROCESS(COMMAND sh ${LIBGCRYPTCONFIG_EXECUTABLE} --libs RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE LIBGCRYPT_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND sh ${LIBGCRYPTCONFIG_EXECUTABLE} --cflags RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE LIBGCRYPT_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
EXEC_PROGRAM(${LIBGCRYPTCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE LIBGCRYPT_CFLAGS)
IF(${LIBGCRYPT_CFLAGS} MATCHES "\n")
IF(NOT LIBGCRYPT_CFLAGS AND NOT _return_VALUE)
SET(LIBGCRYPT_CFLAGS " ")
ENDIF(${LIBGCRYPT_CFLAGS} MATCHES "\n")
ENDIF(NOT LIBGCRYPT_CFLAGS AND NOT _return_VALUE)
IF(LIBGCRYPT_LIBRARIES AND LIBGCRYPT_CFLAGS)
SET(LIBGCRYPT_FOUND TRUE)
@ -40,11 +42,11 @@ ENDIF(LIBGCRYPTCONFIG_EXECUTABLE)
if (LIBGCRYPT_FOUND)
if (NOT LibGcrypt_FIND_QUIETLY)
message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}")
endif (NOT LibGcrypt_FIND_QUIETLY)
else (LIBGCRYPT_FOUND)
endif()
else()
if (LibGcrypt_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libgcrypt libraries")
endif (LibGcrypt_FIND_REQUIRED)
endif (LIBGCRYPT_FOUND)
endif()
endif()
MARK_AS_ADVANCED(LIBGCRYPT_CFLAGS LIBGCRYPT_LIBRARIES)

View File

@ -1,46 +0,0 @@
# - Try to find the NSS library
# Once done this will define
#
# NSS_FOUND - system has mozilla-nss lib
# NSS_INCLUDE_DIRS - the mozilla-nss include directories
# NSS_LIBRARIES - Link these to use mozilla-nss
# NSS_DEFINITIONS - Compiler switches required for using NSS
#
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (NSS_INCLUDE_DIRS AND NSS_LIBRARIES)
# in cache already
SET(NSS_FOUND TRUE)
else (NSS_INCLUDE_DIRS AND NSS_LIBRARIES)
if(NOT WIN32)
INCLUDE(UsePkgConfig)
PKGCONFIG(nss _NSSIncDir _NSSLinkDir _NSSLinkFlags _NSSCflags)
set(NSS_DEFINITIONS ${_NSSCflags})
set(NSS_INCLUDE_DIRS ${_NSSIncDir})
set(NSS_LIBRARIES ${_NSSLinkFlags})
endif(NOT WIN32)
if (NSS_INCLUDE_DIRS AND NSS_LIBRARIES)
set(NSS_FOUND TRUE)
endif (NSS_INCLUDE_DIRS AND NSS_LIBRARIES)
if (NSS_FOUND)
if (NOT Nss_FIND_QUIETLY)
message(STATUS "Found NSS: ${NSS_LIBRARIES}")
endif (NOT Nss_FIND_QUIETLY)
else (NSS_FOUND)
if (Nss_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find NSS")
endif (Nss_FIND_REQUIRED)
endif (NSS_FOUND)
MARK_AS_ADVANCED(NSS_INCLUDE_DIRS NSS_LIBRARIES)
endif (NSS_INCLUDE_DIRS AND NSS_LIBRARIES)

View File

@ -1,108 +0,0 @@
# - Try to find the OpenSSL encryption library
# Once done this will define
#
# OPENSSL_FOUND - system has the OpenSSL library
# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
# OPENSSL_EAY_LIBRARIES - The additional libraries needed to use OpenSSL on windows
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# on win32 we additional need to link to libeay32.lib
MACRO(OPENSSL_ADD_LIB_EAY_LIBS)
IF(MSVC)
# /MD and /MDd are the standard values - if somone wants to use
# others, the libnames have to change here too
# use also eay and libeay32 in debug as fallback for openssl < 0.9.8b
FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd eay libeay libeay32)
FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD eay libeay libeay32)
IF(MSVC_IDE)
IF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
SET(OPENSSL_EAY_LIBRARIES optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG})
ELSE(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl (libeay)")
ENDIF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
ELSE(MSVC_IDE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_EAY_LIBRARIES ${LIB_EAY_DEBUG})
ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_EAY_LIBRARIES ${LIB_EAY_RELEASE})
ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
ENDIF(MSVC_IDE)
MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE)
ELSE(MSVC)
FIND_LIBRARY(OPENSSL_EAY_LIBRARIES NAMES eay libeay libeay32 )
ENDIF(MSVC)
ENDMACRO(OPENSSL_ADD_LIB_EAY_LIBS)
IF(OPENSSL_LIBRARIES)
SET(OpenSSL_FIND_QUIETLY TRUE)
ENDIF(OPENSSL_LIBRARIES)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(LIB_FOUND 1)
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
IF(WIN32 AND MSVC)
# /MD and /MDd are the standard values - if somone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
IF(MSVC_IDE)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl")
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
ELSE(MSVC_IDE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
ENDIF(MSVC_IDE)
MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
ELSE(WIN32 AND MSVC)
FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
ENDIF(WIN32 AND MSVC)
IF(WIN32)
OPENSSL_ADD_LIB_EAY_LIBS()
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
SET(OPENSSL_FOUND TRUE)
ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
SET(OPENSSL_FOUND FALSE)
ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
ELSE(WIN32)
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND TRUE)
ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND FALSE)
ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
ENDIF(WIN32)
IF (OPENSSL_FOUND)
IF (NOT OpenSSL_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
ENDIF (NOT OpenSSL_FIND_QUIETLY)
ELSE (OPENSSL_FOUND)
IF (OpenSSL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
ENDIF (OpenSSL_FIND_REQUIRED)
ENDIF (OPENSSL_FOUND)
MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)

View File

@ -3,8 +3,8 @@
#
# PKCS11H_FOUND - system has pkcs11-helper
# PKCS11H_INCLUDE_DIRS - the pkcs11-helper include directories
# PKCS11H_LIBRARIES - Link to these to use pkcs11-helper
# PKCS11H_DEFINITIONS - Compiler switches required for using pkcs11-helper
# PKCS11H_LDFLAGS - Link to these to use pkcs11-helper
# PKCS11H_CFLAGS_OTHER - Compiler switches required for using pkcs11-helper
#
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
#
@ -14,36 +14,27 @@
# pkcs11-helper can be found at http://www.opensc-project.org/pkcs11-helper
#
if (PKCS11H_INCLUDE_DIRS AND PKCS11H_LIBRARIES)
if(PKCS11H_INCLUDE_DIRS AND PKCS11H_LDFLAGS)
# in cache already
SET(PKCS11H_FOUND TRUE)
else (PKCS11H_INCLUDE_DIRS AND PKCS11H_LIBRARIES)
else()
if(NOT WIN32)
INCLUDE(UsePkgConfig)
find_package(PkgConfig)
pkg_search_module(PKCS11H libpkcs11-helper-1)
endif()
PKGCONFIG(libpkcs11-helper-1 _PKCS11HIncDir _PKCS11HLinkDir _PKCS11HLinkFlags _PKCS11HCflags)
set(PKCS11H_DEFINITIONS ${_PKCS11HCflags})
set(PKCS11H_INCLUDE_DIRS ${_PKCS11HIncDir})
set(PKCS11H_LIBRARIES ${_PKCS11HLinkFlags})
endif(NOT WIN32)
if (PKCS11H_INCLUDE_DIRS AND PKCS11H_LIBRARIES)
set(PKCS11H_FOUND TRUE)
endif (PKCS11H_INCLUDE_DIRS AND PKCS11H_LIBRARIES)
if (PKCS11H_FOUND)
if (NOT Pkcs11Helper_FIND_QUIETLY)
message(STATUS "Found pkcs11-helper: ${PKCS11H_LIBRARIES}")
endif (NOT Pkcs11Helper_FIND_QUIETLY)
else (PKCS11H_FOUND)
message(STATUS "Found pkcs11-helper: ${PKCS11H_LDFLAGS}")
endif()
else()
if (Pkcs11Helper_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find pkcs11-helper")
endif (Pkcs11Helper_FIND_REQUIRED)
endif (PKCS11H_FOUND)
endif()
endif()
MARK_AS_ADVANCED(PKCS11H_INCLUDE_DIRS PKCS11H_LIBRARIES)
mark_as_advanced(PKCS11H_INCLUDE_DIRS PKCS11H_LDFLAGS PKCS11H_CFLAGS_OTHER)
endif (PKCS11H_INCLUDE_DIRS AND PKCS11H_LIBRARIES)
endif()

View File

@ -1,883 +0,0 @@
# - Find QT 4
#
# This is a modified version for QCA, that provides the plugin path
# See: http://www.cmake.org/Bug/bug.php?op=show&bugid=3898
#
# This module can be used to find Qt4.
# The most important issue is that the Qt4 qmake is available via the system path.
# This qmake is then used to detect basically everything else.
# This module defines a number of key variables and macros. First is
# QT_USE_FILE which is the path to a CMake file that can be included to compile
# Qt 4 applications and libraries. By default, the QtCore and QtGui
# libraries are loaded. This behavior can be changed by setting one or more
# of the following variables to true:
# QT_DONT_USE_QTCORE
# QT_DONT_USE_QTGUI
# QT_USE_QT3SUPPORT
# QT_USE_QTASSISTANT
# QT_USE_QTDESIGNER
# QT_USE_QTMOTIF
# QT_USE_QTMAIN
# QT_USE_QTNETWORK
# QT_USE_QTNSPLUGIN
# QT_USE_QTOPENGL
# QT_USE_QTSQL
# QT_USE_QTXML
#
# All the libraries required are stored in a variable called QT_LIBRARIES.
# Add this variable to your TARGET_LINK_LIBRARIES.
#
# macro QT4_WRAP_CPP(outfiles inputfile ... )
# macro QT4_WRAP_UI(outfiles inputfile ... )
# macro QT4_ADD_RESOURCE(outfiles inputfile ... )
# macro QT4_AUTOMOC(inputfile ... )
# macro QT4_GENERATE_MOC(inputfile outputfile )
#
# QT_FOUND If false, don't try to use Qt.
# QT4_FOUND If false, don't try to use Qt 4.
#
# QT_QTCORE_FOUND True if QtCore was found.
# QT_QTGUI_FOUND True if QtGui was found.
# QT_QT3SUPPORT_FOUND True if Qt3Support was found.
# QT_QTASSISTANT_FOUND True if QtAssistant was found.
# QT_QTDESIGNER_FOUND True if QtDesigner was found.
# QT_QTMOTIF_FOUND True if QtMotif was found.
# QT_QTNETWORK_FOUND True if QtNetwork was found.
# QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
# QT_QTOPENGL_FOUND True if QtOpenGL was found.
# QT_QTSQL_FOUND True if QtSql was found.
# QT_QTXML_FOUND True if QtXml was found.
# QT_QTSVG_FOUND True if QtSvg was found.
# QT_QTTEST_FOUND True if QtTest was found.
#
# QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
#
# QT_INCLUDES List of paths to all include directories of
# Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
# always in this variable even if NOTFOUND,
# all other INCLUDE_DIRS are
# only added if they are found.
#
# QT_INCLUDE_DIR Path to "include" of Qt4
# QT_QT_INCLUDE_DIR Path to "include/Qt"
# QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
# QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
# QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
# QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
# QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
# QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
# QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
# QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
# QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
# QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
#
# QT_LIBRARY_DIR Path to "lib" of Qt4
#
# QT_PLUGINS_DIR Path to "plugins" for Qt4
#
# For every library of Qt there are three variables:
# QT_QTFOO_LIBRARY_RELEASE, which contains the full path to the release version
# QT_QTFOO_LIBRARY_DEBUG, which contains the full path to the debug version
# QT_QTFOO_LIBRARY, the full path to the release version if available, otherwise to the debug version
#
# So there are the following variables:
# The Qt3Support library: QT_QT3SUPPORT_LIBRARY
# QT_QT3SUPPORT_LIBRARY_RELEASE
# QT_QT3SUPPORT_DEBUG
#
# The QtAssistant library: QT_QTASSISTANT_LIBRARY
# QT_QTASSISTANT_LIBRARY_RELEASE
# QT_QTASSISTANT_LIBRARY_DEBUG
#
# The QtCore library: QT_QTCORE_LIBRARY
# QT_QTCORE_LIBRARY_RELEASE
# QT_QTCORE_LIBRARY_DEBUG
#
# The QtDesigner library: QT_QTDESIGNER_LIBRARY
# QT_QTDESIGNER_LIBRARY_RELEASE
# QT_QTDESIGNER_LIBRARY_DEBUG
#
# The QtGui library: QT_QTGUI_LIBRARY
# QT_QTGUI_LIBRARY_RELEASE
# QT_QTGUI_LIBRARY_DEBUG
#
# The QtMotif library: QT_QTMOTIF_LIBRARY
# QT_QTMOTIF_LIBRARY_RELEASE
# QT_QTMOTIF_LIBRARY_DEBUG
#
# The QtNetwork library: QT_QTNETWORK_LIBRARY
# QT_QTNETWORK_LIBRARY_RELEASE
# QT_QTNETWORK_LIBRARY_DEBUG
#
# The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY
# QT_QTNSPLUGIN_LIBRARY_RELEASE
# QT_QTNSPLUGIN_LIBRARY_DEBUG
#
# The QtOpenGL library: QT_QTOPENGL_LIBRARY
# QT_QTOPENGL_LIBRARY_RELEASE
# QT_QTOPENGL_LIBRARY_DEBUG
#
# The QtSql library: QT_QTSQL_LIBRARY
# QT_QTSQL_LIBRARY_RELEASE
# QT_QTSQL_LIBRARY_DEBUG
#
# The QtXml library: QT_QTXML_LIBRARY
# QT_QTXML_LIBRARY_RELEASE
# QT_QTXML_LIBRARY_DEBUG
#
# The QtSvg library: QT_QTSVG_LIBRARY
# QT_QTSVG_LIBRARY_RELEASE
# QT_QTSVG_LIBRARY_DEBUG
#
# The QtTest library: QT_QTTEST_LIBRARY
# QT_QTTEST_LIBRARY_RELEASE
# QT_QTTEST_LIBRARY_DEBUG
#
# The qtmain library for Windows QT_QTMAIN_LIBRARY
# QT_QTMAIN_LIBRARY_RELEASE
# QT_QTMAIN_LIBRARY_DEBUG
#
#The QtUiTools library: QT_QTUITOOLS_LIBRARY
# QT_QTUITOOLS_LIBRARY_RELEASE
# QT_QTUITOOLS_LIBRARY_DEBUG
#
# also defined, but NOT for general use are
# QT_MOC_EXECUTABLE Where to find the moc tool.
# QT_UIC_EXECUTABLE Where to find the uic tool.
# QT_UIC3_EXECUTABLE Where to find the uic3 tool.
# QT_RCC_EXECUTABLE Where to find the rcc tool
#
# QT_DOC_DIR Path to "doc" of Qt4
# QT_MKSPECS_DIR Path to "mkspecs" of Qt4
#
#
# These are around for backwards compatibility
# they will be set
# QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
# QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
#
# These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
# QT_MT_REQUIRED Qt4 is now always multithreaded
#
# These variables are set to "" Because Qt structure changed
# (They make no sense in Qt4)
# QT_QT_LIBRARY Qt-Library is now split
INCLUDE(CheckSymbolExists)
INCLUDE(MacroAddFileDependencies)
SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
SET( QT_DEFINITIONS "")
IF (WIN32)
SET(QT_DEFINITIONS -DQT_DLL)
ENDIF(WIN32)
# check for qmake
FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt4 PATHS
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
$ENV{QTDIR}/bin
)
SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
IF (QT_QMAKE_EXECUTABLE)
SET(QT4_QMAKE_FOUND FALSE)
EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
# check that we found the Qt4 qmake, Qt3 qmake output won't match here
STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
IF (qt_version_tmp)
# we need at least version 4.0.0
IF (NOT QT_MIN_VERSION)
SET(QT_MIN_VERSION "4.0.0")
ENDIF (NOT QT_MIN_VERSION)
#now parse the parts of the user given version string into variables
STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
IF (NOT req_qt_major_vers)
MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
ENDIF (NOT req_qt_major_vers)
# now parse the parts of the user given version string into variables
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
IF (NOT req_qt_major_vers EQUAL 4)
MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
ENDIF (NOT req_qt_major_vers EQUAL 4)
# and now the version string given by qmake
STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_qt_major_vers "${QTVERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_qt_minor_vers "${QTVERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_qt_patch_vers "${QTVERSION}")
# compute an overall version number which can be compared at once
MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}")
IF (found_vers LESS req_vers)
SET(QT4_QMAKE_FOUND FALSE)
SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
ELSE (found_vers LESS req_vers)
SET(QT4_QMAKE_FOUND TRUE)
ENDIF (found_vers LESS req_vers)
ENDIF (qt_version_tmp)
ENDIF (QT_QMAKE_EXECUTABLE)
IF (QT4_QMAKE_FOUND)
# ask qmake for the library dir
# Set QT_LIBRARY_DIR
IF (NOT QT_LIBRARY_DIR)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QT_INSTALL_LIBS"
OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
ENDIF(NOT QT_LIBRARY_DIR)
IF (APPLE)
IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
SET(QT_USE_FRAMEWORKS ON
CACHE BOOL "Set to ON if Qt build uses frameworks.")
ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
SET(QT_USE_FRAMEWORKS OFF
CACHE BOOL "Set to ON if Qt build uses frameworks.")
ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
ENDIF (APPLE)
# ask qmake for the binary dir
IF (NOT QT_BINARY_DIR)
EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
ARGS "-query QT_INSTALL_BINS"
OUTPUT_VARIABLE qt_bins )
SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
ENDIF (NOT QT_BINARY_DIR)
# ask qmake for the include dir
IF (NOT QT_HEADERS_DIR)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QT_INSTALL_HEADERS"
OUTPUT_VARIABLE qt_headers )
SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
ENDIF(NOT QT_HEADERS_DIR)
# ask qmake for the documentation directory
IF (NOT QT_DOC_DIR)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QT_INSTALL_DOCS"
OUTPUT_VARIABLE qt_doc_dir )
SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
ENDIF (NOT QT_DOC_DIR)
# ask qmake for the mkspecs directory
IF (NOT QT_MKSPECS_DIR)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QMAKE_MKSPECS"
OUTPUT_VARIABLE qt_mkspecs_dir )
SET(QT_MKSPECS_DIR ${qt_mkspecs_dir} CACHE PATH "The location of the Qt mkspecs")
ENDIF (NOT QT_MKSPECS_DIR)
# ask qmake for the plugins directory
IF (NOT QT_PLUGINS_DIR)
EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
ARGS "-query QT_INSTALL_PLUGINS"
OUTPUT_VARIABLE qt_plugins_dir )
SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
ENDIF (NOT QT_PLUGINS_DIR)
########################################
#
# Setting the INCLUDE-Variables
#
########################################
FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
${QT_HEADERS_DIR}/QtCore
${QT_LIBRARY_DIR}/QtCore.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
IF (QT_USE_FRAMEWORKS)
SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
ELSE (QT_USE_FRAMEWORKS)
STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
ENDIF (QT_USE_FRAMEWORKS)
ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
IF( NOT QT_INCLUDE_DIR)
IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
ENDIF( NOT QT_INCLUDE_DIR)
#############################################
#
# Find out what window system we're using
#
#############################################
# Save required includes variable
SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
# Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
# Check for Window system symbols (note: only one should end up being set)
CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
IF (QT_QTCOPY_REQUIRED)
CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
IF (NOT QT_IS_QTCOPY)
MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
ENDIF (NOT QT_IS_QTCOPY)
ENDIF (QT_QTCOPY_REQUIRED)
# Restore CMAKE_REQUIRED_INCLUDES variable
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
#
#############################################
IF (QT_USE_FRAMEWORKS)
SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
ENDIF (QT_USE_FRAMEWORKS)
# Set QT_QT3SUPPORT_INCLUDE_DIR
FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
PATHS
${QT_INCLUDE_DIR}/Qt3Support
${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QT_INCLUDE_DIR
FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
PATHS
${QT_INCLUDE_DIR}/Qt
${QT_LIBRARY_DIR}/QtCore.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTGUI_INCLUDE_DIR
FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
PATHS
${QT_INCLUDE_DIR}/QtGui
${QT_LIBRARY_DIR}/QtGui.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTSVG_INCLUDE_DIR
FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
PATHS
${QT_INCLUDE_DIR}/QtSvg
${QT_LIBRARY_DIR}/QtSvg.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTTEST_INCLUDE_DIR
FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
PATHS
${QT_INCLUDE_DIR}/QtTest
${QT_LIBRARY_DIR}/QtTest.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTUITOOLS_INCLUDE_DIR
FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtTest
PATHS
${QT_INCLUDE_DIR}/QtUiTools
${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTMOTIF_INCLUDE_DIR
IF(Q_WS_X11)
FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif PATHS ${QT_INCLUDE_DIR}/QtMotif NO_DEFAULT_PATH )
ENDIF(Q_WS_X11)
# Set QT_QTNETWORK_INCLUDE_DIR
FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
PATHS
${QT_INCLUDE_DIR}/QtNetwork
${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTNSPLUGIN_INCLUDE_DIR
FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
PATHS
${QT_INCLUDE_DIR}/QtNsPlugin
${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTOPENGL_INCLUDE_DIR
FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
PATHS
${QT_INCLUDE_DIR}/QtOpenGL
${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTSQL_INCLUDE_DIR
FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
PATHS
${QT_INCLUDE_DIR}/QtSql
${QT_LIBRARY_DIR}/QtSql.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTXML_INCLUDE_DIR
FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
PATHS
${QT_INCLUDE_DIR}/QtXml
${QT_LIBRARY_DIR}/QtXml.framework/Headers
NO_DEFAULT_PATH
)
# Set QT_QTASSISTANT_INCLUDE_DIR
FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
PATHS
${QT_INCLUDE_DIR}/QtAssistant
${QT_HEADERS_DIR}/QtAssistant
NO_DEFAULT_PATH
)
# Set QT_QTDESIGNER_INCLUDE_DIR
FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
PATHS
${QT_INCLUDE_DIR}/QtDesigner
${QT_HEADERS_DIR}/QtDesigner
NO_DEFAULT_PATH
)
# Make variables changeble to the advanced user
MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR)
# Set QT_INCLUDES
SET( QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default )
# Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QT3SUPPORT_LIBRARY
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTGUI_LIBRARY
FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTMOTIF_LIBRARY
IF(Q_WS_X11)
FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
ENDIF(Q_WS_X11)
# Set QT_QTNETWORK_LIBRARY
FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTNSPLUGIN_LIBRARY
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTOPENGL_LIBRARY
FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTSQL_LIBRARY
FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTXML_LIBRARY
FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTSVG_LIBRARY
FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTUITOOLS_LIBRARY
FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTTEST_LIBRARY
FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY )
IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check CMakeFiles/CMakeError.log for more details.")
ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
# Set QT_QTASSISTANT_LIBRARY
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
# Set QT_QTDESIGNER_LIBRARY
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
############################################
#
# Check the existence of the libraries.
#
############################################
MACRO (_QT4_ADJUST_LIB_VARS basename)
IF (QT_${basename}_INCLUDE_DIR)
# if only the release version was found, set the debug variable also to the release version
IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE})
ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
# if only the debug version was found, set the release variable also to the debug version
IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG})
ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
IF(NOT MSVC)
SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
ELSE(NOT MSVC)
SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
ENDIF(NOT MSVC)
SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
IF (QT_${basename}_LIBRARY)
SET(QT_${basename}_FOUND 1)
ENDIF (QT_${basename}_LIBRARY)
#add the include directory to QT_INCLUDES
SET(QT_INCLUDES ${QT_INCLUDES} "${QT_${basename}_INCLUDE_DIR}")
ENDIF (QT_${basename}_INCLUDE_DIR )
# Make variables changeble to the advanced user
MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
ENDMACRO (_QT4_ADJUST_LIB_VARS)
IF(WIN32)
_QT4_ADJUST_LIB_VARS(QTMAIN)
ENDIF(WIN32)
_QT4_ADJUST_LIB_VARS(QTCORE)
_QT4_ADJUST_LIB_VARS(QTGUI)
_QT4_ADJUST_LIB_VARS(QT3SUPPORT)
_QT4_ADJUST_LIB_VARS(QTASSISTANT)
_QT4_ADJUST_LIB_VARS(QTDESIGNER)
IF(Q_WS_X11)
_QT4_ADJUST_LIB_VARS(QTMOTIF)
ENDIF(Q_WS_X11)
_QT4_ADJUST_LIB_VARS(QTNETWORK)
_QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
_QT4_ADJUST_LIB_VARS(QTOPENGL)
_QT4_ADJUST_LIB_VARS(QTSQL)
_QT4_ADJUST_LIB_VARS(QTXML)
_QT4_ADJUST_LIB_VARS(QTSVG)
_QT4_ADJUST_LIB_VARS(QTUITOOLS)
_QT4_ADJUST_LIB_VARS(QTTEST)
#######################################
#
# Check the executables of Qt
# ( moc, uic, rcc )
#
#######################################
# find moc and uic using qmake
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
"message(MOC<$$QMAKE_MOC>)
message(UIC<$$QMAKE_UIC>)
")
EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
OUTPUT_VARIABLE _moc_OUTPUT
ERROR_VARIABLE _moc_OUTPUT )
FILE(REMOVE_RECURSE
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
STRING(REGEX REPLACE
".*MOC<([^>]+).*" "\\1" QT_MOC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" )
STRING(REGEX REPLACE
".*UIC<([^>]+).*" "\\1" QT_UIC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" )
FILE(TO_CMAKE_PATH
"${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
FILE(TO_CMAKE_PATH
"${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
SET(QT_MOC_EXECUTABLE
${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
SET(QT_UIC_EXECUTABLE
${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
FIND_PROGRAM(QT_UIC3_EXECUTABLE
NAMES uic3
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
FIND_PROGRAM(QT_RCC_EXECUTABLE
NAMES rcc
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
IF (QT_MOC_EXECUTABLE)
SET(QT_WRAP_CPP "YES")
ENDIF (QT_MOC_EXECUTABLE)
IF (QT_UIC_EXECUTABLE)
SET(QT_WRAP_UI "YES")
ENDIF (QT_UIC_EXECUTABLE)
MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE )
######################################
#
# Macros for building Qt files
#
######################################
MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
SET(${_moc_INC_DIRS})
GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
FOREACH(_current ${_inc_DIRS})
SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
ENDFOREACH(_current ${_inc_DIRS})
ENDMACRO(QT4_GET_MOC_INC_DIRS)
MACRO (QT4_GENERATE_MOC infile outfile )
# get include dirs
QT4_GET_MOC_INC_DIRS(moc_includes)
GET_FILENAME_COMPONENT(infile ${infile} ABSOLUTE)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_includes} -o ${outfile} ${infile}
DEPENDS ${infile})
MACRO_ADD_FILE_DEPENDENCIES(${infile} ${outfile})
ENDMACRO (QT4_GENERATE_MOC)
# QT4_WRAP_CPP(outfiles inputfile ... )
# TODO perhaps add support for -D, -U and other minor options
MACRO (QT4_WRAP_CPP outfiles )
# get include dirs
QT4_GET_MOC_INC_DIRS(moc_includes)
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_includes} -o ${outfile} ${it}
DEPENDS ${it})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO (QT4_WRAP_CPP)
# QT4_WRAP_UI(outfiles inputfile ... )
MACRO (QT4_WRAP_UI outfiles )
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_WRAP_UI)
# QT4_ADD_RESOURCE(outfiles inputfile ... )
# TODO perhaps consider adding support for compression and root options to rcc
MACRO (QT4_ADD_RESOURCES outfiles )
FOREACH (it ${ARGN})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} )
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH (it)
ENDMACRO (QT4_ADD_RESOURCES)
MACRO(QT4_AUTOMOC)
QT4_GET_MOC_INC_DIRS(_moc_INCS)
SET(_matching_FILES )
FOREACH (_current_FILE ${ARGN})
GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
# here. this is required to make bouic work correctly:
# we need to add generated .cpp files to the sources (to compile them),
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
# cmake is run for the very first time on them -> however the .cpp files might
# exist at a later run. at that time we need to skip them, so that we don't add two
# different rules for the same moc file
GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
IF ( NOT _skip AND EXISTS ${_abs_FILE} )
FILE(READ ${_abs_FILE} _contents)
GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
IF(_match)
FOREACH (_current_MOC_INC ${_match})
STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
GET_filename_component(_basename ${_current_MOC} NAME_WE)
# SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
SET(_header ${_abs_PATH}/${_basename}.h)
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${_moc_INCS} ${_header} -o ${_moc}
DEPENDS ${_header}
)
MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
ENDFOREACH (_current_MOC_INC)
ENDIF(_match)
ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
ENDFOREACH (_current_FILE)
ENDMACRO(QT4_AUTOMOC)
######################################
#
# decide if Qt got found
#
######################################
# if the includes,libraries,moc,uic and rcc are found then we have it
IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
SET( QT4_FOUND "YES" )
IF( NOT Qt4_FIND_QUIETLY)
MESSAGE(STATUS "Found Qt-Version ${QTVERSION}")
ENDIF( NOT Qt4_FIND_QUIETLY)
ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
SET( QT4_FOUND "NO")
IF( Qt4_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
ENDIF( Qt4_FIND_REQUIRED)
ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
SET(QT_FOUND ${QT4_FOUND})
#######################################
#
# System dependent settings
#
#######################################
# for unix add X11 stuff
IF(UNIX)
# on OS X X11 may not be required
IF (Q_WS_X11)
FIND_PACKAGE(X11)
ENDIF (Q_WS_X11)
FIND_PACKAGE(Threads)
SET(QT_QTCORE_LIBRARY ${QT_QTCORE_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(UNIX)
#######################################
#
# compatibility settings
#
#######################################
# Backwards compatibility for CMake1.4 and 1.2
SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
SET( QT_QT_LIBRARY "")
ELSE(QT4_QMAKE_FOUND)
IF(Qt4_FIND_REQUIRED)
IF(QT4_INSTALLED_VERSION_TOO_OLD)
MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
MESSAGE( FATAL_ERROR "Qt qmake not found!")
ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
ELSE(Qt4_FIND_REQUIRED)
IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
ENDIF(Qt4_FIND_REQUIRED)
ENDIF (QT4_QMAKE_FOUND)

View File

@ -14,7 +14,7 @@
if (SASL2_INCLUDE_DIR)
# Already in cache, be silent
set(SASL2_FIND_QUIETLY TRUE)
endif (SASL2_INCLUDE_DIR)
endif()
FIND_PATH(SASL2_INCLUDE_DIR sasl/sasl.h)
@ -23,18 +23,18 @@ FIND_LIBRARY(SASL2_LIBRARIES NAMES sasl2)
if (SASL2_INCLUDE_DIR AND SASL2_LIBRARIES)
set(SASL2_FOUND TRUE)
endif (SASL2_INCLUDE_DIR AND SASL2_LIBRARIES)
endif()
if (SASL2_FOUND)
if (NOT Sasl2_FIND_QUIETLY)
message(STATUS "Found Sasl2: ${SASL2_LIBRARIES}")
endif (NOT Sasl2_FIND_QUIETLY)
else (SASL2_FOUND)
endif()
else()
if (Sasl2_FIND_REQUIRED)
message(FATAL_ERROR "Could not find sasl2 libraries")
endif (Sasl2_FIND_REQUIRED)
endif (SASL2_FOUND)
endif()
endif()
MARK_AS_ADVANCED(SASL2_INCLUDE_DIR SASL2_LIBRARIES)

View File

@ -1,21 +1,87 @@
MACRO(MY_AUTOMOC _srcsList)
QT4_GET_MOC_INC_DIRS(_moc_INCS)
FOREACH (_current_FILE ${${_srcsList}})
GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
SET(extra_moc_argument)
if(WIN32)
SET(extra_moc_argument -DWIN32)
endif(WIN32)
ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${extra_moc_argument} ${_moc_INCS} -o ${_moc} ${_abs_FILE}
DEPENDS ${_current_FILE}
)
LIST(APPEND ${_srcsList} ${_moc})
ENDFOREACH (_current_FILE)
ENDMACRO(MY_AUTOMOC)
MACRO(SETUP_QT_DIRS)
if(QT6)
GET_TARGET_PROPERTY(QMAKE_EXECUTABLE Qt6::qmake LOCATION)
else()
GET_TARGET_PROPERTY(QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} LOCATION)
endif()
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_LIBS" OUTPUT_VARIABLE QT_LIBRARY_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PREFIX" OUTPUT_VARIABLE QT_PREFIX_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PLUGINS" OUTPUT_VARIABLE QT_PLUGINS_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_BINS" OUTPUT_VARIABLE QT_BINARY_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE QT_HEADERS_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_DOCS" OUTPUT_VARIABLE QT_DOC_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_DATA" OUTPUT_VARIABLE QT_DATA_DIR )
EXEC_PROGRAM( ${QMAKE_EXECUTABLE} ARGS "-query QT_HOST_DATA" OUTPUT_VARIABLE QT_ARCHDATA_DIR )
SET( QT_MKSPECS_DIR "${QT_ARCHDATA_DIR}/mkspecs" )
ENDMACRO(SETUP_QT_DIRS)
macro(set_enabled_plugin PLUGIN ENABLED)
# To nice looks
if(ENABLED)
set(ENABLED "on")
else()
set(ENABLED "off")
endif()
set(WITH_${PLUGIN}_PLUGIN_INTERNAL ${ENABLED} CACHE INTERNAL "")
endmacro(set_enabled_plugin)
macro(enable_plugin PLUGIN)
set_enabled_plugin(${PLUGIN} "on")
endmacro(enable_plugin)
macro(disable_plugin PLUGIN)
set_enabled_plugin(${PLUGIN} "off")
endmacro(disable_plugin)
# it used to build examples and tools
macro(target_link_qca_libraries TARGET)
# Link with QCA library
target_link_libraries(${TARGET} ${QCA_LIB_NAME})
# Statically link with all enabled QCA plugins
if(STATIC_PLUGINS)
target_link_libraries(${TARGET} ${QT_QTCORE_LIB_DEPENDENCIES})
foreach(PLUGIN IN LISTS PLUGINS)
# Check plugin for enabled
if(WITH_${PLUGIN}_PLUGIN_INTERNAL)
target_link_libraries(${TARGET} qca-${PLUGIN})
endif()
endforeach(PLUGIN)
endif()
endmacro(target_link_qca_libraries)
# it used to build unittests
macro(target_link_qca_test_libraries TARGET)
target_link_qca_libraries(${TARGET})
if(QT6)
target_link_libraries(${TARGET} Qt6::Test)
else()
target_link_libraries(${TARGET} Qt5::Test)
endif()
endmacro(target_link_qca_test_libraries)
# it used to build unittests
macro(add_qca_test TARGET DESCRIPTION)
add_test(NAME "${DESCRIPTION}"
WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
COMMAND "${TARGET}")
endmacro(add_qca_test)
macro(install_pdb TARGET INSTALL_PATH)
if(MSVC)
get_target_property(LOCATION ${TARGET} LOCATION_DEBUG)
string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}")
install(FILES ${LOCATION} DESTINATION ${INSTALL_PATH} CONFIGURATIONS Debug)
get_target_property(LOCATION ${TARGET} LOCATION_RELWITHDEBINFO)
string(REGEX REPLACE "\\.[^.]*$" ".pdb" LOCATION "${LOCATION}")
install(FILES ${LOCATION} DESTINATION ${INSTALL_PATH} CONFIGURATIONS RelWithDebInfo)
endif()
endmacro(install_pdb)
macro(normalize_path PATH)
get_filename_component(${PATH} "${${PATH}}" ABSOLUTE)
# Strip trailing slashes
string(REGEX REPLACE "/+$" "" PATH ${PATH})
endmacro()

26
cmake_uninstall.cmake.in Normal file
View File

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 2.6.0)
cmake_policy(SET CMP0007 OLD)
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif()
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif()
else()
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif()
endforeach(file)

View File

@ -1,13 +1,26 @@
QCA_INCDIR = @QT_INCLUDE_DIR@
QCA_LIBDIR = @QT_LIBRARY_DIR@
QCA_INCDIR = @CRYPTO_PRF_RELATIVE_PATH@@QCA_INCLUDE_INSTALL_DIR@
QCA_LIBDIR = @CRYPTO_PRF_RELATIVE_PATH@@QCA_LIBRARY_INSTALL_DIR@
CONFIG *= qt
INCLUDEPATH += $$QCA_INCDIR/QtCrypto
LIBS += -L$$QCA_LIBDIR
LINKAGE = -lqca
CONFIG(debug, debug|release) {
windows:LINKAGE = -lqcad
mac:LINKAGE = -lqca_debug
LINKAGE =
exists($$QCA_LIBDIR/@QCA_LIB_NAME@.framework) {
QMAKE_CXXFLAGS += -F$$QCA_LIBDIR
LIBS *= -F$$QCA_LIBDIR
INCLUDEPATH += $$QCA_LIBDIR/@QCA_LIB_NAME@.framework/Headers
LINKAGE = -framework @QCA_LIB_NAME@
}
# else, link normally
isEmpty(LINKAGE) {
INCLUDEPATH += $$QCA_INCDIR/QtCrypto
LIBS += -L$$QCA_LIBDIR
LINKAGE = -l@QCA_LIB_NAME@
CONFIG(debug, debug|release) {
windows:LINKAGE = -l@QCA_LIB_NAME@d
mac:LINKAGE = -l@QCA_LIB_NAME@_debug
}
}
LIBS += $$LINKAGE

View File

@ -1,39 +0,0 @@
# prepend this file with QCA_INCDIR/QCA_LIBDIR definitions
# NOTE: any changes made to this file need to be tracked in qcm/qca.qcm
CONFIG *= qt
# if we are including crypto.prf from the qca tree (and not utilizing it as
# an installed qmake CONFIG feature), then point to the tree. this allows our
# qca tree apps to build before qca itself is installed.
exists($$PWD/qca.pro) {
QCA_INCDIR = $$PWD/include
QCA_LIBDIR = $$PWD/lib
}
LINKAGE =
# on mac, if qca was built as a framework, link against it
mac: {
framework_dir = $$QCA_LIBDIR
exists($$framework_dir/qca.framework) {
#QMAKE_FRAMEWORKPATH *= $$framework_dir
LIBS += -F$$framework_dir
INCLUDEPATH += $$framework_dir/qca.framework/Headers
LINKAGE = -framework qca
}
}
# else, link normally
isEmpty(LINKAGE) {
INCLUDEPATH += $$QCA_INCDIR/QtCrypto
LIBS += -L$$QCA_LIBDIR
LINKAGE = -lqca
CONFIG(debug, debug|release) {
windows:LINKAGE = -lqcad
mac:LINKAGE = -lqca_debug
}
}
LIBS += $$LINKAGE

3
docs/Doxyfile.local Normal file
View File

@ -0,0 +1,3 @@
### KApiDox Project-specific Overrides File
FILE_PATTERNS += *.doco

BIN
docs/pics/qca-arch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,3 +1,9 @@
if(QT6)
find_package(Qt6 REQUIRED Network)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
find_package(Qt5 REQUIRED Network)
endif()
add_subdirectory(aes-cmac)
add_subdirectory(base64test)
add_subdirectory(certtest)

View File

@ -2,5 +2,4 @@ set(aes-cmac_bin_SRCS aes-cmac.cpp)
add_executable(aes-cmac ${aes-cmac_bin_SRCS})
target_link_libraries( aes-cmac qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(aes-cmac)

View File

@ -25,158 +25,150 @@
#include <QCoreApplication>
#include <QDebug>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
class AESCMACContext : public QCA::MACContext
{
Q_OBJECT
public:
AESCMACContext(QCA::Provider *p) : QCA::MACContext(p, "cmac(aes)")
AESCMACContext(QCA::Provider *p)
: QCA::MACContext(p, QStringLiteral("cmac(aes)"))
{
}
~AESCMACContext()
{
}
// Helper to left shift an arbitrary length array
// This is heavily based on the example in the I-D.
QCA::SecureArray leftShift(const QCA::SecureArray &array)
{
// We create an output of the same size as the input
QCA::SecureArray out(array.size());
// We handle one byte at a time - this is the high bit
// from the previous byte.
int overflow = 0;
// We create an output of the same size as the input
QCA::SecureArray out(array.size());
// We handle one byte at a time - this is the high bit
// from the previous byte.
int overflow = 0;
// work through each byte.
for (int i = array.size() -1; i >= 0; --i) {
// do the left shift on this byte.
out[i] = array[i] << 1;
// make the low bit on this byte be the high bit
// from the previous byte.
out[i] |= overflow;
// save the high bit for next time
overflow = (array[i] & 0x80) ? 1 : 0;
}
return out;
// work through each byte.
for (int i = array.size() - 1; i >= 0; --i) {
// do the left shift on this byte.
out[i] = array[i] << 1;
// make the low bit on this byte be the high bit
// from the previous byte.
out[i] |= overflow;
// save the high bit for next time
overflow = (array[i] & 0x80) ? 1 : 0;
}
return out;
}
// Helper to XOR two arrays - must be same length
QCA::SecureArray xorArray(const QCA::SecureArray &array1,
const QCA::SecureArray &array2)
QCA::SecureArray xorArray(const QCA::SecureArray &array1, const QCA::SecureArray &array2)
{
if (array1.size() != array2.size())
// empty array
return QCA::SecureArray();
if (array1.size() != array2.size())
// empty array
return QCA::SecureArray();
QCA::SecureArray result(array1.size());
QCA::SecureArray result(array1.size());
for (int i = 0; i < array1.size(); ++i)
result[i] = array1[i] ^ array2[i];
for (int i = 0; i < array1.size(); ++i)
result[i] = array1[i] ^ array2[i];
return result;
return result;
}
void setup(const QCA::SymmetricKey &key)
void setup(const QCA::SymmetricKey &key) override
{
// We might not have a real key, since this can get called
// from the constructor.
if (key.size() == 0)
return;
// We might not have a real key, since this can get called
// from the constructor.
if (key.size() == 0)
return;
m_key = key;
// Generate the subkeys
QCA::SecureArray const_Zero(16);
QCA::SecureArray const_Rb(16);
const_Rb[15] = (char)0x87;
m_key = key;
// Generate the subkeys
QCA::SecureArray const_Zero(16);
QCA::SecureArray const_Rb(16);
const_Rb[15] = (char)0x87;
m_X = const_Zero;
m_residual = QCA::SecureArray();
m_X = const_Zero;
m_residual = QCA::SecureArray();
// Figure 2.2, step 1.
QCA::Cipher aesObj(QString("aes128"),
QCA::Cipher::ECB, QCA::Cipher::DefaultPadding,
QCA::Encode, key);
QCA::SecureArray L = aesObj.process(const_Zero);
// Figure 2.2, step 1.
QCA::Cipher aesObj(QStringLiteral("aes128"), QCA::Cipher::ECB, QCA::Cipher::DefaultPadding, QCA::Encode, key);
QCA::SecureArray L = aesObj.process(const_Zero);
// Figure 2.2, step 2
if (0 == (L[0] & 0x80))
m_k1 = leftShift(L);
else
m_k1 = xorArray(leftShift(L), const_Rb);
// Figure 2.2, step 2
if (0 == (L[0] & 0x80))
m_k1 = leftShift(L);
else
m_k1 = xorArray(leftShift(L), const_Rb);
// Figure 2.2, step 3
if (0 == (m_k1[0] & 0x80))
m_k2 = leftShift(m_k1);
else
m_k2 = xorArray(leftShift(m_k1), const_Rb);
// Figure 2.2, step 3
if (0 == (m_k1[0] & 0x80))
m_k2 = leftShift(m_k1);
else
m_k2 = xorArray(leftShift(m_k1), const_Rb);
}
QCA::Provider::Context *clone() const
QCA::Provider::Context *clone() const override
{
return new AESCMACContext(*this);
}
void clear()
{
setup(m_key);
setup(m_key);
}
QCA::KeyLength keyLength() const
QCA::KeyLength keyLength() const override
{
return QCA::KeyLength(16, 16, 1);
}
// This is a bit different to the way the I-D does it,
// to allow for multiple update() calls.
void update(const QCA::MemoryRegion &a)
void update(const QCA::MemoryRegion &a) override
{
QCA::SecureArray bytesToProcess = m_residual + a;
int blockNum;
// note that we don't want to do the last full block here, because
// it needs special treatment in final().
for (blockNum = 0; blockNum < ((bytesToProcess.size()-1)/16); ++blockNum) {
// copy a block of data
QCA::SecureArray thisBlock(16);
for (int yalv = 0; yalv < 16; ++yalv)
thisBlock[yalv] = bytesToProcess[blockNum*16 + yalv];
QCA::SecureArray bytesToProcess = m_residual + a;
int blockNum;
// note that we don't want to do the last full block here, because
// it needs special treatment in final().
for (blockNum = 0; blockNum < ((bytesToProcess.size() - 1) / 16); ++blockNum) {
// copy a block of data
QCA::SecureArray thisBlock(16);
for (int yalv = 0; yalv < 16; ++yalv)
thisBlock[yalv] = bytesToProcess[blockNum * 16 + yalv];
m_Y = xorArray(m_X, thisBlock);
m_Y = xorArray(m_X, thisBlock);
QCA::Cipher aesObj(QString("aes128"),
QCA::Cipher::ECB, QCA::Cipher::DefaultPadding,
QCA::Encode, m_key);
m_X = aesObj.process(m_Y);
}
// This can be between 1 and 16
int numBytesLeft = bytesToProcess.size() - 16*blockNum;
// we copy the left over part
m_residual.resize(numBytesLeft);
for(int yalv = 0; yalv < numBytesLeft; ++yalv)
m_residual[yalv] = bytesToProcess[blockNum*16 + yalv];
QCA::Cipher aesObj(
QStringLiteral("aes128"), QCA::Cipher::ECB, QCA::Cipher::DefaultPadding, QCA::Encode, m_key);
m_X = aesObj.process(m_Y);
}
// This can be between 1 and 16
int numBytesLeft = bytesToProcess.size() - 16 * blockNum;
// we copy the left over part
m_residual.resize(numBytesLeft);
for (int yalv = 0; yalv < numBytesLeft; ++yalv)
m_residual[yalv] = bytesToProcess[blockNum * 16 + yalv];
}
void final( QCA::MemoryRegion *out)
void final(QCA::MemoryRegion *out) override
{
QCA::SecureArray lastBlock;
int numBytesLeft = m_residual.size();
if ( numBytesLeft != 16 ) {
// no full block, so we have to pad.
m_residual.resize(16);
m_residual[numBytesLeft] = (char)0x80;
lastBlock = xorArray(m_residual, m_k2);
} else {
// this is a full block - no padding
lastBlock = xorArray(m_residual, m_k1);
}
m_Y = xorArray(m_X, lastBlock);
QCA::Cipher aesObj(QString("aes128"),
QCA::Cipher::ECB, QCA::Cipher::DefaultPadding,
QCA::Encode, m_key);
*out = aesObj.process(m_Y);
QCA::SecureArray lastBlock;
int numBytesLeft = m_residual.size();
if (numBytesLeft != 16) {
// no full block, so we have to pad.
m_residual.resize(16);
m_residual[numBytesLeft] = (char)0x80;
lastBlock = xorArray(m_residual, m_k2);
} else {
// this is a full block - no padding
lastBlock = xorArray(m_residual, m_k1);
}
m_Y = xorArray(m_X, lastBlock);
QCA::Cipher aesObj(QStringLiteral("aes128"), QCA::Cipher::ECB, QCA::Cipher::DefaultPadding, QCA::Encode, m_key);
*out = aesObj.process(m_Y);
}
protected:
@ -198,49 +190,47 @@ protected:
class ClientSideProvider : public QCA::Provider
{
public:
int qcaVersion() const
{
return QCA_VERSION;
}
int qcaVersion() const override
{
return QCA_VERSION;
}
QString name() const
{
return "exampleClientSideProvider";
}
QString name() const override
{
return QStringLiteral("exampleClientSideProvider");
}
QStringList features() const
{
QStringList list;
list += "cmac(aes)";
// you can add more features in here, if you have some.
return list;
}
QStringList features() const override
{
QStringList list;
list += QStringLiteral("cmac(aes)");
// you can add more features in here, if you have some.
return list;
}
Provider::Context *createContext(const QString &type)
{
if(type == "cmac(aes)")
return new AESCMACContext(this);
// else if (type == some other feature)
// return some other context.
else
return 0;
}
Provider::Context *createContext(const QString &type) override
{
if (type == QLatin1String("cmac(aes)"))
return new AESCMACContext(this);
// else if (type == some other feature)
// return some other context.
else
return nullptr;
}
};
// AES CMAC is a Message Authentication Code based on a block cipher
// instead of the more normal keyed hash.
// See RFC 4493 "The AES-CMAC Algorithm"
class AES_CMAC: public QCA::MessageAuthenticationCode
class AES_CMAC : public QCA::MessageAuthenticationCode
{
public:
AES_CMAC(const QCA::SymmetricKey &key = QCA::SymmetricKey(),
const QString &provider = QString()):
QCA::MessageAuthenticationCode( "cmac(aes)", key, provider)
{}
AES_CMAC(const QCA::SymmetricKey &key = QCA::SymmetricKey(), const QString &provider = QString())
: QCA::MessageAuthenticationCode(QStringLiteral("cmac(aes)"), key, provider)
{
}
};
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
@ -251,64 +241,66 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
if( ! QCA::isSupported("aes128-ecb") ) {
qDebug() << "AES not supported!";
if (!QCA::isSupported("aes128-ecb")) {
qDebug() << "AES not supported!";
}
if ( QCA::insertProvider(new ClientSideProvider, 0) )
qDebug() << "Inserted our provider";
if (QCA::insertProvider(new ClientSideProvider, 0))
qDebug() << "Inserted our provider";
else
qDebug() << "our provider could not be added";
qDebug() << "our provider could not be added";
// We should check AES CMAC is supported before using it.
if( ! QCA::isSupported("cmac(aes)") ) {
qDebug() << "AES CMAC not supported!";
if (!QCA::isSupported("cmac(aes)")) {
qDebug() << "AES CMAC not supported!";
} else {
// create the required object
AES_CMAC cmacObject;
// create the required object
AES_CMAC cmacObject;
// create the key
QCA::SymmetricKey key(QCA::hexToArray("2b7e151628aed2a6abf7158809cf4f3c"));
// create the key
QCA::SymmetricKey key(QCA::hexToArray(QStringLiteral("2b7e151628aed2a6abf7158809cf4f3c")));
// set the MAC to use the key
cmacObject.setup(key);
// set the MAC to use the key
cmacObject.setup(key);
QCA::SecureArray message = QCA::hexToArray("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710");
QCA::SecureArray message1(message);
message1.resize(0);
qDebug();
qDebug() << "Message1: " << QCA::arrayToHex(message1.toByteArray());
qDebug() << "Expecting: bb1d6929e95937287fa37d129b756746";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message1).toByteArray());
QCA::SecureArray message =
QCA::hexToArray(QStringLiteral("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"));
QCA::SecureArray message1(message);
message1.resize(0);
qDebug();
qDebug() << "Message1: " << QCA::arrayToHex(message1.toByteArray());
qDebug() << "Expecting: bb1d6929e95937287fa37d129b756746";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message1).toByteArray());
cmacObject.clear();
QCA::SecureArray message2(message);
message2.resize(16);
qDebug();
qDebug() << "Message2: " << QCA::arrayToHex(message2.toByteArray());
qDebug() << "Expecting: 070a16b46b4d4144f79bdd9dd04a287c";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message2).toByteArray());
cmacObject.clear();
QCA::SecureArray message2(message);
message2.resize(16);
qDebug();
qDebug() << "Message2: " << QCA::arrayToHex(message2.toByteArray());
qDebug() << "Expecting: 070a16b46b4d4144f79bdd9dd04a287c";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message2).toByteArray());
cmacObject.clear();
QCA::SecureArray message3(message);
message3.resize(40);
qDebug();
qDebug() << "Message3: " << QCA::arrayToHex(message3.toByteArray());
qDebug() << "Expecting: dfa66747de9ae63030ca32611497c827";
qDebug() << "AES-CMAC " << QCA::arrayToHex(cmacObject.process(message3).toByteArray());
cmacObject.clear();
QCA::SecureArray message3(message);
message3.resize(40);
qDebug();
qDebug() << "Message3: " << QCA::arrayToHex(message3.toByteArray());
qDebug() << "Expecting: dfa66747de9ae63030ca32611497c827";
qDebug() << "AES-CMAC " << QCA::arrayToHex(cmacObject.process(message3).toByteArray());
cmacObject.clear();
QCA::SecureArray message4(message);
message4.resize(64);
qDebug();
qDebug() << "Message4: " << QCA::arrayToHex(message4.toByteArray());
qDebug() << "Expecting: 51f0bebf7e3b9d92fc49741779363cfe";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message4).toByteArray());
cmacObject.clear();
QCA::SecureArray message4(message);
message4.resize(64);
qDebug();
qDebug() << "Message4: " << QCA::arrayToHex(message4.toByteArray());
qDebug() << "Expecting: 51f0bebf7e3b9d92fc49741779363cfe";
qDebug() << "AES-CMAC: " << QCA::arrayToHex(cmacObject.process(message4).toByteArray());
}
return 0;
}
#include "aes-cmac.moc"

View File

@ -1,2 +0,0 @@
SOURCES += aes-cmac.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(base64test_bin_SRCS base64test.cpp)
add_executable(base64test ${base64test_bin_SRCS})
target_link_libraries( base64test qca ${QT_QTCORE_LIBRARY})
target_link_qca_libraries(base64test)

View File

@ -26,42 +26,45 @@
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
QCoreApplication(argc, argv);
QCoreApplication(argc, argv);
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// we use the first argument as the data to encode
// if an argument is provided. Use "hello" if no argument
QByteArray arg; // empty array
arg.append((argc >= 2) ? argv[1] : "hello");
// we use the first argument as the data to encode
// if an argument is provided. Use "hello" if no argument
QByteArray arg; // empty array
arg.append((argc >= 2) ? argv[1] : "hello");
// create our object, which does encoding by default
// QCA::Base64 encoder(QCA::Encode); is equivalent
QCA::Base64 encoder;
// create our object, which does encoding by default
// QCA::Base64 encoder(QCA::Encode); is equivalent
QCA::Base64 encoder;
// This does the actual conversion (encoding).
// You might prefer to use encoder.encode(); and have
// it return a QCA::SecureArray, depending on your needs
QString encoded = encoder.arrayToString(arg);
// This does the actual conversion (encoding).
// You might prefer to use encoder.encode(); and have
// it return a QCA::SecureArray, depending on your needs
QString encoded = encoder.arrayToString(arg);
std::cout << arg.data() << " in base64 encoding is ";
std::cout << encoded.toLatin1().data() << std::endl;
std::cout << arg.data() << " in base64 encoding is ";
std::cout << encoded.toLatin1().data() << std::endl;
// This time, we'll create an object to decode base64. We
// could also have reused the existing object, calling
// clear(); and setup(QCA::Decode); on it.
QCA::Base64 decoder(QCA::Decode);
// This time, we'll create an object to decode base64. We
// could also have reused the existing object, calling
// clear(); and setup(QCA::Decode); on it.
QCA::Base64 decoder(QCA::Decode);
// This time, we convert a QString into a QString
QString decoded = decoder.decodeString(encoded);
// This time, we convert a QString into a QString
QString decoded = decoder.decodeString(encoded);
std::cout << encoded.toLatin1().data() << " decoded from base64 is ";
std::cout << decoded.toLatin1().data() << std::endl;
std::cout << encoded.toLatin1().data() << " decoded from base64 is ";
std::cout << decoded.toLatin1().data() << std::endl;
return 0;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += base64test.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(certtest_bin_SRCS certtest.cpp)
add_executable(certtest ${certtest_bin_SRCS})
target_link_libraries( certtest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(certtest)

View File

@ -20,17 +20,21 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QtCrypto>
#include <QCoreApplication>
#include <QFile>
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
// dump out information about some part of the certificate
// we use this same approach for information about the subject
// of the certificate, and also about the issuer of the certificate
static void dumpCertificateInfo( QCA::CertificateInfo info)
static void dumpCertificateInfo(const QCA::CertificateInfo &info)
{
std::cout << " Organization: " << std::endl;
@ -44,37 +48,35 @@ static void dumpCertificateInfo( QCA::CertificateInfo info)
// out each value. Note that is uncommon for a certificate to
// actually contain multiple values for a single parameter.
QString organization;
foreach( organization, orgInfoList ) {
std::cout << " " << qPrintable(organization) << std::endl;
foreach (organization, orgInfoList) {
std::cout << " " << qPrintable(organization) << std::endl;
}
std::cout << " Country: " << std::endl;
// As above, however this shows a more compact way to represent
// the iteration and output.
foreach( QString country, info.values(QCA::Country) ) {
std::cout << " " << qPrintable(country) << std::endl;
foreach (QString country, info.values(QCA::Country)) { // clazy:exclude=container-anti-pattern
std::cout << " " << qPrintable(country) << std::endl;
}
}
// This is just a convenience routine
static void dumpSubjectInfo( QCA::CertificateInfo subject)
static void dumpSubjectInfo(const QCA::CertificateInfo &subject)
{
std::cout << "Subject: " << std::endl;
dumpCertificateInfo( subject );
dumpCertificateInfo(subject);
}
// This is just a convenience routine
static void dumpIssuerInfo( QCA::CertificateInfo issuer)
static void dumpIssuerInfo(const QCA::CertificateInfo &issuer)
{
std::cout << "Issuer: " << std::endl;
dumpCertificateInfo( issuer );
dumpCertificateInfo(issuer);
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
@ -83,9 +85,9 @@ int main(int argc, char** argv)
QCoreApplication app(argc, argv);
// We need to ensure that we have certificate handling support
if ( !QCA::isSupported( "cert" ) ) {
std::cout << "Sorry, no PKI certificate support" << std::endl;
return 1;
if (!QCA::isSupported("cert")) {
std::cout << "Sorry, no PKI certificate support" << std::endl;
return 1;
}
// We are going to work with a number of certificates, and a
@ -96,77 +98,76 @@ int main(int argc, char** argv)
// as a filename to read the keys from. If there is no argument, we just
// read from the system store certificates.
if (argc >= 2) {
// we are going to read the certificates in using a single call
// which requires a CertificateCollection.
QCA::CertificateCollection filecerts;
// The conversion can be tested (although you don't have to) to find out if it
// worked.
QCA::ConvertResult importResult;
// This imports all the PEM encoded certificates from the file specified as the argument
// Note that you pass in a pointer to the result argument.
filecerts = QCA::CertificateCollection::fromFlatTextFile( argv[1], &importResult );
if ( QCA::ConvertGood == importResult) {
std::cout << "Import succeeded" << std::endl;
// this turns the CertificateCollection into a QList of Certificate objects
certlist = filecerts.certificates();
}
// we are going to read the certificates in using a single call
// which requires a CertificateCollection.
QCA::CertificateCollection filecerts;
// The conversion can be tested (although you don't have to) to find out if it
// worked.
QCA::ConvertResult importResult;
// This imports all the PEM encoded certificates from the file specified as the argument
// Note that you pass in a pointer to the result argument.
filecerts = QCA::CertificateCollection::fromFlatTextFile(QFile::decodeName(argv[1]), &importResult);
if (QCA::ConvertGood == importResult) {
std::cout << "Import succeeded" << std::endl;
// this turns the CertificateCollection into a QList of Certificate objects
certlist = filecerts.certificates();
}
} else {
// we have no arguments, so just use the system certificates
if ( !QCA::haveSystemStore() ) {
std::cout << "System certificates not available" << std::endl;
return 2;
}
// we have no arguments, so just use the system certificates
if (!QCA::haveSystemStore()) {
std::cout << "System certificates not available" << std::endl;
return 2;
}
// Similar to above, except we just want the system certificates
QCA::CertificateCollection systemcerts = QCA::systemStore();
// Similar to above, except we just want the system certificates
QCA::CertificateCollection systemcerts = QCA::systemStore();
// this turns the CertificateCollection into a QList of Certificate objects
certlist = systemcerts.certificates();
// this turns the CertificateCollection into a QList of Certificate objects
certlist = systemcerts.certificates();
}
std::cout << "Number of certificates: " << certlist.count() << std::endl;
QCA::Certificate cert;
foreach (cert, certlist) {
std::cout << "Serial Number:";
// the serial number of the certificate is a QCA::BigInteger, but we can
// just convert it to a string, and then output it.
std::cout << qPrintable(cert.serialNumber().toString()) << std::endl;
std::cout << "Serial Number:";
// the serial number of the certificate is a QCA::BigInteger, but we can
// just convert it to a string, and then output it.
std::cout << qPrintable(cert.serialNumber().toString()) << std::endl;
// The subject information shows properties of who the certificate
// applies to. See the convenience routines above.
dumpSubjectInfo( cert.subjectInfo() );
// The subject information shows properties of who the certificate
// applies to. See the convenience routines above.
dumpSubjectInfo(cert.subjectInfo());
// The issuer information shows properties of who the certificate
// was signed by. See the convenience routines above.
dumpIssuerInfo( cert.issuerInfo() );
// The issuer information shows properties of who the certificate
// was signed by. See the convenience routines above.
dumpIssuerInfo(cert.issuerInfo());
// Test if the certificate can be used as a certificate authority
if ( cert.isCA() ) {
std::cout << "Is certificate authority" << std::endl;
} else {
std::cout << "Is not a certificate authority" << std::endl;
}
// Test if the certificate can be used as a certificate authority
if (cert.isCA()) {
std::cout << "Is certificate authority" << std::endl;
} else {
std::cout << "Is not a certificate authority" << std::endl;
}
// Test if the certificate is self-signed.
if (cert.isSelfSigned() ) {
std::cout << "Self signed" << std::endl;
} else {
std::cout << "Is not self-signed!!!" << std::endl;
}
// Test if the certificate is self-signed.
if (cert.isSelfSigned()) {
std::cout << "Self signed" << std::endl;
} else {
std::cout << "Is not self-signed!!!" << std::endl;
}
// Certificate are only valid between specific dates. We can get the dates
// (as a QDateTime) using a couple of calls
std::cout << "Valid from " << qPrintable(cert.notValidBefore().toString());
std::cout << ", until " << qPrintable(cert.notValidAfter().toString());
std::cout << std::endl;
// Certificate are only valid between specific dates. We can get the dates
// (as a QDateTime) using a couple of calls
std::cout << "Valid from " << qPrintable(cert.notValidBefore().toString());
std::cout << ", until " << qPrintable(cert.notValidAfter().toString());
std::cout << std::endl;
// You can get the certificate in PEM encoding with a simple toPEM() call
std::cout << "PEM:" << std::endl;
std::cout << qPrintable(cert.toPEM());
std::cout << std::endl << std::endl;
}
// You can get the certificate in PEM encoding with a simple toPEM() call
std::cout << "PEM:" << std::endl;
std::cout << qPrintable(cert.toPEM());
std::cout << std::endl << std::endl;
}
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += certtest.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(ciphertest_bin_SRCS ciphertest.cpp)
add_executable(ciphertest ${ciphertest_bin_SRCS})
target_link_libraries( ciphertest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(ciphertest)

View File

@ -22,10 +22,14 @@
// QtCrypto has the declarations for all of QCA
#include <QtCrypto>
#include <stdio.h>
#include <cstdio>
#include <QCoreApplication>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
@ -39,91 +43,88 @@ int main(int argc, char **argv)
QCA::SecureArray arg = (argc >= 2) ? argv[1] : "hello";
// AES128 testing
if(!QCA::isSupported("aes128-cbc-pkcs7"))
printf("AES128-CBC not supported!\n");
if (!QCA::isSupported("aes128-cbc-pkcs7"))
printf("AES128-CBC not supported!\n");
else {
// Create a random key - you'd probably use one from another
// source in a real application
QCA::SymmetricKey key(16);
// Create a random key - you'd probably use one from another
// source in a real application
QCA::SymmetricKey key(16);
// Create a random initialisation vector - you need this
// value to decrypt the resulting cipher text, but it
// need not be kept secret (unlike the key).
QCA::InitializationVector iv(16);
// Create a random initialisation vector - you need this
// value to decrypt the resulting cipher text, but it
// need not be kept secret (unlike the key).
QCA::InitializationVector iv(16);
// create a 128 bit AES cipher object using Cipher Block Chaining (CBC) mode
QCA::Cipher cipher(QString("aes128"),QCA::Cipher::CBC,
// use Default padding, which is equivalent to PKCS7 for CBC
QCA::Cipher::DefaultPadding,
// this object will encrypt
QCA::Encode,
key, iv);
// create a 128 bit AES cipher object using Cipher Block Chaining (CBC) mode
QCA::Cipher cipher(QStringLiteral("aes128"),
QCA::Cipher::CBC,
// use Default padding, which is equivalent to PKCS7 for CBC
QCA::Cipher::DefaultPadding,
// this object will encrypt
QCA::Encode,
key,
iv);
// we use the cipher object to encrypt the argument we passed in
// the result of that is returned - note that if there is less than
// 16 bytes (1 block), then nothing will be returned - it is buffered
// update() can be called as many times as required.
QCA::SecureArray u = cipher.update(arg);
// we use the cipher object to encrypt the argument we passed in
// the result of that is returned - note that if there is less than
// 16 bytes (1 block), then nothing will be returned - it is buffered
// update() can be called as many times as required.
QCA::SecureArray u = cipher.update(arg);
// We need to check if that update() call worked.
if (!cipher.ok()) {
printf("Update failed\n");
}
// output the results of that stage
printf("AES128 encryption of %s is [%s]\n",
arg.data(),
qPrintable(QCA::arrayToHex(u.toByteArray())) );
// We need to check if that update() call worked.
if (!cipher.ok()) {
printf("Update failed\n");
}
// output the results of that stage
printf("AES128 encryption of %s is [%s]\n", arg.data(), qPrintable(QCA::arrayToHex(u.toByteArray())));
// Because we are using PKCS7 padding, we need to output the final (padded) block
// Note that we should always call final() even with no padding, to clean up
QCA::SecureArray f = cipher.final();
// Because we are using PKCS7 padding, we need to output the final (padded) block
// Note that we should always call final() even with no padding, to clean up
QCA::SecureArray f = cipher.final();
// Check if the final() call worked
if (!cipher.ok()) {
printf("Final failed\n");
}
// and output the resulting block. The ciphertext is the results of update()
// and the result of final()
printf("Final block for AES128 encryption is [0x%s]\n", qPrintable(QCA::arrayToHex(f.toByteArray())));
// Check if the final() call worked
if (!cipher.ok()) {
printf("Final failed\n");
}
// and output the resulting block. The ciphertext is the results of update()
// and the result of final()
printf("Final block for AES128 encryption is [0x%s]\n", qPrintable(QCA::arrayToHex(f.toByteArray())) );
// re-use the Cipher t decrypt. We need to use the same key and
// initialisation vector as in the encryption.
cipher.setup(QCA::Decode, key, iv);
// re-use the Cipher t decrypt. We need to use the same key and
// initialisation vector as in the encryption.
cipher.setup( QCA::Decode, key, iv );
// Build a single cipher text array. You could also call update() with
// each block as you receive it, if that is more useful.
QCA::SecureArray cipherText = u.append(f);
// Build a single cipher text array. You could also call update() with
// each block as you receive it, if that is more useful.
QCA::SecureArray cipherText = u.append(f);
// take that cipher text, and decrypt it
QCA::SecureArray plainText = cipher.update(cipherText);
// take that cipher text, and decrypt it
QCA::SecureArray plainText = cipher.update(cipherText);
// check if the update() call worked
if (!cipher.ok()) {
printf("Update failed\n");
}
// check if the update() call worked
if (!cipher.ok()) {
printf("Update failed\n");
}
// output results
printf("Decryption using AES128 of [0x%s] is %s\n",
qPrintable(QCA::arrayToHex(cipherText.toByteArray())),
plainText.data());
// output results
printf("Decryption using AES128 of [0x%s] is %s\n",
qPrintable(QCA::arrayToHex(cipherText.toByteArray())), plainText.data());
// Again we need to call final(), to get the last block (with its padding removed)
plainText = cipher.final();
// Again we need to call final(), to get the last block (with its padding removed)
plainText = cipher.final();
// check if the final() call worked
if (!cipher.ok()) {
printf("Final failed\n");
}
// output results
printf("Final decryption block using AES128 is %s\n", plainText.data());
// instead of update() and final(), you can do the whole thing
// in one step, using process()
printf("One step decryption using AES128: %s\n",
QCA::SecureArray(cipher.process(cipherText)).data() );
// check if the final() call worked
if (!cipher.ok()) {
printf("Final failed\n");
}
// output results
printf("Final decryption block using AES128 is %s\n", plainText.data());
// instead of update() and final(), you can do the whole thing
// in one step, using process()
printf("One step decryption using AES128: %s\n", QCA::SecureArray(cipher.process(cipherText)).data());
}
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += ciphertest.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(cmsexample_bin_SRCS cmsexample.cpp)
add_executable(cmsexample ${cmsexample_bin_SRCS})
target_link_libraries( cmsexample qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(cmsexample)

View File

@ -1,2 +0,0 @@
SOURCES += cmsexample.cpp
include(../examples.pri)

View File

@ -20,13 +20,16 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QtCrypto>
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char** argv)
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
@ -35,31 +38,31 @@ int main(int argc, char** argv)
QCoreApplication app(argc, argv);
// We need to ensure that we have certificate handling support
if ( !QCA::isSupported( "cert" ) ) {
qWarning() << "Sorry, no PKI certificate support";
return 1;
if (!QCA::isSupported("cert")) {
qWarning() << "Sorry, no PKI certificate support";
return 1;
}
// Read in a public key cert
// you could also build this using the fromPEMFile() method
QCA::Certificate pubCert( "User.pem" );
if ( pubCert.isNull() ) {
qWarning() << "Sorry, could not import public key certificate";
return 1;
QCA::Certificate pubCert(QStringLiteral("User.pem"));
if (pubCert.isNull()) {
qWarning() << "Sorry, could not import public key certificate";
return 1;
}
// We are building the certificate into a SecureMessageKey object, via a
// CertificateChain
QCA::SecureMessageKey secMsgKey;
QCA::CertificateChain chain;
chain += pubCert;
secMsgKey.setX509CertificateChain( chain );
secMsgKey.setX509CertificateChain(chain);
// build up a SecureMessage object, based on our public key certificate
if ( !QCA::isSupported( "cms" ) ) {
qWarning() << "Sorry, no CMS support";
return 1;
if (!QCA::isSupported("cms")) {
qWarning() << "Sorry, no CMS support";
return 1;
}
QCA::CMS cms;
QCA::CMS cms;
QCA::SecureMessage msg(&cms);
msg.setRecipient(secMsgKey);
@ -74,35 +77,34 @@ int main(int argc, char** argv)
msg.waitForFinished(1000);
// check to see if it worked
if(!msg.success())
{
qWarning() << "Error encrypting: " << msg.errorCode();
return 1;
if (!msg.success()) {
qWarning() << "Error encrypting: " << msg.errorCode();
return 1;
}
// get the result
QByteArray cipherText = msg.read();
QByteArray cipherText = msg.read();
QCA::Base64 enc;
qDebug() << "'" << plainText.data() << "' encrypts to (in base 64): ";
qDebug() << enc.arrayToString( cipherText );
qDebug() << enc.arrayToString(cipherText);
qDebug() << "Message uses" << msg.hashName() << "hashing algorithm";
qDebug();
// Show we can decrypt it with the private key
// Read in a private key
QCA::PrivateKey privKey;
QCA::PrivateKey privKey;
QCA::ConvertResult convRes;
QCA::SecureArray passPhrase = "start";
privKey = QCA::PrivateKey::fromPEMFile( "Userkey.pem", passPhrase, &convRes );
if ( convRes != QCA::ConvertGood ) {
qWarning() << "Sorry, could not import Private Key";
return 1;
QCA::SecureArray passPhrase = "start";
privKey = QCA::PrivateKey::fromPEMFile(QStringLiteral("Userkey.pem"), passPhrase, &convRes);
if (convRes != QCA::ConvertGood) {
qWarning() << "Sorry, could not import Private Key";
return 1;
}
QCA::SecureMessageKey secMsgKey2;
// needed?
secMsgKey2.setX509CertificateChain( chain );
secMsgKey2.setX509CertificateChain(chain);
secMsgKey2.setX509PrivateKey(privKey);
QCA::SecureMessageKeyList privKeyList;
privKeyList += secMsgKey2;
@ -112,35 +114,31 @@ int main(int argc, char** argv)
// this example simulates encryption and one end, and decryption
// at the other
QCA::CMS anotherCms;
anotherCms.setPrivateKeys( privKeyList );
anotherCms.setPrivateKeys(privKeyList);
QCA::SecureMessage msg2( &anotherCms );
QCA::SecureMessage msg2(&anotherCms);
msg2.startDecrypt();
msg2.update( cipherText );
msg2.update(cipherText);
msg2.end();
// I think it is reasonable to wait for 1 second for this
msg2.waitForFinished(1000);
// check to see if it worked
if(!msg2.success())
{
qWarning() << "Error encrypting: " << msg2.errorCode();
return 1;
if (!msg2.success()) {
qWarning() << "Error encrypting: " << msg2.errorCode();
return 1;
}
QCA::SecureArray plainTextResult = msg2.read();
qDebug() << enc.arrayToString( cipherText )
<< " (in base 64) decrypts to: "
<< plainTextResult.data();
qDebug() << enc.arrayToString(cipherText) << " (in base 64) decrypts to: " << plainTextResult.data();
if (msg2.wasSigned()) {
qDebug() << "Message was signed at "
<< msg2.signer().timestamp();
qDebug() << "Message was signed at " << msg2.signer().timestamp();
} else {
qDebug() << "Message was not signed";
qDebug() << "Message was not signed";
}
qDebug() << "Message used" << msg2.hashName() << "hashing algorithm";
@ -151,7 +149,7 @@ int main(int argc, char** argv)
QByteArray text("Got your message");
// Re-use the CMS and SecureMessageKeyList objects from the decrypt...
QCA::SecureMessage signing( &anotherCms );
QCA::SecureMessage signing(&anotherCms);
signing.setSigners(privKeyList);
signing.startSign(QCA::SecureMessage::Detached);
@ -162,23 +160,21 @@ int main(int argc, char** argv)
signing.waitForFinished(1000);
// check to see if it worked
if(!signing.success())
{
qWarning() << "Error signing: " << signing.errorCode();
return 1;
if (!signing.success()) {
qWarning() << "Error signing: " << signing.errorCode();
return 1;
}
// get the result
QByteArray signature = signing.signature();
qDebug() << "'" << text.data() << "', signature (converted to base 64), is: ";
qDebug() << enc.arrayToString( signature );
qDebug() << enc.arrayToString(signature);
qDebug() << "Message uses" << signing.hashName() << "hashing algorithm";
qDebug();
// Now we go back to the first CMS, and re-use that.
QCA::SecureMessage verifying( &cms );
QCA::SecureMessage verifying(&cms);
// You have to pass the signature to startVerify(),
// and the message to update()
@ -189,23 +185,20 @@ int main(int argc, char** argv)
verifying.waitForFinished(1000);
// check to see if it worked
if(!verifying.success())
{
qWarning() << "Error verifying: " << verifying.errorCode();
return 1;
if (!verifying.success()) {
qWarning() << "Error verifying: " << verifying.errorCode();
return 1;
}
QCA::SecureMessageSignature sign;
sign = verifying.signer();
// todo: dump some data out about the signer
if(verifying.verifySuccess())
{
qDebug() << "Message verified";
if (verifying.verifySuccess()) {
qDebug() << "Message verified";
} else {
qDebug() << "Message failed to verify:" << verifying.errorCode();
qDebug() << "Message failed to verify:" << verifying.errorCode();
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -28,11 +28,10 @@
class QString;
class QStringList;
namespace QCA
{
class PrivateKey;
class CertificateChain;
class KeyStoreEntry;
namespace QCA {
class PrivateKey;
class CertificateChain;
class KeyStoreEntry;
}
class CertItemStore;
@ -42,105 +41,105 @@ class CertItemPrivateLoaderPrivate;
class CertItem
{
public:
enum StorageType
{
File,
KeyStore
};
enum StorageType
{
File,
KeyStore
};
CertItem();
CertItem(const CertItem &from);
~CertItem();
CertItem & operator=(const CertItem &from);
CertItem();
CertItem(const CertItem &from);
~CertItem();
CertItem &operator=(const CertItem &from);
QString name() const;
QCA::CertificateChain certificateChain() const;
bool havePrivate() const;
StorageType storageType() const; // private key storage type
bool isUsable() const; // file/provider present
QString name() const;
QCA::CertificateChain certificateChain() const;
bool havePrivate() const;
StorageType storageType() const; // private key storage type
bool isUsable() const; // file/provider present
private:
class Private;
QSharedDataPointer<Private> d;
class Private;
QSharedDataPointer<Private> d;
friend class CertItemStore;
friend class CertItemStorePrivate;
friend class CertItemPrivateLoader;
friend class CertItemPrivateLoaderPrivate;
friend class CertItemStore;
friend class CertItemStorePrivate;
friend class CertItemPrivateLoader;
friend class CertItemPrivateLoaderPrivate;
};
class CertItemStore : public QAbstractListModel
{
Q_OBJECT
Q_OBJECT
public:
enum IconType
{
IconCert,
IconCrl,
IconKeyBundle,
IconPgpPub,
IconPgpSec
};
enum IconType
{
IconCert,
IconCrl,
IconKeyBundle,
IconPgpPub,
IconPgpSec
};
CertItemStore(QObject *parent = 0);
~CertItemStore();
CertItemStore(QObject *parent = nullptr);
~CertItemStore();
int idFromRow(int row) const;
int rowFromId(int id) const;
CertItem itemFromId(int id) const;
CertItem itemFromRow(int row) const;
int idFromRow(int row) const;
int rowFromId(int id) const;
CertItem itemFromId(int id) const;
CertItem itemFromRow(int row) const;
QList<CertItem> items() const;
QList<CertItem> items() const;
QStringList save() const;
bool load(const QStringList &in);
QStringList save() const;
bool load(const QStringList &in);
// returns a reqId
int addFromFile(const QString &fileName);
int addFromKeyStore(const QCA::KeyStoreEntry &entry);
int addUser(const QCA::CertificateChain &chain);
// returns a reqId
int addFromFile(const QString &fileName);
int addFromKeyStore(const QCA::KeyStoreEntry &entry);
int addUser(const QCA::CertificateChain &chain);
void updateChain(int id, const QCA::CertificateChain &chain);
void updateChain(int id, const QCA::CertificateChain &chain);
void removeItem(int id);
void removeItem(int id);
void setIcon(IconType type, const QPixmap &icon);
void setIcon(IconType type, const QPixmap &icon);
// reimplemented
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
// reimplemented
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
signals:
void addSuccess(int reqId, int id);
void addFailed(int reqId);
Q_SIGNALS:
void addSuccess(int reqId, int id);
void addFailed(int reqId);
private:
friend class CertItemStorePrivate;
CertItemStorePrivate *d;
friend class CertItemStorePrivate;
CertItemStorePrivate *d;
friend class CertItemPrivateLoader;
friend class CertItemPrivateLoaderPrivate;
friend class CertItemPrivateLoader;
friend class CertItemPrivateLoaderPrivate;
};
class CertItemPrivateLoader : public QObject
{
Q_OBJECT
Q_OBJECT
public:
explicit CertItemPrivateLoader(CertItemStore *store, QObject *parent = 0);
~CertItemPrivateLoader();
explicit CertItemPrivateLoader(CertItemStore *store, QObject *parent = nullptr);
~CertItemPrivateLoader();
void start(int id);
void start(int id);
QCA::PrivateKey privateKey() const;
QCA::PrivateKey privateKey() const;
signals:
void finished();
Q_SIGNALS:
void finished();
private:
friend class CertItemPrivateLoaderPrivate;
CertItemPrivateLoaderPrivate *d;
friend class CertItemPrivateLoaderPrivate;
CertItemPrivateLoaderPrivate *d;
};
#endif

View File

@ -21,146 +21,165 @@
#include "certviewdlg.h"
#include <QtCore>
#include <QtGui>
#include <QtCrypto>
#include "ui_certview.h"
#include <QtCore>
#include <QtCrypto>
#include <QtGui>
// from qcatool
class InfoType
{
public:
QCA::CertificateInfoType type;
QString varname;
QString shortname;
QString name;
QString desc;
QCA::CertificateInfoType type;
QString varname;
QString shortname;
QString name;
QString desc;
InfoType()
{
}
InfoType()
{
}
InfoType(QCA::CertificateInfoType _type, const QString &_varname, const QString &_shortname, const QString &_name, const QString &_desc) :
type(_type),
varname(_varname),
shortname(_shortname),
name(_name),
desc(_desc)
{
}
InfoType(QCA::CertificateInfoType _type,
const QString & _varname,
const QString & _shortname,
const QString & _name,
const QString & _desc)
: type(_type)
, varname(_varname)
, shortname(_shortname)
, name(_name)
, desc(_desc)
{
}
};
static QList<InfoType> makeInfoTypeList(bool legacyEmail = false)
{
QList<InfoType> out;
out += InfoType(QCA::CommonName, "CommonName", "CN", CertViewDlg::tr("Common Name (CN)"), "Full name, domain, anything");
out += InfoType(QCA::Email, "Email", "", CertViewDlg::tr("Email Address"), "");
if(legacyEmail)
out += InfoType(QCA::EmailLegacy, "EmailLegacy", "", CertViewDlg::tr("PKCS#9 Email Address"), "");
out += InfoType(QCA::Organization, "Organization", "O", CertViewDlg::tr("Organization (O)"), "Company, group, etc");
out += InfoType(QCA::OrganizationalUnit, "OrganizationalUnit", "OU", CertViewDlg::tr("Organizational Unit (OU)"), "Division/branch of organization");
out += InfoType(QCA::Locality, "Locality", "", CertViewDlg::tr("Locality (L)"), "City, shire, part of a state");
out += InfoType(QCA::State, "State", "", CertViewDlg::tr("State (ST)"), "State within the country");
out += InfoType(QCA::Country, "Country", "C", CertViewDlg::tr("Country Code (C)"), "2-letter code");
out += InfoType(QCA::IncorporationLocality, "IncorporationLocality", "", CertViewDlg::tr("Incorporation Locality"), "For EV certificates");
out += InfoType(QCA::IncorporationState, "IncorporationState", "", CertViewDlg::tr("Incorporation State"), "For EV certificates");
out += InfoType(QCA::IncorporationCountry, "IncorporationCountry", "", CertViewDlg::tr("Incorporation Country"), "For EV certificates");
out += InfoType(QCA::URI, "URI", "", CertViewDlg::tr("URI"), "");
out += InfoType(QCA::DNS, "DNS", "", CertViewDlg::tr("Domain Name"), "Domain (dnsName)");
out += InfoType(QCA::IPAddress, "IPAddress", "", CertViewDlg::tr("IP Adddress"), "");
out += InfoType(QCA::XMPP, "XMPP", "", CertViewDlg::tr("XMPP Address (JID)"), "From RFC 3920 (id-on-xmppAddr)");
return out;
QList<InfoType> out;
out += InfoType(
QCA::CommonName, "CommonName", "CN", CertViewDlg::tr("Common Name (CN)"), "Full name, domain, anything");
out += InfoType(QCA::Email, "Email", "", CertViewDlg::tr("Email Address"), "");
if (legacyEmail)
out += InfoType(QCA::EmailLegacy, "EmailLegacy", "", CertViewDlg::tr("PKCS#9 Email Address"), "");
out += InfoType(QCA::Organization, "Organization", "O", CertViewDlg::tr("Organization (O)"), "Company, group, etc");
out += InfoType(QCA::OrganizationalUnit,
"OrganizationalUnit",
"OU",
CertViewDlg::tr("Organizational Unit (OU)"),
"Division/branch of organization");
out += InfoType(QCA::Locality, "Locality", "", CertViewDlg::tr("Locality (L)"), "City, shire, part of a state");
out += InfoType(QCA::State, "State", "", CertViewDlg::tr("State (ST)"), "State within the country");
out += InfoType(QCA::Country, "Country", "C", CertViewDlg::tr("Country Code (C)"), "2-letter code");
out += InfoType(QCA::IncorporationLocality,
"IncorporationLocality",
"",
CertViewDlg::tr("Incorporation Locality"),
"For EV certificates");
out += InfoType(QCA::IncorporationState,
"IncorporationState",
"",
CertViewDlg::tr("Incorporation State"),
"For EV certificates");
out += InfoType(QCA::IncorporationCountry,
"IncorporationCountry",
"",
CertViewDlg::tr("Incorporation Country"),
"For EV certificates");
out += InfoType(QCA::URI, "URI", "", CertViewDlg::tr("URI"), "");
out += InfoType(QCA::DNS, "DNS", "", CertViewDlg::tr("Domain Name"), "Domain (dnsName)");
out += InfoType(QCA::IPAddress, "IPAddress", "", CertViewDlg::tr("IP Adddress"), "");
out += InfoType(QCA::XMPP, "XMPP", "", CertViewDlg::tr("XMPP Address (JID)"), "From RFC 3920 (id-on-xmppAddr)");
return out;
}
static QString try_print_info(const QString &name, const QStringList &values)
{
QString out;
if(!values.isEmpty())
{
QString value = values.join(", ");
out = QString(" ") + CertViewDlg::tr("%1: %2").arg(name, value) + '\n';
}
return out;
QString out;
if (!values.isEmpty()) {
QString value = values.join(", ");
out = QString(" ") + CertViewDlg::tr("%1: %2").arg(name, value) + '\n';
}
return out;
}
static QString print_info(const QString &title, const QCA::CertificateInfo &info)
{
QString out;
QList<InfoType> list = makeInfoTypeList();
out += title + '\n';
foreach(const InfoType &t, list)
out += try_print_info(t.name, info.values(t.type));
return out;
QString out;
QList<InfoType> list = makeInfoTypeList();
out += title + '\n';
foreach (const InfoType &t, list)
out += try_print_info(t.name, info.values(t.type));
return out;
}
static QString cert_info_string(const QCA::Certificate &cert)
{
QString out;
out += CertViewDlg::tr("Serial Number: %1").arg(cert.serialNumber().toString()) + '\n';
out += print_info(CertViewDlg::tr("Subject"), cert.subjectInfo());
out += print_info(CertViewDlg::tr("Issuer"), cert.issuerInfo());
out += CertViewDlg::tr("Validity") + '\n';
out += QString(" ") + CertViewDlg::tr("Not before: %1").arg(cert.notValidBefore().toString()) + '\n';
out += QString(" ") + CertViewDlg::tr("Not after: %1").arg(cert.notValidAfter().toString()) + '\n';
return out;
QString out;
out += CertViewDlg::tr("Serial Number: %1").arg(cert.serialNumber().toString()) + '\n';
out += print_info(CertViewDlg::tr("Subject"), cert.subjectInfo());
out += print_info(CertViewDlg::tr("Issuer"), cert.issuerInfo());
out += CertViewDlg::tr("Validity") + '\n';
out += QString(" ") + CertViewDlg::tr("Not before: %1").arg(cert.notValidBefore().toString()) + '\n';
out += QString(" ") + CertViewDlg::tr("Not after: %1").arg(cert.notValidAfter().toString()) + '\n';
return out;
}
class CertViewDlg::Private : public QObject
{
Q_OBJECT
Q_OBJECT
public:
CertViewDlg *q;
Ui_CertView ui;
QCA::CertificateChain chain;
CertViewDlg * q;
Ui_CertView ui;
QCA::CertificateChain chain;
Private(CertViewDlg *_q) :
QObject(_q),
q(_q)
{
ui.setupUi(q);
connect(ui.cb_chain, SIGNAL(activated(int)), SLOT(cb_activated(int)));
ui.lb_info->setTextInteractionFlags(Qt::TextSelectableByMouse);
}
Private(CertViewDlg *_q)
: QObject(_q)
, q(_q)
{
ui.setupUi(q);
connect(ui.cb_chain, SIGNAL(activated(int)), SLOT(cb_activated(int)));
ui.lb_info->setTextInteractionFlags(Qt::TextSelectableByMouse);
}
void update()
{
QStringList names = QCA::makeFriendlyNames(chain);
ui.cb_chain->clear();
foreach(const QString &s, names)
ui.cb_chain->insertItem(ui.cb_chain->count(), s);
updateInfo();
}
void update()
{
QStringList names = QCA::makeFriendlyNames(chain);
ui.cb_chain->clear();
foreach (const QString &s, names)
ui.cb_chain->insertItem(ui.cb_chain->count(), s);
updateInfo();
}
void updateInfo()
{
int x = ui.cb_chain->currentIndex();
if(x == -1)
{
ui.lb_info->setText("");
return;
}
void updateInfo()
{
int x = ui.cb_chain->currentIndex();
if (x == -1) {
ui.lb_info->setText("");
return;
}
ui.lb_info->setText(cert_info_string(chain[x]));
}
ui.lb_info->setText(cert_info_string(chain[x]));
}
private slots:
void cb_activated(int)
{
updateInfo();
}
private Q_SLOTS:
void cb_activated(int)
{
updateInfo();
}
};
CertViewDlg::CertViewDlg(const QCA::CertificateChain &chain, QWidget *parent) :
QDialog(parent)
CertViewDlg::CertViewDlg(const QCA::CertificateChain &chain, QWidget *parent)
: QDialog(parent)
{
d = new Private(this);
d->chain = chain;
d->update();
d = new Private(this);
d->chain = chain;
d->update();
}
CertViewDlg::~CertViewDlg()
{
delete d;
delete d;
}
#include "certviewdlg.moc"

View File

@ -24,21 +24,20 @@
#include <QDialog>
namespace QCA
{
class CertificateChain;
namespace QCA {
class CertificateChain;
}
class CertViewDlg : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit CertViewDlg(const QCA::CertificateChain &chain, QWidget *parent = 0);
~CertViewDlg();
explicit CertViewDlg(const QCA::CertificateChain &chain, QWidget *parent = 0);
~CertViewDlg();
private:
class Private;
Private *d;
class Private;
Private *d;
};
#endif

View File

@ -1,22 +0,0 @@
include(../examples.pri)
CONFIG -= console
CONFIG += app_bundle
QT += gui
include(pkcs11configdlg/pkcs11configdlg.pri)
HEADERS += \
prompter.h \
certviewdlg.h \
keyselectdlg.h \
certitem.h
SOURCES += \
prompter.cpp \
certviewdlg.cpp \
keyselectdlg.cpp \
certitem.cpp \
main.cpp
FORMS += certview.ui keyselect.ui mainwin.ui
RESOURCES += cmssigner.qrc

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 815 B

After

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 617 B

View File

@ -21,402 +21,394 @@
#include "keyselectdlg.h"
#include <QtCore>
#include <QtGui>
#include <QtCrypto>
#include "ui_keyselect.h"
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QtCore>
#include <QtCrypto>
#include <QtGui>
#define ONLY_SHOW_KEYBUNDLE
typedef QMap<KeySelectDlg::IconType,QPixmap> KeyStoreIconset;
typedef QMap<KeySelectDlg::IconType, QPixmap> KeyStoreIconset;
class KeyStoreItemShared
{
public:
KeyStoreIconset iconset;
QString notAvailableString;
KeyStoreIconset iconset;
QString notAvailableString;
};
class KeyStoreItem : public QStandardItem
{
public:
enum Type
{
Store = UserType,
Entry
};
enum Type
{
Store = UserType,
Entry
};
enum Role
{
NameRole = Qt::UserRole,
SubTypeRole,
AvailabilityRole,
PositionRole
};
enum Role
{
NameRole = Qt::UserRole,
SubTypeRole,
AvailabilityRole,
PositionRole
};
QPixmap entryTypeToIcon(QCA::KeyStoreEntry::Type type) const
{
QPixmap out;
if(!_shared)
return out;
const KeyStoreIconset &iconset = _shared->iconset;
switch(type)
{
case QCA::KeyStoreEntry::TypeKeyBundle: out = iconset[KeySelectDlg::IconKeyBundle]; break;
case QCA::KeyStoreEntry::TypeCertificate: out = iconset[KeySelectDlg::IconCert]; break;
case QCA::KeyStoreEntry::TypeCRL: out = iconset[KeySelectDlg::IconCrl]; break;
case QCA::KeyStoreEntry::TypePGPSecretKey: out = iconset[KeySelectDlg::IconPgpSec]; break;
case QCA::KeyStoreEntry::TypePGPPublicKey: out = iconset[KeySelectDlg::IconPgpPub]; break;
default: break;
}
return out;
}
QPixmap entryTypeToIcon(QCA::KeyStoreEntry::Type type) const
{
QPixmap out;
if (!_shared)
return out;
const KeyStoreIconset &iconset = _shared->iconset;
switch (type) {
case QCA::KeyStoreEntry::TypeKeyBundle:
out = iconset[KeySelectDlg::IconKeyBundle];
break;
case QCA::KeyStoreEntry::TypeCertificate:
out = iconset[KeySelectDlg::IconCert];
break;
case QCA::KeyStoreEntry::TypeCRL:
out = iconset[KeySelectDlg::IconCrl];
break;
case QCA::KeyStoreEntry::TypePGPSecretKey:
out = iconset[KeySelectDlg::IconPgpSec];
break;
case QCA::KeyStoreEntry::TypePGPPublicKey:
out = iconset[KeySelectDlg::IconPgpPub];
break;
default:
break;
}
return out;
}
Type _type;
KeyStoreItemShared *_shared;
Type _type;
KeyStoreItemShared *_shared;
QCA::KeyStore *keyStore;
QCA::KeyStoreEntry keyStoreEntry;
QCA::KeyStore * keyStore;
QCA::KeyStoreEntry keyStoreEntry;
KeyStoreItem(Type type, KeyStoreItemShared *shared) :
_type(type),
_shared(shared)
{
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
KeyStoreItem(Type type, KeyStoreItemShared *shared)
: _type(type)
, _shared(shared)
{
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
void setStore(const QString &name, QCA::KeyStore::Type type)
{
setData(name, NameRole);
setData((int)type, SubTypeRole);
}
void setStore(const QString &name, QCA::KeyStore::Type type)
{
setData(name, NameRole);
setData((int)type, SubTypeRole);
}
void setEntry(const QString &name, QCA::KeyStoreEntry::Type type, bool available, int pos)
{
setData(name, NameRole);
setData((int)type, SubTypeRole);
setData(available, AvailabilityRole);
setData(pos, PositionRole);
}
void setEntry(const QString &name, QCA::KeyStoreEntry::Type type, bool available, int pos)
{
setData(name, NameRole);
setData((int)type, SubTypeRole);
setData(available, AvailabilityRole);
setData(pos, PositionRole);
}
virtual QVariant data(int role) const
{
if(role == Qt::DisplayRole)
{
if(_type == Store)
{
return data(NameRole).toString();
}
else if(_type == Entry)
{
QString str = data(NameRole).toString();
if(_shared && !data(AvailabilityRole).toBool())
str += QString(" ") + _shared->notAvailableString;
return str;
}
else
return QStandardItem::data(role);
}
else if(role == Qt::DecorationRole)
{
if(_type == Entry)
{
QCA::KeyStoreEntry::Type type = (QCA::KeyStoreEntry::Type)data(SubTypeRole).toInt();
return entryTypeToIcon(type);
}
else
return QStandardItem::data(role);
}
else
return QStandardItem::data(role);
}
virtual QVariant data(int role) const
{
if (role == Qt::DisplayRole) {
if (_type == Store) {
return data(NameRole).toString();
} else if (_type == Entry) {
QString str = data(NameRole).toString();
if (_shared && !data(AvailabilityRole).toBool())
str += QString(" ") + _shared->notAvailableString;
return str;
} else
return QStandardItem::data(role);
} else if (role == Qt::DecorationRole) {
if (_type == Entry) {
QCA::KeyStoreEntry::Type type = (QCA::KeyStoreEntry::Type)data(SubTypeRole).toInt();
return entryTypeToIcon(type);
} else
return QStandardItem::data(role);
} else
return QStandardItem::data(role);
}
virtual int type() const
{
return _type;
}
virtual int type() const
{
return _type;
}
virtual QStandardItem *clone() const
{
return new KeyStoreItem(*this);
}
virtual QStandardItem *clone() const
{
return new KeyStoreItem(*this);
}
};
class KeyStoreModel : public QStandardItemModel
{
Q_OBJECT
Q_OBJECT
public:
KeyStoreItemShared shared;
KeyStoreItemShared shared;
QCA::KeyStoreManager ksm;
QCA::KeyStoreManager ksm;
KeyStoreModel(QObject *parent = 0) :
QStandardItemModel(parent), ksm(this)
{
shared.notAvailableString = tr("(not available)");
KeyStoreModel(QObject *parent = 0)
: QStandardItemModel(parent)
, ksm(this)
{
shared.notAvailableString = tr("(not available)");
// make sure keystores are started
QCA::KeyStoreManager::start();
// make sure keystores are started
QCA::KeyStoreManager::start();
connect(&ksm, SIGNAL(keyStoreAvailable(const QString &)), SLOT(ks_available(const QString &)));
QStringList list = ksm.keyStores();
foreach(const QString &s, list)
ks_available(s);
connect(&ksm, SIGNAL(keyStoreAvailable(const QString &)), SLOT(ks_available(const QString &)));
QStringList list = ksm.keyStores();
foreach (const QString &s, list)
ks_available(s);
setSortRole(KeyStoreItem::PositionRole);
}
setSortRole(KeyStoreItem::PositionRole);
}
KeyStoreItem *itemFromStore(QCA::KeyStore *ks) const
{
for(int n = 0; n < rowCount(); ++n)
{
KeyStoreItem *i = (KeyStoreItem *)item(n);
if(i->keyStore == ks)
return i;
}
return 0;
}
KeyStoreItem *itemFromStore(QCA::KeyStore *ks) const
{
for (int n = 0; n < rowCount(); ++n) {
KeyStoreItem *i = (KeyStoreItem *)item(n);
if (i->keyStore == ks)
return i;
}
return 0;
}
private slots:
void ks_available(const QString &keyStoreId)
{
QCA::KeyStore *ks = new QCA::KeyStore(keyStoreId, &ksm);
private Q_SLOTS:
void ks_available(const QString &keyStoreId)
{
QCA::KeyStore *ks = new QCA::KeyStore(keyStoreId, &ksm);
#ifdef ONLY_SHOW_KEYBUNDLE
// only list stores containing keybundles (non-pgp identities)
if(!ks->holdsIdentities() || ks->type() == QCA::KeyStore::PGPKeyring)
return;
// only list stores containing keybundles (non-pgp identities)
if (!ks->holdsIdentities() || ks->type() == QCA::KeyStore::PGPKeyring)
return;
#endif
connect(ks, SIGNAL(updated()), SLOT(ks_updated()));
connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
connect(ks, SIGNAL(updated()), SLOT(ks_updated()));
connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
KeyStoreItem *store_item = new KeyStoreItem(KeyStoreItem::Store, &shared);
store_item->setStore(ks->name(), ks->type());
store_item->keyStore = ks;
ks->startAsynchronousMode();
appendRow(store_item);
}
KeyStoreItem *store_item = new KeyStoreItem(KeyStoreItem::Store, &shared);
store_item->setStore(ks->name(), ks->type());
store_item->keyStore = ks;
ks->startAsynchronousMode();
appendRow(store_item);
}
void ks_updated()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
KeyStoreItem *store_item = itemFromStore(ks);
Q_ASSERT(store_item);
void ks_updated()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
KeyStoreItem * store_item = itemFromStore(ks);
Q_ASSERT(store_item);
QList<QCA::KeyStoreEntry> newEntries = ks->entryList();
QList<QCA::KeyStoreEntry> newEntries = ks->entryList();
#ifdef ONLY_SHOW_KEYBUNDLE
// ignore entries that are not keybundles
for(int n = 0; n < newEntries.count(); ++n)
{
if(newEntries[n].type() != QCA::KeyStoreEntry::TypeKeyBundle)
{
newEntries.removeAt(n);
--n; // adjust position
}
}
// ignore entries that are not keybundles
for (int n = 0; n < newEntries.count(); ++n) {
if (newEntries[n].type() != QCA::KeyStoreEntry::TypeKeyBundle) {
newEntries.removeAt(n);
--n; // adjust position
}
}
#endif
// update the store item itself
store_item->setStore(ks->name(), ks->type());
// update the store item itself
store_item->setStore(ks->name(), ks->type());
// handle removed child entries
for(int n = 0; n < store_item->rowCount(); ++n)
{
KeyStoreItem *i = (KeyStoreItem *)store_item->child(n);
// handle removed child entries
for (int n = 0; n < store_item->rowCount(); ++n) {
KeyStoreItem *i = (KeyStoreItem *)store_item->child(n);
// is the existing entry in the new list?
bool found = false;
foreach(const QCA::KeyStoreEntry &ne, newEntries)
{
if(ne.id() == i->keyStoreEntry.id())
{
found = true;
break;
}
}
// is the existing entry in the new list?
bool found = false;
foreach (const QCA::KeyStoreEntry &ne, newEntries) {
if (ne.id() == i->keyStoreEntry.id()) {
found = true;
break;
}
}
// if not, remove it
if(!found)
{
store_item->removeRow(n);
--n; // adjust position
}
}
// if not, remove it
if (!found) {
store_item->removeRow(n);
--n; // adjust position
}
}
// handle added/updated child entries
for(int n = 0; n < newEntries.count(); ++n)
{
const QCA::KeyStoreEntry &ne = newEntries[n];
// handle added/updated child entries
for (int n = 0; n < newEntries.count(); ++n) {
const QCA::KeyStoreEntry &ne = newEntries[n];
// was this entry in the original list?
KeyStoreItem *entry_item = 0;
for(int k = 0; k < store_item->rowCount(); ++k)
{
KeyStoreItem *i = (KeyStoreItem *)store_item->child(k);
if(i->keyStoreEntry.id() == ne.id())
{
entry_item = i;
break;
}
}
// was this entry in the original list?
KeyStoreItem *entry_item = 0;
for (int k = 0; k < store_item->rowCount(); ++k) {
KeyStoreItem *i = (KeyStoreItem *)store_item->child(k);
if (i->keyStoreEntry.id() == ne.id()) {
entry_item = i;
break;
}
}
// if not, add it
if(!entry_item)
{
entry_item = new KeyStoreItem(KeyStoreItem::Entry, &shared);
entry_item->keyStoreEntry = ne;
entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
store_item->appendRow(entry_item);
}
// if so, update it
else
{
entry_item->keyStoreEntry = ne;
entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
}
}
// if not, add it
if (!entry_item) {
entry_item = new KeyStoreItem(KeyStoreItem::Entry, &shared);
entry_item->keyStoreEntry = ne;
entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
store_item->appendRow(entry_item);
}
// if so, update it
else {
entry_item->keyStoreEntry = ne;
entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
}
}
store_item->sortChildren(0);
}
store_item->sortChildren(0);
}
void ks_unavailable()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
KeyStoreItem *store_item = itemFromStore(ks);
Q_ASSERT(store_item);
void ks_unavailable()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
KeyStoreItem * store_item = itemFromStore(ks);
Q_ASSERT(store_item);
store_item->removeRows(0, store_item->rowCount());
removeRow(store_item->row());
delete ks;
}
store_item->removeRows(0, store_item->rowCount());
removeRow(store_item->row());
delete ks;
}
};
class KeySelectDlg::Private : public QObject
{
Q_OBJECT
Q_OBJECT
public:
KeySelectDlg *q;
Ui_KeySelect ui;
KeyStoreModel *model;
QCA::KeyStoreEntry cur_entry;
QAction *actionView;
KeySelectDlg * q;
Ui_KeySelect ui;
KeyStoreModel * model;
QCA::KeyStoreEntry cur_entry;
QAction * actionView;
Private(KeySelectDlg *_q) :
QObject(_q),
q(_q)
{
ui.setupUi(q);
Private(KeySelectDlg *_q)
: QObject(_q)
, q(_q)
{
ui.setupUi(q);
model = new KeyStoreModel(this);
connect(&model->ksm, SIGNAL(busyStarted()), SLOT(ksm_busyStarted()));
connect(&model->ksm, SIGNAL(busyFinished()), SLOT(ksm_busyFinished()));
if(model->ksm.isBusy())
ksm_busyStarted();
model = new KeyStoreModel(this);
connect(&model->ksm, SIGNAL(busyStarted()), SLOT(ksm_busyStarted()));
connect(&model->ksm, SIGNAL(busyFinished()), SLOT(ksm_busyFinished()));
if (model->ksm.isBusy())
ksm_busyStarted();
ui.lv_stores->header()->hide();
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui.lv_stores->setModel(model);
ui.lv_stores->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.lv_stores->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), SLOT(stores_selectionChanged(const QItemSelection &, const QItemSelection &)));
connect(ui.lv_stores, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(stores_customContextMenuRequested(const QPoint &)));
ui.lv_stores->header()->hide();
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui.lv_stores->setModel(model);
ui.lv_stores->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui.lv_stores->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(stores_selectionChanged(const QItemSelection &, const QItemSelection &)));
connect(ui.lv_stores,
SIGNAL(customContextMenuRequested(const QPoint &)),
SLOT(stores_customContextMenuRequested(const QPoint &)));
actionView = new QAction(tr("&View"), this);
connect(actionView, SIGNAL(triggered()), SLOT(view()));
actionView->setEnabled(false);
}
actionView = new QAction(tr("&View"), this);
connect(actionView, SIGNAL(triggered()), SLOT(view()));
actionView->setEnabled(false);
}
private slots:
void ksm_busyStarted()
{
ui.lb_busy->setText(tr("Looking for devices..."));
}
private Q_SLOTS:
void ksm_busyStarted()
{
ui.lb_busy->setText(tr("Looking for devices..."));
}
void ksm_busyFinished()
{
ui.lb_busy->setText("");
}
void ksm_busyFinished()
{
ui.lb_busy->setText("");
}
void stores_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
Q_UNUSED(deselected);
void stores_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
Q_UNUSED(deselected);
KeyStoreItem *i = 0;
if(!selected.indexes().isEmpty())
{
QModelIndex index = selected.indexes().first();
i = (KeyStoreItem *)model->itemFromIndex(index);
}
KeyStoreItem *i = 0;
if (!selected.indexes().isEmpty()) {
QModelIndex index = selected.indexes().first();
i = (KeyStoreItem *)model->itemFromIndex(index);
}
bool viewable = false;
bool choosable = false;
if(i && i->type() == KeyStoreItem::Entry)
{
QCA::KeyStoreEntry entry = i->keyStoreEntry;
if(entry.type() == QCA::KeyStoreEntry::TypeKeyBundle)
{
viewable = true;
choosable = true;
cur_entry = entry;
}
}
bool viewable = false;
bool choosable = false;
if (i && i->type() == KeyStoreItem::Entry) {
QCA::KeyStoreEntry entry = i->keyStoreEntry;
if (entry.type() == QCA::KeyStoreEntry::TypeKeyBundle) {
viewable = true;
choosable = true;
cur_entry = entry;
}
}
if(!choosable)
cur_entry = QCA::KeyStoreEntry();
if (!choosable)
cur_entry = QCA::KeyStoreEntry();
actionView->setEnabled(viewable);
actionView->setEnabled(viewable);
QPushButton *ok = ui.buttonBox->button(QDialogButtonBox::Ok);
if(choosable && !ok->isEnabled())
ok->setEnabled(true);
else if(!choosable && ok->isEnabled())
ok->setEnabled(false);
}
QPushButton *ok = ui.buttonBox->button(QDialogButtonBox::Ok);
if (choosable && !ok->isEnabled())
ok->setEnabled(true);
else if (!choosable && ok->isEnabled())
ok->setEnabled(false);
}
void stores_customContextMenuRequested(const QPoint &pos)
{
QItemSelection selection = ui.lv_stores->selectionModel()->selection();
if(selection.indexes().isEmpty())
return;
void stores_customContextMenuRequested(const QPoint &pos)
{
QItemSelection selection = ui.lv_stores->selectionModel()->selection();
if (selection.indexes().isEmpty())
return;
QModelIndex index = selection.indexes().first();
KeyStoreItem *i = (KeyStoreItem *)model->itemFromIndex(index);
if(i && i->type() == KeyStoreItem::Entry)
{
QMenu menu(q);
menu.addAction(actionView);
menu.exec(ui.lv_stores->viewport()->mapToGlobal(pos));
}
}
QModelIndex index = selection.indexes().first();
KeyStoreItem *i = (KeyStoreItem *)model->itemFromIndex(index);
if (i && i->type() == KeyStoreItem::Entry) {
QMenu menu(q);
menu.addAction(actionView);
menu.exec(ui.lv_stores->viewport()->mapToGlobal(pos));
}
}
void view()
{
emit q->viewCertificate(cur_entry.keyBundle().certificateChain());
}
void view()
{
emit q->viewCertificate(cur_entry.keyBundle().certificateChain());
}
};
KeySelectDlg::KeySelectDlg(QWidget *parent) :
QDialog(parent)
KeySelectDlg::KeySelectDlg(QWidget *parent)
: QDialog(parent)
{
d = new Private(this);
d = new Private(this);
}
KeySelectDlg::~KeySelectDlg()
{
delete d;
delete d;
}
void KeySelectDlg::setIcon(IconType type, const QPixmap &icon)
{
d->model->shared.iconset[type] = icon;
d->model->shared.iconset[type] = icon;
}
void KeySelectDlg::accept()
{
QCA::KeyStoreEntry entry = d->cur_entry;
QDialog::accept();
emit selected(entry);
QCA::KeyStoreEntry entry = d->cur_entry;
QDialog::accept();
emit selected(entry);
}
#include "keyselectdlg.moc"

View File

@ -26,41 +26,40 @@
class QPixmap;
namespace QCA
{
class CertificateChain;
class KeyStoreEntry;
namespace QCA {
class CertificateChain;
class KeyStoreEntry;
}
class KeySelectDlg : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
enum IconType
{
IconCert,
IconCrl,
IconKeyBundle,
IconPgpPub,
IconPgpSec
};
enum IconType
{
IconCert,
IconCrl,
IconKeyBundle,
IconPgpPub,
IconPgpSec
};
KeySelectDlg(QWidget *parent = 0);
~KeySelectDlg();
KeySelectDlg(QWidget *parent = 0);
~KeySelectDlg();
void setIcon(IconType type, const QPixmap &icon);
void setIcon(IconType type, const QPixmap &icon);
signals:
void selected(const QCA::KeyStoreEntry &entry);
void viewCertificate(const QCA::CertificateChain &chain);
Q_SIGNALS:
void selected(const QCA::KeyStoreEntry &entry);
void viewCertificate(const QCA::CertificateChain &chain);
protected slots:
virtual void accept();
virtual void accept();
private:
class Private;
friend class Private;
Private *d;
class Private;
friend class Private;
Private *d;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,18 +30,18 @@
class Pkcs11ConfigDlg : public QDialog
{
public:
Pkcs11ConfigDlg(QWidget *parent = 0);
Pkcs11ConfigDlg(const QString &providerName, const QVariantMap &config, QWidget *parent = 0);
~Pkcs11ConfigDlg();
Pkcs11ConfigDlg(QWidget *parent = 0);
Pkcs11ConfigDlg(const QString &providerName, const QVariantMap &config, QWidget *parent = 0);
~Pkcs11ConfigDlg();
static bool isSupported();
static bool isSupported();
protected slots:
virtual void done(int r);
virtual void done(int r);
private:
class Private;
Private *d;
class Private;
Private *d;
};
#endif

View File

@ -1,3 +0,0 @@
HEADERS += $$PWD/pkcs11configdlg.h
SOURCES += $$PWD/pkcs11configdlg.cpp
FORMS += $$PWD/pkcs11config.ui

View File

@ -21,298 +21,278 @@
#include "prompter.h"
#include <QApplication>
#include <QInputDialog>
#include <QMessageBox>
#include <QtCore>
#include <QtGui>
#include <QtCrypto>
#include <QtGui>
class Prompter::Private : public QObject
{
Q_OBJECT
Q_OBJECT
public:
Prompter *q;
Prompter *q;
class Item
{
public:
int id;
QCA::Event event;
};
class Item
{
public:
int id;
QCA::Event event;
};
QCA::EventHandler handler;
QList<Item> pending;
bool prompting;
QMessageBox *token_prompt;
bool auto_accept;
QCA::EventHandler handler;
QList<Item> pending;
bool prompting;
QMessageBox * token_prompt;
bool auto_accept;
QCA::KeyStoreManager ksm;
QList<QCA::KeyStore*> keyStores;
QCA::KeyStoreManager ksm;
QList<QCA::KeyStore *> keyStores;
Private(Prompter *_q) :
QObject(_q),
q(_q),
handler(this),
prompting(false),
token_prompt(0),
ksm(this)
{
connect(&handler, SIGNAL(eventReady(int, const QCA::Event &)), SLOT(ph_eventReady(int, const QCA::Event &)));
handler.start();
Private(Prompter *_q)
: QObject(_q)
, q(_q)
, handler(this)
, prompting(false)
, token_prompt(0)
, ksm(this)
{
connect(&handler, SIGNAL(eventReady(int, const QCA::Event &)), SLOT(ph_eventReady(int, const QCA::Event &)));
handler.start();
connect(&ksm, SIGNAL(keyStoreAvailable(const QString &)), SLOT(ks_available(const QString &)));
foreach(const QString &keyStoreId, ksm.keyStores())
ks_available(keyStoreId);
}
connect(&ksm, SIGNAL(keyStoreAvailable(const QString &)), SLOT(ks_available(const QString &)));
foreach (const QString &keyStoreId, ksm.keyStores())
ks_available(keyStoreId);
}
~Private()
{
qDeleteAll(keyStores);
~Private()
{
qDeleteAll(keyStores);
while(!pending.isEmpty())
handler.reject(pending.takeFirst().id);
}
while (!pending.isEmpty())
handler.reject(pending.takeFirst().id);
}
private slots:
void ph_eventReady(int id, const QCA::Event &event)
{
Item i;
i.id = id;
i.event = event;
pending += i;
nextEvent();
}
private Q_SLOTS:
void ph_eventReady(int id, const QCA::Event &event)
{
Item i;
i.id = id;
i.event = event;
pending += i;
nextEvent();
}
void nextEvent()
{
if(prompting || pending.isEmpty())
return;
void nextEvent()
{
if (prompting || pending.isEmpty())
return;
prompting = true;
prompting = true;
const Item &i = pending.first();
const int &id = i.id;
const QCA::Event &event = i.event;
const Item & i = pending.first();
const int & id = i.id;
const QCA::Event &event = i.event;
if(event.type() == QCA::Event::Password)
{
QCA::SecureArray known = q->knownPassword(event);
if(!known.isEmpty())
{
handler.submitPassword(id, known);
goto end;
}
if (event.type() == QCA::Event::Password) {
QCA::SecureArray known = q->knownPassword(event);
if (!known.isEmpty()) {
handler.submitPassword(id, known);
goto end;
}
QString type = Prompter::tr("password");
if(event.passwordStyle() == QCA::Event::StylePassphrase)
type = Prompter::tr("passphrase");
else if(event.passwordStyle() == QCA::Event::StylePIN)
type = Prompter::tr("PIN");
QString type = Prompter::tr("password");
if (event.passwordStyle() == QCA::Event::StylePassphrase)
type = Prompter::tr("passphrase");
else if (event.passwordStyle() == QCA::Event::StylePIN)
type = Prompter::tr("PIN");
QString str;
if(event.source() == QCA::Event::KeyStore)
{
QString name;
QCA::KeyStoreEntry entry = event.keyStoreEntry();
if(!entry.isNull())
{
name = entry.name();
}
else
{
if(event.keyStoreInfo().type() == QCA::KeyStore::SmartCard)
name = Prompter::tr("the '%1' token").arg(event.keyStoreInfo().name());
else
name = event.keyStoreInfo().name();
}
str = Prompter::tr("Enter %1 for %2").arg(type, name);
}
else if(!event.fileName().isEmpty())
{
QFileInfo fi(event.fileName());
str = Prompter::tr("Enter %1 for %2:").arg(type, fi.fileName());
}
else
str = Prompter::tr("Enter %1:").arg(type);
QString str;
if (event.source() == QCA::Event::KeyStore) {
QString name;
QCA::KeyStoreEntry entry = event.keyStoreEntry();
if (!entry.isNull()) {
name = entry.name();
} else {
if (event.keyStoreInfo().type() == QCA::KeyStore::SmartCard)
name = Prompter::tr("the '%1' token").arg(event.keyStoreInfo().name());
else
name = event.keyStoreInfo().name();
}
str = Prompter::tr("Enter %1 for %2").arg(type, name);
} else if (!event.fileName().isEmpty()) {
QFileInfo fi(event.fileName());
str = Prompter::tr("Enter %1 for %2:").arg(type, fi.fileName());
} else
str = Prompter::tr("Enter %1:").arg(type);
bool ok;
QString pass = QInputDialog::getText(0, QApplication::instance()->applicationName() + ": " + tr("Prompt"), str, QLineEdit::Password, QString(), &ok);
if(ok)
{
QCA::SecureArray password = pass.toUtf8();
q->userSubmitted(password, event);
handler.submitPassword(id, password);
}
else
handler.reject(id);
}
else if(event.type() == QCA::Event::Token)
{
// even though we're being prompted for a missing token,
// we should still check if the token is present, due to
// a possible race between insert and token request.
bool found = false;
bool ok;
QString pass = QInputDialog::getText(0,
QApplication::instance()->applicationName() + ": " + tr("Prompt"),
str,
QLineEdit::Password,
QString(),
&ok);
if (ok) {
QCA::SecureArray password = pass.toUtf8();
q->userSubmitted(password, event);
handler.submitPassword(id, password);
} else
handler.reject(id);
} else if (event.type() == QCA::Event::Token) {
// even though we're being prompted for a missing token,
// we should still check if the token is present, due to
// a possible race between insert and token request.
bool found = false;
// token-only
if(event.keyStoreEntry().isNull())
{
foreach(QCA::KeyStore *ks, keyStores)
{
if(ks->id() == event.keyStoreInfo().id())
{
found = true;
break;
}
}
}
// token-entry
else
{
QCA::KeyStoreEntry kse = event.keyStoreEntry();
// token-only
if (event.keyStoreEntry().isNull()) {
foreach (QCA::KeyStore *ks, keyStores) {
if (ks->id() == event.keyStoreInfo().id()) {
found = true;
break;
}
}
}
// token-entry
else {
QCA::KeyStoreEntry kse = event.keyStoreEntry();
QCA::KeyStore *ks = 0;
foreach(QCA::KeyStore *i, keyStores)
{
if(i->id() == event.keyStoreInfo().id())
{
ks = i;
break;
}
}
if(ks)
{
QList<QCA::KeyStoreEntry> list = ks->entryList();
foreach(const QCA::KeyStoreEntry &e, list)
{
if(e.id() == kse.id() && kse.isAvailable())
{
found = true;
break;
}
}
}
}
if(found)
{
// auto-accept
handler.tokenOkay(id);
return;
}
QCA::KeyStore *ks = 0;
foreach (QCA::KeyStore *i, keyStores) {
if (i->id() == event.keyStoreInfo().id()) {
ks = i;
break;
}
}
if (ks) {
QList<QCA::KeyStoreEntry> list = ks->entryList();
foreach (const QCA::KeyStoreEntry &e, list) {
if (e.id() == kse.id() && kse.isAvailable()) {
found = true;
break;
}
}
}
}
if (found) {
// auto-accept
handler.tokenOkay(id);
return;
}
QCA::KeyStoreEntry entry = event.keyStoreEntry();
QString name;
if(!entry.isNull())
{
name = Prompter::tr("Please make %1 (of %2) available").arg(entry.name(), entry.storeName());
}
else
{
name = Prompter::tr("Please insert the '%1' token").arg(event.keyStoreInfo().name());
}
QCA::KeyStoreEntry entry = event.keyStoreEntry();
QString name;
if (!entry.isNull()) {
name = Prompter::tr("Please make %1 (of %2) available").arg(entry.name(), entry.storeName());
} else {
name = Prompter::tr("Please insert the '%1' token").arg(event.keyStoreInfo().name());
}
QString str = Prompter::tr("%1 and click OK.").arg(name);
QString str = Prompter::tr("%1 and click OK.").arg(name);
QMessageBox msgBox(QMessageBox::Information, QApplication::instance()->applicationName() + ": " + tr("Prompt"), str, QMessageBox::Ok | QMessageBox::Cancel, 0);
token_prompt = &msgBox;
auto_accept = false;
if(msgBox.exec() == QMessageBox::Ok || auto_accept)
handler.tokenOkay(id);
else
handler.reject(id);
token_prompt = 0;
}
else
handler.reject(id);
QMessageBox msgBox(QMessageBox::Information,
QApplication::instance()->applicationName() + ": " + tr("Prompt"),
str,
QMessageBox::Ok | QMessageBox::Cancel,
0);
token_prompt = &msgBox;
auto_accept = false;
if (msgBox.exec() == QMessageBox::Ok || auto_accept)
handler.tokenOkay(id);
else
handler.reject(id);
token_prompt = 0;
} else
handler.reject(id);
end:
pending.removeFirst();
prompting = false;
end:
pending.removeFirst();
prompting = false;
if(!pending.isEmpty())
QMetaObject::invokeMethod(this, "nextEvent", Qt::QueuedConnection);
}
if (!pending.isEmpty())
QMetaObject::invokeMethod(this, "nextEvent", Qt::QueuedConnection);
}
void ks_available(const QString &keyStoreId)
{
QCA::KeyStore *ks = new QCA::KeyStore(keyStoreId, &ksm);
connect(ks, SIGNAL(updated()), SLOT(ks_updated()));
connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
keyStores += ks;
ks->startAsynchronousMode();
void ks_available(const QString &keyStoreId)
{
QCA::KeyStore *ks = new QCA::KeyStore(keyStoreId, &ksm);
connect(ks, SIGNAL(updated()), SLOT(ks_updated()));
connect(ks, SIGNAL(unavailable()), SLOT(ks_unavailable()));
keyStores += ks;
ks->startAsynchronousMode();
// are we currently in a token-only prompt?
if(token_prompt && pending.first().event.type() == QCA::Event::Token && pending.first().event.keyStoreEntry().isNull())
{
// was the token we're looking for just inserted?
if(pending.first().event.keyStoreInfo().id() == keyStoreId)
{
// auto-accept
auto_accept = true;
token_prompt->accept();
}
}
}
// are we currently in a token-only prompt?
if (token_prompt && pending.first().event.type() == QCA::Event::Token &&
pending.first().event.keyStoreEntry().isNull()) {
// was the token we're looking for just inserted?
if (pending.first().event.keyStoreInfo().id() == keyStoreId) {
// auto-accept
auto_accept = true;
token_prompt->accept();
}
}
}
void ks_unavailable()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
keyStores.removeAll(ks);
delete ks;
}
void ks_unavailable()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
keyStores.removeAll(ks);
delete ks;
}
void ks_updated()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
void ks_updated()
{
QCA::KeyStore *ks = (QCA::KeyStore *)sender();
// are we currently in a token-entry prompt?
if(token_prompt && pending.first().event.type() == QCA::Event::Token && !pending.first().event.keyStoreEntry().isNull())
{
QCA::KeyStoreEntry kse = pending.first().event.keyStoreEntry();
// are we currently in a token-entry prompt?
if (token_prompt && pending.first().event.type() == QCA::Event::Token &&
!pending.first().event.keyStoreEntry().isNull()) {
QCA::KeyStoreEntry kse = pending.first().event.keyStoreEntry();
// was the token of the entry we're looking for updated?
if(pending.first().event.keyStoreInfo().id() == ks->id())
{
// is the entry available?
bool avail = false;
QList<QCA::KeyStoreEntry> list = ks->entryList();
foreach(const QCA::KeyStoreEntry &e, list)
{
if(e.id() == kse.id())
{
avail = kse.isAvailable();
break;
}
}
if(avail)
{
// auto-accept
auto_accept = true;
token_prompt->accept();
}
}
}
}
// was the token of the entry we're looking for updated?
if (pending.first().event.keyStoreInfo().id() == ks->id()) {
// is the entry available?
bool avail = false;
QList<QCA::KeyStoreEntry> list = ks->entryList();
foreach (const QCA::KeyStoreEntry &e, list) {
if (e.id() == kse.id()) {
avail = kse.isAvailable();
break;
}
}
if (avail) {
// auto-accept
auto_accept = true;
token_prompt->accept();
}
}
}
}
};
Prompter::Prompter(QObject *parent) :
QObject(parent)
Prompter::Prompter(QObject *parent)
: QObject(parent)
{
d = new Private(this);
d = new Private(this);
}
Prompter::~Prompter()
{
delete d;
delete d;
}
QCA::SecureArray Prompter::knownPassword(const QCA::Event &event)
{
Q_UNUSED(event);
return QCA::SecureArray();
Q_UNUSED(event);
return QCA::SecureArray();
}
void Prompter::userSubmitted(const QCA::SecureArray &password, const QCA::Event &event)
{
Q_UNUSED(password);
Q_UNUSED(event);
Q_UNUSED(password);
Q_UNUSED(event);
}
#include "prompter.moc"

View File

@ -24,34 +24,33 @@
#include <QObject>
namespace QCA
{
class SecureArray;
class Event;
namespace QCA {
class SecureArray;
class Event;
}
class Prompter : public QObject
{
Q_OBJECT
Q_OBJECT
public:
Prompter(QObject *parent = 0);
~Prompter();
Prompter(QObject *parent = nullptr);
~Prompter();
protected:
// called with every password event, to check for a known value.
// reimplement it to provide known/cached passwords.
virtual QCA::SecureArray knownPassword(const QCA::Event &event);
// called with every password event, to check for a known value.
// reimplement it to provide known/cached passwords.
virtual QCA::SecureArray knownPassword(const QCA::Event &event);
// called when a user-entered password is submitted. note that this
// does not mean the password was correct. to know if the password
// was correct, you'll have to match up the event information with
// the operation that triggered it.
virtual void userSubmitted(const QCA::SecureArray &password, const QCA::Event &event);
// called when a user-entered password is submitted. note that this
// does not mean the password was correct. to know if the password
// was correct, you'll have to match up the event information with
// the operation that triggered it.
virtual void userSubmitted(const QCA::SecureArray &password, const QCA::Event &event);
private:
class Private;
friend class Private;
Private *d;
class Private;
friend class Private;
Private *d;
};
#endif

View File

@ -1,8 +1,5 @@
set(eventhandlerdemo_bin_SRCS eventhandlerdemo.cpp)
MY_AUTOMOC( eventhandlerdemo_bin_SRCS)
add_executable(eventhandlerdemo ${eventhandlerdemo_bin_SRCS})
target_link_libraries( eventhandlerdemo qca ${QT_QTCORE_LIBRARY})
target_link_qca_libraries(eventhandlerdemo)

View File

@ -26,80 +26,84 @@
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
/**
We need a class on the client side to handle password requests.
*/
class ClientPassphraseHandler: public QObject
class ClientPassphraseHandler : public QObject
{
Q_OBJECT
public:
ClientPassphraseHandler(QObject *parent = 0) : QObject( parent )
ClientPassphraseHandler(QObject *parent = nullptr)
: QObject(parent)
{
// When the PasswordAsker or TokenAsker needs to interact
// with the user, it raises a signal. We connect that to a
// local slot to get the required information.
connect( &m_handler, SIGNAL( eventReady(int, const QCA::Event &) ),
SLOT( my_eventReady(int, const QCA::Event &) ) );
connect(&m_handler, &QCA::EventHandler::eventReady, this, &ClientPassphraseHandler::my_eventReady);
// Now that we are set up, we can start the EventHandler. Nothing
// will happen if you don't call this method.
m_handler.start();
}
private slots:
private Q_SLOTS:
// This slot gets called when the provider needs a token inserted,
// or to get a passphrase / password / PIN.
void my_eventReady(int id, const QCA::Event &event)
{
// We can sanity check the event
if ( event.isNull() ) {
if (event.isNull()) {
return;
}
// Events can be associated with a a keystore or a file/bytearray
// You can tell which by looking at the Source
if ( event.source() == QCA::Event::KeyStore ) {
if (event.source() == QCA::Event::KeyStore) {
std::cout << "Event is associated with a key store operation" << std::endl;
} else if ( event.source() == QCA::Event::Data ) {
} else if (event.source() == QCA::Event::Data) {
std::cout << "Event is associated with a file or some other data" << std::endl;
// if the event comes from a file type operation, you can get the
// name / label using fileName()
std::cout << " Filename: " << qPrintable( event.fileName() ) << std::endl;
std::cout << " Filename: " << qPrintable(event.fileName()) << std::endl;
} else {
std::cout << "Unexpected Source for Event" << std::endl;
}
// There are different kinds of events.
if ( event.type() == QCA::Event::Token ) {
if (event.type() == QCA::Event::Token) {
// You would typically ask the user to insert the token here
std::cout << "Request for token" << std::endl;
// we just fake it for this demo.
m_handler.tokenOkay( id );
m_handler.tokenOkay(id);
// you could use m_handler.reject( id ) to refuse the token request
} else if ( event.type() == QCA::Event::Password ) {
} else if (event.type() == QCA::Event::Password) {
std::cout << "Request for password, passphrase or PIN" << std::endl;
// and within the Password type, we have a few different styles.
if ( event.passwordStyle() == QCA::Event::StylePassword ) {
if (event.passwordStyle() == QCA::Event::StylePassword) {
std::cout << " [Password request]" << std::endl;
} else if ( event.passwordStyle() == QCA::Event::StylePassphrase ) {
} else if (event.passwordStyle() == QCA::Event::StylePassphrase) {
std::cout << " [Passphrase request]" << std::endl;
} else if ( event.passwordStyle() == QCA::Event::StylePIN ){
} else if (event.passwordStyle() == QCA::Event::StylePIN) {
std::cout << " [PIN request]" << std::endl;
} else {
std::cout << " [unexpect request style]" << std::endl;
}
// You would typically request the password/PIN/passphrase.
// again, we just fake it.
m_handler.submitPassword( id, QCA::SecureArray( "hello" ) );
m_handler.submitPassword(id, QCA::SecureArray("hello"));
} else {
std::cout << "Unexpected event type" << std::endl;
}
}
private:
QCA::EventHandler m_handler;
};
void asker_procedure();
@ -108,7 +112,7 @@ class AskerThread : public QThread
{
Q_OBJECT
protected:
virtual void run()
void run() override
{
asker_procedure();
}
@ -126,7 +130,7 @@ int main(int argc, char **argv)
// handler and asker cannot occur in the same thread
AskerThread askerThread;
QObject::connect(&askerThread, SIGNAL(finished()), &exampleApp, SLOT(quit()));
QObject::connect(&askerThread, &AskerThread::finished, &exampleApp, &QCoreApplication::quit);
askerThread.start();
exampleApp.exec();
@ -137,7 +141,7 @@ void asker_procedure()
{
QCA::PasswordAsker pwAsker;
pwAsker.ask( QCA::Event::StylePassword, "foo.tmp", 0 );
pwAsker.ask(QCA::Event::StylePassword, QStringLiteral("foo.tmp"), nullptr);
pwAsker.waitForResponse();
@ -147,11 +151,14 @@ void asker_procedure()
QCA::TokenAsker tokenAsker;
tokenAsker.ask( QCA::KeyStoreInfo( QCA::KeyStore::SmartCard, "Token Id", "Token Name" ), QCA::KeyStoreEntry(), 0 );
tokenAsker.ask(
QCA::KeyStoreInfo(QCA::KeyStore::SmartCard, QStringLiteral("Token Id"), QStringLiteral("Token Name")),
QCA::KeyStoreEntry(),
nullptr);
tokenAsker.waitForResponse();
if ( tokenAsker.accepted() ) {
if (tokenAsker.accepted()) {
std::cout << "Token was accepted" << std::endl;
} else {
std::cout << "Token was not accepted" << std::endl;

View File

@ -1,2 +0,0 @@
SOURCES += eventhandlerdemo.cpp
include(../examples.pri)

View File

@ -169,7 +169,7 @@ The code below shows how to create an SSL client
*/
/* \example tlssocket.cpp
/** \example tlssocket.cpp
The code below shows how to create a socket that can operate
over an Transport Layer Security (TLS, also known as SSL) connection.

View File

@ -1,6 +0,0 @@
include(../app.pri)
# default to console (individual programs can always override this if needed)
CONFIG += console
CONFIG -= app_bundle
QT -= gui

View File

@ -1,24 +0,0 @@
TEMPLATE = subdirs
SUBDIRS += \
aes-cmac \
base64test \
certtest \
ciphertest \
cms \
cmssigner \
eventhandlerdemo \
hashtest \
hextest \
keyloader \
mactest \
md5crypt \
providertest \
publickeyexample \
randomtest \
rsatest \
saslclient \
saslserver \
ssltest \
sslservtest \
tlssocket

View File

@ -2,5 +2,4 @@ set(hashtest_bin_SRCS hashtest.cpp)
add_executable(hashtest ${hashtest_bin_SRCS})
target_link_libraries( hashtest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(hashtest)

View File

@ -24,51 +24,54 @@
#include <QCoreApplication>
#include <stdio.h>
#include <cstdio>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
QCoreApplication app(argc, argv);
QCoreApplication app(argc, argv);
// we use the first argument if provided, or
// use "hello" if no arguments
QCA::SecureArray arg = (argc >= 2) ? argv[1] : "hello";
// we use the first argument if provided, or
// use "hello" if no arguments
QCA::SecureArray arg = (argc >= 2) ? argv[1] : "hello";
// must always check that an algorithm is supported before using it
if( !QCA::isSupported("sha1") )
printf("SHA1 not supported!\n");
else {
// this shows the "all in one" approach
QString result = QCA::Hash("sha1").hashToString(arg);
printf("sha1(\"%s\") = [%s]\n", arg.data(), result.toAscii().data());
}
// must always check that an algorithm is supported before using it
if (!QCA::isSupported("sha1"))
printf("SHA1 not supported!\n");
else {
// this shows the "all in one" approach
QString result = QCA::Hash(QStringLiteral("sha1")).hashToString(arg);
printf("sha1(\"%s\") = [%s]\n", arg.data(), qPrintable(result));
}
// must always check that an algorithm is supported before using it
if( !QCA::isSupported("md5") )
printf("MD5 not supported!\n");
else {
// this shows the incremental approach. Naturally
// for this simple job, we could use the "all in one"
// approach - this is an example, after all :-)
QCA::SecureArray part1(arg.toByteArray().left(3)); // three chars - "hel"
QCA::SecureArray part2(arg.toByteArray().mid(3)); // the rest - "lo"
// must always check that an algorithm is supported before using it
if (!QCA::isSupported("md5"))
printf("MD5 not supported!\n");
else {
// this shows the incremental approach. Naturally
// for this simple job, we could use the "all in one"
// approach - this is an example, after all :-)
QCA::SecureArray part1(arg.toByteArray().left(3)); // three chars - "hel"
QCA::SecureArray part2(arg.toByteArray().mid(3)); // the rest - "lo"
// create the required object.
QCA::Hash hashObject("md5");
// we split it into two parts to show incremental update
hashObject.update(part1);
hashObject.update(part2);
// no more updates after calling final.
QCA::SecureArray resultArray = hashObject.final();
// convert the result into printable hexadecimal.
QString result = QCA::arrayToHex(resultArray.toByteArray());
printf("md5(\"%s\") = [%s]\n", arg.data(), result.toAscii().data());
}
// create the required object.
QCA::Hash hashObject(QStringLiteral("md5"));
// we split it into two parts to show incremental update
hashObject.update(part1);
hashObject.update(part2);
// no more updates after calling final.
QCA::SecureArray resultArray = hashObject.final();
// convert the result into printable hexadecimal.
QString result = QCA::arrayToHex(resultArray.toByteArray());
printf("md5(\"%s\") = [%s]\n", arg.data(), qPrintable(result));
}
return 0;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += hashtest.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(hextest_bin_SRCS hextest.cpp)
add_executable(hextest ${hextest_bin_SRCS})
target_link_libraries( hextest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(hextest)

View File

@ -26,41 +26,44 @@
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
QCoreApplication app(argc, argv);
QCoreApplication app(argc, argv);
// we use the first argument as the data to encode / decode
// if an argument is provided. Use "hello" if no argument
QByteArray arg; // empty array
arg.append((argc >= 2) ? argv[1] : "hello");
// we use the first argument as the data to encode / decode
// if an argument is provided. Use "hello" if no argument
QByteArray arg; // empty array
arg.append((argc >= 2) ? argv[1] : "hello");
// create our object, which does encoding by default
// QCA::Hex encoder(QCA::Encode); is equivalent
QCA::Hex encoder;
// create our object, which does encoding by default
// QCA::Hex encoder(QCA::Encode); is equivalent
QCA::Hex encoder;
// You might prefer to use encoder.encode(); and have
// it return a QCA::SecureArray, depending on your needs
QString encoded = encoder.arrayToString(arg);
// You might prefer to use encoder.encode(); and have
// it return a QCA::SecureArray, depending on your needs
QString encoded = encoder.arrayToString(arg);
std::cout << arg.data() << " in hex encoding is ";
std::cout << encoded.toLatin1().data() << std::endl;
std::cout << arg.data() << " in hex encoding is ";
std::cout << encoded.toLatin1().data() << std::endl;
// This time, we'll create an object to decode hexadecimal.
// We could also have reused the existing object, calling
// clear(); and setup(QCA::Decode); on it.
QCA::Hex decoder(QCA::Decode);
// This time, we'll create an object to decode hexadecimal.
// We could also have reused the existing object, calling
// clear(); and setup(QCA::Decode); on it.
QCA::Hex decoder(QCA::Decode);
// This time, we convert a QString into a QString
QString decoded = decoder.decodeString(encoded);
// This time, we convert a QString into a QString
QString decoded = decoder.decodeString(encoded);
std::cout << encoded.toLatin1().data() << " decoded from hex is ";
std::cout << decoded.toLatin1().data() << std::endl;
std::cout << encoded.toLatin1().data() << " decoded from hex is ";
std::cout << decoded.toLatin1().data() << std::endl;
return 0;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += hextest.cpp
include(../examples.pri)

View File

@ -1,8 +1,5 @@
set(keyloader_bin_SRCS keyloader.cpp)
MY_AUTOMOC( keyloader_bin_SRCS )
add_executable(keyloader ${keyloader_bin_SRCS})
target_link_libraries( keyloader qca ${QT_QTCORE_LIBRARY})
target_link_qca_libraries(keyloader)

View File

@ -23,94 +23,94 @@
#include <QtCrypto>
#include <QCoreApplication>
#include <QFile>
#include <QTimer>
#include <stdio.h>
#include <cstdio>
class PassphraseHandler: public QObject
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
class PassphraseHandler : public QObject
{
Q_OBJECT
Q_OBJECT
public:
QCA::EventHandler handler;
QCA::EventHandler handler;
PassphraseHandler(QObject *parent = 0) : QObject(parent)
{
connect(&handler, SIGNAL(eventReady(int, const QCA::Event &)),
SLOT(eh_eventReady(int, const QCA::Event &)));
handler.start();
}
PassphraseHandler(QObject *parent = nullptr)
: QObject(parent)
{
connect(&handler, &QCA::EventHandler::eventReady, this, &PassphraseHandler::eh_eventReady);
handler.start();
}
private slots:
void eh_eventReady(int id, const QCA::Event &event)
{
if(event.type() == QCA::Event::Password)
{
QCA::SecureArray pass;
QCA::ConsolePrompt prompt;
prompt.getHidden("Passphrase");
prompt.waitForFinished();
pass = prompt.result();
handler.submitPassword(id, pass);
}
else
handler.reject(id);
}
private Q_SLOTS:
void eh_eventReady(int id, const QCA::Event &event)
{
if (event.type() == QCA::Event::Password) {
QCA::SecureArray pass;
QCA::ConsolePrompt prompt;
prompt.getHidden(QStringLiteral("Passphrase"));
prompt.waitForFinished();
pass = prompt.result();
handler.submitPassword(id, pass);
} else
handler.reject(id);
}
};
class App : public QObject
{
Q_OBJECT
Q_OBJECT
public:
QCA::KeyLoader keyLoader;
QString str;
QCA::KeyLoader keyLoader;
QString str;
App()
{
connect(&keyLoader, SIGNAL(finished()), SLOT(kl_finished()));
}
App()
{
connect(&keyLoader, &QCA::KeyLoader::finished, this, &App::kl_finished);
}
public slots:
void start()
{
keyLoader.loadPrivateKeyFromPEMFile(str);
}
public Q_SLOTS:
void start()
{
keyLoader.loadPrivateKeyFromPEMFile(str);
}
signals:
void quit();
Q_SIGNALS:
void quit();
private slots:
void kl_finished()
{
if(keyLoader.convertResult() == QCA::ConvertGood)
{
QCA::PrivateKey key = keyLoader.privateKey();
printf("Loaded successfully. Bits: %d\n", key.bitSize());
}
else
printf("Unable to load.\n");
private Q_SLOTS:
void kl_finished()
{
if (keyLoader.convertResult() == QCA::ConvertGood) {
QCA::PrivateKey key = keyLoader.privateKey();
printf("Loaded successfully. Bits: %d\n", key.bitSize());
} else
printf("Unable to load.\n");
emit quit();
}
emit quit();
}
};
int main(int argc, char **argv)
{
QCA::Initializer init;
QCoreApplication qapp(argc, argv);
QCA::Initializer init;
QCoreApplication qapp(argc, argv);
if(argc < 2)
{
printf("usage: keyloader [privatekey.pem]\n");
return 0;
}
if (argc < 2) {
printf("usage: keyloader [privatekey.pem]\n");
return 0;
}
PassphraseHandler passphraseHandler;
App app;
app.str = argv[1];
QObject::connect(&app, SIGNAL(quit()), &qapp, SLOT(quit()));
QTimer::singleShot(0, &app, SLOT(start()));
qapp.exec();
return 0;
PassphraseHandler passphraseHandler;
App app;
app.str = QFile::decodeName(argv[1]);
QObject::connect(&app, &App::quit, &qapp, QCoreApplication::quit);
QTimer::singleShot(0, &app, &App::start);
qapp.exec();
return 0;
}
#include "keyloader.moc"

View File

@ -1,2 +0,0 @@
SOURCES += keyloader.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(mactest_bin_SRCS mactest.cpp)
add_executable(mactest ${mactest_bin_SRCS})
target_link_libraries( mactest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(mactest)

View File

@ -26,57 +26,60 @@
#include <QDebug>
// needed for printf
#include<stdio.h>
#include <cstdio>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
QCoreApplication app(argc, argv);
QCoreApplication app(argc, argv);
qDebug() << "This example shows hashed MAC";
qDebug() << "This example shows hashed MAC";
// we use the first argument as the data to authenticate
// if an argument is provided. Use "hello" if no argument
QByteArray arg = (argc >= 2) ? argv[1] : "hello";
// we use the first argument as the data to authenticate
// if an argument is provided. Use "hello" if no argument
QByteArray arg = (argc >= 2) ? argv[1] : "hello";
// we use the second argument as the key to authenticate
// with, if two arguments are provided. Use "secret" as
// the key if less than two arguments.
QCA::SecureArray key((argc >= 3) ? argv[2] : "secret");
// we use the second argument as the key to authenticate
// with, if two arguments are provided. Use "secret" as
// the key if less than two arguments.
QCA::SecureArray key((argc >= 3) ? argv[2] : "secret");
// must always check that an algorithm is supported before using it
if( !QCA::isSupported("hmac(sha1)") ) {
printf("HMAC(SHA1) not supported!\n");
} else {
// create the required object using HMAC with SHA-1, and an
// empty key.
QCA::MessageAuthenticationCode hmacObject( "hmac(sha1)", QCA::SecureArray() );
// must always check that an algorithm is supported before using it
if (!QCA::isSupported("hmac(sha1)")) {
printf("HMAC(SHA1) not supported!\n");
} else {
// create the required object using HMAC with SHA-1, and an
// empty key.
QCA::MessageAuthenticationCode hmacObject(QStringLiteral("hmac(sha1)"), QCA::SecureArray());
// create the key
QCA::SymmetricKey keyObject(key);
// create the key
QCA::SymmetricKey keyObject(key);
// set the HMAC object to use the key
hmacObject.setup(key);
// that could also have been done in the
// QCA::MessageAuthenticationCode constructor
// set the HMAC object to use the key
hmacObject.setup(key);
// that could also have been done in the
// QCA::MessageAuthenticationCode constructor
// we split it into two parts to show incremental update
QCA::SecureArray part1(arg.left(3)); // three chars - "hel"
QCA::SecureArray part2(arg.mid(3)); // the rest - "lo"
hmacObject.update(part1);
hmacObject.update(part2);
// we split it into two parts to show incremental update
QCA::SecureArray part1(arg.left(3)); // three chars - "hel"
QCA::SecureArray part2(arg.mid(3)); // the rest - "lo"
hmacObject.update(part1);
hmacObject.update(part2);
// no more updates after calling final.
QCA::SecureArray resultArray = hmacObject.final();
// no more updates after calling final.
QCA::SecureArray resultArray = hmacObject.final();
// convert the result into printable hexadecimal.
QString result = QCA::arrayToHex(resultArray.toByteArray());
printf("HMAC(SHA1) of \"%s\" with \"%s\" = [%s]\n", arg.data(), key.data(), result.toLatin1().data());
}
// convert the result into printable hexadecimal.
QString result = QCA::arrayToHex(resultArray.toByteArray());
printf("HMAC(SHA1) of \"%s\" with \"%s\" = [%s]\n", arg.data(), key.data(), result.toLatin1().data());
}
return 0;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += mactest.cpp
include(../examples.pri)

View File

@ -2,6 +2,6 @@ set(md5crypt_bin_SRCS md5crypt.cpp)
add_executable(md5crypt ${md5crypt_bin_SRCS})
#add "crypt" to the libs if you are trying the crypt() equivalent
target_link_libraries( md5crypt qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(md5crypt)
#add "crypt" to the libs if you are trying the crypt() equivalent

View File

@ -25,114 +25,97 @@
(http://www-128.ibm.com/developerworks/linux/library/l-md5crypt/)
*/
#include <QtCrypto>
#include <QCoreApplication>
#include <QtCrypto>
#include <QtDebug>
#include <stdio.h>
#include <cstdio>
QString to64 ( long v , int size )
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
QString to64(long v, int size)
{
// Character set of the encrypted password: A-Za-z0-9./
QString itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
QString itoa64 = QStringLiteral("./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
QString result;
while ( --size >= 0 )
{
result.append ( itoa64.at ( ( int )( v & 0x3f ) ) );
while (--size >= 0) {
result.append(itoa64.at((int)(v & 0x3f)));
v = v >> 6;
}
return result;
}
int byte2unsigned ( int byteValue )
int byte2unsigned(int byteValue)
{
int integerToReturn;
integerToReturn = (int) byteValue & 0xff;
integerToReturn = (int)byteValue & 0xff;
return integerToReturn;
}
QString qca_md5crypt( const QCA::SecureArray &password, const QCA::SecureArray &salt )
QString qca_md5crypt(const QCA::SecureArray &password, const QCA::SecureArray &salt)
{
QCA::SecureArray finalState, magic_string = "$1$";
// The md5crypt algorithm uses two separate hashes
QCA::Hash hash1( "md5" );
QCA::Hash hash2( "md5" );
QCA::Hash hash1(QStringLiteral("md5"));
QCA::Hash hash2(QStringLiteral("md5"));
// MD5 Hash #1: pwd, magic string and salt
hash1.update ( password );
hash1.update ( magic_string );
hash1.update ( salt );
hash1.update(password);
hash1.update(magic_string);
hash1.update(salt);
// MD5 Hash #2: password, salt, password
hash2.update ( password );
hash2.update ( salt );
hash2.update ( password );
hash2.update(password);
hash2.update(salt);
hash2.update(password);
finalState = hash2.final();
// Two sets of transformations based on the length of the password
for ( int i = password.size() ; i > 0 ; i -= 16 )
{
for (int i = password.size(); i > 0; i -= 16) {
// Update hash1 from offset value (i > 16 ? 16 : i)
hash1.update( finalState.toByteArray().left(i > 16 ? 16 : i));
hash1.update(finalState.toByteArray().left(i > 16 ? 16 : i));
}
// Clear array bits
finalState.fill( 0 );
finalState.fill(0);
for ( int i = password.size() ; i != 0 ; i = i >> 1 )
{
if ( ( i & 1 ) != 0 )
{
hash1.update( finalState.toByteArray().left ( 1 ) );
}
else
{
hash1.update( password.toByteArray().left ( 1 ) );
for (int i = password.size(); i != 0; i = i >> 1) {
if ((i & 1) != 0) {
hash1.update(finalState.toByteArray().left(1));
} else {
hash1.update(password.toByteArray().left(1));
}
}
finalState = hash1.final();
// Now build a 1000 entry dictionary...
for ( int i = 0 ; i < 1000 ; i++ )
{
for (int i = 0; i < 1000; i++) {
hash2.clear();
if ((i & 1) != 0)
{
hash2.update ( password );
}
else
{
hash2.update ( finalState.toByteArray().left( 16 ));
if ((i & 1) != 0) {
hash2.update(password);
} else {
hash2.update(finalState.toByteArray().left(16));
}
if ((i % 3) != 0)
{
hash2.update ( salt );
if ((i % 3) != 0) {
hash2.update(salt);
}
if ((i % 7) != 0)
{
hash2.update ( password );
if ((i % 7) != 0) {
hash2.update(password);
}
if ((i & 1) != 0)
{
hash2.update ( finalState.toByteArray().left( 16 ) );
}
else
{
hash2.update ( password );
if ((i & 1) != 0) {
hash2.update(finalState.toByteArray().left(16));
} else {
hash2.update(password);
}
finalState = hash2.final();
@ -142,80 +125,69 @@ QString qca_md5crypt( const QCA::SecureArray &password, const QCA::SecureArray &
// Salt is part of the encoded password ($1$<string>$)
QString encodedString;
encodedString.append ( magic_string.toByteArray() );
encodedString.append ( salt.toByteArray() );
encodedString.append ( "$" );
encodedString.append(QString::fromLatin1(magic_string.toByteArray()));
encodedString.append(QString::fromLatin1(salt.toByteArray()));
encodedString.append(QStringLiteral("$"));
long l;
l = ( byte2unsigned (finalState.toByteArray().at(0) ) << 16 |
( byte2unsigned (finalState.toByteArray().at(6)) ) << 8 |
byte2unsigned (finalState.toByteArray().at(12)) );
encodedString.append ( to64 (l, 4) );
l = (byte2unsigned(finalState.toByteArray().at(0)) << 16 | (byte2unsigned(finalState.toByteArray().at(6))) << 8 |
byte2unsigned(finalState.toByteArray().at(12)));
encodedString.append(to64(l, 4));
l = ( byte2unsigned (finalState.toByteArray().at(1)) << 16 |
( byte2unsigned (finalState.toByteArray().at(7))) << 8 |
byte2unsigned (finalState.toByteArray().at(13)) );
encodedString.append ( to64 (l, 4) );
l = (byte2unsigned(finalState.toByteArray().at(1)) << 16 | (byte2unsigned(finalState.toByteArray().at(7))) << 8 |
byte2unsigned(finalState.toByteArray().at(13)));
encodedString.append(to64(l, 4));
l = ( byte2unsigned (finalState.toByteArray().at(2)) << 16 |
( byte2unsigned (finalState.toByteArray().at(8))) << 8 |
byte2unsigned (finalState.toByteArray().at(14)) );
encodedString.append ( to64 (l, 4) );
l = (byte2unsigned(finalState.toByteArray().at(2)) << 16 | (byte2unsigned(finalState.toByteArray().at(8))) << 8 |
byte2unsigned(finalState.toByteArray().at(14)));
encodedString.append(to64(l, 4));
l = ( byte2unsigned (finalState.toByteArray().at(3)) << 16 |
( byte2unsigned (finalState.toByteArray().at(9))) << 8 |
byte2unsigned (finalState.toByteArray().at(15)) );
encodedString.append ( to64 (l, 4) );
l = (byte2unsigned(finalState.toByteArray().at(3)) << 16 | (byte2unsigned(finalState.toByteArray().at(9))) << 8 |
byte2unsigned(finalState.toByteArray().at(15)));
encodedString.append(to64(l, 4));
l = ( byte2unsigned (finalState.toByteArray().at(4)) << 16 |
( byte2unsigned (finalState.toByteArray().at(10))) << 8 |
byte2unsigned (finalState.toByteArray().at(5)) );
encodedString.append ( to64 (l, 4) );
l = (byte2unsigned(finalState.toByteArray().at(4)) << 16 | (byte2unsigned(finalState.toByteArray().at(10))) << 8 |
byte2unsigned(finalState.toByteArray().at(5)));
encodedString.append(to64(l, 4));
l = byte2unsigned (finalState.toByteArray().at(11));
encodedString.append ( to64 (l, 2) );
l = byte2unsigned(finalState.toByteArray().at(11));
encodedString.append(to64(l, 2));
return encodedString;
}
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
QCoreApplication app ( argc, argv );
QCoreApplication app(argc, argv);
QCA::SecureArray password, salt;
if ( argc < 3 )
{
printf ( "Usage: %s password salt (salt without $1$)\n" , argv[0] );
if (argc < 3) {
printf("Usage: %s password salt (salt without $1$)\n", argv[0]);
return 1;
}
password.append( argv[1] );
password.append(argv[1]);
salt.append( argv[2] );
salt.append(argv[2]);
// must always check that an algorithm is supported before using it
if( !QCA::isSupported( "md5" ) )
printf ("MD5 hash not supported!\n");
else
{
QString result = qca_md5crypt( password, salt );
if (!QCA::isSupported("md5"))
printf("MD5 hash not supported!\n");
else {
QString result = qca_md5crypt(password, salt);
printf ("md5crypt [ %s , %s ] = '%s'\n" , password.data(), salt.data() , qPrintable(result) );
printf("md5crypt [ %s , %s ] = '%s'\n", password.data(), salt.data(), qPrintable(result));
// this is equivalent if you have GNU libc 2.0
// printf( "GNU md5crypt [ %s , %s ] = '%s'\n", password.data(), salt.data(), crypt( password.data(), ( "$1$"+salt ).data() ) );
// printf( "GNU md5crypt [ %s , %s ] = '%s'\n", password.data(), salt.data(), crypt( password.data(), (
// "$1$"+salt ).data() ) );
}
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += md5crypt.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(providertest_bin_SRCS providertest.cpp)
add_executable(providertest ${providertest_bin_SRCS})
target_link_libraries( providertest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(providertest)

View File

@ -20,12 +20,16 @@
*/
// QtCrypto has the declarations for all of QCA
#include <QtCrypto>
#include <QCoreApplication>
#include <QtCrypto>
#include <iostream>
#include <qstringlist.h>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
@ -40,15 +44,15 @@ int main(int argc, char **argv)
QCA::scanForPlugins();
// this gives us all the plugin providers as a list
QCA::ProviderList qcaProviders = QCA::providers();
for (int i = 0; i < qcaProviders.size(); ++i) {
// each provider has a name, which we can display
std::cout << qcaProviders[i]->name().toLatin1().data() << ": ";
// ... and also a list of features
QStringList capabilities = qcaProviders[i]->features();
// we turn the string list back into a single string,
// and display it as well
std::cout << capabilities.join(", ").toLatin1().data() << std::endl;
const QCA::ProviderList qcaProviders = QCA::providers();
for (const QCA::Provider *provider : qcaProviders) {
// each provider has a name, which we can display
std::cout << provider->name().toLatin1().data() << ": ";
// ... and also a list of features
QStringList capabilities = provider->features();
// we turn the string list back into a single string,
// and display it as well
std::cout << capabilities.join(QStringLiteral(", ")).toLatin1().data() << std::endl;
}
// Note that the default provider isn't included in
@ -57,7 +61,6 @@ int main(int argc, char **argv)
// However it is still possible to get the features
// supported by the default provider
QStringList capabilities = QCA::defaultFeatures();
std::cout << capabilities.join(", ").toLatin1().data() << std::endl;
std::cout << capabilities.join(QStringLiteral(", ")).toLatin1().data() << std::endl;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += providertest.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(publickeyexample_bin_SRCS publickeyexample.cpp)
add_executable(publickeyexample ${publickeyexample_bin_SRCS})
target_link_libraries( publickeyexample qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(publickeyexample)

View File

@ -20,15 +20,17 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QtCrypto>
#include <QCoreApplication>
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char** argv)
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
@ -37,37 +39,37 @@ int main(int argc, char** argv)
QCoreApplication app(argc, argv);
// We need to ensure that we have certificate handling support
if ( !QCA::isSupported( "cert" ) ) {
std::cout << "Sorry, no PKI certificate support" << std::endl;
return 1;
if (!QCA::isSupported("cert")) {
std::cout << "Sorry, no PKI certificate support" << std::endl;
return 1;
}
// Read in a private key
QCA::PrivateKey privKey;
QCA::PrivateKey privKey;
QCA::ConvertResult convRes;
QCA::SecureArray passPhrase = "start";
privKey = QCA::PrivateKey::fromPEMFile( "Userkey.pem", passPhrase, &convRes );
if ( convRes != QCA::ConvertGood ) {
std::cout << "Sorry, could not import Private Key" << std::endl;
return 1;
QCA::SecureArray passPhrase = "start";
privKey = QCA::PrivateKey::fromPEMFile(QStringLiteral("Userkey.pem"), passPhrase, &convRes);
if (convRes != QCA::ConvertGood) {
std::cout << "Sorry, could not import Private Key" << std::endl;
return 1;
}
// Read in a matching public key cert
// you could also build this using the fromPEMFile() method
QCA::Certificate pubCert( "User.pem" );
if ( pubCert.isNull() ) {
std::cout << "Sorry, could not import public key certificate" << std::endl;
return 1;
QCA::Certificate pubCert(QStringLiteral("User.pem"));
if (pubCert.isNull()) {
std::cout << "Sorry, could not import public key certificate" << std::endl;
return 1;
}
// We are building the certificate into a SecureMessageKey object, via a
// CertificateChain
QCA::SecureMessageKey secMsgKey;
QCA::CertificateChain chain;
chain += pubCert;
secMsgKey.setX509CertificateChain( chain );
secMsgKey.setX509CertificateChain(chain);
// build up a SecureMessage object, based on our public key certificate
QCA::CMS cms;
QCA::CMS cms;
QCA::SecureMessage msg(&cms);
msg.setRecipient(secMsgKey);
@ -82,33 +84,31 @@ int main(int argc, char** argv)
msg.waitForFinished(1000);
// check to see if it worked
if(!msg.success())
{
std::cout << "Error encrypting: " << msg.errorCode() << std::endl;
return 1;
if (!msg.success()) {
std::cout << "Error encrypting: " << msg.errorCode() << std::endl;
return 1;
}
// get the result
QCA::SecureArray cipherText = msg.read();
QCA::Base64 enc;
QCA::Base64 enc;
std::cout << plainText.data() << " encrypts to (in base 64): ";
std::cout << qPrintable( enc.arrayToString( cipherText ) ) << std::endl;
std::cout << qPrintable(enc.arrayToString(cipherText)) << std::endl;
// Show we can decrypt it with the private key
if ( !privKey.canDecrypt() ) {
std::cout << "Private key cannot be used to decrypt" << std::endl;
return 1;
if (!privKey.canDecrypt()) {
std::cout << "Private key cannot be used to decrypt" << std::endl;
return 1;
}
QCA::SecureArray plainTextResult;
if ( 0 == privKey.decrypt(cipherText, &plainTextResult, QCA::EME_PKCS1_OAEP ) ) {
std::cout << "Decryption process failed" << std::endl;
return 1;
if (0 == privKey.decrypt(cipherText, &plainTextResult, QCA::EME_PKCS1_OAEP)) {
std::cout << "Decryption process failed" << std::endl;
return 1;
}
std::cout << qPrintable( enc.arrayToString( cipherText ) );
std::cout << qPrintable(enc.arrayToString(cipherText));
std::cout << " (in base 64) decrypts to: ";
std::cout << plainTextResult.data() << std::endl;
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += publickeyexample.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(randomtest_bin_SRCS randomtest.cpp)
add_executable(randomtest ${randomtest_bin_SRCS})
target_link_libraries( randomtest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(randomtest)

View File

@ -27,43 +27,46 @@
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
// the Initializer object sets things up, and
// also does cleanup when it goes out of scope
QCA::Initializer init;
QCoreApplication app(argc, argv);
QCoreApplication app(argc, argv);
qDebug() << "This example generates random numbers";
qDebug() << "This example generates random numbers";
int randInt;
// This is the standard way to generate a random integer.
randInt = QCA::Random::randomInt();
qDebug() << "A random number: " << randInt;
int randInt;
// This is the standard way to generate a random integer.
randInt = QCA::Random::randomInt();
qDebug() << "A random number: " << randInt;
// If you wanted a random character (octet), you could
// use something like:
unsigned char randChar;
randChar = QCA::Random::randomChar();
// It might not be printable, so this may not produce output
std::cout << "A random character: " << randChar << std::endl;
// If you wanted a random character (octet), you could
// use something like:
unsigned char randChar;
randChar = QCA::Random::randomChar();
// It might not be printable, so this may not produce output
std::cout << "A random character: " << randChar << std::endl;
QCA::SecureArray tenBytes(10);
// If you need more random values, you may want to
// get an array, as shown below.
tenBytes = QCA::Random::randomArray(10);
QCA::SecureArray tenBytes(10);
// If you need more random values, you may want to
// get an array, as shown below.
tenBytes = QCA::Random::randomArray(10);
// To make this viewable, we convert to hexadecimal.
std::cout << "A random 10 byte array (in hex): ";
std::cout << QCA::Hex().arrayToString(tenBytes).toAscii().data() << std::endl;
// To make this viewable, we convert to hexadecimal.
std::cout << "A random 10 byte array (in hex): ";
std::cout << qPrintable(QCA::Hex().arrayToString(tenBytes)) << std::endl;
// Under some circumstances, you may want to create a
// Random object, rather than a static public member function.
// This isn't normally the easiest way, but it does work
QCA::Random myRandomObject;
randChar = myRandomObject.nextByte();
tenBytes = myRandomObject.nextBytes(10);
return 0;
// Under some circumstances, you may want to create a
// Random object, rather than a static public member function.
// This isn't normally the easiest way, but it does work
QCA::Random myRandomObject;
randChar = myRandomObject.nextByte();
tenBytes = myRandomObject.nextBytes(10);
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += randomtest.cpp
include(../examples.pri)

View File

@ -2,5 +2,4 @@ set(rsatest_bin_SRCS rsatest.cpp)
add_executable(rsatest ${rsatest_bin_SRCS})
target_link_libraries( rsatest qca ${QT_QTGUI_LIBRARY})
target_link_qca_libraries(rsatest)

View File

@ -20,11 +20,15 @@
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <QtCrypto>
#include <QCoreApplication>
#include <QtCrypto>
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
// The Initializer object sets things up, and also
@ -39,115 +43,109 @@ int main(int argc, char **argv)
// We demonstrate PEM usage here, so we need to test for
// supportedIOTypes, not just supportedTypes
if(!QCA::isSupported("pkey") ||
!QCA::PKey::supportedIOTypes().contains(QCA::PKey::RSA))
std::cout << "RSA not supported!\n";
if (!QCA::isSupported("pkey") || !QCA::PKey::supportedIOTypes().contains(QCA::PKey::RSA))
std::cout << "RSA not supported!\n";
else {
// When creating a public / private key pair, you make the
// private key, and then extract the public key component from it
// Using RSA is very common, however DSA can provide equivalent
// signature/verification. This example applies to DSA to the
// extent that the operations work on that key type.
// When creating a public / private key pair, you make the
// private key, and then extract the public key component from it
// Using RSA is very common, however DSA can provide equivalent
// signature/verification. This example applies to DSA to the
// extent that the operations work on that key type.
// QCA provides KeyGenerator as a convenient source of new keys,
// however you could also import an existing key instead.
QCA::PrivateKey seckey = QCA::KeyGenerator().createRSA(1024);
if(seckey.isNull()) {
std::cout << "Failed to make private RSA key" << std::endl;
return 1;
}
// QCA provides KeyGenerator as a convenient source of new keys,
// however you could also import an existing key instead.
QCA::PrivateKey seckey = QCA::KeyGenerator().createRSA(1024);
if (seckey.isNull()) {
std::cout << "Failed to make private RSA key" << std::endl;
return 1;
}
QCA::PublicKey pubkey = seckey.toPublicKey();
QCA::PublicKey pubkey = seckey.toPublicKey();
// check if the key can encrypt
if(!pubkey.canEncrypt()) {
std::cout << "Error: this kind of key cannot encrypt" << std::endl;
return 1;
}
// check if the key can encrypt
if (!pubkey.canEncrypt()) {
std::cout << "Error: this kind of key cannot encrypt" << std::endl;
return 1;
}
// encrypt some data - note that only the public key is required
// you must also choose the algorithm to be used
QCA::SecureArray result = pubkey.encrypt(arg, QCA::EME_PKCS1_OAEP);
if(result.isEmpty()) {
std::cout << "Error encrypting" << std::endl;
return 1;
}
// encrypt some data - note that only the public key is required
// you must also choose the algorithm to be used
QCA::SecureArray result = pubkey.encrypt(arg, QCA::EME_PKCS1_OAEP);
if (result.isEmpty()) {
std::cout << "Error encrypting" << std::endl;
return 1;
}
// output the encrypted data
QString rstr = QCA::arrayToHex(result.toByteArray());
std::cout << "\"" << arg.data() << "\" encrypted with RSA is \"";
std::cout << qPrintable(rstr) << "\"" << std::endl;
// output the encrypted data
QString rstr = QCA::arrayToHex(result.toByteArray());
std::cout << "\"" << arg.data() << "\" encrypted with RSA is \"";
std::cout << qPrintable(rstr) << "\"" << std::endl;
// save the private key - in a real example, make sure this goes
// somewhere secure and has a good pass phrase
// You can use the same technique with the public key too.
QCA::SecureArray passPhrase = "pass phrase";
seckey.toPEMFile("keyprivate.pem", passPhrase);
// save the private key - in a real example, make sure this goes
// somewhere secure and has a good pass phrase
// You can use the same technique with the public key too.
QCA::SecureArray passPhrase = "pass phrase";
seckey.toPEMFile(QStringLiteral("keyprivate.pem"), passPhrase);
// Read that key back in, checking if the read succeeded
QCA::ConvertResult conversionResult;
QCA::PrivateKey privateKey = QCA::PrivateKey::fromPEMFile( "keyprivate.pem",
passPhrase,
&conversionResult);
if (! (QCA::ConvertGood == conversionResult) ) {
std::cout << "Private key read failed" << std::endl;
}
// Read that key back in, checking if the read succeeded
QCA::ConvertResult conversionResult;
QCA::PrivateKey privateKey =
QCA::PrivateKey::fromPEMFile(QStringLiteral("keyprivate.pem"), passPhrase, &conversionResult);
if (!(QCA::ConvertGood == conversionResult)) {
std::cout << "Private key read failed" << std::endl;
}
// now decrypt that encrypted data using the private key that
// we read in. The algorithm is the same.
QCA::SecureArray decrypt;
if(0 == privateKey.decrypt(result, &decrypt, QCA::EME_PKCS1_OAEP)) {
std::cout << "Error decrypting.\n";
return 1;
}
// now decrypt that encrypted data using the private key that
// we read in. The algorithm is the same.
QCA::SecureArray decrypt;
if (0 == privateKey.decrypt(result, &decrypt, QCA::EME_PKCS1_OAEP)) {
std::cout << "Error decrypting.\n";
return 1;
}
// output the resulting decrypted string
std::cout << "\"" << qPrintable(rstr) << "\" decrypted with RSA is \"";
std::cout << decrypt.data() << "\"" << std::endl;
// output the resulting decrypted string
std::cout << "\"" << qPrintable(rstr) << "\" decrypted with RSA is \"";
std::cout << decrypt.data() << "\"" << std::endl;
// Some private keys can also be used for producing signatures
if (!privateKey.canSign()) {
std::cout << "Error: this kind of key cannot sign" << std::endl;
return 1;
}
privateKey.startSign(QCA::EMSA3_MD5);
privateKey.update(arg); // just reuse the same message
QByteArray argSig = privateKey.signature();
// Some private keys can also be used for producing signatures
if(!privateKey.canSign()) {
std::cout << "Error: this kind of key cannot sign" << std::endl;
return 1;
}
privateKey.startSign( QCA::EMSA3_MD5 );
privateKey.update( arg ); // just reuse the same message
QByteArray argSig = privateKey.signature();
// instead of using the startSign(), update(), signature() calls,
// you may be better doing the whole thing in one go, using the
// signMessage call. Of course you need the whole message in one
// hit, which may or may not be a problem
// instead of using the startSign(), update(), signature() calls,
// you may be better doing the whole thing in one go, using the
// signMessage call. Of course you need the whole message in one
// hit, which may or may not be a problem
// output the resulting signature
rstr = QCA::arrayToHex(argSig);
std::cout << "Signature for \"" << arg.data() << "\" using RSA, is ";
std::cout << "\"" << qPrintable(rstr) << "\"" << std::endl;
// output the resulting signature
rstr = QCA::arrayToHex(argSig);
std::cout << "Signature for \"" << arg.data() << "\" using RSA, is ";
std::cout << "\"" << qPrintable( rstr ) << "\"" << std::endl;
// to check a signature, we must check that the key is
// appropriate
if(pubkey.canVerify()) {
pubkey.startVerify( QCA::EMSA3_MD5 );
pubkey.update( arg );
if ( pubkey.validSignature( argSig ) ) {
std::cout << "Signature is valid" << std::endl;
} else {
std::cout << "Bad signature" << std::endl;
}
}
// We can also do the verification in a single step if we
// have all the message
if ( pubkey.canVerify() &&
pubkey.verifyMessage( arg, argSig, QCA::EMSA3_MD5 ) ) {
std::cout << "Signature is valid" << std::endl;
} else {
std::cout << "Signature could not be verified" << std::endl;
}
// to check a signature, we must check that the key is
// appropriate
if (pubkey.canVerify()) {
pubkey.startVerify(QCA::EMSA3_MD5);
pubkey.update(arg);
if (pubkey.validSignature(argSig)) {
std::cout << "Signature is valid" << std::endl;
} else {
std::cout << "Bad signature" << std::endl;
}
}
// We can also do the verification in a single step if we
// have all the message
if (pubkey.canVerify() && pubkey.verifyMessage(arg, argSig, QCA::EMSA3_MD5)) {
std::cout << "Signature is valid" << std::endl;
} else {
std::cout << "Signature could not be verified" << std::endl;
}
}
return 0;
}

View File

@ -1,2 +0,0 @@
SOURCES += rsatest.cpp
include(../examples.pri)

View File

@ -1,7 +1,10 @@
set(saslclient_bin_SRCS saslclient.cpp)
MY_AUTOMOC( saslclient_bin_SRCS)
add_executable(saslclient ${saslclient_bin_SRCS})
target_link_libraries( saslclient qca ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})
target_link_qca_libraries(saslclient)
if(QT6)
target_link_libraries(saslclient Qt6::Network)
else()
target_link_libraries(saslclient Qt5::Network)
endif()

Some files were not shown because too many files have changed in this diff Show More