crypto: gcm - 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>pull/318/merge
parent
7202e65b1e
commit
712c22aa59
|
|
@ -576,10 +576,10 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
|
||||||
const char *ctr_name,
|
const char *ctr_name,
|
||||||
const char *ghash_name)
|
const char *ghash_name)
|
||||||
{
|
{
|
||||||
|
struct skcipher_alg_common *ctr;
|
||||||
u32 mask;
|
u32 mask;
|
||||||
struct aead_instance *inst;
|
struct aead_instance *inst;
|
||||||
struct gcm_instance_ctx *ctx;
|
struct gcm_instance_ctx *ctx;
|
||||||
struct skcipher_alg *ctr;
|
|
||||||
struct hash_alg_common *ghash;
|
struct hash_alg_common *ghash;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
@ -607,13 +607,12 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
|
||||||
ctr_name, 0, mask);
|
ctr_name, 0, mask);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_free_inst;
|
goto err_free_inst;
|
||||||
ctr = crypto_spawn_skcipher_alg(&ctx->ctr);
|
ctr = crypto_spawn_skcipher_alg_common(&ctx->ctr);
|
||||||
|
|
||||||
/* The skcipher algorithm must be CTR mode, using 16-byte blocks. */
|
/* The skcipher algorithm must be CTR mode, using 16-byte blocks. */
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if (strncmp(ctr->base.cra_name, "ctr(", 4) != 0 ||
|
if (strncmp(ctr->base.cra_name, "ctr(", 4) != 0 ||
|
||||||
crypto_skcipher_alg_ivsize(ctr) != 16 ||
|
ctr->ivsize != 16 || ctr->base.cra_blocksize != 1)
|
||||||
ctr->base.cra_blocksize != 1)
|
|
||||||
goto err_free_inst;
|
goto err_free_inst;
|
||||||
|
|
||||||
err = -ENAMETOOLONG;
|
err = -ENAMETOOLONG;
|
||||||
|
|
@ -634,7 +633,7 @@ static int crypto_gcm_create_common(struct crypto_template *tmpl,
|
||||||
ctr->base.cra_alignmask;
|
ctr->base.cra_alignmask;
|
||||||
inst->alg.base.cra_ctxsize = sizeof(struct crypto_gcm_ctx);
|
inst->alg.base.cra_ctxsize = sizeof(struct crypto_gcm_ctx);
|
||||||
inst->alg.ivsize = GCM_AES_IV_SIZE;
|
inst->alg.ivsize = GCM_AES_IV_SIZE;
|
||||||
inst->alg.chunksize = crypto_skcipher_alg_chunksize(ctr);
|
inst->alg.chunksize = ctr->chunksize;
|
||||||
inst->alg.maxauthsize = 16;
|
inst->alg.maxauthsize = 16;
|
||||||
inst->alg.init = crypto_gcm_init_tfm;
|
inst->alg.init = crypto_gcm_init_tfm;
|
||||||
inst->alg.exit = crypto_gcm_exit_tfm;
|
inst->alg.exit = crypto_gcm_exit_tfm;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue