crypto: testmgr - check skcipher min_keysize
authorEric Biggers <ebiggers@google.com>
Sun, 1 Dec 2019 21:53:27 +0000 (13:53 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 11 Dec 2019 08:37:01 +0000 (16:37 +0800)
When checking two implementations of the same skcipher algorithm for
consistency, require that the minimum key size be the same, not just the
maximum key size.  There's no good reason to allow different minimum key
sizes.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c

index a8940415512fbce12ca80e6845188630718a0ee9..3d7c1c1529cf5ab51574e6e66789eeb0c651008f 100644 (file)
@@ -2764,6 +2764,15 @@ static int test_skcipher_vs_generic_impl(const char *driver,
 
        /* Check the algorithm properties for consistency. */
 
+       if (crypto_skcipher_min_keysize(tfm) !=
+           crypto_skcipher_min_keysize(generic_tfm)) {
+               pr_err("alg: skcipher: min keysize for %s (%u) doesn't match generic impl (%u)\n",
+                      driver, crypto_skcipher_min_keysize(tfm),
+                      crypto_skcipher_min_keysize(generic_tfm));
+               err = -EINVAL;
+               goto out;
+       }
+
        if (maxkeysize != crypto_skcipher_max_keysize(generic_tfm)) {
                pr_err("alg: skcipher: max keysize for %s (%u) doesn't match generic impl (%u)\n",
                       driver, maxkeysize,