linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] libkmod-module: do not crash modinfo on 0 key id len
@ 2016-06-05  3:13 Lucas De Marchi
  2016-06-05  3:13 ` [PATCH 2/3] libkmod-signature: handle PKCS#7 Lucas De Marchi
  2016-06-05  3:13 ` [PATCH 3/3] libkmod-module: modinfo: print signature id Lucas De Marchi
  0 siblings, 2 replies; 3+ messages in thread
From: Lucas De Marchi @ 2016-06-05  3:13 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Marek, Wouter van Kesteren, Lucas De Marchi

From: Lucas De Marchi <lucas.demarchi@intel.com>

---
 libkmod/libkmod-module.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 1460c67..a19e8bc 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2253,22 +2253,30 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
 			goto list_error;
 		count++;
 
-		/* Display the key id as 01:12:DE:AD:BE:EF:... */
-		key_hex = malloc(sig_info.key_id_len * 3);
-		if (key_hex == NULL)
-			goto list_error;
-		for (i = 0; i < (int)sig_info.key_id_len; i++) {
-			sprintf(key_hex + i * 3, "%02X",
-					(unsigned char)sig_info.key_id[i]);
-			if (i < (int)sig_info.key_id_len - 1)
-				key_hex[i * 3 + 2] = ':';
+		if (sig_info.key_id_len) {
+			/* Display the key id as 01:12:DE:AD:BE:EF:... */
+			key_hex = malloc(sig_info.key_id_len * 3);
+			if (key_hex == NULL)
+				goto list_error;
+			for (i = 0; i < (int)sig_info.key_id_len; i++) {
+				sprintf(key_hex + i * 3, "%02X",
+						(unsigned char)sig_info.key_id[i]);
+				if (i < (int)sig_info.key_id_len - 1)
+					key_hex[i * 3 + 2] = ':';
+			}
+			n = kmod_module_info_append(list, "sig_key", strlen("sig_key"),
+					key_hex, sig_info.key_id_len * 3 - 1);
+			free(key_hex);
+			if (n == NULL)
+				goto list_error;
+			count++;
+		} else {
+			n = kmod_module_info_append(list, "sig_key", strlen("sig_key"),
+					NULL, 0);
+			if (n == NULL)
+				goto list_error;
+			count++;
 		}
-		n = kmod_module_info_append(list, "sig_key", strlen("sig_key"),
-				key_hex, sig_info.key_id_len * 3 - 1);
-		free(key_hex);
-		if (n == NULL)
-			goto list_error;
-		count++;
 
 		n = kmod_module_info_append(list,
 				"sig_hashalgo", strlen("sig_hashalgo"),
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] libkmod-signature: handle PKCS#7
  2016-06-05  3:13 [PATCH 1/3] libkmod-module: do not crash modinfo on 0 key id len Lucas De Marchi
@ 2016-06-05  3:13 ` Lucas De Marchi
  2016-06-05  3:13 ` [PATCH 3/3] libkmod-module: modinfo: print signature id Lucas De Marchi
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2016-06-05  3:13 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Marek, Wouter van Kesteren, Lucas De Marchi

From: Lucas De Marchi <lucas.demarchi@intel.com>

---
 libkmod/libkmod-signature.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
index 6fc06fc..ef5fe6e 100644
--- a/libkmod/libkmod-signature.c
+++ b/libkmod/libkmod-signature.c
@@ -69,12 +69,14 @@ const char *const pkey_hash_algo[PKEY_HASH__LAST] = {
 enum pkey_id_type {
 	PKEY_ID_PGP,		/* OpenPGP generated key ID */
 	PKEY_ID_X509,		/* X.509 arbitrary subjectKeyIdentifier */
+	PKEY_ID_PKCS7,		/* Signature in PKCS#7 message */
 	PKEY_ID_TYPE__LAST
 };
 
 const char *const pkey_id_type[PKEY_ID_TYPE__LAST] = {
 	[PKEY_ID_PGP]		= "PGP",
 	[PKEY_ID_X509]		= "X509",
+	[PKEY_ID_PKCS7]		= "PKCS#7",
 };
 
 /*
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] libkmod-module: modinfo: print signature id
  2016-06-05  3:13 [PATCH 1/3] libkmod-module: do not crash modinfo on 0 key id len Lucas De Marchi
  2016-06-05  3:13 ` [PATCH 2/3] libkmod-signature: handle PKCS#7 Lucas De Marchi
@ 2016-06-05  3:13 ` Lucas De Marchi
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2016-06-05  3:13 UTC (permalink / raw)
  To: linux-modules; +Cc: Michal Marek, Wouter van Kesteren, Lucas De Marchi

From: Lucas De Marchi <lucas.demarchi@intel.com>

This way it's possible to give at least the signature type for PKCS#7.
---
 libkmod/libkmod-module.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index a19e8bc..39a081d 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2247,6 +2247,12 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
 		struct kmod_list *n;
 		char *key_hex;
 
+		n = kmod_module_info_append(list, "signature", strlen("sig_id"),
+				sig_info.id_type, strlen(sig_info.id_type));
+		if (n == NULL)
+			goto list_error;
+		count++;
+
 		n = kmod_module_info_append(list, "signer", strlen("signer"),
 				sig_info.signer, sig_info.signer_len);
 		if (n == NULL)
@@ -2286,7 +2292,7 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, struct kmod_
 		count++;
 
 		/*
-		 * Omit sig_info.id_type and sig_info.algo for now, as these
+		 * Omit sig_info.algo for now, as these
 		 * are currently constant.
 		 */
 	}
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-05  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-05  3:13 [PATCH 1/3] libkmod-module: do not crash modinfo on 0 key id len Lucas De Marchi
2016-06-05  3:13 ` [PATCH 2/3] libkmod-signature: handle PKCS#7 Lucas De Marchi
2016-06-05  3:13 ` [PATCH 3/3] libkmod-module: modinfo: print signature id Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).