summaryrefslogtreecommitdiff
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-02-14 00:03:51 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-02-22 12:47:27 +0800
commit40ae6daaa2c1285e2bc85b384203227064053e5b (patch)
tree9a03e61e75882326b0ccf2cfa32ea25e9315f819 /crypto/testmgr.c
parentf667ee7414862ac4c329c200299eaf17c899bd5b (diff)
downloadlinux-crypto-40ae6daaa2c1285e2bc85b384203227064053e5b.tar.gz
linux-crypto-40ae6daaa2c1285e2bc85b384203227064053e5b.zip
crypto: testmgr - support checking skcipher output IV
Allow skcipher test vectors to declare the value the IV buffer should be updated to at the end of the encryption or decryption operation. (This check actually used to be supported in testmgr, but it was never used and therefore got removed except for the AES-Keywrap special case. But it will be used by CBC and CTR now, so re-add it.) Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r--crypto/testmgr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index d582a275..8386038d 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1542,7 +1542,9 @@ static int test_skcipher_vec_cfg(const char *driver, int enc,
if (ivsize) {
if (WARN_ON(ivsize > MAX_IVLEN))
return -EINVAL;
- if (vec->iv && !(vec->generates_iv && enc))
+ if (vec->generates_iv && !enc)
+ memcpy(iv, vec->iv_out, ivsize);
+ else if (vec->iv)
memcpy(iv, vec->iv, ivsize);
else
memset(iv, 0, ivsize);
@@ -1635,7 +1637,7 @@ static int test_skcipher_vec_cfg(const char *driver, int enc,
}
/* If applicable, check that the algorithm generated the correct IV */
- if (vec->generates_iv && enc && memcmp(iv, vec->iv, ivsize) != 0) {
+ if (vec->iv_out && memcmp(iv, vec->iv_out, ivsize) != 0) {
pr_err("alg: skcipher: %s %s test failed (wrong output IV) on test vector %u, cfg=\"%s\"\n",
driver, op, vec_num, cfg->name);
hexdump(iv, ivsize);