[gnome-keyring/dbus-api] [gck] Return CKR_ATTRIBUTE_READ_ONLY when attribute exists.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api] [gck] Return CKR_ATTRIBUTE_READ_ONLY when attribute exists.
- Date: Sun, 30 Aug 2009 18:54:34 +0000 (UTC)
commit 046dcf54982611d735c9cf690c49154bc0fa3057
Author: Stef Walter <stef memberwebs com>
Date: Sun Aug 30 18:51:41 2009 +0000
[gck] Return CKR_ATTRIBUTE_READ_ONLY when attribute exists.
When setting an attribute, return CKR_ATTRIBUTE_READ_ONLY when an
attribute exists but cannot be written to. Up until now we were
returning CKR_ATTRIBUTE_TYPE_INVALID.
pkcs11/gck/gck-object.c | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/pkcs11/gck/gck-object.c b/pkcs11/gck/gck-object.c
index 3f7d64f..5b0dba6 100644
--- a/pkcs11/gck/gck-object.c
+++ b/pkcs11/gck/gck-object.c
@@ -193,6 +193,9 @@ static void
gck_object_real_set_attribute (GckObject *self, GckSession *session,
GckTransaction* transaction, CK_ATTRIBUTE* attr)
{
+ CK_ATTRIBUTE check;
+ CK_RV rv;
+
switch (attr->type) {
case CKA_TOKEN:
case CKA_PRIVATE:
@@ -220,7 +223,15 @@ gck_object_real_set_attribute (GckObject *self, GckSession *session,
return;
}
- gck_transaction_fail (transaction, CKR_ATTRIBUTE_TYPE_INVALID);
+ /* Check if this attribute exists */
+ check.type = attr->type;
+ check.pValue = 0;
+ check.ulValueLen = 0;
+ rv = gck_object_get_attribute (self, session, &check);
+ if (rv == CKR_ATTRIBUTE_TYPE_INVALID)
+ gck_transaction_fail (transaction, CKR_ATTRIBUTE_TYPE_INVALID);
+ else
+ gck_transaction_fail (transaction, CKR_ATTRIBUTE_READ_ONLY);
}
static void
@@ -507,9 +518,6 @@ void
gck_object_set_attribute (GckObject *self, GckSession *session,
GckTransaction *transaction, CK_ATTRIBUTE_PTR attr)
{
- CK_ATTRIBUTE check;
- CK_RV rv;
-
g_return_if_fail (GCK_IS_OBJECT (self));
g_return_if_fail (GCK_IS_TRANSACTION (transaction));
g_return_if_fail (!gck_transaction_get_failed (transaction));
@@ -517,18 +525,8 @@ gck_object_set_attribute (GckObject *self, GckSession *session,
g_assert (GCK_OBJECT_GET_CLASS (self)->set_attribute);
- /* Check if this attribute exists */
- check.type = attr->type;
- check.pValue = 0;
- check.ulValueLen = 0;
- rv = gck_object_get_attribute (self, session, &check);
- if (rv == CKR_ATTRIBUTE_TYPE_INVALID) {
- gck_transaction_fail (transaction, rv);
- return;
- }
-
/* Check that the value will actually change */
- if (rv != CKR_OK || !gck_object_match (self, session, attr))
+ if (!gck_object_match (self, session, attr))
GCK_OBJECT_GET_CLASS (self)->set_attribute (self, session, transaction, attr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]