Skip to content
Snippets Groups Projects
Commit 36b6fbef authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: ctr - Only access common skcipher fields on spawn


As skcipher spawns may be of the type lskcipher, only the common
fields may be accessed.  This was already the case but use the
correct helpers to make this more obvious.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c9e4b76f
No related branches found
No related tags found
No related merge requests found
...@@ -258,8 +258,8 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl, ...@@ -258,8 +258,8 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl,
struct rtattr **tb) struct rtattr **tb)
{ {
struct skcipher_instance *inst; struct skcipher_instance *inst;
struct skcipher_alg *alg;
struct crypto_skcipher_spawn *spawn; struct crypto_skcipher_spawn *spawn;
struct skcipher_alg_common *alg;
u32 mask; u32 mask;
int err; int err;
...@@ -278,11 +278,11 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl, ...@@ -278,11 +278,11 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl,
if (err) if (err)
goto err_free_inst; goto err_free_inst;
alg = crypto_spawn_skcipher_alg(spawn); alg = crypto_spawn_skcipher_alg_common(spawn);
/* We only support 16-byte blocks. */ /* We only support 16-byte blocks. */
err = -EINVAL; err = -EINVAL;
if (crypto_skcipher_alg_ivsize(alg) != CTR_RFC3686_BLOCK_SIZE) if (alg->ivsize != CTR_RFC3686_BLOCK_SIZE)
goto err_free_inst; goto err_free_inst;
/* Not a stream cipher? */ /* Not a stream cipher? */
...@@ -303,11 +303,9 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl, ...@@ -303,11 +303,9 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl,
inst->alg.base.cra_alignmask = alg->base.cra_alignmask; inst->alg.base.cra_alignmask = alg->base.cra_alignmask;
inst->alg.ivsize = CTR_RFC3686_IV_SIZE; inst->alg.ivsize = CTR_RFC3686_IV_SIZE;
inst->alg.chunksize = crypto_skcipher_alg_chunksize(alg); inst->alg.chunksize = alg->chunksize;
inst->alg.min_keysize = crypto_skcipher_alg_min_keysize(alg) + inst->alg.min_keysize = alg->min_keysize + CTR_RFC3686_NONCE_SIZE;
CTR_RFC3686_NONCE_SIZE; inst->alg.max_keysize = alg->max_keysize + CTR_RFC3686_NONCE_SIZE;
inst->alg.max_keysize = crypto_skcipher_alg_max_keysize(alg) +
CTR_RFC3686_NONCE_SIZE;
inst->alg.setkey = crypto_rfc3686_setkey; inst->alg.setkey = crypto_rfc3686_setkey;
inst->alg.encrypt = crypto_rfc3686_crypt; inst->alg.encrypt = crypto_rfc3686_crypt;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment