gnome-keyring r1063 - in trunk: . common/tests pk pk/tests pkix pkix/tests
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1063 - in trunk: . common/tests pk pk/tests pkix pkix/tests
- Date: Fri, 15 Feb 2008 00:11:58 +0000 (GMT)
Author: nnielsen
Date: Fri Feb 15 00:11:58 2008
New Revision: 1063
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1063&view=rev
Log:
* common/tests/unit-test-unique.c:
* pk/gkr-pk-cert.c:
* pk/gkr-pk-index.c:
* pk/gkr-pk-index.h:
* pk/gkr-pk-netscape-trust.c:
* pk/gkr-pk-object.c:
* pk/gkr-pk-object.h:
* pk/gkr-pk-object-manager.c:
* pk/gkr-pk-object-manager.h:
* pk/gkr-pk-object-storage.c:
* pk/gkr-pk-privkey.c:
* pk/gkr-pk-privkey.h:
* pk/tests/unit-test-pk-index.c: Use the word 'digest' instead of 'unique'
to make it clearer what is going on.
* pkix/gkr-pkix-parser.c:
* pkix/gkr-pkix-parser.h:
* pkix/tests/unit-test-pkix-parser.c: Limit the PKCS#12 parsing to only
one element per bag, since that is all we can realistically prompt for
passwords for.
Modified:
trunk/ChangeLog
trunk/common/tests/unit-test-unique.c
trunk/configure.in
trunk/pk/gkr-pk-cert.c
trunk/pk/gkr-pk-index.c
trunk/pk/gkr-pk-index.h
trunk/pk/gkr-pk-netscape-trust.c
trunk/pk/gkr-pk-object-manager.c
trunk/pk/gkr-pk-object-manager.h
trunk/pk/gkr-pk-object-storage.c
trunk/pk/gkr-pk-object.c
trunk/pk/gkr-pk-object.h
trunk/pk/gkr-pk-privkey.c
trunk/pk/gkr-pk-pubkey.c
trunk/pk/tests/unit-test-pk-index.c
trunk/pkix/gkr-pkix-parser.c
trunk/pkix/gkr-pkix-parser.h
trunk/pkix/tests/unit-test-pkix-parser.c
Modified: trunk/common/tests/unit-test-unique.c
==============================================================================
--- trunk/common/tests/unit-test-unique.c (original)
+++ trunk/common/tests/unit-test-unique.c Fri Feb 15 00:11:58 2008
@@ -47,7 +47,7 @@
*
* Tests be run in the order specified here.
*/
-void unit_test_unique_basics (CuTest* cu)
+void unit_test_id_basics (CuTest* cu)
{
gchar test[] = "my big test";
gkrid id, id2;
@@ -60,7 +60,7 @@
data = gkr_id_get_raw (id, &n_data);
CuAssert (cu, "raw returned null", data != NULL);
CuAssert (cu, "length has changed", n_data == strlen (test));
- CuAssert (cu, "unique data is wrong", memcmp (data, test, n_data) == 0);
+ CuAssert (cu, "id data is wrong", memcmp (data, test, n_data) == 0);
id2 = gkr_id_new ((guchar*)test, strlen(test));
CuAssert (cu, "didn't create id", id != NULL);
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri Feb 15 00:11:58 2008
@@ -32,15 +32,15 @@
DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.8.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
-PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.6.0)
+PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.8.0)
AC_SUBST(GTHREAD_CFLAGS)
AC_SUBST(GTHREAD_LIBS)
-PKG_CHECK_MODULES(GOBJECT, glib-2.0 >= 2.6.0 gobject-2.0 >= 2.6.0)
+PKG_CHECK_MODULES(GOBJECT, glib-2.0 >= 2.8.0 gobject-2.0 >= 2.8.0)
AC_SUBST(GOBJECT_CFLAGS)
AC_SUBST(GOBJECT_LIBS)
Modified: trunk/pk/gkr-pk-cert.c
==============================================================================
--- trunk/pk/gkr-pk-cert.c (original)
+++ trunk/pk/gkr-pk-cert.c Fri Feb 15 00:11:58 2008
@@ -660,7 +660,7 @@
}
cert = g_object_new (GKR_TYPE_PK_CERT, "location", location,
- "unique", id, "manager", manager,
+ "digest", id, "manager", manager,
"asn1-tree", asn1, NULL);
gkr_id_free (id);
Modified: trunk/pk/gkr-pk-index.c
==============================================================================
--- trunk/pk/gkr-pk-index.c (original)
+++ trunk/pk/gkr-pk-index.c Fri Feb 15 00:11:58 2008
@@ -230,21 +230,21 @@
}
static gchar*
-unique_to_group (gkrconstid uni)
+digest_to_group (gkrconstid digest)
{
- const guchar *unidata;
- gsize n_group, n_unidata;
+ const guchar *digdata;
+ gsize n_group, n_digdata;
gboolean r;
gchar *group;
- g_return_val_if_fail (uni, NULL);
+ g_return_val_if_fail (digest, NULL);
- unidata = gkr_id_get_raw (uni, &n_unidata);
- g_assert (unidata);
- n_group = (n_unidata * 2) + 1;
+ digdata = gkr_id_get_raw (digest, &n_digdata);
+ g_assert (digdata);
+ n_group = (n_digdata * 2) + 1;
group = g_malloc0 (n_group);
- r = gkr_crypto_hex_encode (unidata, n_unidata, group, &n_group);
+ r = gkr_crypto_hex_encode (digdata, n_digdata, group, &n_group);
g_assert (r == TRUE);
return group;
@@ -453,7 +453,7 @@
}
static void
-set_keyfile_value (GKeyFile *key_file, gkrconstid uni,
+set_keyfile_value (GKeyFile *key_file, gkrconstid digest,
const gchar *field, WriteValueFunc func,
gpointer data, gboolean *updated)
{
@@ -461,12 +461,12 @@
gchar *group;
g_assert (key_file);
- g_assert (uni);
+ g_assert (digest);
g_assert (func);
g_assert (updated);
/* TODO: Cache this somehow? */
- group = unique_to_group (uni);
+ group = digest_to_group (digest);
g_return_if_fail (group);
*updated = (func) (key_file, group, field, &err, data);
@@ -665,7 +665,7 @@
}
static gboolean
-read_pk_index_value (GkrPkIndex *index, GQuark loc, gkrconstid uni,
+read_pk_index_value (GkrPkIndex *index, GQuark loc, gkrconstid digest,
const gchar *field, GkrPkObject *object,
ReadValueFunc func, gpointer data)
{
@@ -676,7 +676,7 @@
gchar *group;
gint ret = 0;
- g_return_val_if_fail (uni, FALSE);
+ g_return_val_if_fail (digest, FALSE);
if (loc) {
path = index_path_for_location (index, loc);
@@ -691,7 +691,7 @@
/* Try the actual item first */
if (key_file) {
- group = unique_to_group (uni);
+ group = digest_to_group (digest);
g_return_val_if_fail (group, FALSE);
ret = get_keyfile_value (key_file, group, field, func, data);
@@ -720,7 +720,7 @@
}
static gboolean
-update_pk_index_value (GkrPkIndex *index, GQuark loc, gkrconstid uni,
+update_pk_index_value (GkrPkIndex *index, GQuark loc, gkrconstid digest,
const gchar *field, GkrPkObject *object,
WriteValueFunc func, gpointer data)
{
@@ -736,7 +736,7 @@
int tries = 0;
int fd = -1;
- g_return_val_if_fail (uni, FALSE);
+ g_return_val_if_fail (digest, FALSE);
if (loc) {
path = index_path_for_location (index, loc);
@@ -782,7 +782,7 @@
if (!key_file)
goto done;
- set_keyfile_value (key_file, uni, field, func, data, &updated);
+ set_keyfile_value (key_file, digest, field, func, data, &updated);
if (updated && loc) {
/* Serialize the key file into memory */
@@ -932,7 +932,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), ret);
g_return_val_if_fail (field != NULL, ret);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (ReadValueFunc)read_boolean_value, &ret))
ret = defvalue;
@@ -947,7 +947,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), ret);
g_return_val_if_fail (field != NULL, ret);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (ReadValueFunc)read_int_value, &ret))
ret = defvalue;
@@ -962,7 +962,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), NULL);
g_return_val_if_fail (field != NULL, NULL);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (ReadValueFunc)read_string_value, &ret))
ret = NULL;
@@ -970,15 +970,15 @@
}
gchar*
-gkr_pk_index_get_string_full (GQuark location, gkrconstid uni,
+gkr_pk_index_get_string_full (GQuark location, gkrconstid digest,
const gchar *field)
{
gchar *ret = NULL;
- g_return_val_if_fail (uni, NULL);
+ g_return_val_if_fail (digest, NULL);
g_return_val_if_fail (field != NULL, NULL);
- if (!read_pk_index_value (get_index_singleton (), location, uni, field,
+ if (!read_pk_index_value (get_index_singleton (), location, digest, field,
NULL, (ReadValueFunc)read_string_value, &ret))
ret = NULL;
@@ -1021,7 +1021,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), NULL);
g_return_val_if_fail (field != NULL, NULL);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (ReadValueFunc)read_quarks_value, &ret))
ret = NULL;
@@ -1036,7 +1036,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (ReadValueFunc)read_exists_value, &ret))
ret = FALSE;
@@ -1050,7 +1050,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
- if (!read_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ if (!read_pk_index_value (get_index_singleton (), obj->location, obj->digest,
NULL, obj, (ReadValueFunc)read_exists_any_value, &ret))
ret = FALSE;
@@ -1058,13 +1058,13 @@
}
gboolean
-gkr_pk_index_have_full (GQuark location, gkrconstid uni)
+gkr_pk_index_have_full (GQuark location, gkrconstid digest)
{
gboolean ret;
- g_return_val_if_fail (uni, FALSE);
+ g_return_val_if_fail (digest, FALSE);
- if (!read_pk_index_value (get_index_singleton (), location, uni, NULL,
+ if (!read_pk_index_value (get_index_singleton (), location, digest, NULL,
NULL, (ReadValueFunc)read_exists_any_value, &ret))
ret = FALSE;
@@ -1077,7 +1077,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (WriteValueFunc)write_boolean_value, &val);
}
@@ -1087,7 +1087,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (WriteValueFunc)write_int_value, &val);
}
@@ -1098,19 +1098,19 @@
g_return_val_if_fail (field != NULL, FALSE);
g_return_val_if_fail (val, FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (WriteValueFunc)write_string_value, &val);
}
gboolean
-gkr_pk_index_set_string_full (GQuark location, gkrconstid uni, const gchar *field,
+gkr_pk_index_set_string_full (GQuark location, gkrconstid digest, const gchar *field,
const gchar *val)
{
- g_return_val_if_fail (uni, FALSE);
+ g_return_val_if_fail (digest, FALSE);
g_return_val_if_fail (field != NULL, FALSE);
g_return_val_if_fail (val, FALSE);
- return update_pk_index_value (get_index_singleton (), location, uni, field,
+ return update_pk_index_value (get_index_singleton (), location, digest, field,
NULL, (WriteValueFunc)write_string_value, &val);
}
@@ -1144,7 +1144,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (WriteValueFunc)write_quarks_value, &quarks);
}
@@ -1154,7 +1154,7 @@
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
g_return_val_if_fail (field != NULL, FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
field, obj, (WriteValueFunc)write_delete, NULL);
}
@@ -1164,7 +1164,7 @@
{
g_return_val_if_fail (GKR_IS_PK_OBJECT (obj), FALSE);
- return update_pk_index_value (get_index_singleton (), obj->location, obj->unique,
+ return update_pk_index_value (get_index_singleton (), obj->location, obj->digest,
NULL, obj, (WriteValueFunc)write_clear, NULL);
}
Modified: trunk/pk/gkr-pk-index.h
==============================================================================
--- trunk/pk/gkr-pk-index.h (original)
+++ trunk/pk/gkr-pk-index.h Fri Feb 15 00:11:58 2008
@@ -37,7 +37,7 @@
gchar* gkr_pk_index_get_string (GkrPkObject *object, const gchar *field);
-gchar* gkr_pk_index_get_string_full (GQuark location, gkrconstid uni, const gchar *field);
+gchar* gkr_pk_index_get_string_full (GQuark location, gkrconstid digest, const gchar *field);
guchar* gkr_pk_index_get_binary (GkrPkObject *object, const gchar *field,
gsize *n_data);
@@ -53,7 +53,7 @@
gboolean gkr_pk_index_set_string (GkrPkObject *object, const gchar *field,
const gchar *val);
-gboolean gkr_pk_index_set_string_full (GQuark location, gkrconstid uni,
+gboolean gkr_pk_index_set_string_full (GQuark location, gkrconstid digest,
const gchar *field, const gchar *val);
gboolean gkr_pk_index_set_binary (GkrPkObject *object, const gchar *field,
@@ -68,7 +68,7 @@
gboolean gkr_pk_index_have (GkrPkObject *object);
-gboolean gkr_pk_index_have_full (GQuark location, gkrconstid uni);
+gboolean gkr_pk_index_have_full (GQuark location, gkrconstid digest);
gboolean gkr_pk_index_clear (GkrPkObject *object);
Modified: trunk/pk/gkr-pk-netscape-trust.c
==============================================================================
--- trunk/pk/gkr-pk-netscape-trust.c (original)
+++ trunk/pk/gkr-pk-netscape-trust.c Fri Feb 15 00:11:58 2008
@@ -374,7 +374,7 @@
gkr_pk_netscape_trust_new (GkrPkObjectManager *mgr, GkrPkCert *cert)
{
GkrPkNetscapeTrust *trust;
- gkrid unique = NULL;
+ gkrid digest = NULL;
GkrPkObject *obj;
const guchar *raw;
gsize n_raw;
@@ -382,16 +382,16 @@
g_return_val_if_fail (GKR_IS_PK_CERT (cert), NULL);
obj = GKR_PK_OBJECT (cert);
- /* Make a new unique based on the certificate */
- if (obj->unique) {
- raw = gkr_id_get_raw (obj->unique, &n_raw);
+ /* Make a new digest based on the certificate */
+ if (obj->digest) {
+ raw = gkr_id_get_raw (obj->digest, &n_raw);
g_return_val_if_fail (raw, NULL);
- unique = gkr_id_new_digestv ((guchar*)"trust", 5, raw, n_raw, NULL);
+ digest = gkr_id_new_digestv ((guchar*)"trust", 5, raw, n_raw, NULL);
}
trust = g_object_new (GKR_TYPE_PK_NETSCAPE_TRUST, "manager", mgr,
- "unique", unique, "certificate", cert, NULL);
+ "digest", digest, "certificate", cert, NULL);
- gkr_id_free (unique);
+ gkr_id_free (digest);
return trust;
}
Modified: trunk/pk/gkr-pk-object-manager.c
==============================================================================
--- trunk/pk/gkr-pk-object-manager.c (original)
+++ trunk/pk/gkr-pk-object-manager.c Fri Feb 15 00:11:58 2008
@@ -55,7 +55,7 @@
gboolean is_token;
GHashTable *object_by_handle;
- GHashTable *object_by_unique;
+ GHashTable *object_by_digest;
};
#define GKR_PK_OBJECT_MANAGER_GET_PRIVATE(o) \
@@ -91,7 +91,7 @@
gpointer k;
g_assert (GKR_IS_PK_OBJECT (object));
- g_assert (object->unique);
+ g_assert (object->digest);
g_assert (object->manager == NULL);
if (!object->handle) {
@@ -108,11 +108,11 @@
g_hash_table_replace (pv->object_by_handle, k, object);
/*
- * Mapping of objects by unique key. There may be multiple objects
- * with a given unique key.
+ * Mapping of objects by digest key. There may be multiple objects
+ * with a given digest key.
*/
- g_assert (object->unique);
- g_hash_table_replace (pv->object_by_unique, object->unique, object);
+ g_assert (object->digest);
+ g_hash_table_replace (pv->object_by_digest, object->digest, object);
/* Note objects is being managed */
objmgr->objects = g_list_prepend (objmgr->objects, object);
@@ -134,11 +134,11 @@
g_hash_table_remove (pv->object_by_handle, k);
/*
- * Mapping of objects by unique key. There may be multiple objects
- * with a given unique, so just remove if it matches this one.
+ * Mapping of objects by digest key. There may be multiple objects
+ * with a given digest, so just remove if it matches this one.
*/
- if (g_hash_table_lookup (pv->object_by_unique, object->unique) == object)
- g_hash_table_remove (pv->object_by_unique, object->unique);
+ if (g_hash_table_lookup (pv->object_by_digest, object->digest) == object)
+ g_hash_table_remove (pv->object_by_digest, object->digest);
/* Release object management */
objmgr->objects = g_list_remove (objmgr->objects, object);
@@ -155,7 +155,7 @@
GkrPkObjectManagerPrivate *pv = GKR_PK_OBJECT_MANAGER_GET_PRIVATE (objmgr);
pv->object_by_handle = g_hash_table_new (g_direct_hash, g_direct_equal);
- pv->object_by_unique = g_hash_table_new (gkr_id_hash, gkr_id_equals);
+ pv->object_by_digest = g_hash_table_new (gkr_id_hash, gkr_id_equals);
}
static void
@@ -174,7 +174,7 @@
g_return_if_fail (objmgr->objects == NULL);
g_return_if_fail (g_hash_table_size (pv->object_by_handle) == 0);
- g_return_if_fail (g_hash_table_size (pv->object_by_unique) == 0);
+ g_return_if_fail (g_hash_table_size (pv->object_by_digest) == 0);
if (pv->for_pid) {
g_assert (object_managers_by_pid);
@@ -203,7 +203,7 @@
GkrPkObjectManagerPrivate *pv = GKR_PK_OBJECT_MANAGER_GET_PRIVATE (obj);
g_hash_table_destroy (pv->object_by_handle);
- g_hash_table_destroy (pv->object_by_unique);
+ g_hash_table_destroy (pv->object_by_digest);
g_assert (!man->objects);
g_assert (!pv->for_pid);
@@ -277,7 +277,7 @@
pv = GKR_PK_OBJECT_MANAGER_GET_PRIVATE (objmgr);
g_return_if_fail (object->manager == NULL);
- g_return_if_fail (object->unique);
+ g_return_if_fail (object->digest);
add_object (objmgr, object);
}
@@ -292,7 +292,7 @@
pv = GKR_PK_OBJECT_MANAGER_GET_PRIVATE (objmgr);
g_return_if_fail (object->manager == objmgr);
- g_return_if_fail (object->unique);
+ g_return_if_fail (object->digest);
remove_object (objmgr, object);
}
@@ -448,15 +448,15 @@
}
GkrPkObject*
-gkr_pk_object_manager_find_by_unique (GkrPkObjectManager *objmgr, gkrconstid unique)
+gkr_pk_object_manager_find_by_digest (GkrPkObjectManager *objmgr, gkrconstid digest)
{
GkrPkObjectManagerPrivate *pv;
GkrPkObject *object;
- g_return_val_if_fail (unique, NULL);
+ g_return_val_if_fail (digest, NULL);
g_return_val_if_fail (GKR_IS_PK_OBJECT_MANAGER (objmgr), NULL);
pv = GKR_PK_OBJECT_MANAGER_GET_PRIVATE (objmgr);
- object = GKR_PK_OBJECT (g_hash_table_lookup (pv->object_by_unique, unique));
+ object = GKR_PK_OBJECT (g_hash_table_lookup (pv->object_by_digest, digest));
return object;
}
Modified: trunk/pk/gkr-pk-object-manager.h
==============================================================================
--- trunk/pk/gkr-pk-object-manager.h (original)
+++ trunk/pk/gkr-pk-object-manager.h Fri Feb 15 00:11:58 2008
@@ -96,8 +96,8 @@
GkrPkObject* gkr_pk_object_manager_find_by_id (GkrPkObjectManager *objmgr,
GType gtype, gkrconstid id);
-GkrPkObject* gkr_pk_object_manager_find_by_unique (GkrPkObjectManager *objmgr,
- gkrconstid unique);
+GkrPkObject* gkr_pk_object_manager_find_by_digest (GkrPkObjectManager *objmgr,
+ gkrconstid digest);
G_END_DECLS
Modified: trunk/pk/gkr-pk-object-storage.c
==============================================================================
--- trunk/pk/gkr-pk-object-storage.c (original)
+++ trunk/pk/gkr-pk-object-storage.c Fri Feb 15 00:11:58 2008
@@ -71,7 +71,7 @@
GkrPkObjectStorage *storage; /* The object storage to parse into */
GQuark location; /* The location being parsed */
GHashTable *checks; /* The set of objects that existed before parse */
- GHashTable *types_by_unique; /* The parse types for every object prompted for or seen */
+ GHashTable *types_by_digest; /* The parse types for every object prompted for or seen */
} ParseContext;
#define NO_VALUE GUINT_TO_POINTER (TRUE)
@@ -174,7 +174,7 @@
}
static gchar*
-parser_ask_password (GkrPkixParser *parser, GQuark loc, gkrid unique,
+parser_ask_password (GkrPkixParser *parser, GQuark loc, gkrid digest,
GQuark type, const gchar *label, guint failures,
ParseContext *ctx)
{
@@ -212,7 +212,7 @@
* If we've parsed this before, then we can lookup in our index as to what
* exactly this is we're talking about here.
*/
- stype = gkr_pk_index_get_string_full (loc, unique, "parsed-type");
+ stype = gkr_pk_index_get_string_full (loc, digest, "parsed-type");
if (stype) {
if (!type && stype[0])
type = g_quark_from_string (stype);
@@ -224,7 +224,7 @@
* If we've indexed this before, and the user isn't specifically requesting it
* to be loaded then we don't need to prompt for the password
*/
- if (have_indexed && !g_hash_table_lookup (pv->specific_load_requests, unique))
+ if (have_indexed && !g_hash_table_lookup (pv->specific_load_requests, digest))
return NULL;
/* TODO: Load a better label if we have one */
@@ -262,7 +262,7 @@
}
/* Track that we prompted for this */
- g_hash_table_insert (ctx->types_by_unique, gkr_id_dup (unique),
+ g_hash_table_insert (ctx->types_by_digest, gkr_id_dup (digest),
GUINT_TO_POINTER (type));
}
@@ -361,7 +361,7 @@
static GkrPkObject*
prepare_object (GkrPkObjectStorage *storage, GQuark location,
- gkrconstid unique, GQuark type)
+ gkrconstid digest, GQuark type)
{
GkrPkObjectStoragePrivate *pv = GKR_PK_OBJECT_STORAGE_GET_PRIVATE (storage);
GkrPkObjectManager *manager;
@@ -369,7 +369,7 @@
GType gtype;
manager = gkr_pk_object_manager_for_token ();
- object = gkr_pk_object_manager_find_by_unique (manager, unique);
+ object = gkr_pk_object_manager_find_by_digest (manager, digest);
/* The object already exists just reference it */
if (object) {
@@ -388,11 +388,9 @@
g_return_val_if_reached (NULL);
object = g_object_new (gtype, "manager", manager, "location", location,
- "unique", unique, NULL);
+ "digest", digest, NULL);
add_object (storage, object);
-g_printerr ("parsed %s at %s\n", G_OBJECT_TYPE_NAME (object), g_quark_to_string (location));
-
/* Object was reffed */
g_object_unref (object);
@@ -400,7 +398,7 @@
}
static void
-parser_parsed_partial (GkrPkixParser *parser, GQuark location, gkrid unique,
+parser_parsed_partial (GkrPkixParser *parser, GQuark location, gkrid digest,
GQuark type, ParseContext *ctx)
{
GkrPkObjectStoragePrivate *pv = GKR_PK_OBJECT_STORAGE_GET_PRIVATE (ctx->storage);
@@ -409,30 +407,30 @@
/* If we don't know the type then look it up */
if (!type) {
- stype = gkr_pk_index_get_string_full (location, unique, "parsed-type");
+ stype = gkr_pk_index_get_string_full (location, digest, "parsed-type");
if (stype && stype[0])
type = g_quark_from_string (stype);
g_free (stype);
}
if (type) {
- object = prepare_object (ctx->storage, location, unique, type);
+ object = prepare_object (ctx->storage, location, digest, type);
g_return_if_fail (object != NULL);
/* Make note of having seen this object in load requests */
- g_hash_table_remove (pv->specific_load_requests, unique);
+ g_hash_table_remove (pv->specific_load_requests, digest);
/* Make note of having seen this one */
g_hash_table_remove (ctx->checks, object);
}
- /* Track the type for this unique */
- g_hash_table_insert (ctx->types_by_unique, gkr_id_dup (unique),
- GUINT_TO_POINTER (type));
+ /* Track the type of this digest */
+ g_hash_table_insert (ctx->types_by_digest, gkr_id_dup (digest),
+ GUINT_TO_POINTER (type));
}
static void
-parser_parsed_sexp (GkrPkixParser *parser, GQuark location, gkrid unique,
+parser_parsed_sexp (GkrPkixParser *parser, GQuark location, gkrid digest,
GQuark type, gcry_sexp_t sexp, ParseContext *ctx)
{
GkrPkObjectStoragePrivate *pv = GKR_PK_OBJECT_STORAGE_GET_PRIVATE (ctx->storage);
@@ -440,25 +438,25 @@
g_return_if_fail (type != 0);
- object = prepare_object (ctx->storage, location, unique, type);
+ object = prepare_object (ctx->storage, location, digest, type);
g_return_if_fail (object != NULL);
/* Make note of having seen this object in load requests */
- g_hash_table_remove (pv->specific_load_requests, unique);
+ g_hash_table_remove (pv->specific_load_requests, digest);
/* Make note of having seen this one */
g_hash_table_remove (ctx->checks, object);
- /* Track the type for this unique */
- g_hash_table_insert (ctx->types_by_unique, gkr_id_dup (unique),
- GUINT_TO_POINTER (type));
+ /* Track the type of this digest */
+ g_hash_table_insert (ctx->types_by_digest, gkr_id_dup (digest),
+ GUINT_TO_POINTER (type));
/* Setup the sexp, probably a key on this object */
g_object_set (object, "gcrypt-sexp", sexp, NULL);
}
static void
-parser_parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+parser_parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, ASN1_TYPE asn1, ParseContext *ctx)
{
GkrPkObjectStoragePrivate *pv = GKR_PK_OBJECT_STORAGE_GET_PRIVATE (ctx->storage);
@@ -466,18 +464,18 @@
g_return_if_fail (type != 0);
- object = prepare_object (ctx->storage, location, unique, type);
+ object = prepare_object (ctx->storage, location, digest, type);
g_return_if_fail (object != NULL);
/* Make note of having seen this object in load requests */
- g_hash_table_remove (pv->specific_load_requests, unique);
+ g_hash_table_remove (pv->specific_load_requests, digest);
/* Make note of having seen this one */
g_hash_table_remove (ctx->checks, object);
- /* Track the type for this unique */
- g_hash_table_insert (ctx->types_by_unique, gkr_id_dup (unique),
- GUINT_TO_POINTER (type));
+ /* Track the type for this digest */
+ g_hash_table_insert (ctx->types_by_digest, gkr_id_dup (digest),
+ GUINT_TO_POINTER (type));
/* Setup the asn1, probably a certificate on this object */
g_object_set (object, "asn1-tree", asn1, NULL);
@@ -492,7 +490,7 @@
}
static void
-index_each_unique (gkrid unique, gpointer value, gpointer data)
+index_each_digest (gkrid digest, gpointer value, gpointer data)
{
GQuark location = GPOINTER_TO_UINT (data);
GQuark type = GPOINTER_TO_UINT (value);
@@ -501,7 +499,7 @@
return;
/* Stash away the parsed type, in case we need it when prompting for a password */
- gkr_pk_index_set_string_full (location, unique, "parsed-type",
+ gkr_pk_index_set_string_full (location, digest, "parsed-type",
g_quark_to_string (type));
}
@@ -523,7 +521,7 @@
ctx.storage = storage;
ctx.checks = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_object_unref, NULL);
- ctx.types_by_unique = g_hash_table_new_full (gkr_id_hash, gkr_id_equals,
+ ctx.types_by_digest = g_hash_table_new_full (gkr_id_hash, gkr_id_equals,
gkr_id_free, NULL);
/* Create a table of what is at the location */
@@ -553,8 +551,8 @@
* Note any in the index that we prompted for but didn't actually
* get an object out about.
*/
- g_hash_table_foreach (ctx.types_by_unique, (GHFunc)index_each_unique, k);
- g_hash_table_destroy (ctx.types_by_unique);
+ g_hash_table_foreach (ctx.types_by_digest, (GHFunc)index_each_digest, k);
+ g_hash_table_destroy (ctx.types_by_digest);
return ret;
}
@@ -743,14 +741,14 @@
/* Make note of the specific load request */
- g_hash_table_replace (pv->specific_load_requests, gkr_id_dup (obj->unique), NO_VALUE);
+ g_hash_table_replace (pv->specific_load_requests, gkr_id_dup (obj->digest), NO_VALUE);
ret = load_objects_at_location (storage, obj->location, err);
if (!ret)
goto done;
/* See if it was seen */
- if (g_hash_table_lookup (pv->specific_load_requests, obj->unique)) {
+ if (g_hash_table_lookup (pv->specific_load_requests, obj->digest)) {
g_set_error (err, GKR_PKIX_PARSE_ERROR, 0, "the object was not found at: %s",
g_quark_to_string (obj->location));
goto done;
@@ -759,7 +757,7 @@
ret = TRUE;
done:
- g_hash_table_remove (pv->specific_load_requests, obj->unique);
+ g_hash_table_remove (pv->specific_load_requests, obj->digest);
g_object_unref (obj);
return ret;
}
Modified: trunk/pk/gkr-pk-object.c
==============================================================================
--- trunk/pk/gkr-pk-object.c (original)
+++ trunk/pk/gkr-pk-object.c Fri Feb 15 00:11:58 2008
@@ -43,7 +43,7 @@
PROP_0,
PROP_MANAGER,
PROP_LOCATION,
- PROP_UNIQUE,
+ PROP_DIGEST,
PROP_ORIG_LABEL,
PROP_LABEL
};
@@ -238,8 +238,8 @@
case PROP_LOCATION:
g_value_set_uint (value, xobj->location);
break;
- case PROP_UNIQUE:
- g_value_set_boxed (value, xobj->unique);
+ case PROP_DIGEST:
+ g_value_set_boxed (value, xobj->digest);
break;
case PROP_ORIG_LABEL:
g_value_set_string (value, pv->orig_label);
@@ -268,9 +268,9 @@
case PROP_LOCATION:
xobj->location = g_value_get_uint (value);
break;
- case PROP_UNIQUE:
- gkr_id_free (xobj->unique);
- xobj->unique = gkr_id_dup (g_value_get_boxed (value));
+ case PROP_DIGEST:
+ gkr_id_free (xobj->digest);
+ xobj->digest = gkr_id_dup (g_value_get_boxed (value));
break;
case PROP_ORIG_LABEL:
g_free (pv->orig_label);
@@ -327,8 +327,8 @@
g_param_spec_uint ("location", "Location", "Location of Data",
0, G_MAXUINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_UNIQUE,
- g_param_spec_boxed ("unique", "Unique", "Unique Identifier for Data",
+ g_object_class_install_property (gobject_class, PROP_DIGEST,
+ g_param_spec_boxed ("digest", "Digest", "Digest Identifier for Data",
GKR_ID_BOXED_TYPE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, PROP_ORIG_LABEL,
Modified: trunk/pk/gkr-pk-object.h
==============================================================================
--- trunk/pk/gkr-pk-object.h (original)
+++ trunk/pk/gkr-pk-object.h Fri Feb 15 00:11:58 2008
@@ -52,7 +52,7 @@
GObject parent;
GQuark location;
- gkrid unique;
+ gkrid digest;
CK_OBJECT_HANDLE handle;
GkrPkObjectManager *manager;
Modified: trunk/pk/gkr-pk-privkey.c
==============================================================================
--- trunk/pk/gkr-pk-privkey.c (original)
+++ trunk/pk/gkr-pk-privkey.c Fri Feb 15 00:11:58 2008
@@ -577,20 +577,20 @@
{
GkrPkObject *key;
guchar hash[20];
- gkrid unique;
+ gkrid digest;
g_return_val_if_fail (s_key != NULL, NULL);
if (!gcry_pk_get_keygrip (s_key, hash))
g_return_val_if_reached (NULL);
- /* We need to create a unique for this key */
- unique = gkr_id_new_digestv ((const guchar*)"private-key", 11, hash, 20, NULL);
+ /* We need to create a digest for this key */
+ digest = gkr_id_new_digestv ((const guchar*)"private-key", 11, hash, 20, NULL);
key = g_object_new (GKR_TYPE_PK_PRIVKEY, "manager", mgr, "location", location,
- "gcrypt-sexp", s_key, "unique", unique, NULL);
+ "gcrypt-sexp", s_key, "digest", digest, NULL);
- gkr_id_free (unique);
+ gkr_id_free (digest);
return key;
}
Modified: trunk/pk/gkr-pk-pubkey.c
==============================================================================
--- trunk/pk/gkr-pk-pubkey.c (original)
+++ trunk/pk/gkr-pk-pubkey.c Fri Feb 15 00:11:58 2008
@@ -487,20 +487,20 @@
{
GkrPkObject *key;
guchar hash[20];
- gkrid unique;
+ gkrid digest;
g_return_val_if_fail (s_key != NULL, NULL);
if (!gcry_pk_get_keygrip (s_key, hash))
g_return_val_if_reached (NULL);
- /* We need to create a unique for this key */
- unique = gkr_id_new_digestv ((const guchar*)"public-key", 10, hash, 20, NULL);
+ /* We need to create a digest for this key */
+ digest = gkr_id_new_digestv ((const guchar*)"public-key", 10, hash, 20, NULL);
key = g_object_new (GKR_TYPE_PK_PUBKEY, "manager", manager, "location", location,
- "gcrypt-sexp", s_key, "unique", unique, NULL);
+ "gcrypt-sexp", s_key, "digest", digest, NULL);
- gkr_id_free (unique);
+ gkr_id_free (digest);
return key;
}
Modified: trunk/pk/tests/unit-test-pk-index.c
==============================================================================
--- trunk/pk/tests/unit-test-pk-index.c (original)
+++ trunk/pk/tests/unit-test-pk-index.c Fri Feb 15 00:11:58 2008
@@ -60,7 +60,7 @@
gkrid id = gkr_id_new (DATA, DATA_L);
GQuark location = gkr_location_from_child (GKR_LOCATION_VOLUME_LOCAL, "woof");
- object = g_object_new (GKR_TYPE_PK_OBJECT, "location", location, "unique", id, NULL);
+ object = g_object_new (GKR_TYPE_PK_OBJECT, "location", location, "digest", id, NULL);
gkr_pk_index_clear (object);
}
Modified: trunk/pkix/gkr-pkix-parser.c
==============================================================================
--- trunk/pkix/gkr-pkix-parser.c (original)
+++ trunk/pkix/gkr-pkix-parser.c Fri Feb 15 00:11:58 2008
@@ -142,7 +142,7 @@
*/
static const gchar*
-enum_next_password (GkrPkixParser *parser, GQuark loc, gkrid unique,
+enum_next_password (GkrPkixParser *parser, GQuark loc, gkrid digest,
GQuark type, const gchar *label, PasswordState *state)
{
GkrPkixParserPrivate *pv = GKR_PKIX_PARSER_GET_PRIVATE (parser);
@@ -217,7 +217,7 @@
label = display = gkr_location_to_display (loc);
g_signal_emit (parser, signals[ASK_PASSWORD], 0,
- loc, unique, type, label, state->n_prompts, &password);
+ loc, digest, type, label, state->n_prompts, &password);
++state->n_prompts;
g_free (display);
@@ -230,18 +230,18 @@
static void
fire_parsed_partial (GkrPkixParser *parser, GQuark location,
- gkrconstid unique, GQuark type)
+ gkrconstid digest, GQuark type)
{
gboolean owned = FALSE;
g_assert (location);
if (!gkr_async_is_stopping ())
- g_signal_emit (parser, signals[PARSED_PARTIAL], 0, location, unique, type, &owned);
+ g_signal_emit (parser, signals[PARSED_PARTIAL], 0, location, digest, type, &owned);
}
static void
-fire_parsed_sexp (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+fire_parsed_sexp (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, gcry_sexp_t sexp)
{
gboolean owned = FALSE;
@@ -250,13 +250,13 @@
g_assert (type);
if (!gkr_async_is_stopping ())
- g_signal_emit (parser, signals[PARSED_SEXP], 0, location, unique, type, sexp, &owned);
+ g_signal_emit (parser, signals[PARSED_SEXP], 0, location, digest, type, sexp, &owned);
if (!owned)
gcry_sexp_release (sexp);
}
static void
-fire_parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+fire_parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, ASN1_TYPE asn1)
{
gboolean owned = FALSE;
@@ -265,7 +265,7 @@
g_assert (type);
if (!gkr_async_is_stopping ())
- g_signal_emit (parser, signals[PARSED_ASN1], 0, location, unique, type, asn1, &owned);
+ g_signal_emit (parser, signals[PARSED_ASN1], 0, location, digest, type, asn1, &owned);
if (!owned)
asn1_delete_structure (&asn1);
}
@@ -297,7 +297,7 @@
}
static gboolean
-gkr_pkix_parser_parsed_partial (GkrPkixParser *parser, GQuark loc, gkrconstid unique,
+gkr_pkix_parser_parsed_partial (GkrPkixParser *parser, GQuark loc, gkrconstid digest,
GQuark type)
{
/* Didn't take ownership of the data */
@@ -305,7 +305,7 @@
}
static gboolean
-gkr_pkix_parser_parsed_asn1 (GkrPkixParser *parser, GQuark loc, gkrconstid unique,
+gkr_pkix_parser_parsed_asn1 (GkrPkixParser *parser, GQuark loc, gkrconstid digest,
GQuark type, ASN1_TYPE asn1)
{
/* Didn't take ownership of the data */
@@ -313,7 +313,7 @@
}
static gboolean
-gkr_pkix_parser_parsed_sexp (GkrPkixParser *parser, GQuark loc, gkrconstid unique,
+gkr_pkix_parser_parsed_sexp (GkrPkixParser *parser, GQuark loc, gkrconstid digest,
GQuark type, gcry_sexp_t sexp)
{
/* Didn't take ownership of the data */
@@ -321,7 +321,7 @@
}
static gchar*
-gkr_pkix_parser_ask_password (GkrPkixParser *parser, GQuark loc, gkrconstid unique,
+gkr_pkix_parser_ask_password (GkrPkixParser *parser, GQuark loc, gkrconstid digest,
GQuark type, const gchar *details, guint n_prompts)
{
return NULL;
@@ -524,26 +524,26 @@
gkr_pkix_parser_der_private_key (GkrPkixParser *parser, GQuark loc,
const guchar *data, gsize n_data)
{
- gkrid unique;
+ gkrid digest;
GkrPkixResult ret;
gcry_sexp_t s_key = NULL;
- unique = gkr_id_new_digest (data, n_data);
+ digest = gkr_id_new_digest (data, n_data);
ret = gkr_pkix_der_read_private_key_rsa (data, n_data, &s_key);
if (ret == GKR_PKIX_UNRECOGNIZED)
ret = gkr_pkix_der_read_private_key_dsa (data, n_data, &s_key);
if (ret == GKR_PKIX_SUCCESS)
- fire_parsed_sexp (parser, loc, unique, GKR_PKIX_PRIVATE_KEY, s_key);
+ fire_parsed_sexp (parser, loc, digest, GKR_PKIX_PRIVATE_KEY, s_key);
- gkr_id_free (unique);
+ gkr_id_free (digest);
return ret;
}
static GkrPkixResult
parse_der_pkcs8_plain (GkrPkixParser *parser, GQuark loc,
- gkrid unique, const guchar *data, gsize n_data)
+ gkrid digest, const guchar *data, gsize n_data)
{
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
GkrPkixResult ret;
@@ -609,7 +609,7 @@
};
if (ret == GKR_PKIX_SUCCESS)
- fire_parsed_sexp (parser, loc, unique, GKR_PKIX_PRIVATE_KEY, s_key);
+ fire_parsed_sexp (parser, loc, digest, GKR_PKIX_PRIVATE_KEY, s_key);
} else if (ret == GKR_PKIX_FAILURE) {
g_message ("invalid PKCS#8 key");
@@ -624,19 +624,19 @@
gkr_pkix_parser_der_pkcs8_plain (GkrPkixParser *parser, GQuark location,
const guchar *data, gsize n_data)
{
- gkrid unique;
+ gkrid digest;
GkrPkixResult ret;
- unique = gkr_id_new_digest (data, n_data);
- ret = parse_der_pkcs8_plain (parser, location, unique, data, n_data);
- gkr_id_free (unique);
+ digest = gkr_id_new_digest (data, n_data);
+ ret = parse_der_pkcs8_plain (parser, location, digest, data, n_data);
+ gkr_id_free (digest);
return ret;
}
static GkrPkixResult
parse_der_pkcs8_encrypted (GkrPkixParser *parser, GQuark location,
- gkrid unique, const guchar *data, gsize n_data)
+ gkrid digest, const guchar *data, gsize n_data)
{
PasswordState pstate = PASSWORD_STATE_INIT;
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
@@ -670,11 +670,11 @@
g_assert (cih == NULL);
- password = enum_next_password (parser, location, unique, GKR_PKIX_PRIVATE_KEY, NULL, &pstate);
+ password = enum_next_password (parser, location, digest, GKR_PKIX_PRIVATE_KEY, NULL, &pstate);
/* If no password is available, we still know it's a key, so 'partial' parse */
if (!password) {
- fire_parsed_partial (parser, location, unique, GKR_PKIX_PRIVATE_KEY);
+ fire_parsed_partial (parser, location, digest, GKR_PKIX_PRIVATE_KEY);
ret = GKR_PKIX_SUCCESS;
goto done;
}
@@ -711,7 +711,7 @@
n_crypted = l;
/* Try to parse the resulting key */
- r = parse_der_pkcs8_plain (parser, location, unique, crypted, n_crypted);
+ r = parse_der_pkcs8_plain (parser, location, digest, crypted, n_crypted);
gkr_secure_free (crypted);
crypted = NULL;
@@ -737,12 +737,12 @@
gkr_pkix_parser_der_pkcs8_encrypted (GkrPkixParser *parser, GQuark location,
const guchar *data, gsize n_data)
{
- gkrid unique;
+ gkrid digest;
GkrPkixResult ret;
- unique = gkr_id_new_digest (data, n_data);
- ret = parse_der_pkcs8_encrypted (parser, location, unique, data, n_data);
- gkr_id_free (unique);
+ digest = gkr_id_new_digest (data, n_data);
+ ret = parse_der_pkcs8_encrypted (parser, location, digest, data, n_data);
+ gkr_id_free (digest);
return ret;
}
@@ -751,14 +751,14 @@
gkr_pkix_parser_der_pkcs8 (GkrPkixParser *parser, GQuark loc, const guchar *data,
gsize n_data)
{
- gkrid unique;
+ gkrid digest;
GkrPkixResult ret;
- unique = gkr_id_new_digest (data, n_data);
- ret = parse_der_pkcs8_plain (parser, loc, unique, data, n_data);
+ digest = gkr_id_new_digest (data, n_data);
+ ret = parse_der_pkcs8_plain (parser, loc, digest, data, n_data);
if (ret == GKR_PKIX_UNRECOGNIZED)
- ret = parse_der_pkcs8_encrypted (parser, loc, unique, data, n_data);
- gkr_id_free (unique);
+ ret = parse_der_pkcs8_encrypted (parser, loc, digest, data, n_data);
+ gkr_id_free (digest);
return ret;
}
@@ -771,16 +771,16 @@
gkr_pkix_parser_der_certificate (GkrPkixParser *parser, GQuark loc,
const guchar *data, gsize n_data)
{
- gkrid unique;
+ gkrid digest;
GkrPkixResult ret;
ASN1_TYPE asn1;
- unique = gkr_id_new_digest (data, n_data);
+ digest = gkr_id_new_digest (data, n_data);
ret = gkr_pkix_der_read_certificate (data, n_data, &asn1);
if(ret == GKR_PKIX_SUCCESS)
- fire_parsed_asn1 (parser, loc, unique, GKR_PKIX_CERTIFICATE, asn1);
- gkr_id_free (unique);
+ fire_parsed_asn1 (parser, loc, digest, GKR_PKIX_CERTIFICATE, asn1);
+ gkr_id_free (digest);
return ret;
}
@@ -790,7 +790,7 @@
*/
static GkrPkixResult
-parse_pkcs12_cert_bag (GkrPkixParser *parser, GQuark loc, gkrid uni, const guchar *data, gsize n_data)
+parse_pkcs12_cert_bag (GkrPkixParser *parser, GQuark loc, gkrid digest, const guchar *data, gsize n_data)
{
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
ASN1_TYPE casn = ASN1_TYPE_EMPTY;
@@ -820,7 +820,7 @@
ret = gkr_pkix_der_read_certificate (certificate, n_certificate, &casn);
if(ret == GKR_PKIX_SUCCESS)
- fire_parsed_asn1 (parser, loc, uni, GKR_PKIX_CERTIFICATE, casn);
+ fire_parsed_asn1 (parser, loc, digest, GKR_PKIX_CERTIFICATE, casn);
done:
if (asn)
@@ -830,16 +830,14 @@
}
static GkrPkixResult
-parse_pkcs12_bag (GkrPkixParser *parser, GQuark loc, gkrid uni, const guchar *data, gsize n_data)
+parse_pkcs12_bag (GkrPkixParser *parser, GQuark loc, gkrid digest, const guchar *data, gsize n_data)
{
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
GkrPkixResult ret, r;
- int count = 0;
+ int res, count = 0;
GQuark oid;
- gchar *part;
const guchar *element;
gsize n_element;
- int res, i;
ret = GKR_PKIX_UNRECOGNIZED;
@@ -857,34 +855,34 @@
/*
* Now inside each bag are multiple elements. Who comes up
* with this stuff?
+ *
+ * But this is where we draw the line. We only support one
+ * element per bag, not multiple elements, not strange
+ * nested bags, not fairy queens with magical wands in bags...
+ *
+ * Just one element per bag.
*/
- for (i = 0; i < count; ++i)
- {
- part = g_strdup_printf ("?%u.bagId", i + 1);
- oid = gkr_pkix_asn1_read_oid (asn, part);
- g_free (part);
-
+ if (count >= 1) {
+
+ oid = gkr_pkix_asn1_read_oid (asn, "?1.bagId");
if (!oid)
goto done;
- part = g_strdup_printf ("?%u.bagValue", i + 1);
- element = gkr_pkix_asn1_read_content (asn, data, n_data, part, &n_element);
- g_free (part);
-
+ element = gkr_pkix_asn1_read_content (asn, data, n_data, "?1.bagValue", &n_element);
if (!element)
goto done;
/* A normal unencrypted key */
if (oid == OID_PKCS12_BAG_PKCS8_KEY) {
- r = parse_der_pkcs8_plain (parser, loc, uni, element, n_element);
+ r = parse_der_pkcs8_plain (parser, loc, digest, element, n_element);
/* A properly encrypted key */
} else if (oid == OID_PKCS12_BAG_PKCS8_ENCRYPTED_KEY) {
- r = parse_der_pkcs8_encrypted (parser, loc, uni, element, n_element);
+ r = parse_der_pkcs8_encrypted (parser, loc, digest, element, n_element);
/* A certificate */
} else if (oid == OID_PKCS12_BAG_CERTIFICATE) {
- r = parse_pkcs12_cert_bag (parser, loc, uni, element, n_element);
+ r = parse_pkcs12_cert_bag (parser, loc, digest, element, n_element);
/* TODO: OID_PKCS12_BAG_CRL */
} else {
@@ -907,7 +905,7 @@
}
static GkrPkixResult
-parse_pkcs12_encrypted_bag (GkrPkixParser *parser, GQuark loc, gkrid uni,
+parse_pkcs12_encrypted_bag (GkrPkixParser *parser, GQuark loc, gkrid digest,
const guchar *data, gsize n_data)
{
PasswordState pstate = PASSWORD_STATE_INIT;
@@ -944,9 +942,9 @@
g_assert (cih == NULL);
- password = enum_next_password (parser, loc, uni, 0, NULL, &pstate);
+ password = enum_next_password (parser, loc, digest, 0, NULL, &pstate);
if (!password) {
- fire_parsed_partial (parser, loc, uni, 0);
+ fire_parsed_partial (parser, loc, digest, 0);
ret = GKR_PKIX_SUCCESS;
goto done;
}
@@ -981,7 +979,7 @@
n_crypted = l;
/* Try to parse the resulting key */
- r = parse_pkcs12_bag (parser, loc, uni, crypted, n_crypted);
+ r = parse_pkcs12_bag (parser, loc, digest, crypted, n_crypted);
gkr_secure_free (crypted);
crypted = NULL;
@@ -1009,7 +1007,7 @@
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
GkrPkixResult ret, r;
const guchar *bag;
- gkrid uni = NULL;
+ gkrid digest = NULL;
gsize n_bag;
gchar *part;
GQuark oid;
@@ -1043,8 +1041,8 @@
if (!bag) /* A parse error */
goto done;
- gkr_id_free (uni);
- uni = gkr_id_new_digest (bag, n_bag);
+ gkr_id_free (digest);
+ digest = gkr_id_new_digest (bag, n_bag);
/* A non encrypted bag, just parse */
if (oid == OID_PKCS7_DATA) {
@@ -1057,11 +1055,11 @@
if (!bag)
goto done;
- r = parse_pkcs12_bag (parser, loc, uni, bag, n_bag);
+ r = parse_pkcs12_bag (parser, loc, digest, bag, n_bag);
/* Encrypted data first needs decryption */
} else if (oid == OID_PKCS7_ENCRYPTED_DATA) {
- r = parse_pkcs12_encrypted_bag (parser, loc, uni, bag, n_bag);
+ r = parse_pkcs12_encrypted_bag (parser, loc, digest, bag, n_bag);
/* Hmmmm, not sure what this is */
} else {
@@ -1080,8 +1078,8 @@
done:
if (asn)
asn1_delete_structure (&asn);
- if (uni)
- gkr_id_free (uni);
+ if (digest)
+ gkr_id_free (digest);
return ret;
}
@@ -1132,7 +1130,7 @@
}
static GkrPkixResult
-parse_pkcs7_signed_data (GkrPkixParser *parser, GQuark loc, gkrid uni,
+parse_pkcs7_signed_data (GkrPkixParser *parser, GQuark loc, gkrid digest,
const guchar *data, gsize n_data)
{
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
@@ -1163,7 +1161,7 @@
ret = gkr_pkix_der_read_certificate (certificate, n_certificate, &casn);
if (ret == GKR_PKIX_SUCCESS)
- fire_parsed_asn1 (parser, loc, uni, GKR_PKIX_CERTIFICATE, casn);
+ fire_parsed_asn1 (parser, loc, digest, GKR_PKIX_CERTIFICATE, casn);
if (ret == GKR_PKIX_FAILURE)
goto done;
}
@@ -1179,7 +1177,7 @@
}
static GkrPkixResult
-parse_der_pkcs7 (GkrPkixParser *parser, GQuark loc, gkrid uni,
+parse_der_pkcs7 (GkrPkixParser *parser, GQuark loc, gkrid digest,
const guchar *data, gsize n_data)
{
ASN1_TYPE asn = ASN1_TYPE_EMPTY;
@@ -1210,7 +1208,7 @@
if (!content)
goto done;
- ret = parse_pkcs7_signed_data (parser, loc, uni, content, n_content);
+ ret = parse_pkcs7_signed_data (parser, loc, digest, content, n_content);
done:
if (asn)
@@ -1222,11 +1220,11 @@
gkr_pkix_parser_der_pkcs7 (GkrPkixParser *parser, GQuark loc, const guchar *data, gsize n_data)
{
GkrPkixResult ret;
- gkrid uni;
+ gkrid digest;
- uni = gkr_id_new_digest (data, n_data);
- ret = parse_der_pkcs7 (parser, loc, uni, data, n_data);
- gkr_id_free (uni);
+ digest = gkr_id_new_digest (data, n_data);
+ ret = parse_der_pkcs7 (parser, loc, digest, data, n_data);
+ gkr_id_free (digest);
return ret;
}
@@ -1258,7 +1256,7 @@
}
static GkrPkixResult
-parse_plain_pem (GkrPkixParser *parser, GQuark location, gkrid unique,
+parse_plain_pem (GkrPkixParser *parser, GQuark location, gkrid digest,
GQuark type, const guchar *data, gsize n_data)
{
GkrPkixResult res;
@@ -1279,17 +1277,17 @@
res = gkr_pkix_der_read_private_key (data, n_data, &s_key);
} else if (type == PEM_PRIVATE_KEY) {
- return parse_der_pkcs8_plain (parser, location, unique, data, n_data);
+ return parse_der_pkcs8_plain (parser, location, digest, data, n_data);
} else if (type == PEM_ENCRYPTED_PRIVATE_KEY) {
- return parse_der_pkcs8_encrypted (parser, location, unique, data, n_data);
+ return parse_der_pkcs8_encrypted (parser, location, digest, data, n_data);
} else if (type == PEM_CERTIFICATE) {
parsed = GKR_PKIX_CERTIFICATE;
res = gkr_pkix_der_read_certificate (data, n_data, &asn1);
} else if (type == PEM_PKCS7) {
- return parse_der_pkcs7 (parser, location, unique, data, n_data);
+ return parse_der_pkcs7 (parser, location, digest, data, n_data);
} else if (type == PEM_PKCS7) {
return gkr_pkix_parser_der_pkcs12 (parser, location, data, n_data);
@@ -1303,16 +1301,16 @@
g_assert (parsed);
if (s_key)
- fire_parsed_sexp (parser, location, unique, parsed, s_key);
+ fire_parsed_sexp (parser, location, digest, parsed, s_key);
else
- fire_parsed_asn1 (parser, location, unique, parsed, asn1);
+ fire_parsed_asn1 (parser, location, digest, parsed, asn1);
}
return res;
}
static GkrPkixResult
-parse_encrypted_pem (GkrPkixParser *parser, GQuark location, gkrid unique,
+parse_encrypted_pem (GkrPkixParser *parser, GQuark location, gkrid digest,
GQuark type, GHashTable *headers, const guchar *data, gsize n_data)
{
PasswordState pstate = PASSWORD_STATE_INIT;
@@ -1341,11 +1339,11 @@
while (!gkr_async_is_stopping ()) {
- password = enum_next_password (parser, location, unique, parsed, NULL, &pstate);
+ password = enum_next_password (parser, location, digest, parsed, NULL, &pstate);
/* If no password is available, we still know what it was, so 'partial' parse */
if (!password) {
- fire_parsed_partial (parser, location, unique, parsed);
+ fire_parsed_partial (parser, location, digest, parsed);
return GKR_PKIX_SUCCESS;
}
@@ -1366,7 +1364,7 @@
n_decrypted = l;
/* Try to parse */
- ret = parse_plain_pem (parser, location, unique, type, decrypted, n_decrypted);
+ ret = parse_plain_pem (parser, location, digest, type, decrypted, n_decrypted);
gkr_secure_free (decrypted);
if (ret != GKR_PKIX_UNRECOGNIZED)
@@ -1383,10 +1381,10 @@
ParserCtx *ctx = (ParserCtx*)user_data;
GkrPkixResult res = GKR_PKIX_FAILURE;
gboolean encrypted = FALSE;
- gkrid unique;
+ gkrid digest;
const gchar *val;
- unique = gkr_id_new_digest (data, n_data);
+ digest = gkr_id_new_digest (data, n_data);
/* See if it's encrypted PEM all openssl like*/
if (headers) {
@@ -1396,10 +1394,10 @@
}
if (encrypted) {
- res = parse_encrypted_pem (ctx->parser, ctx->location, unique,
+ res = parse_encrypted_pem (ctx->parser, ctx->location, digest,
type, headers, data, n_data);
} else {
- res = parse_plain_pem (ctx->parser, ctx->location, unique,
+ res = parse_plain_pem (ctx->parser, ctx->location, digest,
type, data, n_data);
}
@@ -1408,7 +1406,7 @@
} else if (ctx->result == GKR_PKIX_UNRECOGNIZED)
ctx->result = res;
- gkr_id_free (unique);
+ gkr_id_free (digest);
}
GkrPkixResult
Modified: trunk/pkix/gkr-pkix-parser.h
==============================================================================
--- trunk/pkix/gkr-pkix-parser.h (original)
+++ trunk/pkix/gkr-pkix-parser.h Fri Feb 15 00:11:58 2008
@@ -57,22 +57,22 @@
/* When an object is not fully parsed because of restrictions */
gboolean (*parsed_partial) (GkrPkixParser *parser, GQuark location,
- gkrconstid unique, GQuark type);
+ gkrconstid digest, GQuark type);
/* When an ASN.1 type object is parsed */
gboolean (*parsed_asn1) (GkrPkixParser *parser, GQuark location,
- gkrconstid unique, GQuark type,
+ gkrconstid digest, GQuark type,
ASN1_TYPE asn1);
/* When a gcrypt sexp is parsed */
gboolean (*parsed_sexp) (GkrPkixParser *parser, GQuark location,
- gkrconstid unique, GQuark type,
+ gkrconstid digest, GQuark type,
gcry_sexp_t sexp);
/* A callback for each password needed */
gchar* (*ask_password) (GkrPkixParser *parser, GQuark location,
- gkrconstid unique, GQuark type,
- const gchar *orig_label, guint failed);
+ gkrconstid digest, GQuark type,
+ const gchar *orig_label, guint failed);
};
GType gkr_pkix_parser_get_type (void) G_GNUC_CONST;
Modified: trunk/pkix/tests/unit-test-pkix-parser.c
==============================================================================
--- trunk/pkix/tests/unit-test-pkix-parser.c (original)
+++ trunk/pkix/tests/unit-test-pkix-parser.c Fri Feb 15 00:11:58 2008
@@ -62,7 +62,7 @@
static CuTest *the_cu = NULL;
static gboolean
-parsed_partial (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+parsed_partial (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, gpointer user_data)
{
CuTest *cu = the_cu;
@@ -70,7 +70,7 @@
CuAssert (cu, "location is empty", location != 0);
CuAssert (cu, "location is invalid", gkr_location_to_path (location) != NULL);
- CuAssert (cu, "unique is empty", unique != NULL);
+ CuAssert (cu, "digest is empty", digest != NULL);
CuAssert (cu, "type is invalid", type != 0);
g_print ("parsed partial at: %s\n", g_quark_to_string (location));
@@ -82,7 +82,7 @@
}
static gboolean
-parsed_sexp (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+parsed_sexp (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, gcry_sexp_t sexp, gpointer user_data)
{
CuTest *cu = the_cu;
@@ -90,7 +90,7 @@
CuAssert (cu, "location is empty", location != 0);
CuAssert (cu, "location is invalid", gkr_location_to_path (location) != NULL);
- CuAssert (cu, "unique is empty", unique != NULL);
+ CuAssert (cu, "digest is empty", digest != NULL);
CuAssert (cu, "type is invalid", type != 0);
CuAssert (cu, "sexp is invalid", sexp != NULL);
@@ -104,7 +104,7 @@
}
static gboolean
-parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid unique,
+parsed_asn1 (GkrPkixParser *parser, GQuark location, gkrconstid digest,
GQuark type, ASN1_TYPE asn1, gpointer user_data)
{
CuTest *cu = the_cu;
@@ -112,7 +112,7 @@
CuAssert (cu, "location is empty", location != 0);
CuAssert (cu, "location is invalid", gkr_location_to_path (location) != NULL);
- CuAssert (cu, "unique is empty", unique != NULL);
+ CuAssert (cu, "digest is empty", digest != NULL);
CuAssert (cu, "type is invalid", type != 0);
CuAssert (cu, "asn1 is invalid", asn1 != NULL);
@@ -126,7 +126,7 @@
}
static gchar*
-ask_password (GkrPkixParser *parser, GQuark loc, gkrconstid unique,
+ask_password (GkrPkixParser *parser, GQuark loc, gkrconstid digest,
GQuark type, const gchar *details, guint n_prompts,
gpointer user_data)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]