Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdtls_base.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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#include "qdtls_base_p.h"
6
8
9void QDtlsBasePrivate::setDtlsError(QDtlsError code, const QString &description)
10{
11 errorCode = code;
12 errorDescription = description;
13}
14
15QDtlsError QDtlsBasePrivate::error() const
16{
17 return errorCode;
18}
19
20QString QDtlsBasePrivate::errorString() const
21{
22 return errorDescription;
23}
24
25void QDtlsBasePrivate::clearDtlsError()
26{
27 errorCode = QDtlsError::NoError;
28 errorDescription.clear();
29}
30
31QSslConfiguration QDtlsBasePrivate::configuration() const
32{
33 return dtlsConfiguration;
34}
35
36void QDtlsBasePrivate::setConfiguration(const QSslConfiguration &configuration)
37{
38 dtlsConfiguration = configuration;
39 clearDtlsError();
40}
41
42bool QDtlsBasePrivate::setCookieGeneratorParameters(const GenParams &params)
43{
44 if (!params.secret.size()) {
45 setDtlsError(QDtlsError::InvalidInputParameters,
46 QDtls::tr("Invalid (empty) secret"));
47 return false;
48 }
49
50 clearDtlsError();
51
52 hashAlgorithm = params.hash;
53 secret = params.secret;
54
55 return true;
56}
57
58QDtlsClientVerifier::GeneratorParameters
59QDtlsBasePrivate::cookieGeneratorParameters() const
60{
61 return {hashAlgorithm, secret};
62}
63
64bool QDtlsBasePrivate::isDtlsProtocol(QSsl::SslProtocol protocol)
65{
66 switch (protocol) {
67QT_WARNING_PUSH
68QT_WARNING_DISABLE_DEPRECATED
69 case QSsl::DtlsV1_0:
70 case QSsl::DtlsV1_0OrLater:
71QT_WARNING_POP
72 case QSsl::DtlsV1_2:
73 case QSsl::DtlsV1_2OrLater:
74 return true;
75 default:
76 return false;
77 }
78}
79
80QT_END_NAMESPACE