gnome-keyring r1430 - in trunk: . pkcs11/gck pkcs11/gck/tests
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1430 - in trunk: . pkcs11/gck pkcs11/gck/tests
- Date: Sun, 4 Jan 2009 23:14:54 +0000 (UTC)
Author: nnielsen
Date: Sun Jan 4 23:14:53 2009
New Revision: 1430
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1430&view=rev
Log:
* pkcs11/gck/gck-module.c: Make the module properly support slot appartments.
Modified:
trunk/ChangeLog
trunk/pkcs11/gck/gck-module.c
trunk/pkcs11/gck/tests/Makefile.am
Modified: trunk/pkcs11/gck/gck-module.c
==============================================================================
--- trunk/pkcs11/gck/gck-module.c (original)
+++ trunk/pkcs11/gck/gck-module.c Sun Jan 4 23:14:53 2009
@@ -22,6 +22,7 @@
#include "config.h"
#include "pkcs11/pkcs11.h"
+#include "pkcs11/pkcs11g.h"
#include "gck-attributes.h"
#include "gck-factory.h"
@@ -56,6 +57,9 @@
gboolean logged_in;
} VirtualSlot;
+/* Our slot identifier is 1 */
+#define GCK_SLOT_ID 1
+
G_DEFINE_TYPE (GckModule, gck_module, G_TYPE_OBJECT);
/* These info blocks are used unless derived class overrides */
@@ -63,7 +67,7 @@
static const CK_INFO default_module_info = {
{ CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR },
"Gnome Keyring",
- 0x40000000, /* TODO: Define as CKF_VIRTUAL_SLOTS elsewhere */
+ CKF_GNOME_APPARTMENTS,
"Gnome Keyring Module",
{ 1, 1 },
};
@@ -705,7 +709,8 @@
g_return_val_if_fail (slot_list, CKR_ARGUMENTS_BAD);
- slot_list[0] = 0;
+ /* Answer C_GetSlotList with 0 for app */
+ slot_list[0] = CK_GNOME_VIRTUAL_SLOT_ID (GCK_SLOT_ID, 0);
*count = 1;
return CKR_OK;
}
@@ -717,7 +722,9 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
- if (!info)
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
+ if (info == NULL)
return CKR_ARGUMENTS_BAD;
/* Any slot ID is valid for partitioned module */
@@ -741,7 +748,9 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
- if (!info)
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
+ if (info == NULL)
return CKR_ARGUMENTS_BAD;
/* Any slot ID is valid for partitioned module */
@@ -772,7 +781,9 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
- if (!count)
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
+ if (count == NULL)
return CKR_ARGUMENTS_BAD;
/* Just want to get the count */
@@ -803,7 +814,9 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
- if (!info)
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
+ if (info == NULL)
return CKR_ARGUMENTS_BAD;
for (index = 0; index < n_mechanisms; ++index) {
@@ -826,7 +839,7 @@
}
CK_RV
-gck_module_C_OpenSession (GckModule *self, CK_SLOT_ID slot_id, CK_FLAGS flags, CK_VOID_PTR user_data,
+gck_module_C_OpenSession (GckModule *self, CK_SLOT_ID id, CK_FLAGS flags, CK_VOID_PTR user_data,
CK_NOTIFY callback, CK_SESSION_HANDLE_PTR result)
{
CK_SESSION_HANDLE handle;
@@ -836,6 +849,8 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
if (!result)
return CKR_ARGUMENTS_BAD;
@@ -843,9 +858,9 @@
return CKR_SESSION_PARALLEL_NOT_SUPPORTED;
/* Lookup or register the virtual slot */
- slot = lookup_virtual_slot (self, slot_id);
+ slot = lookup_virtual_slot (self, id);
if (slot == NULL) {
- slot = virtual_slot_new (GCK_MODULE_GET_CLASS (self), slot_id);
+ slot = virtual_slot_new (GCK_MODULE_GET_CLASS (self), id);
register_virtual_slot (self, slot);
}
@@ -899,7 +914,7 @@
}
CK_RV
-gck_module_C_CloseAllSessions (GckModule *self, CK_SLOT_ID slot_id)
+gck_module_C_CloseAllSessions (GckModule *self, CK_SLOT_ID id)
{
VirtualSlot *slot;
CK_SESSION_HANDLE handle;
@@ -907,9 +922,12 @@
g_return_val_if_fail (GCK_IS_MODULE (self), CKR_CRYPTOKI_NOT_INITIALIZED);
+ if (CK_GNOME_VIRTUAL_TO_SLOT (id) != GCK_SLOT_ID)
+ return CKR_SLOT_ID_INVALID;
+
/* Calculate the virtual slot */
- slot = lookup_virtual_slot (self, slot_id);
- if (!slot)
+ slot = lookup_virtual_slot (self, id);
+ if (slot == NULL)
return CKR_OK;
/* Unregister all its sessions */
Modified: trunk/pkcs11/gck/tests/Makefile.am
==============================================================================
--- trunk/pkcs11/gck/tests/Makefile.am (original)
+++ trunk/pkcs11/gck/tests/Makefile.am Sun Jan 4 23:14:53 2009
@@ -11,7 +11,7 @@
unit-test-data-asn1.c \
unit-test-data-der.c \
unit-test-data-openssl.c \
- unit-test-transaction.c \
+ unit-test-transaction.c \
unit-test-store.c \
unit-test-memory-store.c \
unit-test-file-store.c \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]