• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef _SSL_CODE_H_
16 #define _SSL_CODE_H_
17 
18 #ifdef __cplusplus
19  extern "C" {
20 #endif
21 
22 #include "ssl3.h"
23 #include "tls1.h"
24 #include "x509_vfy.h"
25 
26 /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
27 # define SSL_SENT_SHUTDOWN       1
28 # define SSL_RECEIVED_SHUTDOWN   2
29 
30 # define SSL_VERIFY_NONE                 0x00
31 # define SSL_VERIFY_PEER                 0x01
32 # define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
33 # define SSL_VERIFY_CLIENT_ONCE          0x04
34 
35 /*
36  * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
37  * should not need these
38  */
39 # define SSL_ST_READ_HEADER                      0xF0
40 # define SSL_ST_READ_BODY                        0xF1
41 # define SSL_ST_READ_DONE                        0xF2
42 
43 # define SSL_NOTHING            1
44 # define SSL_WRITING            2
45 # define SSL_READING            3
46 # define SSL_X509_LOOKUP        4
47 # define SSL_ASYNC_PAUSED       5
48 # define SSL_ASYNC_NO_JOBS      6
49 
50 
51 # define SSL_ERROR_NONE                  0
52 # define SSL_ERROR_SSL                   1
53 # define SSL_ERROR_WANT_READ             2
54 # define SSL_ERROR_WANT_WRITE            3
55 # define SSL_ERROR_WANT_X509_LOOKUP      4
56 # define SSL_ERROR_SYSCALL               5/* look at error stack/return value/errno */
57 # define SSL_ERROR_ZERO_RETURN           6
58 # define SSL_ERROR_WANT_CONNECT          7
59 # define SSL_ERROR_WANT_ACCEPT           8
60 # define SSL_ERROR_WANT_ASYNC            9
61 # define SSL_ERROR_WANT_ASYNC_JOB       10
62 
63 /* Message flow states */
64 typedef enum {
65     /* No handshake in progress */
66     MSG_FLOW_UNINITED,
67     /* A permanent error with this connection */
68     MSG_FLOW_ERROR,
69     /* We are about to renegotiate */
70     MSG_FLOW_RENEGOTIATE,
71     /* We are reading messages */
72     MSG_FLOW_READING,
73     /* We are writing messages */
74     MSG_FLOW_WRITING,
75     /* Handshake has finished */
76     MSG_FLOW_FINISHED
77 } MSG_FLOW_STATE;
78 
79 /* SSL subsystem states */
80 typedef enum {
81     TLS_ST_BEFORE,
82     TLS_ST_OK,
83     DTLS_ST_CR_HELLO_VERIFY_REQUEST,
84     TLS_ST_CR_SRVR_HELLO,
85     TLS_ST_CR_CERT,
86     TLS_ST_CR_CERT_STATUS,
87     TLS_ST_CR_KEY_EXCH,
88     TLS_ST_CR_CERT_REQ,
89     TLS_ST_CR_SRVR_DONE,
90     TLS_ST_CR_SESSION_TICKET,
91     TLS_ST_CR_CHANGE,
92     TLS_ST_CR_FINISHED,
93     TLS_ST_CW_CLNT_HELLO,
94     TLS_ST_CW_CERT,
95     TLS_ST_CW_KEY_EXCH,
96     TLS_ST_CW_CERT_VRFY,
97     TLS_ST_CW_CHANGE,
98     TLS_ST_CW_NEXT_PROTO,
99     TLS_ST_CW_FINISHED,
100     TLS_ST_SW_HELLO_REQ,
101     TLS_ST_SR_CLNT_HELLO,
102     DTLS_ST_SW_HELLO_VERIFY_REQUEST,
103     TLS_ST_SW_SRVR_HELLO,
104     TLS_ST_SW_CERT,
105     TLS_ST_SW_KEY_EXCH,
106     TLS_ST_SW_CERT_REQ,
107     TLS_ST_SW_SRVR_DONE,
108     TLS_ST_SR_CERT,
109     TLS_ST_SR_KEY_EXCH,
110     TLS_ST_SR_CERT_VRFY,
111     TLS_ST_SR_NEXT_PROTO,
112     TLS_ST_SR_CHANGE,
113     TLS_ST_SR_FINISHED,
114     TLS_ST_SW_SESSION_TICKET,
115     TLS_ST_SW_CERT_STATUS,
116     TLS_ST_SW_CHANGE,
117     TLS_ST_SW_FINISHED
118 } OSSL_HANDSHAKE_STATE;
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif
125