crypto: cts - Weed out non-CBC algorithms
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 16 Jan 2015 08:38:17 +0000 (19:38 +1100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 20 Jan 2015 03:44:15 +0000 (14:44 +1100)
The cts algorithm as currently implemented assumes the underlying
is a CBC-mode algorithm.  So this patch adds a check for that to
eliminate bogus combinations of cts with non-CBC modes.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/cts.c

index 6a8089c4d4b42e4eefc5566817adab45e6ec9b43..e467ec0acf9f091cc2865963b5370cd975791ed3 100644 (file)
@@ -290,6 +290,9 @@ static struct crypto_instance *crypto_cts_alloc(struct rtattr **tb)
        if (!is_power_of_2(alg->cra_blocksize))
                goto out_put_alg;
 
+       if (strncmp(alg->cra_name, "cbc(", 4))
+               goto out_put_alg;
+
        inst = crypto_alloc_instance("cts", alg);
        if (IS_ERR(inst))
                goto out_put_alg;