diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asymmetric_keys/asymmetric_type.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c index eb8cd46961a5..f666b4e8d256 100644 --- a/crypto/asymmetric_keys/asymmetric_type.c +++ b/crypto/asymmetric_keys/asymmetric_type.c | |||
@@ -59,9 +59,11 @@ EXPORT_SYMBOL_GPL(asymmetric_keyid_match); | |||
59 | * "id:<id>" - request a key matching the ID | 59 | * "id:<id>" - request a key matching the ID |
60 | * "<subtype>:<id>" - request a key of a subtype | 60 | * "<subtype>:<id>" - request a key of a subtype |
61 | */ | 61 | */ |
62 | static int asymmetric_key_match(const struct key *key, const void *description) | 62 | static int asymmetric_key_match(const struct key *key, |
63 | const struct key_match_data *match_data) | ||
63 | { | 64 | { |
64 | const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); | 65 | const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); |
66 | const char *description = match_data->raw_data; | ||
65 | const char *spec = description; | 67 | const char *spec = description; |
66 | const char *id; | 68 | const char *id; |
67 | ptrdiff_t speclen; | 69 | ptrdiff_t speclen; |
@@ -94,6 +96,31 @@ static int asymmetric_key_match(const struct key *key, const void *description) | |||
94 | } | 96 | } |
95 | 97 | ||
96 | /* | 98 | /* |
99 | * Preparse the match criterion. If we don't set lookup_type and cmp, | ||
100 | * the default will be an exact match on the key description. | ||
101 | * | ||
102 | * There are some specifiers for matching key IDs rather than by the key | ||
103 | * description: | ||
104 | * | ||
105 | * "id:<id>" - request a key by any available ID | ||
106 | * | ||
107 | * These have to be searched by iteration rather than by direct lookup because | ||
108 | * the key is hashed according to its description. | ||
109 | */ | ||
110 | static int asymmetric_key_match_preparse(struct key_match_data *match_data) | ||
111 | { | ||
112 | match_data->lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE; | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * Free the preparsed the match criterion. | ||
118 | */ | ||
119 | static void asymmetric_key_match_free(struct key_match_data *match_data) | ||
120 | { | ||
121 | } | ||
122 | |||
123 | /* | ||
97 | * Describe the asymmetric key | 124 | * Describe the asymmetric key |
98 | */ | 125 | */ |
99 | static void asymmetric_key_describe(const struct key *key, struct seq_file *m) | 126 | static void asymmetric_key_describe(const struct key *key, struct seq_file *m) |
@@ -196,7 +223,9 @@ struct key_type key_type_asymmetric = { | |||
196 | .preparse = asymmetric_key_preparse, | 223 | .preparse = asymmetric_key_preparse, |
197 | .free_preparse = asymmetric_key_free_preparse, | 224 | .free_preparse = asymmetric_key_free_preparse, |
198 | .instantiate = generic_key_instantiate, | 225 | .instantiate = generic_key_instantiate, |
226 | .match_preparse = asymmetric_key_match_preparse, | ||
199 | .match = asymmetric_key_match, | 227 | .match = asymmetric_key_match, |
228 | .match_free = asymmetric_key_match_free, | ||
200 | .destroy = asymmetric_key_destroy, | 229 | .destroy = asymmetric_key_destroy, |
201 | .describe = asymmetric_key_describe, | 230 | .describe = asymmetric_key_describe, |
202 | .def_lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE, | 231 | .def_lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE, |