crypto: skcipher - Add skcipher_ialg_simple helper

This patch introduces the skcipher_ialg_simple helper which fetches
the crypto_alg structure from a simple skcipher instance's spawn.

This allows us to remove the third argument from the function
skcipher_alloc_instance_simple.

In doing so the reference count to the algorithm is now maintained
by the Crypto API and the caller no longer needs to drop the alg
refcount.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu
2019-12-20 13:29:40 +08:00
parent 93e23eb2ed
commit b3c16bfc6a
9 changed files with 45 additions and 43 deletions

View File

@@ -214,9 +214,17 @@ skcipher_cipher_simple(struct crypto_skcipher *tfm)
return ctx->cipher;
}
struct skcipher_instance *
skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr **tb,
struct crypto_alg **cipher_alg_ret);
struct skcipher_instance *skcipher_alloc_instance_simple(
struct crypto_template *tmpl, struct rtattr **tb);
static inline struct crypto_alg *skcipher_ialg_simple(
struct skcipher_instance *inst)
{
struct crypto_spawn *spawn = skcipher_instance_ctx(inst);
return spawn->alg;
}
#endif /* _CRYPTO_INTERNAL_SKCIPHER_H */