[gnome-keyring: 10/12] gck: Add functions for matching uri to modules and tokens
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring: 10/12] gck: Add functions for matching uri to modules and tokens
- Date: Mon, 19 Sep 2011 07:39:27 +0000 (UTC)
commit 03b40841cc3468ad15bc0e2ef7633d0d63a2716f
Author: Stef Walter <stefw collabora co uk>
Date: Fri Sep 9 14:54:32 2011 +0200
gck: Add functions for matching uri to modules and tokens
docs/reference/gck/gck-sections.txt | 2 +
gck/gck-module.c | 31 ++++++++++++++++++++++++++++
gck/gck-slot.c | 38 +++++++++++++++++++++++++++++++++++
gck/gck.h | 14 +++++++++++-
4 files changed, 83 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gck/gck-sections.txt b/docs/reference/gck/gck-sections.txt
index cf8b4d5..4615fef 100644
--- a/docs/reference/gck/gck-sections.txt
+++ b/docs/reference/gck/gck-sections.txt
@@ -68,6 +68,7 @@ gck_module_initialize_finish
gck_module_new
gck_module_equal
gck_module_hash
+gck_module_match
gck_module_get_path
gck_module_get_functions
gck_module_get_info
@@ -115,6 +116,7 @@ gck_slot_hash
gck_slot_get_module
gck_slot_get_handle
gck_slot_get_info
+gck_slot_match
gck_slot_get_token_info
gck_slot_get_mechanisms
gck_slot_get_mechanism_info
diff --git a/gck/gck-module.c b/gck/gck-module.c
index 1b018ed..0015a88 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -736,3 +736,34 @@ gck_module_get_functions (GckModule *self)
g_return_val_if_fail (GCK_IS_MODULE (self), NULL);
return self->pv->funcs;
}
+
+/**
+ * gck_module_match:
+ * @self: the module to match
+ * @uri: the uri to match against the module
+ *
+ * Check whether the PKCS\#11 URI matches the module
+ *
+ * Returns: whether the URI matches or not
+ */
+gboolean
+gck_module_match (GckModule *self,
+ GckUriData *uri)
+{
+ gboolean match = TRUE;
+ GckModuleInfo *info;
+
+ g_return_val_if_fail (GCK_IS_MODULE (self), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ if (uri->any_unrecognized)
+ match = FALSE;
+
+ if (match && uri->module_info) {
+ info = gck_module_get_info (self);
+ match = _gck_module_info_match (uri->module_info, info);
+ gck_module_info_free (info);
+ }
+
+ return match;
+}
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index 9d789ae..ebde95c 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -1103,3 +1103,41 @@ gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, GError **err)
return session;
}
+
+/**
+ * gck_slot_match:
+ * @self: the slot to match
+ * @uri: the uri to match against the slot
+ *
+ * Check whether the PKCS\#11 URI matches the slot
+ *
+ * Returns: whether the URI matches or not
+ */
+gboolean
+gck_slot_match (GckSlot *self,
+ GckUriData *uri)
+{
+ GckModule *module;
+ GckTokenInfo *info;
+ gboolean match = TRUE;
+
+ g_return_val_if_fail (GCK_IS_SLOT (self), FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ if (uri->any_unrecognized)
+ match = FALSE;
+
+ if (match && uri->module_info) {
+ module = gck_slot_get_module (self);
+ match = gck_module_match (module, uri);
+ g_object_unref (module);
+ }
+
+ if (match && uri->token_info) {
+ info = gck_slot_get_token_info (self);
+ match = _gck_token_info_match (uri->token_info, info);
+ gck_token_info_free (info);
+ }
+
+ return match;
+}
diff --git a/gck/gck.h b/gck/gck.h
index 0fe7073..1d8ff3d 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -246,6 +246,7 @@ typedef struct _GckModule GckModule;
typedef struct _GckSession GckSession;
typedef struct _GckObject GckObject;
typedef struct _GckEnumerator GckEnumerator;
+typedef struct _GckUriData GckUriData;
/* -------------------------------------------------------------------------
* MODULE
@@ -315,6 +316,9 @@ gboolean gck_module_equal (gconstpointer mod
guint gck_module_hash (gconstpointer module);
+gboolean gck_module_match (GckModule *self,
+ GckUriData *uri);
+
const gchar* gck_module_get_path (GckModule *self);
CK_FUNCTION_LIST_PTR gck_module_get_functions (GckModule *self);
@@ -454,6 +458,9 @@ typedef struct _GckTokenInfo {
gint64 utc_time;
} GckTokenInfo;
+gboolean gck_token_info_match (GckTokenInfo *match,
+ GckTokenInfo *info);
+
void gck_token_info_free (GckTokenInfo *token_info);
typedef struct _GckMechanismInfo {
@@ -507,6 +514,9 @@ gboolean gck_slot_equal (gconstpointer slot1
guint gck_slot_hash (gconstpointer slot);
+gboolean gck_slot_match (GckSlot *self,
+ GckUriData *uri);
+
GckSlot* gck_slot_from_handle (GckModule *module,
CK_SLOT_ID slot_id);
@@ -1162,7 +1172,7 @@ typedef enum {
GCK_URI_FOR_ANY = 0x0000FFFF,
} GckUriFlags;
-typedef struct _GckUriData {
+struct _GckUriData {
gboolean any_unrecognized;
GckModuleInfo *module_info;
GckTokenInfo *token_info;
@@ -1170,7 +1180,7 @@ typedef struct _GckUriData {
/*< private >*/
gpointer dummy[4];
-} GckUriData;
+};
#define GCK_URI_ERROR (gck_uri_get_error_quark ())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]