• 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_X509_H_
16 #define _SSL_X509_H_
17 
18 #ifdef __cplusplus
19  extern "C" {
20 #endif
21 
22 #include "ssl_types.h"
23 #include "ssl_stack.h"
24 
25 DEFINE_STACK_OF(X509_NAME)
26 
27 /**
28  * @brief create a X509 certification object according to input X509 certification
29  *
30  * @param ix - input X509 certification point
31  *
32  * @return new X509 certification object point
33  */
34 X509* __X509_new(X509 *ix);
35 
36 /**
37  * @brief create a X509 certification object
38  *
39  * @param none
40  *
41  * @return X509 certification object point
42  */
43 X509* X509_new(void);
44 
45 /**
46  * @brief load a character certification context into system context. If '*cert' is pointed to the
47  *        certification, then load certification into it. Or create a new X509 certification object
48  *
49  * @param cert   - a point pointed to X509 certification
50  * @param buffer - a point pointed to the certification context memory point
51  * @param length - certification bytes
52  *
53  * @return X509 certification object point
54  */
55 X509* d2i_X509(X509 **cert, const unsigned char *buffer, long len);
56 
57 /**
58  * @brief free a X509 certification object
59  *
60  * @param x - X509 certification object point
61  *
62  * @return none
63  */
64 void X509_free(X509 *x);
65 
66 /**
67  * @brief set SSL context client CA certification
68  *
69  * @param ctx - SSL context point
70  * @param x   - X509 certification point
71  *
72  * @return result
73  *     0 : failed
74  *     1 : OK
75  */
76 int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);
77 
78 /**
79  * @brief add CA client certification into the SSL
80  *
81  * @param ssl - SSL point
82  * @param x   - X509 certification point
83  *
84  * @return result
85  *     0 : failed
86  *     1 : OK
87  */
88 int SSL_add_client_CA(SSL *ssl, X509 *x);
89 
90 /**
91  * @brief load certification into the SSL
92  *
93  * @param ssl - SSL point
94  * @param len - data bytes
95  * @param d   - data point
96  *
97  * @return result
98  *     0 : failed
99  *     1 : OK
100  *
101  */
102 
103 int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);
104 
105 const char *X509_verify_cert_error_string(long n);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif
112