TrustCore SDK NanoSSL API reference  version 7.0
Ungrouped Functions

NanoSSL functions that aren't part of any other function group. More...

Functions

MOC_EXTERN MSTATUS SSL_deserializePSK (ubyte *pPsk, ubyte4 pskLen, tls13PSK **ppRetPsk)
 Deserialize TLS 1.3 PSK. More...
 
MOC_EXTERN MSTATUS SSL_freePSK (tls13PSK **ppPsk)
 Free TLS 1.3 PSK. More...
 
MOC_EXTERN sbyte4 SSL_getSelectedApplicationProtocol (sbyte4 connectionInstance, const ubyte **selectedApplicationProtocol, ubyte4 *selectedApplicationProtocolLen)
 Retrieve the selected Application Layer Protocol. More...
 
MOC_EXTERN sbyte4 SSL_getSSLTLSVersion (sbyte4 connectionInstance, ubyte4 *pVersion)
 Get a connection's SSL/TLS version. More...
 
MOC_EXTERN MSTATUS SSL_serializePSK (tls13PSK *pPsk, ubyte **ppPsk, ubyte4 *pPskLen)
 Serialize TLS 1.3 PSK. More...
 
MOC_EXTERN sbyte4 SSL_setApplicationLayerProtocol (sbyte4 connectionInstance, sbyte4 numNextProtocols, const char **nextProtocols)
 Set the Application Layer Protocol Negotiation information. More...
 
MOC_EXTERN MSTATUS SSL_setClientCAList (SizedBuffer *pClientCAList, ubyte4 numClientCANames)
 Set the CA list that will be sent as part of Certificate Request message. More...
 
MOC_EXTERN sbyte4 SSL_setEarlyData (sbyte4 connectionInstance, ubyte *pEarlyData, ubyte4 earlyDataSize)
 Set the max early data. More...
 
MOC_EXTERN sbyte4 SSL_setMaxEarlyDataSize (sbyte4 connectionInstance, sbyte4 earlyDataSize)
 Set the max early data size. More...
 
MOC_EXTERN sbyte4 SSL_setRecvEarlyDataSize (sbyte4 connectionInstance, sbyte4 recvEarlyDataSize)
 Set the recv early data size. More...
 

Detailed Description

Function Documentation

◆ SSL_deserializePSK()

MOC_EXTERN MSTATUS SSL_deserializePSK ( ubyte *  pPsk,
ubyte4  pskLen,
tls13PSK **  ppRetPsk 
)

This function takes in a serialized ASN.1 TLS 1.3 PSK encoding and converts it into a NanoSSL TLS 1.3 PSK object. The allocated PSK object must be freed by the caller.

The PSK ASN.1 encoding is required to be

SEQUENCE
  INTEGER      version
  INTEGER      isExternal
  INTEGER      isPSKavailable
  INTEGER      pskTLS13LifetimeHint
  INTEGER      pskTLS13AgeAdd
  OCTETSTRING  ticketNonce
  OCTETSTRING  pskTLS13
  INTEGER      obfuscatedTicketAge
  INTEGER      hashAlgo
  UTCTIME      startTime
  INTEGER      maxEarlyDataSize
  INTEGER      pSelectedTlsVersion
  OCTETSTRING  selectedALPN
  INTEGER      selectedCipherSuiteId
Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__

ssl.h

Parameters
pPskPointer to the PSK to deserialize.
pskLenLength of the PSK to deserialize.
ppRetPskLocation at which the new PSK object will be stored.
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.

ssl.c

◆ SSL_freePSK()

MOC_EXTERN MSTATUS SSL_freePSK ( tls13PSK **  ppPsk)

This function free a TLS 1.3 PSK structure.

Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__

ssl.h

Parameters
ppPskLocation at which the serialized PSK pointer is freed.
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.

ssl.c

◆ SSL_getSelectedApplicationProtocol()

MOC_EXTERN sbyte4 SSL_getSelectedApplicationProtocol ( sbyte4  connectionInstance,
const ubyte **  selectedApplicationProtocol,
ubyte4 *  selectedApplicationProtocolLen 
)

This function retrieves the index of the selected application layer protocol, and returns it in the .

Since
6.5 (added in commit [e6173b4], March 21, 2016)
Version
6.5 and later

Please review the function and param descriptions to ensure that the Tech Pubs edits are ok.

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
selectedApplicationProtocolOn input, application protocol to search for. On return, pointer to matching socket.
selectedApplicationProtocolLenOn input, length (number of bytes) in the string representing the selected application protocol (selected ApplicationProtocol). On return, pointer to length of string representing the mathcing socket.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c

◆ SSL_getSSLTLSVersion()

