summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2019-01-21 06:58:44 +0000
committerjsing <>2019-01-21 06:58:44 +0000
commit549758b49616a2ed2f8e76f1ec804a664cab843e (patch)
tree3ab3f3f45daa0fe0d9fd6647639796883adedaef
parentee45b5205b24ef754b5fddbb35818a8cf22dbe51 (diff)
downloadopenbsd-549758b49616a2ed2f8e76f1ec804a664cab843e.tar.gz
openbsd-549758b49616a2ed2f8e76f1ec804a664cab843e.tar.bz2
openbsd-549758b49616a2ed2f8e76f1ec804a664cab843e.zip
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@
-rw-r--r--src/lib/libssl/ssl_locl.h4
-rw-r--r--src/lib/libssl/tls13_handshake.c23
-rw-r--r--src/lib/libssl/tls13_internal.h15
3 files changed, 21 insertions, 21 deletions
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 1653b2ab96..30c1afd22d 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.226 2019/01/18 12:09:52 beck Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.227 2019/01/21 06:58:44 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -609,6 +609,8 @@ typedef struct ssl_ctx_internal_st {
609} SSL_CTX_INTERNAL; 609} SSL_CTX_INTERNAL;
610 610
611typedef struct ssl_internal_st { 611typedef struct ssl_internal_st {
612 struct tls13_ctx *tls13;
613
612 uint16_t min_version; 614 uint16_t min_version;
613 uint16_t max_version; 615 uint16_t max_version;
614 616
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 @@
1/* $OpenBSD: tls13_handshake.c,v 1.14 2019/01/20 06:40:55 tb Exp $ */ 1/* $OpenBSD: tls13_handshake.c,v 1.15 2019/01/21 06:58:44 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2018-2019 Theo Buehler <tb@openbsd.org>
4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org>
@@ -27,17 +27,6 @@
27#define TLS13_HANDSHAKE 1 27#define TLS13_HANDSHAKE 1
28#define TLS13_APPLICATION_DATA 2 28#define TLS13_APPLICATION_DATA 2
29 29
30/* Indexing into the state machine */
31struct tls13_handshake {
32 uint8_t hs_type;
33 uint8_t message_number;
34};
35
36struct tls13_ctx {
37 uint8_t mode;
38 struct tls13_handshake handshake;
39};
40
41struct tls13_handshake_action { 30struct tls13_handshake_action {
42 uint8_t record_type; 31 uint8_t record_type;
43 uint8_t handshake_type; 32 uint8_t handshake_type;
@@ -266,7 +255,7 @@ static enum tls13_message_type handshakes[][TLS13_NUM_MESSAGE_TYPES] = {
266enum tls13_message_type 255enum tls13_message_type
267tls13_handshake_active_state(struct tls13_ctx *ctx) 256tls13_handshake_active_state(struct tls13_ctx *ctx)
268{ 257{
269 struct tls13_handshake hs = ctx->handshake; 258 struct tls13_handshake_stage hs = ctx->handshake_stage;
270 259
271 if (hs.hs_type >= NUM_HANDSHAKES) 260 if (hs.hs_type >= NUM_HANDSHAKES)
272 return INVALID; 261 return INVALID;
@@ -290,7 +279,7 @@ tls13_handshake_active_action(struct tls13_ctx *ctx)
290int 279int
291tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) 280tls13_handshake_advance_state_machine(struct tls13_ctx *ctx)
292{ 281{
293 if (++ctx->handshake.message_number >= TLS13_NUM_MESSAGE_TYPES) 282 if (++ctx->handshake_stage.message_number >= TLS13_NUM_MESSAGE_TYPES)
294 return 0; 283 return 0;
295 284
296 return 1; 285 return 1;
@@ -472,7 +461,7 @@ tls13_client_key_update_recv(struct tls13_ctx *ctx)
472int 461int
473tls13_server_hello_recv(struct tls13_ctx *ctx) 462tls13_server_hello_recv(struct tls13_ctx *ctx)
474{ 463{
475 ctx->handshake.hs_type |= NEGOTIATED; 464 ctx->handshake_stage.hs_type |= NEGOTIATED;
476 465
477 return 0; 466 return 0;
478} 467}
@@ -480,7 +469,7 @@ tls13_server_hello_recv(struct tls13_ctx *ctx)
480int 469int
481tls13_server_hello_send(struct tls13_ctx *ctx) 470tls13_server_hello_send(struct tls13_ctx *ctx)
482{ 471{
483 ctx->handshake.hs_type |= NEGOTIATED; 472 ctx->handshake_stage.hs_type |= NEGOTIATED;
484 473
485 return 0; 474 return 0;
486} 475}
@@ -521,7 +510,7 @@ tls13_server_certificate_request_recv(struct tls13_ctx *ctx)
521 * switching state, to avoid advancing state. 510 * switching state, to avoid advancing state.
522 */ 511 */
523 if (msg_type == TLS13_MT_CERTIFICATE) { 512 if (msg_type == TLS13_MT_CERTIFICATE) {
524 ctx->handshake.hs_type |= WITHOUT_CR; 513 ctx->handshake_stage.hs_type |= WITHOUT_CR;
525 return tls13_server_certificate_recv(ctx); 514 return tls13_server_certificate_recv(ctx);
526 } 515 }
527 516
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index 6b85cfdab9..bb3ff1fe9c 100644
--- a/src/lib/libssl/tls13_internal.h
+++ b/src/lib/libssl/tls13_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_internal.h,v 1.10 2019/01/20 12:27:34 jsing Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.11 2019/01/21 06:58:44 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -95,8 +95,6 @@ int tls13_derive_handshake_secrets(struct tls13_secrets *secrets,
95int tls13_derive_application_secrets(struct tls13_secrets *secrets, 95int tls13_derive_application_secrets(struct tls13_secrets *secrets,
96 const struct tls13_secret *context); 96 const struct tls13_secret *context);
97 97
98struct tls13_ctx;
99
100/* 98/*
101 * Record Layer. 99 * Record Layer.
102 */ 100 */
@@ -139,6 +137,17 @@ int tls13_handshake_msg_recv(struct tls13_handshake_msg *msg,
139int tls13_handshake_msg_send(struct tls13_handshake_msg *msg, 137int tls13_handshake_msg_send(struct tls13_handshake_msg *msg,
140 struct tls13_record_layer *rl); 138 struct tls13_record_layer *rl);
141 139
140struct tls13_handshake_stage {
141 uint8_t hs_type;
142 uint8_t message_number;
143};
144
145struct tls13_ctx {
146 SSL *ssl;
147 uint8_t mode;
148 struct tls13_handshake_stage handshake_stage;
149};
150
142/* 151/*
143 * Message Types - RFC 8446, Section B.3. 152 * Message Types - RFC 8446, Section B.3.
144 * 153 *