summaryrefslogtreecommitdiffstats
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-02-01 02:51:50 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2019-02-08 02:30:09 -0500
commita6e5ef9baa2a3245c40b2353c1050bbf1744ca37 (patch)
tree10075983470b2e4949d9ba91af5224e8c3146b3d /crypto/testmgr.c
parentfa353c99174e83ab59ab69ddbf923223b9e7ebbd (diff)
crypto: testmgr - check for aead_request corruption
Check that algorithms do not change the aead_request structure, as users may rely on submitting the request again (e.g. after copying new data into the same source buffer) without reinitializing everything. 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.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 31df04baa85f..d582a2758feb 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1253,6 +1253,50 @@ static int test_aead_vec_cfg(const char *driver, int enc,
1253 return -EINVAL; 1253 return -EINVAL;
1254 } 1254 }
1255 1255
1256 /* Check that the algorithm didn't overwrite things it shouldn't have */
1257 if (req->cryptlen != (enc ? vec->plen : vec->clen) ||
1258 req->assoclen != vec->alen ||
1259 req->iv != iv ||
1260 req->src != tsgls->src.sgl_ptr ||
1261 req->dst != tsgls->dst.sgl_ptr ||
1262 crypto_aead_reqtfm(req) != tfm ||
1263 req->base.complete != crypto_req_done ||
1264 req->base.flags != req_flags ||
1265 req->base.data != &wait) {
1266 pr_err("alg: aead: %s %s corrupted request struct on test vector %u, cfg=\"%s\"\n",
1267 driver, op, vec_num, cfg->name);
1268 if (req->cryptlen != (enc ? vec->plen : vec->clen))
1269 pr_err("alg: aead: changed 'req->cryptlen'\n");
1270 if (req->assoclen != vec->alen)
1271 pr_err("alg: aead: changed 'req->assoclen'\n");
1272 if (req->iv != iv)
1273 pr_err("alg: aead: changed 'req->iv'\n");
1274 if (req->src != tsgls->src.sgl_ptr)
1275 pr_err("alg: aead: changed 'req->src'\n");
1276 if (req->dst != tsgls->dst.sgl_ptr)
1277 pr_err("alg: aead: changed 'req->dst'\n");
1278 if (crypto_aead_reqtfm(req) != tfm)
1279 pr_err("alg: aead: changed 'req->base.tfm'\n");
1280 if (req->base.complete != crypto_req_done)
1281 pr_err("alg: aead: changed 'req->base.complete'\n");
1282 if (req->base.flags != req_flags)
1283 pr_err("alg: aead: changed 'req->base.flags'\n");
1284 if (req->base.data != &wait)
1285 pr_err("alg: aead: changed 'req->base.data'\n");
1286 return -EINVAL;
1287 }
1288 if (is_test_sglist_corrupted(&tsgls->src)) {
1289 pr_err("alg: aead: %s %s corrupted src sgl on test vector %u, cfg=\"%s\"\n",
1290 driver, op, vec_num, cfg->name);
1291 return -EINVAL;
1292 }
1293 if (tsgls->dst.sgl_ptr != tsgls->src.sgl &&
1294 is_test_sglist_corrupted(&tsgls->dst)) {
1295 pr_err("alg: aead: %s %s corrupted dst sgl on test vector %u, cfg=\"%s\"\n",
1296 driver, op, vec_num, cfg->name);
1297 return -EINVAL;
1298 }
1299
1256 /* Check for the correct output (ciphertext or plaintext) */ 1300 /* Check for the correct output (ciphertext or plaintext) */
1257 err = verify_correct_output(&tsgls->dst, enc ? vec->ctext : vec->ptext, 1301 err = verify_correct_output(&tsgls->dst, enc ? vec->ctext : vec->ptext,
1258 enc ? vec->clen : vec->plen, 1302 enc ? vec->clen : vec->plen,