Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4417,8 +4417,11 @@ if(WOLFSSL_EXAMPLES)
tests/api/test_dtls.c
tests/api/test_dtls13.c
tests/api/test_ssl_cert.c
tests/api/test_ssl_crl_ocsp.c
tests/api/test_ssl_pk.c
tests/api/test_ssl_ext.c
tests/api/test_ssl_rw.c
tests/api/test_ssl_hs.c
tests/api/test_ocsp.c
tests/api/test_evp.c
tests/api/test_tls_ext.c
Expand Down
152 changes: 152 additions & 0 deletions doc/dox_comments/header_files/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,45 @@ int wolfSSL_get_using_nonblock(WOLFSSL*);
*/
int wolfSSL_write(WOLFSSL* ssl, const void* data, int sz);

/*!
\ingroup IO

\brief This function writes sz bytes from the buffer, data, to the SSL
connection, ssl, and reports the number of bytes written. It is equivalent
to wolfSSL_write() except that the length written is returned through wr
and the return value only indicates success or failure. Whether a partial
write counts as success depends on WOLFSSL_MODE_ENABLE_PARTIAL_WRITE having
been set with wolfSSL_CTX_set_mode(); without it, anything short of the
full length is a failure.

\return 1 on success.
\return 0 on failure. Call wolfSSL_get_error() for the reason.

\param ssl pointer to the SSL session, created with wolfSSL_new().
\param data data buffer to write to the SSL connection.
\param sz number of bytes to write.
\param wr pointer that receives the number of bytes written. May be NULL.

_Example_
\code
WOLFSSL* ssl = 0;
char msg[] = "hello wolfssl!";
size_t written = 0;
...

if (wolfSSL_write_ex(ssl, msg, sizeof(msg), &written) != 1) {
// handle the failure, see wolfSSL_get_error()
}
\endcode

\sa wolfSSL_write
\sa wolfSSL_read_ex
\sa wolfSSL_CTX_set_mode
\sa wolfSSL_get_error
*/
int wolfSSL_write_ex(WOLFSSL* ssl, const void* data, size_t sz, size_t* wr);


/*!
\ingroup IO

Expand Down Expand Up @@ -2225,6 +2264,47 @@ int wolfSSL_write(WOLFSSL* ssl, const void* data, int sz);
*/
int wolfSSL_read(WOLFSSL* ssl, void* data, int sz);

/*!
\ingroup IO

\brief This function reads up to sz bytes of decrypted application data
from the SSL connection, ssl, into the buffer, data, and reports the number
of bytes read. It is equivalent to wolfSSL_read() except that the length
read is returned through rd and the return value only indicates whether any
application data was read.

\return 1 when application data was read.
\return 0 when no application data was read. Call wolfSSL_get_error() for
the reason.
\return BAD_FUNC_ARG when ssl is NULL and wolfSSL was built with
OPENSSL_EXTRA.

\param ssl pointer to the SSL session, created with wolfSSL_new().
\param data buffer to hold the data read.
\param sz size of the buffer in bytes.
\param rd pointer that receives the number of bytes read. May be NULL and
is only set when data was read.

_Example_
\code
WOLFSSL* ssl = 0;
char reply[1024];
size_t bytesRead = 0;
...

if (wolfSSL_read_ex(ssl, reply, sizeof(reply), &bytesRead) == 1) {
// "bytesRead" bytes returned into buffer "reply"
}
\endcode

\sa wolfSSL_read
\sa wolfSSL_write_ex
\sa wolfSSL_pending
\sa wolfSSL_get_error
*/
int wolfSSL_read_ex(WOLFSSL* ssl, void* data, size_t sz, size_t* rd);


/*!
\ingroup IO

Expand Down Expand Up @@ -2459,6 +2539,43 @@ void wolfSSL_free(WOLFSSL* ssl);
*/
int wolfSSL_shutdown(WOLFSSL* ssl);

