OpenCoverage

qsslcipher.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslcipher.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40-
41/*!-
42 \class QSslCipher-
43 \brief The QSslCipher class represents an SSL cryptographic cipher.-
44 \since 4.3-
45-
46 \reentrant-
47 \ingroup network-
48 \ingroup ssl-
49 \ingroup shared-
50 \inmodule QtNetwork-
51-
52 QSslCipher stores information about one cryptographic cipher. It-
53 is most commonly used with QSslSocket, either for configuring-
54 which ciphers the socket can use, or for displaying the socket's-
55 ciphers to the user.-
56-
57 \sa QSslSocket, QSslKey-
58*/-
59-
60#include "qsslcipher.h"-
61#include "qsslcipher_p.h"-
62#include "qsslsocket.h"-
63#include "qsslconfiguration.h"-
64-
65#ifndef QT_NO_DEBUG_STREAM-
66#include <QtCore/qdebug.h>-
67#endif-
68-
69QT_BEGIN_NAMESPACE-
70-
71/*!-
72 Constructs an empty QSslCipher object.-
73*/-
74QSslCipher::QSslCipher()-
75 : d(new QSslCipherPrivate)-
76{-
77}
executed 8449 times by 17 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslcipher - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
8449
78-
79/*!-
80 \since 5.3-
81-
82 Constructs a QSslCipher object for the cipher determined by \a-
83 name. The constructor accepts only supported ciphers (i.e., the-
84 \a name must identify a cipher in the list of ciphers returned by-
85 QSslSocket::supportedCiphers()).-
86-
87 You can call isNull() after construction to check if \a name-
88 correctly identified a supported cipher.-
89*/-
90QSslCipher::QSslCipher(const QString &name)-
91 : d(new QSslCipherPrivate)-
92{-
93 const auto ciphers = QSslConfiguration::supportedCiphers();-
94 for (const QSslCipher &cipher : ciphers) {-
95 if (cipher.name() == name) {
cipher.name() == nameDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
FALSEevaluated 2756 times by 1 test
Evaluated by:
  • tst_qsslsocket - unknown status
13-2756
96 *this = cipher;-
97 return;
executed 13 times by 1 test: return;
Executed by:
  • tst_qsslsocket - unknown status
13
98 }-
99 }
executed 2756 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
2756
100}
executed 30 times by 1 test: end of block
Executed by:
  • tst_qsslsocket - unknown status
