From bc60631d3e327fd97f53c68c5b3134e4cefad7e1 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 13 Jan 2014 18:02:44 +0100 Subject: iter: Add p11_kit_iter_get_attributes() function A simple wrapper for C_GetAttributeValue() --- p11-kit/iter.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'p11-kit/iter.c') diff --git a/p11-kit/iter.c b/p11-kit/iter.c index 6a3ad4a..b6861a5 100644 --- a/p11-kit/iter.c +++ b/p11-kit/iter.c @@ -749,6 +749,41 @@ p11_kit_iter_destroy_object (P11KitIter *iter) } /** + * p11_kit_iter_get_attributes: + * @iter: the iterator + * @template: (array length=count) (inout): the attributes to get + * @count: the number of attributes + * + * Get attributes for the current matching object. + * + * This calls C_GetAttributeValue for the object + * currently iterated to. Return value and attribute memory behavior + * is identical to the PKCS\#11 C_GetAttributeValue + * function. + * + * You might choose to use p11_kit_iter_load_attributes() for a more + * helpful variant. + * + * This can only be called after p11_kit_iter_next() succeeds. + * + * Returns: The result from C_GetAttributeValue. + */ +CK_RV +p11_kit_iter_get_attributes (P11KitIter *iter, + CK_ATTRIBUTE *template, + CK_ULONG count) +{ + return_val_if_fail (iter != NULL, CKR_GENERAL_ERROR); + return_val_if_fail (iter->iterating, CKR_GENERAL_ERROR); + return_val_if_fail (iter->module != NULL, CKR_GENERAL_ERROR); + return_val_if_fail (iter->session != 0, CKR_GENERAL_ERROR); + return_val_if_fail (iter->object != 0, CKR_GENERAL_ERROR); + + return (iter->module->C_GetAttributeValue) (iter->session, iter->object, + template, count); +} + +/** * p11_kit_iter_load_attributes: * @iter: the iterator * @template: (array length=count) (inout): the attributes to load -- cgit v1.1