mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
crypto: shash - Add shash_register_instance
This patch adds shash_register_instance so that shash instances can be registered without bypassing the shash checks applied to normal algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
7d6f56400a
commit
619a6ebd25
2 changed files with 27 additions and 2 deletions
|
@ -480,7 +480,7 @@ struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(crypto_alloc_shash);
|
EXPORT_SYMBOL_GPL(crypto_alloc_shash);
|
||||||
|
|
||||||
int crypto_register_shash(struct shash_alg *alg)
|
static int shash_prepare_alg(struct shash_alg *alg)
|
||||||
{
|
{
|
||||||
struct crypto_alg *base = &alg->base;
|
struct crypto_alg *base = &alg->base;
|
||||||
|
|
||||||
|
@ -491,6 +491,17 @@ int crypto_register_shash(struct shash_alg *alg)
|
||||||
base->cra_type = &crypto_shash_type;
|
base->cra_type = &crypto_shash_type;
|
||||||
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
|
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
|
||||||
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
|
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int crypto_register_shash(struct shash_alg *alg)
|
||||||
|
{
|
||||||
|
struct crypto_alg *base = &alg->base;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = shash_prepare_alg(alg);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
return crypto_register_alg(base);
|
return crypto_register_alg(base);
|
||||||
}
|
}
|
||||||
|
@ -502,6 +513,19 @@ int crypto_unregister_shash(struct shash_alg *alg)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(crypto_unregister_shash);
|
EXPORT_SYMBOL_GPL(crypto_unregister_shash);
|
||||||
|
|
||||||
|
int shash_register_instance(struct crypto_template *tmpl,
|
||||||
|
struct shash_instance *inst)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = shash_prepare_alg(&inst->alg);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return crypto_register_instance(tmpl, shash_crypto_instance(inst));
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(shash_register_instance);
|
||||||
|
|
||||||
void shash_free_instance(struct crypto_instance *inst)
|
void shash_free_instance(struct crypto_instance *inst)
|
||||||
{
|
{
|
||||||
crypto_drop_spawn(crypto_instance_ctx(inst));
|
crypto_drop_spawn(crypto_instance_ctx(inst));
|
||||||
|
|
|
@ -53,7 +53,8 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
|
||||||
|
|
||||||
int crypto_register_shash(struct shash_alg *alg);
|
int crypto_register_shash(struct shash_alg *alg);
|
||||||
int crypto_unregister_shash(struct shash_alg *alg);
|
int crypto_unregister_shash(struct shash_alg *alg);
|
||||||
|
int shash_register_instance(struct crypto_template *tmpl,
|
||||||
|
struct shash_instance *inst);
|
||||||
void shash_free_instance(struct crypto_instance *inst);
|
void shash_free_instance(struct crypto_instance *inst);
|
||||||
|
|
||||||
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
|
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue