1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* gck-private.h - the GObject PKCS#11 wrapper library
4 Copyright (C) 2008, Stefan Walter
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.
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.
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.
21 Author: Stef Walter <nielsen@memberwebs.com>
24 #ifndef GCK_PRIVATE_H_
25 #define GCK_PRIVATE_H_
30 #include <glib-object.h>
35 /* ---------------------------------------------------------------------------
39 void _gck_attributes_lock (GckAttributes *attrs);
41 void _gck_attributes_unlock (GckAttributes *attrs);
43 CK_ATTRIBUTE_PTR _gck_attributes_prepare_in (GckAttributes *attrs,
44 CK_ULONG_PTR n_attrs);
46 CK_ATTRIBUTE_PTR _gck_attributes_commit_in (GckAttributes *attrs,
47 CK_ULONG_PTR n_attrs);
49 CK_ATTRIBUTE_PTR _gck_attributes_commit_out (GckAttributes *attrs,
50 CK_ULONG_PTR n_attrs);
52 gchar * _gck_attributes_format (GckAttributes *attrs);
54 /* ----------------------------------------------------------------------------
58 guint _gck_ulong_hash (gconstpointer v);
60 gboolean _gck_ulong_equal (gconstpointer v1,
63 const gchar * _gck_stringize_rv (CK_RV rv);
65 CK_RV _gck_rv_from_error (GError *error,
66 CK_RV catch_all_code);
68 /* ----------------------------------------------------------------------------
72 GckModule* _gck_module_new_initialized (CK_FUNCTION_LIST_PTR funcs);
74 GckModuleInfo* _gck_module_info_from_pkcs11 (CK_INFO_PTR info);
76 void _gck_module_info_to_pkcs11 (GckModuleInfo* module_info,
79 gboolean _gck_module_info_match (GckModuleInfo *match,
80 GckModuleInfo *module_info);
82 /* -----------------------------------------------------------------------------
86 GckEnumerator* _gck_enumerator_new (GList *modules,
87 GckSessionOptions session_options,
88 GckUriData *uri_data);
90 /* ----------------------------------------------------------------------------
94 GckTokenInfo* _gck_token_info_from_pkcs11 (CK_TOKEN_INFO_PTR info);
96 void _gck_token_info_to_pkcs11 (GckTokenInfo *token_info,
97 CK_TOKEN_INFO_PTR info);
99 gboolean _gck_token_info_match (GckTokenInfo *match,
102 CK_RV _gck_session_authenticate_token (CK_FUNCTION_LIST_PTR funcs,
103 CK_SESSION_HANDLE session,
105 GTlsInteraction *interaction,
106 GCancellable *cancellable);
108 CK_RV _gck_session_authenticate_key (CK_FUNCTION_LIST_PTR funcs,
109 CK_SESSION_HANDLE session,
111 GTlsInteraction *interaction,
112 GCancellable *cancellable);
114 /* ----------------------------------------------------------------------------
118 void _gck_password_update (GckPassword *self,
119 gboolean request_retry);
121 /* ----------------------------------------------------------------------------
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))
129 typedef struct _GckInteraction GckInteraction;
131 GType _gck_interaction_get_type (void) G_GNUC_CONST;
133 GTlsInteraction * _gck_interaction_new (gpointer token_or_key);
135 /* ----------------------------------------------------------------------------
139 typedef CK_RV (*GckPerformFunc) (gpointer call_data);
140 typedef gboolean (*GckCompleteFunc) (gpointer call_data, CK_RV result);
142 typedef struct _GckCall GckCall;
144 typedef struct _GckArguments {
147 /* For the call function to use */
148 CK_FUNCTION_LIST_PTR pkcs11;
153 #define GCK_MECHANISM_EMPTY { 0UL, NULL, 0 }
155 #define GCK_ARGUMENTS_INIT { NULL, NULL, 0 }
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))
164 typedef struct _GckCallClass GckCallClass;
166 GType _gck_call_get_type (void) G_GNUC_CONST;
168 #define _gck_call_arguments(call, type) (type*)(_gck_call_get_arguments (GCK_CALL (call)))
170 gpointer _gck_call_get_arguments (GckCall *call);
172 void _gck_call_uninitialize (void);
174 gboolean _gck_call_sync (gpointer object,
178 GCancellable *cancellable,
181 gpointer _gck_call_async_prep (gpointer object,
186 gpointer destroy_func);
188 GckCall* _gck_call_async_ready (gpointer args,
189 GCancellable *cancellable,
190 GAsyncReadyCallback callback,
193 void _gck_call_async_go (GckCall *call);
195 void _gck_call_async_ready_go (gpointer args,
196 GCancellable *cancellable,
197 GAsyncReadyCallback callback,
200 void _gck_call_async_short (GckCall *call,
203 gboolean _gck_call_basic_finish (GAsyncResult *result,
206 void _gck_call_async_object (GckCall *call,
209 #endif /* GCK_PRIVATE_H_ */