QSslPreSharedKeyAuthenticator Class

QSslPreSharedKeyAuthenticator クラスは、事前共有鍵 (PSK) 暗号スイート用の認証データを提供します。詳細...

ヘッダ #include <QSslPreSharedKeyAuthenticator>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

注意:このクラスの関数はすべてリエントラントです。

パブリック関数

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 クラスは、事前共有鍵 (PSK) 暗号スイートで必要な認証データを提供するために SSL ソケットで使用されます。

PSK ハンドシェイクでは、クライアントは鍵を導出しなければならず、それはサーバに設定されている鍵と一致しなければなりません。鍵を導出する正確なアルゴリズムはアプリケーションに依存するが、この目的のために、サーバはクライアントにIDヒントを送信することができる。このヒントは、他の情報(たとえばパスフレーズ)と組み合わされ、共有鍵を構築するためにクライアントによって使用される。

QSslPreSharedKeyAuthenticator は、PSK ハンドシェイクを完了するための手段をクライアントアプリケーションに提供する。クライアントアプリケーションは、スロットをQSslSocket::preSharedKeyAuthenticationRequired() シグナルに接続する必要がある:

    connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired,
            this, &AuthManager::handlePreSharedKeyAuthentication);

このシグナルは QSslPreSharedKeyAuthenticator オブジェクトを運び、サーバーがクライアントに送る ID のヒントを含み、対応するクライアントの ID と派生キーを埋めなければならない:

    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)

QSslPreSharedKeyAuthenticator オブジェクトをauthenticator のコピーとして構築します。

operator=()も参照してください

[noexcept] QSslPreSharedKeyAuthenticator::~QSslPreSharedKeyAuthenticator()

QSslPreSharedKeyAuthenticator オブジェクトを破棄する。

QByteArray QSslPreSharedKeyAuthenticator::identity() const

PSK クライアントの ID を返します。

setIdentity()も参照

QByteArray QSslPreSharedKeyAuthenticator::identityHint() const

サーバから提供された PSK ID ヒントを返す。このヒントの解釈はアプリケーションに任されています。

int QSslPreSharedKeyAuthenticator::maximumIdentityLength() const

PSK クライアント ID の最大長をバイト単位で返す。

この場合、実際にサーバに送信されるのは最初の maximumIdentityLength() バイトのみとなる。

setIdentity()も参照

int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const

事前共有鍵の最大長をバイト数で返す。

注意: maxPreSharedKeyLength() よりも大きな長さの鍵を設定することも可能です。 この場合、実際にサーバに送信されるのは最初の maxPreSharedKeyLength() バイトのみとなります。

setPreSharedKey()も参照

QByteArray QSslPreSharedKeyAuthenticator::preSharedKey() const

共有キーを返します。

setPreSharedKey()も参照

void QSslPreSharedKeyAuthenticator::setIdentity(const QByteArray &identity)

サーバに通知する)PSKクライアントIDをidentity に設定する。

注意: maximumIdentityLength() よりも長い長さのIDを設定することも可能である。この場合、最初の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)

Move-このオブジェクトにQSslPreSharedKeyAuthenticator オブジェクトauthenticator を割り当て、移動したインスタンスへの参照を返す。

QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(const QSslPreSharedKeyAuthenticator &authenticator)

QSslPreSharedKeyAuthenticator オブジェクトauthenticator をこのオブジェクトに割り当て、コピーへの参照を返します。

関連する非会員

bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)

認証子オブジェクトlhsrhs と等しくなければtrue を返し、そうでなければfalse を返す。

bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)

認証子オブジェクトlhsrhs と等しい場合はtrue を、そうでない場合はfalse を返す。

2つの認証子オブジェクトが等しいのは、IDヒント、ID、事前共有鍵、IDの最大長、事前共有鍵の最大長が同じ場合のみである。

© 2025 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.