diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-08-13 05:28:54 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-08-17 04:53:43 -0400 |
commit | 92932d03c2b3613f40ce49ff42088e814e403afc (patch) | |
tree | 810eea4db7eb8887449e1d3d5a4078a0839d7070 /crypto/seqiv.c | |
parent | 8a2cd1c4a7aa0b4a24eafd6914756be6fbe7f361 (diff) |
crypto: seqiv - Remove AEAD compatibility code
Now that we no longer have any legacy AEAD implementations the
compatibility code path can no longer be triggered. This patch
removes it.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/seqiv.c')
-rw-r--r-- | crypto/seqiv.c | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/crypto/seqiv.c b/crypto/seqiv.c index debf8d37cafd..3d8b02b80872 100644 --- a/crypto/seqiv.c +++ b/crypto/seqiv.c | |||
@@ -66,32 +66,6 @@ static void seqiv_complete(struct crypto_async_request *base, int err) | |||
66 | skcipher_givcrypt_complete(req, err); | 66 | skcipher_givcrypt_complete(req, err); |
67 | } | 67 | } |
68 | 68 | ||
69 | static void seqiv_aead_complete2(struct aead_givcrypt_request *req, int err) | ||
70 | { | ||
71 | struct aead_request *subreq = aead_givcrypt_reqctx(req); | ||
72 | struct crypto_aead *geniv; | ||
73 | |||
74 | if (err == -EINPROGRESS) | ||
75 | return; | ||
76 | |||
77 | if (err) | ||
78 | goto out; | ||
79 | |||
80 | geniv = aead_givcrypt_reqtfm(req); | ||
81 | memcpy(req->areq.iv, subreq->iv, crypto_aead_ivsize(geniv)); | ||
82 | |||
83 | out: | ||
84 | kfree(subreq->iv); | ||
85 | } | ||
86 | |||
87 | static void seqiv_aead_complete(struct crypto_async_request *base, int err) | ||
88 | { | ||
89 | struct aead_givcrypt_request *req = base->data; | ||
90 | |||
91 | seqiv_aead_complete2(req, err); | ||
92 | aead_givcrypt_complete(req, err); | ||
93 | } | ||
94 | |||
95 | static void seqiv_aead_encrypt_complete2(struct aead_request *req, int err) | 69 | static void seqiv_aead_encrypt_complete2(struct aead_request *req, int err) |
96 | { | 70 | { |
97 | struct aead_request *subreq = aead_request_ctx(req); | 71 | struct aead_request *subreq = aead_request_ctx(req); |
@@ -178,52 +152,6 @@ static int seqiv_givencrypt(struct skcipher_givcrypt_request *req) | |||
178 | return err; | 152 | return err; |
179 | } | 153 | } |
180 | 154 | ||
181 | static int seqiv_aead_givencrypt(struct aead_givcrypt_request *req) | ||
182 | { | ||
183 | struct crypto_aead *geniv = aead_givcrypt_reqtfm(req); | ||
184 | struct seqiv_ctx *ctx = crypto_aead_ctx(geniv); | ||
185 | struct aead_request *areq = &req->areq; | ||
186 | struct aead_request *subreq = aead_givcrypt_reqctx(req); | ||
187 | crypto_completion_t compl; | ||
188 | void *data; | ||
189 | u8 *info; | ||
190 | unsigned int ivsize; | ||
191 | int err; | ||
192 | |||
193 | aead_request_set_tfm(subreq, aead_geniv_base(geniv)); | ||
194 | |||
195 | compl = areq->base.complete; | ||
196 | data = areq->base.data; | ||
197 | info = areq->iv; | ||
198 | |||
199 | ivsize = crypto_aead_ivsize(geniv); | ||
200 | |||
201 | if (unlikely(!IS_ALIGNED((unsigned long)info, | ||
202 | crypto_aead_alignmask(geniv) + 1))) { | ||
203 | info = kmalloc(ivsize, areq->base.flags & | ||
204 | CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL: | ||
205 | GFP_ATOMIC); | ||
206 | if (!info) | ||
207 | return -ENOMEM; | ||
208 | |||
209 | compl = seqiv_aead_complete; | ||
210 | data = req; | ||
211 | } | ||
212 | |||
213 | aead_request_set_callback(subreq, areq->base.flags, compl, data); | ||
214 | aead_request_set_crypt(subreq, areq->src, areq->dst, areq->cryptlen, | ||
215 | info); | ||
216 | aead_request_set_assoc(subreq, areq->assoc, areq->assoclen); | ||
217 | |||
218 | seqiv_geniv(ctx, info, req->seq, ivsize); | ||
219 | memcpy(req->giv, info, ivsize); | ||
220 | |||
221 | err = crypto_aead_encrypt(subreq); | ||
222 | if (unlikely(info != areq->iv)) | ||
223 | seqiv_aead_complete2(req, err); | ||
224 | return err; | ||
225 | } | ||
226 | |||
227 | static int seqiv_aead_encrypt(struct aead_request *req) | 155 | static int seqiv_aead_encrypt(struct aead_request *req) |
228 | { | 156 | { |
229 | struct crypto_aead *geniv = crypto_aead_reqtfm(req); | 157 | struct crypto_aead *geniv = crypto_aead_reqtfm(req); |
@@ -330,27 +258,6 @@ static int seqiv_init(struct crypto_tfm *tfm) | |||
330 | return err ?: skcipher_geniv_init(tfm); | 258 | return err ?: skcipher_geniv_init(tfm); |
331 | } | 259 | } |
332 | 260 | ||
333 | static int seqiv_old_aead_init(struct crypto_tfm *tfm) | ||
334 | { | ||
335 | struct crypto_aead *geniv = __crypto_aead_cast(tfm); | ||
336 | struct seqiv_ctx *ctx = crypto_aead_ctx(geniv); | ||
337 | int err; | ||
338 | |||
339 | spin_lock_init(&ctx->lock); | ||
340 | |||
341 | crypto_aead_set_reqsize(__crypto_aead_cast(tfm), | ||
342 | sizeof(struct aead_request)); | ||
343 | err = 0; | ||
344 | if (!crypto_get_default_rng()) { | ||
345 | geniv->givencrypt = seqiv_aead_givencrypt; | ||
346 | err = crypto_rng_get_bytes(crypto_default_rng, ctx->salt, | ||
347 | crypto_aead_ivsize(geniv)); | ||
348 | crypto_put_default_rng(); | ||
349 | } | ||
350 | |||
351 | return err ?: aead_geniv_init(tfm); | ||
352 | } | ||
353 | |||
354 | static int seqiv_aead_init_common(struct crypto_aead *geniv, | 261 | static int seqiv_aead_init_common(struct crypto_aead *geniv, |
355 | unsigned int reqsize) | 262 | unsigned int reqsize) |
356 | { | 263 | { |
@@ -439,33 +346,6 @@ free_inst: | |||
439 | goto out; | 346 | goto out; |
440 | } | 347 | } |
441 | 348 | ||
442 | static int seqiv_old_aead_create(struct crypto_template *tmpl, | ||
443 | struct aead_instance *aead) | ||
444 | { | ||
445 | struct crypto_instance *inst = aead_crypto_instance(aead); | ||
446 | int err = -EINVAL; | ||
447 | |||
448 | if (inst->alg.cra_aead.ivsize < sizeof(u64)) | ||
449 | goto free_inst; | ||
450 | |||
451 | inst->alg.cra_init = seqiv_old_aead_init; | ||
452 | inst->alg.cra_exit = aead_geniv_exit; | ||
453 | |||
454 | inst->alg.cra_ctxsize = inst->alg.cra_aead.ivsize; | ||
455 | inst->alg.cra_ctxsize += sizeof(struct seqiv_ctx); | ||
456 | |||
457 | err = crypto_register_instance(tmpl, inst); | ||
458 | if (err) | ||
459 | goto free_inst; | ||
460 | |||
461 | out: | ||
462 | return err; | ||
463 | |||
464 | free_inst: | ||
465 | aead_geniv_free(aead); | ||
466 | goto out; | ||
467 | } | ||
468 | |||
469 | static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb) | 349 | static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb) |
470 | { | 350 | { |
471 | struct aead_instance *inst; | 351 | struct aead_instance *inst; |
@@ -480,15 +360,9 @@ static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
480 | 360 | ||
481 | inst->alg.base.cra_alignmask |= __alignof__(u32) - 1; | 361 | inst->alg.base.cra_alignmask |= __alignof__(u32) - 1; |
482 | 362 | ||
483 | if (inst->alg.base.cra_aead.encrypt) | ||
484 | return seqiv_old_aead_create(tmpl, inst); | ||
485 | |||
486 | spawn = aead_instance_ctx(inst); | 363 | spawn = aead_instance_ctx(inst); |
487 | alg = crypto_spawn_aead_alg(spawn); | 364 | alg = crypto_spawn_aead_alg(spawn); |
488 | 365 | ||
489 | if (alg->base.cra_aead.encrypt) | ||
490 | goto done; | ||
491 | |||
492 | err = -EINVAL; | 366 | err = -EINVAL; |
493 | if (inst->alg.ivsize != sizeof(u64)) | 367 | if (inst->alg.ivsize != sizeof(u64)) |
494 | goto free_inst; | 368 | goto free_inst; |
@@ -502,7 +376,6 @@ static int seqiv_aead_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
502 | inst->alg.base.cra_ctxsize = sizeof(struct seqiv_aead_ctx); | 376 | inst->alg.base.cra_ctxsize = sizeof(struct seqiv_aead_ctx); |
503 | inst->alg.base.cra_ctxsize += inst->alg.ivsize; | 377 | inst->alg.base.cra_ctxsize += inst->alg.ivsize; |
504 | 378 | ||
505 | done: | ||
506 | err = aead_register_instance(tmpl, inst); | 379 | err = aead_register_instance(tmpl, inst); |
507 | if (err) | 380 | if (err) |
508 | goto free_inst; | 381 | goto free_inst; |