Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsslcipher.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
/*!
7
\class QSslCipher
8
\brief The QSslCipher class represents an SSL cryptographic cipher.
9
\since 4.3
10
11
\reentrant
12
\ingroup network
13
\ingroup ssl
14
\ingroup shared
15
\inmodule QtNetwork
16
17
QSslCipher stores information about one cryptographic cipher. It
18
is most commonly used with QSslSocket, either for configuring
19
which ciphers the socket can use, or for displaying the socket's
20
ciphers to the user.
21
22
\sa QSslSocket, QSslKey
23
*/
24
25
#
include
"qsslcipher.h"
26
#
include
"qsslcipher_p.h"
27
#
include
"qsslsocket.h"
28
#
include
"qsslconfiguration.h"
29
30
#
ifndef
QT_NO_DEBUG_STREAM
31
#
include
<
QtCore
/
qdebug
.
h
>
32
#
endif
33
34
QT_BEGIN_NAMESPACE
35
36
/*!
37
Constructs an empty QSslCipher object.
38
*/
39
QSslCipher::QSslCipher()
40
: d(
new
QSslCipherPrivate)
41
{
42
}
43
44
/*!
45
\since 5.3
46
47
Constructs a QSslCipher object for the cipher determined by \a
48
name. The constructor accepts only supported ciphers (i.e., the
49
\a name must identify a cipher in the list of ciphers returned by
50
QSslSocket::supportedCiphers()).
51
52
You can call isNull() after construction to check if \a name
53
correctly identified a supported cipher.
54
*/
55
QSslCipher::QSslCipher(
const
QString &name)
56
: d(
new
QSslCipherPrivate)
57
{
58
const
auto
ciphers = QSslConfiguration::supportedCiphers();
59
for
(
const
QSslCipher &cipher : ciphers) {
60
if
(cipher.name() == name) {
61
*
this
= cipher;
62
return
;
63
}
64
}
65
}
66
67
/*!
68
Constructs a QSslCipher object for the cipher determined by \a
69
name and \a protocol. The constructor accepts only supported
70
ciphers (i.e., the \a name and \a protocol must identify a cipher
71
in the list of ciphers returned by
72
QSslSocket::supportedCiphers()).
73
74
You can call isNull() after construction to check if \a name and
75
\a protocol correctly identified a supported cipher.
76
*/
77
QSslCipher::QSslCipher(
const
QString &name, QSsl::SslProtocol protocol)
78
: d(
new
QSslCipherPrivate)
79
{
80
const
auto
ciphers = QSslConfiguration::supportedCiphers();
81
for
(
const
QSslCipher &cipher : ciphers) {
82
if
(cipher.name() == name && cipher.protocol() == protocol) {
83
*
this
= cipher;
84
return
;
85
}
86
}
87
}
88
89
/*!
90
Constructs an identical copy of the \a other cipher.
91
*/
92
QSslCipher::QSslCipher(
const
QSslCipher &other)
93
: d(
new
QSslCipherPrivate)
94
{
95
*d.get() = *other.d.get();
96
}
97
98
/*!
99
Destroys the QSslCipher object.
100
*/
101
QSslCipher::~QSslCipher()
102
{
103
}
104
105
/*!
106
Copies the contents of \a other into this cipher, making the two
107
ciphers identical.
108
*/
109
QSslCipher &QSslCipher::operator=(
const
QSslCipher &other)
110
{
111
*d.get() = *other.d.get();
112
return
*
this
;
113
}
114
115
/*!
116
\fn void QSslCipher::swap(QSslCipher &other)
117
\since 5.0
118
\memberswap{cipher instance}
119
*/
120
121
/*!
122
Returns \c true if this cipher is the same as \a other; otherwise,
123
false is returned.
124
*/
125
bool
QSslCipher::operator==(
const
QSslCipher &other)
const
126
{
127
return
d->name == other.d->name && d->protocol == other.d->protocol;
128
}
129
130
/*!
131
\fn bool QSslCipher::operator!=(const QSslCipher &other) const
132
133
Returns \c true if this cipher is not the same as \a other;
134
otherwise, false is returned.
135
*/
136
137
/*!
138
Returns \c true if this is a null cipher; otherwise returns \c false.
139
*/
140
bool
QSslCipher::isNull()
const
141
{
142
return
d->isNull;
143
}
144
145
/*!
146
Returns the name of the cipher, or an empty QString if this is a null
147
cipher.
148
149
\sa isNull()
150
*/
151
QString QSslCipher::name()
const
152
{
153
return
d->name;
154
}
155
156
/*!
157
Returns the number of bits supported by the cipher.
158
159
\sa usedBits()
160
*/
161
int
QSslCipher::supportedBits()
const
162
{
163
return
d->supportedBits;
164
}
165
166
/*!
167
Returns the number of bits used by the cipher.
168
169
\sa supportedBits()
170
*/
171
int
QSslCipher::usedBits()
const
172
{
173
return
d->bits;
174
}
175
176
/*!
177
Returns the cipher's key exchange method as a QString.
178
*/
179
QString QSslCipher::keyExchangeMethod()
const
180
{
181
return
d->keyExchangeMethod;
182
}
183
184
/*!
185
Returns the cipher's authentication method as a QString.
186
*/
187
QString QSslCipher::authenticationMethod()
const
188
{
189
return
d->authenticationMethod;
190
}
191
192
/*!
193
Returns the cipher's encryption method as a QString.
194
*/
195
QString QSslCipher::encryptionMethod()
const
196
{
197
return
d->encryptionMethod;
198
}
199
200
/*!
201
Returns the cipher's protocol as a QString.
202
203
\sa protocol()
204
*/
205
QString QSslCipher::protocolString()
const
206
{
207
return
d->protocolString;
208
}
209
210
/*!
211
Returns the cipher's protocol type, or \l QSsl::UnknownProtocol if
212
QSslCipher is unable to determine the protocol (protocolString() may
213
contain more information).
214
215
\sa protocolString()
216
*/
217
QSsl::SslProtocol QSslCipher::protocol()
const
218
{
219
return
d->protocol;
220
}
221
222
#
ifndef
QT_NO_DEBUG_STREAM
223
QDebug operator<<(QDebug debug,
const
QSslCipher &cipher)
224
{
225
QDebugStateSaver saver(debug);
226
debug.resetFormat().nospace().noquote();
227
debug <<
"QSslCipher(name="
<< cipher.name()
228
<<
", bits="
<< cipher.usedBits()
229
<<
", proto="
<< cipher.protocolString()
230
<<
')'
;
231
return
debug;
232
}
233
#
endif
234
235
QT_END_NAMESPACE
qtbase
src
network
ssl
qsslcipher.cpp
Generated on
for Qt by
1.18.0