Add documentation for the SSL_export_keying_material() function
[openssl.git] / ssl / methods.c
1 /*
2  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9
10 #include <stdio.h>
11 #include <openssl/objects.h>
12 #include "ssl_locl.h"
13
14 /*-
15  * TLS/SSLv3 methods
16  */
17
18 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
19                         TLS_method,
20                         ossl_statem_accept,
21                         ossl_statem_connect, TLSv1_2_enc_data)
22 #ifndef OPENSSL_NO_TLS1_3_METHOD
23 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
24                         tlsv1_3_method,
25                         ossl_statem_accept,
26                         ossl_statem_connect, TLSv1_3_enc_data)
27 #endif
28 #ifndef OPENSSL_NO_TLS1_2_METHOD
29 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
30                         tlsv1_2_method,
31                         ossl_statem_accept,
32                         ossl_statem_connect, TLSv1_2_enc_data)
33 #endif
34 #ifndef OPENSSL_NO_TLS1_1_METHOD
35 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
36                         tlsv1_1_method,
37                         ossl_statem_accept,
38                         ossl_statem_connect, TLSv1_1_enc_data)
39 #endif
40 #ifndef OPENSSL_NO_TLS1_METHOD
41 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
42                         tlsv1_method,
43                         ossl_statem_accept, ossl_statem_connect, TLSv1_enc_data)
44 #endif
45 #ifndef OPENSSL_NO_SSL3_METHOD
46 IMPLEMENT_ssl3_meth_func(sslv3_method, ossl_statem_accept, ossl_statem_connect)
47 #endif
48 /*-
49  * TLS/SSLv3 server methods
50  */
51 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
52                         TLS_server_method,
53                         ossl_statem_accept,
54                         ssl_undefined_function, TLSv1_2_enc_data)
55 #ifndef OPENSSL_NO_TLS1_3_METHOD
56 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
57                         tlsv1_3_server_method,
58                         ossl_statem_accept,
59                         ssl_undefined_function, TLSv1_3_enc_data)
60 #endif
61 #ifndef OPENSSL_NO_TLS1_2_METHOD
62 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
63                         tlsv1_2_server_method,
64                         ossl_statem_accept,
65                         ssl_undefined_function, TLSv1_2_enc_data)
66 #endif
67 #ifndef OPENSSL_NO_TLS1_1_METHOD
68 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
69                         tlsv1_1_server_method,
70                         ossl_statem_accept,
71                         ssl_undefined_function, TLSv1_1_enc_data)
72 #endif
73 #ifndef OPENSSL_NO_TLS1_METHOD
74 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
75                         tlsv1_server_method,
76                         ossl_statem_accept,
77                         ssl_undefined_function, TLSv1_enc_data)
78 #endif
79 #ifndef OPENSSL_NO_SSL3_METHOD
80 IMPLEMENT_ssl3_meth_func(sslv3_server_method,
81                          ossl_statem_accept, ssl_undefined_function)
82 #endif
83 /*-
84  * TLS/SSLv3 client methods
85  */
86 IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,
87                         TLS_client_method,
88                         ssl_undefined_function,
89                         ossl_statem_connect, TLSv1_2_enc_data)
90 #ifndef OPENSSL_NO_TLS1_3_METHOD
91 IMPLEMENT_tls_meth_func(TLS1_3_VERSION, 0, SSL_OP_NO_TLSv1_3,
92                         tlsv1_3_client_method,
93                         ssl_undefined_function,
94                         ossl_statem_connect, TLSv1_3_enc_data)
95 #endif
96 #ifndef OPENSSL_NO_TLS1_2_METHOD
97 IMPLEMENT_tls_meth_func(TLS1_2_VERSION, 0, SSL_OP_NO_TLSv1_2,
98                         tlsv1_2_client_method,
99                         ssl_undefined_function,
100                         ossl_statem_connect, TLSv1_2_enc_data)
101 #endif
102 #ifndef OPENSSL_NO_TLS1_1_METHOD
103 IMPLEMENT_tls_meth_func(TLS1_1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1_1,
104                         tlsv1_1_client_method,
105                         ssl_undefined_function,
106                         ossl_statem_connect, TLSv1_1_enc_data)
107 #endif
108 #ifndef OPENSSL_NO_TLS1_METHOD
109 IMPLEMENT_tls_meth_func(TLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_TLSv1,
110                         tlsv1_client_method,
111                         ssl_undefined_function,
112                         ossl_statem_connect, TLSv1_enc_data)
113 #endif
114 #ifndef OPENSSL_NO_SSL3_METHOD
115 IMPLEMENT_ssl3_meth_func(sslv3_client_method,
116                          ssl_undefined_function, ossl_statem_connect)
117 #endif
118 /*-
119  * DTLS methods
120  */
121 #ifndef OPENSSL_NO_DTLS1_METHOD
122 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
123                           dtlsv1_method,
124                           ossl_statem_accept,
125                           ossl_statem_connect, DTLSv1_enc_data)
126 #endif
127 #ifndef OPENSSL_NO_DTLS1_2_METHOD
128 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
129                           dtlsv1_2_method,
130                           ossl_statem_accept,
131                           ossl_statem_connect, DTLSv1_2_enc_data)
132 #endif
133 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
134                           DTLS_method,
135                           ossl_statem_accept,
136                           ossl_statem_connect, DTLSv1_2_enc_data)
137
138 /*-
139  * DTLS server methods
140  */
141 #ifndef OPENSSL_NO_DTLS1_METHOD
142 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
143                           dtlsv1_server_method,
144                           ossl_statem_accept,
145                           ssl_undefined_function, DTLSv1_enc_data)
146 #endif
147 #ifndef OPENSSL_NO_DTLS1_2_METHOD
148 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
149                           dtlsv1_2_server_method,
150                           ossl_statem_accept,
151                           ssl_undefined_function, DTLSv1_2_enc_data)
152 #endif
153 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
154                           DTLS_server_method,
155                           ossl_statem_accept,
156                           ssl_undefined_function, DTLSv1_2_enc_data)
157
158 /*-
159  * DTLS client methods
160  */
161 #ifndef OPENSSL_NO_DTLS1_METHOD
162 IMPLEMENT_dtls1_meth_func(DTLS1_VERSION, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
163                           dtlsv1_client_method,
164                           ssl_undefined_function,
165                           ossl_statem_connect, DTLSv1_enc_data)
166 IMPLEMENT_dtls1_meth_func(DTLS1_BAD_VER, SSL_METHOD_NO_SUITEB, SSL_OP_NO_DTLSv1,
167                           dtls_bad_ver_client_method,
168                           ssl_undefined_function,
169                           ossl_statem_connect, DTLSv1_enc_data)
170 #endif
171 #ifndef OPENSSL_NO_DTLS1_2_METHOD
172 IMPLEMENT_dtls1_meth_func(DTLS1_2_VERSION, 0, SSL_OP_NO_DTLSv1_2,
173                           dtlsv1_2_client_method,
174                           ssl_undefined_function,
175                           ossl_statem_connect, DTLSv1_2_enc_data)
176 #endif
177 IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
178                           DTLS_client_method,
179                           ssl_undefined_function,
180                           ossl_statem_connect, DTLSv1_2_enc_data)
181 #if OPENSSL_API_COMPAT < 0x10100000L
182 # ifndef OPENSSL_NO_TLS1_2_METHOD
183 const SSL_METHOD *TLSv1_2_method(void)
184 {
185     return tlsv1_2_method();
186 }
187
188 const SSL_METHOD *TLSv1_2_server_method(void)
189 {
190     return tlsv1_2_server_method();
191 }
192
193 const SSL_METHOD *TLSv1_2_client_method(void)
194 {
195     return tlsv1_2_client_method();
196 }
197 # endif
198
199 # ifndef OPENSSL_NO_TLS1_1_METHOD
200 const SSL_METHOD *TLSv1_1_method(void)
201 {
202     return tlsv1_1_method();
203 }
204
205 const SSL_METHOD *TLSv1_1_server_method(void)
206 {
207     return tlsv1_1_server_method();
208 }
209
210 const SSL_METHOD *TLSv1_1_client_method(void)
211 {
212     return tlsv1_1_client_method();
213 }
214 # endif
215
216 # ifndef OPENSSL_NO_TLS1_METHOD
217 const SSL_METHOD *TLSv1_method(void)
218 {
219     return tlsv1_method();
220 }
221
222 const SSL_METHOD *TLSv1_server_method(void)
223 {
224     return tlsv1_server_method();
225 }
226
227 const SSL_METHOD *TLSv1_client_method(void)
228 {
229     return tlsv1_client_method();
230 }
231 # endif
232
233 # ifndef OPENSSL_NO_SSL3_METHOD
234 const SSL_METHOD *SSLv3_method(void)
235 {
236     return sslv3_method();
237 }
238
239 const SSL_METHOD *SSLv3_server_method(void)
240 {
241     return sslv3_server_method();
242 }
243
244 const SSL_METHOD *SSLv3_client_method(void)
245 {
246     return sslv3_client_method();
247 }
248 # endif
249
250 # ifndef OPENSSL_NO_DTLS1_2_METHOD
251 const SSL_METHOD *DTLSv1_2_method(void)
252 {
253     return dtlsv1_2_method();
254 }
255
256 const SSL_METHOD *DTLSv1_2_server_method(void)
257 {
258     return dtlsv1_2_server_method();
259 }
260
261 const SSL_METHOD *DTLSv1_2_client_method(void)
262 {
263     return dtlsv1_2_client_method();
264 }
265 # endif
266
267 # ifndef OPENSSL_NO_DTLS1_METHOD
268 const SSL_METHOD *DTLSv1_method(void)
269 {
270     return dtlsv1_method();
271 }
272
273 const SSL_METHOD *DTLSv1_server_method(void)
274 {
275     return dtlsv1_server_method();
276 }
277
278 const SSL_METHOD *DTLSv1_client_method(void)
279 {
280     return dtlsv1_client_method();
281 }
282 # endif
283
284 #endif