TrustCore SDK NanoSSL API reference  version 7.0
Core (Async and Sync) Server Callbacks

Customizable asynchronous and synchronous NanoSSL server callbacks. More...

Variables

sbyte4(* sslSettings::funcPtrGetHintPSK )(sbyte4 connectionInstance, ubyte hintPSK[SSL_PSK_SERVER_IDENTITY_LENGTH], ubyte4 *pRetHintLength)
 Retrieve a server's preferred PSK. More...
 
sbyte4(* sslSettings::funcPtrLookupPSK )(sbyte4 connectionInstance, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte retPSK[SSL_PSK_MAX_LENGTH], ubyte4 *pRetLengthPSK)
 Retrieve a (based on the provided PSK's name/identity) the preferred PSK. More...
 
sbyte4(* sslSettings::funcPtrLookupPSKParams )(sbyte4 connectionInstance, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte **pPsk, ubyte4 *pPskLen, intBoolean *pFreeMemory)
 Retrieve a (based on the provided PSK's name/identity) the preferred PSK params. More...
 
sbyte4(* sslSettings::funcPtrServerDeletePSK )(sbyte4 connectionInstance, sbyte *pServerName, ubyte4 serverNameLen, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte *pPskParams)
 Save server's preferred PSK. More...
 
sbyte4(* sslSettings::funcPtrServerSavePSK )(sbyte4 connectionInstance, ubyte *pServerName, ubyte4 serverNameLen, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte *pPsk, ubyte4 pskLen)
 Save server's preferred PSK. More...
 

Detailed Description

The following callbacks can be customized for your application:

Variable Documentation

◆ funcPtrGetHintPSK

sbyte4(* sslSettings::funcPtrGetHintPSK) (sbyte4 connectionInstance, ubyte hintPSK[SSL_PSK_SERVER_IDENTITY_LENGTH], ubyte4 *pRetHintLength)

This callback function returns a hint through the hintPSK parameter indicating the server's preferred PSK. To abort the session, the function should return an error code (a negative value) instead of DISPLAY_ERROR (0).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Note
If this function isn't defined, no hint can be returned to the client.
Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_PSK_SUPPORT__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
hintPSKOn return, the server's preferred PSK.
pRetHintLengthOn return, pointer to number of bytes (excluding any terminating NULL) in hintPSK.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured for PSK support.

ssl.h

◆ funcPtrLookupPSK

sbyte4(* sslSettings::funcPtrLookupPSK) (sbyte4 connectionInstance, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte retPSK[SSL_PSK_MAX_LENGTH], ubyte4 *pRetLengthPSK)

This callback function looks up the specified identity (the PSK's name) and returns its preferred PSK — the secret used to encrypt data — through the retPSK parameter. To abort the session, the function should return an error code (a negative value) instead of DISPLAY_ERROR (0).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_PSK_SUPPORT__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
pIdentityPSKPointer to buffer containing the PSK identity to look up.
identityLengthPSKNumber of bytes in PSK identity (pIdentityPSK).
retPSKOn return, buffer containing the identity's PSK.
pRetLengthPSKOn return, pointer to number of bytes in identity's PSK (retPSK).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured for PSK support.

ssl.h

◆ funcPtrLookupPSKParams

sbyte4(* sslSettings::funcPtrLookupPSKParams) (sbyte4 connectionInstance, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte **pPsk, ubyte4 *pPskLen, intBoolean *pFreeMemory)

This callback function looks up the specified identity (the PSK's name) and returns its preferred PSK — the secret used to encrypt data — through the retPSK parameter. To abort the session, the function should return an error code (a negative value) instead of DISPLAY_ERROR (0).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_PSK_SUPPORT__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
pIdentityPSKPointer to buffer containing the PSK identity to look up.
identityLengthPSKNumber of bytes in PSK identity (pIdentityPSK).
pPskOn return, Pointer to serialized tls13PSK structure.
pFreeMemoryShould stack free the memory of PSK. Application sets this value when the callback is invoked. If set to true, stack frees the memory. If set to FALSE, it is application's responsibility to free the memory.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured for PSK support.

ssl.h

◆ funcPtrServerDeletePSK

sbyte4(* sslSettings::funcPtrServerDeletePSK) (sbyte4 connectionInstance, sbyte *pServerName, ubyte4 serverNameLen, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte *pPskParams)

This callback function updates the existing psk To abort the session, the function should return an error code (a negative value) instead of DISPLAY_ERROR (0).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Note
If this function isn't defined, no hint can be returned to the client.
Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_PSK_SUPPORT__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
pServerNameName of the server.
serverNameLenLength of the server name.
pIdentityPSKPointer to buffer containing the PSK identity to look up.
identityLengthPSKNumber of bytes in PSK identity (pIdentityPSK).
pPskParamsSerialized tls13PSk structure.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured for PSK support.

ssl.h

◆ funcPtrServerSavePSK

sbyte4(* sslSettings::funcPtrServerSavePSK) (sbyte4 connectionInstance, ubyte *pServerName, ubyte4 serverNameLen, ubyte *pIdentityPSK, ubyte4 identityLengthPSK, ubyte *pPsk, ubyte4 pskLen)

This callback function saves associated paramter with psk server's preferred PSK. To abort the session, the function should return an error code (a negative value) instead of DISPLAY_ERROR (0).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Note
If this function isn't defined, no hint can be returned to the client.
Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_PSK_SUPPORT__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
pServerNameName of the server.
serverNameLenLength of the server name.
pIdentityPSKPointer to buffer containing the PSK identity to look up.
identityLengthPSKNumber of bytes in PSK identity (pIdentityPSK).
pPskSerialized tls13PSk structure.
pskLenLength of PSK.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured for PSK support.

ssl.h