diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_handshake.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index 7798093def..9110c601c6 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.11 2019/01/20 02:08:05 tb Exp $ */ | 1 | /* $OpenBSD: tls13_handshake.c,v 1.12 2019/01/20 02:57:16 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> |
| @@ -30,7 +30,7 @@ | |||
| 30 | /* Indexing into the state machine */ | 30 | /* Indexing into the state machine */ |
| 31 | struct tls13_handshake { | 31 | struct tls13_handshake { |
| 32 | uint8_t hs_type; | 32 | uint8_t hs_type; |
| 33 | int message_number; | 33 | uint8_t message_number; |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | struct tls13_ctx { | 36 | struct tls13_ctx { |
| @@ -259,10 +259,18 @@ static enum tls13_message_type handshakes[][TLS13_NUM_MESSAGE_TYPES] = { | |||
| 259 | }, | 259 | }, |
| 260 | }; | 260 | }; |
| 261 | 261 | ||
| 262 | #define NUM_HANDSHAKES (sizeof(handshakes) / sizeof(handshakes[0])) | ||
| 263 | |||
| 262 | enum tls13_message_type | 264 | enum tls13_message_type |
| 263 | tls13_handshake_active_state(struct tls13_ctx *ctx) | 265 | tls13_handshake_active_state(struct tls13_ctx *ctx) |
| 264 | { | 266 | { |
| 265 | struct tls13_handshake hs = ctx->handshake; | 267 | struct tls13_handshake hs = ctx->handshake; |
| 268 | |||
| 269 | if (hs.hs_type >= NUM_HANDSHAKES) | ||
| 270 | return INVALID; | ||
| 271 | if (hs.message_number >= TLS13_NUM_MESSAGE_TYPES) | ||
| 272 | return INVALID; | ||
| 273 | |||
| 266 | return handshakes[hs.hs_type][hs.message_number]; | 274 | return handshakes[hs.hs_type][hs.message_number]; |
| 267 | } | 275 | } |
| 268 | 276 | ||
| @@ -270,10 +278,23 @@ struct tls13_handshake_action * | |||
| 270 | tls13_handshake_active_action(struct tls13_ctx *ctx) | 278 | tls13_handshake_active_action(struct tls13_ctx *ctx) |
| 271 | { | 279 | { |
| 272 | enum tls13_message_type mt = tls13_handshake_active_state(ctx); | 280 | enum tls13_message_type mt = tls13_handshake_active_state(ctx); |
| 281 | |||
| 282 | if (mt == INVALID) | ||
| 283 | return NULL; | ||
| 284 | |||
| 273 | return &state_machine[mt]; | 285 | return &state_machine[mt]; |
| 274 | } | 286 | } |
| 275 | 287 | ||
| 276 | int | 288 | int |
| 289 | tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) | ||
| 290 | { | ||
| 291 | if (++ctx->handshake.message_number >= TLS13_NUM_MESSAGE_TYPES) | ||
| 292 | return 0; | ||
| 293 | |||
| 294 | return 1; | ||
| 295 | } | ||
| 296 | |||
| 297 | int | ||
| 277 | tls13_connect(struct tls13_ctx *ctx) | 298 | tls13_connect(struct tls13_ctx *ctx) |
| 278 | { | 299 | { |
| 279 | struct tls13_handshake_action *action; | 300 | struct tls13_handshake_action *action; |
| @@ -332,13 +353,6 @@ tls13_accept(struct tls13_ctx *ctx) | |||
| 332 | } | 353 | } |
| 333 | 354 | ||
| 334 | int | 355 | int |
| 335 | tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) | ||
| 336 | { | ||
| 337 | ctx->handshake.message_number++; | ||
| 338 | return 0; | ||
| 339 | } | ||
| 340 | |||
| 341 | int | ||
| 342 | tls13_handshake_send_action(struct tls13_ctx *ctx, | 356 | tls13_handshake_send_action(struct tls13_ctx *ctx, |
| 343 | struct tls13_handshake_action *action) | 357 | struct tls13_handshake_action *action) |
| 344 | { | 358 | { |
