이 페이지에서

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 클래스는 SSL 소켓에서 사전 공유 키(PSK) 암호 모음에 필요한 인증 데이터를 제공하는 데 사용됩니다.

PSK 핸드셰이크에서 클라이언트는 서버에 설정된 키와 일치하는 키를 도출해야 합니다. 키를 도출하는 정확한 알고리즘은 애플리케이션에 따라 다르지만, 이를 위해 서버는 클라이언트에 신원 힌트를 보낼 수 있습니다. 클라이언트는 이 힌트를 다른 정보(예: 암호 문구)와 결합하여 공유 키를 구성합니다.

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 클라이언트 식별자를 반환합니다.

setIdentity()도 참조하십시오 .

QByteArray QSslPreSharedKeyAuthenticator::identityHint() const

서버에서 제공한 PSK 신원 힌트를 반환합니다. 이 힌트의 해석은 애플리케이션에 맡겨집니다.

int QSslPreSharedKeyAuthenticator::maximumIdentityLength() const

PSK 클라이언트 식별자의 최대 길이(바이트 단위)를 반환합니다.

참고: maximumIdentityLength()보다 긴 길이의 식별자를 설정할 수도있습니다 . 이 경우, 실제로 서버로 전송되는 것은 처음 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 을 반환합니다.

두 인증자 객체는 신원 힌트, 신원, 사전 공유 키, 신원의 최대 길이 및 사전 공유 키의 최대 길이가 모두 동일한 경우에만 서로 동일합니다.

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