QSslPreSharedKeyAuthenticator Class
QSslPreSharedKeyAuthenticator クラスは、事前共有鍵(PSK)暗号スイート用の認証データを提供します。詳細...
| ヘッダー: | #include <QSslPreSharedKeyAuthenticator> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
- 継承されたメンバーを含む、すべてのメンバーの一覧
- QSslPreSharedKeyAuthenticator は、ネットワークプログラミング APIおよび暗黙的に共有されるクラスの一部です。
注:このクラスのすべての関数は再入可能です。
パブリック関数
| QSslPreSharedKeyAuthenticator() | |
| QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator &authenticator) | |
| ~QSslPreSharedKeyAuthenticator() | |
| QByteArray | identity() const |
| QByteArray | identityHint() const |
| int | maximumIdentityLength() const |
| int | maximumPreSharedKeyLength() const |
| QByteArray | preSharedKey() const |
| void | setIdentity(const QByteArray &identity) |
| void | setPreSharedKey(const QByteArray &preSharedKey) |
| void | swap(QSslPreSharedKeyAuthenticator &other) |
| QSslPreSharedKeyAuthenticator & | operator=(QSslPreSharedKeyAuthenticator &&authenticator) |
| QSslPreSharedKeyAuthenticator & | operator=(const QSslPreSharedKeyAuthenticator &authenticator) |
関連する非メンバー
| bool | operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
| bool | operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
詳細な説明
QSslPreSharedKeyAuthenticator クラスは、SSL ソケットによって使用され、事前共有鍵 (PSK) 暗号スイートで必要な認証データを提供します。
PSK ハンドシェイクでは、クライアントはキーを導出する必要があり、そのキーはサーバーで設定されたキーと一致している必要があります。 鍵の導出に用いられる具体的なアルゴリズムはアプリケーションによって異なりますが、この目的のために、サーバーはクライアントにID ヒントを送信する場合があります。このヒントは、他の情報(パスフレーズなど)と組み合わせて、クライアントが共有鍵を構築するために使用されます。
`QSslPreSharedKeyAuthenticator` は、クライアントアプリケーションが PSK ハンドシェイクを完了するための手段を提供します。クライアントアプリケーションは、QSslSocket::preSharedKeyAuthenticationRequired() シグナルにスロットを接続する必要があります:
connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired,
this, &AuthManager::handlePreSharedKeyAuthentication);このシグナルは、サーバーからクライアントに送信された識別情報ヒントを含むQSslPreSharedKeyAuthenticatorオブジェクトを伝送します。このオブジェクトには、対応するクライアント識別情報と導出された鍵を格納する必要があります:
void AuthManager::handlePreSharedKeyAuthentication(QSslPreSharedKeyAuthenticator *authenticator)
{
authenticator->setIdentity("My Qt App");
const QByteArray key = deriveKey(authenticator->identityHint(), passphrase);
authenticator->setPreSharedKey(key);
}注:PSK 暗号スイートは、SSL バックエンドとして OpenSSL 1.0.1(またはそれ以降)を使用している場合にのみサポートされます。
注:PSKは 現在、OpenSSLでのみサポートされています。
QSslSocketも参照してください 。
メンバ関数のドキュメント
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator()
デフォルトの QSslPreSharedKeyAuthenticator オブジェクトを生成します。
IDヒント、ID、およびキーは空のバイト配列として初期化され、IDとキーの両方の最大長は0として初期化されます。
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator &authenticator)
authenticator のコピーとして QSslPreSharedKeyAuthenticator オブジェクトを生成します。
operator=()も参照してください 。
[noexcept] QSslPreSharedKeyAuthenticator::~QSslPreSharedKeyAuthenticator()
QSslPreSharedKeyAuthenticator オブジェクトを破棄します。
QByteArray QSslPreSharedKeyAuthenticator::identity() const
PSKクライアントのIDを返します。
setIdentity()も参照してください 。
QByteArray QSslPreSharedKeyAuthenticator::identityHint() const
サーバーから提供されたPSK識別子ヒントを返します。このヒントの解釈はアプリケーションに委ねられます。
int QSslPreSharedKeyAuthenticator::maximumIdentityLength() const
PSKクライアントIDの最大長(バイト単位)を返します。
注: maximumIdentityLength() より長い長さの ID を設定することは可能ですが 、その場合は、実際にサーバーに送信されるのは最初の maximumIdentityLength() バイトのみとなります。
setIdentity()も参照してください 。
int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const
事前共有鍵の最大長(バイト単位)を返します。
注: `maximumPreSharedKeyLength()` を超える長さのキーを設定することは可能ですが 、その場合は、実際にサーバーへ送信されるのは最初の `maximumPreSharedKeyLength()` バイトのみとなります。
setPreSharedKey()も参照してください 。
QByteArray QSslPreSharedKeyAuthenticator::preSharedKey() const
事前共有鍵を返します。
setPreSharedKey()も参照してください 。
void QSslPreSharedKeyAuthenticator::setIdentity(const QByteArray &identity)
PSKクライアントの識別子(サーバーに通知されるもの)を「identity 」に設定します。
注: maximumIdentityLength() より長い識別子を設定することも可能ですが 、その場合は、最初のmaximumIdentityLength() バイトのみが実際にサーバーに送信されます。
identity() およびmaximumIdentityLength()も参照してください 。
void QSslPreSharedKeyAuthenticator::setPreSharedKey(const QByteArray &preSharedKey)
事前共有鍵を `preSharedKey` に設定します。
注: maximumPreSharedKeyLength() より長い鍵を設定することも可能ですが 、その場合は、最初のmaximumPreSharedKeyLength() バイトのみが実際にサーバーに送信されます。
preSharedKey()、maximumPreSharedKeyLength()、およびQByteArray::fromHex()も参照してください 。
[noexcept] void QSslPreSharedKeyAuthenticator::swap(QSslPreSharedKeyAuthenticator &other)
この認証情報をother と置き換えます。この操作は非常に高速で、失敗することはありません。
[noexcept] QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(QSslPreSharedKeyAuthenticator &&authenticator)
QSslPreSharedKeyAuthenticator オブジェクト `authenticator ` をこのオブジェクトに「移動代入」し、移動されたインスタンスへの参照を返します。
QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(const QSslPreSharedKeyAuthenticator &authenticator)
このオブジェクトにQSslPreSharedKeyAuthenticator オブジェクト `authenticator ` を割り当て、そのコピーへの参照を返します。
関連する非メンバー関数
bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
認証オブジェクト `lhs ` が `rhs` と等しくない場合は `true ` を返し、それ以外の場合は `false ` を返します。
bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
認証オブジェクト `lhs ` が `rhs` と等しい場合は `true ` を返し、それ以外の場合は `false ` を返します。
2つの認証オブジェクトが等しいのは、アイデンティティ・ヒント、アイデンティティ、事前共有鍵、アイデンティティの最大長、および事前共有鍵の最大長がすべて同じである場合に限られる。
© 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.