diff options
author | Dmitry Kasatkin <d.kasatkin@samsung.com> | 2014-06-17 04:56:58 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2014-07-17 09:35:16 -0400 |
commit | ffb70f61bab1482a3bd0f85fd8f1e9c9909df2ca (patch) | |
tree | f25c90a65af6441434dd70dcaacb7d204b6ea00b /crypto | |
parent | b3426827c848d252ed4ca5f4d3085551be083e12 (diff) |
KEYS: validate certificate trust only with selected key
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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asymmetric_keys/asymmetric_type.c | 1 | ||||
-rw-r--r-- | crypto/asymmetric_keys/x509_public_key.c | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c index 1fd1d304a15a..c948df5c4ecd 100644 --- a/crypto/asymmetric_keys/asymmetric_type.c +++ b/crypto/asymmetric_keys/asymmetric_type.c | |||
@@ -49,6 +49,7 @@ int asymmetric_keyid_match(const char *kid, const char *id) | |||
49 | 49 | ||
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | EXPORT_SYMBOL_GPL(asymmetric_keyid_match); | ||
52 | 53 | ||
53 | /* | 54 | /* |
54 | * Match asymmetric keys on (part of) their name | 55 | * Match asymmetric keys on (part of) their name |
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c index 436fbd8552fc..d376195e1d08 100644 --- a/crypto/asymmetric_keys/x509_public_key.c +++ b/crypto/asymmetric_keys/x509_public_key.c | |||
@@ -24,6 +24,22 @@ | |||
24 | #include "public_key.h" | 24 | #include "public_key.h" |
25 | #include "x509_parser.h" | 25 | #include "x509_parser.h" |
26 | 26 | ||
27 | static char *ca_keyid; | ||
28 | |||
29 | #ifndef MODULE | ||
30 | static int __init ca_keys_setup(char *str) | ||
31 | { | ||
32 | if (!str) /* default system keyring */ | ||
33 | return 1; | ||
34 | |||
35 | if (strncmp(str, "id:", 3) == 0) | ||
36 | ca_keyid = str; /* owner key 'id:xxxxxx' */ | ||
37 | |||
38 | return 1; | ||
39 | } | ||
40 | __setup("ca_keys=", ca_keys_setup); | ||
41 | #endif | ||
42 | |||
27 | /* | 43 | /* |
28 | * Find a key in the given keyring by issuer and authority. | 44 | * Find a key in the given keyring by issuer and authority. |
29 | */ | 45 | */ |
@@ -171,6 +187,9 @@ static int x509_validate_trust(struct x509_certificate *cert, | |||
171 | if (!trust_keyring) | 187 | if (!trust_keyring) |
172 | return -EOPNOTSUPP; | 188 | return -EOPNOTSUPP; |
173 | 189 | ||
190 | if (ca_keyid && !asymmetric_keyid_match(cert->authority, ca_keyid)) | ||
191 | return -EPERM; | ||
192 | |||
174 | key = x509_request_asymmetric_key(trust_keyring, | 193 | key = x509_request_asymmetric_key(trust_keyring, |
175 | cert->issuer, strlen(cert->issuer), | 194 | cert->issuer, strlen(cert->issuer), |
176 | cert->authority, | 195 | cert->authority, |