summaryrefslogtreecommitdiff
path: root/crypto/ccm.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-01-03 06:58:46 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2020-01-09 06:30:54 +0300
commitcd900f0cacd7601dabdd028e8cbdbf2a7041cee2 (patch)
treeee7a4e59f6dd405c03d544ec877f3f33ec3ba685 /crypto/ccm.c
parentb9f76dddb1f9f70e008b982381bbc9a67c9b8c66 (diff)
downloadlinux-cd900f0cacd7601dabdd028e8cbdbf2a7041cee2.tar.xz
crypto: aead - pass instance to crypto_grab_aead()
Initializing a crypto_aead_spawn currently requires: 1. Set spawn->base.inst to point to the instance. 2. Call crypto_grab_aead(). But there's no reason for these steps to be separate, and in fact this unneeded complication has caused at least one bug, the one fixed by commit 6db43410179b ("crypto: adiantum - initialize crypto_spawn::inst") So just make crypto_grab_aead() take the instance as an argument. To keep the function calls from getting too unwieldy due to this extra argument, also introduce a 'mask' variable into the affected places which weren't already using one. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ccm.c')
-rw-r--r--crypto/ccm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 4414f0ddfe5a..48766e81b933 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -734,6 +734,7 @@ static int crypto_rfc4309_create(struct crypto_template *tmpl,
struct rtattr **tb)
{
struct crypto_attr_type *algt;
+ u32 mask;
struct aead_instance *inst;
struct crypto_aead_spawn *spawn;
struct aead_alg *alg;
@@ -747,6 +748,8 @@ static int crypto_rfc4309_create(struct crypto_template *tmpl,
if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
return -EINVAL;
+ mask = crypto_requires_sync(algt->type, algt->mask);
+
ccm_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(ccm_name))
return PTR_ERR(ccm_name);
@@ -756,9 +759,8 @@ static int crypto_rfc4309_create(struct crypto_template *tmpl,
return -ENOMEM;
spawn = aead_instance_ctx(inst);
- crypto_set_aead_spawn(spawn, aead_crypto_instance(inst));
- err = crypto_grab_aead(spawn, ccm_name, 0,
- crypto_requires_sync(algt->type, algt->mask));
+ err = crypto_grab_aead(spawn, aead_crypto_instance(inst),
+ ccm_name, 0, mask);
if (err)
goto out_free_inst;