]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[CRYPTO] Check cra_alignmask against cra_blocksize
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 3 Oct 2005 05:15:36 +0000 (15:15 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 30 Oct 2005 00:19:43 +0000 (11:19 +1100)
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>
crypto/api.c

index 959c4e5f264f42ed831720149b3627d9a9e6300c..40ae42e9b6a62acd1047f8be7ecb09600f794e97 100644 (file)
@@ -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);