This patch adds the hooks cra_init/cra_exit which are called during a tfm's
construction and destruction respectively. This will be used by the instances
to allocate child tfm's.
For now this lets us get rid of the coa_init/coa_exit functions which are
used for exactly that purpose (unlike the dia_init function which is called
for each transaction).
In fact the coa_exit path is currently buggy as it may get called twice
when an error is encountered during initialisation.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
if (crypto_init_flags(tfm, flags))
goto out_free_tfm;
if (crypto_init_flags(tfm, flags))
goto out_free_tfm;
- if (crypto_init_ops(tfm)) {
- crypto_exit_ops(tfm);
+ if (crypto_init_ops(tfm))
+
+ if (alg->cra_init && alg->cra_init(tfm))
+ goto cra_init_failed;
+cra_init_failed:
+ crypto_exit_ops(tfm);
out_free_tfm:
kfree(tfm);
tfm = NULL;
out_free_tfm:
kfree(tfm);
tfm = NULL;
alg = tfm->__crt_alg;
size = sizeof(*tfm) + alg->cra_ctxsize;
alg = tfm->__crt_alg;
size = sizeof(*tfm) + alg->cra_ctxsize;
+ if (alg->cra_exit)
+ alg->cra_exit(tfm);
crypto_exit_ops(tfm);
crypto_alg_put(alg);
memset(tfm, 0, size);
crypto_exit_ops(tfm);
crypto_alg_put(alg);
memset(tfm, 0, size);
int crypto_init_compress_ops(struct crypto_tfm *tfm)
{
int crypto_init_compress_ops(struct crypto_tfm *tfm)
{
struct compress_tfm *ops = &tfm->crt_compress;
struct compress_tfm *ops = &tfm->crt_compress;
-
- ret = tfm->__crt_alg->cra_compress.coa_init(tfm);
- if (ret)
- goto out;
ops->cot_compress = crypto_compress;
ops->cot_decompress = crypto_decompress;
ops->cot_compress = crypto_compress;
ops->cot_decompress = crypto_decompress;
}
void crypto_exit_compress_ops(struct crypto_tfm *tfm)
{
}
void crypto_exit_compress_ops(struct crypto_tfm *tfm)
{
- tfm->__crt_alg->cra_compress.coa_exit(tfm);
.cra_ctxsize = sizeof(struct deflate_ctx),
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(alg.cra_list),
.cra_ctxsize = sizeof(struct deflate_ctx),
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(alg.cra_list),
+ .cra_init = deflate_init,
+ .cra_exit = deflate_exit,
- .coa_init = deflate_init,
- .coa_exit = deflate_exit,
.coa_compress = deflate_compress,
.coa_decompress = deflate_decompress } }
};
.coa_compress = deflate_compress,
.coa_decompress = deflate_decompress } }
};
- int (*coa_init)(struct crypto_tfm *tfm);
- void (*coa_exit)(struct crypto_tfm *tfm);
int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src,
unsigned int slen, u8 *dst, unsigned int *dlen);
int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src,
int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src,
unsigned int slen, u8 *dst, unsigned int *dlen);
int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src,
struct digest_alg digest;
struct compress_alg compress;
} cra_u;
struct digest_alg digest;
struct compress_alg compress;
} cra_u;
+
+ int (*cra_init)(struct crypto_tfm *tfm);
+ void (*cra_exit)(struct crypto_tfm *tfm);
struct module *cra_module;
};
struct module *cra_module;
};