[gnome-keyring/ui-widgets: 45/49] Merge branch 'gck-work' into ui-widgets
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/ui-widgets: 45/49] Merge branch 'gck-work' into ui-widgets
- Date: Wed, 8 Sep 2010 02:24:04 +0000 (UTC)
commit 1d9ff263ef2a5ddd8faa4d2297e816e3d9cd363b
Merge: 999087a 9ea8cbd
Author: Stef Walter <stef memberwebs com>
Date: Sat Aug 28 23:01:53 2010 +0000
Merge branch 'gck-work' into ui-widgets
.gitignore | 1 +
Makefile.am | 3 +-
configure.in | 14 +-
daemon/Makefile.am | 2 +-
daemon/control/gkd-control-client.c | 30 +
daemon/control/gkd-control-codes.h | 1 +
daemon/control/gkd-control-server.c | 13 +
daemon/control/gkd-control.h | 2 +
daemon/control/tests/.gitignore | 1 +
daemon/control/tests/Makefile.am | 12 +-
daemon/control/tests/test-control-quit.c | 25 +
daemon/data/Makefile.am | 24 +-
daemon/data/gnome-keyring.schemas.in | 46 -
daemon/dbus/Makefile.am | 9 +
daemon/dbus/gkd-dbus-secrets.c | 38 +-
daemon/dbus/gkd-dbus.c | 9 +-
daemon/dbus/gkd-secret-change.c | 41 +-
daemon/dbus/gkd-secret-change.h | 4 +-
daemon/dbus/gkd-secret-create.c | 73 +-
daemon/dbus/gkd-secret-create.h | 12 +-
daemon/dbus/gkd-secret-lock.c | 30 +-
daemon/dbus/gkd-secret-lock.h | 4 +-
daemon/dbus/gkd-secret-objects.c | 308 ++--
daemon/dbus/gkd-secret-objects.h | 8 +-
daemon/dbus/gkd-secret-prompt.c | 10 +-
daemon/dbus/gkd-secret-prompt.h | 6 +-
daemon/dbus/gkd-secret-property.c | 56 +-
daemon/dbus/gkd-secret-property.h | 12 +-
daemon/dbus/gkd-secret-service.c | 62 +-
daemon/dbus/gkd-secret-service.h | 6 +-
daemon/dbus/gkd-secret-session.c | 203 +-
daemon/dbus/gkd-secret-session.h | 12 +-
daemon/dbus/gkd-secret-unlock.c | 82 +-
daemon/dbus/gkd-secret-unlock.h | 4 +-
daemon/dbus/gkd-secret-util.c | 6 +-
daemon/dbus/tests/Makefile.am | 14 +
daemon/dbus/tests/test-secret-util.c | 42 +
daemon/gkd-main.c | 69 +-
daemon/gnome-keyring-gpg.desktop.in.in | 1 -
daemon/gnome-keyring-pkcs11.desktop.in.in | 1 -
daemon/gnome-keyring-secrets.desktop.in.in | 1 -
daemon/gnome-keyring-ssh.desktop.in.in | 1 -
daemon/gpg-agent/Makefile.am | 2 +-
daemon/gpg-agent/gkd-gpg-agent-ops.c | 142 +-
daemon/gpg-agent/gkd-gpg-agent-private.h | 10 +-
daemon/gpg-agent/gkd-gpg-agent-standalone.c | 12 +-
daemon/gpg-agent/gkd-gpg-agent.c | 65 +-
daemon/login/Makefile.am | 2 +-
daemon/login/gkd-login.c | 256 ++--
daemon/login/gkd-login.h | 2 +-
daemon/ssh-agent/Makefile.am | 2 +-
daemon/ssh-agent/gkd-ssh-agent-ops.c | 544 +++---
daemon/ssh-agent/gkd-ssh-agent-private.h | 46 +-
daemon/ssh-agent/gkd-ssh-agent-proto.c | 136 +-
daemon/ssh-agent/gkd-ssh-agent-standalone.c | 11 +-
daemon/ssh-agent/gkd-ssh-agent.c | 58 +-
egg/Makefile.am | 12 +-
egg/egg-asn1x.c | 70 +-
egg/egg-hex.c | 68 +-
egg/egg-hex.h | 12 +-
egg/tests/unit-test-hex.c | 32 +-
gck/.gitignore | 2 +
gck/Makefile.am | 71 +
gck/gck-attributes.c | 1333 ++++++++++++++
gck/gck-call.c | 543 ++++++
gck/gck-enumerator.c | 723 ++++++++
gck/gck-marshal.list | 3 +
gck/gck-misc.c | 437 +++++
gck/gck-module.c | 707 +++++++
gck/gck-modules.c | 235 +++
gck/gck-object.c | 1346 ++++++++++++++
gck/gck-private.h | 163 ++
gck/gck-session.c | 2638 +++++++++++++++++++++++++++
gck/gck-slot.c | 1075 +++++++++++
gck/gck-uri.c | 350 ++++
gck/gck.h | 1290 +++++++++++++
gck/gck.pc.in | 14 +
gck/pkcs11.h | 30 +
gck/tests/Makefile.am | 45 +
gck/tests/gck-test-module.c | 1693 +++++++++++++++++
gck/tests/gck-test.h | 55 +
gck/tests/test-gck-attributes.c | 462 +++++
gck/tests/test-gck-crypto.c | 593 ++++++
gck/tests/test-gck-enumerator.c | 170 ++
gck/tests/test-gck-mechanism.c | 60 +
gck/tests/test-gck-module.c | 169 ++
gck/tests/test-gck-modules.c | 145 ++
gck/tests/test-gck-object.c | 372 ++++
gck/tests/test-gck-session.c | 266 +++
gck/tests/test-gck-slot.c | 203 ++
gck/tests/test-gck-uri.c | 229 +++
gcr/Makefile.am | 2 +-
gcr/gcr-certificate-widget.c | 24 +-
gcr/gcr-import-dialog.c | 36 +-
gcr/gcr-import-dialog.h | 6 +-
gcr/gcr-importer.c | 89 +-
gcr/gcr-importer.h | 10 +-
gcr/gcr-initializer.h | 4 +-
gcr/gcr-internal.h | 2 -
gcr/gcr-key-widget.c | 40 +-
gcr/gcr-key-widget.h | 2 +-
gcr/gcr-library.c | 19 +-
gcr/gcr-parser.c | 30 +-
gcr/gcr-parser.h | 2 +-
gcr/gcr-types.h | 8 +-
gcr/gcr-view.c | 20 +-
gcr/gcr-view.h | 4 +-
gcr/tests/unit-test-parser.c | 4 +-
pkcs11/Makefile.am | 2 +-
pkcs11/gkm/gkm-mock.c | 5 -
pkcs11/gkm/gkm-module.c | 4 +-
pkcs11/wrap-layer/gkm-wrap-prompt.c | 2 +-
pkcs11/wrap-layer/gkm-wrap-prompt.h | 2 +
po/de.po | 535 +++---
po/es.po | 126 +-
po/et.po | 26 +-
po/gl.po | 482 +----
po/he.po | 122 +-
po/nb.po | 159 +-
po/pa.po | 559 +++---
po/sl.po | 579 +-----
po/sv.po | 479 +++---
po/ta.po | 522 +++---
po/zh_CN.po | 1454 ++++++++-------
po/zh_HK.po | 475 +++---
po/zh_TW.po | 479 +++---
testing/testing.c | 10 +
tool/Makefile.am | 2 +-
tool/gkr-tool-import.c | 22 +-
ui/gku-prompt.h | 2 -
130 files changed, 19912 insertions(+), 4640 deletions(-)
---
diff --cc gck/gck-attributes.c
index 0000000,a691b76..a6fc34e
mode 000000,100644..100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@@ -1,0 -1,1292 +1,1333 @@@
+ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+ /* gck-attribute.c - the GObject PKCS#11 wrapper library
+
+ Copyright (C) 2008, Stefan Walter
+
+ The Gnome Keyring Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Keyring Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Stef Walter <nielsen memberwebs com>
+ */
+
+ #include "config.h"
+
+ #include "gck.h"
+ #include "gck-private.h"
+
+ #include <stdlib.h>
+ #include <string.h>
+
+ /**
+ * SECTION:gck-attribute
+ * @title: GckAttribute
+ * @short_description: A PKCS11 attribute.
+ *
+ * This structure represents a PKCS11 CK_ATTRIBUTE. These attributes contain information
+ * about a PKCS11 object. Use gck_object_get() or gck_object_set() to set and retrieve
+ * attributes on an object.
+ */
+
+ /**
+ * GckAttribute:
+ * @type: The attribute type, such as CKA_LABEL.
+ * @value: The value of the attribute. May be NULL.
+ * @length: The length of the attribute. May be G_MAXULONG if the attribute is invalid.
+ *
+ * This structure represents a PKCS11 CK_ATTRIBUTE.
+ */
+
+ static void
+ attribute_init (GckAttribute *attr, gulong attr_type,
+ gconstpointer value, gsize length,
+ GckAllocator allocator)
+ {
+ g_assert (sizeof (GckAttribute) == sizeof (CK_ATTRIBUTE));
+ g_assert (allocator);
+
+ memset (attr, 0, sizeof (GckAttribute));
+ attr->type = attr_type;
+ attr->length = length;
+ if (value) {
+ attr->value = (allocator) (NULL, length ? length : 1);
+ g_assert (attr->value);
+ memcpy (attr->value, value, length);
+ }
+ }
+
+ /**
+ * gck_attribute_init:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The raw value of the attribute.
+ * @length: The length of the raw value.
+ *
+ * Initialize a PKCS#11 attribute. This copies the value memory
+ * into an internal buffer.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init (GckAttribute *attr, gulong attr_type,
+ gconstpointer value, gsize length)
+ {
+ g_return_if_fail (attr);
+ attribute_init (attr, attr_type, value, length, g_realloc);
+ }
+
+ /**
+ * gck_attribute_init_invalid:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ *
+ * Initialize a PKCS#11 attribute to an 'invalid' or 'not found'
+ * state. Specifically this sets the value length to (CK_ULONG)-1
+ * as specified in the PKCS#11 specification.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_invalid (GckAttribute *attr, gulong attr_type)
+ {
+ g_return_if_fail (attr);
+ g_assert (sizeof (GckAttribute) == sizeof (CK_ATTRIBUTE));
+ memset (attr, 0, sizeof (GckAttribute));
+ attr->type = attr_type;
+ attr->length = (gulong)-1;
+ }
+
+ /**
+ * gck_attribute_init_empty:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ *
+ * Initialize a PKCS#11 attribute to an empty state. The attribute
+ * type will be set, but no data will be set.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_empty (GckAttribute *attr, gulong attr_type)
+ {
+ g_return_if_fail (attr);
+ g_assert (sizeof (GckAttribute) == sizeof (CK_ATTRIBUTE));
+ memset (attr, 0, sizeof (GckAttribute));
+ attr->type = attr_type;
+ attr->length = 0;
+ attr->value = 0;
+ }
+
+ static void
+ attribute_init_boolean (GckAttribute *attr, gulong attr_type,
+ gboolean value, GckAllocator allocator)
+ {
+ CK_BBOOL bvalue = value ? CK_TRUE : CK_FALSE;
+ attribute_init (attr, attr_type, &bvalue, sizeof (bvalue), allocator);
+ }
+
+ /**
+ * gck_attribute_init_boolean:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The boolean value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to boolean. This will result
+ * in a CK_BBOOL attribute from the PKCS#11 specs.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_boolean (GckAttribute *attr, gulong attr_type,
+ gboolean value)
+ {
+ g_return_if_fail (attr);
+ attribute_init_boolean (attr, attr_type, value, g_realloc);
+ }
+
+ static void
+ attribute_init_date (GckAttribute *attr, gulong attr_type,
+ const GDate *value, GckAllocator allocator)
+ {
+ gchar buffer[9];
+ CK_DATE date;
+ g_assert (value);
+ g_snprintf (buffer, sizeof (buffer), "%04d%02d%02d",
+ (int)g_date_get_year (value),
+ (int)g_date_get_month (value),
+ (int)g_date_get_day (value));
+ memcpy (&date.year, buffer + 0, 4);
+ memcpy (&date.month, buffer + 4, 2);
+ memcpy (&date.day, buffer + 6, 2);
+ attribute_init (attr, attr_type, &date, sizeof (CK_DATE), allocator);
+ }
+
+ /**
+ * gck_attribute_init_date:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The date value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a date. This will result
+ * in a CK_DATE attribute from the PKCS#11 specs.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_date (GckAttribute *attr, gulong attr_type,
+ const GDate *value)
+ {
+ g_return_if_fail (attr);
+ g_return_if_fail (value);
+ attribute_init_date (attr, attr_type, value, g_realloc);
+ }
+
+ static void
+ attribute_init_ulong (GckAttribute *attr, gulong attr_type,
+ gulong value, GckAllocator allocator)
+ {
+ CK_ULONG uvalue = value;
+ attribute_init (attr, attr_type, &uvalue, sizeof (uvalue), allocator);
+ }
+
+ /**
+ * gck_attribute_init_ulong:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The ulong value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a unsigned long. This will result
+ * in a CK_ULONG attribute from the PKCS#11 specs.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_ulong (GckAttribute *attr, gulong attr_type,
+ gulong value)
+ {
+ g_return_if_fail (attr);
+ attribute_init_ulong (attr, attr_type, value, g_realloc);
+ }
+
+ static void
+ attribute_init_string (GckAttribute *attr, gulong attr_type,
+ const gchar *value, GckAllocator allocator)
+ {
+ gsize len = value ? strlen (value) : 0;
+ attribute_init (attr, attr_type, (gpointer)value, len, allocator);
+ }
+
+ /**
+ * gck_attribute_init_string:
+ * @attr: An uninitialized attribute.
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The null terminated string value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a string. This will result
+ * in an attribute containing the text, but not the null terminator.
+ * The text in the attribute will be of the same encoding as you pass
+ * to this function.
+ *
+ * When done with the attribute you should use gck_attribute_clear()
+ * to free the internal memory.
+ **/
+ void
+ gck_attribute_init_string (GckAttribute *attr, gulong attr_type,
+ const gchar *value)
+ {
+ g_return_if_fail (attr);
+ attribute_init_string (attr, attr_type, value, g_realloc);
+ }
+
+ /**
+ * gck_attribute_new:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The raw value of the attribute.
+ * @length: The length of the attribute.
+ *
+ * Create a new PKCS#11 attribute. The value will be copied
+ * into the new attribute.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new (gulong attr_type, gpointer value, gsize length)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ attribute_init (attr, attr_type, value, length, g_realloc);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_invalid:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ *
+ * Create a new PKCS#11 attribute as 'invalid' or 'not found'
+ * state. Specifically this sets the value length to (CK_ULONG)-1
+ * as specified in the PKCS#11 specification.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new_invalid (gulong attr_type)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ gck_attribute_init_invalid (attr, attr_type);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_empty:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ *
+ * Create a new PKCS#11 attribute with empty data.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ */
+ GckAttribute*
+ gck_attribute_new_empty (gulong attr_type)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ gck_attribute_init_empty (attr, attr_type);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_boolean:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The boolean value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to boolean. This will result
+ * in a CK_BBOOL attribute from the PKCS#11 specs.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new_boolean (gulong attr_type, gboolean value)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ attribute_init_boolean (attr, attr_type, value, g_realloc);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_date:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The date value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a date. This will result
+ * in a CK_DATE attribute from the PKCS#11 specs.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new_date (gulong attr_type, const GDate *value)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ attribute_init_date (attr, attr_type, value, g_realloc);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_ulong:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The ulong value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a unsigned long. This will result
+ * in a CK_ULONG attribute from the PKCS#11 specs.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new_ulong (gulong attr_type, gulong value)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ attribute_init_ulong (attr, attr_type, value, g_realloc);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_new_string:
+ * @attr_type: The PKCS#11 attribute type to set on the attribute.
+ * @value: The null terminated string value of the attribute.
+ *
+ * Initialize a PKCS#11 attribute to a string. This will result
+ * in an attribute containing the text, but not the null terminator.
+ * The text in the attribute will be of the same encoding as you pass
+ * to this function.
+ *
+ * Return value: The new attribute. When done with the attribute use
+ * gck_attribute_free() to free it.
+ **/
+ GckAttribute*
+ gck_attribute_new_string (gulong attr_type, const gchar *value)
+ {
+ GckAttribute *attr = g_slice_new0 (GckAttribute);
+ attribute_init_string (attr, attr_type, value, g_realloc);
+ return attr;
+ }
+
+ /**
+ * gck_attribute_is_invalid:
+ * @attr: The attribute to check.
+ *
+ * Check if the PKCS#11 attribute represents 'invalid' or 'not found'
+ * according to the PKCS#11 spec. That is, having length
+ * of (CK_ULONG)-1.
+ *
+ * Return value: Whether the attribute represents invalid or not.
+ */
+ gboolean
+ gck_attribute_is_invalid (GckAttribute *attr)
+ {
+ g_return_val_if_fail (attr, TRUE);
+ return attr->length == (gulong)-1;
+ }
+
+ /**
+ * gck_attribute_get_boolean:
+ * @attr: The attribute to retrieve value from.
+ *
+ * Get the CK_BBOOL of a PKCS#11 attribute. No conversion
+ * is performed. It is an error to pass an attribute to this
+ * function unless you're know it's supposed to contain a
+ * boolean value.
+ *
+ * Return value: The boolean value of the attribute.
+ */
+ gboolean
+ gck_attribute_get_boolean (GckAttribute *attr)
+ {
+ g_return_val_if_fail (attr, FALSE);
+ if (gck_attribute_is_invalid (attr))
+ return FALSE;
+ g_return_val_if_fail (attr->length == sizeof (CK_BBOOL), FALSE);
+ g_return_val_if_fail (attr->value, FALSE);
+ return *((CK_BBOOL*)attr->value) == CK_TRUE ? TRUE : FALSE;
+ }
+
+ /**
+ * gck_attribute_get_ulong:
+ * @attr: The attribute to retrieve value from.
+ *
+ * Get the CK_ULONG value of a PKCS#11 attribute. No
+ * conversion is performed. It is an error to pass an attribute
+ * to this function unless you're know it's supposed to contain
+ * a value of the right type.
+ *
+ * Return value: The ulong value of the attribute.
+ */
+ gulong
+ gck_attribute_get_ulong (GckAttribute *attr)
+ {
+ g_return_val_if_fail (attr, FALSE);
+ if (gck_attribute_is_invalid (attr))
+ return 0;
+ g_return_val_if_fail (attr->length == sizeof (CK_ULONG), (gulong)-1);
+ g_return_val_if_fail (attr->value, (gulong)-1);
+ return *((CK_ULONG*)attr->value);
+ }
+
+ /**
+ * gck_attribute_get_string:
+ * @attr: The attribute to retrieve value from.
+ *
+ * Get the string value of a PKCS#11 attribute. No
+ * conversion is performed. It is an error to pass an attribute
+ * to this function unless you're know it's supposed to contain
+ * a value of the right type.
+ *
+ * Return value: A null terminated string, to be freed with g_free(),
+ * or NULL if the value contained a NULL string.
+ */
+ gchar*
+ gck_attribute_get_string (GckAttribute *attr)
+ {
+ g_return_val_if_fail (attr, NULL);
+
+ if (gck_attribute_is_invalid (attr))
+ return NULL;
+ if (!attr->value)
+ return NULL;
+
+ return g_strndup ((gchar*)attr->value, attr->length);
+ }
+
+ /**
+ * gck_attribute_get_date:
+ * @attr: The attribute to retrieve value from.
+ * @value: The date value to fill in with the parsed date.
+ *
+ * Get the CK_DATE of a PKCS#11 attribute. No
+ * conversion is performed. It is an error to pass an attribute
+ * to this function unless you're know it's supposed to contain
+ * a value of the right type.
+ */
+ void
+ gck_attribute_get_date (GckAttribute *attr, GDate *value)
+ {
+ guint year, month, day;
+ gchar buffer[5];
+ CK_DATE *date;
+ gchar *end;
+
+ g_return_if_fail (attr);
+
+ if (gck_attribute_is_invalid (attr)) {
+ g_date_clear (value, 1);
+ return;
+ }
+
+ g_return_if_fail (attr->length == sizeof (CK_DATE));
+ g_return_if_fail (attr->value);
+ date = (CK_DATE*)attr->value;
+
+ memset (&buffer, 0, sizeof (buffer));
+ memcpy (buffer, date->year, 4);
+ year = strtol (buffer, &end, 10);
+ g_return_if_fail (end != buffer && !*end);
+
+ memset (&buffer, 0, sizeof (buffer));
+ memcpy (buffer, date->month, 2);
+ month = strtol (buffer, &end, 10);
+ g_return_if_fail (end != buffer && !*end);
+
+ memset (&buffer, 0, sizeof (buffer));
+ memcpy (buffer, date->day, 2);
+ day = strtol (buffer, &end, 10);
+ g_return_if_fail (end != buffer && !*end);
+
+ g_date_set_dmy (value, day, month, year);
+ }
+
+ /**
+ * gck_attribute_dup:
+ * @attr: The attribute to duplicate.
+ *
+ * Duplicate the PKCS#11 attribute. All value memory is
+ * also copied.
+ *
+ * Return value: The duplicated attribute. Use gck_attribute_free()
+ * to free it.
+ */
+ GckAttribute*
+ gck_attribute_dup (GckAttribute *attr)
+ {
+ GckAttribute *copy;
+
+ if (!attr)
+ return NULL;
+
+ copy = g_slice_new0 (GckAttribute);
+ gck_attribute_init_copy (copy, attr);
+ return copy;
+ }
+
+ static void
+ attribute_init_copy (GckAttribute *dest, const GckAttribute *src, GckAllocator allocator)
+ {
+ g_assert (dest);
+ g_assert (src);
+ g_assert (allocator);
+
+ /*
+ * TODO: Handle stupid, dumb, broken, special cases like
+ * CKA_WRAP_TEMPLATE and CKA_UNWRAP_TEMPLATE.
+ */
+
+ memcpy (dest, src, sizeof (GckAttribute));
+ if (src->value && src->length) {
+ dest->value = (allocator) (NULL, src->length);
+ g_assert (dest->value);
+ memcpy (dest->value, src->value, src->length);
+ }
+ }
+
+ /**
+ * gck_attribute_init_copy:
+ * @dest: An uninitialized attribute.
+ * @src: An attribute to copy.
+ *
+ * Initialize a PKCS#11 attribute as a copy of another attribute.
+ * This copies the value memory as well.
+ *
+ * When done with the copied attribute you should use
+ * gck_attribute_clear() to free the internal memory.
+ **/
+ void
+ gck_attribute_init_copy (GckAttribute *dest, const GckAttribute *src)
+ {
+ g_return_if_fail (dest);
+ g_return_if_fail (src);
+ attribute_init_copy (dest, src, g_realloc);
+ }
+
+ static void
+ attribute_clear (GckAttribute *attr, GckAllocator allocator)
+ {
+ g_assert (attr);
+ g_assert (allocator);
+ if (attr->value)
+ (allocator) (attr->value, 0);
+ attr->value = NULL;
+ attr->length = 0;
+ }
+
+ /**
+ * gck_attribute_clear:
+ * @attr: Attribute to clear.
+ *
+ * Clear allocated memory held by a statically allocated attribute.
+ * These are usually initialized with gck_attribute_init() or a
+ * similar function.
+ *
+ * The type of the attribute will remain set.
+ **/
+ void
+ gck_attribute_clear (GckAttribute *attr)
+ {
+ g_return_if_fail (attr);
+ attribute_clear (attr, g_realloc);
+ }
+
+ /**
+ * gck_attribute_free:
+ * @attr: Attribute to free.
+ *
+ * Free an attribute and its allocated memory. These is usually
+ * used with attributes that are allocated by gck_attribute_new()
+ * or a similar function.
+ **/
+ void
+ gck_attribute_free (GckAttribute *attr)
+ {
+ if (attr) {
+ attribute_clear (attr, g_realloc);
+ g_slice_free (GckAttribute, attr);
+ }
+ }
+
++gboolean
++gck_attribute_equal (gconstpointer a, gconstpointer b)
++{
++ const GckAttribute *aa = a;
++ const GckAttribute *ab = b;
++
++ if (!a && !b)
++ return TRUE;
++ if (!a || !b)
++ return FALSE;
++
++ if (aa->type != ab->type)
++ return FALSE;
++ if (aa->length != ab->length)
++ return FALSE;
++ if (!aa->value && !ab->value)
++ return TRUE;
++ if (!aa->value || !ab->value)
++ return FALSE;
++ return memcmp (aa->value, ab->value, aa->length) == 0;
++}
++
+ /**
+ * SECTION:gck-attributes
+ * @title: GckAttributes
+ * @short_description: A set of PKCS11 attributes.
+ *
+ * A set of GckAttribute structures. These attributes contain information
+ * about a PKCS11 object. Use gck_object_get() or gck_object_set() to set and retrieve
+ * attributes on an object.
+ */
+
+ /**
+ * GckAttributes:
+ *
+ * A set of GckAttribute structures.
+ */
+ struct _GckAttributes {
+ GArray *array;
+ GckAllocator allocator;
+ gboolean locked;
+ gint refs;
+ };
+
+ /**
+ * gck_BOOLEAN:
+ *
+ * The attribute data is a gboolean. Used with variable argument functions.
+ **/
+
+ /**
+ * gck_ULONG:
+ *
+ * The attribute data is a gulong. Used with variable argument functions.
+ **/
+
+ /**
+ * gck_STRING:
+ *
+ * The attribute data is a gchar. Used with variable argument functions.
+ **/
+
+ /**
+ * gck_DATE:
+ *
+ * The attribute data is a GDate. Used with variable argument functions.
+ **/
+
+ /**
+ * gck_DATE:
+ *
+ * Signifies that no more attributes follow. Used with variable argument functions.
+ **/
+
+ /**
+ * gck_ATTRIBUTES_TYPE:
+ *
+ * A boxed type that can be used to hold a GckAttributes object.
+ **/
+
+ /**
+ * GckAllocator:
+ * @data: Memory to allocate or deallocate.
+ * @length: New length of memory.
+ *
+ * An allocator used to allocate data for the attributes in this GckAttributes set.
+ *
+ * This is a function that acts like g_realloc. Specifically it frees when length is
+ * set to zero, it allocates when data is set to NULL, and it reallocates when both
+ * are valid.
+ *
+ * Returns: The allocated memory, or NULL when freeing.
+ **/
+
+ /**
+ * gck_attributes_get_boxed_type:
+ *
+ * Get the boxed type representing a GckAttributes array.
+ *
+ * Return value: The boxed type.
+ **/
+ GType
+ gck_attributes_get_boxed_type (void)
+ {
+ static GType type = 0;
+ if (!type)
+ type = g_boxed_type_register_static ("GckAttributes",
+ (GBoxedCopyFunc)gck_attributes_ref,
+ (GBoxedFreeFunc)gck_attributes_unref);
+ return type;
+ }
+
+ /**
+ * gck_attributes_new:
+ *
+ * Create a new GckAttributes array.
+ *
+ * Return value: The new attributes array. When done with the array
+ * release it with gck_attributes_unref().
+ **/
+ GckAttributes*
+ gck_attributes_new (void)
+ {
+ return gck_attributes_new_full (g_realloc);
+ }
+
+ /**
+ * gck_attributes_new_full:
+ * @allocator: Memory allocator for attribute data, or NULL for default.
+ *
+ * Create a new GckAttributes array.
+ *
+ * Return value: The new attributes array. When done with the array
+ * release it with gck_attributes_unref().
+ **/
+ GckAttributes*
+ gck_attributes_new_full (GckAllocator allocator)
+ {
+ GckAttributes *attrs;
+
+ if (!allocator)
+ allocator = g_realloc;
+
+ g_assert (sizeof (GckAttribute) == sizeof (CK_ATTRIBUTE));
+ attrs = g_slice_new0 (GckAttributes);
+ attrs->array = g_array_new (0, 1, sizeof (GckAttribute));
+ attrs->allocator = allocator;
+ attrs->refs = 1;
+ attrs->locked = FALSE;
+ return attrs;
+ }
+
+ /**
+ * gck_attributes_new_empty:
+ * @attr_type: The first attribute type to add as empty.
+ * @...: The arguments should be values of attribute types, terminated with gck_INVALID.
+ *
+ * Creates an GckAttributes array with empty attributes. The arguments
+ * should be values of attribute types, terminated with gck_INVALID.
+ *
+ * Return value: The new attributes array. When done with the array
+ * release it with gck_attributes_unref().
+ **/
+ GckAttributes*
+ gck_attributes_new_empty (gulong attr_type, ...)
+ {
+ GckAttributes *attrs = gck_attributes_new_full (g_realloc);
+ va_list va;
+
+ va_start (va, attr_type);
+
+ while (attr_type != GCK_INVALID) {
+ gck_attributes_add_empty (attrs, attr_type);
+ attr_type = va_arg (va, gulong);
+ }
+
+ va_end (va);
+
+ return attrs;
+ }
+
+ /**
+ * gck_attributes_at:
+ * @attrs: The attributes array.
+ * @index: The attribute index to retrieve.
+ *
+ * Get attribute at the specified index in the attribute array.
+ *
+ * Use gck_attributes_count() to determine how many attributes are
+ * in the array.
+ *
+ * Return value: The specified attribute.
+ **/
+ GckAttribute*
+ gck_attributes_at (GckAttributes *attrs, guint index)
+ {
+ g_return_val_if_fail (attrs && attrs->array, NULL);
+ g_return_val_if_fail (index < attrs->array->len, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ return &g_array_index (attrs->array, GckAttribute, index);
+ }
+
+ static GckAttribute*
+ attributes_push (GckAttributes *attrs)
+ {
+ GckAttribute attr;
+ g_assert (!attrs->locked);
+ memset (&attr, 0, sizeof (attr));
+ g_array_append_val (attrs->array, attr);
+ return &g_array_index (attrs->array, GckAttribute, attrs->array->len - 1);
+ }
+
+ /**
+ * gck_attributes_add:
+ * @attrs: The attributes array to add to
+ * @attr: The attribute to add.
+ *
+ * Add the specified attribute to the array.
+ *
+ * The value stored in the attribute will be copied.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add (GckAttributes *attrs, GckAttribute *attr)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs && attrs->array, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ g_return_val_if_fail (attr, NULL);
+ added = attributes_push (attrs);
+ attribute_init_copy (added, attr, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_data:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ * @value: The raw memory of the attribute value.
+ * @length: The length of the attribute value.
+ *
+ * Add an attribute with the specified type and value to the array.
+ *
+ * The value stored in the attribute will be copied.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_data (GckAttributes *attrs, gulong attr_type,
+ gconstpointer value, gsize length)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ attribute_init (added, attr_type, value, length, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_invalid:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ *
+ * Add an attribute with the specified type and an 'invalid' value to the array.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_invalid (GckAttributes *attrs, gulong attr_type)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ gck_attribute_init_invalid (added, attr_type);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_empty:
+ * @attrs: The attributes array to add.
+ * @attr_type: The type of attribute to add.
+ *
+ * Add an attribute with the specified type, with empty data.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_empty (GckAttributes *attrs, gulong attr_type)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ gck_attribute_init_empty (added, attr_type);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_boolean:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ * @value: The boolean value to add.
+ *
+ * Add an attribute with the specified type and value to the array.
+ *
+ * The value will be stored as a CK_BBOOL PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_boolean (GckAttributes *attrs, gulong attr_type, gboolean value)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ attribute_init_boolean (added, attr_type, value, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_string:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ * @value: The null terminated string value to add.
+ *
+ * Add an attribute with the specified type and value to the array.
+ *
+ * The value will be copied into the attribute.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_string (GckAttributes *attrs, gulong attr_type, const gchar *value)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ attribute_init_string (added, attr_type, value, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_date:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ * @value: The GDate value to add.
+ *
+ * Add an attribute with the specified type and value to the array.
+ *
+ * The value will be stored as a CK_DATE PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_date (GckAttributes *attrs, gulong attr_type, const GDate *value)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ attribute_init_date (added, attr_type, value, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_add_ulong:
+ * @attrs: The attributes array to add to.
+ * @attr_type: The type of attribute to add.
+ * @value: The gulong value to add.
+ *
+ * Add an attribute with the specified type and value to the array.
+ *
+ * The value will be stored as a CK_ULONG PKCS#11 style attribute.
+ *
+ * Return value: The attribute that was added.
+ **/
+ GckAttribute*
+ gck_attributes_add_ulong (GckAttributes *attrs, gulong attr_type, gulong value)
+ {
+ GckAttribute *added;
+ g_return_val_if_fail (attrs, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+ added = attributes_push (attrs);
+ attribute_init_ulong (added, attr_type, value, attrs->allocator);
+ return added;
+ }
+
+ /**
+ * gck_attributes_count:
+ * @attrs: The attributes array to count.
+ *
+ * Get the number of attributes in this attribute array.
+ *
+ * Return value: The number of contained attributes.
+ **/
+ gulong
+ gck_attributes_count (GckAttributes *attrs)
+ {
+ g_return_val_if_fail (attrs, 0);
+ g_return_val_if_fail (!attrs->locked, 0);
+ return attrs->array->len;
+ }
+
+ /**
+ * gck_attributes_find:
+ * @attrs: The attributes array to search.
+ * @attr_type: The type of attribute to find.
+ *
+ * Find an attribute with the specified type in the array.
+ *
+ * Return value: The first attribute found with the specified type, or NULL.
+ **/
+ GckAttribute*
+ gck_attributes_find (GckAttributes *attrs, gulong attr_type)
+ {
+ GckAttribute *attr;
+ guint i;
+
+ g_return_val_if_fail (attrs && attrs->array, NULL);
+ g_return_val_if_fail (!attrs->locked, NULL);
+
+ for (i = 0; i < attrs->array->len; ++i) {
+ attr = gck_attributes_at (attrs, i);
+ if (attr->type == attr_type)
+ return attr;
+ }
+
+ return NULL;
+ }
+
+ /**
+ * gck_attributes_find_boolean:
+ * @attrs: The attributes array to search.
+ * @attr_type: The type of attribute to find.
+ * @value: The resulting gboolean value.
+ *
+ * Find an attribute with the specified type in the array.
+ *
+ * The attribute (if found) must be of the right size to store
+ * a boolean value (ie: CK_BBOOL). If the attribute is marked invalid
+ * then it will be treated as not found.
+ *
+ * Return value: Whether a value was found or not.
+ **/
+ gboolean
+ gck_attributes_find_boolean (GckAttributes *attrs, gulong attr_type, gboolean *value)
+ {
+ GckAttribute *attr;
+
+ g_return_val_if_fail (value, FALSE);
+ g_return_val_if_fail (!attrs->locked, FALSE);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (!attr || gck_attribute_is_invalid (attr))
+ return FALSE;
+ *value = gck_attribute_get_boolean (attr);
+ return TRUE;
+ }
+
+ /**
+ * gck_attributes_find_ulong:
+ * @attrs: The attributes array to search.
+ * @attr_type: The type of attribute to find.
+ * @value: The resulting gulong value.
+ *
+ * Find an attribute with the specified type in the array.
+ *
+ * The attribute (if found) must be of the right size to store
+ * a unsigned long value (ie: CK_ULONG). If the attribute is marked invalid
+ * then it will be treated as not found.
+ *
+ * Return value: Whether a value was found or not.
+ **/
+ gboolean
+ gck_attributes_find_ulong (GckAttributes *attrs, gulong attr_type, gulong *value)
+ {
+ GckAttribute *attr;
+
+ g_return_val_if_fail (value, FALSE);
+ g_return_val_if_fail (!attrs->locked, FALSE);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (!attr || gck_attribute_is_invalid (attr))
+ return FALSE;
+ *value = gck_attribute_get_ulong (attr);
+ return TRUE;
+ }
+
+ /**
+ * gck_attributes_find_string:
+ * @attrs: The attributes array to search.
+ * @attr_type: The type of attribute to find.
+ * @value: The resulting string value.
+ *
+ * Find an attribute with the specified type in the array.
+ *
+ * If the attribute is marked invalid then it will be treated as not found.
+ * The resulting string will be null-terminated, and must be freed by the caller
+ * using g_free().
+ *
+ * Return value: Whether a value was found or not.
+ **/
+ gboolean
+ gck_attributes_find_string (GckAttributes *attrs, gulong attr_type, gchar **value)
+ {
+ GckAttribute *attr;
+
+ g_return_val_if_fail (value, FALSE);
+ g_return_val_if_fail (!attrs->locked, FALSE);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (!attr || gck_attribute_is_invalid (attr))
+ return FALSE;
+ *value = gck_attribute_get_string (attr);
+ return TRUE;
+ }
+
+ /**
+ * gck_attributes_find_date:
+ * @attrs: The attributes array to search.
+ * @attr_type: The type of attribute to find.
+ * @value: The resulting GDate value.
+ *
+ * Find an attribute with the specified type in the array.
+ *
+ * The attribute (if found) must be of the right size to store
+ * a date value (ie: CK_DATE). If the attribute is marked invalid
+ * then it will be treated as not found.
+ *
+ * Return value: Whether a value was found or not.
+ **/
+ gboolean
+ gck_attributes_find_date (GckAttributes *attrs, gulong attr_type, GDate *value)
+ {
+ GckAttribute *attr;
+
+ g_return_val_if_fail (value, FALSE);
+ g_return_val_if_fail (!attrs->locked, FALSE);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (!attr || gck_attribute_is_invalid (attr))
+ return FALSE;
+ gck_attribute_get_date (attr, value);
+ return TRUE;
+ }
+
+ /**
+ * gck_attributes_ref:
+ * @attrs: An attribute array
+ *
+ * Reference this attributes array.
+ *
+ * Returns: The attributes.
+ **/
+ GckAttributes*
+ gck_attributes_ref (GckAttributes *attrs)
+ {
+ g_return_val_if_fail (attrs, NULL);
+ g_atomic_int_inc (&attrs->refs);
+ return attrs;
+ }
+
+ /**
+ * gck_attributes_unref:
+ * @attrs: An attribute array
+ *
+ * Unreference this attribute array.
+ *
+ * When all outstanding references are NULL, the array will be freed.
+ */
+ void
+ gck_attributes_unref (GckAttributes *attrs)
+ {
+ guint i;
+
+ if (!attrs)
+ return;
+
+ if (g_atomic_int_dec_and_test (&attrs->refs)) {
+ g_return_if_fail (attrs->array);
+ g_return_if_fail (!attrs->locked);
+ for (i = 0; i < attrs->array->len; ++i)
+ attribute_clear (gck_attributes_at (attrs, i), attrs->allocator);
+ g_array_free (attrs->array, TRUE);
+ attrs->array = NULL;
+ g_slice_free (GckAttributes, attrs);
+ }
+ }
+
++gboolean
++gck_attributes_contains (GckAttributes *attrs, GckAttribute *match)
++{
++ GckAttribute *attr;
++ guint i;
++
++ g_return_val_if_fail (attrs && attrs->array, FALSE);
++
++ for (i = 0; i < attrs->array->len; ++i) {
++ attr = gck_attributes_at (attrs, i);
++ if (gck_attribute_equal (attr, match))
++ return TRUE;
++ }
++
++ return FALSE;
++}
++
++
++
+ /* -------------------------------------------------------------------------------------------
+ * INTERNAL
+ *
+ * The idea is that while we're processing a GckAttributes array (via PKCS#11
+ * C_GetAtributeValue for example) the calling application shouldn't access those
+ * attributes at all, except to ref or unref them.
+ *
+ * We try to help debug this with our 'locked' states. The various processing
+ * functions that accept GckAttributes lock the attributes while handing
+ * them off to be processed (perhaps in a different thread). We check this locked
+ * flag in all public functions accessing GckAttributes.
+ *
+ * The reason we don't use thread safe or atomic primitives here, is because:
+ * a) The attributes are 'locked' by the same thread that prepares the call.
+ * b) This is a debugging feature, and should not be relied on for correctness.
+ */
+
+ void
+ _gck_attributes_lock (GckAttributes *attrs)
+ {
+ g_assert (attrs);
+ g_assert (!attrs->locked);
+ attrs->locked = TRUE;
+ }
+
+ void
+ _gck_attributes_unlock (GckAttributes *attrs)
+ {
+ g_assert (attrs);
+ g_assert (attrs->locked);
+ attrs->locked = FALSE;
+ }
+
+ CK_ATTRIBUTE_PTR
+ _gck_attributes_prepare_in (GckAttributes *attrs, CK_ULONG_PTR n_attrs)
+ {
+ GckAttribute *attr;
+ guint i;
+
+ g_assert (attrs);
+ g_assert (n_attrs);
+ g_assert (attrs->locked);
+
+ /* Prepare the attributes to receive their length */
+
+ for (i = 0; i < attrs->array->len; ++i) {
+ attr = &g_array_index (attrs->array, GckAttribute, i);
+ attribute_clear (attr, attrs->allocator);
+ }
+
+ *n_attrs = attrs->array->len;
+ return (CK_ATTRIBUTE_PTR)attrs->array->data;
+ }
+
+ CK_ATTRIBUTE_PTR
+ _gck_attributes_commit_in (GckAttributes *attrs, CK_ULONG_PTR n_attrs)
+ {
+ GckAttribute *attr;
+ guint i;
+
+ g_assert (attrs);
+ g_assert (n_attrs);
+ g_assert (attrs->locked);
+
+ /* Allocate each attribute with the length that was set */
+
+ for (i = 0; i < attrs->array->len; ++i) {
+ attr = &g_array_index (attrs->array, GckAttribute, i);
+ g_assert (!attr->value);
+ if (attr->length != 0 && attr->length != (gulong)-1) {
+ attr->value = (attrs->allocator) (NULL, attr->length);
+ g_assert (attr->value);
+ }
+ }
+
+ *n_attrs = attrs->array->len;
+ return (CK_ATTRIBUTE_PTR)attrs->array->data;
+ }
+
+ CK_ATTRIBUTE_PTR
+ _gck_attributes_commit_out (GckAttributes *attrs, CK_ULONG_PTR n_attrs)
+ {
+ g_assert (attrs);
+ g_assert (n_attrs);
+ g_assert (attrs->locked);
+
+ *n_attrs = attrs->array->len;
+ return (CK_ATTRIBUTE_PTR)attrs->array->data;
+ }
diff --cc gck/gck.h
index 0000000,e8a52d9..aa9067a
mode 000000,100644..100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@@ -1,0 -1,1284 +1,1290 @@@
+ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+ /* gck.h - the GObject PKCS#11 wrapper library
+
+ Copyright (C) 2008, Stefan Walter
+
+ The Gnome Keyring Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Keyring Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Stef Walter <nielsen memberwebs com>
+ */
+
+ #ifndef GCK_H
+ #define GCK_H
+
+ #include <glib.h>
+ #include <glib-object.h>
+ #include <gio/gio.h>
+
+ #include "pkcs11.h"
+
+ G_BEGIN_DECLS
+
+ #define GCK_VENDOR_CODE 0x47503131 /* GP11 */
+
+ /* An error code which results from a failure to load the PKCS11 module */
+ #define CKR_GCK_MODULE_PROBLEM (CKR_VENDOR_DEFINED | (GCK_VENDOR_CODE + 1))
+
+ #define GCK_ERROR (gck_get_error_quark ())
+
+ GQuark gck_get_error_quark (void);
+
+ GList* gck_list_ref_copy (GList *reflist);
+
+ void gck_list_unref_free (GList *reflist);
+
+ const gchar* gck_message_from_rv (CK_RV rv);
+
+ gchar* gck_string_from_chars (const guchar *data, gsize max);
+
+ typedef gpointer (*GckAllocator) (gpointer data, gsize length);
+
+ typedef struct GckMechanism {
+ gulong type;
+ gpointer parameter;
+ gulong n_parameter;
+ } GckMechanism;
+
+ GckMechanism* gck_mechanism_new (gulong type);
+
+ GckMechanism* gck_mechanism_new_with_param (gulong type,
+ gconstpointer parameter,
+ gulong n_parameter);
+
+ GckMechanism* gck_mechanism_ref (GckMechanism* mech);
+
+ void gck_mechanism_unref (GckMechanism* mech);
+
+ typedef struct GckAttribute {
+ gulong type;
+ gpointer value;
+ gulong length;
+ } GckAttribute;
+
+ #define GCK_INVALID G_MAXULONG
+
+ enum {
+ GCK_AUTHENTICATE_TOKENS = 2,
+ GCK_AUTHENTICATE_OBJECTS = 4
+ };
+
+ void gck_attribute_init (GckAttribute *attr,
+ gulong attr_type,
+ gconstpointer value,
+ gsize length);
+
+ void gck_attribute_init_invalid (GckAttribute *attr,
+ gulong attr_type);
+
+ void gck_attribute_init_empty (GckAttribute *attr,
+ gulong attr_type);
+
+ void gck_attribute_init_boolean (GckAttribute *attr,
+ gulong attr_type,
+ gboolean value);
+
+ void gck_attribute_init_date (GckAttribute *attr,
+ gulong attr_type,
+ const GDate *value);
+
+ void gck_attribute_init_ulong (GckAttribute *attr,
+ gulong attr_type,
+ gulong value);
+
+ void gck_attribute_init_string (GckAttribute *attr,
+ gulong attr_type,
+ const gchar *value);
+
+ void gck_attribute_init_copy (GckAttribute *dest,
+ const GckAttribute *src);
+
+ GckAttribute* gck_attribute_new (gulong attr_type,
+ gpointer value,
+ gsize length);
+
+ GckAttribute* gck_attribute_new_invalid (gulong attr_type);
+
+ GckAttribute* gck_attribute_new_empty (gulong attr_type);
+
+ GckAttribute* gck_attribute_new_boolean (gulong attr_type,
+ gboolean value);
+
+ GckAttribute* gck_attribute_new_date (gulong attr_type,
+ const GDate *value);
+
+ GckAttribute* gck_attribute_new_ulong (gulong attr_type,
+ gulong value);
+
+ GckAttribute* gck_attribute_new_string (gulong attr_type,
+ const gchar *value);
+
+ gboolean gck_attribute_is_invalid (GckAttribute *attr);
+
+ gboolean gck_attribute_get_boolean (GckAttribute *attr);
+
+ gulong gck_attribute_get_ulong (GckAttribute *attr);
+
+ gchar* gck_attribute_get_string (GckAttribute *attr);
+
+ void gck_attribute_get_date (GckAttribute *attr,
+ GDate* value);
+
++gboolean gck_attribute_equal (gconstpointer a,
++ gconstpointer b);
++
+ GckAttribute* gck_attribute_dup (GckAttribute *attr);
+
+ void gck_attribute_clear (GckAttribute *attr);
+
+ void gck_attribute_free (GckAttribute *attr);
+
+
+ typedef struct _GckAttributes GckAttributes;
+
+ #define GCK_TYPE_ATTRIBUTES (gck_attributes_get_boxed_type ())
+
+ GType gck_attributes_get_boxed_type (void) G_GNUC_CONST;
+
+ GckAttributes* gck_attributes_new (void);
+
+ GckAttributes* gck_attributes_new_empty (gulong attr_type,
+ ...);
+
+ GckAttributes* gck_attributes_new_full (GckAllocator allocator);
+
+ GckAttribute* gck_attributes_at (GckAttributes *attrs,
+ guint index);
+
+ GckAttribute* gck_attributes_add (GckAttributes *attrs,
+ GckAttribute *attr);
+
+ GckAttribute* gck_attributes_add_data (GckAttributes *attrs,
+ gulong attr_type,
+ gconstpointer value,
+ gsize length);
+
+ GckAttribute* gck_attributes_add_invalid (GckAttributes *attrs,
+ gulong attr_type);
+
+ GckAttribute* gck_attributes_add_empty (GckAttributes *attrs,
+ gulong attr_type);
+
+ GckAttribute* gck_attributes_add_boolean (GckAttributes *attrs,
+ gulong attr_type,
+ gboolean value);
+
+ GckAttribute* gck_attributes_add_string (GckAttributes *attrs,
+ gulong attr_type,
+ const gchar *value);
+
+ GckAttribute* gck_attributes_add_date (GckAttributes *attrs,
+ gulong attr_type,
+ const GDate *value);
+
+ GckAttribute* gck_attributes_add_ulong (GckAttributes *attrs,
+ gulong attr_type,
+ gulong value);
+
+ GckAttribute* gck_attributes_find (GckAttributes *attrs,
+ gulong attr_type);
+
+ gboolean gck_attributes_find_boolean (GckAttributes *attrs,
+ gulong attr_type,
+ gboolean *value);
+
+ gboolean gck_attributes_find_ulong (GckAttributes *attrs,
+ gulong attr_type,
+ gulong *value);
+
+ gboolean gck_attributes_find_string (GckAttributes *attrs,
+ gulong attr_type,
+ gchar **value);
+
+ gboolean gck_attributes_find_date (GckAttributes *attrs,
+ gulong attr_type,
+ GDate *value);
+
+ gulong gck_attributes_count (GckAttributes *attrs);
+
+ GckAttributes* gck_attributes_ref (GckAttributes *attrs);
+
+ void gck_attributes_unref (GckAttributes *attrs);
+
++gboolean gck_attributes_contains (GckAttributes *attrs,
++ GckAttribute *match);
++
+ /* -------------------------------------------------------------------------
+ * FORWARDS
+ */
+ typedef struct _GckSlot GckSlot;
+ typedef struct _GckModule GckModule;
+ typedef struct _GckSession GckSession;
+ typedef struct _GckObject GckObject;
+ typedef struct _GckEnumerator GckEnumerator;
+
+ /* -------------------------------------------------------------------------
+ * MODULE
+ */
+
+ typedef struct _GckModuleInfo {
+ guint8 pkcs11_version_major;
+ guint8 pkcs11_version_minor;
+
+ gchar *manufacturer_id;
+ gulong flags;
+
+ gchar *library_description;
+ guint8 library_version_major;
+ guint8 library_version_minor;
+ } GckModuleInfo;
+
+ void gck_module_info_free (GckModuleInfo *module_info);
+
+ #define GCK_TYPE_MODULE (gck_module_get_type())
+ #define GCK_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_MODULE, GckModule))
+ #define GCK_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_MODULE, GckModule))
+ #define GCK_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_MODULE))
+ #define GCK_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_MODULE))
+ #define GCK_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_MODULE, GckModuleClass))
+
+ typedef struct _GckModuleClass GckModuleClass;
+ typedef struct _GckModulePrivate GckModulePrivate;
+
+ struct _GckModule {
+ GObject parent;
+ GckModulePrivate *pv;
+ gpointer reserved[4];
+ };
+
+ struct _GckModuleClass {
+ GObjectClass parent;
+
+ gboolean (*authenticate_slot) (GckModule *self, GckSlot *slot, gchar *label, gchar **password);
+
+ gboolean (*authenticate_object) (GckModule *self, GckObject *object, gchar *label, gchar **password);
+
+ gpointer reserved[8];
+ };
+
+ GType gck_module_get_type (void) G_GNUC_CONST;
+
+ GckModule* gck_module_new (CK_FUNCTION_LIST_PTR funcs,
+ guint options);
+
+ GckModule* gck_module_initialize (const gchar *path,
+ gpointer reserved,
+ guint options,
+ GError **err);
+
+ gboolean gck_module_equal (gconstpointer module1,
+ gconstpointer module2);
+
+ guint gck_module_hash (gconstpointer module);
+
+ const gchar* gck_module_get_path (GckModule *self);
+
+ CK_FUNCTION_LIST_PTR gck_module_get_functions (GckModule *self);
+
+ GckModuleInfo* gck_module_get_info (GckModule *self);
+
+ GList* gck_module_get_slots (GckModule *self,
+ gboolean token_present);
+
+ guint gck_module_get_options (GckModule *self);
+
+ gchar** gck_modules_list_registered_paths (GError **err);
+
+ GList* gck_modules_initialize_registered (guint options);
+
+ GList* gck_modules_get_slots (GList *modules,
+ gboolean token_present);
+
+ GckEnumerator* gck_modules_enumerate_objects (GList *modules,
+ GckAttributes *attrs,
+ guint session_flags);
+
+ GckSlot* gck_modules_token_for_uri (GList *modules,
+ const gchar *uri,
+ GError **error);
+
+ GckObject* gck_modules_object_for_uri (GList *modules,
+ const gchar *uri,
+ guint session_flags,
+ GError **error);
+
+ GList* gck_modules_objects_for_uri (GList *modules,
+ const gchar *uri,
+ guint session_flags,
+ GError **error);
+
+ GckEnumerator* gck_modules_enumerate_uri (GList *modules,
+ const gchar *uri,
+ guint session_flags,
+ GError **error);
+
+
+ /* ------------------------------------------------------------------------
+ * ENUMERATOR
+ */
+
+ #define GCK_TYPE_ENUMERATOR (gck_enumerator_get_type())
+ #define GCK_ENUMERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_ENUMERATOR, GckEnumerator))
+ #define GCK_ENUMERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_ENUMERATOR, GckEnumerator))
+ #define GCK_IS_ENUMERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_ENUMERATOR))
+ #define GCK_IS_ENUMERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_ENUMERATOR))
+ #define GCK_ENUMERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_ENUMERATOR, GckEnumeratorClass))
+
+ typedef struct _GckEnumeratorClass GckEnumeratorClass;
+ typedef struct _GckEnumeratorPrivate GckEnumeratorPrivate;
+
+ struct _GckEnumerator {
+ GObject parent;
+ GckEnumeratorPrivate *pv;
+ gpointer reserved[2];
+ };
+
+ struct _GckEnumeratorClass {
+ GObjectClass parent;
+ gpointer reserved[2];
+ };
+
+ GType gck_enumerator_get_type (void) G_GNUC_CONST;
+
+ GckObject* gck_enumerator_next (GckEnumerator *self,
+ GCancellable *cancellable,
+ GError **err);
+
+ GList* gck_enumerator_next_n (GckEnumerator *self,
+ gint max_objects,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_enumerator_next_async (GckEnumerator *self,
+ gint max_objects,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GList* gck_enumerator_next_finish (GckEnumerator *self,
+ GAsyncResult *res,
+ GError **err);
+
+ /* ------------------------------------------------------------------------
+ * SLOT
+ */
+
+ typedef struct _GckSlotInfo {
+ gchar *slot_description;
+ gchar *manufacturer_id;
+ gulong flags;
+ guint8 hardware_version_major;
+ guint8 hardware_version_minor;
+ guint8 firmware_version_major;
+ guint8 firmware_version_minor;
+ } GckSlotInfo;
+
+ void gck_slot_info_free (GckSlotInfo *slot_info);
+
+ typedef struct _GckTokenInfo {
+ gchar *label;
+ gchar *manufacturer_id;
+ gchar *model;
+ gchar *serial_number;
+ gulong flags;
+ glong max_session_count;
+ glong session_count;
+ glong max_rw_session_count;
+ glong rw_session_count;
+ glong max_pin_len;
+ glong min_pin_len;
+ glong total_public_memory;
+ glong free_public_memory;
+ glong total_private_memory;
+ glong free_private_memory;
+ guint8 hardware_version_major;
+ guint8 hardware_version_minor;
+ guint8 firmware_version_major;
+ guint8 firmware_version_minor;
+ gint64 utc_time;
+ } GckTokenInfo;
+
+ void gck_token_info_free (GckTokenInfo *token_info);
+
+ typedef struct _GckMechanismInfo {
+ gulong min_key_size;
+ gulong max_key_size;
+ gulong flags;
+ } GckMechanismInfo;
+
+ void gck_mechanism_info_free (GckMechanismInfo *mech_info);
+
+ typedef GArray GckMechanisms;
+
+ #define gck_mechanisms_length(a) ((a)->len)
+
+ #define gck_mechanisms_at(a, i) (g_array_index(a, CK_MECHANISM_TYPE, i))
+
+ #define gck_mechanisms_free(a) (g_array_free(a, TRUE))
+
+ gboolean gck_mechanisms_check (GckMechanisms *mechanisms,
+ ...);
+
+ #define GCK_TYPE_SLOT (gck_slot_get_type())
+ #define GCK_SLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_SLOT, GckSlot))
+ #define GCK_SLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_SLOT, GckSlot))
+ #define GCK_IS_SLOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_SLOT))
+ #define GCK_IS_SLOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_SLOT))
+ #define GCK_SLOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_SLOT, GckSlotClass))
+
+ typedef struct _GckSlotClass GckSlotClass;
+ typedef struct _GckSlotPrivate GckSlotPrivate;
+
+ struct _GckSlot {
+ GObject parent;
+ GckSlotPrivate *pv;
+ gpointer reserved[4];
+ };
+
+ struct _GckSlotClass {
+ GObjectClass parent;
+ gpointer reserved[9];
+ };
+
+ GType gck_slot_get_type (void) G_GNUC_CONST;
+
+ gboolean gck_slot_equal (gconstpointer slot1,
+ gconstpointer slot2);
+
+ guint gck_slot_hash (gconstpointer slot);
+
+ GckSlot* gck_slot_from_handle (GckModule *module,
+ CK_SLOT_ID slot_id);
+
+ GckModule* gck_slot_get_module (GckSlot *self);
+
+ CK_SLOT_ID gck_slot_get_handle (GckSlot *self);
+
+ GckSlotInfo* gck_slot_get_info (GckSlot *self);
+
+ GckTokenInfo* gck_slot_get_token_info (GckSlot *self);
+
+ GckMechanisms* gck_slot_get_mechanisms (GckSlot *self);
+
+ GckMechanismInfo* gck_slot_get_mechanism_info (GckSlot *self,
+ gulong mech_type);
+
+ gboolean gck_slot_has_flags (GckSlot *self,
+ gulong flags);
+
+ #if UNIMPLEMENTED
+
+ gboolean gck_slot_init_token (GckSlot *self,
+ const guchar *pin,
+ gsize length,
+ const gchar *label,
+ GError **err);
+
+
+ void gck_slot_init_token_async (GckSlot *self,
+ const guchar *pin,
+ gsize length,
+ const gchar *label,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_slot_init_token_finish (GckSlot *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ GckSession* gck_slot_open_session (GckSlot *self,
+ gulong flags,
+ GError **err);
+
+ GckSession* gck_slot_open_session_full (GckSlot *self,
+ gulong flags,
+ gpointer app_data,
+ CK_NOTIFY notify,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_slot_open_session_async (GckSlot *self,
+ gulong flags,
+ gpointer app_data,
+ CK_NOTIFY notify,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckSession* gck_slot_open_session_finish (GckSlot *self,
+ GAsyncResult *result,
+ GError **err);
+
+ /* ------------------------------------------------------------------------
+ * SESSION
+ */
+
+ typedef struct _GckSessionInfo {
+ gulong slot_id;
+ gulong state;
+ gulong flags;
+ gulong device_error;
+ } GckSessionInfo;
+
+ void gck_session_info_free (GckSessionInfo *session_info);
+
+ #define GCK_TYPE_SESSION (gck_session_get_type())
+ #define GCK_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_SESSION, GckSession))
+ #define GCK_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_SESSION, GckSession))
+ #define GCK_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_SESSION))
+ #define GCK_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_SESSION))
+ #define GCK_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_SESSION, GckSessionClass))
+
+ typedef struct _GckSessionClass GckSessionClass;
+ typedef struct _GckSessionPrivate GckSessionPrivate;
+
+ struct _GckSession {
+ GObject parent;
+ GckSessionPrivate *pv;
+ gpointer reserved[4];
+ };
+
+ struct _GckSessionClass {
+ GObjectClass parent;
+
+ gboolean (*discard_handle) (GckSession *session, CK_SESSION_HANDLE handle);
+
+ gpointer reserved[8];
+ };
+
+ GType gck_session_get_type (void) G_GNUC_CONST;
+
+ GckSession* gck_session_from_handle (GckSlot *slot,
+ CK_SESSION_HANDLE handle);
+
+ GckModule* gck_session_get_module (GckSession *self);
+
+ GckSlot* gck_session_get_slot (GckSession *self);
+
+ CK_SESSION_HANDLE gck_session_get_handle (GckSession *self);
+
+ GckSessionInfo* gck_session_get_info (GckSession *self);
+
+ gulong gck_session_get_state (GckSession *self);
+
+ gboolean gck_session_init_pin (GckSession *self,
+ const guchar *pin,
+ gsize n_pin,
+ GError **err);
+
+ gboolean gck_session_init_pin_full (GckSession *self,
+ const guchar *pin,
+ gsize n_pin,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_init_pin_async (GckSession *self,
+ const guchar *pin,
+ gsize n_pin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_init_pin_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ gboolean gck_session_set_pin (GckSession *self,
+ const guchar *old_pin,
+ gsize n_old_pin,
+ const guchar *new_pin,
+ gsize n_new_pin,
+ GError **err);
+
+ gboolean gck_session_set_pin_full (GckSession *self,
+ const guchar *old_pin,
+ gsize n_old_pin,
+ const guchar *new_pin,
+ gsize n_new_pin,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_set_pin_async (GckSession *self,
+ const guchar *old_pin,
+ gsize n_old_pin,
+ const guchar *new_pin,
+ gsize n_new_pin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_set_pin_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ gboolean gck_session_login (GckSession *self,
+ gulong user_type,
+ const guchar *pin,
+ gsize n_pin,
+ GError **err);
+
+ gboolean gck_session_login_full (GckSession *self,
+ gulong user_type,
+ const guchar *pin,
+ gsize n_pin,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_login_async (GckSession *self,
+ gulong user_type,
+ const guchar *pin,
+ gsize n_pin,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_login_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ gboolean gck_session_logout (GckSession *self,
+ GError **err);
+
+ gboolean gck_session_logout_full (GckSession *self,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_logout_async (GckSession *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_logout_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ GckObject* gck_session_create_object (GckSession *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_create_object_async (GckSession *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckObject* gck_session_create_object_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ GList* gck_session_find_objects (GckSession *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_find_objects_async (GckSession *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GList* gck_session_find_objects_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #if UNIMPLEMENTED
+
+ GckObject* gck_session_generate_key (GckSession *self,
+ GckMechanism *mechanism,
+ GError **err,
+ ...);
+
+ void gck_session_generate_key_async (GckSession *self,
+ GckMechanism *mechanism,
+ GAsyncReadyCallback callback,
+ gpointer user_data,
+ ...);
+
+ GckObject* gck_session_generate_key_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err,
+ ...);
+
+ #endif /* UNIMPLEMENTED */
+
+ gboolean gck_session_generate_key_pair_full (GckSession *self,
+ GckMechanism *mechanism,
+ GckAttributes *public_attrs,
+ GckAttributes *private_attrs,
+ GckObject **public_key,
+ GckObject **private_key,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_generate_key_pair_async (GckSession *self,
+ GckMechanism *mechanism,
+ GckAttributes *public_attrs,
+ GckAttributes *private_attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_generate_key_pair_finish (GckSession *self,
+ GAsyncResult *result,
+ GckObject **public_key,
+ GckObject **private_key,
+ GError **err);
+
+ guchar* gck_session_encrypt (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_encrypt_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_encrypt_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_encrypt_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_decrypt (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_decrypt_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_decrypt_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_decrypt_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ #if UNIMPLEMENTED
+
+ guchar* gck_session_digest (GckSession *self,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_digest_full (GckSession *self,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_digest_async (GckSession *self,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_digest_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ guchar* gck_session_sign (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_sign_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_sign_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_sign_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ #if UNIMPLEMENTED
+
+ guchar* gck_session_sign_recover (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_sign_recover_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_sign_recover_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_sign_recover_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ gboolean gck_session_verify (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ const guchar *signature,
+ gsize n_signature,
+ GError **err);
+
+ gboolean gck_session_verify_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ const guchar *signature,
+ gsize n_signature,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_verify_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ const guchar *signature,
+ gsize n_signature,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_session_verify_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #if UNIMPLEMENTED
+
+ guchar* gck_session_verify_recover (GckSession *self,
+ GckObject *key,
+ gulong mech_type,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GError **err);
+
+ guchar* gck_session_verify_recover_full (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_verify_recover_async (GckSession *self,
+ GckObject *key,
+ GckMechanism *mechanism,
+ const guchar *input,
+ gsize n_input,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ guchar* gck_session_verify_recover_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ gpointer gck_session_wrap_key (GckSession *self,
+ GckObject *wrapper,
+ gulong mech_type,
+ GckObject *wrapped,
+ gsize *n_result,
+ GError **err);
+
+ gpointer gck_session_wrap_key_full (GckSession *self,
+ GckObject *wrapper,
+ GckMechanism *mechanism,
+ GckObject *wrapped,
+ gsize *n_result,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_wrap_key_async (GckSession *self,
+ GckObject *wrapper,
+ GckMechanism *mechanism,
+ GckObject *wrapped,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gpointer gck_session_wrap_key_finish (GckSession *self,
+ GAsyncResult *result,
+ gsize *n_result,
+ GError **err);
+
+ GckObject* gck_session_unwrap_key (GckSession *self,
+ GckObject *wrapper,
+ GckMechanism *mechanism,
+ gconstpointer input,
+ gsize n_input,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_unwrap_key_async (GckSession *self,
+ GckObject *wrapper,
+ GckMechanism *mechanism,
+ gconstpointer input,
+ gsize n_input,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckObject* gck_session_unwrap_key_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ GckObject* gck_session_derive_key (GckSession *self,
+ GckObject *base,
+ GckMechanism *mechanism,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_session_derive_key_async (GckSession *self,
+ GckObject *base,
+ GckMechanism *mechanism,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckObject* gck_session_derive_key_finish (GckSession *self,
+ GAsyncResult *result,
+ GError **err);
+
+ /* ------------------------------------------------------------------------
+ * OBJECT
+ */
+
+ #define GCK_TYPE_OBJECT (gck_object_get_type())
+ #define GCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCK_TYPE_OBJECT, GckObject))
+ #define GCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCK_TYPE_OBJECT, GckObject))
+ #define GCK_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCK_TYPE_OBJECT))
+ #define GCK_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCK_TYPE_OBJECT))
+ #define GCK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCK_TYPE_OBJECT, GckObjectClass))
+
+ typedef struct _GckObjectClass GckObjectClass;
+ typedef struct _GckObjectPrivate GckObjectPrivate;
+
+ struct _GckObject {
+ GObject parent;
+ GckObjectPrivate *pv;
+ gpointer reserved[4];
+ };
+
+ struct _GckObjectClass {
+ GObjectClass parent;
+ gpointer reserved[8];
+ };
+
+ GType gck_object_get_type (void) G_GNUC_CONST;
+
+ GckObject* gck_object_from_handle (GckSession *session,
+ CK_OBJECT_HANDLE handle);
+
+ GList* gck_objects_from_handle_array (GckSession *session,
+ CK_OBJECT_HANDLE_PTR handles,
+ CK_ULONG n_handles);
+
+ gboolean gck_object_equal (gconstpointer object1,
+ gconstpointer object2);
+
+ guint gck_object_hash (gconstpointer object);
+
+ GckModule* gck_object_get_module (GckObject *self);
+
+ CK_OBJECT_HANDLE gck_object_get_handle (GckObject *self);
+
+ GckSession* gck_object_get_session (GckObject *self);
+
+ gchar* gck_object_build_uri (GckObject *self,
+ guint options,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_build_uri_async (GckObject *self,
+ guint options,
+ GCancellable *cancellable,
+ GError **err);
+
+ gchar* gck_object_build_uri_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #ifdef UNIMPLEMENTED
+
+ GckObject* gck_object_copy (GckObject *self,
+ GError **err);
+
+ GckObject* gck_object_copy_full (GckObject *self,
+ GckAttributes *additional,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_copy_async (GckObject *self,
+ GckAttributes *additional,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckObject* gck_object_copy_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ gboolean gck_object_destroy (GckObject *self,
+ GError **err);
+
+ gboolean gck_object_destroy_full (GckObject *self,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_destroy_async (GckObject *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_object_destroy_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #if UNIMPLEMENTED
+
+ gssize gck_object_get_size (GckObject *self,
+ GError **err);
+
+ gssize gck_object_get_size_full (GckObject *self,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_get_size_async (GckObject *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gssize gck_object_get_size_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ #endif /* UNIMPLEMENTED */
+
+ gboolean gck_object_set (GckObject *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_set_async (GckObject *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_object_set_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ GckAttributes* gck_object_get (GckObject *self,
+ GError **err,
+ ...);
+
+ GckAttributes* gck_object_get_full (GckObject *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_get_async (GckObject *self,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckAttributes* gck_object_get_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ gpointer gck_object_get_data (GckObject *self,
+ gulong attr_type,
+ gsize *n_data,
+ GError **err);
+
+ gpointer gck_object_get_data_full (GckObject *self,
+ gulong attr_type,
+ GckAllocator allocator,
+ GCancellable *cancellable,
+ gsize *n_data,
+ GError **err);
+
+ void gck_object_get_data_async (GckObject *self,
+ gulong attr_type,
+ GckAllocator allocator,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gpointer gck_object_get_data_finish (GckObject *self,
+ GAsyncResult *result,
+ gsize *n_data,
+ GError **err);
+
+ gboolean gck_object_set_template (GckObject *self,
+ gulong attr_type,
+ GckAttributes *attrs,
+ GError **err);
+
+ gboolean gck_object_set_template_full (GckObject *self,
+ gulong attr_type,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_set_template_async (GckObject *self,
+ gulong attr_type,
+ GckAttributes *attrs,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ gboolean gck_object_set_template_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ GckAttributes* gck_object_get_template (GckObject *self,
+ gulong attr_type,
+ GError **err);
+
+ GckAttributes* gck_object_get_template_full (GckObject *self,
+ gulong attr_type,
+ GCancellable *cancellable,
+ GError **err);
+
+ void gck_object_get_template_async (GckObject *self,
+ gulong attr_type,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+ GckAttributes* gck_object_get_template_finish (GckObject *self,
+ GAsyncResult *result,
+ GError **err);
+
+ /* ----------------------------------------------------------------------------
+ * URI
+ */
+
+ enum {
+ GCK_URI_BAD_PREFIX = 1,
+ GCK_URI_BAD_ENCODING = 2,
+ GCK_URI_BAD_SYNTAX = 3
+ };
+
+ #define GCK_URI_ERROR (gck_uri_get_error_quark ())
+
+ GQuark gck_uri_get_error_quark (void);
+
+ gchar* gck_uri_build (GckTokenInfo *token,
+ GckAttributes *attrs);
+
+ gboolean gck_uri_parse (const gchar *uri,
+ GckTokenInfo **token,
+ GckAttributes **attrs,
+ GError **err);
+
+ G_END_DECLS
+
+ #endif /* GCK_H */
diff --cc gcr/gcr-certificate-widget.c
index d6ef235,0000000..f1ee235
mode 100644,000000..100644
--- a/gcr/gcr-certificate-widget.c
+++ b/gcr/gcr-certificate-widget.c
@@@ -1,517 -1,0 +1,519 @@@
+/*
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gcr-certificate.h"
+#include "gcr-certificate-widget.h"
+#include "gcr-display-view.h"
+#include "gcr-icons.h"
+#include "gcr-simple-certificate.h"
+#include "gcr-view.h"
+
+#include "egg/egg-asn1x.h"
+#include "egg/egg-asn1-defs.h"
+#include "egg/egg-dn.h"
+#include "egg/egg-oid.h"
+#include "egg/egg-hex.h"
+
++#include "gck/gck.h"
++
+#include <gdk/gdk.h>
+#include <glib/gi18n-lib.h>
+
+enum {
+ PROP_0,
+ PROP_CERTIFICATE,
+ PROP_LABEL,
+ PROP_ATTRIBUTES
+};
+
+struct _GcrCertificateWidgetPrivate {
+ GcrCertificate *certificate;
+ GcrDisplayView *view;
+ guint key_size;
+ gchar *label;
- GP11Attributes *attributes;
++ GckAttributes *attributes;
+};
+
+static void gcr_view_iface_init (GcrViewIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GcrCertificateWidget, gcr_certificate_widget, GTK_TYPE_ALIGNMENT,
+ G_IMPLEMENT_INTERFACE (GCR_TYPE_VIEW, gcr_view_iface_init));
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+
+static gchar*
+calculate_label (GcrCertificateWidget *self, GNode *asn)
+{
+ gchar *label;
+
+ if (self->pv->label)
+ return g_strdup (self->pv->label);
+
+ if (self->pv->attributes) {
- if (gp11_attributes_find_string (self->pv->attributes, CKA_LABEL, &label))
++ if (gck_attributes_find_string (self->pv->attributes, CKA_LABEL, &label))
+ return label;
+ }
+
+ if (asn != NULL) {
+ label = egg_dn_read_part (egg_asn1x_node (asn, "tbsCertificate", "subject", "rdnSequence", NULL), "CN");
+ if (label != NULL)
+ return label;
+ }
+
+ return g_strdup (_("Certificate"));
+}
+
+static gboolean
+append_extension (GcrCertificateWidget *self, GNode *asn,
+ const guchar *data, gsize n_data, gint index)
+{
+ GNode *node;
+ GQuark oid;
+ gchar *display;
+ gsize n_value;
+ const guchar *value;
+ const gchar *text;
+ gboolean critical;
+
+ /* Make sure it is present */
+ node = egg_asn1x_node (asn, "tbsCertificate", "extensions", index, NULL);
+ if (node == NULL)
+ return FALSE;
+
+ /* Dig out the OID */
+ oid = egg_asn1x_get_oid_as_quark (egg_asn1x_node (node, "extnID", NULL));
+ g_return_val_if_fail (oid, FALSE);
+
+ _gcr_display_view_append_heading (self->pv->view, _("Extension"));
+
+
+ /* Extension type */
+ text = egg_oid_get_description (oid);
+ _gcr_display_view_append_value (self->pv->view, _("Identifier"), text, FALSE);
+
+
+ /* Extension value */
+ value = egg_asn1x_get_raw_value (egg_asn1x_node (node, "extnValue", NULL), &n_value);
+
+ /* TODO: Parsing of extensions that we understand */
+ display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Value"), display, TRUE);
+ g_free (display);
+
+
+ /* Critical */
+ if (egg_asn1x_get_boolean (egg_asn1x_node (node, "critical", NULL), &critical))
+ _gcr_display_view_append_value (self->pv->view, _("Critical"), critical ? _("Yes") : _("No"), FALSE);
+
+ return TRUE;
+}
+
+static void
+on_parsed_dn_part (guint index, GQuark oid, const guchar *value,
+ gsize n_value, gpointer user_data)
+{
+ GcrCertificateWidget *self = user_data;
+ const gchar *attr;
+ const gchar *desc;
+ gchar *field;
+ gchar *display;
+
+ g_return_if_fail (GCR_IS_CERTIFICATE_WIDGET (self));
+
+ attr = egg_oid_get_name (oid);
+ desc = egg_oid_get_description (oid);
+
+ /* Combine them into something sane */
+ if (attr && desc) {
+ if (strcmp (attr, desc) == 0)
+ field = g_strdup (attr);
+ else
+ field = g_strdup_printf ("%s (%s)", attr, desc);
+ } else if (!attr && !desc) {
+ field = g_strdup ("");
+ } else if (attr) {
+ field = g_strdup (attr);
+ } else if (desc) {
+ field = g_strdup (desc);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ display = egg_dn_print_value (oid, value, n_value);
+ if (display == NULL)
+ display = g_strdup ("");
+
+ _gcr_display_view_append_value (self->pv->view, field, display, FALSE);
+ g_free (field);
+ g_free (display);
+}
+
+static void
+refresh_display (GcrCertificateWidget *self)
+{
+ const guchar *data, *value;
+ gsize n_data, n_value, n_raw;
+ const gchar *text;
+ gpointer raw;
+ gulong version;
+ guint bits, index;
+ gchar *display;
+ GNode *asn;
+ GQuark oid;
+ GDate date;
+
+ if (!self->pv->view)
+ return;
+
+ _gcr_display_view_clear (self->pv->view);
+
+ if (!self->pv->certificate)
+ return;
+
+ data = gcr_certificate_get_der_data (self->pv->certificate, &n_data);
+ g_return_if_fail (data);
+
+ asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data, n_data);
+ g_return_if_fail (asn);
+
+ display = calculate_label (self, asn);
+ _gcr_display_view_append_title (self->pv->view, display);
+ g_free (display);
+
+ display = egg_dn_read_part (egg_asn1x_node (asn, "tbsCertificate", "subject", "rdnSequence", NULL), "CN");
+ _gcr_display_view_append_content (self->pv->view, _("Identity"), display);
+ g_free (display);
+
+ display = egg_dn_read_part (egg_asn1x_node (asn, "tbsCertificate", "issuer", "rdnSequence", NULL), "CN");
+ _gcr_display_view_append_content (self->pv->view, _("Verified by"), display);
+ g_free (display);
+
+ if (egg_asn1x_get_time_as_date (egg_asn1x_node (asn, "tbsCertificate", "validity", "notAfter", NULL), &date)) {
+ display = g_malloc0 (128);
+ if (!g_date_strftime (display, 128, "%x", &date))
+ g_return_if_reached ();
+ _gcr_display_view_append_content (self->pv->view, _("Expires"), display);
+ g_free (display);
+ }
+
+ _gcr_display_view_start_details (self->pv->view);
+
+ /* The subject */
+ _gcr_display_view_append_heading (self->pv->view, _("Subject Name"));
+ egg_dn_parse (egg_asn1x_node (asn, "tbsCertificate", "subject", "rdnSequence", NULL), on_parsed_dn_part, self);
+
+ /* The Issuer */
+ _gcr_display_view_append_heading (self->pv->view, _("Issuer Name"));
+ egg_dn_parse (egg_asn1x_node (asn, "tbsCertificate", "issuer", "rdnSequence", NULL), on_parsed_dn_part, self);
+
+ /* The Issued Parameters */
+ _gcr_display_view_append_heading (self->pv->view, _("Issued Certificate"));
+
+ if (!egg_asn1x_get_integer_as_ulong (egg_asn1x_node (asn, "tbsCertificate", "version", NULL), &version))
+ g_return_if_reached ();
+ display = g_strdup_printf ("%lu", version + 1);
+ _gcr_display_view_append_value (self->pv->view, _("Version"), display, FALSE);
+ g_free (display);
+
+ raw = egg_asn1x_get_integer_as_raw (egg_asn1x_node (asn, "tbsCertificate", "serialNumber", NULL), NULL, &n_raw);
+ g_return_if_fail (raw);
+ display = egg_hex_encode_full (raw, n_raw, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Serial Number"), display, TRUE);
+ g_free (display);
+ g_free (raw);
+
+ display = g_malloc0 (128);
+ if (egg_asn1x_get_time_as_date (egg_asn1x_node (asn, "tbsCertificate", "validity", "notBefore", NULL), &date)) {
+ if (!g_date_strftime (display, 128, "%Y-%m-%d", &date))
+ g_return_if_reached ();
+ _gcr_display_view_append_value (self->pv->view, _("Not Valid Before"), display, FALSE);
+ }
+ if (egg_asn1x_get_time_as_date (egg_asn1x_node (asn, "tbsCertificate", "validity", "notAfter", NULL), &date)) {
+ if (!g_date_strftime (display, 128, "%Y-%m-%d", &date))
+ g_return_if_reached ();
+ _gcr_display_view_append_value (self->pv->view, _("Not Valid After"), display, FALSE);
+ }
+ g_free (display);
+
+ /* Signature */
+ _gcr_display_view_append_heading (self->pv->view, _("Signature"));
+
+ oid = egg_asn1x_get_oid_as_quark (egg_asn1x_node (asn, "signatureAlgorithm", "algorithm", NULL));
+ text = egg_oid_get_description (oid);
+ _gcr_display_view_append_value (self->pv->view, _("Signature Algorithm"), text, FALSE);
+
+ value = egg_asn1x_get_raw_element (egg_asn1x_node (asn, "signatureAlgorithm", "parameters", NULL), &n_value);
+ if (value && n_value) {
+ display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Signature Parameters"), display, TRUE);
+ g_free (display);
+ }
+
+ raw = egg_asn1x_get_bits_as_raw (egg_asn1x_node (asn, "signature", NULL), NULL, &bits);
+ g_return_if_fail (raw);
+ display = egg_hex_encode_full (raw, bits / 8, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Signature"), display, TRUE);
+ g_free (display);
+ g_free (raw);
+
+ /* Public Key Info */
+ _gcr_display_view_append_heading (self->pv->view, _("Public Key Info"));
+
+ oid = egg_asn1x_get_oid_as_quark (egg_asn1x_node (asn, "tbsCertificate", "subjectPublicKeyInfo",
+ "algorithm", "algorithm", NULL));
+ text = egg_oid_get_description (oid);
+ _gcr_display_view_append_value (self->pv->view, _("Key Algorithm"), text, FALSE);
+
+ value = egg_asn1x_get_raw_element (egg_asn1x_node (asn, "tbsCertificate", "subjectPublicKeyInfo",
+ "algorithm", "parameters", NULL), &n_value);
+ if (value && n_value) {
+ display = egg_hex_encode_full (value, n_value, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Key Parameters"), display, TRUE);
+ g_free (display);
+ }
+
+ bits = gcr_certificate_get_key_size (self->pv->certificate);
+ if (bits > 0) {
+ display = g_strdup_printf ("%u", bits);
+ _gcr_display_view_append_value (self->pv->view, _("Key Size"), display, FALSE);
+ g_free (display);
+ }
+
+ raw = egg_asn1x_get_bits_as_raw (egg_asn1x_node (asn, "tbsCertificate", "subjectPublicKeyInfo",
+ "subjectPublicKey", NULL), NULL, &bits);
+ g_return_if_fail (raw);
+ display = egg_hex_encode_full (raw, bits / 8, TRUE, ' ', 1);
+ _gcr_display_view_append_value (self->pv->view, _("Public Key"), display, TRUE);
+ g_free (display);
+ g_free (raw);
+
+ /* Fingerprints */
+ _gcr_display_view_append_heading (self->pv->view, _("Fingerprints"));
+
+ _gcr_display_view_append_fingerprint (self->pv->view, data, n_data, "SHA1", G_CHECKSUM_SHA1);
+ _gcr_display_view_append_fingerprint (self->pv->view, data, n_data, "MD5", G_CHECKSUM_MD5);
+
+ /* Extensions */
+ for (index = 1; TRUE; ++index) {
+ if (!append_extension (self, asn, data, n_data, index))
+ break;
+ }
+
+ egg_asn1x_destroy (asn);
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static GObject*
+gcr_certificate_widget_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ GObject *obj = G_OBJECT_CLASS (gcr_certificate_widget_parent_class)->constructor (type, n_props, props);
+ GcrCertificateWidget *self = NULL;
+ GtkWidget *scroll;
+
+ g_return_val_if_fail (obj, NULL);
+
+ self = GCR_CERTIFICATE_WIDGET (obj);
+
+ self->pv->view = _gcr_display_view_new ();
+ _gcr_display_view_set_stock_image (self->pv->view, GCR_ICON_CERTIFICATE);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (self->pv->view));
+
+ gtk_container_add (GTK_CONTAINER (self), scroll);
+ gtk_widget_show_all (scroll);
+
+ return obj;
+}
+
+static void
+gcr_certificate_widget_init (GcrCertificateWidget *self)
+{
+ self->pv = (G_TYPE_INSTANCE_GET_PRIVATE (self, GCR_TYPE_CERTIFICATE_WIDGET, GcrCertificateWidgetPrivate));
+}
+
+static void
+gcr_certificate_widget_dispose (GObject *obj)
+{
+ GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (obj);
+
+ if (self->pv->certificate)
+ g_object_unref (self->pv->certificate);
+ self->pv->certificate = NULL;
+
+ G_OBJECT_CLASS (gcr_certificate_widget_parent_class)->dispose (obj);
+}
+
+static void
+gcr_certificate_widget_finalize (GObject *obj)
+{
+ GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (obj);
+
+ g_assert (!self->pv->certificate);
+
+ if (self->pv->attributes)
- gp11_attributes_unref (self->pv->attributes);
++ gck_attributes_unref (self->pv->attributes);
+ self->pv->attributes = NULL;
+
+ g_free (self->pv->label);
+ self->pv->label = NULL;
+
+ G_OBJECT_CLASS (gcr_certificate_widget_parent_class)->finalize (obj);
+}
+
+static void
+gcr_certificate_widget_set_property (GObject *obj, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (obj);
+ GcrCertificate *cert;
- GP11Attribute *attr;
++ GckAttribute *attr;
+
+ switch (prop_id) {
+ case PROP_CERTIFICATE:
+ gcr_certificate_widget_set_certificate (self, g_value_get_object (value));
+ break;
+ case PROP_LABEL:
+ g_free (self->pv->label);
+ self->pv->label = g_value_dup_string (value);
+ g_object_notify (obj, "label");
+ refresh_display (self);
+ break;
+ case PROP_ATTRIBUTES:
+ g_return_if_fail (!self->pv->attributes);
+ self->pv->attributes = g_value_dup_boxed (value);
+ if (self->pv->attributes) {
- attr = gp11_attributes_find (self->pv->attributes, CKA_VALUE);
++ attr = gck_attributes_find (self->pv->attributes, CKA_VALUE);
+ if (attr) {
+ /* Create a new certificate object refferring to same memory */
+ cert = gcr_simple_certificate_new_static (attr->value, attr->length);
+ g_object_set_data_full (G_OBJECT (cert), "attributes",
- gp11_attributes_ref (self->pv->attributes),
- (GDestroyNotify)gp11_attributes_unref);
++ gck_attributes_ref (self->pv->attributes),
++ (GDestroyNotify)gck_attributes_unref);
+ gcr_certificate_widget_set_certificate (self, cert);
+ g_object_unref (cert);
+ refresh_display (self);
+ }
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gcr_certificate_widget_get_property (GObject *obj, guint prop_id, GValue *value,
+ GParamSpec *pspec)
+{
+ GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (obj);
+
+ switch (prop_id) {
+ case PROP_CERTIFICATE:
+ g_value_set_object (value, self->pv->certificate);
+ break;
+ case PROP_LABEL:
+ g_value_take_string (value, calculate_label (self, NULL));
+ break;
+ case PROP_ATTRIBUTES:
+ g_value_set_boxed (value, self->pv->attributes);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gcr_certificate_widget_class_init (GcrCertificateWidgetClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GP11Attributes *registered;
++ GckAttributes *registered;
+
+ gcr_certificate_widget_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GcrCertificateWidgetPrivate));
+
+ gobject_class->constructor = gcr_certificate_widget_constructor;
+ gobject_class->dispose = gcr_certificate_widget_dispose;
+ gobject_class->finalize = gcr_certificate_widget_finalize;
+ gobject_class->set_property = gcr_certificate_widget_set_property;
+ gobject_class->get_property = gcr_certificate_widget_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_CERTIFICATE,
+ g_param_spec_object("certificate", "Certificate", "Certificate to display.",
+ GCR_TYPE_CERTIFICATE, G_PARAM_READWRITE));
+
+ g_object_class_override_property (gobject_class, PROP_LABEL, "label");
+ g_object_class_override_property (gobject_class, PROP_ATTRIBUTES, "attributes");
+
+ _gcr_icons_register ();
+
+ /* Register this as a view which can be loaded */
- registered = gp11_attributes_new ();
- gp11_attributes_add_ulong (registered, CKA_CLASS, CKO_CERTIFICATE);
++ registered = gck_attributes_new ();
++ gck_attributes_add_ulong (registered, CKA_CLASS, CKO_CERTIFICATE);
+ gcr_view_register (GCR_TYPE_CERTIFICATE_WIDGET, registered);
- gp11_attributes_unref (registered);
++ gck_attributes_unref (registered);
+}
+
+static void
+gcr_view_iface_init (GcrViewIface *iface)
+{
+ /* Nothing to do */
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+GcrCertificateWidget*
+gcr_certificate_widget_new (GcrCertificate *certificate)
+{
+ return g_object_new (GCR_TYPE_CERTIFICATE_WIDGET, "certificate", certificate, NULL);
+}
+
+GcrCertificate*
+gcr_certificate_widget_get_certificate (GcrCertificateWidget *self)
+{
+ g_return_val_if_fail (GCR_IS_CERTIFICATE_WIDGET (self), NULL);
+ return self->pv->certificate;
+}
+
+void
+gcr_certificate_widget_set_certificate (GcrCertificateWidget *self, GcrCertificate *cert)
+{
+ g_return_if_fail (GCR_IS_CERTIFICATE_WIDGET (self));
+
+ if (self->pv->certificate)
+ g_object_unref (self->pv->certificate);
+ self->pv->certificate = cert;
+ if (self->pv->certificate)
+ g_object_ref (self->pv->certificate);
+
+ refresh_display (self);
+ g_object_notify (G_OBJECT (self), "certificate");
+}
diff --cc gcr/gcr-importer.c
index 68c94b8,87dfc7d..de4c07d
--- a/gcr/gcr-importer.c
+++ b/gcr/gcr-importer.c
@@@ -55,11 -54,13 +55,12 @@@ struct _GcrImporterPrivate
/* State data during import */
gboolean processing;
GCancellable *cancel;
- GInputStream *input;
gboolean prompted;
gboolean async;
- GP11Session *session;
+ GByteArray *buffer;
+ GckSession *session;
GQueue queue;
--
++
/* Extra async stuff */
GAsyncReadyCallback callback;
gpointer user_data;
@@@ -85,16 -88,24 +86,20 @@@ G_DEFINE_TYPE_WITH_CODE (GcrImporter, g
static void
cleanup_state_data (GcrImporter *self)
{
- GP11Attributes *attrs;
+ GckAttributes *attrs;
-
++
+ if (self->pv->buffer)
+ g_byte_array_free (self->pv->buffer, TRUE);
+ self->pv->buffer = NULL;
-
+
if (self->pv->session)
g_object_unref (self->pv->session);
self->pv->session = NULL;
while ((attrs = g_queue_pop_head (&self->pv->queue)) != NULL)
- gp11_attributes_unref (attrs);
+ gck_attributes_unref (attrs);
g_assert (g_queue_is_empty (&self->pv->queue));
-
- if (self->pv->input)
- g_object_unref (self->pv->input);
- self->pv->input = NULL;
-
+
if (self->pv->cancel)
g_object_unref (self->pv->cancel);
self->pv->cancel = NULL;
@@@ -121,103 -132,6 +126,103 @@@ next_state (GcrImporter *self, void (*s
(state) (self, self->pv->async);
}
+static const gchar*
+prepare_auth_primary (CK_OBJECT_CLASS klass)
+{
+ if (klass == CKO_PRIVATE_KEY)
+ return _("Enter password to unlock the private key");
+ else if (klass == CKO_CERTIFICATE)
+ return _("Enter password to unlock the certificate");
+ else
+ return _("Enter password to unlock");
+}
+
+static gchar*
+prepare_auth_secondary (CK_OBJECT_CLASS klass, const gchar *label)
+{
+ if (label == NULL) {
+ if (klass == CKO_PRIVATE_KEY) {
+ /* TRANSLATORS: The key is locked. */
+ return g_strdup (_("In order to import the private key, it must be unlocked"));
+ } else if (klass == CKO_CERTIFICATE) {
+ /* TRANSLATORS: The certificate is locked. */
+ return g_strdup (_("In order to import the certificate, it must be unlocked"));
+ } else {
+ /* TRANSLATORS: The data is locked. */
+ return g_strdup (_("In order to import the data, it must be unlocked"));
+ }
+ } else {
+ if (klass == CKO_PRIVATE_KEY) {
+ /* TRANSLATORS: The key is locked. */
+ return g_strdup_printf (_("In order to import the private key '%s', it must be unlocked"), label);
+ } else if (klass == CKO_CERTIFICATE) {
+ /* TRANSLATORS: The certificate is locked. */
+ return g_strdup_printf (_("In order to import the certificate '%s', it must be unlocked"), label);
+ } else {
+ /* TRANSLATORS: The object '%s' is locked. */
+ return g_strdup_printf (_("In order to import '%s', it must be unlocked"), label);
+ }
+ }
+}
+
+static void
+on_parser_parsed (GcrParser *parser, GcrImporter *self)
+{
- GP11Attributes *attrs;
++ GckAttributes *attrs;
+
+ g_return_if_fail (GCR_IS_PARSER (parser));
+ g_return_if_fail (GCR_IS_IMPORTER (self));
+
+ attrs = gcr_parser_get_parsed_attributes (parser);
+ g_return_if_fail (attrs);
+
+ gcr_importer_queue (self, gcr_parser_get_parsed_label (parser), attrs);
+}
+
+static gboolean
+on_parser_authenticate (GcrParser *parser, gint count, GcrImporter *self)
+{
+ GcrImportDialog *dialog;
- GP11Attributes *attrs;
++ GckAttributes *attrs;
+ const gchar *password;
+ gchar *text, *label;
- GP11Slot *slot;
++ GckSlot *slot;
+ gulong klass;
+
+ dialog = _gcr_import_dialog_new ();
+
+ if (self->pv->slot)
+ _gcr_import_dialog_set_selected_slot (dialog, self->pv->slot);
+
+ /* Figure out the text for the dialog */
+ attrs = gcr_parser_get_parsed_attributes (parser);
+ g_return_val_if_fail (attrs, FALSE);
+
- if (!gp11_attributes_find_ulong (attrs, CKA_CLASS, &klass))
++ if (!gck_attributes_find_ulong (attrs, CKA_CLASS, &klass))
+ klass = (gulong)-1;
- if (!gp11_attributes_find_string (attrs, CKA_LABEL, &label))
++ if (!gck_attributes_find_string (attrs, CKA_LABEL, &label))
+ label = NULL;
+
+ text = prepare_auth_secondary (klass, label);
+ _gcr_import_dialog_set_primary_text (dialog, prepare_auth_primary (klass));
+ _gcr_import_dialog_set_secondary_text (dialog, text);
+ g_free (label);
+ g_free (text);
+
+ if (!_gcr_import_dialog_run (dialog, NULL))
+ return FALSE;
+
+ slot = _gcr_import_dialog_get_selected_slot (dialog);
+ gcr_importer_set_slot (self, slot);
+
+ password = _gcr_import_dialog_get_password (dialog);
+ gcr_parser_add_password (parser, password);
+
+ g_object_unref (dialog);
+ self->pv->prompted = TRUE;
+ return TRUE;
+}
+
/* ---------------------------------------------------------------------------------
* COMPLETE
*/
@@@ -612,20 -742,19 +617,20 @@@ gcr_importer_class_init (GcrImporterCla
gobject_class->get_property = gcr_importer_get_property;
g_type_class_add_private (gobject_class, sizeof (GcrImporterPrivate));
-
- g_object_class_install_property (gobject_class, PROP_PARSER,
- g_param_spec_object ("parser", "Parser", "Parser used to parse imported data",
- GCR_TYPE_PARSER, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_PARSER,
+
+ g_object_class_install_property (gobject_class, PROP_SLOT,
g_param_spec_object ("slot", "Slot", "PKCS#11 slot to import data into",
- GP11_TYPE_SLOT, G_PARAM_READWRITE));
+ GCK_TYPE_SLOT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_PROMPT_BEHAVIOR,
g_param_spec_int ("prompt-behavior", "Prompt Behavior", "Import Prompt Behavior",
0, G_MAXINT, GCR_IMPORTER_PROMPT_NEEDED, G_PARAM_READWRITE));
-
+
+ signals[QUEUED] = g_signal_new ("queued", GCR_TYPE_IMPORTER,
+ G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GcrImporterClass, queued),
+ NULL, NULL, _gcr_marshal_VOID__STRING_BOXED,
- G_TYPE_NONE, 1, G_TYPE_STRING, GP11_TYPE_ATTRIBUTES);
++ G_TYPE_NONE, 1, G_TYPE_STRING, GCK_TYPE_ATTRIBUTES);
+
signals[IMPORTED] = g_signal_new ("imported", GCR_TYPE_IMPORTER,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GcrImporterClass, imported),
NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
@@@ -665,7 -794,29 +670,7 @@@ gcr_importer_new (void
return g_object_new (GCR_TYPE_IMPORTER, NULL);
}
- GP11Slot*
-GcrParser*
-gcr_importer_get_parser (GcrImporter *self)
-{
- g_return_val_if_fail (GCR_IS_IMPORTER (self), NULL);
- if (!self->pv->parser)
- self->pv->parser = gcr_parser_new ();
- return self->pv->parser;
-}
-
-void
-gcr_importer_set_parser (GcrImporter *self, GcrParser *parser)
-{
- g_return_if_fail (GCR_IS_IMPORTER (self));
-
- if (parser)
- g_object_ref (parser);
- if (self->pv->parser)
- g_object_unref (self->pv->parser);
- self->pv->parser = parser;
- g_object_notify (G_OBJECT (self), "parser");
-}
-
+ GckSlot*
gcr_importer_get_slot (GcrImporter *self)
{
g_return_val_if_fail (GCR_IS_IMPORTER (self), NULL);
@@@ -766,25 -924,3 +771,25 @@@ gcr_importer_import_finish (GcrImporte
return TRUE;
}
+
+
+void
+gcr_importer_listen (GcrImporter *self, GcrParser *parser)
+{
+ g_return_if_fail (GCR_IS_IMPORTER (self));
+ g_return_if_fail (GCR_IS_PARSER (self));
+
+ /* Listen in to the parser */
+ g_signal_connect_object (parser, "parsed", G_CALLBACK (on_parser_parsed), self, 0);
+ g_signal_connect_object (parser, "authenticate", G_CALLBACK (on_parser_authenticate), self, 0);
+}
+
+void
- gcr_importer_queue (GcrImporter *self, const gchar *label, GP11Attributes *attrs)
++gcr_importer_queue (GcrImporter *self, const gchar *label, GckAttributes *attrs)
+{
+ g_return_if_fail (GCR_IS_IMPORTER (self));
+ g_return_if_fail (attrs);
+
- g_queue_push_tail (&self->pv->queue, gp11_attributes_ref (attrs));
++ g_queue_push_tail (&self->pv->queue, gck_attributes_ref (attrs));
+ g_signal_emit (self, signals[QUEUED], 0, label, attrs);
+}
diff --cc gcr/gcr-importer.h
index 2d9f794,d186fb9..2e836aa
--- a/gcr/gcr-importer.h
+++ b/gcr/gcr-importer.h
@@@ -53,34 -53,33 +53,34 @@@ struct _GcrImporter
struct _GcrImporterClass {
GObjectClass parent_class;
-
+
/* signals */
- void (*queued) (GcrImporter *self, const gchar *label, struct _GP11Attributes *attrs);
- void (*imported) (GcrImporter *self, struct _GP11Object *object);
-
++ void (*queued) (GcrImporter *self, const gchar *label, struct _GckAttributes *attrs);
+ void (*imported) (GcrImporter *self, struct _GckObject *object);
};
GType gcr_importer_get_type (void);
GcrImporter* gcr_importer_new (void);
- struct _GP11Slot* gcr_importer_get_slot (GcrImporter *self);
-GcrParser* gcr_importer_get_parser (GcrImporter *self);
-
-void gcr_importer_set_parser (GcrImporter *self,
- GcrParser *parser);
-
+ struct _GckSlot* gcr_importer_get_slot (GcrImporter *self);
void gcr_importer_set_slot (GcrImporter *self,
- struct _GP11Slot *slot);
+ struct _GckSlot *slot);
GcrImporterPromptBehavior gcr_importer_get_prompt_behavior (GcrImporter *self);
void gcr_importer_set_prompt_behavior (GcrImporter *self,
GcrImporterPromptBehavior behavior);
+void gcr_importer_queue (GcrImporter *self,
+ const gchar *label,
- struct _GP11Attributes *attrs);
++ struct _GckAttributes *attrs);
+
+void gcr_importer_listen (GcrImporter *self,
+ GcrParser *parser);
+
gboolean gcr_importer_import (GcrImporter *self,
- GInputStream *input,
GCancellable *cancel,
GError **error);
diff --cc gcr/gcr-key-widget.c
index bfdf77d,0000000..8f7a7b5
mode 100644,000000..100644
--- a/gcr/gcr-key-widget.c
+++ b/gcr/gcr-key-widget.c
@@@ -1,337 -1,0 +1,337 @@@
+/*
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gcr-key-widget.h"
+#include "gcr-display-view.h"
+#include "gcr-icons.h"
+#include "gcr-view.h"
+
+#include "egg/egg-asn1x.h"
+#include "egg/egg-oid.h"
+#include "egg/egg-hex.h"
+
- #include "gp11/gp11.h"
++#include "gck/gck.h"
+
+#include <gdk/gdk.h>
+#include <glib/gi18n-lib.h>
+
+enum {
+ PROP_0,
+ PROP_LABEL,
+ PROP_ATTRIBUTES
+};
+
+struct _GcrKeyWidgetPrivate {
+ GcrDisplayView *view;
+ guint key_size;
+ gchar *label;
- GP11Attributes *attributes;
++ GckAttributes *attributes;
+};
+
+static void gcr_view_iface_init (GcrViewIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GcrKeyWidget, gcr_key_widget, GTK_TYPE_ALIGNMENT,
+ G_IMPLEMENT_INTERFACE (GCR_TYPE_VIEW, gcr_view_iface_init));
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+
+static gchar*
+calculate_label (GcrKeyWidget *self)
+{
+ gchar *label;
+
+ if (self->pv->label)
+ return g_strdup (self->pv->label);
+
+ if (self->pv->attributes) {
- if (gp11_attributes_find_string (self->pv->attributes, CKA_LABEL, &label))
++ if (gck_attributes_find_string (self->pv->attributes, CKA_LABEL, &label))
+ return label;
+ }
+
+ return g_strdup (_("Key"));
+}
+
+static gint
- calculate_rsa_key_size (GP11Attributes *attrs)
++calculate_rsa_key_size (GckAttributes *attrs)
+{
- GP11Attribute *attr;
++ GckAttribute *attr;
+ gulong bits;
+
- attr = gp11_attributes_find (attrs, CKA_MODULUS);
++ attr = gck_attributes_find (attrs, CKA_MODULUS);
+
+ /* Calculate the bit length, and remove the complement */
+ if (attr != NULL)
+ return (attr->length / 2) * 2 * 8;
+
- if (gp11_attributes_find_ulong (attrs, CKA_MODULUS_BITS, &bits))
++ if (gck_attributes_find_ulong (attrs, CKA_MODULUS_BITS, &bits))
+ return (gint)bits;
+
+ return -1;
+}
+
+static guint
- calculate_dsa_key_size (GP11Attributes *attrs)
++calculate_dsa_key_size (GckAttributes *attrs)
+{
- GP11Attribute *attr;
++ GckAttribute *attr;
+ gulong bits;
+
- attr = gp11_attributes_find (attrs, CKA_PRIME);
++ attr = gck_attributes_find (attrs, CKA_PRIME);
+
+ /* Calculate the bit length, and remove the complement */
+ if (attr != NULL)
+ return (attr->length / 2) * 2 * 8;
+
- if (gp11_attributes_find_ulong (attrs, CKA_PRIME_BITS, &bits))
++ if (gck_attributes_find_ulong (attrs, CKA_PRIME_BITS, &bits))
+ return (gint)bits;
+
+ return -1;
+}
+
+static gint
- calculate_key_size (GP11Attributes *attrs, gulong key_type)
++calculate_key_size (GckAttributes *attrs, gulong key_type)
+{
+ if (key_type == CKK_RSA)
+ return calculate_rsa_key_size (attrs);
+ else if (key_type == CKK_DSA)
+ return calculate_dsa_key_size (attrs);
+ else
+ return -1;
+}
+
+static void
+refresh_display (GcrKeyWidget *self)
+{
+ const gchar *text;
+ gchar *display;
+ gulong klass;
+ gulong key_type;
+ gint size;
+
+ if (!self->pv->view)
+ return;
+
+ _gcr_display_view_clear (self->pv->view);
+
+ if (!self->pv->attributes)
+ return;
+
- if (!gp11_attributes_find_ulong (self->pv->attributes, CKA_CLASS, &klass) ||
- !gp11_attributes_find_ulong (self->pv->attributes, CKA_KEY_TYPE, &key_type)) {
++ if (!gck_attributes_find_ulong (self->pv->attributes, CKA_CLASS, &klass) ||
++ !gck_attributes_find_ulong (self->pv->attributes, CKA_KEY_TYPE, &key_type)) {
+ g_warning ("private key does not have the CKA_CLASS and CKA_KEY_TYPE attributes");
+ return;
+ }
+
+ display = calculate_label (self);
+ _gcr_display_view_append_title (self->pv->view, display);
+ g_free (display);
+
+ if (klass == CKO_PRIVATE_KEY) {
+ if (key_type == CKK_RSA)
+ text = _("Private RSA Key");
+ else if (key_type == CKK_DSA)
+ text = _("Private DSA Key");
+ else
+ text = _("Private Key");
+ } else if (klass == CKO_PUBLIC_KEY) {
+ if (key_type == CKK_RSA)
+ text = _("Public DSA Key");
+ else if (key_type == CKK_DSA)
+ text = _("Public DSA Key");
+ else
+ text = _("Public Key");
+ }
+
+ _gcr_display_view_append_content (self->pv->view, text, NULL);
+
+ size = calculate_key_size (self->pv->attributes, key_type);
+ if (size >= 0) {
+ display = g_strdup_printf (_("%d bits"), size);
+ _gcr_display_view_append_content (self->pv->view, _("Strength"), display);
+ g_free (display);
+ }
+
+ _gcr_display_view_start_details (self->pv->view);
+
+
+ if (key_type == CKK_RSA)
+ text = _("RSA");
+ else if (key_type == CKK_DSA)
+ text = _("DSA");
+ else
+ text = _("Unknown");
+ _gcr_display_view_append_value (self->pv->view, _("Algorithm"), text, FALSE);
+
+ size = calculate_key_size (self->pv->attributes, key_type);
+ if (size < 0)
+ display = g_strdup (_("Unknown"));
+ else
+ display = g_strdup_printf ("%d", size);
+ _gcr_display_view_append_value (self->pv->view, _("Size"), display, FALSE);
+ g_free (display);
+
+ /* TODO: We need to have consistent key fingerprints. */
+ _gcr_display_view_append_value (self->pv->view, _("Fingerprint"), "XX XX XX XX XX XX XX XX XX XX", TRUE);
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static GObject*
+gcr_key_widget_constructor (GType type, guint n_props, GObjectConstructParam *props)
+{
+ GObject *obj = G_OBJECT_CLASS (gcr_key_widget_parent_class)->constructor (type, n_props, props);
+ GcrKeyWidget *self = NULL;
+ GtkWidget *scroll;
+
+ g_return_val_if_fail (obj, NULL);
+
+ self = GCR_KEY_WIDGET (obj);
+
+ self->pv->view = _gcr_display_view_new ();
+ _gcr_display_view_set_stock_image (self->pv->view, GTK_STOCK_DIALOG_AUTHENTICATION);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
+ gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (self->pv->view));
+
+ gtk_container_add (GTK_CONTAINER (self), scroll);
+ gtk_widget_show_all (scroll);
+
+ refresh_display (self);
+
+ return obj;
+}
+
+static void
+gcr_key_widget_init (GcrKeyWidget *self)
+{
+ self->pv = (G_TYPE_INSTANCE_GET_PRIVATE (self, GCR_TYPE_KEY_WIDGET, GcrKeyWidgetPrivate));
+}
+
+static void
+gcr_key_widget_dispose (GObject *obj)
+{
+ G_OBJECT_CLASS (gcr_key_widget_parent_class)->dispose (obj);
+}
+
+static void
+gcr_key_widget_finalize (GObject *obj)
+{
+ GcrKeyWidget *self = GCR_KEY_WIDGET (obj);
+
+ if (self->pv->attributes)
- gp11_attributes_unref (self->pv->attributes);
++ gck_attributes_unref (self->pv->attributes);
+ self->pv->attributes = NULL;
+
+ g_free (self->pv->label);
+ self->pv->label = NULL;
+
+ G_OBJECT_CLASS (gcr_key_widget_parent_class)->finalize (obj);
+}
+
+static void
+gcr_key_widget_set_property (GObject *obj, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ GcrKeyWidget *self = GCR_KEY_WIDGET (obj);
+
+ switch (prop_id) {
+ case PROP_LABEL:
+ g_free (self->pv->label);
+ self->pv->label = g_value_dup_string (value);
+ g_object_notify (obj, "label");
+ refresh_display (self);
+ break;
+ case PROP_ATTRIBUTES:
+ g_return_if_fail (!self->pv->attributes);
+ self->pv->attributes = g_value_dup_boxed (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gcr_key_widget_get_property (GObject *obj, guint prop_id, GValue *value,
+ GParamSpec *pspec)
+{
+ GcrKeyWidget *self = GCR_KEY_WIDGET (obj);
+
+ switch (prop_id) {
+ case PROP_LABEL:
+ g_value_take_string (value, calculate_label (self));
+ break;
+ case PROP_ATTRIBUTES:
+ g_value_set_boxed (value, self->pv->attributes);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gcr_key_widget_class_init (GcrKeyWidgetClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GP11Attributes *registered;
++ GckAttributes *registered;
+
+ gcr_key_widget_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GcrKeyWidgetPrivate));
+
+ gobject_class->constructor = gcr_key_widget_constructor;
+ gobject_class->dispose = gcr_key_widget_dispose;
+ gobject_class->finalize = gcr_key_widget_finalize;
+ gobject_class->set_property = gcr_key_widget_set_property;
+ gobject_class->get_property = gcr_key_widget_get_property;
+
+ g_object_class_override_property (gobject_class, PROP_LABEL, "label");
+ g_object_class_override_property (gobject_class, PROP_ATTRIBUTES, "attributes");
+
+ _gcr_icons_register ();
+
+ /* Register this as a view which can be loaded */
- registered = gp11_attributes_new ();
- gp11_attributes_add_ulong (registered, CKA_CLASS, CKO_PRIVATE_KEY);
++ registered = gck_attributes_new ();
++ gck_attributes_add_ulong (registered, CKA_CLASS, CKO_PRIVATE_KEY);
+ gcr_view_register (GCR_TYPE_KEY_WIDGET, registered);
- gp11_attributes_unref (registered);
++ gck_attributes_unref (registered);
+}
+
+static void
+gcr_view_iface_init (GcrViewIface *iface)
+{
+ /* Nothing to do */
+}
+
+/* -----------------------------------------------------------------------------
+ * PUBLIC
+ */
+
+GcrKeyWidget*
- gcr_key_widget_new (const gchar *label, GP11Attributes *attrs)
++gcr_key_widget_new (const gchar *label, GckAttributes *attrs)
+{
+ return g_object_new (GCR_TYPE_KEY_WIDGET, "label", label, "attributes", attrs, NULL);
+}
diff --cc gcr/gcr-key-widget.h
index 0aeffac,0000000..34aefa0
mode 100644,000000..100644
--- a/gcr/gcr-key-widget.h
+++ b/gcr/gcr-key-widget.h
@@@ -1,57 -1,0 +1,57 @@@
+/*
+ * Copyright (C) 2010 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GCR_KEY_WIDGET_H__
+#define __GCR_KEY_WIDGET_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "gcr-types.h"
+
+G_BEGIN_DECLS
+
+#define GCR_TYPE_KEY_WIDGET (gcr_key_widget_get_type ())
+#define GCR_KEY_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_KEY_WIDGET, GcrKeyWidget))
+#define GCR_KEY_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCR_TYPE_KEY_WIDGET, GcrKeyWidgetClass))
+#define GCR_IS_KEY_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_KEY_WIDGET))
+#define GCR_IS_KEY_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCR_TYPE_KEY_WIDGET))
+#define GCR_KEY_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCR_TYPE_KEY_WIDGET, GcrKeyWidgetClass))
+
+typedef struct _GcrKeyWidget GcrKeyWidget;
+typedef struct _GcrKeyWidgetClass GcrKeyWidgetClass;
+typedef struct _GcrKeyWidgetPrivate GcrKeyWidgetPrivate;
+
+struct _GcrKeyWidget {
+ GtkAlignment parent;
+ GcrKeyWidgetPrivate *pv;
+};
+
+struct _GcrKeyWidgetClass {
+ GtkAlignmentClass parent_class;
+};
+
+GType gcr_key_widget_get_type (void);
+
+GcrKeyWidget* gcr_key_widget_new (const gchar *label,
- struct _GP11Attributes *attrs);
++ struct _GckAttributes *attrs);
+
+G_END_DECLS
+
+#endif /* __GCR_KEY_WIDGET_H__ */
diff --cc gcr/gcr-view.c
index ff6c763,0000000..9df6606
mode 100644,000000..100644
--- a/gcr/gcr-view.c
+++ b/gcr/gcr-view.c
@@@ -1,144 -1,0 +1,144 @@@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2010 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "gcr-view.h"
+
- #include "gp11/gp11.h"
++#include "gck/gck.h"
+
+#include <gtk/gtk.h>
+
+typedef struct _GcrRegisteredView {
- GP11Attributes *attrs;
++ GckAttributes *attrs;
+ GType view_type;
+} GcrRegisteredView;
+
+static GArray *registered_views = NULL;
+static gboolean registered_sorted = FALSE;
+
+static void
+gcr_view_base_init (gpointer gobject_iface)
+{
+ static gboolean initialized = FALSE;
+ if (!initialized) {
+
+ g_object_interface_install_property (gobject_iface,
+ g_param_spec_string ("label", "Label", "The label for the view",
+ "", G_PARAM_READWRITE));
+
+ g_object_interface_install_property (gobject_iface,
+ g_param_spec_boxed ("attributes", "Attributes", "The data displayed in the view",
- GP11_TYPE_ATTRIBUTES, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
++ GCK_TYPE_ATTRIBUTES, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ initialized = TRUE;
+ }
+}
+
+GType
+gcr_view_get_type (void)
+{
+ static GType type = 0;
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (GcrViewIface),
+ gcr_view_base_init, /* base init */
+ NULL, /* base finalize */
+ };
+ type = g_type_register_static (G_TYPE_INTERFACE, "GcrViewIface", &info, 0);
+ g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
+ }
+
+ return type;
+}
+
+static gint
+sort_registered_by_n_attrs (gconstpointer a, gconstpointer b)
+{
+ const GcrRegisteredView *ra = a;
+ const GcrRegisteredView *rb = b;
+ gulong na, nb;
+
+ g_assert (a);
+ g_assert (b);
+
- na = gp11_attributes_count (ra->attrs);
- nb = gp11_attributes_count (rb->attrs);
++ na = gck_attributes_count (ra->attrs);
++ nb = gck_attributes_count (rb->attrs);
+
+ /* Note we're sorting in reverse order */
+ if (na < nb)
+ return 1;
+ return (na == nb) ? 0 : -1;
+}
+
+GcrView*
- gcr_view_create (const gchar *label, GP11Attributes *attrs)
++gcr_view_create (const gchar *label, GckAttributes *attrs)
+{
+ GcrRegisteredView *registered;
+ gboolean matched;
+ gulong n_attrs;
+ gulong j;
+ gsize i;
+
+ g_return_val_if_fail (attrs, NULL);
+
+ if (!registered_views)
+ return NULL;
+
+ if (!registered_sorted) {
+ g_array_sort (registered_views, sort_registered_by_n_attrs);
+ registered_sorted = TRUE;
+ }
+
+ for (i = 0; i < registered_views->len; ++i) {
+ registered = &(g_array_index (registered_views, GcrRegisteredView, i));
- n_attrs = gp11_attributes_count (registered->attrs);
++ n_attrs = gck_attributes_count (registered->attrs);
+
+ matched = TRUE;
+
+ for (j = 0; j < n_attrs; ++j) {
- if (!gp11_attributes_contains (attrs, gp11_attributes_at (registered->attrs, j))) {
++ if (!gck_attributes_contains (attrs, gck_attributes_at (registered->attrs, j))) {
+ matched = FALSE;
+ break;
+ }
+ }
+
+ if (matched)
+ return g_object_new (registered->view_type, "label", label,
+ "attributes", attrs, NULL);
+ }
+
+ return NULL;
+}
+
+void
- gcr_view_register (GType view_type, GP11Attributes *attrs)
++gcr_view_register (GType view_type, GckAttributes *attrs)
+{
+ GcrRegisteredView registered;
+
+ if (!registered_views)
+ registered_views = g_array_new (FALSE, FALSE, sizeof (GcrRegisteredView));
+
+ registered.view_type = view_type;
- registered.attrs = gp11_attributes_ref (attrs);
++ registered.attrs = gck_attributes_ref (attrs);
+ g_array_append_val (registered_views, registered);
+ registered_sorted = FALSE;
+}
diff --cc gcr/gcr-view.h
index d630756,0000000..cbcbbfa
mode 100644,000000..100644
--- a/gcr/gcr-view.h
+++ b/gcr/gcr-view.h
@@@ -1,53 -1,0 +1,53 @@@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2010 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GCR_VIEW_H__
+#define __GCR_VIEW_H__
+
+#include <glib-object.h>
+
+#include "gcr-types.h"
+
+G_BEGIN_DECLS
+
+#define GCR_TYPE_VIEW (gcr_view_get_type())
+#define GCR_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_VIEW, GcrView))
+#define GCR_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_VIEW))
+#define GCR_VIEW_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GCR_TYPE_VIEW, GcrViewIface))
+
+typedef struct _GcrView GcrView;
+typedef struct _GcrViewIface GcrViewIface;
+
+struct _GcrViewIface {
+ GTypeInterface parent;
+};
+
+GType gcr_view_get_type (void) G_GNUC_CONST;
+
+GcrView* gcr_view_create (const gchar *label,
- struct _GP11Attributes *attrs);
++ struct _GckAttributes *attrs);
+
+void gcr_view_register (GType view_type,
- struct _GP11Attributes *attrs);
++ struct _GckAttributes *attrs);
+
+G_END_DECLS
+
+#endif /* __GCR_VIEW_H__ */
diff --cc po/sl.po
index 9af6633,f0d57c5..ba1b412
--- a/po/sl.po
+++ b/po/sl.po
@@@ -1055,404 -1055,4 +1055,3 @@@ msgstr "_Staro geslo:
#: ../ui/gku-prompt.ui.h:8
msgid "_Password:"
msgstr "_Geslo:"
--
- #~ msgid "Automatically unlock secure storage when I log in."
- #~ msgstr "Samodejno odkleni zbirko kljuÄ?ev ob prijavi."
-
- #~ msgid ""
- #~ "<span size=\"large\" weight=\"bold\">Enter password for keyring 'login' "
- #~ "to unlock</span>\n"
- #~ "\n"
- #~ "An application wants access to the keyring 'xxx', but it is locked."
- #~ msgstr ""
- #~ "<span size=\"large\" weight=\"bold\">Vnesite geslo za zbirko kljuÄ?ev "
- #~ "'login' za odklepanje</span>\n"
- #~ "\n"
- #~ "Program želi dostopiti do zbirke kljuÄ?ev 'xxx', vendar je ta zaklenjena."
-
- #~ msgid "Prompt me for each application that accesses this keyring."
- #~ msgstr ""
- #~ "Pokaži obvestilo vsakiÄ?, ko zahteva katerikoli program dostop do zbirke "
- #~ "kljuÄ?ev.-"
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to access the password for '<object "
- #~ "prop='name'/>' in the default keyring."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi dostop do gesla za'<object prop='name'/>'' v "
- #~ "privzeti zbirki kljuÄ?ev."
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to access the password for '<object "
- #~ "prop='name'/>' in %s."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi dostop do gesla za '<object prop='name'/>' v %s."
-
- #~ msgid ""
- #~ "The application '%s' wants to access the password for '<object "
- #~ "prop='name'/>' in the default keyring."
- #~ msgstr ""
- #~ "Program '%s' želi dostop do gesla za '<object prop='name'/>' v privzeti "
- #~ "zbirki kljuÄ?ev."
-
- #~ msgid ""
- #~ "The application '%s' wants to access the password for '<object "
- #~ "prop='name'/>' in %s."
- #~ msgstr "Program '%s' želi dostop do gesla za '<object prop='name'/>' v %s."
-
- #~ msgid ""
- #~ "An unknown application wants to access the password for '<object "
- #~ "prop='name'/>' in the default keyring."
- #~ msgstr ""
- #~ "Neznan program želi dostop do gesla za '<object prop='name'/>' v privzeti "
- #~ "zbirki kljuÄ?ev."
-
- #~ msgid ""
- #~ "An unknown application wants to access the password for '<object "
- #~ "prop='name'/>' in %s."
- #~ msgstr ""
- #~ "Neznan program želi dostop do gesla za '<object prop='name'/>' v %s."
-
- #~ msgid "Allow access"
- #~ msgstr "Dovoli dostop"
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants access to the default keyring, but it is "
- #~ "locked"
- #~ msgstr ""
- #~ "Program '%s' (%s) želi dostop do privzete zbirke kljuÄ?ev, vendar je "
- #~ "zaklenjena"
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants access to the keyring '%s', but it is "
- #~ "locked"
- #~ msgstr ""
- #~ "Program '%s' (%s) želi dostop do zbirke kljuÄ?ev '%s', vendar je zaklenjena"
-
- #~ msgid ""
- #~ "The application '%s' wants access to the default keyring, but it is locked"
- #~ msgstr ""
- #~ "Program '%s' želi dostop do privzete zbirke kljuÄ?ev, vendar je zaklenjena"
-
- #~ msgid ""
- #~ "The application '%s' wants access to the keyring '%s', but it is locked"
- #~ msgstr ""
- #~ "Program '%s' želi dostop do zbirke kljuÄ?ev '%s', vendar je zaklenjena"
-
- #~ msgid ""
- #~ "An unknown application wants access to the default keyring, but it is "
- #~ "locked"
- #~ msgstr ""
- #~ "Neznani program želi dostop do privzete zbirke kljuÄ?ev, vendar je "
- #~ "zaklenjena"
-
- #~ msgid "Enter password for default keyring to unlock"
- #~ msgstr "Vnesite geslo za dostop do privzete zbirke kljuÄ?ev"
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to create a new keyring called '%s'. You "
- #~ "have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi ustvariti novo zbirko kljuÄ?ev z imenom '%s'. "
- #~ "Izbrati morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to create a new default keyring. You have "
- #~ "to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi ustvariti novo privzeto zbirko kljuÄ?ev. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' wants to create a new keyring called '%s'. You have "
- #~ "to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' želi ustvariti novo zbirko kljuÄ?ev z imenom '%s'. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' wants to create a new default keyring. You have to "
- #~ "choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' želi ustvariti novo privzeto zbirko kljuÄ?ev. Izbrati morate "
- #~ "geslo za to zbirko."
-
- #~ msgid ""
- #~ "An unknown application wants to create a new default keyring. You have to "
- #~ "choose the password you want to use for it."
- #~ msgstr ""
- #~ "Neznan program želi ustvariti novo privzeto zbirko kljuÄ?ev. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to change the password for the '%s' "
- #~ "keyring. You have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi spremeniti geslo za zbirko kljuÄ?ev '%s'. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to change the password for the default "
- #~ "keyring. You have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi spremeniti geslo za privzeto zbirko kljuÄ?ev. "
- #~ "Izbrati morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' wants to change the password for the '%s' keyring. "
- #~ "You have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' želi spremeniti geslo za zbirko kljuÄ?ev '%s'. Izbrati morate "
- #~ "geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' wants to change the password for the default "
- #~ "keyring. You have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Program '%s' želi spremeniti geslo za privzeto zbirko kljuÄ?ev. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid ""
- #~ "An unknown application wants to change the password for the default "
- #~ "keyring. You have to choose the password you want to use for it."
- #~ msgstr ""
- #~ "Neznan program želi spremeniti geslo za privzeto zbirko kljuÄ?ev. Izbrati "
- #~ "morate geslo za to zbirko."
-
- #~ msgid "Choose a new password for the default keyring."
- #~ msgstr "Izberite novo geslo za privzeto zbirko kljuÄ?ev."
-
- #~ msgid ""
- #~ "The application '%s' (%s) wants to store a password, but there is no "
- #~ "default keyring. To create one, you need to choose the password you wish "
- #~ "to use for it."
- #~ msgstr ""
- #~ "Program '%s' (%s) želi shraniti geslo, vendar ni privzete zbirke kljuÄ?ev. "
- #~ "Da jo ustvarite, morate izbrati geslo za to zbirko."
-
- #~ msgid ""
- #~ "The application '%s' wants to store a password, but there is no default "
- #~ "keyring. To create one, you need to choose the password you wish to use "
- #~ "for it."
- #~ msgstr ""
- #~ "Program '%s' želi shraniti geslo, vendar ni privzete zbirke kljuÄ?ev. Da "
- #~ "jo ustvarite, morate izbrati geslo za to zbirko."
-
- #~ msgid ""
- #~ "An unknown application wants to store a password, but there is no default "
- #~ "keyring. To create one, you need to choose the password you wish to use "
- #~ "for it."
- #~ msgstr ""
- #~ "Neznan program želi shraniti geslo, vendar ni privzete zbirke kljuÄ?ev. Da "
- #~ "jo ustvarite, morate izbrati geslo za to zbirko."
-
- #~ msgid "Create Default Keyring"
- #~ msgstr "Ustvari privzeto zbirko kljuÄ?ev"
-
- #~ msgid "Choose password for default keyring"
- #~ msgstr "Izberite geslo za privzeto zbirko kljuÄ?ev"
-
- #~ msgid "Create Login Keyring"
- #~ msgstr "Ustvari zbirko kljuÄ?ev prijave"
-
- #~ msgid "Enter your login password"
- #~ msgstr "Vnesite geslo za prijavo"
-
- #~ msgid ""
- #~ "Your login keyring was not automatically created when you logged into "
- #~ "this computer. It will now be created."
- #~ msgstr ""
- #~ "Prijavna zbirka kljuÄ?ev ni bila samodejno ustvarjena ob prijavi na ta "
- #~ "raÄ?unalnik. Sedaj bo ustvarjena."
-
- #~ msgid "Unlock password for %s keyring"
- #~ msgstr "Izberite geslo za zbirko kljuÄ?ev %s"
-
- #~ msgid "Automatically unlock this private key when I log in."
- #~ msgstr "Samodejno odkleni osebni kljuÄ? ob prijavi."
-
- #~ msgid "Automatically unlock this certificate when I log in."
- #~ msgstr "Samodejno odkleni potrdilo ob prijavi."
-
- #~ msgid "Automatically unlock this public key when I log in."
- #~ msgstr "Samodejno odkleni javni kljuÄ? ob prijavi."
-
- #~ msgid "Automatically unlock this when I log in"
- #~ msgstr "Samodejno odkleni prijavi."
-
- #~ msgid ""
- #~ "<b><big>Could not grab your mouse.</big></b>\n"
- #~ "\n"
- #~ "A malicious client may be eavesdropping on your session or you may have "
- #~ "just clicked a menu or some application just decided to get focus.\n"
- #~ "\n"
- #~ "Try again."
- #~ msgstr ""
- #~ "<b><big>Ni mogoÄ?e nadzirati miÅ¡ke.</big></b>\n"
- #~ "\n"
- #~ "MogoÄ?e je, da nepooblaÅ¡Ä?ena oseba prisluÅ¡kuje seji ali pa ste ravnokar "
- #~ "kliknili na meni oziroma je nek program priÅ¡el v žariÅ¡Ä?e delovanja.\n"
- #~ "\n"
- #~ "Poskusite znova."
-
- #~ msgid ""
- #~ "<b><big>Could not grab your keyboard.</big></b>\n"
- #~ "\n"
- #~ "A malicious client may be eavesdropping on your session or you may have "
- #~ "just clicked a menu or some application just decided to get focus.\n"
- #~ "\n"
- #~ "Try again."
- #~ msgstr ""
- #~ "<b><big>Ni mogoÄ?e nadzirati tipkovnice.</big></b>\n"
- #~ "\n"
- #~ "MogoÄ?e je, da nepooblaÅ¡Ä?ena oseba prisluÅ¡kuje seji ali pa ste ravnokar "
- #~ "kliknili na meni oziroma je nek program priÅ¡el v žariÅ¡Ä?e delovanja.\n"
- #~ "\n"
- #~ "Poskusite znova."
-
- #~ msgid "_Deny"
- #~ msgstr "_Zavrni"
-
- #~ msgid "C_reate"
- #~ msgstr "Ustva_ri"
-
- #~ msgid "C_hange"
- #~ msgstr "S_premeni"
-
- #~ msgid "Allow _Once"
- #~ msgstr "Dovoli enkrat"
-
- #~ msgid "_Always Allow"
- #~ msgstr "Vedno dovoli"
-
- #~ msgid "Removable Disk: %s"
- #~ msgstr "Odstranljiva naprava: %s"
-
- #~ msgid "Removable Disk"
- #~ msgstr "Odstranljiva naprava"
-
- #~ msgid "Home"
- #~ msgstr "Domov"
-
- #~ msgid "The disk or drive this file is located on is not present"
- #~ msgstr "Disk ali pogon na katerem je ta datoteka, ni na voljo"
-
- #~ msgid "Couldn't create directory: %s"
- #~ msgstr "Ni mogoÄ?e ustvariti imenika: %s"
-
- #~ msgid "Couldn't delete the file: %s"
- #~ msgstr "Ni mogoÄ?e izbrisati datoteke: %s"
-
- #~ msgid "Access Denied"
- #~ msgstr "Dostop zavrnjen"
-
- #~ msgid "The gnome-keyring-daemon application is not running."
- #~ msgstr "Demn zbirke kljuÄ?ev ne teÄ?e."
-
- #~ msgid "Error communicating with gnome-keyring-daemon"
- #~ msgstr "Napaka med povezovanjem z ozadnjim programom zbirke kljuÄ?ev"
-
- #~ msgid "A keyring with that name already exists"
- #~ msgstr "Zbirka kljuÄ?ev s tem imenom že obstaja"
-
- #~ msgid "Programmer error: The application sent invalid data."
- #~ msgstr "Programska napaka: Program je poslal neveljavne podatke."
-
- #~ msgid "No matching results"
- #~ msgstr "Ni zadetkov iskanja"
-
- #~ msgid "A keyring with that name does not exist."
- #~ msgstr "Zbirka kljuÄ?ev s tem imenom ne obstaja."
-
- #~ msgid "The keyring has already been unlocked."
- #~ msgstr "Zbirka kljuÄ?ev je že odklenjena."
-
- #~ msgid ""
- #~ "A list of paths to PKCS#11 modules to load. No modules are currently "
- #~ "listed by default, as this is still an experimental feature. This is used "
- #~ "by seahorse and other PKCS#11 aware applications."
- #~ msgstr ""
- #~ "Seznam poti do PKCS#11 modulov. Trenutno v seznamu ni modulov, saj je to "
- #~ "še vedno nova možnost programa. Seznam uporabljajo programi seahorse in "
- #~ "pa drugi programi, ki upravljajo s PKCS#11 potrdili."
-
- #~ msgid "PKCS#11 Modules"
- #~ msgstr "PKCS#11 Moduli"
-
- #~ msgid "Import private key"
- #~ msgstr "Uvozi osebni kljuÄ?"
-
- #~ msgid "Import public key"
- #~ msgstr "Uvozi javni kljuÄ?"
-
- #~ msgid "The system wants to import the public key '%s', but it is locked"
- #~ msgstr "Sistem želi uvoziti javni kljuÄ? '%s', vendar je ta zaklenjen"
-
- #~ msgid "Create Storage for Key Information"
- #~ msgstr "Ustvari shrnjevalnik za podrobnosti kljuÄ?a."
-
- #~ msgid "Choose password to protect storage"
- #~ msgstr "Izberite geslo za varovanje zbirke"
-
- #~ msgid ""
- #~ "The system wants to store information about your keys and certificates. "
- #~ "In order to protect this information, choose a password with which it "
- #~ "will be locked."
- #~ msgstr ""
- #~ "Program poskuÅ¡a shraniti podrobnosti kljuÄ?a in potrdil. Za varovanje "
- #~ "podrobnosti, izberite geslo s katerim boste podatke zaklenili."
-
- #~ msgid "Unlock Storage for Key Information"
- #~ msgstr "Odkleni shranjeno za izpis podrobnosti kljuÄ?a"
-
- #~ msgid "Enter password to unlock storage"
- #~ msgstr "Vnesite geslo za odklepanje potrdila"
-
- #~ msgid ""
- #~ "The system wants to access information about your keys and certificates, "
- #~ "but it is locked."
- #~ msgstr ""
- #~ "Sistem zahteva dostop do podrobnosti vaÅ¡ega kljuÄ?a in potrdil, vendar so "
- #~ "ti podatki zaklenjeni."
-
- #~ msgid "Trust Association"
- #~ msgstr "DoloÄ?ila zaupnosti"
-
- #~ msgid "Cannot delete '%s' because it is tied to other objects."
- #~ msgstr "Ni mogoÄ?e izbrisati '%s', saj je vezan na druge predmete."
-
- #~ msgid "Lock private key"
- #~ msgstr "Zakleni osebni kljuÄ?"
-
- #~ msgid "Lock"
- #~ msgstr "Zakleni"
-
- #~ msgid "Enter password to protect the private key"
- #~ msgstr "Vnesite geslo za zaÅ¡Ä?ito osebnega kljuÄ?a"
-
- #~ msgid ""
- #~ "The system wants to store the private key '%s' on your disk. Please enter "
- #~ "a password to lock it with."
- #~ msgstr ""
- #~ "Sistem želi shraniti osebni kljuÄ? '%s' na disk. Vnesite geslo za "
- #~ "zaklepanje."
-
- #~ msgid ""
- #~ "The system wants to store '%s' on your disk. Please enter a password to "
- #~ "lock it with."
- #~ msgstr "Program poskuša shraniti '%s' na disk. Vnesite geslo za zaklepanje."
-
- #~ msgid "Couldn't encode secure shell public key."
- #~ msgstr "Ni mogoÄ?e kodirati varnega lupinskega osebnega kljuÄ?a."
-
- #~ msgid "Couldn't read secure shell private key: %s"
- #~ msgstr "Ni mogoÄ?e prebrati varnega lupinskega osebnega kljuÄ?a: %s"
-
- #~ msgid "Invalid secure shell private key at: %s"
- #~ msgstr "Neveljavni varni lupinski osebni kljuÄ? na: %s"
-
- #~ msgid "Couldn't encrypt the SSH key to store it."
- #~ msgstr "Ni mogoÄ?e Å¡ifrirati SSH kljuÄ?a in ga shraniti."
-
- #~ msgid "Couldn't encode the SSH key to store it."
- #~ msgstr "Ni mogoÄ?e kodirati SSH kljuÄ?a in ga shraniti."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]