[gnome-keyring/gck-work] [gck] Remove most complex var args functions.



commit a6adc688b7be28f487695db35377cd87aabd8948
Author: Stef Walter <stef memberwebs com>
Date:   Sat Jul 31 10:39:59 2010 +0200

    [gck] Remove most complex var args functions.
    
     * These functions could not be bound through gobject introspection.
     * They were hard to get right even in C, because the varargs were
       triples.

 gck/gck-attributes.c            |  136 ------------------------
 gck/gck-modules.c               |   76 +------------
 gck/gck-object.c                |   56 +----------
 gck/gck-session.c               |  223 ++-------------------------------------
 gck/gck.h                       |   49 ---------
 gck/tests/gck-test-module.c     |   70 ++++++------
 gck/tests/test-gck-attributes.c |   78 +-------------
 gck/tests/test-gck-crypto.c     |   42 +++----
 gck/tests/test-gck-module.c     |    9 +-
 gck/tests/test-gck-object.c     |  127 ++++++++---------------
 gck/tests/test-gck-session.c    |   12 +-
 11 files changed, 129 insertions(+), 749 deletions(-)
---
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c
index 30250e8..a691b76 100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@ -788,142 +788,6 @@ gck_attributes_new_empty (gulong attr_type, ...)
 	return attrs;
 }
 
