]> granicus.if.org Git - p11-kit/commitdiff
trust: Show public-key-info in 'trust list --details'
authorStef Walter <stef@thewalter.net>
Fri, 5 Sep 2014 13:46:51 +0000 (15:46 +0200)
committerStef Walter <stef@thewalter.net>
Fri, 5 Sep 2014 13:46:51 +0000 (15:46 +0200)
Since the public-key-info is an important part of the way we
represent trust, show it in 'trust list' if --details is present.

trust/list.c

index a7fa4d94cfde61f317888db1589dd4d074c84b07..c3f5759f6ab4af9183d419800495727c66e3e6be 100644 (file)
@@ -44,6 +44,7 @@
 #include "message.h"
 #include "pkcs11x.h"
 #include "tool.h"
+#include "url.h"
 
 #include "p11-kit/iter.h"
 
@@ -83,11 +84,13 @@ static bool
 list_iterate (p11_enumerate *ex,
               bool details)
 {
+       unsigned char *bytes;
        CK_OBJECT_HANDLE object;
        CK_ATTRIBUTE *attr;
        CK_ULONG klass;
        CK_ULONG category;
        CK_BBOOL val;
+       p11_buffer buf;
        CK_RV rv;
        const char *nick;
        char *string;
@@ -142,6 +145,17 @@ list_iterate (p11_enumerate *ex,
                                printf ("    category: %s\n", nick);
                }
 
+               if (details) {
+                       attr = p11_attrs_find_valid (ex->attrs, CKA_X_PUBLIC_KEY_INFO);
+                       if (attr) {
+                               p11_buffer_init (&buf, 1024);
+                               bytes = attr->pValue;
+                               p11_url_encode (bytes, bytes + attr->ulValueLen, "", &buf);
+                               printf ("    public-key-info: %.*s\n", (int)buf.len, (char *)buf.data);
+                               p11_buffer_uninit (&buf);
+                       }
+               }
+
                printf ("\n");
        }