Top |
tlssep_status_t
tlssep_init (tlssep_context_t *context
);
This function initializes libtlssep and executes a network decorator in preparation for later creating a TLS session.
tlssep_status_t tlssep_connect (tlssep_context_t *context
,int file_descriptor
,const char *expected_name
,char *name
,tlssep_desc_t *desc
);
This function creates a TLS session by connecting over the given file descriptor. Most commonly, the file descriptor is a socket with an existing transport-layer connection to the remote host.
context |
a pointer to a valid tlssep_context_t |
|
file_descriptor |
the file descriptor upon which to create a TLS session; usually a network socket |
|
expected_name |
a pointer to NULL or a valid string representing the name (i.e., subject-common name or subject-alternative name) which is expected to be present in the remote certificate; what is done with this depends on the configured verification engine |
|
name |
if not NULL, this function will copy the remote certificate's name to this address; the buffer must be at least |
|
desc |
a pointer to a tlssep_desc_t which this function will initialize |
tlssep_status_t tlssep_accept (tlssep_context_t *context
,int file_descriptor
,const char *expected_name
,char *name
,tlssep_desc_t *desc
);
This function creates a TLS session by accepting on the given file descriptor. Most commonly, the file descriptor is a socket with an existing transport-layer connection to the remote host.
context |
a pointer to a valid tlssep_context_t |
|
file_descriptor |
the file descriptor upon which to create a TLS session; usually a network socket |
|
expected_name |
a pointer to NULL or a valid string representing the name (i.e., subject-common name or subject-alternative name) which is expected to be present in the remote certificate; what is done with this depends on the configured verification engine |
|
name |
if not NULL, this function will copy the remote certificate's name to this address; the buffer must be at least |
|
desc |
a pointer to a tlssep_desc_t which this function will initialize |
tlssep_status_t tlssep_write (tlssep_desc_t *desc
,const void *buf
,int buf_size
,int *bytes_written
);
This function passes a number of bytes to the network decorator which will encrypt the bytes before writing them to the TLS connection.
desc |
a pointer to a valid tlssep_desc_t |
|
buf |
some buffer of bytes to write |
|
buf_size |
the number of bytes to write from |
|
bytes_written |
a pointer to an integer which this function will set to the number of bytes actually written |
tlssep_status_t tlssep_read (tlssep_desc_t *desc
,void *buf
,int buf_size
,int *bytes_read
);
This function requests that a number of bytes will be read by the network decorator. The network decorator will decrypt the bytes read from the TLS connection before returning them to the application.
desc |
a pointer to a valid tlssep_desc_t |
|
buf |
a buffer which will hold any bytes read |
|
buf_size |
the size of |
|
bytes_read |
a pointer to an integer which this function will set to the number of bytes actually read |
tlssep_status_t tlssep_peek (tlssep_desc_t *desc
,void *buf
,int buf_size
,int *bytes_read
);
This function requests that a number of bytes will be read by the network decorator. The network decorator will decrypt the bytes read from the TLS connection before returning them to the application. Unlike with tlssep_read, the network decorator will not remove the bytes from its TLS buffer; thus subsequent tlssep_read/tlssep_peek calls will read the same bytes again.
desc |
a pointer to a valid tlssep_desc_t |
|
buf |
a buffer which will hold any bytes read |
|
buf_size |
the size of |
|
bytes_read |
a pointer to an integer which this function will set to the number of bytes actually read |
tlssep_status_t tlssep_poll (tlssep_desc_t *desc
,unsigned int timeout
);
This function blocks until there is data ready to be read from the TLS connection
up to the limit of timeout
seconds.
desc |
a pointer to a valid tlssep_desc_t |
|
timeout |
the number of seconds to wait for data before giving up |
tlssep_status_t
tlssep_setnonblock (tlssep_desc_t *desc
);
This function sets the mode of the network decorator’s TLS file descriptor to non-blocking.
tlssep_status_t
tlssep_close (tlssep_desc_t *desc
);
This function instructs the decorator to close the given TLS connection and remove its file descriptor from the select file descriptor set. The procedure also frees any state associated with the connection
tlssep_status_t
tlssep_terminate (tlssep_context_t *context
);
This function instructs the network decorator to exit.
char *
tlssep_strerror (tlssep_status_t error
);
This function transforms a tlssep_status_t into its string description.
Enum values used to specify status conditions.
typedef struct { } tlssep_context_t;
Maintains the state of a set of TLS connections, but contains no public fields. Initialize this structure by calling tlssep_init.
typedef struct { int notificationfd; } tlssep_desc_t;
Serves as the descriptor of a single TLS connection. An application can
poll the notificationFd
file descriptor to determine if there exists
data which can be read from the network decorator using tlssep_read.
Initialize this structure by calling tlssep_connect or tlssep_accept.