diff options
Diffstat (limited to 'crypto/ablkcipher.c')
| -rw-r--r-- | crypto/ablkcipher.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index e11ce37c7104..f6f08336df5d 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include <crypto/internal/skcipher.h> | 16 | #include <crypto/internal/skcipher.h> |
| 17 | #include <linux/cpumask.h> | ||
| 17 | #include <linux/err.h> | 18 | #include <linux/err.h> |
| 18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 19 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| @@ -25,6 +26,8 @@ | |||
| 25 | 26 | ||
| 26 | #include "internal.h" | 27 | #include "internal.h" |
| 27 | 28 | ||
| 29 | static const char *skcipher_default_geniv __read_mostly; | ||
| 30 | |||
| 28 | static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key, | 31 | static int setkey_unaligned(struct crypto_ablkcipher *tfm, const u8 *key, |
| 29 | unsigned int keylen) | 32 | unsigned int keylen) |
| 30 | { | 33 | { |
| @@ -180,7 +183,14 @@ EXPORT_SYMBOL_GPL(crypto_givcipher_type); | |||
| 180 | 183 | ||
| 181 | const char *crypto_default_geniv(const struct crypto_alg *alg) | 184 | const char *crypto_default_geniv(const struct crypto_alg *alg) |
| 182 | { | 185 | { |
| 183 | return alg->cra_flags & CRYPTO_ALG_ASYNC ? "eseqiv" : "chainiv"; | 186 | if (((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == |
| 187 | CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize : | ||
| 188 | alg->cra_ablkcipher.ivsize) != | ||
| 189 | alg->cra_blocksize) | ||
| 190 | return "chainiv"; | ||
| 191 | |||
| 192 | return alg->cra_flags & CRYPTO_ALG_ASYNC ? | ||
| 193 | "eseqiv" : skcipher_default_geniv; | ||
| 184 | } | 194 | } |
| 185 | 195 | ||
| 186 | static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask) | 196 | static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask) |
| @@ -201,8 +211,9 @@ static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask) | |||
| 201 | int err; | 211 | int err; |
| 202 | 212 | ||
| 203 | larval = crypto_larval_lookup(alg->cra_driver_name, | 213 | larval = crypto_larval_lookup(alg->cra_driver_name, |
| 214 | (type & ~CRYPTO_ALG_TYPE_MASK) | | ||
| 204 | CRYPTO_ALG_TYPE_GIVCIPHER, | 215 | CRYPTO_ALG_TYPE_GIVCIPHER, |
| 205 | CRYPTO_ALG_TYPE_MASK); | 216 | mask | CRYPTO_ALG_TYPE_MASK); |
| 206 | err = PTR_ERR(larval); | 217 | err = PTR_ERR(larval); |
| 207 | if (IS_ERR(larval)) | 218 | if (IS_ERR(larval)) |
| 208 | goto out; | 219 | goto out; |
| @@ -360,3 +371,17 @@ err: | |||
| 360 | return ERR_PTR(err); | 371 | return ERR_PTR(err); |
| 361 | } | 372 | } |
| 362 | EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher); | 373 | EXPORT_SYMBOL_GPL(crypto_alloc_ablkcipher); |
| 374 | |||
| 375 | static int __init skcipher_module_init(void) | ||
| 376 | { | ||
| 377 | skcipher_default_geniv = num_possible_cpus() > 1 ? | ||
| 378 | "eseqiv" : "chainiv"; | ||
| 379 | return 0; | ||
| 380 | } | ||
| 381 | |||
| 382 | static void skcipher_module_exit(void) | ||
| 383 | { | ||
| 384 | } | ||
| 385 | |||
| 386 | module_init(skcipher_module_init); | ||
| 387 | module_exit(skcipher_module_exit); | ||
