Skip to contentSkip to conversation

crypto: adiantum - propagate CRYPTO_ALG_ASYNC flag to instance

PATCH In review Eric Biggers 2 participants 2 messages Dec 5, 2018 – Dec 13, 2018 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: adiantum - propagate CRYPTO_ALG_ASYNC flag to instance

From: Eric Biggers <[email protected]>

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")
---
 crypto/adiantum.c | 2 ++
 1 file changed, 2 insertions(+)
crypto/adiantum.c +2 -0
index 2dfcf12fd4529..ca27e0dc2958c 100644
@@ -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 |
Signature · 1 line
2.20.0.rc1.387.gf8505762e3-goog
maintainer
#1 lore raw
Quoted 6 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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.

Quoted 8 lines

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")
---
 crypto/adiantum.c | 2 ++
 1 file changed, 2 insertions(+)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt