From 42c271c6c538857cb13c5ead5184d264d745f675 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 7 Dec 2007 18:52:49 +0800 Subject: [CRYPTO] scatterwalk: Move scatterwalk.h to linux/crypto The scatterwalk infrastructure is used by algorithms so it needs to move out of crypto for future users that may live in drivers/crypto or asm/*/crypto. Signed-off-by: Herbert Xu --- crypto/xcbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crypto/xcbc.c') diff --git a/crypto/xcbc.c b/crypto/xcbc.c index ac68f3b62fd..789cdeee6b7 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -19,6 +19,7 @@ * Kazunori Miyazawa */ +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include "internal.h" static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x02020202, 0x02020202, 0x02020202, 0x02020202, -- cgit v1.2.3 From 1b87887d6c232becba77835b29a424cf78442b7d Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 1 Jan 2008 15:44:50 +1100 Subject: [CRYPTO] xcbc: Fix algorithm leak when block size check fails When the underlying algorithm has a block size other than 16 we abort without freeing it. In fact, we try to return the algorithm itself as an error! This patch plugs the leak and makes it return -EINVAL instead. Signed-off-by: Herbert Xu --- crypto/xcbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crypto/xcbc.c') diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 789cdeee6b7..e3d9503a034 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -307,7 +307,8 @@ static struct crypto_instance *xcbc_alloc(struct rtattr **tb) case 16: break; default: - return ERR_PTR(PTR_ERR(alg)); + inst = ERR_PTR(-EINVAL); + goto out_put_alg; } inst = crypto_alloc_instance("xcbc", alg); -- cgit v1.2.3 From 94765b9e4cba8e3c51c292338db16aa174894d30 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 1 Jan 2008 15:49:17 +1100 Subject: [CRYPTO] xcbc: Remove bogus hash/cipher test When setting the digest size xcbc tests to see if the underlying algorithm is a hash. This is silly because we don't allow it to be a hash and we've specifically requested for a cipher. This patch removes the bogus test. Signed-off-by: Herbert Xu --- crypto/xcbc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crypto/xcbc.c') diff --git a/crypto/xcbc.c b/crypto/xcbc.c index e3d9503a034..a82959df678 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -321,10 +321,7 @@ static struct crypto_instance *xcbc_alloc(struct rtattr **tb) inst->alg.cra_alignmask = alg->cra_alignmask; inst->alg.cra_type = &crypto_hash_type; - inst->alg.cra_hash.digestsize = - (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == - CRYPTO_ALG_TYPE_HASH ? alg->cra_hash.digestsize : - alg->cra_blocksize; + inst->alg.cra_hash.digestsize = alg->cra_blocksize; inst->alg.cra_ctxsize = sizeof(struct crypto_xcbc_ctx) + ALIGN(inst->alg.cra_blocksize * 3, sizeof(void *)); inst->alg.cra_init = xcbc_init_tfm; -- cgit v1.2.3