16 #include <linux/module.h>
17 #include <linux/slab.h>
41 if (!subtype || !spec || !*spec)
45 if (key->description &&
strcmp(key->description, description) == 0)
59 kid = asymmetric_key_id(key);
68 kid += kidlen - idlen;
73 memcmp(spec,
"id", 2) == 0)
86 static void asymmetric_key_describe(
const struct key *key,
struct seq_file *
m)
89 const char *kid = asymmetric_key_id(key);
120 static int asymmetric_key_preparse(
struct key_preparsed_payload *prep)
127 if (prep->datalen == 0)
136 ret = parser->
parse(prep);
138 pr_debug(
"Parser recognised the format (ret %d)\n",
144 up_read(&asymmetric_key_parsers_sem);
145 pr_devel(
"<==%s() = %d\n", __func__, ret);
152 static void asymmetric_key_free_preparse(
struct key_preparsed_payload *prep)
159 subtype->
destroy(prep->payload);
160 module_put(subtype->
owner);
162 kfree(prep->type_data[1]);
163 kfree(prep->description);
170 static int asymmetric_key_instantiate(
struct key *key,
struct key_preparsed_payload *prep)
178 key->type_data.p[0] = prep->type_data[0];
179 key->type_data.p[1] = prep->type_data[1];
180 key->payload.data = prep->payload;
181 prep->type_data[0] =
NULL;
182 prep->type_data[1] =
NULL;
183 prep->payload =
NULL;
185 pr_devel(
"<==%s() = %d\n", __func__, ret);
192 static void asymmetric_key_destroy(
struct key *key)
196 subtype->
destroy(key->payload.data);
197 module_put(subtype->
owner);
198 key->type_data.p[0] =
NULL;
200 kfree(key->type_data.p[1]);
201 key->type_data.p[1] =
NULL;
205 .name =
"asymmetric",
206 .preparse = asymmetric_key_preparse,
207 .free_preparse = asymmetric_key_free_preparse,
208 .instantiate = asymmetric_key_instantiate,
209 .match = asymmetric_key_match,
210 .destroy = asymmetric_key_destroy,
211 .describe = asymmetric_key_describe,
228 pr_err(
"Asymmetric key parser '%s' already registered\n",
237 pr_notice(
"Asymmetric key parser '%s' registered\n", parser->
name);
241 up_write(&asymmetric_key_parsers_sem);
254 up_write(&asymmetric_key_parsers_sem);
256 pr_notice(
"Asymmetric key parser '%s' unregistered\n", parser->
name);
263 static int __init asymmetric_key_init(
void)
268 static void __exit asymmetric_key_cleanup(
void)