Move the renamed typedef statements to ssl_helpers.h
With this change, the renamed typedef statements (commit de3caee)
are moved from test_suite_ssl.function into ssl_helpers.h
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/tests/include/test/ssl_helpers.h b/tests/include/test/ssl_helpers.h
index 0209f47..a292def 100644
--- a/tests/include/test/ssl_helpers.h
+++ b/tests/include/test/ssl_helpers.h
@@ -24,5 +24,122 @@
#define SSL_HELPERS_H
#include <test/helpers.h>
+#include <mbedtls/ssl.h>
+
+#if defined(MBEDTLS_SSL_CACHE_C)
+#include "mbedtls/ssl_cache.h"
+#endif
+
+typedef struct mbedtls_test_ssl_log_pattern {
+ const char *pattern;
+ size_t counter;
+} mbedtls_test_ssl_log_pattern;
+
+typedef struct mbedtls_test_handshake_test_options {
+ const char *cipher;
+ mbedtls_ssl_protocol_version client_min_version;
+ mbedtls_ssl_protocol_version client_max_version;
+ mbedtls_ssl_protocol_version server_min_version;
+ mbedtls_ssl_protocol_version server_max_version;
+ mbedtls_ssl_protocol_version expected_negotiated_version;
+ int expected_handshake_result;
+ int expected_ciphersuite;
+ int pk_alg;
+ int opaque_alg;
+ int opaque_alg2;
+ int opaque_usage;
+ data_t *psk_str;
+ int dtls;
+ int srv_auth_mode;
+ int serialize;
+ int mfl;
+ int cli_msg_len;
+ int srv_msg_len;
+ int expected_cli_fragments;
+ int expected_srv_fragments;
+ int renegotiate;
+ int legacy_renegotiation;
+ void *srv_log_obj;
+ void *cli_log_obj;
+ void (*srv_log_fun)(void *, int, const char *, int, const char *);
+ void (*cli_log_fun)(void *, int, const char *, int, const char *);
+ int resize_buffers;
+#if defined(MBEDTLS_SSL_CACHE_C)
+ mbedtls_ssl_cache_context *cache;
+#endif
+} mbedtls_test_handshake_test_options;
+
+typedef struct mbedtls_test_ssl_buffer {
+ size_t start;
+ size_t content_length;
+ size_t capacity;
+ unsigned char *buffer;
+} mbedtls_test_ssl_buffer;
+
+/*
+ * Context for a message metadata queue (fifo) that is on top of the ring buffer.
+ */
+typedef struct mbedtls_test_ssl_message_queue {
+ size_t *messages;
+ int pos;
+ int num;
+ int capacity;
+} mbedtls_test_ssl_message_queue;
+
+/*
+ * Context for the I/O callbacks simulating network connection.
+ */
+
+#define MBEDTLS_MOCK_SOCKET_CONNECTED 1
+
+typedef struct mbedtls_test_mock_socket {
+ int status;
+ mbedtls_test_ssl_buffer *input;
+ mbedtls_test_ssl_buffer *output;
+ struct mbedtls_test_mock_socket *peer;
+} mbedtls_test_mock_socket;
+
+/* Errors used in the message socket mocks */
+
+#define MBEDTLS_TEST_ERROR_CONTEXT_ERROR -55
+#define MBEDTLS_TEST_ERROR_SEND_FAILED -66
+#define MBEDTLS_TEST_ERROR_RECV_FAILED -77
+
+/*
+ * Structure used as an addon, or a wrapper, around the mocked sockets.
+ * Contains an input queue, to which the other socket pushes metadata,
+ * and an output queue, to which this one pushes metadata. This context is
+ * considered as an owner of the input queue only, which is initialized and
+ * freed in the respective setup and free calls.
+ */
+typedef struct mbedtls_test_message_socket_context {
+ mbedtls_test_ssl_message_queue *queue_input;
+ mbedtls_test_ssl_message_queue *queue_output;
+ mbedtls_test_mock_socket *socket;
+} mbedtls_test_message_socket_context;
+
+#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
+
+/*
+ * Structure with endpoint's certificates for SSL communication tests.
+ */
+typedef struct mbedtls_test_ssl_endpoint_certificate {
+ mbedtls_x509_crt *ca_cert;
+ mbedtls_x509_crt *cert;
+ mbedtls_pk_context *pkey;
+} mbedtls_test_ssl_endpoint_certificate;
+
+/*
+ * Endpoint structure for SSL communication tests.
+ */
+typedef struct mbedtls_test_ssl_endpoint {
+ const char *name;
+ mbedtls_ssl_context ssl;
+ mbedtls_ssl_config conf;
+ mbedtls_test_mock_socket socket;
+ mbedtls_test_ssl_endpoint_certificate cert;
+} mbedtls_test_ssl_endpoint;
+
+#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
#endif /* SSL_HELPERS_H */
diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function
index 0e3d14f..c6315e4 100644
--- a/tests/suites/test_suite_ssl.function
+++ b/tests/suites/test_suite_ssl.function
@@ -1,5 +1,4 @@
/* BEGIN_HEADER */
-#include <mbedtls/ssl.h>
#include <ssl_misc.h>
#include <mbedtls/timing.h>
#include <mbedtls/debug.h>
@@ -9,10 +8,6 @@
#include "test/certs.h"
#include <test/ssl_helpers.h>
-#if defined(MBEDTLS_SSL_CACHE_C)
-#include "mbedtls/ssl_cache.h"
-#endif
-
#include <mbedtls/legacy_or_psa.h>
#include "hash_info.h"
@@ -37,11 +32,6 @@
#undef MBEDTLS_SSL_TLS1_3_LABEL
};
-typedef struct mbedtls_test_ssl_log_pattern {
- const char *pattern;
- size_t counter;
-} mbedtls_test_ssl_log_pattern;
-
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
static int rng_seed = 0xBEEF;
static int rng_get(void *p_rng, unsigned char *output, size_t output_len)
@@ -77,40 +67,6 @@
}
}
-typedef struct mbedtls_test_handshake_test_options {
- const char *cipher;
- mbedtls_ssl_protocol_version client_min_version;
- mbedtls_ssl_protocol_version client_max_version;
- mbedtls_ssl_protocol_version server_min_version;
- mbedtls_ssl_protocol_version server_max_version;
- mbedtls_ssl_protocol_version expected_negotiated_version;
- int expected_handshake_result;
- int expected_ciphersuite;
- int pk_alg;
- int opaque_alg;
- int opaque_alg2;
- int opaque_usage;
- data_t *psk_str;
- int dtls;
- int srv_auth_mode;
- int serialize;
- int mfl;
- int cli_msg_len;
- int srv_msg_len;
- int expected_cli_fragments;
- int expected_srv_fragments;
- int renegotiate;
- int legacy_renegotiation;
- void *srv_log_obj;
- void *cli_log_obj;
- void (*srv_log_fun)(void *, int, const char *, int, const char *);
- void (*cli_log_fun)(void *, int, const char *, int, const char *);
- int resize_buffers;
-#if defined(MBEDTLS_SSL_CACHE_C)
- mbedtls_ssl_cache_context *cache;
-#endif
-} mbedtls_test_handshake_test_options;
-
void init_handshake_options(mbedtls_test_handshake_test_options *opts)
{
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
@@ -184,13 +140,6 @@
* Buffer structure for custom I/O callbacks.
*/
-typedef struct mbedtls_test_ssl_buffer {
- size_t start;
- size_t content_length;
- size_t capacity;
- unsigned char *buffer;
-} mbedtls_test_ssl_buffer;
-
/*
* Initialises \p buf. After calling this function it is safe to call
* `mbedtls_test_buffer_free()` on \p buf.
@@ -333,16 +282,6 @@
#define MBEDTLS_TEST_ERROR_MESSAGE_TRUNCATED -44
/*
- * Context for a message metadata queue (fifo) that is on top of the ring buffer.
- */
-typedef struct mbedtls_test_ssl_message_queue {
- size_t *messages;
- int pos;
- int num;
- int capacity;
-} mbedtls_test_ssl_message_queue;
-
-/*
* Setup and free functions for the message metadata queue.
*
* \p capacity describes the number of message metadata chunks that can be held
@@ -463,18 +402,6 @@
*msg_len = queue->messages[queue->pos];
return (*msg_len > buf_len) ? MBEDTLS_TEST_ERROR_MESSAGE_TRUNCATED : 0;
}
-/*
- * Context for the I/O callbacks simulating network connection.
- */
-
-#define MBEDTLS_MOCK_SOCKET_CONNECTED 1
-
-typedef struct mbedtls_test_mock_socket {
- int status;
- mbedtls_test_ssl_buffer *input;
- mbedtls_test_ssl_buffer *output;
- struct mbedtls_test_mock_socket *peer;
-} mbedtls_test_mock_socket;
/*
* Setup and teardown functions for mock sockets.
@@ -636,25 +563,6 @@
return mbedtls_test_buffer_get(socket->input, buf, len);
}
-/* Errors used in the message socket mocks */
-
-#define MBEDTLS_TEST_ERROR_CONTEXT_ERROR -55
-#define MBEDTLS_TEST_ERROR_SEND_FAILED -66
-#define MBEDTLS_TEST_ERROR_RECV_FAILED -77
-
-/*
- * Structure used as an addon, or a wrapper, around the mocked sockets.
- * Contains an input queue, to which the other socket pushes metadata,
- * and an output queue, to which this one pushes metadata. This context is
- * considered as an owner of the input queue only, which is initialized and
- * freed in the respective setup and free calls.
- */
-typedef struct mbedtls_test_message_socket_context {
- mbedtls_test_ssl_message_queue *queue_input;
- mbedtls_test_ssl_message_queue *queue_output;
- mbedtls_test_mock_socket *socket;
-} mbedtls_test_message_socket_context;
-
void mbedtls_message_socket_init(mbedtls_test_message_socket_context *ctx)
{
ctx->queue_input = NULL;
@@ -803,26 +711,6 @@
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
/*
- * Structure with endpoint's certificates for SSL communication tests.
- */
-typedef struct mbedtls_test_ssl_endpoint_certificate {
- mbedtls_x509_crt *ca_cert;
- mbedtls_x509_crt *cert;
- mbedtls_pk_context *pkey;
-} mbedtls_test_ssl_endpoint_certificate;
-
-/*
- * Endpoint structure for SSL communication tests.
- */
-typedef struct mbedtls_test_ssl_endpoint {
- const char *name;
- mbedtls_ssl_context ssl;
- mbedtls_ssl_config conf;
- mbedtls_test_mock_socket socket;
- mbedtls_test_ssl_endpoint_certificate cert;
-} mbedtls_test_ssl_endpoint;
-
-/*
* Deinitializes certificates from endpoint represented by \p ep.
*/
void mbedtls_endpoint_certificate_free(mbedtls_test_ssl_endpoint *ep)