Compare commits
464 Commits
Author | SHA1 | Date | |
---|---|---|---|
45f2312979 | |||
a602142dcb | |||
5b49c00168 | |||
|
e9fd31b4a1 | ||
|
7ead054437 | ||
|
b2e54520a3 | ||
|
5cc26f77f0 | ||
|
2c3992f075 | ||
|
0c3db8a062 | ||
|
974f8ec8d0 | ||
|
040d7d6348 | ||
|
d8f1e6cb9c | ||
|
9443ba76ba | ||
|
effbe387a0 | ||
|
e6a15466ae | ||
|
35366fea78 | ||
|
3e90e13d5e | ||
|
91ff0aa0db | ||
|
564e906dd1 | ||
|
d3d16fcc17 | ||
|
797b430540 | ||
|
ecdd0538dd | ||
|
aa26b43be2 | ||
|
bc94cc08e1 | ||
|
2d7e7e8242 | ||
|
32275f1a74 | ||
|
1bcde93efc | ||
|
e9e0f2085d | ||
|
bd31ef1587 | ||
|
7174e6ed70 | ||
|
0684db8255 | ||
|
dfb96ac596 | ||
|
f62a8ee8f7 | ||
|
04dbe5ca7d | ||
|
db8ff052a9 | ||
|
f88abb0697 | ||
|
0fd3c4cb26 | ||
|
0d174fea58 | ||
|
fb926ae7b2 | ||
|
6f4e01f92d | ||
|
71a1f95cba | ||
|
f899a6aaad | ||
|
6c5486c227 | ||
|
dd323fb8dc | ||
|
6ee845ba60 | ||
|
5d027c8012 | ||
|
e23bf00919 | ||
|
cfc80a9d6e | ||
|
a014df24c5 | ||
|
c68a5e449f | ||
|
3242caee6a | ||
|
ae5dec259f | ||
|
3b35392d13 | ||
|
27dcf14de4 | ||
|
cabc7d32da | ||
|
26af53173e | ||
|
b69aab2431 | ||
|
cf929ce541 | ||
|
bb9c771f4f | ||
|
886d37792c | ||
|
77d127249c | ||
|
cfea73392b | ||
|
02585a58e3 | ||
|
4cf5d1965f | ||
|
06ad9c62b5 | ||
|
30a9249dd9 | ||
|
c1a028c345 | ||
|
4100770e32 | ||
|
f944220634 | ||
|
ad1b9e1b07 | ||
|
197b49677d | ||
|
9582a7970e | ||
|
957e8ab4be | ||
|
8b171279e9 | ||
|
4a98dbdcd9 | ||
|
e2029649b9 | ||
|
c0ac498159 | ||
|
a29518b978 | ||
|
001f827a4f | ||
|
24e702e6cd | ||
|
d26d7a7959 | ||
|
5ddf120260 | ||
|
93336bb110 | ||
|
8ee19a09e2 | ||
|
0398e228de | ||
|
a177dbaae4 | ||
|
4c31e0c81f | ||
|
c5f5a4c038 | ||
|
5e2751fe85 | ||
|
294cf98f59 | ||
|
dce16514fe | ||
|
7df8f7e215 | ||
|
9e9366bbef | ||
|
c685525849 | ||
|
32c6eb989c | ||
|
e8a7e1f12b | ||
|
987e447551 | ||
|
d61a1ce875 | ||
|
f9fc3f356f | ||
|
d298a11af7 | ||
|
d3fd2d9a10 | ||
|
d3f8ea684e | ||
|
3d6e4e7c2e | ||
|
6a1d268315 | ||
|
2a988a2021 | ||
|
6b229c3ae2 | ||
|
79af2e7fdf | ||
|
dbef5838d4 | ||
|
80f58d05f0 | ||
|
4449dd088b | ||
|
29c7d98898 | ||
|
0ce2b3927e | ||
|
501a539c22 | ||
|
156dd01575 | ||
|
24df5ea742 | ||
|
c0d8f1807d | ||
|
bdb0e9d37d | ||
|
c1a4ad1ab1 | ||
|
61daaffee6 | ||
|
416d89268e | ||
|
391360f145 | ||
|
f429960d58 | ||
|
a77ea02b8d | ||
|
acb45eeb84 | ||
|
694abbcafa | ||
|
5105fc4981 | ||
|
b9d80939c6 | ||
|
1b061d63a8 | ||
|
8adde8d9c7 | ||
|
a0194d7ffd | ||
|
ba3fb44b49 | ||
|
70406170f5 | ||
|
4ad7e911d9 | ||
|
0816a04f42 | ||
|
83c23c7a3a | ||
|
d71f4c279b | ||
|
3293100c42 | ||
|
00d311d90f | ||
|
326399794e | ||
|
691395e193 | ||
|
c167627675 | ||
|
4b11437f7a | ||
|
2895ca34dd | ||
|
0be2a2ced3 | ||
|
b614cdbd6e | ||
|
db5f82be2a | ||
|
b38e904a4e | ||
|
32419c899c | ||
|
63fd27fbce | ||
|
7b03a01b18 | ||
|
1137ed5f07 | ||
|
32343842d3 | ||
|
ad50594cb2 | ||
|
f57d661416 | ||
|
98eead0058 | ||
|
da4d1d06d4 | ||
|
e854f357f4 | ||
|
78503bf574 | ||
|
01cbb31770 | ||
|
47163784d7 | ||
|
3e6a86b6b8 | ||
|
b1abd13319 | ||
|
ee536fd995 | ||
|
d58e20ee65 | ||
|
159e144abf | ||
|
8871dcd2e1 | ||
|
df794c0181 | ||
|
5f18ebc705 | ||
|
be55b9c98d | ||
|
aec63cd2e6 | ||
|
89800d4341 | ||
|
f4b2eb0ced | ||
|
b435c1b87b | ||
|
7ba0ee591e | ||
|
d320ef4fdb | ||
|
28245c731e | ||
|
19ec49f89a | ||
|
57878ff44f | ||
|
4efa158c31 | ||
|
fdf961cfa3 | ||
|
84f53aea25 | ||
|
6a685d6b0b | ||
|
759ff45dba | ||
|
eb5eeca609 | ||
|
601fd3a051 | ||
|
a0c9a28728 | ||
|
9e4bf79543 | ||
|
583d450885 | ||
|
f223ce03d4 | ||
|
1ff36f4030 | ||
|
4c9f27270e | ||
|
69d8e070f0 | ||
|
da14be6f1b | ||
|
558f819819 | ||
|
bf61f35cb4 | ||
|
7e4192b70e | ||
|
7a76a9c027 | ||
|
0dbed8eb38 | ||
|
20a587d776 | ||
|
db17d5969b | ||
|
e44d0a335e | ||
|
4f966b0217 | ||
|
66b9754170 | ||
|
088ff642fc | ||
|
4fd11c444a | ||
|
cc418554ad | ||
|
7207e6285e | ||
|
d4e9444f9d | ||
|
e40307d108 | ||
|
19aeaedd54 | ||
|
b596e937b8 | ||
|
b7f47694f8 | ||
|
99128312fb | ||
|
c9f85b4dca | ||
|
3e3533b275 | ||
|
c32bc6f1bc | ||
|
ffc53703ad | ||
|
4aae2dee34 | ||
|
3b1bb19c7c | ||
|
e57f8e7795 | ||
|
a67d31b1ec | ||
|
02be30908f | ||
|
9a9c16dfd1 | ||
|
98be0a1234 | ||
|
95223e9ee3 | ||
|
c8008de37b | ||
|
20686e955c | ||
|
5d311c9219 | ||
|
66447d0454 | ||
|
2c58be171e | ||
|
25860ff244 | ||
|
593de6855a | ||
|
f8fe237c3c | ||
|
72457bee3a | ||
|
8ffb52b439 | ||
|
ca1667c118 | ||
|
ef1b4b8eb0 | ||
|
f1b2a891c3 | ||
|
ba970ea670 | ||
|
58e9539513 | ||
|
f214d9c2a6 | ||
|
0311beb5e5 | ||
|
13050bf00d | ||
|
de67ebfc8d | ||
|
5de8ea800d | ||
|
2445411897 | ||
|
35c678bee2 | ||
|
d045cd7324 | ||
|
4694e4f1d7 | ||
|
8ca9ddb56b | ||
|
ec8f991143 | ||
|
638a8aff5c | ||
|
2e0fb206f9 | ||
|
7f8346bbae | ||
|
2df13c85e8 | ||
|
a8240df544 | ||
|
6ee6f7f22a | ||
|
9b8f978bff | ||
|
90b1287e52 | ||
|
5d28790cb5 | ||
|
47fc70af6e | ||
|
de02538aaf | ||
|
38eae11512 | ||
|
f38eee2d18 | ||
|
380710aae0 | ||
|
fe0d1ad5c0 | ||
|
efb8da2402 | ||
|
54e8363ddf | ||
|
13e7660ffb | ||
|
d598c689b7 | ||
|
686c8cac9a | ||
|
f0a5b957fc | ||
|
3548ee76e9 | ||
|
a021c500ed | ||
|
e8050ebbc1 | ||
|
c00da86463 | ||
|
0ef16c3837 | ||
|
c9576b7c16 | ||
|
ac8b8acd37 | ||
|
3ebc9c14e2 | ||
|
3cd0db9841 | ||
|
ed4a05f674 | ||
|
4b8e2214cd | ||
|
192243d4bd | ||
|
2950458c77 | ||
|
2cdd6c4bd1 | ||
|
a8a26e0bf7 | ||
|
7268472226 | ||
|
1f155f4c55 | ||
|
bd0390b11c | ||
|
fe4971ccf1 | ||
|
0e4e55f5bb | ||
|
867ae093eb | ||
|
93f60f1626 | ||
|
a94f59da17 | ||
|
df6e7a2377 | ||
|
869b20e64b | ||
|
2559f1779a | ||
|
1acc18cf38 | ||
|
1563886480 | ||
|
bfe0784fde | ||
|
c30f5d2455 | ||
|
da1f8190ac | ||
|
6ee2797689 | ||
|
c42227f927 | ||
|
101b99a657 | ||
|
efd70c659e | ||
|
f3b284f565 | ||
|
c8b445b04a | ||
|
38e0665127 | ||
|
55093770df | ||
|
2c69c724d5 | ||
|
fbdf57f843 | ||
|
01bf129066 | ||
|
9504d1c8e0 | ||
|
e42df7e95c | ||
|
2502aad59d | ||
|
d9cbbf906d | ||
|
dc42b9713f | ||
|
a917dc3a93 | ||
|
b049c59588 | ||
|
184db75d4b | ||
|
eb54373946 | ||
|
71f932186b | ||
|
0e2dd07cd1 | ||
|
9537815da5 | ||
|
e2ff4f0a61 | ||
|
e5ec390625 | ||
|
9e0ddb716d | ||
|
2817b31e06 | ||
|
b0c8788d9a | ||
|
7d7535216a | ||
|
80048dc7b9 | ||
|
c820094625 | ||
|
01e2b1d1cd | ||
|
6dd10a4e91 | ||
|
8098fc925f | ||
|
5bfb2dc9bf | ||
|
6bf4e5213e | ||
|
506d9ef311 | ||
|
6d690c0070 | ||
|
4edfa3fcba | ||
|
1c09b7b8b1 | ||
|
94ab628411 | ||
|
dc5af5c374 | ||
|
087357a810 | ||
|
5d06579605 | ||
|
17cf1841f7 | ||
|
9ea9d6203f | ||
|
ea239aaf96 | ||
|
31c9e2a76f | ||
|
3048e63aa3 | ||
|
d8993df06a | ||
|
7868e79a64 | ||
|
7fd427f0c6 | ||
|
60b96878d7 | ||
|
4e535d25e5 | ||
|
c7ccfc6749 | ||
|
2d1d815ab2 | ||
|
ab7ec14047 | ||
|
e2ab61c10e | ||
|
3aafc9c4e3 | ||
|
0b363c4048 | ||
|
094899a00c | ||
|
a74aa82269 | ||
|
239a0718d2 | ||
|
1b3249c6e2 | ||
|
cb46853ffd | ||
|
094929f903 | ||
|
013d6846fc | ||
|
49f312505c | ||
|
c97846b994 | ||
|
76f0643e55 | ||
|
1bd99826d5 | ||
|
f55fab268d | ||
|
d594caf7f3 | ||
|
9ad63089fe | ||
|
728a2de655 | ||
|
0a03235ade | ||
|
638cf2aac7 | ||
|
25cbeefcb7 | ||
|
4362678874 | ||
|
0768474121 | ||
|
cadbbd4f4f | ||
|
bfeabc149e | ||
|
034f873f68 | ||
|
bd2c474039 | ||
|
b9b3f8045a | ||
|
e44dd906cd | ||
|
5700a5e2e5 | ||
|
eb011df617 | ||
|
1c6dbab41a | ||
|
a23f035f55 | ||
|
55e6545949 | ||
|
0bfa3bf749 | ||
|
9462469bb5 | ||
|
13d0dc5e6d | ||
|
fc315c5bba | ||
|
0a8b9db661 | ||
|
be172d527a | ||
|
4320c6532b | ||
|
affef9fc80 | ||
|
7bee81cf0d | ||
|
5f6e1759ed | ||
|
44c7fbb74f | ||
|
f2e705c9dd | ||
|
1c0a8d987e | ||
|
917c314926 | ||
|
d4f444ec20 | ||
|
0423163ed6 | ||
|
e0cdd5db40 | ||
|
57aa7db0e3 | ||
|
f5cb5b04dc | ||
|
c6aab53822 | ||
|
4f55e9b680 | ||
|
72fd118a27 | ||
|
4dcfaae8ab | ||
|
b5e5481ca5 | ||
|
1b67ea10b0 | ||
|
21d951e5de | ||
|
cf825de1cf | ||
|
49b303a9cf | ||
|
3156ab625f | ||
|
f3315b6913 | ||
|
7f1d1743d5 | ||
|
26bbdc2cf1 | ||
|
73ae6a3fc1 | ||
|
a765b0f1df | ||
|
e4092537e6 | ||
|
be81ce4bd5 | ||
|
7d073db453 | ||
|
e00ed4ce20 | ||
|
57ce5c3bc9 | ||
|
6e0134f3b3 | ||
|
d349189b84 | ||
|
312b693de0 | ||
|
748af8203e | ||
|
5618306b94 | ||
|
1df0a8e5d9 | ||
|
b982fe98f0 | ||
|
352e9bffbf | ||
|
6f02652a99 | ||
|
54fe377ee0 | ||
|
e8059de1f6 | ||
|
34e8bed74f | ||
|
835d757b71 | ||
|
b6db383609 | ||
|
0e7e3ada8f | ||
|
e305fb28ba | ||
|
38a76161a3 | ||
|
4c9afd56cc | ||
|
ddbc7a0da5 | ||
|
2203a7aaab | ||
|
177149f8b4 | ||
|
014595173f | ||
|
311784a999 | ||
|
9576352278 | ||
|
07af05d41e | ||
|
d6774e9a57 | ||
|
c0eaef5f69 | ||
|
221fb75106 | ||
|
0e18d679bd | ||
|
5af426b83a | ||
|
0ce797a909 |
3
.arcconfig
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"phabricator.uri" : "https://phabricator.kde.org/"
|
||||
}
|
99
.clang-format
Normal 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
@ -0,0 +1,2 @@
|
||||
# _clang_format added
|
||||
f62a8ee8f7e81a1b573c335ded3326d8ee985ab4
|
50
.gitlab-ci.yml
Normal 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
@ -0,0 +1,4 @@
|
||||
REPOSITORY = "git://anongit.kde.org/qca"
|
||||
REVIEWBOARD_URL = "https://git.reviewboard.kde.org"
|
||||
TARGET_PEOPLE = "iromanov"
|
||||
BRANCH = "master"
|
471
CMakeLists.txt
@ -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()
|
||||
|
@ -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
@ -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
|
||||
|
27
Mainpage.dox
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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
|
||||
}
|
@ -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
|
||||
|
||||
|
5093
certs/rootcerts.pem
@ -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)
|
||||
|
||||
|
@ -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)
|
@ -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)
|
||||
|
@ -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)
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
@ -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)
|
@ -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
|
||||
|
@ -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
@ -0,0 +1,3 @@
|
||||
### KApiDox Project-specific Overrides File
|
||||
|
||||
FILE_PATTERNS += *.doco
|
BIN
docs/pics/qca-arch.png
Normal file
After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += aes-cmac.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += base64test.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += certtest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += ciphertest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += cmsexample.cpp
|
||||
include(../examples.pri)
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 638 B |
Before Width: | Height: | Size: 726 B After Width: | Height: | Size: 693 B |
Before Width: | Height: | Size: 815 B After Width: | Height: | Size: 786 B |
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 835 B |
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 617 B |
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,3 +0,0 @@
|
||||
HEADERS += $$PWD/pkcs11configdlg.h
|
||||
SOURCES += $$PWD/pkcs11configdlg.cpp
|
||||
FORMS += $$PWD/pkcs11config.ui
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += eventhandlerdemo.cpp
|
||||
include(../examples.pri)
|
@ -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.
|
||||
|
@ -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
|
@ -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
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += hashtest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += hextest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += keyloader.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += mactest.cpp
|
||||
include(../examples.pri)
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += md5crypt.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += providertest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += publickeyexample.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += randomtest.cpp
|
||||
include(../examples.pri)
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
SOURCES += rsatest.cpp
|
||||
include(../examples.pri)
|
@ -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()
|
||||
|