/** * gck_module_initialize: * @path: The file system path to the PKCS\#11 module to load. * @cancellable: (allow-none): optional cancellation object * @error: A location to store an error resulting from a failed load. * * Load and initialize a PKCS\#11 module represented by a GckModule object. * * Return value: (transfer full): The loaded PKCS\#11 module or %NULL if failed. **/ GckModule* gck_module_initialize (const gchar *path, GCancellable *cancellable, GError **error) { Initialize args = { GCK_ARGUMENTS_INIT, 0, }; g_return_val_if_fail (path != NULL, NULL); g_return_val_if_fail (!error || !*error, NULL); args.path = g_strdup (path); if (!_gck_call_sync (NULL, perform_initialize, NULL, &args, cancellable, error)) { /* A custom error from perform_initialize */ if (args.error) { g_clear_error (error); g_propagate_error (error, args.error); args.error = NULL; } } g_free (args.path); g_clear_error (&args.error); return args.result; }
gboolean gck_slot_init_token (GckSlot *self, const guchar *pin, gsize length, const gchar *label, GCancellable *cancellable, GError **err) { InitToken args = { GCK_ARGUMENTS_INIT, pin, length, label }; return _gck_call_sync (self, perform_init_token, NULL, &args, err); }
/** * gck_slot_open_session_full: * @self: The slot to open a session on. * @options: The options to open the new session with. * @pkcs11_flags: Additional raw PKCS#11 flags. * @app_data: Application data for notification callback. * @notify: PKCS#11 notification callback. * @cancellable: Optional cancellation object, or NULL. * @err: A location to return an error, or NULL. * * Open a session on the slot. If the 'auto reuse' setting is set, * then this may be a recycled session with the same flags. * * This call may block for an indefinite period. * * Return value: A new session or NULL if an error occurs. **/ GckSession* gck_slot_open_session_full (GckSlot *self, guint options, gulong pkcs11_flags, gpointer app_data, CK_NOTIFY notify, GCancellable *cancellable, GError **err) { OpenSession args = { GCK_ARGUMENTS_INIT, 0, }; GckSession *session = NULL; GckModule *module = NULL; CK_SLOT_ID slot_id; g_object_ref (self); /* Try to use a cached session */ module = gck_slot_get_module (self); slot_id = gck_slot_get_handle (self); /* Open a new session */ args.slot = self; args.app_data = app_data; args.notify = notify; args.password = NULL; args.session = 0; args.auto_login = ((options & GCK_SESSION_LOGIN_USER) == GCK_SESSION_LOGIN_USER); args.flags = pkcs11_flags | CKF_SERIAL_SESSION; if ((options & GCK_SESSION_READ_WRITE) == GCK_SESSION_READ_WRITE) args.flags |= CKF_RW_SESSION; if (_gck_call_sync (self, perform_open_session, complete_open_session, &args, cancellable, err)) session = make_session_object (self, options, args.session); g_object_unref (module); g_object_unref (self); return session; }