summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-10-03 15:15:36 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2005-10-30 11:19:43 +1100
commit36c68f90fcc70cd5bb2066d9fbd443ad0b71b957 (patch)
treebd4f390d172f40911e47c0ea554da8d1d2949010
parentdae88ca0ae5d4f4dba06d267fee1ddea0e29c797 (diff)
downloadlinux-crypto-36c68f90fcc70cd5bb2066d9fbd443ad0b71b957.tar.gz
linux-crypto-36c68f90fcc70cd5bb2066d9fbd443ad0b71b957.zip
[CRYPTO] Check cra_alignmask against cra_blocksize
The cipher code relies on the fact that the block size is a multiple of the required alignment. So we should check this at the time of algorith registration. We also ensure that the block size is bounded by the page size. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/api.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 959c4e5f..40ae42e9 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -215,7 +215,10 @@ int crypto_register_alg(struct crypto_alg *alg)
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
return -EINVAL;
- if (alg->cra_alignmask > PAGE_SIZE)
+ if (alg->cra_alignmask & alg->cra_blocksize)
+ return -EINVAL;
+
+ if (alg->cra_blocksize > PAGE_SIZE)
return -EINVAL;
down_write(&crypto_alg_sem);