diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libssl/tls13_handshake.c | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/lib/libssl/tls13_handshake.c b/lib/libssl/tls13_handshake.c index df832e05696..c2ec287f73c 100644 --- a/lib/libssl/tls13_handshake.c +++ b/lib/libssl/tls13_handshake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_handshake.c,v 1.4 2018/11/09 23:54:57 tb Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.5 2018/11/10 00:38:31 tb Exp $ */ /* * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> * @@ -38,8 +38,6 @@ struct tls13_handshake { struct tls13_ctx { uint8_t mode; -#define TLS13_HS_MODE_CLIENT 0 -#define TLS13_HS_MODE_SERVER 1 struct tls13_handshake handshake; }; @@ -48,9 +46,9 @@ struct tls13_handshake_action { uint8_t handshake_type; uint8_t sender; -#define TLS13_HS_CLIENT_SENDS 1 -#define TLS13_HS_SERVER_SENDS 2 -#define TLS13_HS_BOTH_SEND (TLS13_HS_CLIENT_SENDS | TLS13_HS_SERVER_SENDS) +#define TLS13_HS_CLIENT 1 +#define TLS13_HS_SERVER 2 +#define TLS13_HS_BOTH (TLS13_HS_CLIENT | TLS13_HS_SERVER) int (*send)(struct tls13_ctx *ctx); int (*recv)(struct tls13_ctx *ctx); @@ -91,119 +89,119 @@ struct tls13_handshake_action state_machine[] = { [CLIENT_HELLO] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CLIENT_HELLO, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_hello_send, .recv = tls13_client_hello_recv, }, [CLIENT_HELLO_RETRY] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CLIENT_HELLO, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_hello_retry_send, .recv = tls13_client_hello_retry_recv, }, [CLIENT_END_OF_EARLY_DATA] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_END_OF_EARLY_DATA, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_end_of_early_data_send, .recv = tls13_client_end_of_early_data_recv, }, [CLIENT_CERTIFICATE] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CERTIFICATE, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_certificate_send, .recv = tls13_client_certificate_recv, }, [CLIENT_CERTIFICATE_VERIFY] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CERTIFICATE_VERIFY, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_certificate_verify_send, .recv = tls13_client_certificate_verify_recv, }, [CLIENT_FINISHED] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_FINISHED, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_finished_send, .recv = tls13_client_finished_recv, }, [CLIENT_KEY_UPDATE] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_KEY_UPDATE, - .sender = TLS13_HS_CLIENT_SENDS, + .sender = TLS13_HS_CLIENT, .send = tls13_client_key_update_send, .recv = tls13_client_key_update_recv, }, [SERVER_HELLO] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_SERVER_HELLO, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_hello_send, .recv = tls13_server_hello_recv, }, [SERVER_NEW_SESSION_TICKET] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_NEW_SESSION_TICKET, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_new_session_ticket_send, .recv = tls13_server_new_session_ticket_recv, }, [SERVER_ENCRYPTED_EXTENSIONS] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_ENCRYPTED_EXTENSIONS, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_encrypted_extensions_send, .recv = tls13_server_encrypted_extensions_recv, }, [SERVER_CERTIFICATE] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CERTIFICATE, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_certificate_send, .recv = tls13_server_certificate_recv, }, [SERVER_CERTIFICATE_REQUEST] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CERTIFICATE, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_certificate_request_send, .recv = tls13_server_certificate_request_recv, }, [SERVER_CERTIFICATE_VERIFY] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_CERTIFICATE_VERIFY, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_certificate_verify_send, .recv = tls13_server_certificate_verify_recv, }, [SERVER_FINISHED] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_FINISHED, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_finished_send, .recv = tls13_server_finished_recv, }, [SERVER_KEY_UPDATE] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_KEY_UPDATE, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_key_update_send, .recv = tls13_server_key_update_recv, }, [SERVER_MESSAGE_HASH] = { .record_type = TLS13_HANDSHAKE, .handshake_type = TLS13_MT_MESSAGE_HASH, - .sender = TLS13_HS_SERVER_SENDS, + .sender = TLS13_HS_SERVER, .send = tls13_server_message_hash_send, .recv = tls13_server_message_hash_recv, }, [APPLICATION_DATA] = { .record_type = TLS13_APPLICATION_DATA, .handshake_type = 0, - .sender = TLS13_HS_BOTH_SEND, + .sender = TLS13_HS_BOTH, .send = NULL, .recv = NULL, }, @@ -294,10 +292,10 @@ tls13_handshake_get_sender(struct tls13_ctx *ctx) int tls13_connect(struct tls13_ctx *ctx) { - ctx->mode = TLS13_HS_MODE_CLIENT; + ctx->mode = TLS13_HS_CLIENT; - while (tls13_handshake_get_sender(ctx) != TLS13_HS_BOTH_SEND) { - if (tls13_handshake_get_sender(ctx) == TLS13_HS_CLIENT_SENDS) { + while (tls13_handshake_get_sender(ctx) != TLS13_HS_BOTH) { + if (tls13_handshake_get_sender(ctx) == TLS13_HS_CLIENT) { if (!tls13_handshake_send_action(ctx)) return 0; } else { @@ -314,10 +312,10 @@ tls13_connect(struct tls13_ctx *ctx) int tls13_accept(struct tls13_ctx *ctx) { - ctx->mode = TLS13_HS_MODE_SERVER; + ctx->mode = TLS13_HS_SERVER; - while (tls13_handshake_get_sender(ctx) != TLS13_HS_BOTH_SEND) { - if (tls13_handshake_get_sender(ctx) == TLS13_HS_SERVER_SENDS) { + while (tls13_handshake_get_sender(ctx) != TLS13_HS_BOTH) { + if (tls13_handshake_get_sender(ctx) == TLS13_HS_SERVER) { if (!tls13_handshake_send_action(ctx)) return 0; } else { @@ -334,7 +332,7 @@ tls13_accept(struct tls13_ctx *ctx) int tls13_handshake_advance_state_machine(struct tls13_ctx *ctx) { - if (tls13_handshake_get_sender(ctx) == TLS13_HS_BOTH_SEND) + if (tls13_handshake_get_sender(ctx) == TLS13_HS_BOTH) return 0; ctx->handshake.message_number++; return 1; |