diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/algapi.c | 13 | ||||
-rw-r--r-- | crypto/cbc.c | 9 | ||||
-rw-r--r-- | crypto/ecb.c | 9 | ||||
-rw-r--r-- | crypto/hmac.c | 9 | ||||
-rw-r--r-- | crypto/lrw.c | 11 | ||||
-rw-r--r-- | crypto/pcbc.c | 9 | ||||
-rw-r--r-- | crypto/xcbc.c | 9 |
7 files changed, 42 insertions, 27 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 69eb504721a4..0f1abca1b98c 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn) | |||
377 | } | 377 | } |
378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); | 378 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); |
379 | 379 | ||
380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | 380 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, |
381 | u32 mask) | ||
381 | { | 382 | { |
382 | struct crypto_alg *alg; | 383 | struct crypto_alg *alg; |
383 | struct crypto_alg *alg2; | 384 | struct crypto_alg *alg2; |
@@ -396,10 +397,18 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn) | |||
396 | return ERR_PTR(-EAGAIN); | 397 | return ERR_PTR(-EAGAIN); |
397 | } | 398 | } |
398 | 399 | ||
400 | tfm = ERR_PTR(-EINVAL); | ||
401 | if (unlikely((alg->cra_flags ^ type) & mask)) | ||
402 | goto out_put_alg; | ||
403 | |||
399 | tfm = __crypto_alloc_tfm(alg); | 404 | tfm = __crypto_alloc_tfm(alg); |
400 | if (IS_ERR(tfm)) | 405 | if (IS_ERR(tfm)) |
401 | crypto_mod_put(alg); | 406 | goto out_put_alg; |
407 | |||
408 | return tfm; | ||
402 | 409 | ||
410 | out_put_alg: | ||
411 | crypto_mod_put(alg); | ||
403 | return tfm; | 412 | return tfm; |
404 | } | 413 | } |
405 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); | 414 | EXPORT_SYMBOL_GPL(crypto_spawn_tfm); |
diff --git a/crypto/cbc.c b/crypto/cbc.c index f5542b4db387..136fea7e7000 100644 --- a/crypto/cbc.c +++ b/crypto/cbc.c | |||
@@ -243,6 +243,7 @@ static int crypto_cbc_init_tfm(struct crypto_tfm *tfm) | |||
243 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 243 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
244 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 244 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
245 | struct crypto_cbc_ctx *ctx = crypto_tfm_ctx(tfm); | 245 | struct crypto_cbc_ctx *ctx = crypto_tfm_ctx(tfm); |
246 | struct crypto_cipher *cipher; | ||
246 | 247 | ||
247 | switch (crypto_tfm_alg_blocksize(tfm)) { | 248 | switch (crypto_tfm_alg_blocksize(tfm)) { |
248 | case 8: | 249 | case 8: |
@@ -260,11 +261,11 @@ static int crypto_cbc_init_tfm(struct crypto_tfm *tfm) | |||
260 | ctx->xor = xor_quad; | 261 | ctx->xor = xor_quad; |
261 | } | 262 | } |
262 | 263 | ||
263 | tfm = crypto_spawn_tfm(spawn); | 264 | cipher = crypto_spawn_cipher(spawn); |
264 | if (IS_ERR(tfm)) | 265 | if (IS_ERR(cipher)) |
265 | return PTR_ERR(tfm); | 266 | return PTR_ERR(cipher); |
266 | 267 | ||
267 | ctx->child = crypto_cipher_cast(tfm); | 268 | ctx->child = cipher; |
268 | return 0; | 269 | return 0; |
269 | } | 270 | } |
270 | 271 | ||
diff --git a/crypto/ecb.c b/crypto/ecb.c index f239aa9c4017..839a0aed8c22 100644 --- a/crypto/ecb.c +++ b/crypto/ecb.c | |||
@@ -99,12 +99,13 @@ static int crypto_ecb_init_tfm(struct crypto_tfm *tfm) | |||
99 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 99 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
100 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 100 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
101 | struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(tfm); | 101 | struct crypto_ecb_ctx *ctx = crypto_tfm_ctx(tfm); |
102 | struct crypto_cipher *cipher; | ||
102 | 103 | ||
103 | tfm = crypto_spawn_tfm(spawn); | 104 | cipher = crypto_spawn_cipher(spawn); |
104 | if (IS_ERR(tfm)) | 105 | if (IS_ERR(cipher)) |
105 | return PTR_ERR(tfm); | 106 | return PTR_ERR(cipher); |
106 | 107 | ||
107 | ctx->child = crypto_cipher_cast(tfm); | 108 | ctx->child = cipher; |
108 | return 0; | 109 | return 0; |
109 | } | 110 | } |
110 | 111 | ||
diff --git a/crypto/hmac.c b/crypto/hmac.c index b521bcd2b2c6..44187c5ee593 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c | |||
@@ -172,15 +172,16 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | |||
172 | 172 | ||
173 | static int hmac_init_tfm(struct crypto_tfm *tfm) | 173 | static int hmac_init_tfm(struct crypto_tfm *tfm) |
174 | { | 174 | { |
175 | struct crypto_hash *hash; | ||
175 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 176 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
176 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 177 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
177 | struct hmac_ctx *ctx = hmac_ctx(__crypto_hash_cast(tfm)); | 178 | struct hmac_ctx *ctx = hmac_ctx(__crypto_hash_cast(tfm)); |
178 | 179 | ||
179 | tfm = crypto_spawn_tfm(spawn); | 180 | hash = crypto_spawn_hash(spawn); |
180 | if (IS_ERR(tfm)) | 181 | if (IS_ERR(hash)) |
181 | return PTR_ERR(tfm); | 182 | return PTR_ERR(hash); |
182 | 183 | ||
183 | ctx->child = crypto_hash_cast(tfm); | 184 | ctx->child = hash; |
184 | return 0; | 185 | return 0; |
185 | } | 186 | } |
186 | 187 | ||
diff --git a/crypto/lrw.c b/crypto/lrw.c index 56642586d84f..b4105080ac7a 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c | |||
@@ -201,21 +201,22 @@ static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
201 | 201 | ||
202 | static int init_tfm(struct crypto_tfm *tfm) | 202 | static int init_tfm(struct crypto_tfm *tfm) |
203 | { | 203 | { |
204 | struct crypto_cipher *cipher; | ||
204 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 205 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
205 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 206 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
206 | struct priv *ctx = crypto_tfm_ctx(tfm); | 207 | struct priv *ctx = crypto_tfm_ctx(tfm); |
207 | u32 *flags = &tfm->crt_flags; | 208 | u32 *flags = &tfm->crt_flags; |
208 | 209 | ||
209 | tfm = crypto_spawn_tfm(spawn); | 210 | cipher = crypto_spawn_cipher(spawn); |
210 | if (IS_ERR(tfm)) | 211 | if (IS_ERR(cipher)) |
211 | return PTR_ERR(tfm); | 212 | return PTR_ERR(cipher); |
212 | 213 | ||
213 | if (crypto_tfm_alg_blocksize(tfm) != 16) { | 214 | if (crypto_cipher_blocksize(cipher) != 16) { |
214 | *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN; | 215 | *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN; |
215 | return -EINVAL; | 216 | return -EINVAL; |
216 | } | 217 | } |
217 | 218 | ||
218 | ctx->child = crypto_cipher_cast(tfm); | 219 | ctx->child = cipher; |
219 | return 0; | 220 | return 0; |
220 | } | 221 | } |
221 | 222 | ||
diff --git a/crypto/pcbc.c b/crypto/pcbc.c index 0ffb46eb259f..5174d7fdad6e 100644 --- a/crypto/pcbc.c +++ b/crypto/pcbc.c | |||
@@ -247,6 +247,7 @@ static int crypto_pcbc_init_tfm(struct crypto_tfm *tfm) | |||
247 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 247 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
248 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 248 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
249 | struct crypto_pcbc_ctx *ctx = crypto_tfm_ctx(tfm); | 249 | struct crypto_pcbc_ctx *ctx = crypto_tfm_ctx(tfm); |
250 | struct crypto_cipher *cipher; | ||
250 | 251 | ||
251 | switch (crypto_tfm_alg_blocksize(tfm)) { | 252 | switch (crypto_tfm_alg_blocksize(tfm)) { |
252 | case 8: | 253 | case 8: |
@@ -264,11 +265,11 @@ static int crypto_pcbc_init_tfm(struct crypto_tfm *tfm) | |||
264 | ctx->xor = xor_quad; | 265 | ctx->xor = xor_quad; |
265 | } | 266 | } |
266 | 267 | ||
267 | tfm = crypto_spawn_tfm(spawn); | 268 | cipher = crypto_spawn_cipher(spawn); |
268 | if (IS_ERR(tfm)) | 269 | if (IS_ERR(cipher)) |
269 | return PTR_ERR(tfm); | 270 | return PTR_ERR(cipher); |
270 | 271 | ||
271 | ctx->child = crypto_cipher_cast(tfm); | 272 | ctx->child = cipher; |
272 | return 0; | 273 | return 0; |
273 | } | 274 | } |
274 | 275 | ||
diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 317e9f08fc04..d7b4be0a057d 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c | |||
@@ -254,14 +254,15 @@ static int crypto_xcbc_digest(struct hash_desc *pdesc, | |||
254 | 254 | ||
255 | static int xcbc_init_tfm(struct crypto_tfm *tfm) | 255 | static int xcbc_init_tfm(struct crypto_tfm *tfm) |
256 | { | 256 | { |
257 | struct crypto_cipher *cipher; | ||
257 | struct crypto_instance *inst = (void *)tfm->__crt_alg; | 258 | struct crypto_instance *inst = (void *)tfm->__crt_alg; |
258 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); | 259 | struct crypto_spawn *spawn = crypto_instance_ctx(inst); |
259 | struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm)); | 260 | struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm)); |
260 | int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm)); | 261 | int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm)); |
261 | 262 | ||
262 | tfm = crypto_spawn_tfm(spawn); | 263 | cipher = crypto_spawn_cipher(spawn); |
263 | if (IS_ERR(tfm)) | 264 | if (IS_ERR(cipher)) |
264 | return PTR_ERR(tfm); | 265 | return PTR_ERR(cipher); |
265 | 266 | ||
266 | switch(bs) { | 267 | switch(bs) { |
267 | case 16: | 268 | case 16: |
@@ -271,7 +272,7 @@ static int xcbc_init_tfm(struct crypto_tfm *tfm) | |||
271 | return -EINVAL; | 272 | return -EINVAL; |
272 | } | 273 | } |
273 | 274 | ||
274 | ctx->child = crypto_cipher_cast(tfm); | 275 | ctx->child = cipher; |
275 | ctx->odds = (u8*)(ctx+1); | 276 | ctx->odds = (u8*)(ctx+1); |
276 | ctx->prev = ctx->odds + bs; | 277 | ctx->prev = ctx->odds + bs; |
277 | ctx->key = ctx->prev + bs; | 278 | ctx->key = ctx->prev + bs; |