Skip to content

Commit 50b39c9

Browse files
committed
fixup! (d)tls13: check if early data is possible in write_early_data
1 parent 7b9d374 commit 50b39c9

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

doc/dox_comments/header_files/ssl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14430,6 +14430,8 @@ int wolfSSL_set_max_early_data(WOLFSSL* ssl, unsigned int sz);
1443014430
\return BAD_FUNC_ARG if a pointer parameter is NULL, sz is less than 0 or
1443114431
not using TLSv1.3.
1443214432
\return SIDE_ERROR if called with a server.
14433+
\return BAD_STATE_E if invoked without a valid session or without a valid
14434+
PSK cb
1443314435
\return WOLFSSL_FATAL_ERROR if the connection is not made.
1443414436
\return the amount of early data written in bytes if successful.
1443514437

src/tls13.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14990,8 +14990,9 @@ int wolfSSL_get_max_early_data(WOLFSSL* ssl)
1499014990
* sz The size of the early data in bytes.
1499114991
* outSz The number of early data bytes written.
1499214992
* returns BAD_FUNC_ARG when: ssl, data or outSz is NULL; sz is negative;
14993-
* or not using TLS v1.3. SIDE ERROR when not a server. Otherwise the number of
14994-
* early data bytes written.
14993+
* or not using TLS v1.3. SIDE ERROR when not a server. BAD_STATE_E if invoked
14994+
* without a valid session or without a valid PSK CB.
14995+
* Otherwise the number of early data bytes written.
1499514996
*/
1499614997
int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data, int sz, int* outSz)
1499714998
{
@@ -15010,8 +15011,7 @@ int wolfSSL_write_early_data(WOLFSSL* ssl, const void* data, int sz, int* outSz)
1501015011

1501115012
/* Early data requires PSK or session resumption */
1501215013
if (!EarlyDataPossible(ssl)) {
15013-
ssl->error = BAD_STATE_E;
15014-
return WOLFSSL_FATAL_ERROR;
15014+
return BAD_STATE_E;
1501515015
}
1501615016

1501715017
if (ssl->options.handShakeState == NULL_STATE) {

tests/api/test_tls13.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,9 @@ int test_tls13_apis(void)
764764
ExpectIntEQ(wolfSSL_write_early_data(clientTls12Ssl, earlyData,
765765
sizeof(earlyData), &outSz), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
766766
#endif
767+
/* invoking without session or psk cbs */
767768
ExpectIntEQ(wolfSSL_write_early_data(clientSsl, earlyData,
768-
sizeof(earlyData), &outSz), WC_NO_ERR_TRACE(WOLFSSL_FATAL_ERROR));
769+
sizeof(earlyData), &outSz), WC_NO_ERR_TRACE(BAD_STATE_E));
769770
#endif
770771

771772
ExpectIntEQ(wolfSSL_read_early_data(NULL, earlyDataBuffer,

0 commit comments

Comments
 (0)