static void dump_object (P11KitIter *iter, CK_ATTRIBUTE *attrs) { CK_ATTRIBUTE label = { CKA_LABEL, }; CK_ATTRIBUTE *attr; char *string; char *name; CK_RV rv; attr = p11_attrs_find_valid (attrs, CKA_LABEL); if (!attr) { rv = p11_kit_iter_load_attributes (iter, &label, 1); if (rv == CKR_OK) attr = &label; } if (attr) name = strndup (attr->pValue, attr->ulValueLen); else name = strdup ("unknown"); string = p11_attrs_to_string (attrs, -1); printf ("\"%s\" = %s\n", name, string); free (string); free (label.pValue); free (name); }
static const char * description_for_object_at_iter (p11_kit_iter *iter) { CK_OBJECT_CLASS klass; CK_ATTRIBUTE attrs[] = { { CKA_CLASS, &klass, sizeof (klass) }, { CKA_INVALID }, }; const char *desc = "object"; CK_RV rv; rv = p11_kit_iter_load_attributes (iter, attrs, 1); if (rv == CKR_OK) desc = p11_constant_nick (p11_constant_classes, klass); return desc; }