How do I generate and use PSK with TLS v1.3 in NanoSSL?
less than a minute
Question: How do I generate and use PSK in TLS v1.3 in NanoSSL?
Answer: To enable generation and use of PSK in TLS v1.3:
- Request a session ticket in the new connection.where
SSL_ioctl(connectionInstance, SSL_REQUEST_SESSION_TICKET, &requestTicket)requestTicket=1. - Define and register a callback to save the PSK.
SSL_setClientSavePSKCallback(sbyte4 connectionInstance, sbyte4 (*cb) (sbyte4 connectionInstance, sbyte* ServerInfo, ubyte4 serverInfoLen, void *userData, ubyte *pPsk, ubyte4 pskLen)) - For subsequent connections, use the saved PSK to establish a connection:
- Set the PSK key exchange modes. SSL_ioctl(connectionInstance, SSL_PSK_KEY_EXCHANGE_MODE, &pskMode)
- Define and register a callback to retrieve the PSK. SSL_CLIENT_setRetrievePSKCallback(sbyte4 connectionInstance, sbyte4 (cb) (sbyte4 connectionInstance, sbyte ServerInfo, ubyte4 serverInfoLen, void *userData, void **ppPSKs, ubyte2 pNumPSKs,ubyte selectedIndex, intBoolean *pFreeMemory)
Was this page helpful?
Provide feedback