forked from wolfSSL/wolfssl
tests: run test_wolfSSL_dtls_export() over UDP instead of TCP
This commit is contained in:
23
tests/api.c
23
tests/api.c
@ -6601,7 +6601,13 @@ static void test_wolfSSL_dtls_export(void)
|
||||
int msgSz = (int)XSTRLEN(msg);
|
||||
byte *session, *window;
|
||||
unsigned int sessionSz, windowSz;
|
||||
|
||||
#ifndef TEST_IPV6
|
||||
struct sockaddr_in peerAddr;
|
||||
#else
|
||||
struct sockaddr_in6 peerAddr;
|
||||
#endif /* TEST_IPV6 */
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
@ -6637,6 +6643,7 @@ static void test_wolfSSL_dtls_export(void)
|
||||
XMEMSET(&server_args, 0, sizeof(func_args));
|
||||
XMEMSET(&server_cbf, 0, sizeof(callback_functions));
|
||||
server_cbf.method = wolfDTLSv1_2_server_method;
|
||||
server_cbf.doUdp = 1;
|
||||
server_args.callbacks = &server_cbf;
|
||||
server_args.argc = 3; /* set loop_count to 3 */
|
||||
|
||||
@ -6653,15 +6660,25 @@ static void test_wolfSSL_dtls_export(void)
|
||||
wolfSSL_CTX_use_certificate_file(ctx, cliCertFile, SSL_FILETYPE_PEM));
|
||||
AssertIntEQ(WOLFSSL_SUCCESS,
|
||||
wolfSSL_CTX_use_PrivateKey_file(ctx, cliKeyFile, SSL_FILETYPE_PEM));
|
||||
tcp_connect(&sockfd, wolfSSLIP, server_args.signal->port, 0, 0, NULL);
|
||||
tcp_connect(&sockfd, wolfSSLIP, server_args.signal->port, 1, 0, NULL);
|
||||
AssertNotNull(ssl = wolfSSL_new(ctx));
|
||||
AssertIntEQ(wolfSSL_set_fd(ssl, sockfd), WOLFSSL_SUCCESS);
|
||||
|
||||
/* store server information connected too */
|
||||
XMEMSET(&peerAddr, 0, sizeof(peerAddr));
|
||||
#ifndef TEST_IPV6
|
||||
peerAddr.sin_family = AF_INET;
|
||||
AssertIntEQ(XINET_PTON(AF_INET, wolfSSLIP, &peerAddr.sin_addr),1);
|
||||
peerAddr.sin_port = XHTONS(server_args.signal->port);
|
||||
wolfSSL_dtls_set_peer(ssl, &peerAddr, sizeof(peerAddr));
|
||||
#else
|
||||
peerAddr.sin6_family = AF_INET6;
|
||||
AssertIntEQ(
|
||||
XINET_PTON(AF_INET6, wolfSSLIP, &peerAddr.sin6_addr),1);
|
||||
peerAddr.sin6_port = XHTONS(server_args.signal->port);
|
||||
#endif
|
||||
|
||||
AssertIntEQ(wolfSSL_dtls_set_peer(ssl, &peerAddr, sizeof(peerAddr)),
|
||||
WOLFSSL_SUCCESS);
|
||||
|
||||
AssertIntEQ(wolfSSL_connect(ssl), WOLFSSL_SUCCESS);
|
||||
AssertIntEQ(wolfSSL_dtls_export(ssl, NULL, &sessionSz), 0);
|
||||
@ -6680,6 +6697,8 @@ static void test_wolfSSL_dtls_export(void)
|
||||
AssertIntGT(wolfSSL_dtls_import(ssl, session, sessionSz), 0);
|
||||
AssertIntGT(wolfSSL_dtls_import(ssl, window, windowSz), 0);
|
||||
AssertIntEQ(wolfSSL_set_fd(ssl, sockfd), WOLFSSL_SUCCESS);
|
||||
AssertIntEQ(wolfSSL_dtls_set_peer(ssl, &peerAddr, sizeof(peerAddr)),
|
||||
WOLFSSL_SUCCESS);
|
||||
AssertIntEQ(wolfSSL_write(ssl, msg, msgSz), msgSz);
|
||||
AssertIntGE(wolfSSL_read(ssl, reply, sizeof(reply)), 0);
|
||||
AssertIntGT(wolfSSL_dtls_export_state_only(ssl, window, &windowSz), 0);
|
||||
|
Reference in New Issue
Block a user