QSslPreSharedKeyAuthenticator Class
La classe QSslPreSharedKeyAuthenticator fornisce i dati di autenticazione per le suite di cifratura con chiavi pre-condivise (PSK). Per saperne di più...
| Intestazione: | #include <QSslPreSharedKeyAuthenticator> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
- Elenco di tutti i membri, compresi quelli ereditati
- QSslPreSharedKeyAuthenticator fa parte dell'API di programmazione di rete e delle classi implicitamente condivise.
Nota: tutte le funzioni di questa classe sono rientranti.
Funzioni pubbliche
| 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) |
Elementi non membri correlati
| bool | operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
| bool | operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs) |
Descrizione dettagliata
La classe QSslPreSharedKeyAuthenticator viene utilizzata da un socket SSL per fornire i dati di autenticazione richiesti in una suite di cifratura con chiave pre-condivisa (PSK).
In un handshake PSK, il client deve derivare una chiave che deve corrispondere a quella impostata sul server. L'algoritmo esatto di derivazione della chiave dipende dall'applicazione; tuttavia, a questo scopo, il server può inviare un suggerimento di identità al client. Questo suggerimento, combinato con altre informazioni (ad esempio una passphrase), viene quindi utilizzato dal client per costruire la chiave condivisa.
QSslPreSharedKeyAuthenticator fornisce alle applicazioni client gli strumenti per completare l’handshake PSK. L’applicazione client deve collegare uno slot al segnale QSslSocket::preSharedKeyAuthenticationRequired():
connect(socket, &QSslSocket::preSharedKeyAuthenticationRequired,
this, &AuthManager::handlePreSharedKeyAuthentication);Il segnale trasporta un oggetto `QSslPreSharedKeyAuthenticator` contenente l’indicazione di identità inviata dal server al client, che deve essere popolato con l’identità del client corrispondente e la chiave derivata:
void AuthManager::handlePreSharedKeyAuthentication(QSslPreSharedKeyAuthenticator *authenticator)
{
authenticator->setIdentity("My Qt App");
const QByteArray key = deriveKey(authenticator->identityHint(), passphrase);
authenticator->setPreSharedKey(key);
}Nota: le suite di cifraturaPSK sono supportate solo quando si utilizza OpenSSL 1.0.1 (o versioni successive) come backend SSL.
Nota: il PSK è attualmente supportato solo in OpenSSL.
Vedi anche QSslSocket.
Documentazione delle funzioni membro
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator()
Crea un oggetto QSslPreSharedKeyAuthenticator predefinito.
L'identificatore di identità, l'identità e la chiave verranno inizializzati come array di byte vuoti; la lunghezza massima sia dell'identità che della chiave verrà inizializzata a 0.
QSslPreSharedKeyAuthenticator::QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator &authenticator)
Crea un oggetto QSslPreSharedKeyAuthenticator come copia di authenticator.
Vedi anche operator=().
[noexcept] QSslPreSharedKeyAuthenticator::~QSslPreSharedKeyAuthenticator()
Elimina l'oggetto “ QSslPreSharedKeyAuthenticator ”.
QByteArray QSslPreSharedKeyAuthenticator::identity() const
Restituisce l'identità del client PSK.
Vedi anche setIdentity().
QByteArray QSslPreSharedKeyAuthenticator::identityHint() const
Restituisce l'indicazione di identità PSK fornita dal server. L'interpretazione di tale indicazione è lasciata all'applicazione.
int QSslPreSharedKeyAuthenticator::maximumIdentityLength() const
Restituisce la lunghezza massima, in byte, dell'identità del client PSK.
Nota: è possibile impostare un'identità la cui lunghezza sia superiore a maximumIdentityLength(); in questo caso, solo i primi maximumIdentityLength() byte verranno effettivamente inviati al server.
Vedi anche ` setIdentity()`.
int QSslPreSharedKeyAuthenticator::maximumPreSharedKeyLength() const
Restituisce la lunghezza massima, in byte, della chiave pre-condivisa.
Nota: è possibile impostare una chiave la cui lunghezza sia superiore al valore di maximumPreSharedKeyLength(); in questo caso, solo i primi maximumPreSharedKeyLength() byte verranno effettivamente inviati al server.
Vedi anche ` setPreSharedKey()`.
QByteArray QSslPreSharedKeyAuthenticator::preSharedKey() const
Restituisce la chiave pre-condivisa.
Vedi anche setPreSharedKey().
void QSslPreSharedKeyAuthenticator::setIdentity(const QByteArray &identity)
Imposta l'identità del client PSK (da comunicare al server) su identity.
Nota: è possibile impostare un'identità la cui lunghezza sia superiore a maximumIdentityLength(); in questo caso, solo i primi maximumIdentityLength() byte verranno effettivamente inviati al server.
Vedi anche identity() e maximumIdentityLength().
void QSslPreSharedKeyAuthenticator::setPreSharedKey(const QByteArray &preSharedKey)
Imposta la chiave pre-condivisa su preSharedKey.
Nota: è possibile impostare una chiave la cui lunghezza sia superiore a maximumPreSharedKeyLength(); in questo caso, solo i primi maximumPreSharedKeyLength() byte verranno effettivamente inviati al server.
Vedi anche preSharedKey(), maximumPreSharedKeyLength() e QByteArray::fromHex().
[noexcept] void QSslPreSharedKeyAuthenticator::swap(QSslPreSharedKeyAuthenticator &other)
Sostituisce questo autenticatore con other. Questa operazione è molto veloce e non fallisce mai.
[noexcept] QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(QSslPreSharedKeyAuthenticator &&authenticator)
Move-assigns l'oggetto QSslPreSharedKeyAuthenticator authenticator a questo oggetto e restituisce un riferimento all'istanza spostata.
QSslPreSharedKeyAuthenticator &QSslPreSharedKeyAuthenticator::operator=(const QSslPreSharedKeyAuthenticator &authenticator)
Assegna l'oggetto " QSslPreSharedKeyAuthenticator " authenticator a questo oggetto e restituisce un riferimento alla copia.
Elementi correlati non membri
bool operator!=(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
Restituisce ` true ` se l'oggetto autenticatore ` lhs ` non è uguale a ` rhs`; in caso contrario, restituisce ` false `.
bool operator==(const QSslPreSharedKeyAuthenticator &lhs, const QSslPreSharedKeyAuthenticator &rhs)
Restituisce ` true ` se l'oggetto autenticatore lhs è uguale a rhs; in caso contrario, restituisce ` false `.
Due oggetti autenticatori sono uguali se e solo se hanno lo stesso suggerimento di identità, la stessa identità, la stessa chiave pre-condivisa, la stessa lunghezza massima per l’identità e la stessa lunghezza massima per la chiave pre-condivisa.
© 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.