QCoapPrivateKey Class
The QCoapPrivateKey class provides an interface for managing CoAP security keys. More...
| Header: | #include <QCoapPrivateKey> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Coap)target_link_libraries(mytarget PRIVATE Qt6::Coap) |
| qmake: | QT += coap |
Public Functions
| QCoapPrivateKey() | |
| QCoapPrivateKey(const Qt::HANDLE &handle) | |
| QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray &passPhrase = QByteArray()) | |
| QCoapPrivateKey(const QCoapPrivateKey &other) | |
| QCoapPrivateKey(QCoapPrivateKey &&other) | |
| ~QCoapPrivateKey() | |
| QSsl::KeyAlgorithm | algorithm() const |
| QSsl::EncodingFormat | encodingFormat() const |
| Qt::HANDLE | handle() const |
| bool | isNull() const |
| QByteArray | key() const |
| QByteArray | passPhrase() const |
| void | swap(QCoapPrivateKey &other) |
| QCoapPrivateKey & | operator=(const QCoapPrivateKey &other) |
Detailed Description
A QCoapPrivateKey packages a private key used in negotiating CoAP connections securely. It holds the information required for authentication using pre-shared keys and X.509 certificates.
Security Considerations
QCoapPrivateKey stores the private key and its passphrase internally using general-purpose data types (QByteArray) that do not guarantee secure erasure of their contents from memory on destruction. This material may persist in freed heap pages, core dumps, swap files, or process memory after a QCoapPrivateKey object is destroyed or cleared. Because QByteArray is implicitly shared, copies of the key or passphrase may exist in several locations and cannot be wiped deterministically.
Where the security back-end supports it, constructing the key from a native handle (the Qt::HANDLE overload) keeps the key material outside Qt's general-purpose containers. Applications with strict requirements for credential hygiene should take this into account when deciding how and where to use QCoapPrivateKey.
Member Function Documentation
QCoapPrivateKey::QCoapPrivateKey()
Constructs an empty instance of QCoapPrivateKey.
QCoapPrivateKey::QCoapPrivateKey(const Qt::HANDLE &handle)
Constructs a QCoapPrivateKey from a native key handle.
QCoapPrivateKey::QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray &passPhrase = QByteArray())
Constructs a QCoapPrivateKey from the byte array key using the specified algorithm and encoding format.
If the key is encrypted then passPhrase is required to decrypt it.
QCoapPrivateKey::QCoapPrivateKey(const QCoapPrivateKey &other)
Copies the contents of other into this key, making the two keys identical.
[noexcept] QCoapPrivateKey::QCoapPrivateKey(QCoapPrivateKey &&other)
Move-constructs a QCoapPrivateKey, making it point to the same object as other was pointing to.
[noexcept] QCoapPrivateKey::~QCoapPrivateKey()
Releases any resources held by QCoapPrivateKey.
QSsl::KeyAlgorithm QCoapPrivateKey::algorithm() const
Returns the key algorithm.
QSsl::EncodingFormat QCoapPrivateKey::encodingFormat() const
Returns the encoding format of the key.
Qt::HANDLE QCoapPrivateKey::handle() const
Returns a pointer to the native key handle.
bool QCoapPrivateKey::isNull() const
Returns true if the private key is null, returns false otherwise.
QByteArray QCoapPrivateKey::key() const
Returns the encoded private key.
QByteArray QCoapPrivateKey::passPhrase() const
Returns the passphrase for the key.
[noexcept] void QCoapPrivateKey::swap(QCoapPrivateKey &other)
Swaps this private key with other. This operation is very fast and never fails.
QCoapPrivateKey &QCoapPrivateKey::operator=(const QCoapPrivateKey &other)
Copies the contents of other into this key, making the two keys identical.
Returns a reference to this QCoapPrivateKey.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.