OSDN Git Service

crypto: adiantum - propagate CRYPTO_ALG_ASYNC flag to instance
authorEric Biggers <ebiggers@google.com>
Wed, 5 Dec 2018 00:46:54 +0000 (16:46 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Dec 2018 10:24:56 +0000 (18:24 +0800)
If the stream cipher implementation is asynchronous, then the Adiantum
instance must be flagged as asynchronous as well.  Otherwise someone
asking for a synchronous algorithm can get an asynchronous algorithm.

There are no asynchronous xchacha12 or xchacha20 implementations yet
which makes this largely a theoretical issue, but it should be fixed.

Fixes: 059c2a4d8e16 ("crypto: adiantum - add Adiantum support")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/adiantum.c

index 2dfcf12..ca27e0d 100644 (file)
@@ -590,6 +590,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
                     hash_alg->base.cra_driver_name) >= CRYPTO_MAX_ALG_NAME)
                goto out_drop_hash;
 
+       inst->alg.base.cra_flags = streamcipher_alg->base.cra_flags &
+                                  CRYPTO_ALG_ASYNC;
        inst->alg.base.cra_blocksize = BLOCKCIPHER_BLOCK_SIZE;
        inst->alg.base.cra_ctxsize = sizeof(struct adiantum_tfm_ctx);
        inst->alg.base.cra_alignmask = streamcipher_alg->base.cra_alignmask |