Skip to content
Merged
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
33 changes: 16 additions & 17 deletions doc/dox_comments/header_files/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13938,9 +13938,11 @@ int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data,

\brief This function reads any early data from a client on resumption.
Call this function instead of wolfSSL_accept() or wolfSSL_accept_TLSv13()
to accept a client and read any early data in the handshake.
If there is no early data than the handshake will be processed as normal.
This function is only used with servers.
to accept a client and read any early data in the handshake. The function
should be invoked until wolfSSL_is_init_finished() returns true. Early data
may be sent by the client in multiple messsages. If there is no early data
then the handshake will be processed as normal. This function is only used
with servers.

\param [in,out] ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
\param [out] data a buffer to hold the early data read from client.
Expand All @@ -13951,7 +13953,7 @@ int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data,
not using TLSv1.3.
\return SIDE_ERROR if called with a client.
\return WOLFSSL_FATAL_ERROR if accepting a connection fails.
\return WOLFSSL_SUCCESS if successful.
\return Number of early data bytes read (may be zero).

_Example_
\code
Expand All @@ -13963,19 +13965,16 @@ int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data,
char buffer[80];
...

ret = wolfSSL_read_early_data(ssl, earlyData, sizeof(earlyData), &outSz);
if (ret != SSL_SUCCESS) {
err = wolfSSL_get_error(ssl, ret);
printf(“error = %d, %s\n”, err, wolfSSL_ERR_error_string(err, buffer));
}
if (outSz > 0) {
// early data available
}
ret = wolfSSL_accept_TLSv13(ssl);
if (ret != SSL_SUCCESS) {
err = wolfSSL_get_error(ssl, ret);
printf(“error = %d, %s\n”, err, wolfSSL_ERR_error_string(err, buffer));
}
do {
ret = wolfSSL_read_early_data(ssl, earlyData, sizeof(earlyData), &outSz);
if (ret < 0) {
err = wolfSSL_get_error(ssl, ret);
printf(“error = %d, %s\n”, err, wolfSSL_ERR_error_string(err, buffer));
}
if (outSz > 0) {
// early data available
}
} while (!wolfSSL_is_init_finished(ssl));
\endcode

\sa wolfSSL_write_early_data
Expand Down
1 change: 1 addition & 0 deletions src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -14357,6 +14357,7 @@ int wolfSSL_read_early_data(WOLFSSL* ssl, void* data, int sz, int* outSz)
if (!IsAtLeastTLSv1_3(ssl->version))
return BAD_FUNC_ARG;

*outSz = 0;
#ifndef NO_WOLFSSL_SERVER
if (ssl->options.side == WOLFSSL_CLIENT_END)
return SIDE_ERROR;
Expand Down
3 changes: 2 additions & 1 deletion tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -69268,6 +69268,7 @@ static int test_tls13_early_data(void)
ExpectFalse(wolfSSL_is_init_finished(ssl_s));
ExpectIntEQ(wolfSSL_read_early_data(ssl_s, msgBuf, sizeof(msgBuf),
&read), 0);
ExpectIntEQ(read, 0);
ExpectTrue(wolfSSL_is_init_finished(ssl_s));

ExpectIntEQ(wolfSSL_connect(ssl_c), WOLFSSL_SUCCESS);
Expand All @@ -69278,7 +69279,7 @@ static int test_tls13_early_data(void)
ExpectFalse(wolfSSL_is_init_finished(ssl_s));
ExpectIntEQ(wolfSSL_read_early_data(ssl_s, msgBuf, sizeof(msgBuf),
&read), 0);

ExpectIntEQ(read, 0);
ExpectTrue(wolfSSL_is_init_finished(ssl_s));

/* Read server 0.5-RTT data */
Expand Down