1 | /** |
2 | * Copyright (C) 2006 Brad Hards <bradh@frogmouth.net> |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include <QtCrypto> |
27 | #include <QtTest/QtTest> |
28 | |
29 | #ifdef QT_STATICPLUGIN |
30 | #include "import_plugins.h" |
31 | #endif |
32 | |
33 | #include <memory> |
34 | |
35 | class TLSUnitTest : public QObject |
36 | { |
37 | Q_OBJECT |
38 | |
39 | private Q_SLOTS: |
40 | void initTestCase(); |
41 | void cleanupTestCase(); |
42 | void testCipherList(); |
43 | |
44 | private: |
45 | QCA::Initializer *m_init; |
46 | }; |
47 | |
48 | void TLSUnitTest::initTestCase() |
49 | { |
50 | m_init = new QCA::Initializer; |
51 | } |
52 | |
53 | void TLSUnitTest::cleanupTestCase() |
54 | { |
55 | delete m_init; |
56 | } |
57 | |
58 | void TLSUnitTest::testCipherList() |
59 | { |
60 | if (!QCA::isSupported(features: "tls" , QStringLiteral("qca-ossl" ))) |
61 | QWARN("TLS not supported for qca-ossl" ); |
62 | else { |
63 | std::unique_ptr<QCA::TLS> tls(new QCA::TLS(QCA::TLS::Stream, nullptr, QStringLiteral("qca-ossl" ))); |
64 | QStringList cipherList = tls->supportedCipherSuites(version: QCA::TLS::TLS_v1); |
65 | QVERIFY(cipherList.contains(QStringLiteral("TLS_DHE_RSA_WITH_AES_256_CBC_SHA" ))); |
66 | QVERIFY(cipherList.contains(QStringLiteral("TLS_RSA_WITH_AES_256_CBC_SHA" ))); |
67 | QVERIFY(cipherList.contains(QStringLiteral("TLS_DHE_RSA_WITH_AES_128_CBC_SHA" ))); |
68 | |
69 | // openSUSE TW OpenSSL 1.1 does not have this |
70 | // QVERIFY( cipherList.contains("TLS_DHE_DSS_WITH_AES_256_CBC_SHA") ); |
71 | // QVERIFY( cipherList.contains("TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA") ); |
72 | // QVERIFY( cipherList.contains("TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA") ); |
73 | // QVERIFY( cipherList.contains("TLS_RSA_WITH_3DES_EDE_CBC_SHA") ); |
74 | // QVERIFY( cipherList.contains("TLS_RSA_WITH_AES_128_CBC_SHA") ); |
75 | // QVERIFY( cipherList.contains("TLS_DHE_DSS_WITH_AES_128_CBC_SHA") ); |
76 | |
77 | // Fedora 26 openssl has no this cipher suites. |
78 | // QVERIFY( cipherList.contains("TLS_RSA_WITH_RC4_128_SHA") ); |
79 | // QVERIFY( cipherList.contains("TLS_RSA_WITH_RC4_128_MD5") ); |
80 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_RC4_128_SHA") ); |
81 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_RC4_128_MD5") ); |
82 | |
83 | // Fedora 20 openssl has no this cipher suites. |
84 | // I just believe that F20 has the most strict patent rules |
85 | // and Fedora list is the minimal default list. |
86 | // It should fit for every openssl distribuition. |
87 | |
88 | // QVERIFY( cipherList.contains("TLS_DHE_RSA_WITH_DES_CBC_SHA") ); |
89 | // QVERIFY( cipherList.contains("TLS_DHE_DSS_WITH_DES_CBC_SHA") ); |
90 | // QVERIFY( cipherList.contains("TLS_RSA_WITH_DES_CBC_SHA") ); |
91 | // QVERIFY( cipherList.contains("TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA") ); |
92 | // QVERIFY( cipherList.contains("TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA") ); |
93 | // QVERIFY( cipherList.contains("TLS_RSA_EXPORT_WITH_DES40_CBC_SHA") ); |
94 | // QVERIFY( cipherList.contains("TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5") ); |
95 | // QVERIFY( cipherList.contains("TLS_RSA_EXPORT_WITH_RC4_40_MD5") ); |
96 | |
97 | // OpenSSL 1.1 in openSUSE TW has it disabled by default |
98 | // cipherList = tls->supportedCipherSuites(QCA::TLS::SSL_v3); |
99 | // QVERIFY( cipherList.contains("SSL_DHE_RSA_WITH_AES_256_CBC_SHA") ); |
100 | // QVERIFY( cipherList.contains("SSL_DHE_DSS_WITH_AES_256_CBC_SHA") ); |
101 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_AES_256_CBC_SHA") ); |
102 | // QVERIFY( cipherList.contains("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA") ); |
103 | // QVERIFY( cipherList.contains("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA") ); |
104 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_3DES_EDE_CBC_SHA") ); |
105 | // QVERIFY( cipherList.contains("SSL_DHE_RSA_WITH_AES_128_CBC_SHA") ); |
106 | // QVERIFY( cipherList.contains("SSL_DHE_DSS_WITH_AES_128_CBC_SHA") ); |
107 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_AES_128_CBC_SHA") ); |
108 | |
109 | // Fedora 22 has no SSL_RSA_WITH_RC4_128_MD5 |
110 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_RC4_128_MD5") ); |
111 | |
112 | // QVERIFY( cipherList.contains("SSL_DHE_RSA_WITH_DES_CBC_SHA") ); |
113 | // QVERIFY( cipherList.contains("SSL_DHE_DSS_WITH_DES_CBC_SHA") ); |
114 | // QVERIFY( cipherList.contains("SSL_RSA_WITH_DES_CBC_SHA") ); |
115 | // QVERIFY( cipherList.contains("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA") ); |
116 | // QVERIFY( cipherList.contains("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA") ); |
117 | // QVERIFY( cipherList.contains("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA") ); |
118 | // QVERIFY( cipherList.contains("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5") ); |
119 | // QVERIFY( cipherList.contains("SSL_RSA_EXPORT_WITH_RC4_40_MD5") ); |
120 | |
121 | // Debian testing (jessie) has no these ciphers. So disable them. |
122 | |
123 | // cipherList = tls->supportedCipherSuites(QCA::TLS::SSL_v2); |
124 | // QVERIFY( cipherList.contains("SSL_CK_DES_192_EDE3_CBC_WITH_MD5") ); |
125 | // QVERIFY( cipherList.contains("SSL_CK_RC4_128_EXPORT40_WITH_MD5") ); |
126 | // QVERIFY( cipherList.contains("SSL_CK_RC2_128_CBC_WITH_MD5") ); |
127 | // QVERIFY( cipherList.contains("SSL_CK_RC4_128_WITH_MD5") ); |
128 | // QVERIFY( cipherList.contains("SSL_CK_DES_64_CBC_WITH_MD5") ); |
129 | // QVERIFY( cipherList.contains("SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5") ); |
130 | // QVERIFY( cipherList.contains("SSL_CK_RC4_128_EXPORT40_WITH_MD5") ); |
131 | } |
132 | } |
133 | |
134 | QTEST_MAIN(TLSUnitTest) |
135 | |
136 | #include "tlsunittest.moc" |
137 | |