KEYS: validate certificate trust only with selected key
authorDmitry Kasatkin <d.kasatkin@samsung.com>
Tue, 17 Jun 2014 08:56:58 +0000 (11:56 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Thu, 17 Jul 2014 13:35:16 +0000 (09:35 -0400)
Instead of allowing public keys, with certificates signed by any
key on the system trusted keyring, to be added to a trusted keyring,
this patch further restricts the certificates to those signed by a
particular key on the system keyring.

This patch defines a new kernel parameter 'ca_keys' to identify the
specific key which must be used for trust validation of certificates.

Simplified Mimi's "KEYS: define an owner trusted keyring" patch.

Changelog:
- support for builtin x509 public keys only
- export "asymmetric_keyid_match"
- remove ifndefs MODULE
- rename kernel boot parameter from keys_ownerid to ca_keys

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Documentation/kernel-parameters.txt
crypto/asymmetric_keys/asymmetric_type.c
crypto/asymmetric_keys/x509_public_key.c

index 8b2ab548b6e42ef9657a5bc7f004d04abfe5ad10..bdb193afe176fc845c4b805ed6973d4872c8fe4e 100644 (file)
@@ -566,6 +566,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        possible to determine what the correct size should be.
                        This option provides an override for these situations.
 
+       ca_keys=        [KEYS] This parameter identifies a specific key(s) on
+                       the system trusted keyring to be used for certificate
+                       trust validation.
+                       format: id:<keyid>
+
        ccw_timeout_log [S390]
                        See Documentation/s390/CommonIO for details.
 
index 1fd1d304a15a52f1a9e2da92073597911dfe363e..c948df5c4ecd1c66b911cccefee624942179ea62 100644 (file)
@@ -49,6 +49,7 @@ int asymmetric_keyid_match(const char *kid, const char *id)
 
        return 1;
 }
+EXPORT_SYMBOL_GPL(asymmetric_keyid_match);
 
 /*
  * Match asymmetric keys on (part of) their name
index 436fbd8552fc4c06ffc8b1464bb1b3fa18e2d253..d376195e1d08a3f1f9a65aadeb7f095f711ad4a2 100644 (file)
 #include "public_key.h"
 #include "x509_parser.h"
 
+static char *ca_keyid;
+
+#ifndef MODULE
+static int __init ca_keys_setup(char *str)
+{
+       if (!str)               /* default system keyring */
+               return 1;
+
+       if (strncmp(str, "id:", 3) == 0)
+               ca_keyid = str; /* owner key 'id:xxxxxx' */
+
+       return 1;
+}
+__setup("ca_keys=", ca_keys_setup);
+#endif
+
 /*
  * Find a key in the given keyring by issuer and authority.
  */
@@ -171,6 +187,9 @@ static int x509_validate_trust(struct x509_certificate *cert,
        if (!trust_keyring)
                return -EOPNOTSUPP;
 
+       if (ca_keyid && !asymmetric_keyid_match(cert->authority, ca_keyid))
+               return -EPERM;
+
        key = x509_request_asymmetric_key(trust_keyring,
                                          cert->issuer, strlen(cert->issuer),
                                          cert->authority,