summaryrefslogtreecommitdiff
path: root/tests/dtls-etm.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2023-04-24 12:39:42 +0900
committerDaiki Ueno <ueno@gnu.org>2023-04-24 12:45:46 +0900
commitaa5950abab56b011331ad4331409b6ff8efb8aeb (patch)
treead363fb38e8b65c942876641cda9c76caa13b498 /tests/dtls-etm.c
parent0fe9cb6842d63761718046cc7dd7eb437e6c5163 (diff)
downloadgnutls-aa5950abab56b011331ad4331409b6ff8efb8aeb.tar.gz
build: re-indent code
Signed-off-by: Daiki Ueno <ueno@gnu.org>
Diffstat (limited to 'tests/dtls-etm.c')
-rw-r--r--tests/dtls-etm.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/tests/dtls-etm.c b/tests/dtls-etm.c
index 86e613ff3b..53d70a6c5c 100644
--- a/tests/dtls-etm.c
+++ b/tests/dtls-etm.c
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdio.h>
@@ -35,20 +35,20 @@ int main(void)
#else
-# include <string.h>
-# include <sys/types.h>
-# include <netinet/in.h>
-# include <sys/socket.h>
-# include <sys/wait.h>
-# include <arpa/inet.h>
-# include <unistd.h>
-# include <gnutls/gnutls.h>
-# include <gnutls/dtls.h>
-# include <signal.h>
-# include <assert.h>
-
-# include "utils.h"
-# include "cert-common.h"
+#include <string.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <gnutls/gnutls.h>
+#include <gnutls/dtls.h>
+#include <signal.h>
+#include <assert.h>
+
+#include "utils.h"
+#include "cert-common.h"
static void terminate(void);
@@ -68,7 +68,7 @@ static void client_log_func(int level, const char *str)
/* A very basic TLS client, with anonymous authentication.
*/
-# define MAX_BUF 1024
+#define MAX_BUF 1024
static void client(int fd, const char *prio, unsigned etm)
{
@@ -107,8 +107,7 @@ static void client(int fd, const char *prio, unsigned etm)
*/
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\n");
@@ -121,8 +120,8 @@ static void client(int fd, const char *prio, unsigned etm)
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)));
if (etm != 0 && gnutls_session_etm_status(session) == 0) {
fail("client: EtM was not negotiated with %s!\n", prio);
@@ -132,13 +131,12 @@ static void client(int fd, const char *prio, unsigned etm)
exit(1);
}
- if (etm != 0
- && ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM) == 0)) {
+ if (etm != 0 &&
+ ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM) == 0)) {
fail("client: EtM was not negotiated with %s!\n", prio);
exit(1);
- } else if (etm == 0
- && ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM)
- != 0)) {
+ } else if (etm == 0 && ((gnutls_session_get_flags(session) &
+ GNUTLS_SFLAGS_ETM) != 0)) {
fail("client: EtM was negotiated with %s!\n", prio);
exit(1);
}
@@ -162,7 +160,7 @@ static void client(int fd, const char *prio, unsigned etm)
gnutls_bye(session, GNUTLS_SHUT_WR);
- end:
+end:
close(fd);
@@ -240,13 +238,12 @@ static void server(int fd, const char *prio, unsigned etm)
exit(1);
}
- if (etm != 0
- && ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM) == 0)) {
+ if (etm != 0 &&
+ ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM) == 0)) {
fail("server: EtM was not negotiated with %s!\n", prio);
exit(1);
- } else if (etm == 0
- && ((gnutls_session_get_flags(session) & GNUTLS_SFLAGS_ETM)
- != 0)) {
+ } else if (etm == 0 && ((gnutls_session_get_flags(session) &
+ GNUTLS_SFLAGS_ETM) != 0)) {
fail("server: EtM was negotiated with %s!\n", prio);
exit(1);
}
@@ -256,13 +253,13 @@ static void server(int fd, const char *prio, unsigned etm)
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)));
do {
do {
- ret =
- gnutls_record_send(session, buffer, sizeof(buffer));
+ ret = gnutls_record_send(session, buffer,
+ sizeof(buffer));
} while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
if (ret < 0) {
@@ -271,8 +268,7 @@ static void server(int fd, const char *prio, unsigned etm)
terminate();
}
to_send++;
- }
- while (to_send < 64);
+ } while (to_send < 64);
to_send = -1;
/* do not wait for the peer to close the connection.
@@ -321,9 +317,12 @@ static void start(const char *prio, unsigned etm)
}
}
-# define AES_CBC "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
-# define AES_CBC_SHA256 "NONE:+VERS-DTLS1.2:-CIPHER-ALL:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA256:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
-# define AES_GCM "NONE:+VERS-DTLS1.2:-CIPHER-ALL:+RSA:+AES-128-GCM:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
+#define AES_CBC \
+ "NONE:+VERS-DTLS1.0:-CIPHER-ALL:+AES-128-CBC:+SHA1:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
+#define AES_CBC_SHA256 \
+ "NONE:+VERS-DTLS1.2:-CIPHER-ALL:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA256:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
+#define AES_GCM \
+ "NONE:+VERS-DTLS1.2:-CIPHER-ALL:+RSA:+AES-128-GCM:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL"
static void ch_handler(int sig)
{
@@ -342,4 +341,4 @@ void doit(void)
start(AES_GCM, 0);
}
-#endif /* _WIN32 */
+#endif /* _WIN32 */