mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
crypto: lrw - 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: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
c4c6bb6e79
commit
1ec0a8aba5
12
crypto/lrw.c
12
crypto/lrw.c
@ -299,8 +299,8 @@ static void lrw_free_instance(struct skcipher_instance *inst)
|
|||||||
static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
|
static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
|
||||||
{
|
{
|
||||||
struct crypto_skcipher_spawn *spawn;
|
struct crypto_skcipher_spawn *spawn;
|
||||||
|
struct skcipher_alg_common *alg;
|
||||||
struct skcipher_instance *inst;
|
struct skcipher_instance *inst;
|
||||||
struct skcipher_alg *alg;
|
|
||||||
const char *cipher_name;
|
const char *cipher_name;
|
||||||
char ecb_name[CRYPTO_MAX_ALG_NAME];
|
char ecb_name[CRYPTO_MAX_ALG_NAME];
|
||||||
u32 mask;
|
u32 mask;
|
||||||
@ -336,13 +336,13 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_free_inst;
|
goto err_free_inst;
|
||||||
|
|
||||||
alg = crypto_skcipher_spawn_alg(spawn);
|
alg = crypto_spawn_skcipher_alg_common(spawn);
|
||||||
|
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if (alg->base.cra_blocksize != LRW_BLOCK_SIZE)
|
if (alg->base.cra_blocksize != LRW_BLOCK_SIZE)
|
||||||
goto err_free_inst;
|
goto err_free_inst;
|
||||||
|
|
||||||
if (crypto_skcipher_alg_ivsize(alg))
|
if (alg->ivsize)
|
||||||
goto err_free_inst;
|
goto err_free_inst;
|
||||||
|
|
||||||
err = crypto_inst_setname(skcipher_crypto_instance(inst), "lrw",
|
err = crypto_inst_setname(skcipher_crypto_instance(inst), "lrw",
|
||||||
@ -382,10 +382,8 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
|
|||||||
(__alignof__(be128) - 1);
|
(__alignof__(be128) - 1);
|
||||||
|
|
||||||
inst->alg.ivsize = LRW_BLOCK_SIZE;
|
inst->alg.ivsize = LRW_BLOCK_SIZE;
|
||||||
inst->alg.min_keysize = crypto_skcipher_alg_min_keysize(alg) +
|
inst->alg.min_keysize = alg->min_keysize + LRW_BLOCK_SIZE;
|
||||||
LRW_BLOCK_SIZE;
|
inst->alg.max_keysize = alg->max_keysize + LRW_BLOCK_SIZE;
|
||||||
inst->alg.max_keysize = crypto_skcipher_alg_max_keysize(alg) +
|
|
||||||
LRW_BLOCK_SIZE;
|
|
||||||
|
|
||||||
inst->alg.base.cra_ctxsize = sizeof(struct lrw_tfm_ctx);
|
inst->alg.base.cra_ctxsize = sizeof(struct lrw_tfm_ctx);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user