diff options
author | David Howells <dhowells@redhat.com> | 2015-10-21 09:04:48 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2015-10-21 10:18:36 -0400 |
commit | 146aa8b1453bd8f1ff2304ffb71b4ee0eb9acdcc (patch) | |
tree | a89ef2cd2e8029b0c09a58739cca0e7e2e68f4db /crypto | |
parent | 4adc605edc5f744dcf432241b5996ff6a13d868c (diff) |
KEYS: Merge the type-specific data with the payload data
Merge the type-specific data with the payload data into one four-word chunk
as it seems pointless to keep them separate.
Use user_key_payload() for accessing the payloads of overloaded
user-defined keys.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-cifs@vger.kernel.org
cc: ecryptfs@vger.kernel.org
cc: linux-ext4@vger.kernel.org
cc: linux-f2fs-devel@lists.sourceforge.net
cc: linux-nfs@vger.kernel.org
cc: ceph-devel@vger.kernel.org
cc: linux-ima-devel@lists.sourceforge.net
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asymmetric_keys/asymmetric_keys.h | 5 | ||||
-rw-r--r-- | crypto/asymmetric_keys/asymmetric_type.c | 44 | ||||
-rw-r--r-- | crypto/asymmetric_keys/public_key.c | 4 | ||||
-rw-r--r-- | crypto/asymmetric_keys/signature.c | 2 | ||||
-rw-r--r-- | crypto/asymmetric_keys/x509_parser.h | 1 | ||||
-rw-r--r-- | crypto/asymmetric_keys/x509_public_key.c | 9 |
6 files changed, 35 insertions, 30 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_keys.h b/crypto/asymmetric_keys/asymmetric_keys.h index 3f5b537ab33e..1d450b580245 100644 --- a/crypto/asymmetric_keys/asymmetric_keys.h +++ b/crypto/asymmetric_keys/asymmetric_keys.h | |||
@@ -14,8 +14,3 @@ extern struct asymmetric_key_id *asymmetric_key_hex_to_key_id(const char *id); | |||
14 | extern int __asymmetric_key_hex_to_key_id(const char *id, | 14 | extern int __asymmetric_key_hex_to_key_id(const char *id, |
15 | struct asymmetric_key_id *match_id, | 15 | struct asymmetric_key_id *match_id, |
16 | size_t hexlen); | 16 | size_t hexlen); |
17 | static inline | ||
18 | const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key) | ||
19 | { | ||
20 | return key->type_data.p[1]; | ||
21 | } | ||
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c index 1916680ad81b..9f2165b27d52 100644 --- a/crypto/asymmetric_keys/asymmetric_type.c +++ b/crypto/asymmetric_keys/asymmetric_type.c | |||
@@ -307,25 +307,34 @@ static int asymmetric_key_preparse(struct key_preparsed_payload *prep) | |||
307 | } | 307 | } |
308 | 308 | ||
309 | /* | 309 | /* |
310 | * Clean up the key ID list | ||
311 | */ | ||
312 | static void asymmetric_key_free_kids(struct asymmetric_key_ids *kids) | ||
313 | { | ||
314 | int i; | ||
315 | |||
316 | if (kids) { | ||
317 | for (i = 0; i < ARRAY_SIZE(kids->id); i++) | ||
318 | kfree(kids->id[i]); | ||
319 | kfree(kids); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | /* | ||
310 | * Clean up the preparse data | 324 | * Clean up the preparse data |
311 | */ | 325 | */ |
312 | static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep) | 326 | static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep) |
313 | { | 327 | { |
314 | struct asymmetric_key_subtype *subtype = prep->type_data[0]; | 328 | struct asymmetric_key_subtype *subtype = prep->payload.data[asym_subtype]; |
315 | struct asymmetric_key_ids *kids = prep->type_data[1]; | 329 | struct asymmetric_key_ids *kids = prep->payload.data[asym_key_ids]; |
316 | int i; | ||
317 | 330 | ||
318 | pr_devel("==>%s()\n", __func__); | 331 | pr_devel("==>%s()\n", __func__); |
319 | 332 | ||
320 | if (subtype) { | 333 | if (subtype) { |
321 | subtype->destroy(prep->payload[0]); | 334 | subtype->destroy(prep->payload.data[asym_crypto]); |
322 | module_put(subtype->owner); | 335 | module_put(subtype->owner); |
323 | } | 336 | } |
324 | if (kids) { | 337 | asymmetric_key_free_kids(kids); |
325 | for (i = 0; i < ARRAY_SIZE(kids->id); i++) | ||
326 | kfree(kids->id[i]); | ||
327 | kfree(kids); | ||
328 | } | ||
329 | kfree(prep->description); | 338 | kfree(prep->description); |
330 | } | 339 | } |
331 | 340 | ||
@@ -335,20 +344,19 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep) | |||
335 | static void asymmetric_key_destroy(struct key *key) | 344 | static void asymmetric_key_destroy(struct key *key) |
336 | { | 345 | { |
337 | struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); | 346 | struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); |
338 | struct asymmetric_key_ids *kids = key->type_data.p[1]; | 347 | struct asymmetric_key_ids *kids = key->payload.data[asym_key_ids]; |
348 | void *data = key->payload.data[asym_crypto]; | ||
349 | |||
350 | key->payload.data[asym_crypto] = NULL; | ||
351 | key->payload.data[asym_subtype] = NULL; | ||
352 | key->payload.data[asym_key_ids] = NULL; | ||
339 | 353 | ||
340 | if (subtype) { | 354 | if (subtype) { |
341 | subtype->destroy(key->payload.data); | 355 | subtype->destroy(data); |
342 | module_put(subtype->owner); | 356 | module_put(subtype->owner); |
343 | key->type_data.p[0] = NULL; | ||
344 | } | 357 | } |
345 | 358 | ||
346 | if (kids) { | 359 | asymmetric_key_free_kids(kids); |
347 | kfree(kids->id[0]); | ||
348 | kfree(kids->id[1]); | ||
349 | kfree(kids); | ||
350 | key->type_data.p[1] = NULL; | ||
351 | } | ||
352 | } | 360 | } |
353 | 361 | ||
354 | struct key_type key_type_asymmetric = { | 362 | struct key_type key_type_asymmetric = { |
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index 81efccbe22d5..6db4c01c6503 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c | |||
@@ -49,7 +49,7 @@ EXPORT_SYMBOL_GPL(pkey_id_type_name); | |||
49 | static void public_key_describe(const struct key *asymmetric_key, | 49 | static void public_key_describe(const struct key *asymmetric_key, |
50 | struct seq_file *m) | 50 | struct seq_file *m) |
51 | { | 51 | { |
52 | struct public_key *key = asymmetric_key->payload.data; | 52 | struct public_key *key = asymmetric_key->payload.data[asym_crypto]; |
53 | 53 | ||
54 | if (key) | 54 | if (key) |
55 | seq_printf(m, "%s.%s", | 55 | seq_printf(m, "%s.%s", |
@@ -112,7 +112,7 @@ EXPORT_SYMBOL_GPL(public_key_verify_signature); | |||
112 | static int public_key_verify_signature_2(const struct key *key, | 112 | static int public_key_verify_signature_2(const struct key *key, |
113 | const struct public_key_signature *sig) | 113 | const struct public_key_signature *sig) |
114 | { | 114 | { |
115 | const struct public_key *pk = key->payload.data; | 115 | const struct public_key *pk = key->payload.data[asym_crypto]; |
116 | return public_key_verify_signature(pk, sig); | 116 | return public_key_verify_signature(pk, sig); |
117 | } | 117 | } |
118 | 118 | ||
diff --git a/crypto/asymmetric_keys/signature.c b/crypto/asymmetric_keys/signature.c index 7525fd183574..9441240f7d2a 100644 --- a/crypto/asymmetric_keys/signature.c +++ b/crypto/asymmetric_keys/signature.c | |||
@@ -37,7 +37,7 @@ int verify_signature(const struct key *key, | |||
37 | return -EINVAL; | 37 | return -EINVAL; |
38 | subtype = asymmetric_key_subtype(key); | 38 | subtype = asymmetric_key_subtype(key); |
39 | if (!subtype || | 39 | if (!subtype || |
40 | !key->payload.data) | 40 | !key->payload.data[0]) |
41 | return -EINVAL; | 41 | return -EINVAL; |
42 | if (!subtype->verify_signature) | 42 | if (!subtype->verify_signature) |
43 | return -ENOTSUPP; | 43 | return -ENOTSUPP; |
diff --git a/crypto/asymmetric_keys/x509_parser.h b/crypto/asymmetric_keys/x509_parser.h index 1de01eaec884..dbeed6018e63 100644 --- a/crypto/asymmetric_keys/x509_parser.h +++ b/crypto/asymmetric_keys/x509_parser.h | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <crypto/public_key.h> | 13 | #include <crypto/public_key.h> |
14 | #include <keys/asymmetric-type.h> | ||
14 | 15 | ||
15 | struct x509_certificate { | 16 | struct x509_certificate { |
16 | struct x509_certificate *next; | 17 | struct x509_certificate *next; |
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c index 197096632412..64d42981a8d7 100644 --- a/crypto/asymmetric_keys/x509_public_key.c +++ b/crypto/asymmetric_keys/x509_public_key.c | |||
@@ -266,7 +266,8 @@ static int x509_validate_trust(struct x509_certificate *cert, | |||
266 | if (!IS_ERR(key)) { | 266 | if (!IS_ERR(key)) { |
267 | if (!use_builtin_keys | 267 | if (!use_builtin_keys |
268 | || test_bit(KEY_FLAG_BUILTIN, &key->flags)) | 268 | || test_bit(KEY_FLAG_BUILTIN, &key->flags)) |
269 | ret = x509_check_signature(key->payload.data, cert); | 269 | ret = x509_check_signature(key->payload.data[asym_crypto], |
270 | cert); | ||
270 | key_put(key); | 271 | key_put(key); |
271 | } | 272 | } |
272 | return ret; | 273 | return ret; |
@@ -352,9 +353,9 @@ static int x509_key_preparse(struct key_preparsed_payload *prep) | |||
352 | 353 | ||
353 | /* We're pinning the module by being linked against it */ | 354 | /* We're pinning the module by being linked against it */ |
354 | __module_get(public_key_subtype.owner); | 355 | __module_get(public_key_subtype.owner); |
355 | prep->type_data[0] = &public_key_subtype; | 356 | prep->payload.data[asym_subtype] = &public_key_subtype; |
356 | prep->type_data[1] = kids; | 357 | prep->payload.data[asym_key_ids] = kids; |
357 | prep->payload[0] = cert->pub; | 358 | prep->payload.data[asym_crypto] = cert->pub; |
358 | prep->description = desc; | 359 | prep->description = desc; |
359 | prep->quotalen = 100; | 360 | prep->quotalen = 100; |
360 | 361 | ||