aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asymmetric_keys
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/asymmetric_keys')
-rw-r--r--crypto/asymmetric_keys/asymmetric_type.c27
-rw-r--r--crypto/asymmetric_keys/pkcs7_key_type.c10
-rw-r--r--crypto/asymmetric_keys/x509_public_key.c2
3 files changed, 9 insertions, 30 deletions
diff --git a/crypto/asymmetric_keys/asymmetric_type.c b/crypto/asymmetric_keys/asymmetric_type.c
index b77eb5304788..21960a4e74e8 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -156,7 +156,7 @@ static void asymmetric_key_free_preparse(struct key_preparsed_payload *prep)
156 pr_devel("==>%s()\n", __func__); 156 pr_devel("==>%s()\n", __func__);
157 157
158 if (subtype) { 158 if (subtype) {
159 subtype->destroy(prep->payload); 159 subtype->destroy(prep->payload[0]);
160 module_put(subtype->owner); 160 module_put(subtype->owner);
161 } 161 }
162 kfree(prep->type_data[1]); 162 kfree(prep->type_data[1]);
@@ -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,
diff --git a/crypto/asymmetric_keys/pkcs7_key_type.c b/crypto/asymmetric_keys/pkcs7_key_type.c
index b1797d2516e2..c2091f7bd15d 100644
--- a/crypto/asymmetric_keys/pkcs7_key_type.c
+++ b/crypto/asymmetric_keys/pkcs7_key_type.c
@@ -18,9 +18,9 @@
18#include "pkcs7_parser.h" 18#include "pkcs7_parser.h"
19 19
20/* 20/*
21 * Instantiate a PKCS#7 wrapped and validated key. 21 * Preparse a PKCS#7 wrapped and validated data blob.
22 */ 22 */
23int pkcs7_instantiate(struct key *key, struct key_preparsed_payload *prep) 23static int pkcs7_preparse(struct key_preparsed_payload *prep)
24{ 24{
25 struct pkcs7_message *pkcs7; 25 struct pkcs7_message *pkcs7;
26 const void *data, *saved_prep_data; 26 const void *data, *saved_prep_data;
@@ -54,7 +54,7 @@ int pkcs7_instantiate(struct key *key, struct key_preparsed_payload *prep)
54 54
55 prep->data = data; 55 prep->data = data;
56 prep->datalen = datalen; 56 prep->datalen = datalen;
57 ret = user_instantiate(key, prep); 57 ret = user_preparse(prep);
58 prep->data = saved_prep_data; 58 prep->data = saved_prep_data;
59 prep->datalen = saved_prep_datalen; 59 prep->datalen = saved_prep_datalen;
60 60
@@ -72,7 +72,9 @@ error:
72struct key_type key_type_pkcs7 = { 72struct key_type key_type_pkcs7 = {
73 .name = "pkcs7_test", 73 .name = "pkcs7_test",
74 .def_lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT, 74 .def_lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,
75 .instantiate = pkcs7_instantiate, 75 .preparse = pkcs7_preparse,
76 .free_preparse = user_free_preparse,
77 .instantiate = generic_key_instantiate,
76 .match = user_match, 78 .match = user_match,
77 .revoke = user_revoke, 79 .revoke = user_revoke,
78 .destroy = user_destroy, 80 .destroy = user_destroy,
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 382ef0d2ff2e..3fc8a0634ed7 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -177,7 +177,7 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
177 __module_get(public_key_subtype.owner); 177 __module_get(public_key_subtype.owner);
178 prep->type_data[0] = &public_key_subtype; 178 prep->type_data[0] = &public_key_subtype;
179 prep->type_data[1] = cert->fingerprint; 179 prep->type_data[1] = cert->fingerprint;
180 prep->payload = cert->pub; 180 prep->payload[0] = cert->pub;
181 prep->description = desc; 181 prep->description = desc;
182 prep->quotalen = 100; 182 prep->quotalen = 100;
183 183