2007-12-12 12:30:52

by Herbert Xu

[permalink] [raw]
Subject: [PATCH 1/10] [CRYPTO] skcipher: Fix mask on skcipher spawns

[CRYPTO] skcipher: Fix mask on skcipher spawns

The mask set on spawns should match the mask used to locate the algorithm
originally. This patch fixes the mask used on skcipher spawns so that it
includes the proper type mask and GENIV where applicable.

Signed-off-by: Herbert Xu <[email protected]>
---

crypto/ablkcipher.c | 9 +++++++--
crypto/blkcipher.c | 7 ++++---
2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index d3fc416..0bfc01f 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -250,8 +250,7 @@ static struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type,
{
struct crypto_alg *alg;

- alg = crypto_alg_mod_lookup(name, crypto_skcipher_type(type),
- crypto_skcipher_mask(mask));
+ alg = crypto_alg_mod_lookup(name, type, mask);
if (IS_ERR(alg))
return alg;

@@ -273,6 +272,9 @@ int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,
struct crypto_alg *alg;
int err;

+ type = crypto_skcipher_type(type);
+ mask = crypto_skcipher_mask(mask);
+
alg = crypto_lookup_skcipher(name, type, mask);
if (IS_ERR(alg))
return PTR_ERR(alg);
@@ -289,6 +291,9 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
struct crypto_tfm *tfm;
int err;

+ type = crypto_skcipher_type(type);
+ mask = crypto_skcipher_mask(mask);
+
for (;;) {
struct crypto_alg *alg;

diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 2ef5b10..10c2229 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -516,9 +516,10 @@ static int crypto_grab_nivcipher(struct crypto_skcipher_spawn *spawn,
struct crypto_alg *alg;
int err;

- alg = crypto_alg_mod_lookup(name, crypto_skcipher_type(type),
- crypto_skcipher_mask(mask) |
- CRYPTO_ALG_GENIV);
+ type = crypto_skcipher_type(type);
+ mask = crypto_skcipher_mask(mask) | CRYPTO_ALG_GENIV;
+
+ alg = crypto_alg_mod_lookup(name, type, mask);
if (IS_ERR(alg))
return PTR_ERR(alg);