diff options
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/crypto/api.c b/crypto/api.c index bc4b7901acdf..edaa843d8e83 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -226,17 +226,18 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) | |||
226 | 226 | ||
227 | case CRYPTO_ALG_TYPE_COMPRESS: | 227 | case CRYPTO_ALG_TYPE_COMPRESS: |
228 | return crypto_init_compress_flags(tfm, flags); | 228 | return crypto_init_compress_flags(tfm, flags); |
229 | |||
230 | default: | ||
231 | break; | ||
232 | } | 229 | } |
233 | 230 | ||
234 | BUG(); | 231 | return 0; |
235 | return -EINVAL; | ||
236 | } | 232 | } |
237 | 233 | ||
238 | static int crypto_init_ops(struct crypto_tfm *tfm) | 234 | static int crypto_init_ops(struct crypto_tfm *tfm) |
239 | { | 235 | { |
236 | const struct crypto_type *type = tfm->__crt_alg->cra_type; | ||
237 | |||
238 | if (type) | ||
239 | return type->init(tfm); | ||
240 | |||
240 | switch (crypto_tfm_alg_type(tfm)) { | 241 | switch (crypto_tfm_alg_type(tfm)) { |
241 | case CRYPTO_ALG_TYPE_CIPHER: | 242 | case CRYPTO_ALG_TYPE_CIPHER: |
242 | return crypto_init_cipher_ops(tfm); | 243 | return crypto_init_cipher_ops(tfm); |
@@ -257,6 +258,14 @@ static int crypto_init_ops(struct crypto_tfm *tfm) | |||
257 | 258 | ||
258 | static void crypto_exit_ops(struct crypto_tfm *tfm) | 259 | static void crypto_exit_ops(struct crypto_tfm *tfm) |
259 | { | 260 | { |
261 | const struct crypto_type *type = tfm->__crt_alg->cra_type; | ||
262 | |||
263 | if (type) { | ||
264 | if (type->exit) | ||
265 | type->exit(tfm); | ||
266 | return; | ||
267 | } | ||
268 | |||
260 | switch (crypto_tfm_alg_type(tfm)) { | 269 | switch (crypto_tfm_alg_type(tfm)) { |
261 | case CRYPTO_ALG_TYPE_CIPHER: | 270 | case CRYPTO_ALG_TYPE_CIPHER: |
262 | crypto_exit_cipher_ops(tfm); | 271 | crypto_exit_cipher_ops(tfm); |
@@ -278,26 +287,31 @@ static void crypto_exit_ops(struct crypto_tfm *tfm) | |||
278 | 287 | ||
279 | static unsigned int crypto_ctxsize(struct crypto_alg *alg, int flags) | 288 | static unsigned int crypto_ctxsize(struct crypto_alg *alg, int flags) |
280 | { | 289 | { |
290 | const struct crypto_type *type = alg->cra_type; | ||
281 | unsigned int len; | 291 | unsigned int len; |
282 | 292 | ||
293 | len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); | ||
294 | if (type) | ||
295 | return len + type->ctxsize(alg); | ||
296 | |||
283 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { | 297 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { |
284 | default: | 298 | default: |
285 | BUG(); | 299 | BUG(); |
286 | 300 | ||
287 | case CRYPTO_ALG_TYPE_CIPHER: | 301 | case CRYPTO_ALG_TYPE_CIPHER: |
288 | len = crypto_cipher_ctxsize(alg, flags); | 302 | len += crypto_cipher_ctxsize(alg, flags); |
289 | break; | 303 | break; |
290 | 304 | ||
291 | case CRYPTO_ALG_TYPE_DIGEST: | 305 | case CRYPTO_ALG_TYPE_DIGEST: |
292 | len = crypto_digest_ctxsize(alg, flags); | 306 | len += crypto_digest_ctxsize(alg, flags); |
293 | break; | 307 | break; |
294 | 308 | ||
295 | case CRYPTO_ALG_TYPE_COMPRESS: | 309 | case CRYPTO_ALG_TYPE_COMPRESS: |
296 | len = crypto_compress_ctxsize(alg, flags); | 310 | len += crypto_compress_ctxsize(alg, flags); |
297 | break; | 311 | break; |
298 | } | 312 | } |
299 | 313 | ||
300 | return len + (alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1)); | 314 | return len; |
301 | } | 315 | } |
302 | 316 | ||
303 | void crypto_shoot_alg(struct crypto_alg *alg) | 317 | void crypto_shoot_alg(struct crypto_alg *alg) |