本项止转自github官方arduino-esp32 传在这里仅为阅读源码方便
projectuser
2019-07-05 50148ccffe21ff54262064ec9f2245900eaf18aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
 
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
 
#ifndef _SSL_TYPES_H_
#define _SSL_TYPES_H_
 
#ifdef __cplusplus
 extern "C" {
#endif
 
#include "ssl_code.h"
 
typedef void SSL_CIPHER;
 
typedef void X509_STORE_CTX;
typedef void X509_STORE;
 
typedef void RSA;
 
typedef void STACK;
 
#define ossl_inline inline
 
#define SSL_METHOD_CALL(f, s, ...)        s->method->func->ssl_##f(s, ##__VA_ARGS__)
#define X509_METHOD_CALL(f, x, ...)       x->method->x509_##f(x, ##__VA_ARGS__)
#define EVP_PKEY_METHOD_CALL(f, k, ...)   k->method->pkey_##f(k, ##__VA_ARGS__)
 
typedef int (*OPENSSL_sk_compfunc)(const void *, const void *);
 
struct stack_st;
typedef struct stack_st OPENSSL_STACK;
 
struct ssl_method_st;
typedef struct ssl_method_st SSL_METHOD;
 
struct ssl_method_func_st;
typedef struct ssl_method_func_st SSL_METHOD_FUNC;
 
struct record_layer_st;
typedef struct record_layer_st RECORD_LAYER;
 
struct ossl_statem_st;
typedef struct ossl_statem_st OSSL_STATEM;
 
struct ssl_session_st;
typedef struct ssl_session_st SSL_SESSION;
 
struct ssl_ctx_st;
typedef struct ssl_ctx_st SSL_CTX;
 
struct ssl_st;
typedef struct ssl_st SSL;
 
struct cert_st;
typedef struct cert_st CERT;
 
struct x509_st;
typedef struct x509_st X509;
 
struct X509_VERIFY_PARAM_st;
typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;
 
struct evp_pkey_st;
typedef struct evp_pkey_st EVP_PKEY;
 
struct x509_method_st;
typedef struct x509_method_st X509_METHOD;
 
struct pkey_method_st;
typedef struct pkey_method_st PKEY_METHOD;
 
struct ssl_alpn_st;
typedef struct ssl_alpn_st SSL_ALPN;
 
struct bio_st;
typedef struct bio_st BIO;
 
struct stack_st {
 
    char **data;
 
    int num_alloc;
 
    OPENSSL_sk_compfunc c;
};
 
struct evp_pkey_st {
 
    void *pkey_pm;
 
    const PKEY_METHOD *method;
};
 
struct x509_st {
 
    /* X509 certification platform private point */
    void *x509_pm;
 
    const X509_METHOD *method;
 
    int ref_counter;
};
 
struct cert_st {
 
    int sec_level;
 
    X509 *x509;
 
    EVP_PKEY *pkey;
 
};
 
struct ossl_statem_st {
 
    MSG_FLOW_STATE state;
 
    int hand_state;
};
 
struct record_layer_st {
 
    int rstate;
 
    int read_ahead;
};
 
struct ssl_session_st {
 
    long timeout;
 
    long time;
 
    X509 *peer;
};
 
struct X509_VERIFY_PARAM_st {
 
    int depth;
 
};
 
struct bio_st {
    const unsigned char * data;
    int dlen;
};
 
typedef enum { ALPN_INIT, ALPN_ENABLE, ALPN_DISABLE, ALPN_ERROR } ALPN_STATUS;
struct ssl_alpn_st {
     ALPN_STATUS alpn_status;
     /* This is dynamically allocated */
     char *alpn_string;
     /* This only points to the members in the string */
#define ALPN_LIST_MAX 10
     const char *alpn_list[ALPN_LIST_MAX];
};
 
struct ssl_ctx_st
{
    int version;
 
    int references;
 
    unsigned long options;
 
    SSL_ALPN ssl_alpn;
 
    const SSL_METHOD *method;
 
    CERT *cert;
 
    X509 *client_CA;
 
    int verify_mode;
 
    int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx);
 
    long session_timeout;
 
    int read_ahead;
 
    int read_buffer_len;
 
    X509_VERIFY_PARAM param;
};
 
struct ssl_st
{
    /* protocol version(one of SSL3.0, TLS1.0, etc.) */
    int version;
 
    unsigned long options;
 
    /* shut things down(0x01 : sent, 0x02 : received) */
    int shutdown;
 
    CERT *cert;
 
    X509 *client_CA;
 
    SSL_CTX  *ctx;
 
    const SSL_METHOD *method;
 
    RECORD_LAYER rlayer;
 
    /* where we are */
    OSSL_STATEM statem;
 
    SSL_SESSION *session;
 
    int verify_mode;
 
    int (*verify_callback) (int ok, X509_STORE_CTX *ctx);
 
    int rwstate;
 
    long verify_result;
 
    X509_VERIFY_PARAM param;
 
    int err;
 
    void (*info_callback) (const SSL *ssl, int type, int val);
 
    /* SSL low-level system arch point */
    void *ssl_pm;
};
 
struct ssl_method_st {
    /* protocol version(one of SSL3.0, TLS1.0, etc.) */
    int version;
 
    /* SSL mode(client(0) , server(1), not known(-1)) */
    int endpoint;
 
    const SSL_METHOD_FUNC *func;
};
 
struct ssl_method_func_st {
 
    int (*ssl_new)(SSL *ssl);
 
    void (*ssl_free)(SSL *ssl);
 
    int (*ssl_handshake)(SSL *ssl);
 
    int (*ssl_shutdown)(SSL *ssl);
 
    int (*ssl_clear)(SSL *ssl);
 
    int (*ssl_read)(SSL *ssl, void *buffer, int len);
 
    int (*ssl_send)(SSL *ssl, const void *buffer, int len);
 
    int (*ssl_pending)(const SSL *ssl);
 
    void (*ssl_set_fd)(SSL *ssl, int fd, int mode);
 
    void (*ssl_set_hostname)(SSL *ssl, const char *hostname);
 
    int (*ssl_get_fd)(const SSL *ssl, int mode);
 
    void (*ssl_set_bufflen)(SSL *ssl, int len);
 
    long (*ssl_get_verify_result)(const SSL *ssl);
 
    OSSL_HANDSHAKE_STATE (*ssl_get_state)(const SSL *ssl);
};
 
struct x509_method_st {
 
    int (*x509_new)(X509 *x, X509 *m_x);
 
    void (*x509_free)(X509 *x);
 
    int (*x509_load)(X509 *x, const unsigned char *buf, int len);
 
    int (*x509_show_info)(X509 *x);
};
 
struct pkey_method_st {
 
    int (*pkey_new)(EVP_PKEY *pkey, EVP_PKEY *m_pkey);
 
    void (*pkey_free)(EVP_PKEY *pkey);
 
    int (*pkey_load)(EVP_PKEY *pkey, const unsigned char *buf, int len);
};
 
 
typedef int (*next_proto_cb)(SSL *ssl, unsigned char **out,
                             unsigned char *outlen, const unsigned char *in,
                             unsigned int inlen, void *arg);
 
#ifdef __cplusplus
}
#endif
 
#endif