aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asymmetric_keys
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2014-07-18 13:56:34 -0400
committerDavid Howells <dhowells@redhat.com>2014-07-18 13:56:34 -0400
commit6a09d17bb66a533c165be81e8a4c3557f68e1a3b (patch)
treed56b7ce27813ea9ab20ae1f22236af76b5390d6a /crypto/asymmetric_keys
parent32c2e6752ff0f48fe03b9e1c7c64bde580a840d2 (diff)
KEYS: Provide a generic instantiation function
Provide a generic instantiation function for key types that use the preparse hook. This makes it easier to prereserve key quota before keyrings get locked to retain the new key. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Steve Dickson <steved@redhat.com> Acked-by: Jeff Layton <jlayton@primarydata.com> Reviewed-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'crypto/asymmetric_keys')
-rw-r--r--crypto/asymmetric_keys/asymmetric_type.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index b77eb5304788..c1fe0fcee8e3 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -164,29 +164,6 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
164} 164}
165 165
166/* 166/*
167 * Instantiate a asymmetric_key defined key. The key was preparsed, so we just
168 * have to transfer the data here.
169 */
170static int asymmetric_key_instantiate(struct key *key, struct key_preparsed_payload *prep)
171{
172 int ret;
173
174 pr_devel("==>%s()\n", __func__);
175
176 ret = key_payload_reserve(key, prep->quotalen);
177 if (ret == 0) {
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;
184 }
185 pr_devel("<==%s() = %d\n", __func__, ret);
186 return ret;
187}
188
189/*
190 * dispose of the data dangling from the corpse of a asymmetric key 167 * dispose of the data dangling from the corpse of a asymmetric key
191 */ 168 */
192static void asymmetric_key_destroy(struct key *key) 169static void asymmetric_key_destroy(struct key *key)
@@ -205,7 +182,7 @@ struct key_type key_type_asymmetric = {
205 .name = "asymmetric", 182 .name = "asymmetric",
206 .preparse = asymmetric_key_preparse, 183 .preparse = asymmetric_key_preparse,
207 .free_preparse = asymmetric_key_free_preparse, 184 .free_preparse = asymmetric_key_free_preparse,
208 .instantiate = asymmetric_key_instantiate, 185 .instantiate = generic_key_instantiate,
209 .match = asymmetric_key_match, 186 .match = asymmetric_key_match,
210 .destroy = asymmetric_key_destroy, 187 .destroy = asymmetric_key_destroy,
211 .describe = asymmetric_key_describe, 188 .describe = asymmetric_key_describe,