-static GckAttributes*
-initialize_from_valist (GckAllocator allocator, gulong type, va_list va)
-{
-	GckAttributes *attrs;
-	gssize length;
-	gpointer value;
-
-	g_assert (allocator);
-
-	attrs = gck_attributes_new_full (allocator);
-
-	/* No attributes */
-	if (type == GCK_INVALID)
-		return attrs;
-
-	do {
-		length = va_arg (va, gssize);
-
-		/* All the different set types */
-		switch (length) {
-		case GCK_BOOLEAN:
-			gck_attributes_add_boolean (attrs, type, va_arg (va, gboolean));
-			break;
-		case GCK_ULONG:
-			gck_attributes_add_ulong (attrs, type, va_arg (va, gulong));
-			break;
-		case GCK_STRING:
-			gck_attributes_add_string (attrs, type, va_arg (va, const gchar*));
-			break;
-		case GCK_DATE:
-			gck_attributes_add_date (attrs, type, va_arg (va, const GDate*));
-			break;
-
-		/* Otherwise it should be data */
-		default:
-			value = va_arg (va, gpointer);
-
-			/* But not this long */
-			if (length < 0 || length >= G_MAXSSIZE)
-				g_warning ("length passed to attributes varargs is invalid or too large: %d", (int)length);
-			else
-				gck_attributes_add_data (attrs, type, value, length);
-			break;
-		};
-
-		type = va_arg (va, gulong);
-
-	} while (type != GCK_INVALID);
-
-	return attrs;
-}
-
-/**
- * gck_attributes_newv:
- * @attr_type: The first attribute type.
- * @...: The arguments must be triples of: attribute type, data type, value
- *
- * Create a new GckAttributes array, containing a list of attributes.
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of gck_BOOLEAN, gck_ULONG,
- * 				gck_STRING, gck_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with gck_INVALID.</para>
- *
- * Return value: The new attributes array. When done with the array
- * release it with gck_attributes_unref().
- **/
-GckAttributes*
-gck_attributes_newv (gulong attr_type, ...)
-{
-	GckAttributes *attrs;
-	va_list va;
-
-	va_start (va, attr_type);
-	attrs = initialize_from_valist (g_realloc, attr_type, va);
-	va_end (va);
-
-	return attrs;
-}
-
-/**
- * gck_attributes_new_valist:
- * @allocator: Memory allocator for attribute data, or NULL for default.
- * @va: Variable argument containing attributes to add.
- *
- * Create a new GckAttributes array.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of gck_BOOLEAN, gck_ULONG,
- * 				gck_STRING, gck_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with gck_INVALID.</para>
- *
- * Return value: The new attributes array. When done with the array
- * release it with gck_attributes_unref().
- **/
-GckAttributes*
-gck_attributes_new_valist (GckAllocator allocator, va_list va)
-{
-	gulong type = va_arg (va, gulong);
-
-	if (!allocator)
-		allocator = g_realloc;
-
-	return initialize_from_valist (allocator, type, va);
-}
-
 /**
  * gck_attributes_at:
  * @attrs: The attributes array.
diff --git a/gck/gck-modules.c b/gck/gck-modules.c
index ae70d6f..bf13de1 100644
--- a/gck/gck-modules.c
+++ b/gck/gck-modules.c
@@ -51,76 +51,10 @@ gck_modules_get_slots (GList *modules, gboolean token_present)
 }
 
 /**
- * gck_modules_enumerate_objects:
- * @modules: The modules on which to enumerate objects.
- * @func: Function to call for each object.
- * @user_data: Data to pass to the function.
- * @...: The arguments must be triples of: attribute type, data type, value.
- *
- * Call a function for every matching object on the module. This call may
- * block for an indefinite period.
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * This function will open a session per slot. It's recommended that you
- * set the 'reuse-sessions' property on each slot if you'll be calling
- * it a lot.
- *
- * You can access the session in which the object was found, by using the
- * gck_object_get_session() function on the resulting objects.
- *
- * This function skips tokens that are not initialize, and makes a best effort to
- * find objects on valid tokens.
- *
- * The function can return FALSE to stop the enumeration.
- *
- * Return value: If FALSE then an error prevented all matching objects from being enumerated.
- **/
-gboolean
-gck_modules_enumerate_objects (GList *modules, GckObjectForeachFunc func,
-                               gpointer user_data, ...)
-{
-	GckAttributes *attrs;
-	GError *error = NULL;
-	va_list va;
-
-	va_start (va, user_data);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	gck_modules_enumerate_objects_full (modules, attrs, CKF_RW_SESSION, NULL, func, user_data, &error);
-	gck_attributes_unref (attrs);
-
-	if (error != NULL) {
-		g_warning ("enumerating objects failed: %s", error->message);
-		g_clear_error (&error);
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-/**
  * gck_module_enumerate_objects_full:
  * @self: The module to enumerate objects.
  * @attrs: Attributes that the objects must have, or empty for all objects.
+ * @session_flags: PKCS#11 flags for opening a session.
  * @cancellable: Optional cancellation object, or NULL.
  * @func: Function to call for each object.
  * @user_data: Data to pass to the function.
@@ -141,9 +75,9 @@ gck_modules_enumerate_objects (GList *modules, GckObjectForeachFunc func,
  * Return value: If FALSE then an error prevented all matching objects from being enumerated.
  **/
 gboolean
-gck_modules_enumerate_objects_full (GList *modules, GckAttributes *attrs, guint session_flags,
-                                    GCancellable *cancellable, GckObjectForeachFunc func,
-                                    gpointer user_data, GError **err)
+gck_modules_enumerate_objects (GList *modules, GckAttributes *attrs, guint session_flags,
+                               GCancellable *cancellable, GckObjectForeachFunc func,
+                               gpointer user_data, GError **err)
 {
 	gboolean stop = FALSE;
 	gboolean ret = TRUE;
@@ -178,7 +112,7 @@ gck_modules_enumerate_objects_full (GList *modules, GckAttributes *attrs, guint
 				continue;
 			}
 
-			objects = gck_session_find_objects_full (session, attrs, cancellable, &error);
+			objects = gck_session_find_objects (session, attrs, cancellable, &error);
 			if (error) {
 				ret = FALSE;
 				g_object_unref (session);
diff --git a/gck/gck-object.c b/gck/gck-object.c
index c1e2128..ce9cb20 100644
--- a/gck/gck-object.c
+++ b/gck/gck-object.c
@@ -509,58 +509,6 @@ free_set_attributes (SetAttributes *args)
 /**
  * gck_object_set:
  * @self: The object to set attributes on.
- * @err: A location to return an error.
- * @...: The attributes to set.
- *
- * Set PKCS#11 attributes on an object.
- * This call may block for an indefinite period.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * Return value: Whether the call was successful or not.
- **/
-gboolean
-gck_object_set (GckObject *self, GError **err, ...)
-{
-	GckAttributes *attrs;
-	va_list va;
-	CK_RV rv;
-
-	g_return_val_if_fail (GCK_IS_OBJECT (self), FALSE);
-	g_return_val_if_fail (!err || !*err, FALSE);
-
-	va_start (va, err);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	rv = gck_object_set_full (self, attrs, NULL, err);
-
-	gck_attributes_unref (attrs);
-	return rv;
-}
-
-/**
- * gck_object_set_full:
- * @self: The object to set attributes on.
  * @attrs: The attributes to set on the object.
  * @cancellable: Optional cancellable object, or NULL to ignore.
  * @err: A location to return an error.
@@ -570,8 +518,8 @@ gck_object_set (GckObject *self, GError **err, ...)
  * Return value: Whether the call was successful or not.
  **/
 gboolean
-gck_object_set_full (GckObject *self, GckAttributes *attrs,
-                     GCancellable *cancellable, GError **err)
+gck_object_set (GckObject *self, GckAttributes *attrs,
+                GCancellable *cancellable, GError **err)
 {
 	GckObjectData *data = GCK_OBJECT_GET_DATA (self);
 	SetAttributes args;
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 73de8c8..7d331ec 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -933,55 +933,6 @@ perform_create_object (CreateObject *args)
 /**
  * gck_session_create_object:
  * @self: The session to create the object on.
- * @err: A location to store an error.
- * @...: The attributes to create the new object with.
- *
- * Create a new PKCS#11 object. This call may block
- * for an indefinite period.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- *
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * Return value: The newly created object, or NULL if an error occurred.
- **/
-GckObject*
-gck_session_create_object (GckSession *self, GError **err, ...)
-{
-	GckAttributes *attrs;
-	GckObject *object;
-	va_list va;
-
-	va_start (va, err);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	object = gck_session_create_object_full (self, attrs, NULL, err);
-	gck_attributes_unref (attrs);
-	return object;
-}
-
-/**
- * gck_session_create_object_full:
- * @self: The session to create the object on.
  * @attrs: The attributes to create the object with.
  * @cancellable: Optional cancellation object, or NULL.
  * @err: A location to return an error, or NULL.
@@ -992,8 +943,8 @@ gck_session_create_object (GckSession *self, GError **err, ...)
  * Return value: The newly created object or NULL if an error occurred.
  **/
 GckObject*
-gck_session_create_object_full (GckSession *self, GckAttributes *attrs,
-                                 GCancellable *cancellable, GError **err)
+gck_session_create_object (GckSession *self, GckAttributes *attrs,
+                           GCancellable *cancellable, GError **err)
 {
 	CreateObject args = { GCK_ARGUMENTS_INIT, attrs, 0 };
 	gboolean ret;
@@ -1153,54 +1104,6 @@ objlist_from_handles (GckSession *self, CK_OBJECT_HANDLE_PTR objects,
 /**
  * gck_session_find_objects:
  * @self: The session to find objects on.
- * @err: A location to return an error or NULL.
- * @...: The attributes to match.
- *
- * Find objects matching the passed attributes. This call may
- * block for an indefinite period.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * Return value: A list of the matching objects, which may be empty.
- **/
-GList*
-gck_session_find_objects (GckSession *self, GError **err, ...)
-{
-	GckAttributes *attrs;
-	GList *results;
-	va_list va;
-
-	va_start (va, err);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	results = gck_session_find_objects_full (self, attrs, NULL, err);
-	gck_attributes_unref (attrs);
-	return results;
-}
-
-/**
- * gck_session_find_objects_full:
- * @self: The session to find objects on.
  * @attrs: The attributes to match.
  * @cancellable: Optional cancellation object or NULL.
  * @err: A location to return an error or NULL.
@@ -1211,8 +1114,8 @@ gck_session_find_objects (GckSession *self, GError **err, ...)
  * Return value: A list of the matching objects, which may be empty.
  **/
 GList*
-gck_session_find_objects_full (GckSession *self, GckAttributes *attrs,
-                                GCancellable *cancellable, GError **err)
+gck_session_find_objects (GckSession *self, GckAttributes *attrs,
+                          GCancellable *cancellable, GError **err)
 {
 	FindObjects args = { GCK_ARGUMENTS_INIT, attrs, NULL, 0 };
 	GList *results = NULL;
@@ -1657,60 +1560,6 @@ perform_unwrap_key (UnwrapKey *args)
  * gck_session_unwrap_key:
  * @self: The session to use.
  * @wrapper: The key to use for unwrapping.
- * @mech_type: The mechanism type to use for derivation.
- * @input: The wrapped data as a byte stream.
- * @n_input: The length of the wrapped data.
- * @err: A location to return an error, or NULL.
- * @...: Additional attributes for the unwrapped key.
- *
- * Unwrap a key from a byte stream. This call may block for an
- * indefinite period.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * Return value: The new unwrapped key or NULL if the operation failed.
- **/
-GckObject*
-gck_session_unwrap_key (GckSession *self, GckObject *key, gulong mech_type,
-                         gconstpointer input, gsize n_input, GError **err, ...)
-{
-	GckMechanism mech = { mech_type, NULL, 0 };
-	GckAttributes *attrs;
-	GckObject *object;
-	va_list va;
-
-	va_start (va, err);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	object = gck_session_unwrap_key_full (self, key, &mech, input, n_input, attrs, NULL, err);
-	gck_attributes_unref (attrs);
-	return object;
-}
-
-/**
- * gck_session_unwrap_key_full:
- * @self: The session to use.
- * @wrapper: The key to use for unwrapping.
  * @mechanism: The mechanism to use for unwrapping.
  * @input: The wrapped data as a byte stream.
  * @n_input: The length of the wrapped data.
@@ -1724,9 +1573,9 @@ gck_session_unwrap_key (GckSession *self, GckObject *key, gulong mech_type,
  * Return value: The new unwrapped key or NULL if the operation failed.
  **/
 GckObject*
-gck_session_unwrap_key_full (GckSession *self, GckObject *wrapper, GckMechanism *mechanism,
-                              gconstpointer input, gsize n_input, GckAttributes *attrs,
-                              GCancellable *cancellable, GError **err)
+gck_session_unwrap_key (GckSession *self, GckObject *wrapper, GckMechanism *mechanism,
+                        gconstpointer input, gsize n_input, GckAttributes *attrs,
+                        GCancellable *cancellable, GError **err)
 {
 	UnwrapKey args = { GCK_ARGUMENTS_INIT, mechanism, attrs, 0, input, n_input, 0 };
 	gboolean ret;
@@ -1851,59 +1700,7 @@ perform_derive_key (DeriveKey *args)
 }
 
 /**
- * gck_session_derive_key_full:
- * @self: The session to use.
- * @base: The key to derive from.
- * @mech_type: The mechanism type to use for derivation.
- * @err: A location to return an error, or NULL.
- * @...: Additional attributes for the derived key.
- *
- * Derive a key from another key. This call may block for an
- * indefinite period.
- *
- * The arguments must be triples of: attribute type, data type, value
- *
- * <para>The variable argument list should contain:
- * 	<variablelist>
- *		<varlistentry>
- * 			<term>a)</term>
- * 			<listitem><para>The gulong attribute type (ie: CKA_LABEL). </para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>b)</term>
- * 			<listitem><para>The attribute data type (one of GCK_BOOLEAN, GCK_ULONG,
- * 				GCK_STRING, GCK_DATE) orthe raw attribute value length.</para></listitem>
- * 		</varlistentry>
- * 		<varlistentry>
- * 			<term>c)</term>
- * 			<listitem><para>The attribute value, either a gboolean, gulong, gchar*, GDate* or
- * 				a pointer to a raw attribute value.</para></listitem>
- * 		</varlistentry>
- * 	</variablelist>
- * The variable argument list should be terminated with GCK_INVALID.</para>
- *
- * Return value: The new derived key or NULL if the operation failed.
- **/
-GckObject*
-gck_session_derive_key (GckSession *self, GckObject *key, gulong mech_type,
-                         GError **err, ...)
-{
-	GckMechanism mech = { mech_type, NULL, 0 };
-	GckAttributes *attrs;
-	GckObject *object;
-	va_list va;
-
-	va_start (va, err);
-	attrs = gck_attributes_new_valist (g_realloc, va);
-	va_end (va);
-
-	object = gck_session_derive_key_full (self, key, &mech, attrs, NULL, err);
-	gck_attributes_unref (attrs);
-	return object;
-}
-
-/**
- * gck_session_derive_key_full:
+ * gck_session_derive_key:
  * @self: The session to use.
  * @base: The key to derive from.
  * @mechanism: The mechanism to use for derivation.
@@ -1917,8 +1714,8 @@ gck_session_derive_key (GckSession *self, GckObject *key, gulong mech_type,
  * Return value: The new derived key or NULL if the operation failed.
  **/
 GckObject*
-gck_session_derive_key_full (GckSession *self, GckObject *base, GckMechanism *mechanism,
-                              GckAttributes *attrs, GCancellable *cancellable, GError **err)
+gck_session_derive_key (GckSession *self, GckObject *base, GckMechanism *mechanism,
+                        GckAttributes *attrs, GCancellable *cancellable, GError **err)
 {
 	DeriveKey args = { GCK_ARGUMENTS_INIT, mechanism, attrs, 0, 0 };
 	gboolean ret;
diff --git a/gck/gck.h b/gck/gck.h
index bc53667..cd4f9ca 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -73,11 +73,6 @@ typedef struct GckAttribute {
 	gulong length;
 } GckAttribute;
 
-#define GCK_BOOLEAN  ((gssize)-1)
-#define GCK_ULONG    ((gssize)-2)
-#define GCK_STRING   ((gssize)-3)
-#define GCK_DATE     ((gssize)-4)
-
 #define GCK_INVALID G_MAXULONG
 
 enum {
@@ -166,12 +161,6 @@ GckAttributes*      gck_attributes_new_empty                (gulong attr_type,
 
 GckAttributes*      gck_attributes_new_full                 (GckAllocator allocator);
 
-GckAttributes*      gck_attributes_newv                     (gulong attr_type,
-                                                             ...);
-
-GckAttributes*      gck_attributes_new_valist               (GckAllocator allocator,
-                                                             va_list va);
-
 GckAttribute*       gck_attributes_at                       (GckAttributes *attrs,
                                                              guint index);
 
@@ -316,11 +305,6 @@ GList*                gck_modules_get_slots                   (GList *modules,
                                                                gboolean token_present);
 
 gboolean              gck_modules_enumerate_objects           (GList *modules,
-                                                               GckObjectForeachFunc func,
-                                                               gpointer user_data,
-                                                               ...);
-
-gboolean              gck_modules_enumerate_objects_full      (GList *modules,
                                                                GckAttributes *attrs,
                                                                guint session_flags,
                                                                GCancellable *cancellable,
@@ -346,13 +330,6 @@ void                  gck_modules_enumerate_objects_finish    (GList *modules,
                                                                GError **error);
 #endif
 
-enum {
-	GCK_IS_STRING = -1,
-	GCK_IS_BOOLEAN = -2,
-	GCK_IS_DATE = -3,
-	GCK_IS_ULONG = -4
-};
-
 /* ------------------------------------------------------------------------
  * SLOT
  */
@@ -640,10 +617,6 @@ gboolean            gck_session_logout_finish               (GckSession *self,
                                                              GError **err);
 
 GckObject*          gck_session_create_object               (GckSession *self,
-                                                             GError **err,
-                                                             ...);
-
-GckObject*          gck_session_create_object_full          (GckSession *self,
                                                              GckAttributes *attrs,
                                                              GCancellable *cancellable,
                                                              GError **err);
@@ -659,10 +632,6 @@ GckObject*          gck_session_create_object_finish        (GckSession *self,
                                                              GError **err);
 
 GList*              gck_session_find_objects                (GckSession *self,
-                                                             GError **err,
-                                                             ...);
-
-GList*              gck_session_find_objects_full           (GckSession *self,
                                                              GckAttributes *attrs,
                                                              GCancellable *cancellable,
                                                              GError **err);
@@ -979,14 +948,6 @@ gpointer            gck_session_wrap_key_finish              (GckSession *self,
 
 GckObject*          gck_session_unwrap_key                   (GckSession *self,
                                                               GckObject *wrapper,
-                                                              gulong mech_type,
-                                                              gconstpointer input,
-                                                              gsize n_input,
-                                                              GError **err,
-                                                              ...);
-
-GckObject*          gck_session_unwrap_key_full              (GckSession *self,
-                                                              GckObject *wrapper,
                                                               GckMechanism *mechanism,
                                                               gconstpointer input,
                                                               gsize n_input,
@@ -1010,12 +971,6 @@ GckObject*          gck_session_unwrap_key_finish            (GckSession *self,
 
 GckObject*          gck_session_derive_key                   (GckSession *self,
                                                               GckObject *base,
-                                                              gulong mech_type,
-                                                              GError **err,
-                                                              ...);
-
-GckObject*          gck_session_derive_key_full              (GckSession *self,
-                                                              GckObject *base,
                                                               GckMechanism *mechanism,
                                                               GckAttributes *attrs,
                                                               GCancellable *cancellable,
@@ -1134,10 +1089,6 @@ gssize              gck_object_get_size_finish              (GckObject *self,
 #endif /* UNIMPLEMENTED */
 
 gboolean            gck_object_set                          (GckObject *self,
-                                                             GError **err,
-                                                             ...);
-
-gboolean            gck_object_set_full                     (GckObject *self,
                                                              GckAttributes *attrs,
                                                              GCancellable *cancellable,
                                                              GError **err);
diff --git a/gck/tests/gck-test-module.c b/gck/tests/gck-test-module.c
index 4fb8e60..cad5430 100644
--- a/gck/tests/gck-test-module.c
+++ b/gck/tests/gck-test-module.c
@@ -134,57 +134,57 @@ test_C_Initialize (CK_VOID_PTR pInitArgs)
 	the_objects = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)gck_attributes_unref);
 
 	/* Our token object */
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                              CKA_LABEL, GCK_STRING, "TEST LABEL",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "TEST LABEL");
 	g_hash_table_insert (the_objects, GUINT_TO_POINTER (2), attrs);
 
 	/* Private capitalize key */
 	value = CKM_CAPITALIZE;
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_PRIVATE_KEY,
-	                              CKA_LABEL, GCK_STRING, "Private Capitalize Key",
-	                              CKA_ALLOWED_MECHANISMS, sizeof (value), &value,
-	                              CKA_DECRYPT, GCK_BOOLEAN, TRUE,
-	                              CKA_PRIVATE, GCK_BOOLEAN, TRUE,
-	                              CKA_WRAP, GCK_BOOLEAN, TRUE,
-	                              CKA_UNWRAP, GCK_BOOLEAN, TRUE,
-	                              CKA_DERIVE, GCK_BOOLEAN, TRUE,
-	                              CKA_VALUE, GCK_STRING, "value",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PRIVATE_KEY);
+	gck_attributes_add_string (attrs, CKA_LABEL, "Private Capitalize Key");
+	gck_attributes_add_data (attrs, CKA_ALLOWED_MECHANISMS, &value, sizeof (value));
+	gck_attributes_add_boolean (attrs, CKA_DECRYPT, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_PRIVATE, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_WRAP, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_UNWRAP, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_DERIVE, TRUE);
+	gck_attributes_add_string (attrs, CKA_VALUE, "value");
 	g_hash_table_insert (the_objects, GUINT_TO_POINTER (PRIVATE_KEY_CAPITALIZE), attrs);
 
 	/* Public capitalize key */
 	value = CKM_CAPITALIZE;
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_PUBLIC_KEY,
-	                              CKA_LABEL, GCK_STRING, "Public Capitalize Key",
-	                              CKA_ALLOWED_MECHANISMS, sizeof (value), &value,
-	                              CKA_ENCRYPT, GCK_BOOLEAN, TRUE,
-	                              CKA_PRIVATE, GCK_BOOLEAN, FALSE,
-	                              CKA_VALUE, GCK_STRING, "value",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PUBLIC_KEY);
+	gck_attributes_add_string (attrs, CKA_LABEL, "Public Capitalize Key");
+	gck_attributes_add_data (attrs, CKA_ALLOWED_MECHANISMS, &value, sizeof (value));
+	gck_attributes_add_boolean (attrs, CKA_ENCRYPT, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_PRIVATE, FALSE);
+	gck_attributes_add_string (attrs, CKA_VALUE, "value");
 	g_hash_table_insert (the_objects, GUINT_TO_POINTER (PUBLIC_KEY_CAPITALIZE), attrs);
 
 	/* Private prefix key */
 	value = CKM_PREFIX;
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_PRIVATE_KEY,
-	                              CKA_LABEL, GCK_STRING, "Private prefix key",
-	                              CKA_ALLOWED_MECHANISMS, sizeof (value), &value,
-	                              CKA_SIGN, GCK_BOOLEAN, TRUE,
-	                              CKA_PRIVATE, GCK_BOOLEAN, TRUE,
-	                              CKA_ALWAYS_AUTHENTICATE, GCK_BOOLEAN, TRUE,
-	                              CKA_VALUE, GCK_STRING, "value",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PRIVATE_KEY);
+	gck_attributes_add_string (attrs, CKA_LABEL, "Private prefix key");
+	gck_attributes_add_data (attrs, CKA_ALLOWED_MECHANISMS, &value, sizeof (value));
+	gck_attributes_add_boolean (attrs, CKA_SIGN, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_PRIVATE, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_ALWAYS_AUTHENTICATE, TRUE);
+	gck_attributes_add_string (attrs, CKA_VALUE, "value");
 	g_hash_table_insert (the_objects, GUINT_TO_POINTER (PRIVATE_KEY_PREFIX), attrs);
 
 	/* Private prefix key */
 	value = CKM_PREFIX;
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_PUBLIC_KEY,
-	                              CKA_LABEL, GCK_STRING, "Public prefix key",
-	                              CKA_ALLOWED_MECHANISMS, sizeof (value), &value,
-	                              CKA_VERIFY, GCK_BOOLEAN, TRUE,
-	                              CKA_PRIVATE, GCK_BOOLEAN, FALSE,
-	                              CKA_VALUE, GCK_STRING, "value",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PUBLIC_KEY);
+	gck_attributes_add_string (attrs, CKA_LABEL, "Public prefix key");
+	gck_attributes_add_data (attrs, CKA_ALLOWED_MECHANISMS, &value, sizeof (value));
+	gck_attributes_add_boolean (attrs, CKA_VERIFY, TRUE);
+	gck_attributes_add_boolean (attrs, CKA_PRIVATE, FALSE);
+	gck_attributes_add_string (attrs, CKA_VALUE, "value");
 	g_hash_table_insert (the_objects, GUINT_TO_POINTER (PUBLIC_KEY_PREFIX), attrs);
 
 	initialized = TRUE;
diff --git a/gck/tests/test-gck-attributes.c b/gck/tests/test-gck-attributes.c
index 24e8ee3..f2926ae 100644
--- a/gck/tests/test-gck-attributes.c
+++ b/gck/tests/test-gck-attributes.c
@@ -346,26 +346,6 @@ test_attributes_contents (GckAttributes *attrs, gboolean extras)
 	g_assert (attr->value == NULL);
 }
 
-DEFINE_TEST(newv_attributes)
-{
-	GDate *date = g_date_new_dmy (11, 12, 2008);
-	GckAttributes *attrs;
-	attrs = gck_attributes_newv (0UL, GCK_BOOLEAN, TRUE,
-	                              101UL, GCK_ULONG, 888UL,
-	                              202UL, GCK_STRING, "string",
-	                              303UL, GCK_DATE, date,
-	                              404UL, N_ATTR_DATA, ATTR_DATA,
-	                              GCK_INVALID);
-	g_date_free (date);
-
-	test_attributes_contents (attrs, FALSE);
-	gck_attributes_unref (attrs);
-
-	/* An empty one */
-	attrs = gck_attributes_newv (GCK_INVALID);
-	gck_attributes_unref (attrs);
-}
-
 DEFINE_TEST(new_empty_attributes)
 {
 	GckAttributes *attrs = gck_attributes_new_empty (101UL, 202UL, 303UL, 404UL, GCK_INVALID);
@@ -381,50 +361,6 @@ DEFINE_TEST(new_empty_attributes)
 	}
 }
 
-static GckAttributes*
-help_attributes_valist (int dummy, ...)
-{
-	GckAttributes *attrs;
-	va_list va;
-
-	va_start (va, dummy);
-	attrs = gck_attributes_new_valist (NULL, va);
-	va_end (va);
-
-	return attrs;
-}
-
-DEFINE_TEST(new_valist_attributes)
-{
-	GckAttributes *attrs;
-	GDate *date = g_date_new_dmy (11, 12, 2008);
-
-	attrs = help_attributes_valist (232434243, /* Not used */
-	                                0UL, GCK_BOOLEAN, TRUE,
-	                                101UL, GCK_ULONG, 888UL,
-	                                202UL, GCK_STRING, "string",
-	                                303UL, GCK_DATE, date,
-	                                404UL, N_ATTR_DATA, ATTR_DATA,
-	                                GCK_INVALID);
-
-	g_date_free (date);
-	test_attributes_contents (attrs, FALSE);
-	gck_attributes_unref (attrs);
-}
-
-#if 0
-DEFINE_ABORT(bad_length)
-{
-	GckAttributes *attrs;
-
-	/* We should catch this with a warning */
-	attrs = gck_attributes_newv (1UL, G_MAXSSIZE + 500U, GCK_ULONG, "invalid data",
-	                              GCK_INVALID);
-
-	gck_attributes_unref (attrs);
-}
-#endif
-
 DEFINE_TEST(add_data_attributes)
 {
 	GckAttributes *attrs;
@@ -457,7 +393,6 @@ DEFINE_TEST(add_attributes)
 	gck_attribute_init_ulong (&attr, 101UL, 888);
 	gck_attributes_add (attrs, &attr);
 	gck_attribute_clear (&attr);
-
 	gck_attribute_init_string (&attr, 202UL, "string");
 	gck_attributes_add (attrs, &attr);
 	gck_attribute_clear (&attr);
@@ -492,13 +427,12 @@ DEFINE_TEST(find_attributes)
 	gulong uvalue;
 	gchar *svalue;
 
-	GckAttributes *attrs;
-	attrs = gck_attributes_newv (0UL, GCK_BOOLEAN, TRUE,
-	                              101UL, GCK_ULONG, 888UL,
-	                              202UL, GCK_STRING, "string",
-	                              303UL, GCK_DATE, date,
-	                              404UL, N_ATTR_DATA, ATTR_DATA,
-	                              GCK_INVALID);
+	GckAttributes *attrs = gck_attributes_new ();
+	gck_attributes_add_boolean (attrs, 0UL, TRUE);
+	gck_attributes_add_ulong (attrs, 101UL, 888UL);
+	gck_attributes_add_string (attrs, 202UL, "string");
+	gck_attributes_add_date (attrs, 303UL, date);
+	gck_attributes_add_data (attrs, 404UL, ATTR_DATA, N_ATTR_DATA);
 
 	attr = gck_attributes_find (attrs, 404);
 	g_assert (attr != NULL);
diff --git a/gck/tests/test-gck-crypto.c b/gck/tests/test-gck-crypto.c
index 9e6018c..e0232d2 100644
--- a/gck/tests/test-gck-crypto.c
+++ b/gck/tests/test-gck-crypto.c
@@ -51,11 +51,15 @@ static GckObject*
 find_key (GckSession *session, CK_ATTRIBUTE_TYPE method, CK_MECHANISM_TYPE mech)
 {
 	GList *objects, *l;
+	GckAttributes *attrs;
 	GckObject *object = NULL;
 	CK_MECHANISM_TYPE_PTR mechs;
 	gsize n_mechs;
 
-	objects = gck_session_find_objects (session, NULL, method, GCK_BOOLEAN, TRUE, GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_boolean (attrs, method, TRUE);
+	objects = gck_session_find_objects (session, attrs, NULL, NULL);
+	gck_attributes_unref (attrs);
 	g_assert (objects);
 
 	for (l = objects; l; l = g_list_next (l)) {
@@ -80,9 +84,13 @@ static GckObject*
 find_key_with_value (GckSession *session, const gchar *value)
 {
 	GList *objects;
+	GckAttributes *attrs;
 	GckObject *object;
 
-	objects = gck_session_find_objects (session, NULL, CKA_VALUE, GCK_STRING, value, GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_string (attrs, CKA_VALUE, value);
+	objects = gck_session_find_objects (session, attrs, NULL, NULL);
+	gck_attributes_unref (attrs);
 	g_assert (objects);
 
 	object = g_object_ref (objects->data);
@@ -483,18 +491,11 @@ DEFINE_TEST(unwrap_key)
 
 	mech = gck_mechanism_new_with_param (CKM_WRAP, "wrap", 4);
 	wrapper = find_key (session, CKA_UNWRAP, 0);
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_SECRET_KEY, GCK_INVALID);
-
-	/* Simple One */
-	unwrapped = gck_session_unwrap_key (session, wrapper, CKM_WRAP, "special", 7, &error,
-	                                     CKA_CLASS, GCK_ULONG, CKO_SECRET_KEY, GCK_INVALID);
-	SUCCESS_RES (unwrapped, error);
-	g_assert (GCK_IS_OBJECT (unwrapped));
-	check_key_with_value (session, unwrapped, CKO_SECRET_KEY, "special");
-	g_object_unref (unwrapped);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_SECRET_KEY);
 
 	/* Full One*/
-	unwrapped = gck_session_unwrap_key_full (session, wrapper, mech, "special", 7, attrs, NULL, &error);
+	unwrapped = gck_session_unwrap_key (session, wrapper, mech, "special", 7, attrs, NULL, &error);
 	SUCCESS_RES (unwrapped, error);
 	g_assert (GCK_IS_OBJECT (unwrapped));
 	check_key_with_value (session, unwrapped, CKO_SECRET_KEY, "special");
@@ -502,7 +503,7 @@ DEFINE_TEST(unwrap_key)
 
 	/* Failure one */
 	mech->type = 0;
-	unwrapped = gck_session_unwrap_key_full (session, wrapper, mech, "special", 7, attrs, NULL, &error);
+	unwrapped = gck_session_unwrap_key (session, wrapper, mech, "special", 7, attrs, NULL, &error);
 	FAIL_RES (unwrapped, error);
 
 	/* Asynchronous one */
@@ -542,18 +543,11 @@ DEFINE_TEST(derive_key)
 
 	mech = gck_mechanism_new_with_param (CKM_DERIVE, "derive", 6);
 	wrapper = find_key (session, CKA_DERIVE, 0);
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_SECRET_KEY, GCK_INVALID);
-
-	/* Simple One */
-	derived = gck_session_derive_key (session, wrapper, CKM_DERIVE, &error,
-	                                   CKA_CLASS, GCK_ULONG, CKO_SECRET_KEY, GCK_INVALID);
-	SUCCESS_RES (derived, error);
-	g_assert (GCK_IS_OBJECT (derived));
-	check_key_with_value (session, derived, CKO_SECRET_KEY, "derived");
-	g_object_unref (derived);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_SECRET_KEY);
 
 	/* Full One*/
-	derived = gck_session_derive_key_full (session, wrapper, mech, attrs, NULL, &error);
+	derived = gck_session_derive_key (session, wrapper, mech, attrs, NULL, &error);
 	SUCCESS_RES (derived, error);
 	g_assert (GCK_IS_OBJECT (derived));
 	check_key_with_value (session, derived, CKO_SECRET_KEY, "derived");
@@ -561,7 +555,7 @@ DEFINE_TEST(derive_key)
 
 	/* Failure one */
 	mech->type = 0;
-	derived = gck_session_derive_key_full (session, wrapper, mech, attrs, NULL, &error);
+	derived = gck_session_derive_key (session, wrapper, mech, attrs, NULL, &error);
 	FAIL_RES (derived, error);
 
 	/* Asynchronous one */
diff --git a/gck/tests/test-gck-module.c b/gck/tests/test-gck-module.c
index 6a3ebf9..955ae49 100644
--- a/gck/tests/test-gck-module.c
+++ b/gck/tests/test-gck-module.c
@@ -131,7 +131,7 @@ DEFINE_TEST(module_enumerate)
 	modules = g_list_prepend (NULL, g_object_ref (module));
 
 	attrs = gck_attributes_new ();
-	ret = gck_modules_enumerate_objects_full (modules, attrs, 0, NULL, for_first_object, "first", NULL);
+	ret = gck_modules_enumerate_objects (modules, attrs, 0, NULL, for_first_object, "first", NULL);
 	g_assert (ret);
 	g_assert_cmpint (n_objects, ==, 1);
 	g_assert (GCK_IS_OBJECT (last_object));
@@ -145,12 +145,13 @@ DEFINE_TEST(module_enumerate)
 	last_object = NULL;
 	n_objects = 0;
 
-	ret = gck_modules_enumerate_objects (modules, for_each_object, "blah",
-	                                     CKA_CLASS, GCK_ULONG, CKO_PRIVATE_KEY,
-	                                     GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PRIVATE_KEY);
+	ret = gck_modules_enumerate_objects (modules, attrs, 0, NULL, for_each_object, "blah", NULL);
 	g_assert (ret);
 	g_assert_cmpint (n_objects, ==, 2);
 	g_assert (GCK_IS_OBJECT (last_object));
+	gck_attributes_unref (attrs);
 
 	session = gck_object_get_session (last_object);
 	g_assert (GCK_IS_SESSION (session));
diff --git a/gck/tests/test-gck-object.c b/gck/tests/test-gck-object.c
index b552529..c6e5da4 100644
--- a/gck/tests/test-gck-object.c
+++ b/gck/tests/test-gck-object.c
@@ -110,37 +110,18 @@ DEFINE_TEST(create_object)
 	CK_OBJECT_HANDLE last_handle;
 	GError *err = NULL;
 
-	/* Using simple */
-	object = gck_session_create_object (session, &err,
-	                                     CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                     CKA_LABEL, GCK_STRING, "TEST LABEL",
-	                                     CKA_TOKEN, GCK_BOOLEAN, CK_FALSE,
-	                                     CKA_VALUE, 4UL, "BLAH",
-	                                     GCK_INVALID);
-	SUCCESS_RES (object, err);
-	g_assert (GCK_IS_OBJECT (object));
-
-	if (object) {
-		last_handle = gck_object_get_handle (object);
-		g_object_unref (object);
-	}
-
-	/* Using full */
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                              CKA_LABEL, GCK_STRING, "TEST LABEL",
-	                              CKA_TOKEN, GCK_BOOLEAN, CK_FALSE,
-	                              CKA_VALUE, 4UL, "BLAH",
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "TEST LABEL");
+	gck_attributes_add_boolean (attrs, CKA_TOKEN, CK_FALSE);
+	gck_attributes_add_data (attrs, CKA_VALUE, "BLAH", 4);
 
-	object = gck_session_create_object_full (session, attrs, NULL, &err);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	g_assert (GCK_IS_OBJECT (object));
 	SUCCESS_RES (object, err);
 
-	if (object) {
-		g_assert (last_handle != gck_object_get_handle (object));
-		last_handle = gck_object_get_handle (object);
-		g_object_unref (object);
-	}
+	last_handle = gck_object_get_handle (object);
+	g_object_unref (object);
 
 	/* Using async */
 	gck_session_create_object_async (session, attrs, NULL, fetch_async_result, &result);
@@ -152,62 +133,48 @@ DEFINE_TEST(create_object)
 	SUCCESS_RES (object, err);
 	g_assert (GCK_IS_OBJECT (object));
 
-	if (object)
-		g_object_unref (object);
+	g_assert (last_handle != gck_object_get_handle (object));
+	g_object_unref (object);
+
 	gck_attributes_unref (attrs);
 }
 
 DEFINE_TEST(destroy_object)
 {
 	GAsyncResult *result = NULL;
+	GckAttributes *attrs;
 	GckObject *object;
 	GError *err = NULL;
 	gboolean ret;
 
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "TEST OBJECT");
+	gck_attributes_add_boolean (attrs, CKA_TOKEN, CK_TRUE);
+
 	/* Using simple */
-	object = gck_session_create_object (session, &err,
-	                                     CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                     CKA_LABEL, GCK_STRING, "TEST OBJECT",
-	                                     CKA_TOKEN, GCK_BOOLEAN, CK_TRUE,
-	                                     GCK_INVALID);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	SUCCESS_RES (object, err);
 	g_assert (GCK_IS_OBJECT (object));
 
-	if (!object)
-		return;
-
 	ret = gck_object_destroy (object, &err);
 	SUCCESS_RES (ret, err);
 	g_object_unref (object);
 
 	/* Using full */
-	object = gck_session_create_object (session, &err,
-	                                     CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                     CKA_LABEL, GCK_STRING, "TEST OBJECT",
-	                                     CKA_TOKEN, GCK_BOOLEAN, CK_TRUE,
-	                                     GCK_INVALID);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	SUCCESS_RES (object, err);
 	g_assert (GCK_IS_OBJECT (object));
 
-	if (!object)
-		return;
-
 	ret = gck_object_destroy_full (object, NULL, &err);
 	SUCCESS_RES (ret, err);
 	g_object_unref (object);
 
 	/* Using async */
-	object = gck_session_create_object (session, &err,
-	                                     CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                     CKA_LABEL, GCK_STRING, "TEST OBJECT",
-	                                     CKA_TOKEN, GCK_BOOLEAN, CK_TRUE,
-	                                     GCK_INVALID);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	SUCCESS_RES (object, err);
 	g_assert (GCK_IS_OBJECT (object));
 
-	if (!object)
-		return;
-
 	/* Using async */
 	gck_object_destroy_async (object, NULL, fetch_async_result, &result);
 	testing_wait_until (500);
@@ -317,26 +284,12 @@ DEFINE_TEST(set_attributes)
 	gchar *value = NULL;
 	gboolean ret;
 
-	/* Simple */
-	ret = gck_object_set (object, &err,
-	                       CKA_CLASS, GCK_ULONG, 5,
-	                       CKA_LABEL, GCK_STRING, "CHANGE ONE",
-	                       GCK_INVALID);
-	SUCCESS_RES (ret, err);
-	if (ret) {
-		attrs = gck_object_get (object, &err, CKA_CLASS, CKA_LABEL, GCK_INVALID);
-		g_assert (gck_attributes_find_ulong (attrs, CKA_CLASS, &klass) && klass == 5);
-		g_assert (gck_attributes_find_string (attrs, CKA_LABEL, &value) && strcmp (value, "CHANGE ONE") == 0);
-		g_free (value); value = NULL;
-		gck_attributes_unref (attrs);
-	}
-
-	templ = gck_attributes_newv (CKA_CLASS, GCK_ULONG, 6,
-	                              CKA_LABEL, GCK_STRING, "CHANGE TWO",
-	                              GCK_INVALID);
+	templ = gck_attributes_new ();
+	gck_attributes_add_ulong (templ, CKA_CLASS, 6);
+	gck_attributes_add_string (templ, CKA_LABEL, "CHANGE TWO");
 
 	/* Full */
-	ret = gck_object_set_full (object, templ, NULL, &err);
+	ret = gck_object_set (object, templ, NULL, &err);
 	gck_attributes_unref (templ);
 	SUCCESS_RES (ret, err);
 	if (ret) {
@@ -347,9 +300,9 @@ DEFINE_TEST(set_attributes)
 		gck_attributes_unref (attrs);
 	}
 
-	templ = gck_attributes_newv (CKA_CLASS, GCK_ULONG, 7,
-	                              CKA_LABEL, GCK_STRING, "CHANGE THREE",
-	                              GCK_INVALID);
+	templ = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, 7);
+	gck_attributes_add_string (attrs, CKA_LABEL, "CHANGE THREE");
 
 	/* Async */
 	gck_object_set_async (object, templ, NULL, fetch_async_result, &result);
@@ -371,32 +324,36 @@ DEFINE_TEST(set_attributes)
 DEFINE_TEST(find_objects)
 {
 	GAsyncResult *result = NULL;
-	GckAttributes *templ;
+	GckAttributes *templ, *attrs;
 	GList *objects;
 	GckObject *testobj;
 	GError *err = NULL;
 
-	testobj = gck_session_create_object (session, &err,
-	                                      CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                      CKA_LABEL, GCK_STRING, "UNIQUE LABEL",
-	                                      GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "UNIQUE LABEL");
+	testobj = gck_session_create_object (session, attrs, NULL, &err);
+	gck_attributes_unref (attrs);
 	g_object_unref (testobj);
 
-	testobj = gck_session_create_object (session, &err,
-	                                      CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                                      CKA_LABEL, GCK_STRING, "OTHER LABEL",
-	                                      GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "OTHER LABEL");
+	gck_attributes_unref (attrs);
 	g_object_unref (testobj);
 
 	/* Simple, "TEST LABEL" */
-	objects = gck_session_find_objects (session, &err, CKA_LABEL, GCK_STRING, "UNIQUE LABEL", GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_string (attrs, CKA_LABEL, "UNIQUE LABEL");
+	objects = gck_session_find_objects (session, attrs, NULL, &err);
 	SUCCESS_RES (objects, err);
 	g_assert (g_list_length (objects) == 1);
 	gck_list_unref_free (objects);
+	gck_attributes_unref (attrs);
 
 	/* Full, All */
 	templ = gck_attributes_new ();
-	objects = gck_session_find_objects_full (session, templ, NULL, &err);
+	objects = gck_session_find_objects (session, templ, NULL, &err);
 	SUCCESS_RES (objects, err);
 	g_assert (g_list_length (objects) > 1);
 	gck_list_unref_free (objects);
diff --git a/gck/tests/test-gck-session.c b/gck/tests/test-gck-session.c
index ed00f32..d60931d 100644
--- a/gck/tests/test-gck-session.c
+++ b/gck/tests/test-gck-session.c
@@ -202,13 +202,13 @@ DEFINE_TEST(auto_login)
 	gboolean ret;
 	gint value;
 
-	attrs = gck_attributes_newv (CKA_CLASS, GCK_ULONG, CKO_DATA,
-	                              CKA_LABEL, GCK_STRING, "TEST OBJECT",
-	                              CKA_PRIVATE, GCK_BOOLEAN, CK_TRUE,
-	                              GCK_INVALID);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_DATA);
+	gck_attributes_add_string (attrs, CKA_LABEL, "TEST OBJECT");
+	gck_attributes_add_boolean (attrs, CKA_PRIVATE, CK_TRUE);
 
 	/* Try to do something that requires a login */
-	object = gck_session_create_object_full (session, attrs, NULL, &err);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	g_assert (!object);
 	g_assert (err && err->code == CKR_USER_NOT_LOGGED_IN);
 	g_clear_error (&err);
@@ -228,7 +228,7 @@ DEFINE_TEST(auto_login)
 	g_object_unref (new_session);
 
 	/* Try again to do something that requires a login */
-	object = gck_session_create_object_full (session, attrs, NULL, &err);
+	object = gck_session_create_object (session, attrs, NULL, &err);
 	SUCCESS_RES (object, err);
 	g_object_unref (object);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]