]> git.ipfire.org Git - thirdparty/openssl.git/blame - ssl/statem/statem.h
Fix changing of the cipher state when dealing with early data
[thirdparty/openssl.git] / ssl / statem / statem.h
CommitLineData
846e33c7
RS
1/*
2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
8ba708e5 3 *
846e33c7
RS
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8ba708e5
MC
8 */
9
10/*****************************************************************************
11 * *
8483a003 12 * These enums should be considered PRIVATE to the state machine. No *
8ba708e5
MC
13 * non-state machine code should need to use these *
14 * *
15 *****************************************************************************/
16/*
17 * Valid return codes used for functions performing work prior to or after
18 * sending or receiving a message
19 */
be3583fa 20typedef enum {
8ba708e5
MC
21 /* Something went wrong */
22 WORK_ERROR,
23 /* We're done working and there shouldn't be anything else to do after */
24 WORK_FINISHED_STOP,
25 /* We're done working move onto the next thing */
26 WORK_FINISHED_CONTINUE,
27 /* We're working on phase A */
28 WORK_MORE_A,
29 /* We're working on phase B */
ddf97258
BK
30 WORK_MORE_B,
31 /* We're working on phase C */
32 WORK_MORE_C
be3583fa 33} WORK_STATE;
8ba708e5
MC
34
35/* Write transition return codes */
be3583fa 36typedef enum {
8ba708e5
MC
37 /* Something went wrong */
38 WRITE_TRAN_ERROR,
39 /* A transition was successfully completed and we should continue */
40 WRITE_TRAN_CONTINUE,
41 /* There is no more write work to be done */
42 WRITE_TRAN_FINISHED
be3583fa 43} WRITE_TRAN;
8ba708e5 44
8ba708e5 45/* Message flow states */
be3583fa 46typedef enum {
8ba708e5
MC
47 /* No handshake in progress */
48 MSG_FLOW_UNINITED,
49 /* A permanent error with this connection */
50 MSG_FLOW_ERROR,
8ba708e5
MC
51 /* We are reading messages */
52 MSG_FLOW_READING,
53 /* We are writing messages */
54 MSG_FLOW_WRITING,
55 /* Handshake has finished */
56 MSG_FLOW_FINISHED
be3583fa 57} MSG_FLOW_STATE;
8ba708e5
MC
58
59/* Read states */
be3583fa 60typedef enum {
8ba708e5
MC
61 READ_STATE_HEADER,
62 READ_STATE_BODY,
63 READ_STATE_POST_PROCESS
be3583fa 64} READ_STATE;
8ba708e5
MC
65
66/* Write states */
be3583fa 67typedef enum {
8ba708e5
MC
68 WRITE_STATE_TRANSITION,
69 WRITE_STATE_PRE_WORK,
70 WRITE_STATE_SEND,
71 WRITE_STATE_POST_WORK
be3583fa 72} WRITE_STATE;
8ba708e5 73
8ba708e5
MC
74/*****************************************************************************
75 * *
76 * This structure should be considered "opaque" to anything outside of the *
77 * state machine. No non-state machine code should be accessing the members *
78 * of this structure. *
79 * *
80 *****************************************************************************/
81
d6f1a6e9 82struct ossl_statem_st {
be3583fa
MC
83 MSG_FLOW_STATE state;
84 WRITE_STATE write_state;
85 WORK_STATE write_state_work;
86 READ_STATE read_state;
87 WORK_STATE read_state_work;
35bf6e05 88 OSSL_HANDSHAKE_STATE hand_state;
0386aad1
MC
89 /* The handshake state requested by an API call (e.g. HelloRequest) */
90 OSSL_HANDSHAKE_STATE request_state;
8ba708e5
MC
91 int in_init;
92 int read_state_first_init;
024f543c
MC
93 /* true when we are actually in SSL_accept() or SSL_connect() */
94 int in_handshake;
c7f47786
MC
95 /*
96 * True when are processing a "real" handshake that needs cleaning up (not
97 * just a HelloRequest or similar).
98 */
99 int cleanuphand;
a71a4966
MC
100 /* Should we skip the CertificateVerify message? */
101 unsigned int no_cert_verify;
8ba708e5
MC
102 int use_timer;
103#ifndef OPENSSL_NO_SCTP
104 int in_sctp_read_sock;
105#endif
106};
d6f1a6e9 107typedef struct ossl_statem_st OSSL_STATEM;
8ba708e5 108
8ba708e5
MC
109/*****************************************************************************
110 * *
111 * The following macros/functions represent the libssl internal API to the *
112 * state machine. Any libssl code may call these functions/macros *
113 * *
114 *****************************************************************************/
115
fe3a3291
MC
116__owur int ossl_statem_accept(SSL *s);
117__owur int ossl_statem_connect(SSL *s);
118void ossl_statem_clear(SSL *s);
119void ossl_statem_set_renegotiate(SSL *s);
120void ossl_statem_set_error(SSL *s);
121int ossl_statem_in_error(const SSL *s);
122void ossl_statem_set_in_init(SSL *s, int init);
024f543c
MC
123int ossl_statem_get_in_handshake(SSL *s);
124void ossl_statem_set_in_handshake(SSL *s, int inhand);
0a87d0ac 125__owur int ossl_statem_skip_early_data(SSL *s);
31fd10e6 126void ossl_statem_set_hello_verify_done(SSL *s);
fe3a3291 127__owur int ossl_statem_app_data_allowed(SSL *s);
8ba708e5 128#ifndef OPENSSL_NO_SCTP
fe3a3291
MC
129void ossl_statem_set_sctp_read_sock(SSL *s, int read_sock);
130__owur int ossl_statem_in_sctp_read_sock(SSL *s);
8ba708e5 131#endif
fe5e20fd 132int ossl_statem_finish_early_data(SSL *s);