summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-11-15 22:36:07 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-11 08:16:15 +1100
commita0719b6845c05543f2c8f930c7e77b0201182a44 (patch)
tree1d6469de64b6af6f551de06256423c302919fc56
parente1831a52fbacad9aa2bcc90636f2a8e03584d90c (diff)
downloadlinux-crypto-a0719b6845c05543f2c8f930c7e77b0201182a44.tar.gz
linux-crypto-a0719b6845c05543f2c8f930c7e77b0201182a44.zip
[CRYPTO] ablkcipher: Add distinct ABLKCIPHER type
Up until now we have ablkcipher algorithms have been identified as type BLKCIPHER with the ASYNC bit set. This is suboptimal because ablkcipher refers to two things. On the one hand it refers to the top-level ablkcipher interface with requests. On the other hand it refers to and algorithm type underneath. As it is you cannot request a synchronous block cipher algorithm with the ablkcipher interface on top. This is a problem because we want to be able to eventually phase out the blkcipher top-level interface. This patch fixes this by making ABLKCIPHER its own type, just as we have distinct types for HASH and DIGEST. The type it associated with the algorithm implementation only. Which top-level interface is used for synchronous block ciphers is then determined by the mask that's used. If it's a specific mask then the old blkcipher interface is given, otherwise we go with the new ablkcipher interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/authenc.c2
-rw-r--r--crypto/blkcipher.c9
-rw-r--r--crypto/cryptd.c4
3 files changed, 6 insertions, 9 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c
index 126a529b..bc4e608c 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -292,7 +292,7 @@ static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
goto out_put_auth;
enc = crypto_attr_alg(tb[3], CRYPTO_ALG_TYPE_BLKCIPHER,
- CRYPTO_ALG_TYPE_MASK);
+ CRYPTO_ALG_TYPE_BLKCIPHER_MASK);
inst = ERR_PTR(PTR_ERR(enc));
if (IS_ERR(enc))
goto out_put_auth;
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index f6c67f9d..180d9145 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -433,9 +433,8 @@ static unsigned int crypto_blkcipher_ctxsize(struct crypto_alg *alg, u32 type,
struct blkcipher_alg *cipher = &alg->cra_blkcipher;
unsigned int len = alg->cra_ctxsize;
- type ^= CRYPTO_ALG_ASYNC;
- mask &= CRYPTO_ALG_ASYNC;
- if ((type & mask) && cipher->ivsize) {
+ if ((mask & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_MASK &&
+ cipher->ivsize) {
len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
len += cipher->ivsize;
}
@@ -482,9 +481,7 @@ static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
if (alg->ivsize > PAGE_SIZE / 8)
return -EINVAL;
- type ^= CRYPTO_ALG_ASYNC;
- mask &= CRYPTO_ALG_ASYNC;
- if (type & mask)
+ if ((mask & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_MASK)
return crypto_init_blkcipher_ops_sync(tfm);
else
return crypto_init_blkcipher_ops_async(tfm);
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 8bf2da83..1a5c45b9 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -228,7 +228,7 @@ static struct crypto_instance *cryptd_alloc_blkcipher(
struct crypto_alg *alg;
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_BLKCIPHER,
- CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
+ CRYPTO_ALG_TYPE_MASK);
if (IS_ERR(alg))
return ERR_PTR(PTR_ERR(alg));
@@ -236,7 +236,7 @@ static struct crypto_instance *cryptd_alloc_blkcipher(
if (IS_ERR(inst))
goto out_put_alg;
- inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER | CRYPTO_ALG_ASYNC;
+ inst->alg.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC;
inst->alg.cra_type = &crypto_ablkcipher_type;
inst->alg.cra_ablkcipher.ivsize = alg->cra_blkcipher.ivsize;