[gnome-keyring/trust-store] [pkcs11] Refresh token before creating token object.
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/trust-store] [pkcs11] Refresh token before creating token object.
- Date: Fri, 26 Nov 2010 21:55:33 +0000 (UTC)
commit d67cb780699ba5505d0a73a0906ee3e3b8f5a518
Author: Stef Walter <stefw collabora co uk>
Date: Fri Nov 26 19:37:52 2010 +0000
[pkcs11] Refresh token before creating token object.
* Also remove redundant function.
pkcs11/gkm/gkm-session.c | 30 +++++++-----------------------
1 files changed, 7 insertions(+), 23 deletions(-)
---
diff --git a/pkcs11/gkm/gkm-session.c b/pkcs11/gkm/gkm-session.c
index 4a43c8d..9c68b0a 100644
--- a/pkcs11/gkm/gkm-session.c
+++ b/pkcs11/gkm/gkm-session.c
@@ -354,27 +354,6 @@ add_object (GkmSession *self, GkmTransaction *transaction, GkmObject *object)
g_object_ref (object));
}
-static gboolean
-attributes_find_boolean (CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs,
- CK_ATTRIBUTE_TYPE type, CK_BBOOL *value)
-{
- CK_ULONG i;
-
- g_assert (attrs || !n_attrs);
- g_assert (value);
-
- for (i = 0; i < n_attrs; ++i) {
- if (attrs[i].type == type &&
- attrs[i].pValue != NULL &&
- attrs[i].ulValueLen == sizeof (CK_BBOOL)) {
- *value = *((CK_BBOOL*)attrs[i].pValue);
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
/* -----------------------------------------------------------------------------
* OBJECT
*/
@@ -767,6 +746,7 @@ gkm_session_create_object_for_factory (GkmSession *self, GkmFactory *factory,
{
GkmTransaction *owned = NULL;
GkmObject *object;
+ gboolean token;
g_return_val_if_fail (GKM_IS_SESSION (self), NULL);
g_return_val_if_fail (factory && factory->func, NULL);
@@ -778,6 +758,10 @@ gkm_session_create_object_for_factory (GkmSession *self, GkmFactory *factory,
g_return_val_if_fail (GKM_IS_TRANSACTION (transaction), NULL);
+ /* Refresh the module if storing on the token */
+ if (gkm_attributes_find_boolean (template, count, CKA_TOKEN, &token) && token)
+ gkm_module_refresh_token (self->pv->module);
+
/*
* Duplicate the memory for the attributes (but not values) so we
* can 'consume' in the factory function
@@ -1115,7 +1099,7 @@ CK_RV
gkm_session_C_FindObjectsInit (GkmSession* self, CK_ATTRIBUTE_PTR template,
CK_ULONG count)
{
- CK_BBOOL token = CK_FALSE;
+ gboolean token = FALSE;
gboolean also_private;
CK_RV rv = CKR_OK;
GArray *found;
@@ -1132,7 +1116,7 @@ gkm_session_C_FindObjectsInit (GkmSession* self, CK_ATTRIBUTE_PTR template,
}
/* See whether this is token or not */
- all = !attributes_find_boolean (template, count, CKA_TOKEN, &token);
+ all = !gkm_attributes_find_boolean (template, count, CKA_TOKEN, &token);
/* An array of object handles */
found = g_array_new (FALSE, TRUE, sizeof (CK_OBJECT_HANDLE));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]