All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] key: Add cert chain validation capability to keyring
@ 2016-10-21 20:52 Mat Martineau
  2016-10-21 20:52 ` [PATCH 2/4] unit: Update certificate generation script Mat Martineau
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mat Martineau @ 2016-10-21 20:52 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 2252 bytes --]

Verifying certificate chains was a little awkward using the
L_KEYRING_TRUSTED_ASYM keyring type, which required verifying the
signature and then separately adding the verified certificate to the
"trusted" keyring.

With L_KEYRING_TRUSTED_ASYM_CHAIN, the destination keyring is also
searched for signing keys.

One use model is to have two keyrings:

 1. trust_keyring: contains long-lived root and intermediate CA certs.
 2. verify_keyring: an L_KEYRING_TRUSTED_ASYM_CHAIN keyring that
                    is created with "trust_keyring" referenced for
		    trusted certificates.

In order to validate new certificates, they are added to verify_keyring
in series, starting with certs that are signed by those in
trust_keyring. Once an intermediate CA cert is added to verify_keyring,
certs signed by that intermediate CA can also be added to verify_keyring.
---
 ell/key.c | 22 ++++++++++++++++------
 ell/key.h |  3 ++-
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/ell/key.c b/ell/key.c
index fc20d29..4cf2307 100644
--- a/ell/key.c
+++ b/ell/key.c
@@ -653,15 +653,25 @@ LIB_EXPORT struct l_keyring *l_keyring_new(enum l_keyring_type type,
 	if (!internal_keyring && !setup_internal_keyring())
 		return NULL;
 
-	if (type == L_KEYRING_TRUSTED_ASYM) {
-		if (!trusted)
-			return NULL;
+	switch (type) {
+	case L_KEYRING_SIMPLE:
+		break;
+	case L_KEYRING_TRUSTED_ASYM:
+	case L_KEYRING_TRUSTED_ASYM_CHAIN:
+	{
+		char *option = "";
+
+		if (type == L_KEYRING_TRUSTED_ASYM_CHAIN)
+			option = ":chain";
 
 		payload = l_strdup_printf(
-			"restrict=asymmetric:key_or_keyring:%d",
-			trusted->serial);
+			"restrict=asymmetric:key_or_keyring:%d%s",
+			trusted ? trusted->serial : 0, option);
 		payload_length = strlen(payload);
-	} else if (type != L_KEYRING_SIMPLE) {
+
+		break;
+	}
+	default:
 		/* Unsupported type */
 		return NULL;
 	}
diff --git a/ell/key.h b/ell/key.h
index ff4b543..e7036c6 100644
--- a/ell/key.h
+++ b/ell/key.h
@@ -42,7 +42,8 @@ enum l_key_type {
 
 enum l_keyring_type {
 	L_KEYRING_SIMPLE = 0,
-	L_KEYRING_TRUSTED_ASYM
+	L_KEYRING_TRUSTED_ASYM,
+	L_KEYRING_TRUSTED_ASYM_CHAIN,
 };
 
 enum l_key_cipher_type {
-- 
2.10.1


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

end of thread, other threads:[~2016-10-24 16:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-21 20:52 [PATCH 1/4] key: Add cert chain validation capability to keyring Mat Martineau
2016-10-21 20:52 ` [PATCH 2/4] unit: Update certificate generation script Mat Martineau
2016-10-21 20:52 ` [PATCH 3/4] unit: New certificates for intermediate CA testing Mat Martineau
2016-10-21 20:52 ` [PATCH 4/4] unit: Add L_KEYRING_TRUSTED_ASYM_CHAIN test Mat Martineau
2016-10-24 16:01 ` [PATCH 1/4] key: Add cert chain validation capability to keyring Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.