/*!
Comment thread
SparkiDev marked this conversation as resolved.
\ingroup TLS

\brief This function sends a user_canceled alert to the peer and then
shuts the connection down by calling wolfSSL_shutdown(). It is used when
the application abandons a connection for its own reasons rather than
because of a protocol failure.

\return WOLFSSL_SUCCESS on successful shutdown.
\return WOLFSSL_SHUTDOWN_NOT_DONE when the peer has yet to send its
close notify alert. Call wolfSSL_shutdown() again to complete the
bidirectional shutdown.
\return WOLFSSL_FAILURE when ssl is NULL or the alert could not be sent.
Call wolfSSL_get_error() for the reason.
\return WOLFSSL_FATAL_ERROR when the shutdown that follows the alert
fails. Call wolfSSL_get_error() for the reason.

\param ssl pointer to the SSL session, created with wolfSSL_new().

_Example_
\code
int ret = 0;
WOLFSSL* ssl = 0;
...

ret = wolfSSL_SendUserCanceled(ssl);
if (ret != WOLFSSL_SUCCESS) {
// failed to shut the connection down, see wolfSSL_get_error()
}
\endcode

\sa wolfSSL_shutdown
\sa wolfSSL_get_error
*/
int wolfSSL_SendUserCanceled(WOLFSSL* ssl);


/*!
\ingroup IO

Expand Down Expand Up @@ -6760,6 +6877,39 @@ int wolfSSL_want_read(WOLFSSL* ssl);
*/
int wolfSSL_want_write(WOLFSSL* ssl);

/*!
\ingroup Debug

\brief This function reports which I/O operation, if any, the SSL session
is waiting on. It reflects the same state that wolfSSL_want_read() and
wolfSSL_want_write() report individually.

\return WOLFSSL_READING when the underlying I/O needs data to be read
before progress can be made.
\return WOLFSSL_WRITING when the underlying I/O needs data to be written
before progress can be made.
\return WOLFSSL_NOTHING when the session is not waiting on the underlying
I/O, or ssl is NULL.

\param ssl pointer to the SSL session, created with wolfSSL_new().

_Example_
\code
WOLFSSL* ssl = 0;
...

if (wolfSSL_want(ssl) == WOLFSSL_READING) {
// wait for the socket to become readable, then retry
}
\endcode

\sa wolfSSL_want_read
\sa wolfSSL_want_write
\sa wolfSSL_get_error
*/
int wolfSSL_want(WOLFSSL* ssl);


/*!
\ingroup Setup

Expand Down Expand Up @@ -8316,6 +8466,8 @@ int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
\return 0 will be returned upon failure. Call wolfSSL_get_error() for
the specific error code.
\return MEMORY_ERROR will be returned if a memory error was encountered.
\return BAD_FUNC_ARG will be returned when ssl is NULL, iovcnt is negative,
or iov is NULL with a non-zero iovcnt.
\return SSL_FATAL_ERROR will be returned upon failure when either an error
occurred or, when using non-blocking sockets, the SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE error was received and and the application needs to
Expand Down
11 changes: 11 additions & 0 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,17 @@ WC_RNG* wolfssl_make_rng(WC_RNG* rng, int* local)
#define WOLFSSL_SSL_SESS_INCLUDED
#include "src/ssl_sess.c"

/* Forward declarations for static functions that are defined in a file
* included later in this amalgamation but used by one included earlier. Keep
* them here, next to the includes, rather than inside the files that need
* them.
*
* x509GetIssuerFromCM() is defined in src/x509_str.c. */
#if defined(SESSION_CERTS) && defined(OPENSSL_EXTRA)
static int x509GetIssuerFromCM(WOLFSSL_X509 **issuer, WOLFSSL_CERT_MANAGER* cm,
WOLFSSL_X509 *x);
#endif

#define WOLFSSL_SSL_API_CERT_INCLUDED
#include "src/ssl_api_cert.c"

Expand Down
Loading
Loading