• 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_METHODS_H_
16 #define _SSL_METHODS_H_
17 
18 #include "ssl_types.h"
19 
20 #ifdef __cplusplus
21  extern "C" {
22 #endif
23 
24 /**
25  * TLS method function implement
26  */
27 #define IMPLEMENT_TLS_METHOD_FUNC(func_name, \
28                     new, free, \
29                     handshake, shutdown, clear, \
30                     read, send, pending, \
31                     set_fd, get_fd, \
32                     set_bufflen, \
33                     get_verify_result, \
34                     get_state) \
35         static const SSL_METHOD_FUNC func_name LOCAL_ATRR = { \
36                 new, \
37                 free, \
38                 handshake, \
39                 shutdown, \
40                 clear, \
41                 read, \
42                 send, \
43                 pending, \
44                 set_fd, \
45                 get_fd, \
46                 set_bufflen, \
47                 get_verify_result, \
48                 get_state \
49         };
50 
51 #define IMPLEMENT_TLS_METHOD(ver, mode, fun, func_name) \
52     const SSL_METHOD* func_name(void) { \
53         static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
54                 ver, \
55                 mode, \
56                 &(fun), \
57         }; \
58         return &func_name##_data; \
59     }
60 
61 #define IMPLEMENT_SSL_METHOD(ver, mode, fun, func_name) \
62     const SSL_METHOD* func_name(void) { \
63         static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
64                 ver, \
65                 mode, \
66                 &(fun), \
67         }; \
68         return &func_name##_data; \
69     }
70 
71 #define IMPLEMENT_X509_METHOD(func_name, \
72                 new, \
73                 free, \
74                 load, \
75                 show_info) \
76     const X509_METHOD* func_name(void) { \
77         static const X509_METHOD func_name##_data LOCAL_ATRR = { \
78                 new, \
79                 free, \
80                 load, \
81                 show_info \
82         }; \
83         return &func_name##_data; \
84     }
85 
86 #define IMPLEMENT_PKEY_METHOD(func_name, \
87                 new, \
88                 free, \
89                 load) \
90     const PKEY_METHOD* func_name(void) { \
91         static const PKEY_METHOD func_name##_data LOCAL_ATRR = { \
92                 new, \
93                 free, \
94                 load \
95         }; \
96         return &func_name##_data; \
97     }
98 
99 /**
100  * @brief get X509 object method
101  *
102  * @param none
103  *
104  * @return X509 object method point
105  */
106 const X509_METHOD* X509_method(void);
107 
108 /**
109  * @brief get private key object method
110  *
111  * @param none
112  *
113  * @return private key object method point
114  */
115 const PKEY_METHOD* EVP_PKEY_method(void);
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif
122