summaryrefslogtreecommitdiff
path: root/tests/tls13/compress-cert-neg.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tls13/compress-cert-neg.c')
-rw-r--r--tests/tls13/compress-cert-neg.c104
1 files changed, 50 insertions, 54 deletions
diff --git a/tests/tls13/compress-cert-neg.c b/tests/tls13/compress-cert-neg.c
index 9f3a28070f..bac991542b 100644
--- a/tests/tls13/compress-cert-neg.c
+++ b/tests/tls13/compress-cert-neg.c
@@ -20,14 +20,14 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
-#if defined(_WIN32) || !defined(HAVE_LIBZ) || \
- !defined(HAVE_LIBBROTLI) || !defined(HAVE_LIBZSTD)
+#if defined(_WIN32) || !defined(HAVE_LIBZ) || !defined(HAVE_LIBBROTLI) || \
+ !defined(HAVE_LIBZSTD)
int main(int argc, char **argv)
{
@@ -36,19 +36,19 @@ int main(int argc, char **argv)
#else
-# include <sys/socket.h>
-# include <sys/wait.h>
-# include <unistd.h>
-# include <gnutls/gnutls.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <gnutls/gnutls.h>
-# include "cert-common.h"
-# include "utils.h"
+#include "cert-common.h"
+#include "utils.h"
/* This program tests whether the compress_certificate extensions is disabled
* when client and server have incompatible compression methods set */
-# define PRIO "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.3"
-# define CHECK(X) assert((X)>=0)
+#define PRIO "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.3"
+#define CHECK(X) assert((X) >= 0)
static pid_t child;
int client_bad;
@@ -77,7 +77,7 @@ static void server_log_func(int level, const char *str)
static int client_callback(gnutls_session_t session, unsigned htype,
unsigned post, unsigned incoming,
- const gnutls_datum_t * msg)
+ const gnutls_datum_t *msg)
{
client_bad = 1;
return 0;
@@ -85,7 +85,7 @@ static int client_callback(gnutls_session_t session, unsigned htype,
static int server_callback(gnutls_session_t session, unsigned htype,
unsigned post, unsigned incoming,
- const gnutls_datum_t * msg)
+ const gnutls_datum_t *msg)
{
server_bad = 1;
return 0;
@@ -98,10 +98,10 @@ static void client(int fd)
gnutls_session_t session;
gnutls_certificate_credentials_t x509_cred;
gnutls_compression_method_t method;
- gnutls_compression_method_t methods[] =
- { GNUTLS_COMP_BROTLI, GNUTLS_COMP_ZSTD };
+ gnutls_compression_method_t methods[] = { GNUTLS_COMP_BROTLI,
+ GNUTLS_COMP_ZSTD };
size_t methods_len =
- sizeof(methods) / sizeof(gnutls_compression_method_t);
+ sizeof(methods) / sizeof(gnutls_compression_method_t);
global_init();
@@ -111,34 +111,32 @@ static void client(int fd)
}
CHECK(gnutls_certificate_allocate_credentials(&x509_cred));
- CHECK(gnutls_certificate_set_x509_trust_mem
- (x509_cred, &ca3_cert, GNUTLS_X509_FMT_PEM));
- CHECK(gnutls_certificate_set_x509_key_mem
- (x509_cred, &cli_ca3_cert_chain, &cli_ca3_key,
- GNUTLS_X509_FMT_PEM));
+ CHECK(gnutls_certificate_set_x509_trust_mem(x509_cred, &ca3_cert,
+ GNUTLS_X509_FMT_PEM));
+ CHECK(gnutls_certificate_set_x509_key_mem(
+ x509_cred, &cli_ca3_cert_chain, &cli_ca3_key,
+ GNUTLS_X509_FMT_PEM));
CHECK(gnutls_init(&session, GNUTLS_CLIENT));
- CHECK(gnutls_credentials_set
- (session, GNUTLS_CRD_CERTIFICATE, x509_cred));
+ CHECK(gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ x509_cred));
CHECK(gnutls_priority_set_direct(session, PRIO, NULL));
- ret =
- gnutls_compress_certificate_set_methods(session, methods,
- methods_len);
+ ret = gnutls_compress_certificate_set_methods(session, methods,
+ methods_len);
if (ret < 0) {
fail("client: setting compression method failed (%s)\n\n",
gnutls_strerror(ret));
terminate();
}
- gnutls_handshake_set_hook_function(session,
- GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT,
- GNUTLS_HOOK_PRE, client_callback);
+ gnutls_handshake_set_hook_function(
+ session, GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT,
+ GNUTLS_HOOK_PRE, client_callback);
gnutls_transport_set_int(session, fd);
do {
ret = gnutls_handshake(session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ } while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
if (ret < 0) {
fail("client: Handshake failed: %s\n", strerror(ret));
goto cleanup;
@@ -147,8 +145,8 @@ static void client(int fd)
success("client: Handshake was completed\n");
if (debug)
success("client: TLS version is: %s\n",
- gnutls_protocol_get_name
- (gnutls_protocol_get_version(session)));
+ gnutls_protocol_get_name(
+ gnutls_protocol_get_version(session)));
method = gnutls_compress_certificate_get_selected_method(session);
if (method != GNUTLS_COMP_UNKNOWN)
@@ -169,7 +167,7 @@ static void client(int fd)
if (debug)
success("client: finished\n");
- cleanup:
+cleanup:
close(fd);
gnutls_deinit(session);
gnutls_certificate_free_credentials(x509_cred);
@@ -185,7 +183,7 @@ static void server(int fd)
gnutls_compression_method_t method;
gnutls_compression_method_t methods[] = { GNUTLS_COMP_ZLIB };
size_t methods_len =
- sizeof(methods) / sizeof(gnutls_compression_method_t);
+ sizeof(methods) / sizeof(gnutls_compression_method_t);
global_init();
@@ -195,35 +193,33 @@ static void server(int fd)
}
CHECK(gnutls_certificate_allocate_credentials(&x509_cred));
- CHECK(gnutls_certificate_set_x509_trust_mem
- (x509_cred, &ca3_cert, GNUTLS_X509_FMT_PEM));
- CHECK(gnutls_certificate_set_x509_key_mem
- (x509_cred, &server_ca3_localhost_cert_chain, &server_ca3_key,
- GNUTLS_X509_FMT_PEM));
+ CHECK(gnutls_certificate_set_x509_trust_mem(x509_cred, &ca3_cert,
+ GNUTLS_X509_FMT_PEM));
+ CHECK(gnutls_certificate_set_x509_key_mem(
+ x509_cred, &server_ca3_localhost_cert_chain, &server_ca3_key,
+ GNUTLS_X509_FMT_PEM));
CHECK(gnutls_init(&session, GNUTLS_SERVER));
- CHECK(gnutls_credentials_set
- (session, GNUTLS_CRD_CERTIFICATE, x509_cred));
+ CHECK(gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
+ x509_cred));
CHECK(gnutls_priority_set_direct(session, PRIO, NULL));
- ret =
- gnutls_compress_certificate_set_methods(session, methods,
- methods_len);
+ ret = gnutls_compress_certificate_set_methods(session, methods,
+ methods_len);
if (ret < 0) {
fail("server: setting compression method failed (%s)\n\n",
gnutls_strerror(ret));
terminate();
}
- gnutls_handshake_set_hook_function(session,
- GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT,
- GNUTLS_HOOK_PRE, server_callback);
+ gnutls_handshake_set_hook_function(
+ session, GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT,
+ GNUTLS_HOOK_PRE, server_callback);
gnutls_certificate_server_set_request(session, GNUTLS_CERT_REQUEST);
gnutls_transport_set_int(session, fd);
do {
ret = gnutls_handshake(session);
- }
- while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
+ } while (ret < 0 && gnutls_error_is_fatal(ret) == 0);
if (ret < 0) {
fail("server: Handshake has failed (%s)\n\n",
gnutls_strerror(ret));
@@ -233,8 +229,8 @@ static void server(int fd)
success("server: Handshake was completed\n");
if (debug)
success("server: TLS version is: %s\n",
- gnutls_protocol_get_name(gnutls_protocol_get_version
- (session)));
+ gnutls_protocol_get_name(
+ gnutls_protocol_get_version(session)));
method = gnutls_compress_certificate_get_selected_method(session);
if (method != GNUTLS_COMP_UNKNOWN)
@@ -255,7 +251,7 @@ static void server(int fd)
if (debug)
success("server: finished\n");
- cleanup:
+cleanup:
close(fd);
gnutls_deinit(session);
gnutls_certificate_free_credentials(x509_cred);
@@ -295,4 +291,4 @@ void doit(void)
}
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */