Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssldiffiehellmanparameters.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
23#include "qtlsbackend_p.h"
24#include "qsslsocket.h"
25#include "qsslsocket_p.h"
26
27#include <QtCore/qcoreapplication.h>
28#include <QtCore/qatomic.h>
29#include <QtCore/qbytearray.h>
30#include <QtCore/qbytearraymatcher.h>
31#include <QtCore/qiodevice.h>
32#include <QtCore/qdebug.h>
33
35
36// The 2048-bit MODP group from RFC 3526
38 "MIIBCAKCAQEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxObIlFKCHmO"
39 "NATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjftawv/XLb0Brft7jhr"
40 "+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXTmmkWP6j9JM9fg2VdI9yjrZYc"
41 "YvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhghfDKQXkYuNs474553LBgOhgObJ4Oi7Aei"
42 "j7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq5RXSJhiY+gUQFXKOWoqsqmj//////////wIBAg==";
43
55
71
84{
86 const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse();
87 if (!tlsBackend)
88 return result;
89 switch (encoding) {
90 case QSsl::Der:
91 result.d->initFromDer(encoded);
92 break;
93 case QSsl::Pem:
94 result.d->initFromPem(encoded);
95 break;
96 }
97 return result;
98}
99
121
131
145{
146 if (d && !d->ref.deref())
147 delete d;
148}
149
162
186{
188}
189
205
229
235{
236 switch (d->error) {
238 return QCoreApplication::translate("QSslDiffieHellmanParameter", "No error");
240 return QCoreApplication::translate("QSslDiffieHellmanParameter", "Invalid input data");
242 return QCoreApplication::translate("QSslDiffieHellmanParameter", "The given Diffie-Hellman parameters are deemed unsafe");
243 }
244
245 Q_UNREACHABLE_RETURN(QString());
246}
247
265bool QSslDiffieHellmanParameters::isEqual(const QSslDiffieHellmanParameters &other) const noexcept
266{
267 return d->derData == other.d->derData;
268}
269
274{
275 if (const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse())
276 error = QSslDiffieHellmanParameters::Error(tlsBackend->dhParametersFromDer(der, &derData));
277}
278
283{
284 if (const auto *tlsBackend = QSslSocketPrivate::tlsBackendInUse())
285 error = QSslDiffieHellmanParameters::Error(tlsBackend->dhParametersFromPem(pem, &derData));
286}
287
288#ifndef QT_NO_DEBUG_STREAM
301{
302 QDebugStateSaver saver(debug);
303 debug.resetFormat().nospace();
304 debug << "QSslDiffieHellmanParameters(" << dhparam.d->derData.toBase64() << ')';
305 return debug;
306}
307#endif
308
316size_t qHash(const QSslDiffieHellmanParameters &dhparam, size_t seed) noexcept
317{
318 return qHash(dhparam.d->derData, seed);
319}
320
IOBluetoothDevice * device
bool ref() noexcept
bool deref() noexcept
\inmodule QtCore
Definition qbytearray.h:57
static QByteArray fromBase64(const QByteArray &base64, Base64Options options=Base64Encoding)
QByteArray toBase64(Base64Options options=Base64Encoding) const
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore \reentrant
Definition qiodevice.h:34
QAtomicInt ref
Definition qshareddata.h:21
QSslDiffieHellmanParameters::Error error
The QSslDiffieHellmanParameters class provides an interface for Diffie-Hellman parameters for servers...
void swap(QSslDiffieHellmanParameters &other) noexcept
Swaps this QSslDiffieHellmanParameters with other.
Error error() const noexcept
Returns the error that caused the QSslDiffieHellmanParameters object to be invalid.
QSslDiffieHellmanParameters()
Constructs an empty QSslDiffieHellmanParameters instance.
bool isEmpty() const noexcept
Returns true if this is a an empty QSslDiffieHellmanParameters instance.
Error
Describes a QSslDiffieHellmanParameters error.
static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format=QSsl::Pem)
Constructs a QSslDiffieHellmanParameters object using the byte array encoded in either PEM or DER for...
QSslDiffieHellmanParameters & operator=(const QSslDiffieHellmanParameters &other)
Copies the contents of other into this QSslDiffieHellmanParameters, making the two QSslDiffieHellmanP...
QString errorString() const noexcept
Returns a human-readable description of the error that caused the QSslDiffieHellmanParameters object ...
bool isValid() const noexcept
Returns true if this is a valid QSslDiffieHellmanParameters; otherwise false.
~QSslDiffieHellmanParameters()
Destroys the QSslDiffieHellmanParameters object.
static QSslDiffieHellmanParameters defaultParameters()
Returns the default QSslDiffieHellmanParameters used by QSslSocket.
static QTlsBackend * tlsBackendInUse()
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
EncodingFormat
Describes supported encoding formats for certificates and keys.
Definition qssl.h:28
@ Pem
Definition qssl.h:29
@ Der
Definition qssl.h:30
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
GLuint64EXT * result
[6]
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
QT_BEGIN_NAMESPACE Q_AUTOTEST_EXPORT const char * qssl_dhparams_default_base64
#define Q_AUTOTEST_EXPORT
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QSharedPointer< T > other(t)
[5]