• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2010 Collabora, Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Stef Walter <stefw@collabora.co.uk>
19  */
20 
21 #ifndef __G_TLS_DATABASE_H__
22 #define __G_TLS_DATABASE_H__
23 
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27 
28 #include <gio/giotypes.h>
29 
30 G_BEGIN_DECLS
31 
32 #define G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER "1.3.6.1.5.5.7.3.1"
33 #define G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT "1.3.6.1.5.5.7.3.2"
34 
35 #define G_TYPE_TLS_DATABASE            (g_tls_database_get_type ())
36 #define G_TLS_DATABASE(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_DATABASE, GTlsDatabase))
37 #define G_TLS_DATABASE_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_DATABASE, GTlsDatabaseClass))
38 #define G_IS_TLS_DATABASE(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_DATABASE))
39 #define G_IS_TLS_DATABASE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_DATABASE))
40 #define G_TLS_DATABASE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_DATABASE, GTlsDatabaseClass))
41 
42 typedef struct _GTlsDatabaseClass   GTlsDatabaseClass;
43 typedef struct _GTlsDatabasePrivate GTlsDatabasePrivate;
44 
45 struct _GTlsDatabase
46 {
47   GObject parent_instance;
48 
49   GTlsDatabasePrivate *priv;
50 };
51 
52 struct _GTlsDatabaseClass
53 {
54   GObjectClass parent_class;
55 
56   /* virtual methods */
57 
58   GTlsCertificateFlags  (*verify_chain)                         (GTlsDatabase            *self,
59                                                                  GTlsCertificate         *chain,
60                                                                  const gchar             *purpose,
61                                                                  GSocketConnectable      *identity,
62                                                                  GTlsInteraction         *interaction,
63                                                                  GTlsDatabaseVerifyFlags  flags,
64                                                                  GCancellable            *cancellable,
65                                                                  GError                 **error);
66 
67   void                  (*verify_chain_async)                   (GTlsDatabase            *self,
68                                                                  GTlsCertificate         *chain,
69                                                                  const gchar             *purpose,
70                                                                  GSocketConnectable      *identity,
71                                                                  GTlsInteraction         *interaction,
72                                                                  GTlsDatabaseVerifyFlags  flags,
73                                                                  GCancellable            *cancellable,
74                                                                  GAsyncReadyCallback      callback,
75                                                                  gpointer                 user_data);
76 
77   GTlsCertificateFlags  (*verify_chain_finish)                  (GTlsDatabase            *self,
78                                                                  GAsyncResult            *result,
79                                                                  GError                 **error);
80 
81   gchar*                (*create_certificate_handle)            (GTlsDatabase            *self,
82                                                                  GTlsCertificate         *certificate);
83 
84   GTlsCertificate*      (*lookup_certificate_for_handle)        (GTlsDatabase            *self,
85                                                                  const gchar             *handle,
86                                                                  GTlsInteraction         *interaction,
87                                                                  GTlsDatabaseLookupFlags  flags,
88                                                                  GCancellable            *cancellable,
89                                                                  GError                 **error);
90 
91   void                  (*lookup_certificate_for_handle_async)  (GTlsDatabase            *self,
92                                                                  const gchar             *handle,
93                                                                  GTlsInteraction         *interaction,
94                                                                  GTlsDatabaseLookupFlags  flags,
95                                                                  GCancellable            *cancellable,
96                                                                  GAsyncReadyCallback      callback,
97                                                                  gpointer                 user_data);
98 
99   GTlsCertificate*      (*lookup_certificate_for_handle_finish) (GTlsDatabase            *self,
100                                                                  GAsyncResult            *result,
101                                                                  GError                 **error);
102 
103   GTlsCertificate*      (*lookup_certificate_issuer)            (GTlsDatabase            *self,
104                                                                  GTlsCertificate         *certificate,
105                                                                  GTlsInteraction         *interaction,
106                                                                  GTlsDatabaseLookupFlags  flags,
107                                                                  GCancellable            *cancellable,
108                                                                  GError                 **error);
109 
110   void                  (*lookup_certificate_issuer_async)      (GTlsDatabase            *self,
111                                                                  GTlsCertificate         *certificate,
112                                                                  GTlsInteraction         *interaction,
113                                                                  GTlsDatabaseLookupFlags  flags,
114                                                                  GCancellable            *cancellable,
115                                                                  GAsyncReadyCallback      callback,
116                                                                  gpointer                 user_data);
117 
118   GTlsCertificate*      (*lookup_certificate_issuer_finish)     (GTlsDatabase            *self,
119                                                                  GAsyncResult            *result,
120                                                                  GError                 **error);
121 
122   GList*                (*lookup_certificates_issued_by)        (GTlsDatabase            *self,
123                                                                  GByteArray              *issuer_raw_dn,
124                                                                  GTlsInteraction         *interaction,
125                                                                  GTlsDatabaseLookupFlags  flags,
126                                                                  GCancellable            *cancellable,
127                                                                  GError                 **error);
128 
129   void                  (*lookup_certificates_issued_by_async)  (GTlsDatabase            *self,
130                                                                  GByteArray              *issuer_raw_dn,
131                                                                  GTlsInteraction         *interaction,
132                                                                  GTlsDatabaseLookupFlags  flags,
133                                                                  GCancellable            *cancellable,
134                                                                  GAsyncReadyCallback      callback,
135                                                                  gpointer                 user_data);
136 
137   GList*                (*lookup_certificates_issued_by_finish) (GTlsDatabase            *self,
138                                                                  GAsyncResult            *result,
139                                                                  GError                 **error);
140 
141   /*< private >*/
142   /* Padding for future expansion */
143   gpointer padding[16];
144 };
145 
146 GLIB_AVAILABLE_IN_ALL
147 GType                g_tls_database_get_type                              (void) G_GNUC_CONST;
148 
149 GLIB_AVAILABLE_IN_ALL
150 GTlsCertificateFlags g_tls_database_verify_chain                          (GTlsDatabase            *self,
151                                                                            GTlsCertificate         *chain,
152                                                                            const gchar             *purpose,
153                                                                            GSocketConnectable      *identity,
154                                                                            GTlsInteraction         *interaction,
155                                                                            GTlsDatabaseVerifyFlags  flags,
156                                                                            GCancellable            *cancellable,
157                                                                            GError                 **error);
158 
159 GLIB_AVAILABLE_IN_ALL
160 void                 g_tls_database_verify_chain_async                    (GTlsDatabase            *self,
161                                                                            GTlsCertificate         *chain,
162                                                                            const gchar             *purpose,
163                                                                            GSocketConnectable      *identity,
164                                                                            GTlsInteraction         *interaction,
165                                                                            GTlsDatabaseVerifyFlags  flags,
166                                                                            GCancellable            *cancellable,
167                                                                            GAsyncReadyCallback      callback,
168                                                                            gpointer                 user_data);
169 
170 GLIB_AVAILABLE_IN_ALL
171 GTlsCertificateFlags g_tls_database_verify_chain_finish                   (GTlsDatabase            *self,
172                                                                            GAsyncResult            *result,
173                                                                            GError                 **error);
174 
175 GLIB_AVAILABLE_IN_ALL
176 gchar*               g_tls_database_create_certificate_handle             (GTlsDatabase            *self,
177                                                                            GTlsCertificate         *certificate);
178 
179 GLIB_AVAILABLE_IN_ALL
180 GTlsCertificate*     g_tls_database_lookup_certificate_for_handle         (GTlsDatabase            *self,
181                                                                            const gchar             *handle,
182                                                                            GTlsInteraction         *interaction,
183                                                                            GTlsDatabaseLookupFlags  flags,
184                                                                            GCancellable            *cancellable,
185                                                                            GError                 **error);
186 
187 GLIB_AVAILABLE_IN_ALL
188 void                 g_tls_database_lookup_certificate_for_handle_async   (GTlsDatabase            *self,
189                                                                            const gchar             *handle,
190                                                                            GTlsInteraction         *interaction,
191                                                                            GTlsDatabaseLookupFlags  flags,
192                                                                            GCancellable            *cancellable,
193                                                                            GAsyncReadyCallback      callback,
194                                                                            gpointer                 user_data);
195 
196 GLIB_AVAILABLE_IN_ALL
197 GTlsCertificate*     g_tls_database_lookup_certificate_for_handle_finish  (GTlsDatabase            *self,
198                                                                            GAsyncResult            *result,
199                                                                            GError                 **error);
200 
201 GLIB_AVAILABLE_IN_ALL
202 GTlsCertificate*     g_tls_database_lookup_certificate_issuer             (GTlsDatabase            *self,
203                                                                            GTlsCertificate         *certificate,
204                                                                            GTlsInteraction         *interaction,
205                                                                            GTlsDatabaseLookupFlags  flags,
206                                                                            GCancellable            *cancellable,
207                                                                            GError                 **error);
208 
209 GLIB_AVAILABLE_IN_ALL
210 void                 g_tls_database_lookup_certificate_issuer_async       (GTlsDatabase            *self,
211                                                                            GTlsCertificate         *certificate,
212                                                                            GTlsInteraction         *interaction,
213                                                                            GTlsDatabaseLookupFlags  flags,
214                                                                            GCancellable            *cancellable,
215                                                                            GAsyncReadyCallback      callback,
216                                                                            gpointer                 user_data);
217 
218 GLIB_AVAILABLE_IN_ALL
219 GTlsCertificate*     g_tls_database_lookup_certificate_issuer_finish      (GTlsDatabase            *self,
220                                                                            GAsyncResult            *result,
221                                                                            GError                 **error);
222 
223 GLIB_AVAILABLE_IN_ALL
224 GList*               g_tls_database_lookup_certificates_issued_by         (GTlsDatabase            *self,
225                                                                            GByteArray              *issuer_raw_dn,
226                                                                            GTlsInteraction         *interaction,
227                                                                            GTlsDatabaseLookupFlags  flags,
228                                                                            GCancellable            *cancellable,
229                                                                            GError                 **error);
230 
231 GLIB_AVAILABLE_IN_ALL
232 void                 g_tls_database_lookup_certificates_issued_by_async    (GTlsDatabase            *self,
233                                                                             GByteArray              *issuer_raw_dn,
234                                                                             GTlsInteraction         *interaction,
235                                                                             GTlsDatabaseLookupFlags  flags,
236                                                                             GCancellable            *cancellable,
237                                                                             GAsyncReadyCallback      callback,
238                                                                             gpointer                 user_data);
239 
240 GLIB_AVAILABLE_IN_ALL
241 GList*               g_tls_database_lookup_certificates_issued_by_finish   (GTlsDatabase            *self,
242                                                                             GAsyncResult            *result,
243                                                                             GError                 **error);
244 
245 G_END_DECLS
246 
247 #endif /* __G_TLS_DATABASE_H__ */
248