From 549758b49616a2ed2f8e76f1ec804a664cab843e Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 21 Jan 2019 06:58:44 +0000 Subject: Move struct tls13_ctx into a header since other things need access to it. While here, rename struct handshake to struct handshake_stage to avoid potential ambiguity/conflict with the handshake data struct. Also add forward and back pointers between SSL and struct tls13_ctx. ok tb@ --- src/lib/libssl/tls13_handshake.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src/lib/libssl/tls13_handshake.c') diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index bec55d8416..92780bb2f2 100644 --- a/src/lib/libssl/tls13_handshake.c +++ b/src/lib/libssl/tls13_handshake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_handshake.c,v 1.14 2019/01/20 06:40:55 tb Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.15 2019/01/21 06:58:44 jsing Exp $ */ /* * Copyright (c) 2018-2019 Theo Buehler * Copyright (c) 2019 Joel Sing @@ -27,17 +27,6 @@ #define TLS13_HANDSHAKE 1 #define TLS13_APPLICATION_DATA 2 -/* Indexing into the state machine */ -struct tls13_handshake { - uint8_t hs_type; - uint8_t message_number; -}; - -struct tls13_ctx { - uint8_t mode; - struct tls13_handshake handshake; -}; - struct tls13_handshake_action { uint8_t record_type; uint8_t handshake_type; @@ -266,7 +255,7 @@ static enum tls13_message_type handshakes[][TLS13_NUM_MESSAGE_TYPES] = { enum tls13_message_type tls13_handshake_active_state(struct tls13_ctx *ctx) { - struct tls13_handshake hs = ctx->handshake; + struct tls13_handshake_stage hs = ctx->handshake_stage; if (hs.hs_type >= NUM_HANDSHAKES) return INVALID; @@ -290,7 +279,7 @@ tls13_handshake_active_action(struct tls13_ctx *ctx) int tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) { - if (++ctx->handshake.message_number >= TLS13_NUM_MESSAGE_TYPES) + if (++ctx->handshake_stage.message_number >= TLS13_NUM_MESSAGE_TYPES) return 0; return 1; @@ -472,7 +461,7 @@ tls13_client_key_update_recv(struct tls13_ctx *ctx) int tls13_server_hello_recv(struct tls13_ctx *ctx) { - ctx->handshake.hs_type |= NEGOTIATED; + ctx->handshake_stage.hs_type |= NEGOTIATED; return 0; } @@ -480,7 +469,7 @@ tls13_server_hello_recv(struct tls13_ctx *ctx) int tls13_server_hello_send(struct tls13_ctx *ctx) { - ctx->handshake.hs_type |= NEGOTIATED; + ctx->handshake_stage.hs_type |= NEGOTIATED; return 0; } @@ -521,7 +510,7 @@ tls13_server_certificate_request_recv(struct tls13_ctx *ctx) * switching state, to avoid advancing state. */ if (msg_type == TLS13_MT_CERTIFICATE) { - ctx->handshake.hs_type |= WITHOUT_CR; + ctx->handshake_stage.hs_type |= WITHOUT_CR; return tls13_server_certificate_recv(ctx); } -- cgit v1.2.3-55-g6feb