Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | | - |
43 | /*! | - |
44 | \class QSslCipher | - |
45 | \brief The QSslCipher class represents an SSL cryptographic cipher. | - |
46 | \since 4.3 | - |
47 | | - |
48 | \reentrant | - |
49 | \ingroup network | - |
50 | \ingroup ssl | - |
51 | \ingroup shared | - |
52 | \inmodule QtNetwork | - |
53 | | - |
54 | QSslCipher stores information about one cryptographic cipher. It | - |
55 | is most commonly used with QSslSocket, either for configuring | - |
56 | which ciphers the socket can use, or for displaying the socket's | - |
57 | ciphers to the user. | - |
58 | | - |
59 | \sa QSslSocket, QSslKey | - |
60 | */ | - |
61 | | - |
62 | #include "qsslcipher.h" | - |
63 | #include "qsslcipher_p.h" | - |
64 | #include "qsslsocket.h" | - |
65 | | - |
66 | #ifndef QT_NO_DEBUG_STREAM | - |
67 | #include <QtCore/qdebug.h> | - |
68 | #endif | - |
69 | | - |
70 | QT_BEGIN_NAMESPACE | - |
71 | | - |
72 | /*! | - |
73 | Constructs an empty QSslCipher object. | - |
74 | */ | - |
75 | QSslCipher::QSslCipher() | - |
76 | : d(new QSslCipherPrivate) | - |
77 | { | - |
78 | } executed: } Execution Count:5009 | 5009 |
79 | | - |
80 | /*! | - |
81 | Constructs a QSslCipher object for the cipher determined by \a | - |
82 | name and \a protocol. The constructor accepts only supported | - |
83 | ciphers (i.e., the \a name and \a protocol must identify a cipher | - |
84 | in the list of ciphers returned by | - |
85 | QSslSocket::supportedCiphers()). | - |
86 | | - |
87 | You can call isNull() after construction to check if \a name and | - |
88 | \a protocol correctly identified a supported cipher. | - |
89 | */ | - |
90 | QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol) | - |
91 | : d(new QSslCipherPrivate) | - |
92 | { | - |
93 | foreach (const QSslCipher &cipher, QSslSocket::supportedCiphers()) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(QSslSocket::supportedCiphers())> _container_(QSslSocket::supportedCiphers()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QSslCipher &cipher = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
94 | if (cipher.name() == name && cipher.protocol() == protocol) { never evaluated: cipher.name() == name never evaluated: cipher.protocol() == protocol | 0 |
95 | *this = cipher; never executed (the execution status of this line is deduced): *this = cipher; | - |
96 | return; | 0 |
97 | } | - |
98 | } | 0 |
99 | } | 0 |
100 | | - |
101 | /*! | - |
102 | Constructs an identical copy of the \a other cipher. | - |
103 | */ | - |
104 | QSslCipher::QSslCipher(const QSslCipher &other) | - |
105 | : d(new QSslCipherPrivate) | - |
106 | { | - |
107 | *d.data() = *other.d.data(); executed (the execution status of this line is deduced): *d.data() = *other.d.data(); | - |
108 | } executed: } Execution Count:386 | 386 |
109 | | - |
110 | /*! | - |
111 | Destroys the QSslCipher object. | - |
112 | */ | - |
113 | QSslCipher::~QSslCipher() | - |
114 | { | - |
115 | } | - |
116 | | - |
117 | /*! | - |
118 | Copies the contents of \a other into this cipher, making the two | - |
119 | ciphers identical. | - |
120 | */ | - |
121 | QSslCipher &QSslCipher::operator=(const QSslCipher &other) | - |
122 | { | - |
123 | *d.data() = *other.d.data(); executed (the execution status of this line is deduced): *d.data() = *other.d.data(); | - |
124 | return *this; executed: return *this; Execution Count:259 | 259 |
125 | } | - |
126 | | - |
127 | /*! | - |
128 | \fn void QSslCipher::swap(QSslCipher &other) | - |
129 | \since 5.0 | - |
130 | | - |
131 | Swaps this cipher instance with \a other. This function is very | - |
132 | fast and never fails. | - |
133 | */ | - |
134 | | - |
135 | /*! | - |
136 | Returns true if this cipher is the same as \a other; otherwise, | - |
137 | false is returned. | - |
138 | */ | - |
139 | bool QSslCipher::operator==(const QSslCipher &other) const | - |
140 | { | - |
141 | return d->name == other.d->name && d->protocol == other.d->protocol; executed: return d->name == other.d->name && d->protocol == other.d->protocol; Execution Count:43 | 43 |
142 | } | - |
143 | | - |
144 | /*! | - |
145 | \fn bool QSslCipher::operator!=(const QSslCipher &other) const | - |
146 | | - |
147 | Returns true if this cipher is not the same as \a other; | - |
148 | otherwise, false is returned. | - |
149 | */ | - |
150 | | - |
151 | /*! | - |
152 | Returns true if this is a null cipher; otherwise returns false. | - |
153 | */ | - |
154 | bool QSslCipher::isNull() const | - |
155 | { | - |
156 | return d->isNull; executed: return d->isNull; Execution Count:225 | 225 |
157 | } | - |
158 | | - |
159 | /*! | - |
160 | Returns the name of the cipher, or an empty QString if this is a null | - |
161 | cipher. | - |
162 | | - |
163 | \sa isNull() | - |
164 | */ | - |
165 | QString QSslCipher::name() const | - |
166 | { | - |
167 | return d->name; executed: return d->name; Execution Count:2400 | 2400 |
168 | } | - |
169 | | - |
170 | /*! | - |
171 | Returns the number of bits supported by the cipher. | - |
172 | | - |
173 | \sa usedBits() | - |
174 | */ | - |
175 | int QSslCipher::supportedBits()const | - |
176 | { | - |
177 | return d->supportedBits; never executed: return d->supportedBits; | 0 |
178 | } | - |
179 | | - |
180 | /*! | - |
181 | Returns the number of bits used by the cipher. | - |
182 | | - |
183 | \sa supportedBits() | - |
184 | */ | - |
185 | int QSslCipher::usedBits() const | - |
186 | { | - |
187 | return d->bits; never executed: return d->bits; | 0 |
188 | } | - |
189 | | - |
190 | /*! | - |
191 | Returns the cipher's key exchange method as a QString. | - |
192 | */ | - |
193 | QString QSslCipher::keyExchangeMethod() const | - |
194 | { | - |
195 | return d->keyExchangeMethod; never executed: return d->keyExchangeMethod; | 0 |
196 | } | - |
197 | | - |
198 | /*! | - |
199 | Returns the cipher's authentication method as a QString. | - |
200 | */ | - |
201 | QString QSslCipher::authenticationMethod() const | - |
202 | { | - |
203 | return d->authenticationMethod; never executed: return d->authenticationMethod; | 0 |
204 | } | - |
205 | | - |
206 | /*! | - |
207 | Returns the cipher's encryption method as a QString. | - |
208 | */ | - |
209 | QString QSslCipher::encryptionMethod() const | - |
210 | { | - |
211 | return d->encryptionMethod; never executed: return d->encryptionMethod; | 0 |
212 | } | - |
213 | | - |
214 | /*! | - |
215 | Returns the cipher's protocol as a QString. | - |
216 | | - |
217 | \sa protocol() | - |
218 | */ | - |
219 | QString QSslCipher::protocolString() const | - |
220 | { | - |
221 | return d->protocolString; never executed: return d->protocolString; | 0 |
222 | } | - |
223 | | - |
224 | /*! | - |
225 | Returns the cipher's protocol type, or \l QSsl::UnknownProtocol if | - |
226 | QSslCipher is unable to determine the protocol (protocolString() may | - |
227 | contain more information). | - |
228 | | - |
229 | \sa protocolString() | - |
230 | */ | - |
231 | QSsl::SslProtocol QSslCipher::protocol() const | - |
232 | { | - |
233 | return d->protocol; never executed: return d->protocol; | 0 |
234 | } | - |
235 | | - |
236 | #ifndef QT_NO_DEBUG_STREAM | - |
237 | QDebug operator<<(QDebug debug, const QSslCipher &cipher) | - |
238 | { | - |
239 | debug << "QSslCipher(name=" << qPrintable(cipher.name()) never executed (the execution status of this line is deduced): debug << "QSslCipher(name=" << QString(cipher.name()).toLocal8Bit().constData() | - |
240 | << ", bits=" << cipher.usedBits() never executed (the execution status of this line is deduced): << ", bits=" << cipher.usedBits() | - |
241 | << ", proto=" << qPrintable(cipher.protocolString()) never executed (the execution status of this line is deduced): << ", proto=" << QString(cipher.protocolString()).toLocal8Bit().constData() | - |
242 | << ')'; never executed (the execution status of this line is deduced): << ')'; | - |
243 | return debug; never executed: return debug; | 0 |
244 | } | - |
245 | #endif | - |
246 | | - |
247 | QT_END_NAMESPACE | - |
248 | | - |
| | |