forked from wolfSSL/wolfssl
DTLS 1.2: Test stateless server connection
This commit is contained in:
@ -24,6 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
|
#include <wolfssl/error-ssl.h>
|
||||||
#include <wolfssl/internal.h>
|
#include <wolfssl/internal.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#ifdef NO_INLINE
|
#ifdef NO_INLINE
|
||||||
@ -57,8 +58,6 @@ void DtlsResetState(WOLFSSL *ssl)
|
|||||||
ssl->keys.dtls_expected_peer_handshake_number = 0;
|
ssl->keys.dtls_expected_peer_handshake_number = 0;
|
||||||
ssl->keys.dtls_handshake_number = 0;
|
ssl->keys.dtls_handshake_number = 0;
|
||||||
|
|
||||||
ssl->msgsReceived.got_client_hello = 0;
|
|
||||||
|
|
||||||
/* Reset states */
|
/* Reset states */
|
||||||
ssl->options.serverState = NULL_STATE;
|
ssl->options.serverState = NULL_STATE;
|
||||||
ssl->options.clientState = NULL_STATE;
|
ssl->options.clientState = NULL_STATE;
|
||||||
@ -73,10 +72,6 @@ void DtlsResetState(WOLFSSL *ssl)
|
|||||||
|
|
||||||
#if defined(WOLFSSL_DTLS_CID)
|
#if defined(WOLFSSL_DTLS_CID)
|
||||||
|
|
||||||
#include <wolfssl/error-ssl.h>
|
|
||||||
#include <wolfssl/internal.h>
|
|
||||||
#include <wolfssl/ssl.h>
|
|
||||||
|
|
||||||
typedef struct ConnectionID {
|
typedef struct ConnectionID {
|
||||||
byte length;
|
byte length;
|
||||||
/* Ignore "nonstandard extension used : zero-sized array in struct/union"
|
/* Ignore "nonstandard extension used : zero-sized array in struct/union"
|
||||||
|
@ -35042,8 +35042,6 @@ static int DefTicketEncCb(WOLFSSL* ssl, byte key_name[WOLFSSL_TICKET_NAME_SZ],
|
|||||||
int inputSz = DTLS_HANDSHAKE_HEADER_SZ + length; /* build msg adds rec hdr */
|
int inputSz = DTLS_HANDSHAKE_HEADER_SZ + length; /* build msg adds rec hdr */
|
||||||
int recordHeaderSz = DTLS_RECORD_HEADER_SZ;
|
int recordHeaderSz = DTLS_RECORD_HEADER_SZ;
|
||||||
|
|
||||||
ssl->msgsReceived.got_client_hello = 0;
|
|
||||||
|
|
||||||
input = (byte*)XMALLOC(inputSz, ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
|
input = (byte*)XMALLOC(inputSz, ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
|
||||||
if (input == NULL)
|
if (input == NULL)
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
|
49
tests/api.c
49
tests/api.c
@ -56275,7 +56275,7 @@ static int test_wolfSSL_dtls_AEAD_limit(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WOLFSSL_DTLS13) && defined(WOLFSSL_SEND_HRR_COOKIE) && \
|
#if defined(WOLFSSL_DTLS) && \
|
||||||
defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(SINGLE_THREADED)
|
defined(HAVE_IO_TESTS_DEPENDENCIES) && !defined(SINGLE_THREADED)
|
||||||
static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl)
|
static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
@ -56331,36 +56331,57 @@ static void test_wolfSSL_dtls_send_ch(WOLFSSL* ssl)
|
|||||||
ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0);
|
ret = (int)send(fd, ch_msg, sizeof(ch_msg), 0);
|
||||||
AssertIntGT(ret, 0);
|
AssertIntGT(ret, 0);
|
||||||
/* consume the HRR otherwise handshake will fail */
|
/* consume the HRR otherwise handshake will fail */
|
||||||
ret = recv(fd, ch_msg, sizeof(ch_msg), 0);
|
ret = (int)recv(fd, ch_msg, sizeof(ch_msg), 0);
|
||||||
AssertIntGT(ret, 0);
|
AssertIntGT(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WOLFSSL_DTLS13) && defined(WOLFSSL_SEND_HRR_COOKIE)
|
||||||
static void test_wolfSSL_dtls_enable_hrrcookie(WOLFSSL* ssl)
|
static void test_wolfSSL_dtls_enable_hrrcookie(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = wolfSSL_send_hrr_cookie(ssl, NULL, 0);
|
ret = wolfSSL_send_hrr_cookie(ssl, NULL, 0);
|
||||||
AssertIntEQ(ret, WOLFSSL_SUCCESS);
|
AssertIntEQ(ret, WOLFSSL_SUCCESS);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int test_wolfSSL_dtls_stateless(void)
|
static int test_wolfSSL_dtls_stateless(void)
|
||||||
{
|
{
|
||||||
callback_functions client_cbs, server_cbs;
|
callback_functions client_cbs, server_cbs;
|
||||||
|
size_t i;
|
||||||
|
struct {
|
||||||
|
method_provider client_meth;
|
||||||
|
method_provider server_meth;
|
||||||
|
ssl_callback client_ssl_ready;
|
||||||
|
ssl_callback server_ssl_ready;
|
||||||
|
} test_params[] = {
|
||||||
|
{wolfDTLSv1_2_client_method, wolfDTLSv1_2_server_method,
|
||||||
|
test_wolfSSL_dtls_send_ch, NULL},
|
||||||
|
#if defined(WOLFSSL_DTLS13) && defined(WOLFSSL_SEND_HRR_COOKIE)
|
||||||
|
{wolfDTLSv1_3_client_method, wolfDTLSv1_3_server_method,
|
||||||
|
test_wolfSSL_dtls_send_ch, test_wolfSSL_dtls_enable_hrrcookie},
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
XMEMSET(&client_cbs, 0, sizeof(client_cbs));
|
printf(testingFmt, "test_wolfSSL_dtls_stateless");
|
||||||
XMEMSET(&server_cbs, 0, sizeof(server_cbs));
|
|
||||||
client_cbs.doUdp = server_cbs.doUdp = 1;
|
|
||||||
client_cbs.method = wolfDTLSv1_3_client_method;
|
|
||||||
server_cbs.method = wolfDTLSv1_3_server_method;
|
|
||||||
|
|
||||||
client_cbs.ssl_ready = test_wolfSSL_dtls_send_ch;
|
for (i = 0; i < sizeof(test_params)/sizeof(*test_params); i++) {
|
||||||
server_cbs.ssl_ready = test_wolfSSL_dtls_enable_hrrcookie;
|
XMEMSET(&client_cbs, 0, sizeof(client_cbs));
|
||||||
test_wolfSSL_client_server_nofail(&client_cbs, &server_cbs);
|
XMEMSET(&server_cbs, 0, sizeof(server_cbs));
|
||||||
|
client_cbs.doUdp = server_cbs.doUdp = 1;
|
||||||
|
client_cbs.method = test_params[i].client_meth;
|
||||||
|
server_cbs.method = test_params[i].server_meth;
|
||||||
|
|
||||||
if (!client_cbs.return_code)
|
client_cbs.ssl_ready = test_params[i].client_ssl_ready;
|
||||||
return -1;
|
server_cbs.ssl_ready = test_params[i].server_ssl_ready;
|
||||||
if (!server_cbs.return_code)
|
test_wolfSSL_client_server_nofail(&client_cbs, &server_cbs);
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
if (!client_cbs.return_code)
|
||||||
|
return -1;
|
||||||
|
if (!server_cbs.return_code)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(resultFmt, passed);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user