30
101-
102/*!-
103 Constructs a QSslCipher object for the cipher determined by \a-
104 name and \a protocol. The constructor accepts only supported-
105 ciphers (i.e., the \a name and \a protocol must identify a cipher-
106 in the list of ciphers returned by-
107 QSslSocket::supportedCiphers()).-
108-
109 You can call isNull() after construction to check if \a name and-
110 \a protocol correctly identified a supported cipher.-
111*/-
112QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)-
113 : d(new QSslCipherPrivate)-
114{-
115 const auto ciphers = QSslConfiguration::supportedCiphers();-
116 for (const QSslCipher &cipher : ciphers) {-
117 if (cipher.name() == name && cipher.protocol() == protocol) {
cipher.name() == nameDescription
TRUEnever evaluated
FALSEnever evaluated
cipher.protocol() == protocolDescription
TRUEnever evaluated
FALSEnever evaluated
0
118 *this = cipher;-
119 return;
never executed: return;
0
120 }-
121 }
never executed: end of block
0
122}
never executed: end of block
0
123-
124/*!-
125 Constructs an identical copy of the \a other cipher.-
126*/-
127QSslCipher::QSslCipher(const QSslCipher &other)-
128 : d(new QSslCipherPrivate)-
129{-
130 *d.data() = *other.d.data();-
131}
executed 3376 times by 16 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
3376
132-
133/*!-
134 Destroys the QSslCipher object.-
135*/-
136QSslCipher::~QSslCipher()-
137{-
138}-
139-
140/*!-
141 Copies the contents of \a other into this cipher, making the two-
142 ciphers identical.-
143*/-
144QSslCipher &QSslCipher::operator=(const QSslCipher &other)-
145{-
146 *d.data() = *other.d.data();-
147 return *this;
executed 733 times by 8 tests: return *this;
Executed by:
  • tst_NetworkSelfTest
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
733
148}-
149-
150/*!-
151 \fn void QSslCipher::swap(QSslCipher &other)-
152 \since 5.0-
153-
154 Swaps this cipher instance with \a other. This function is very-
155 fast and never fails.-
156*/-
157-
158/*!-
159 Returns \c true if this cipher is the same as \a other; otherwise,-
160 false is returned.-
161*/-
162bool QSslCipher::operator==(const QSslCipher &other) const-
163{-
164 return d->name == other.d->name && d->protocol == other.d->protocol;
executed 2102 times by 3 tests: return d->name == other.d->name && d->protocol == other.d->protocol;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qsslsocket - unknown status
2102
165}-
166-
167/*!-
168 \fn bool QSslCipher::operator!=(const QSslCipher &other) const-
169-
170 Returns \c true if this cipher is not the same as \a other;-
171 otherwise, false is returned.-
172*/-
173-
174/*!-
175 Returns \c true if this is a null cipher; otherwise returns \c false.-
176*/-
177bool QSslCipher::isNull() const-
178{-
179 return d->isNull;
executed 1211 times by 15 tests: return d->isNull;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
1211
180}-
181-
182/*!-
183 Returns the name of the cipher, or an empty QString if this is a null-
184 cipher.-
185-
186 \sa isNull()-
187*/-
188QString QSslCipher::name() const-
189{-
190 return d->name;
executed 36207 times by 16 tests: return d->name;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
36207
191}-
192-
193/*!-
194 Returns the number of bits supported by the cipher.-
195-
196 \sa usedBits()-
197*/-
198int QSslCipher::supportedBits()const-
199{-
200 return d->supportedBits;
never executed: return d->supportedBits;
0
201}-
202-
203/*!-
204 Returns the number of bits used by the cipher.-
205-
206 \sa supportedBits()-
207*/-
208int QSslCipher::usedBits() const-
209{-
210 return d->bits;
executed 1875 times by 15 tests: return d->bits;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qsslcertificate - unknown status
  • tst_qsslellipticcurve - unknown status
  • tst_qsslerror - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
1875
211}-
212-
213/*!-
214 Returns the cipher's key exchange method as a QString.-
215*/-
216QString QSslCipher::keyExchangeMethod() const-
217{-
218 return d->keyExchangeMethod;
never executed: return d->keyExchangeMethod;
0
219}-
220-
221/*!-
222 Returns the cipher's authentication method as a QString.-
223*/-
224QString QSslCipher::authenticationMethod() const-
225{-
226 return d->authenticationMethod;
never executed: return d->authenticationMethod;
0
227}-
228-
229/*!-
230 Returns the cipher's encryption method as a QString.-
231*/-
232QString QSslCipher::encryptionMethod() const-
233{-
234 return d->encryptionMethod;
never executed: return d->encryptionMethod;
0
235}-
236-
237/*!-
238 Returns the cipher's protocol as a QString.-
239-
240 \sa protocol()-
241*/-
242QString QSslCipher::protocolString() const-
243{-
244 return d->protocolString;
executed 720 times by 1 test: return d->protocolString;
Executed by:
  • tst_qsslsocket - unknown status
720
245}-
246-
247/*!-
248 Returns the cipher's protocol type, or \l QSsl::UnknownProtocol if-
249 QSslCipher is unable to determine the protocol (protocolString() may-
250 contain more information).-
251-
252 \sa protocolString()-
253*/-
254QSsl::SslProtocol QSslCipher::protocol() const-
255{-
256 return d->protocol;
never executed: return d->protocol;
0
257}-
258-
259#ifndef QT_NO_DEBUG_STREAM-
260QDebug operator<<(QDebug debug, const QSslCipher &cipher)-
261{-
262 QDebugStateSaver saver(debug);-
263 debug.resetFormat().nospace().noquote();-
264 debug << "QSslCipher(name=" << cipher.name()-
265 << ", bits=" << cipher.usedBits()-
266 << ", proto=" << cipher.protocolString()-
267 << ')';-
268 return debug;
executed 720 times by 1 test: return debug;
Executed by:
  • tst_qsslsocket - unknown status
720
269}-
270#endif-
271-
272QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9