QSslPreSharedKeyAuthenticator Class
La clase QSslPreSharedKeyAuthenticator proporciona datos de autenticación para cifrados de claves precompartidas (PSK). Más...
| Cabecera: | #include <QSslPreSharedKeyAuthenticator> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network)target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
- Lista de todos los miembros, incluyendo los heredados
- QSslPreSharedKeyAuthenticator es parte de la API de Programación de Redes y Clases Implícitamente Compartidas.
Nota: Todas las funciones de esta clase son reentrantes.
Funciones Públicas
| 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) |
No miembros relacionados
| bool | operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
| bool | operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
Descripción detallada
La clase QSslPreSharedKeyAuthenticator es utilizada por un socket SSL para proporcionar los datos de autenticación requeridos en un cifrado de clave precompartida (PSK).
En un handshake PSK, el cliente debe derivar una clave, que debe coincidir con la clave establecida en el servidor. El algoritmo exacto para derivar la clave depende de la aplicación; sin embargo, para este propósito, el servidor puede enviar una pista de identidad al cliente. Esta pista, combinada con otra información (por ejemplo, una frase de contraseña), es utilizada por el cliente para construir la clave compartida.
El QSslPreSharedKeyAuthenticator proporciona los medios a las aplicaciones cliente para completar el handshake PSK. La aplicación cliente necesita conectar una ranura a la señal QSslSocket::preSharedKeyAuthenticationRequired():
connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired, this, &AuthManager::handlePreSharedKeyAuthentication);
La señal lleva un objeto QSslPreSharedKeyAuthenticator que contiene la pista de identidad que el servidor envió al cliente, y que debe rellenarse con la correspondiente identidad del cliente y la clave derivada:
void AuthManager::handlePreSharedKeyAuthentication(QSslPreSharedKeyAuthenticator *authenticator) { authenticator->setIdentity("My Qt App"); const QByteArray key = deriveKey(authenticator->identityHint(), passphrase); authenticator->setPreSharedKey(key); }
Nota: Los cifrados PSK sólo se admiten cuando se utiliza OpenSSL 1.0.1 (o superior) como backend SSL.
Nota: PSK sólo se admite actualmente en OpenSSL.
Véase también QSslSocket.
Documentación de las funciones miembro
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator()
Construye un objeto QSslPreSharedKeyAuthenticator por defecto.
La pista de identidad, la identidad y la clave se inicializarán como matrices de bytes vacías; la longitud máxima tanto para la identidad como para la clave se inicializará a 0.
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator &authenticator)
Construye un objeto QSslPreSharedKeyAuthenticator como una copia de authenticator.
Véase también operator=().
[noexcept] QSslPreSharedKeyAuthenticator::~QSslPreSharedKeyAuthenticator()
Destruye el objeto QSslPreSharedKeyAuthenticator.
QByteArray QSslPreSharedKeyAuthenticator::identity() const
Devuelve la identidad del cliente PSK.
Véase también setIdentity().
QByteArray QSslPreSharedKeyAuthenticator::identityHint() const
Devuelve la pista de identidad PSK proporcionada por el servidor. La interpretación de esta pista se deja a la aplicación.
int QSslPreSharedKeyAuthenticator::maximumIdentityLength() const
Devuelve la longitud máxima, en bytes, de la identidad PSK del cliente.
Nota: es posible establecer una identidad cuya longitud sea mayor que maximumIdentityLength(); en este caso, sólo se enviarán al servidor los primeros bytes de maximumIdentityLength().
Véase también setIdentity().
int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const
Devuelve la longitud máxima, en bytes, de la clave precompartida.
Nota: es posible establecer una clave cuya longitud sea mayor que maximumPreSharedKeyLength(); en este caso, sólo se enviarán realmente al servidor los primeros bytes de maximumPreSharedKeyLength().
Véase también setPreSharedKey().
QByteArray QSslPreSharedKeyAuthenticator::preSharedKey() const
Devuelve la clave precompartida.
Véase también setPreSharedKey().
void QSslPreSharedKeyAuthenticator::setIdentity(const QByteArray &identity)
Establece la identidad del cliente PSK (que se comunicará al servidor) en identity.
Nota: es posible establecer una identidad cuya longitud sea mayor que maximumIdentityLength(); en este caso, sólo se enviarán al servidor los primeros maximumIdentityLength() bytes.
Véase también identity() y maximumIdentityLength().
void QSslPreSharedKeyAuthenticator::setPreSharedKey(const QByteArray &preSharedKey)
Establece la clave precompartida en preSharedKey.
Nota: es posible establecer una clave cuya longitud sea mayor que maximumPreSharedKeyLength(); en este caso, sólo se enviarán realmente al servidor los primeros maximumPreSharedKeyLength() bytes.
Véase también preSharedKey(), maximumPreSharedKeyLength() y QByteArray::fromHex().
[noexcept] void QSslPreSharedKeyAuthenticator::swap(QSslPreSharedKeyAuthenticator &other)
Cambia este autentificador por other. Esta operación es muy rápida y nunca falla.
[noexcept] QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(QSslPreSharedKeyAuthenticator &&authenticator)
Mover-asigna el objeto QSslPreSharedKeyAuthenticator authenticator a este objeto, y devuelve una referencia a la instancia movida.
QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(const QSslPreSharedKeyAuthenticator &authenticator)
Asigna el objeto QSslPreSharedKeyAuthenticator authenticator a este objeto, y devuelve una referencia a la copia.
No miembros relacionados
bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
Devuelve true si el objeto autenticador lhs no es igual a rhs; false en caso contrario.
bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
Devuelve true si el objeto autenticador lhs es igual a rhs; false en caso contrario.
Dos objetos autenticadores son iguales si y sólo si tienen la misma pista de identidad, identidad, clave precompartida, longitud máxima para la identidad y longitud máxima para la clave precompartida.
© 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.