[gnome-keyring] gcr: Import keys first when importing via PKCS#11
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gcr: Import keys first when importing via PKCS#11
- Date: Wed, 5 Oct 2011 08:20:15 +0000 (UTC)
commit e97c283d65e2ba0bcd6676839b361eedb14c52dc
Author: Stef Walter <stefw collabora co uk>
Date: Tue Oct 4 16:42:48 2011 +0200
gcr: Import keys first when importing via PKCS#11
* This is what some smartcards seem to require, an easy enough fix
so just work around this problem.
gcr/gcr-pkcs11-importer.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/gcr/gcr-pkcs11-importer.c b/gcr/gcr-pkcs11-importer.c
index b22b4d7..7c909bd 100644
--- a/gcr/gcr-pkcs11-importer.c
+++ b/gcr/gcr-pkcs11-importer.c
@@ -495,6 +495,27 @@ _gcr_pkcs11_importer_class_init (GcrPkcs11ImporterClass *klass)
_gcr_initialize_library ();
}
+static gint
+on_sort_by_private_key_first (gconstpointer a,
+ gconstpointer b,
+ gpointer user_data)
+{
+ gulong class_a, class_b;
+
+ if (!gck_attributes_find_ulong ((GckAttributes *)a, CKA_CLASS, &class_a))
+ class_a = 0;
+ if (!gck_attributes_find_ulong ((GckAttributes *)b, CKA_CLASS, &class_b))
+ class_b = 0;
+
+ if (class_a == class_b)
+ return 0;
+ if (class_a == CKO_PRIVATE_KEY)
+ return -1;
+ if (class_b == CKO_PRIVATE_KEY)
+ return 1;
+ return 0;
+}
+
static GList *
list_all_slots (void)
{
@@ -681,5 +702,6 @@ _gcr_pkcs11_importer_queue (GcrPkcs11Importer *self,
g_return_if_fail (GCR_IS_PKCS11_IMPORTER (self));
g_return_if_fail (attrs != NULL);
- g_queue_push_tail (&self->queue, gck_attributes_ref (attrs));
+ g_queue_insert_sorted (&self->queue, gck_attributes_ref (attrs),
+ on_sort_by_private_key_first, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]