|
@@ -430,26 +430,24 @@ static void echainiv_exit(struct crypto_tfm *tfm)
|
|
crypto_put_default_null_skcipher();
|
|
crypto_put_default_null_skcipher();
|
|
}
|
|
}
|
|
|
|
|
|
-static struct crypto_template echainiv_tmpl;
|
|
|
|
-
|
|
|
|
-static struct crypto_instance *echainiv_aead_alloc(struct rtattr **tb)
|
|
|
|
|
|
+static int echainiv_aead_create(struct crypto_template *tmpl,
|
|
|
|
+ struct rtattr **tb)
|
|
{
|
|
{
|
|
struct aead_instance *inst;
|
|
struct aead_instance *inst;
|
|
struct crypto_aead_spawn *spawn;
|
|
struct crypto_aead_spawn *spawn;
|
|
struct aead_alg *alg;
|
|
struct aead_alg *alg;
|
|
|
|
+ int err;
|
|
|
|
|
|
- inst = aead_geniv_alloc(&echainiv_tmpl, tb, 0, 0);
|
|
|
|
|
|
+ inst = aead_geniv_alloc(tmpl, tb, 0, 0);
|
|
|
|
|
|
if (IS_ERR(inst))
|
|
if (IS_ERR(inst))
|
|
- goto out;
|
|
|
|
|
|
+ return PTR_ERR(inst);
|
|
|
|
|
|
|
|
+ err = -EINVAL;
|
|
if (inst->alg.ivsize < sizeof(u64) ||
|
|
if (inst->alg.ivsize < sizeof(u64) ||
|
|
inst->alg.ivsize & (sizeof(u32) - 1) ||
|
|
inst->alg.ivsize & (sizeof(u32) - 1) ||
|
|
- inst->alg.ivsize > MAX_IV_SIZE) {
|
|
|
|
- aead_geniv_free(inst);
|
|
|
|
- inst = ERR_PTR(-EINVAL);
|
|
|
|
- goto out;
|
|
|
|
- }
|
|
|
|
|
|
+ inst->alg.ivsize > MAX_IV_SIZE)
|
|
|
|
+ goto free_inst;
|
|
|
|
|
|
spawn = aead_instance_ctx(inst);
|
|
spawn = aead_instance_ctx(inst);
|
|
alg = crypto_spawn_aead_alg(spawn);
|
|
alg = crypto_spawn_aead_alg(spawn);
|
|
@@ -474,26 +472,32 @@ static struct crypto_instance *echainiv_aead_alloc(struct rtattr **tb)
|
|
inst->alg.base.cra_exit = echainiv_compat_exit;
|
|
inst->alg.base.cra_exit = echainiv_compat_exit;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ err = aead_register_instance(tmpl, inst);
|
|
|
|
+ if (err)
|
|
|
|
+ goto free_inst;
|
|
|
|
+
|
|
out:
|
|
out:
|
|
- return aead_crypto_instance(inst);
|
|
|
|
|
|
+ return err;
|
|
|
|
+
|
|
|
|
+free_inst:
|
|
|
|
+ aead_geniv_free(inst);
|
|
|
|
+ goto out;
|
|
}
|
|
}
|
|
|
|
|
|
-static struct crypto_instance *echainiv_alloc(struct rtattr **tb)
|
|
|
|
|
|
+static int echainiv_create(struct crypto_template *tmpl, struct rtattr **tb)
|
|
{
|
|
{
|
|
- struct crypto_instance *inst;
|
|
|
|
int err;
|
|
int err;
|
|
|
|
|
|
err = crypto_get_default_rng();
|
|
err = crypto_get_default_rng();
|
|
if (err)
|
|
if (err)
|
|
- return ERR_PTR(err);
|
|
|
|
-
|
|
|
|
- inst = echainiv_aead_alloc(tb);
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
- if (IS_ERR(inst))
|
|
|
|
|
|
+ err = echainiv_aead_create(tmpl, tb);
|
|
|
|
+ if (err)
|
|
goto put_rng;
|
|
goto put_rng;
|
|
|
|
|
|
out:
|
|
out:
|
|
- return inst;
|
|
|
|
|
|
+ return err;
|
|
|
|
|
|
put_rng:
|
|
put_rng:
|
|
crypto_put_default_rng();
|
|
crypto_put_default_rng();
|
|
@@ -508,7 +512,7 @@ static void echainiv_free(struct crypto_instance *inst)
|
|
|
|
|
|
static struct crypto_template echainiv_tmpl = {
|
|
static struct crypto_template echainiv_tmpl = {
|
|
.name = "echainiv",
|
|
.name = "echainiv",
|
|
- .alloc = echainiv_alloc,
|
|
|
|
|
|
+ .create = echainiv_create,
|
|
.free = echainiv_free,
|
|
.free = echainiv_free,
|
|
.module = THIS_MODULE,
|
|
.module = THIS_MODULE,
|
|
};
|
|
};
|