CmpTlsBufferOpen (FUN)

FUNCTION CmpTlsBufferOpen : RTS_IEC_HANDLE

Create a TLS connection around any existing transport media. There are two buffers needed: a send and a receive buffer. Put the data received from the peer to the Rx buffer. The data written by the TLS implementation will be put to the Tx buffer. This buffer has to be sent to the peer after calling the connect, accept or write functions. Maybe after calling the read function the buffer has to be sent too. This depends on internal TLS protocol stuff (change of session keys etc) which may occur at any time. This will be indicated throuth the corresponding returned flag. The TLS connection will be established explicit by calling TSLConnect, or on the server side by calling the Accept function. If the handshaking hasn’t finished the read and write functions will internally finish the handshaking until the connection is established. The implementation will start writing at the beginning at each call. If the function indicated that the the data must be sent the next call will overwrite the data in the Tx buffer. So the caller must handle the data before calling the next TLS function. The buffers given here contain raw TLS protocol data. This data has to be transferred to the peer using a reliable way. The packages have to arrive completely and in the right order. Otherwise TLS won’t work. To read or to write the corresponding plaintext data use the TlsRead and TlsWrite functions. Handling is done as follows:

Received data:
  • The bytestrings pointer will point to the beginning of the data.

  • The bytestrings max length will hold the buffers size

  • The bytestrings length will hold the current available amount of data.

  • The function ResetRx will not change any of the byte string. Only the internal read position will be set to the beginning of the buffer

Transmit data:
  • The bytestrings pointer will point to the of the empty writing buffer.

  • The bytestrings max length will hold the buffer size

  • The bytestrings length will contain the amount of data written by the TLS implementation.

  • The function ResetTx will reset the internal write position. The length of the bytestring will be set to 0.

InOut:

Scope

Name

Type

Comment

Return

CmpTlsBufferOpen

RTS_IEC_HANDLE

The handle to the created TLS connection, or RTS_INVALID_HANDLE, if operation failed.

Input

hTlsContext

RTS_IEC_HANDLE

Handle to the TLS configuration context. Create by CmpTlsCreateContext

pRxBuffer

POINTER TO RtsByteString

Pointer to the buffer containing the data received from the peer.

pTxBuffer

POINTER TO RtsByteString

Pointer to the buffer containing the data to be sent to the peer.

pResult

POINTER TO RTS_IEC_RESULT

Result of this operation. Possible values:
  • ERR_OK: The TLS connection was created successful.

  • ERR_NOMEMORY: The TLS connection could not be created. No memory available

  • ERR_INVALID_HANDLE: The TLS connection could not be created. The given context handle is invalid.

  • ERR_PARAMETER: Some parameters where inconsistent or wrong.