MOC_EXTERN sbyte4 SSL_getSSLTLSVersion ( sbyte4  connectionInstance,
ubyte4 *  pVersion 
)

This function retrieves the specified connection's SSL/TLS version.

(is this for sync and/or async, client and/or server?)

Since
2.02
Version
2.02 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
pVersionOn return, pointer to the connection's SSL version.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c

◆ SSL_serializePSK()

MOC_EXTERN MSTATUS SSL_serializePSK ( tls13PSK *  pPsk,
ubyte **  ppPsk,
ubyte4 *  pPskLen 
)

This function takes in a NanoSSL TLS 1.3 PSK object and serializes the data into an ASN.1 encoded byte array. The allocated array must be freed by the caller.

The PSK ASN.1 encoding will be output as follows

SEQUENCE
  INTEGER      version
  INTEGER      isExternal
  INTEGER      isPSKavailable
  INTEGER      pskTLS13LifetimeHint
  INTEGER      pskTLS13AgeAdd
  OCTETSTRING  ticketNonce
  OCTETSTRING  pskTLS13
  INTEGER      obfuscatedTicketAge
  INTEGER      hashAlgo
  UTCTIME      startTime
  INTEGER      maxEarlyDataSize
  INTEGER      pSelectedTlsVersion
  OCTETSTRING  selectedALPN
  INTEGER      selectedCipherSuiteId
Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__

ssl.h

Parameters
pPskPSK object to serialize.
ppPskLocation at which the new serialized PSK pointer will be stored.
pPskLenLocation at which the length of the serialized PSK will be stored.
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.

ssl.c

◆ SSL_setApplicationLayerProtocol()

MOC_EXTERN sbyte4 SSL_setApplicationLayerProtocol ( sbyte4  connectionInstance,
sbyte4  numNextProtocols,
const char **  nextProtocols 
)

This function sets (defines) the application layer protocols to use during connection negotiations.

Since
6.5
Version
6.5 and later

Please review the function and param descriptions to ensure that the Tech Pubs edits are ok.

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
numNextProtocolsNumber of elements in the nextProtocols array of protocols to use.
nextProtocolsArray of protocols to use, in order of preference.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c

◆ SSL_setClientCAList()

MOC_EXTERN MSTATUS SSL_setClientCAList ( SizedBuffer *  pClientCAList,
ubyte4  numClientCANames 
)

This function sets CA list sent as part of Certificate Request message during connection negotiations. Client should send a certificate who issuer is one in the CA list

Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

ssl.h

Parameters
pClientCAListList of CA Names. This is a SizedBuffer list, where data of each element contains the CA X509 Name and length contains the length of X509 Name
numClientCANamesNumber of CA Names in the list.
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
This function is applicable to synchronous and asynchronous servers.

ssl.c

◆ SSL_setEarlyData()

MOC_EXTERN sbyte4 SSL_setEarlyData ( sbyte4  connectionInstance,
ubyte *  pEarlyData,
ubyte4  earlyDataSize 
)

This function sets the early data which should be sent if 0-RTT is being used. The early data is not copied. It is a shallow copy. Application owns the memory.

Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__
  • __ENABLE_MOCANA_TLS13_0RTT__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
pEarlyDataEarly data to set.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c

◆ SSL_setMaxEarlyDataSize()

MOC_EXTERN sbyte4 SSL_setMaxEarlyDataSize ( sbyte4  connectionInstance,
sbyte4  earlyDataSize 
)

This function sets (defines) the max early data size use during connection negotiations.

Since
6.5
Version
6.5 and later

Please review the function and param descriptions to ensure that the Tech Pubs edits are ok.

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

Additionally, the following flags must be defined:

  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__
  • __ENABLE_MOCANA_TLS13_0RTT__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
earlyDataSizemax early data size to set.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c

◆ SSL_setRecvEarlyDataSize()

MOC_EXTERN sbyte4 SSL_setRecvEarlyDataSize ( sbyte4  connectionInstance,
sbyte4  recvEarlyDataSize 
)

This function sets the recv early data size for the server. Server can recieve early Data of size less than or equal to this value. MaxEarlyDataSize per session should be less than or equal to this value

Since
6.5
Version
6.5 and later

To enable this function, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__

Additionally, the following flags must be defined:

  • __ENABLE_MOCANA_TLS13__
  • __ENABLE_MOCANA_TLS13_PSK__
  • __ENABLE_MOCANA_TLS13_0RTT__

ssl.h

Parameters
connectionInstanceConnection instance returned from SSL_connect().
earlyDataSizerecv early data size to set.
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
This function is applicable to synchronous and asynchronous clients and servers.

ssl.c