| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | // Qt-Security score:significant reason:default |
| 4 | |
| 5 | #ifndef QCOAPSECURITYCONFIGURATION_H |
| 6 | #define QCOAPSECURITYCONFIGURATION_H |
| 7 | |
| 8 | #include <QtCoap/qcoapglobal.h> |
| 9 | |
| 10 | #include <QtCore/qglobal.h> |
| 11 | #include <QtCore/QSharedDataPointer> |
| 12 | #include <QtNetwork/QSslCertificate> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | class QCoapPrivateKeyPrivate; |
| 17 | class Q_COAP_EXPORT QCoapPrivateKey |
| 18 | { |
| 19 | public: |
| 20 | QCoapPrivateKey(); |
| 21 | QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm, |
| 22 | QSsl::EncodingFormat format = QSsl::Pem, |
| 23 | const QByteArray &passPhrase = QByteArray()); |
| 24 | QCoapPrivateKey(const Qt::HANDLE &handle); |
| 25 | |
| 26 | QCoapPrivateKey(const QCoapPrivateKey& other); |
| 27 | QCoapPrivateKey(QCoapPrivateKey&& other) noexcept; |
| 28 | ~QCoapPrivateKey(); |
| 29 | |
| 30 | QCoapPrivateKey &operator=(QCoapPrivateKey &&other) noexcept |
| 31 | { swap(other); return *this; } |
| 32 | QCoapPrivateKey &operator=(const QCoapPrivateKey &other); |
| 33 | |
| 34 | void swap(QCoapPrivateKey &other) noexcept |
| 35 | { d.swap(other&: other.d); } |
| 36 | |
| 37 | bool isNull() const; |
| 38 | |
| 39 | QByteArray key() const; |
| 40 | Qt::HANDLE handle() const; |
| 41 | QSsl::KeyAlgorithm algorithm() const; |
| 42 | QSsl::EncodingFormat encodingFormat() const; |
| 43 | QByteArray passPhrase() const; |
| 44 | private: |
| 45 | QSharedDataPointer<QCoapPrivateKeyPrivate> d; |
| 46 | }; |
| 47 | |
| 48 | class QCoapSecurityConfigurationPrivate; |
| 49 | class Q_COAP_EXPORT QCoapSecurityConfiguration |
| 50 | { |
| 51 | public: |
| 52 | QCoapSecurityConfiguration(); |
| 53 | QCoapSecurityConfiguration(const QCoapSecurityConfiguration &other); |
| 54 | ~QCoapSecurityConfiguration(); |
| 55 | |
| 56 | QCoapSecurityConfiguration(QCoapSecurityConfiguration &&other) noexcept; |
| 57 | QCoapSecurityConfiguration &operator=(QCoapSecurityConfiguration &&other) noexcept |
| 58 | { swap(other); return *this; } |
| 59 | QCoapSecurityConfiguration &operator=(const QCoapSecurityConfiguration &other); |
| 60 | |
| 61 | void swap(QCoapSecurityConfiguration &other) noexcept |
| 62 | { d.swap(other&: other.d); } |
| 63 | |
| 64 | void setPreSharedKeyIdentity(const QByteArray &preSharedKeyIdentity); |
| 65 | QByteArray preSharedKeyIdentity() const; |
| 66 | |
| 67 | void setPreSharedKey(const QByteArray &preSharedKey); |
| 68 | QByteArray preSharedKey() const; |
| 69 | |
| 70 | void setDefaultCipherString(const QString &cipherString); |
| 71 | QString defaultCipherString() const; |
| 72 | |
| 73 | void setCaCertificates(const QList<QSslCertificate> &certificates); |
| 74 | QList<QSslCertificate> caCertificates() const; |
| 75 | |
| 76 | void setLocalCertificateChain(const QList<QSslCertificate> &localChain); |
| 77 | QList<QSslCertificate> localCertificateChain() const; |
| 78 | |
| 79 | void setPrivateKey(const QCoapPrivateKey &key); |
| 80 | QCoapPrivateKey privateKey() const; |
| 81 | |
| 82 | private: |
| 83 | QSharedDataPointer<QCoapSecurityConfigurationPrivate> d; |
| 84 | }; |
| 85 | |
| 86 | Q_DECLARE_SHARED(QCoapSecurityConfiguration) |
| 87 | |
| 88 | QT_END_NAMESPACE |
| 89 | |
| 90 | Q_DECLARE_METATYPE(QCoapSecurityConfiguration) |
| 91 | |
| 92 | #endif // QCOAPSECURITYCONFIGURATION_H |
| 93 |
