]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
crypto: testmgr - test IV value after a cipher operation
authorBoris BREZILLON <boris.brezillon@free-electrons.com>
Tue, 16 Jun 2015 09:46:46 +0000 (11:46 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 15 Oct 2015 13:05:01 +0000 (21:05 +0800)
The crypto drivers are supposed to update the IV passed to the crypto
request before calling the completion callback.
Test for the IV value before considering the test as successful.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c
crypto/testmgr.h

index 25032b0fd9ed226890752d1cb68ddf3f32b0766b..2037983c6405749393fe086902a62ab9052e8fb7 100644 (file)
@@ -1034,12 +1034,22 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
 
                q = data;
                if (memcmp(q, template[i].result, template[i].rlen)) {
-                       pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
+                       pr_err("alg: skcipher%s: Test %d failed (invalid result) on %s for %s\n",
                               d, j, e, algo);
                        hexdump(q, template[i].rlen);
                        ret = -EINVAL;
                        goto out;
                }
+
+               if (template[i].iv_out &&
+                   memcmp(iv, template[i].iv_out,
+                          crypto_skcipher_ivsize(tfm))) {
+                       pr_err("alg: skcipher%s: Test %d failed (invalid output IV) on %s for %s\n",
+                              d, j, e, algo);
+                       hexdump(iv, crypto_skcipher_ivsize(tfm));
+                       ret = -EINVAL;
+                       goto out;
+               }
        }
 
        j = 0;
index e10582d443dd6328ac14442da69fe4d40842180d..c6f47989647109141057c6c493c771a0f01a5eea 100644 (file)
@@ -67,6 +67,7 @@ struct hash_testvec {
 struct cipher_testvec {
        char *key;
        char *iv;
+       char *iv_out;
        char *input;
        char *result;
        unsigned short tap[MAX_TAP];