aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-18 08:41:29 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2009-02-18 08:41:29 -0500
commit6fe4a28d8855e072036f36ee22f0a8f43f44918f (patch)
tree95cb54785155e3d44ed3a07e09929d5c63850f88
parent5852ae42424e3ddba2d3bdf594f72189497f17ee (diff)
crypto: testmgr - Test skciphers with no IVs
As it is an skcipher with no IV escapes testing altogether because we only test givcipher objects. This patch fixes the bypass logic to test these algorithms. Conversely, we're currently testing nivaead algorithms with IVs, which would have deadlocked had it not been for the fact that no nivaead algorithms have any test vectors. This patch also fixes that case. Both fixes are ugly as hell, but this ugliness should hopefully disappear once we move them into the per-type code (i.e., the AEAD test would live in aead.c and the skcipher stuff in ablkcipher.c). Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/algboss.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/crypto/algboss.c b/crypto/algboss.c
index 4601e4267c88..6906f92aeac0 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -10,7 +10,7 @@
10 * 10 *
11 */ 11 */
12 12
13#include <linux/crypto.h> 13#include <crypto/internal/aead.h>
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/init.h> 16#include <linux/init.h>
@@ -206,8 +206,7 @@ static int cryptomgr_test(void *data)
206 u32 type = param->type; 206 u32 type = param->type;
207 int err = 0; 207 int err = 0;
208 208
209 if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) & 209 if (type & CRYPTO_ALG_TESTED)
210 CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV))
211 goto skiptest; 210 goto skiptest;
212 211
213 err = alg_test(param->driver, param->alg, type, CRYPTO_ALG_TESTED); 212 err = alg_test(param->driver, param->alg, type, CRYPTO_ALG_TESTED);
@@ -223,6 +222,7 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
223{ 222{
224 struct task_struct *thread; 223 struct task_struct *thread;
225 struct crypto_test_param *param; 224 struct crypto_test_param *param;
225 u32 type;
226 226
227 if (!try_module_get(THIS_MODULE)) 227 if (!try_module_get(THIS_MODULE))
228 goto err; 228 goto err;
@@ -233,7 +233,19 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
233 233
234 memcpy(param->driver, alg->cra_driver_name, sizeof(param->driver)); 234 memcpy(param->driver, alg->cra_driver_name, sizeof(param->driver));
235 memcpy(param->alg, alg->cra_name, sizeof(param->alg)); 235 memcpy(param->alg, alg->cra_name, sizeof(param->alg));
236 param->type = alg->cra_flags; 236 type = alg->cra_flags;
237
238 /* This piece of crap needs to disappear into per-type test hooks. */
239 if ((!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
240 CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
241 ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
242 CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize :
243 alg->cra_ablkcipher.ivsize)) ||
244 (!((type ^ CRYPTO_ALG_TYPE_AEAD) & CRYPTO_ALG_TYPE_MASK) &&
245 alg->cra_type == &crypto_nivaead_type && alg->cra_aead.ivsize))
246 type |= CRYPTO_ALG_TESTED;
247
248 param->type = type;
237 249
238 thread = kthread_run(cryptomgr_test, param, "cryptomgr_test"); 250 thread = kthread_run(cryptomgr_test, param, "cryptomgr_test");
239 if (IS_ERR(thread)) 251 if (IS_ERR(thread))