Commit 2257f471 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: testmgr - always print the actual AEAD driver name

When alg_test() is called from tcrypt.ko rather than from the algorithm
registration code, "driver" is actually the algorithm name, not the
driver name.  So it shouldn't be used in places where a driver name is
wanted, e.g. when reporting a test failure or when checking whether the
driver is the generic driver or not.

Fix this for the AEAD algorithm tests by getting the driver name from
the crypto_aead that actually got allocated.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 79cafe9a
...@@ -1919,8 +1919,7 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver, ...@@ -1919,8 +1919,7 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
return err; return err;
} }
static int test_aead_vec_cfg(const char *driver, int enc, static int test_aead_vec_cfg(int enc, const struct aead_testvec *vec,
const struct aead_testvec *vec,
const char *vec_name, const char *vec_name,
const struct testvec_config *cfg, const struct testvec_config *cfg,
struct aead_request *req, struct aead_request *req,
...@@ -1930,6 +1929,7 @@ static int test_aead_vec_cfg(const char *driver, int enc, ...@@ -1930,6 +1929,7 @@ static int test_aead_vec_cfg(const char *driver, int enc,
const unsigned int alignmask = crypto_aead_alignmask(tfm); const unsigned int alignmask = crypto_aead_alignmask(tfm);
const unsigned int ivsize = crypto_aead_ivsize(tfm); const unsigned int ivsize = crypto_aead_ivsize(tfm);
const unsigned int authsize = vec->clen - vec->plen; const unsigned int authsize = vec->clen - vec->plen;
const char *driver = crypto_aead_driver_name(tfm);
const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags; const u32 req_flags = CRYPTO_TFM_REQ_MAY_BACKLOG | cfg->req_flags;
const char *op = enc ? "encryption" : "decryption"; const char *op = enc ? "encryption" : "decryption";
DECLARE_CRYPTO_WAIT(wait); DECLARE_CRYPTO_WAIT(wait);
...@@ -2102,9 +2102,8 @@ static int test_aead_vec_cfg(const char *driver, int enc, ...@@ -2102,9 +2102,8 @@ static int test_aead_vec_cfg(const char *driver, int enc,
return 0; return 0;
} }
static int test_aead_vec(const char *driver, int enc, static int test_aead_vec(int enc, const struct aead_testvec *vec,
const struct aead_testvec *vec, unsigned int vec_num, unsigned int vec_num, struct aead_request *req,
struct aead_request *req,
struct cipher_test_sglists *tsgls) struct cipher_test_sglists *tsgls)
{ {
char vec_name[16]; char vec_name[16];
...@@ -2117,7 +2116,7 @@ static int test_aead_vec(const char *driver, int enc, ...@@ -2117,7 +2116,7 @@ static int test_aead_vec(const char *driver, int enc,
sprintf(vec_name, "%u", vec_num); sprintf(vec_name, "%u", vec_num);
for (i = 0; i < ARRAY_SIZE(default_cipher_testvec_configs); i++) { for (i = 0; i < ARRAY_SIZE(default_cipher_testvec_configs); i++) {
err = test_aead_vec_cfg(driver, enc, vec, vec_name, err = test_aead_vec_cfg(enc, vec, vec_name,
&default_cipher_testvec_configs[i], &default_cipher_testvec_configs[i],
req, tsgls); req, tsgls);
if (err) if (err)
...@@ -2132,7 +2131,7 @@ static int test_aead_vec(const char *driver, int enc, ...@@ -2132,7 +2131,7 @@ static int test_aead_vec(const char *driver, int enc,
for (i = 0; i < fuzz_iterations; i++) { for (i = 0; i < fuzz_iterations; i++) {
generate_random_testvec_config(&cfg, cfgname, generate_random_testvec_config(&cfg, cfgname,
sizeof(cfgname)); sizeof(cfgname));
err = test_aead_vec_cfg(driver, enc, vec, vec_name, err = test_aead_vec_cfg(enc, vec, vec_name,
&cfg, req, tsgls); &cfg, req, tsgls);
if (err) if (err)
return err; return err;
...@@ -2148,7 +2147,6 @@ static int test_aead_vec(const char *driver, int enc, ...@@ -2148,7 +2147,6 @@ static int test_aead_vec(const char *driver, int enc,
struct aead_extra_tests_ctx { struct aead_extra_tests_ctx {
struct aead_request *req; struct aead_request *req;
struct crypto_aead *tfm; struct crypto_aead *tfm;
const char *driver;
const struct alg_test_desc *test_desc; const struct alg_test_desc *test_desc;
struct cipher_test_sglists *tsgls; struct cipher_test_sglists *tsgls;
unsigned int maxdatasize; unsigned int maxdatasize;
...@@ -2354,7 +2352,7 @@ static int test_aead_inauthentic_inputs(struct aead_extra_tests_ctx *ctx) ...@@ -2354,7 +2352,7 @@ static int test_aead_inauthentic_inputs(struct aead_extra_tests_ctx *ctx)
if (ctx->vec.novrfy) { if (ctx->vec.novrfy) {
generate_random_testvec_config(&ctx->cfg, ctx->cfgname, generate_random_testvec_config(&ctx->cfg, ctx->cfgname,
sizeof(ctx->cfgname)); sizeof(ctx->cfgname));
err = test_aead_vec_cfg(ctx->driver, DECRYPT, &ctx->vec, err = test_aead_vec_cfg(DECRYPT, &ctx->vec,
ctx->vec_name, &ctx->cfg, ctx->vec_name, &ctx->cfg,
ctx->req, ctx->tsgls); ctx->req, ctx->tsgls);
if (err) if (err)
...@@ -2373,7 +2371,7 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx) ...@@ -2373,7 +2371,7 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx)
{ {
struct crypto_aead *tfm = ctx->tfm; struct crypto_aead *tfm = ctx->tfm;
const char *algname = crypto_aead_alg(tfm)->base.cra_name; const char *algname = crypto_aead_alg(tfm)->base.cra_name;
const char *driver = ctx->driver; const char *driver = crypto_aead_driver_name(tfm);
const char *generic_driver = ctx->test_desc->generic_driver; const char *generic_driver = ctx->test_desc->generic_driver;
char _generic_driver[CRYPTO_MAX_ALG_NAME]; char _generic_driver[CRYPTO_MAX_ALG_NAME];
struct crypto_aead *generic_tfm = NULL; struct crypto_aead *generic_tfm = NULL;
...@@ -2450,14 +2448,14 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx) ...@@ -2450,14 +2448,14 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx)
generate_random_testvec_config(&ctx->cfg, ctx->cfgname, generate_random_testvec_config(&ctx->cfg, ctx->cfgname,
sizeof(ctx->cfgname)); sizeof(ctx->cfgname));
if (!ctx->vec.novrfy) { if (!ctx->vec.novrfy) {
err = test_aead_vec_cfg(driver, ENCRYPT, &ctx->vec, err = test_aead_vec_cfg(ENCRYPT, &ctx->vec,
ctx->vec_name, &ctx->cfg, ctx->vec_name, &ctx->cfg,
ctx->req, ctx->tsgls); ctx->req, ctx->tsgls);
if (err) if (err)
goto out; goto out;
} }
if (ctx->vec.crypt_error == 0 || ctx->vec.novrfy) { if (ctx->vec.crypt_error == 0 || ctx->vec.novrfy) {
err = test_aead_vec_cfg(driver, DECRYPT, &ctx->vec, err = test_aead_vec_cfg(DECRYPT, &ctx->vec,
ctx->vec_name, &ctx->cfg, ctx->vec_name, &ctx->cfg,
ctx->req, ctx->tsgls); ctx->req, ctx->tsgls);
if (err) if (err)
...@@ -2472,8 +2470,7 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx) ...@@ -2472,8 +2470,7 @@ static int test_aead_vs_generic_impl(struct aead_extra_tests_ctx *ctx)
return err; return err;
} }
static int test_aead_extra(const char *driver, static int test_aead_extra(const struct alg_test_desc *test_desc,
const struct alg_test_desc *test_desc,
struct aead_request *req, struct aead_request *req,
struct cipher_test_sglists *tsgls) struct cipher_test_sglists *tsgls)
{ {
...@@ -2489,7 +2486,6 @@ static int test_aead_extra(const char *driver, ...@@ -2489,7 +2486,6 @@ static int test_aead_extra(const char *driver,
return -ENOMEM; return -ENOMEM;
ctx->req = req; ctx->req = req;
ctx->tfm = crypto_aead_reqtfm(req); ctx->tfm = crypto_aead_reqtfm(req);
ctx->driver = driver;
ctx->test_desc = test_desc; ctx->test_desc = test_desc;
ctx->tsgls = tsgls; ctx->tsgls = tsgls;
ctx->maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN; ctx->maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN;
...@@ -2524,8 +2520,7 @@ static int test_aead_extra(const char *driver, ...@@ -2524,8 +2520,7 @@ static int test_aead_extra(const char *driver,
return err; return err;
} }
#else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ #else /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */
static int test_aead_extra(const char *driver, static int test_aead_extra(const struct alg_test_desc *test_desc,
const struct alg_test_desc *test_desc,
struct aead_request *req, struct aead_request *req,
struct cipher_test_sglists *tsgls) struct cipher_test_sglists *tsgls)
{ {
...@@ -2533,8 +2528,7 @@ static int test_aead_extra(const char *driver, ...@@ -2533,8 +2528,7 @@ static int test_aead_extra(const char *driver,
} }
#endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */ #endif /* !CONFIG_CRYPTO_MANAGER_EXTRA_TESTS */
static int test_aead(const char *driver, int enc, static int test_aead(int enc, const struct aead_test_suite *suite,
const struct aead_test_suite *suite,
struct aead_request *req, struct aead_request *req,
struct cipher_test_sglists *tsgls) struct cipher_test_sglists *tsgls)
{ {
...@@ -2542,8 +2536,7 @@ static int test_aead(const char *driver, int enc, ...@@ -2542,8 +2536,7 @@ static int test_aead(const char *driver, int enc,
int err; int err;
for (i = 0; i < suite->count; i++) { for (i = 0; i < suite->count; i++) {
err = test_aead_vec(driver, enc, &suite->vecs[i], i, req, err = test_aead_vec(enc, &suite->vecs[i], i, req, tsgls);
tsgls);
if (err) if (err)
return err; return err;
cond_resched(); cond_resched();
...@@ -2571,6 +2564,7 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver, ...@@ -2571,6 +2564,7 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
driver, PTR_ERR(tfm)); driver, PTR_ERR(tfm));
return PTR_ERR(tfm); return PTR_ERR(tfm);
} }
driver = crypto_aead_driver_name(tfm);
req = aead_request_alloc(tfm, GFP_KERNEL); req = aead_request_alloc(tfm, GFP_KERNEL);
if (!req) { if (!req) {
...@@ -2588,15 +2582,15 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver, ...@@ -2588,15 +2582,15 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
goto out; goto out;
} }
err = test_aead(driver, ENCRYPT, suite, req, tsgls); err = test_aead(ENCRYPT, suite, req, tsgls);
if (err) if (err)
goto out; goto out;
err = test_aead(driver, DECRYPT, suite, req, tsgls); err = test_aead(DECRYPT, suite, req, tsgls);
if (err) if (err)
goto out; goto out;
err = test_aead_extra(driver, desc, req, tsgls); err = test_aead_extra(desc, req, tsgls);
out: out:
free_cipher_test_sglists(tsgls); free_cipher_test_sglists(tsgls);
aead_request_free(req); aead_request_free(req);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment