summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-15 19:38:01 +0100
committerStef Walter <stefw@gnome.org>2013-03-15 19:38:01 +0100
commit57e835d55f6eae39c25b97e35efe0cb58e46b897 (patch)
tree7437615eec67552eb345e84c3ef793fac7a959a9 /common
parent7fd74a78fcad81227be3650239669bca5851a1db (diff)
trust: Update frob-nss-tool so it can compare modules for trust info
Can run with two modules now so that it can compare tokens NSS trust info.
Diffstat (limited to 'common')
-rw-r--r--common/attrs.c23
-rw-r--r--common/attrs.h2
2 files changed, 25 insertions, 0 deletions
diff --git a/common/attrs.c b/common/attrs.c
index 62b35cd..0b8032c 100644
--- a/common/attrs.c
+++ b/common/attrs.c
@@ -380,6 +380,7 @@ p11_attrs_findn_valid (CK_ATTRIBUTE *attrs,
return NULL;
}
+
bool
p11_attrs_remove (CK_ATTRIBUTE *attrs,
CK_ATTRIBUTE_TYPE type)
@@ -404,6 +405,28 @@ p11_attrs_remove (CK_ATTRIBUTE *attrs,
return true;
}
+void
+p11_attrs_purge (CK_ATTRIBUTE *attrs)
+{
+ int in, out;
+
+ for (in = 0, out = 0; !p11_attrs_is_empty (attrs + in); in++) {
+ if (attrs[in].ulValueLen == (CK_ULONG)-1) {
+ free (attrs[in].pValue);
+ attrs[in].pValue = NULL;
+ attrs[in].ulValueLen = 0;
+ } else {
+ if (in != out)
+ memcpy (attrs + out, attrs + in, sizeof (CK_ATTRIBUTE));
+ out++;
+ }
+ }
+
+ attrs[out].type = CKA_INVALID;
+ assert (p11_attrs_is_empty (attrs + out));
+
+}
+
bool
p11_attrs_match (const CK_ATTRIBUTE *attrs,
const CK_ATTRIBUTE *match)
diff --git a/common/attrs.h b/common/attrs.h
index 4e3f46c..619403d 100644
--- a/common/attrs.h
+++ b/common/attrs.h
@@ -59,6 +59,8 @@ CK_ATTRIBUTE * p11_attrs_merge (CK_ATTRIBUTE *attrs,
CK_ATTRIBUTE *merge,
bool replace);
+void p11_attrs_purge (CK_ATTRIBUTE *attrs);
+
bool p11_attrs_is_empty (const CK_ATTRIBUTE *attrs);
CK_ULONG p11_attrs_count (const CK_ATTRIBUTE *attrs);