Add multi-session tickets test
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 050d518..3550c67 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -1139,7 +1139,7 @@
else if( strcmp( p, "tickets" ) == 0 )
{
opt.tickets = atoi( q );
- if( opt.tickets < 0 || opt.tickets > 2 )
+ if( opt.tickets < 0 )
goto usage;
}
else if( strcmp( p, "alpn" ) == 0 )
@@ -2668,6 +2668,9 @@
*/
if( opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM )
{
+#if defined(MBEDTLS_SSL_PROTO_TLS1_3) && defined(MBEDTLS_SSL_SESSION_TICKETS)
+ int ticket_id = 0;
+#endif
do
{
len = sizeof( buf ) - 1;
@@ -2715,7 +2718,8 @@
case MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET:
/* We were waiting for application data but got
* a NewSessionTicket instead. */
- mbedtls_printf( " got new session ticket.\n" );
+ mbedtls_printf( " got new session ticket ( %d ).\n",
+ ticket_id++ );
if( opt.reconnect != 0 )
{
mbedtls_printf(" . Saving session for reuse..." );
@@ -2749,7 +2753,6 @@
(unsigned) session_data_len );
}
}
-
continue;
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index a1b2978..ff63fdd 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -1997,7 +1997,7 @@
else if( strcmp( p, "tickets" ) == 0 )
{
opt.tickets = atoi( q );
- if( opt.tickets < 0 || opt.tickets > 1 )
+ if( opt.tickets < 0 )
goto usage;
}
else if( strcmp( p, "ticket_rotate" ) == 0 )
@@ -2915,7 +2915,7 @@
#endif
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
- if( opt.tickets == MBEDTLS_SSL_SESSION_TICKETS_ENABLED )
+ if( opt.tickets != MBEDTLS_SSL_SESSION_TICKETS_DISABLED )
{
if( ( ret = mbedtls_ssl_ticket_setup( &ticket_ctx,
rng_get, &rng,
@@ -2930,7 +2930,9 @@
mbedtls_ssl_ticket_write,
mbedtls_ssl_ticket_parse,
&ticket_ctx );
-
+#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
+ mbedtls_ssl_conf_new_session_tickets( &conf, opt.tickets );
+#endif
/* exercise manual ticket rotation (not required for typical use)
* (used for external synchronization of session ticket encryption keys)
*/