Split the GCR and GCK libraries out of gnome-keyring
[platform/upstream/gcr.git] / gck / gck-private.h
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gck-private.h - the GObject PKCS#11 wrapper library
3
4    Copyright (C) 2008, Stefan Walter
5
6    The Gnome Keyring Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Library General Public License as
8    published by the Free Software Foundation; either version 2 of the
9    License, or (at your option) any later version.
10
11    The Gnome Keyring Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15
16    You should have received a copy of the GNU Library General Public
17    License along with the Gnome Library; see the file COPYING.LIB.  If not,
18    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.
20
21    Author: Stef Walter <nielsen@memberwebs.com>
22 */
23
24 #ifndef GCK_PRIVATE_H_
25 #define GCK_PRIVATE_H_
26
27 #include "gck.h"
28
29 #include <glib.h>
30 #include <glib-object.h>
31 #include <gio/gio.h>
32
33 G_BEGIN_DECLS
34
35 /* ---------------------------------------------------------------------------
36  * ATTRIBUTE INTERNALS
37  */
38
39 void                _gck_attributes_lock                   (GckAttributes *attrs);
40
41 void                _gck_attributes_unlock                 (GckAttributes *attrs);
42
43 CK_ATTRIBUTE_PTR    _gck_attributes_prepare_in             (GckAttributes *attrs,
44                                                              CK_ULONG_PTR n_attrs);
45
46 CK_ATTRIBUTE_PTR    _gck_attributes_commit_in              (GckAttributes *attrs,
47                                                              CK_ULONG_PTR n_attrs);
48
49 CK_ATTRIBUTE_PTR    _gck_attributes_commit_out             (GckAttributes *attrs,
50                                                              CK_ULONG_PTR n_attrs);
51
52 gchar *             _gck_attributes_format                 (GckAttributes *attrs);
53
54 /* ----------------------------------------------------------------------------
55  * MISC
56  */
57
58 guint               _gck_ulong_hash                        (gconstpointer v);
59
60 gboolean            _gck_ulong_equal                       (gconstpointer v1,
61                                                              gconstpointer v2);
62
63 const gchar *       _gck_stringize_rv                      (CK_RV rv);
64
65 CK_RV               _gck_rv_from_error                     (GError *error,
66                                                             CK_RV catch_all_code);
67
68 /* ----------------------------------------------------------------------------
69  * MODULE
70  */
71
72 GckModule*          _gck_module_new_initialized            (CK_FUNCTION_LIST_PTR funcs);
73
74 GckModuleInfo*      _gck_module_info_from_pkcs11            (CK_INFO_PTR info);
75
76 void                _gck_module_info_to_pkcs11              (GckModuleInfo* module_info,
77                                                              CK_INFO_PTR info);
78
79 gboolean            _gck_module_info_match                  (GckModuleInfo *match,
80                                                              GckModuleInfo *module_info);
81
82 /* -----------------------------------------------------------------------------
83  * ENUMERATOR
84  */
85
86 GckEnumerator*      _gck_enumerator_new                     (GList *modules,
87                                                              GckSessionOptions session_options,
88                                                              GckUriData *uri_data);
89
90 /* ----------------------------------------------------------------------------
91  * SLOT
92  */
93
94 GckTokenInfo*      _gck_token_info_from_pkcs11              (CK_TOKEN_INFO_PTR info);
95
96 void               _gck_token_info_to_pkcs11                (GckTokenInfo *token_info,
97                                                              CK_TOKEN_INFO_PTR info);
98
99 gboolean           _gck_token_info_match                    (GckTokenInfo *match,
100                                                              GckTokenInfo *info);
101
102 CK_RV              _gck_session_authenticate_token          (CK_FUNCTION_LIST_PTR funcs,
103                                                              CK_SESSION_HANDLE session,
104                                                              GckSlot *token,
105                                                              GTlsInteraction *interaction,
106                                                              GCancellable *cancellable);
107
108 CK_RV              _gck_session_authenticate_key            (CK_FUNCTION_LIST_PTR funcs,
109                                                              CK_SESSION_HANDLE session,
110                                                              GckObject *key,
111                                                              GTlsInteraction *interaction,
112                                                              GCancellable *cancellable);
113
114 /* ----------------------------------------------------------------------------
115  * PASSWORD
116  */
117
118 void               _gck_password_update                     (GckPassword *self,
119                                                              gboolean request_retry);
120
121 /* ----------------------------------------------------------------------------
122  * INTERACTION
123  */
124
125 #define GCK_TYPE_INTERACTION    (_gck_interaction_get_type ())
126 #define GCK_INTERACTION(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCK_TYPE_INTERACTION, GckInteraction))
127 #define GCK_IS_INTERACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCK_TYPE_INTERACTION))
128
129 typedef struct _GckInteraction GckInteraction;
130
131 GType               _gck_interaction_get_type               (void) G_GNUC_CONST;
132
133 GTlsInteraction *   _gck_interaction_new                    (gpointer token_or_key);
134
135 /* ----------------------------------------------------------------------------
136  * CALL
137  */
138
139 typedef CK_RV (*GckPerformFunc) (gpointer call_data);
140 typedef gboolean (*GckCompleteFunc) (gpointer call_data, CK_RV result);
141
142 typedef struct _GckCall GckCall;
143
144 typedef struct _GckArguments {
145         GckCall *call;
146
147         /* For the call function to use */
148         CK_FUNCTION_LIST_PTR pkcs11;
149         CK_ULONG handle;
150
151 } GckArguments;
152
153 #define GCK_MECHANISM_EMPTY        { 0UL, NULL, 0 }
154
155 #define GCK_ARGUMENTS_INIT         { NULL, NULL, 0 }
156
157 #define GCK_TYPE_CALL             (_gck_call_get_type())
158 #define GCK_CALL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_CALL, GckCall))
159 #define GCK_CALL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_CALL, GckCall))
160 #define GCK_IS_CALL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_CALL))
161 #define GCK_IS_CALL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_CALL))
162 #define GCK_CALL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_CALL, GckCallClass))
163
164 typedef struct _GckCallClass GckCallClass;
165
166 GType              _gck_call_get_type                    (void) G_GNUC_CONST;
167
168 #define            _gck_call_arguments(call, type)       (type*)(_gck_call_get_arguments (GCK_CALL (call)))
169
170 gpointer           _gck_call_get_arguments               (GckCall *call);
171
172 void               _gck_call_uninitialize                (void);
173
174 gboolean           _gck_call_sync                        (gpointer object,
175                                                            gpointer perform,
176                                                            gpointer complete,
177                                                            gpointer args,
178                                                            GCancellable *cancellable,
179                                                            GError **err);
180
181 gpointer           _gck_call_async_prep                  (gpointer object,
182                                                            gpointer cb_object,
183                                                            gpointer perform,
184                                                            gpointer complete,
185                                                            gsize args_size,
186                                                            gpointer destroy_func);
187
188 GckCall*          _gck_call_async_ready                 (gpointer args,
189                                                            GCancellable *cancellable,
190                                                            GAsyncReadyCallback callback,
191                                                            gpointer user_data);
192
193 void               _gck_call_async_go                    (GckCall *call);
194
195 void               _gck_call_async_ready_go              (gpointer args,
196                                                            GCancellable *cancellable,
197                                                            GAsyncReadyCallback callback,
198                                                            gpointer user_data);
199
200 void               _gck_call_async_short                 (GckCall *call,
201                                                            CK_RV rv);
202
203 gboolean           _gck_call_basic_finish                (GAsyncResult *result,
204                                                            GError **err);
205
206 void               _gck_call_async_object                (GckCall *call,
207                                                            gpointer object);
208
209 #endif /* GCK_PRIVATE_H_ */