Skip to content

Commit 8a826a3

Browse files
Boris BREZILLONherbertx
authored andcommitted
crypto: testmgr - test IV value after a cipher operation
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>
1 parent d6ba06b commit 8a826a3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎crypto/testmgr.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,22 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
10341034

10351035
q = data;
10361036
if (memcmp(q, template[i].result, template[i].rlen)) {
1037-
pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
1037+
pr_err("alg: skcipher%s: Test %d failed (invalid result) on %s for %s\n",
10381038
d, j, e, algo);
10391039
hexdump(q, template[i].rlen);
10401040
ret = -EINVAL;
10411041
goto out;
10421042
}
1043+
1044+
if (template[i].iv_out &&
1045+
memcmp(iv, template[i].iv_out,
1046+
crypto_skcipher_ivsize(tfm))) {
1047+
pr_err("alg: skcipher%s: Test %d failed (invalid output IV) on %s for %s\n",
1048+
d, j, e, algo);
1049+
hexdump(iv, crypto_skcipher_ivsize(tfm));
1050+
ret = -EINVAL;
1051+
goto out;
1052+
}
10431053
}
10441054

10451055
j = 0;

‎crypto/testmgr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct hash_testvec {
6767
struct cipher_testvec {
6868
char *key;
6969
char *iv;
70+
char *iv_out;
7071
char *input;
7172
char *result;
7273
unsigned short tap[MAX_TAP];

0 commit comments

Comments
 (0)