forked from Minki/linux
crypto: ahash - Add init_tfm/exit_tfm
This patch adds the type-safe init_tfm/exit_tfm functions to the ahash interface. This is meant to replace the unsafe cra_init and cra_exit interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
6779d0e6b0
commit
e73d340db6
@ -444,6 +444,14 @@ static int ahash_def_finup(struct ahash_request *req)
|
|||||||
return ahash_def_finup_finish1(req, err);
|
return ahash_def_finup_finish1(req, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void crypto_ahash_exit_tfm(struct crypto_tfm *tfm)
|
||||||
|
{
|
||||||
|
struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
|
||||||
|
struct ahash_alg *alg = crypto_ahash_alg(hash);
|
||||||
|
|
||||||
|
alg->exit_tfm(hash);
|
||||||
|
}
|
||||||
|
|
||||||
static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
|
static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
|
struct crypto_ahash *hash = __crypto_ahash_cast(tfm);
|
||||||
@ -467,7 +475,10 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
|
|||||||
ahash_set_needkey(hash);
|
ahash_set_needkey(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (alg->exit_tfm)
|
||||||
|
tfm->exit = crypto_ahash_exit_tfm;
|
||||||
|
|
||||||
|
return alg->init_tfm ? alg->init_tfm(hash) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int crypto_ahash_extsize(struct crypto_alg *alg)
|
static unsigned int crypto_ahash_extsize(struct crypto_alg *alg)
|
||||||
|
@ -123,6 +123,17 @@ struct ahash_request {
|
|||||||
* data so the transformation can continue from this point onward. No
|
* data so the transformation can continue from this point onward. No
|
||||||
* data processing happens at this point. Driver must not use
|
* data processing happens at this point. Driver must not use
|
||||||
* req->result.
|
* req->result.
|
||||||
|
* @init_tfm: Initialize the cryptographic transformation object.
|
||||||
|
* This function is called only once at the instantiation
|
||||||
|
* time, right after the transformation context was
|
||||||
|
* allocated. In case the cryptographic hardware has
|
||||||
|
* some special requirements which need to be handled
|
||||||
|
* by software, this function shall check for the precise
|
||||||
|
* requirement of the transformation and put any software
|
||||||
|
* fallbacks in place.
|
||||||
|
* @exit_tfm: Deinitialize the cryptographic transformation object.
|
||||||
|
* This is a counterpart to @init_tfm, used to remove
|
||||||
|
* various changes set in @init_tfm.
|
||||||
* @halg: see struct hash_alg_common
|
* @halg: see struct hash_alg_common
|
||||||
*/
|
*/
|
||||||
struct ahash_alg {
|
struct ahash_alg {
|
||||||
@ -135,6 +146,8 @@ struct ahash_alg {
|
|||||||
int (*import)(struct ahash_request *req, const void *in);
|
int (*import)(struct ahash_request *req, const void *in);
|
||||||
int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
|
int (*setkey)(struct crypto_ahash *tfm, const u8 *key,
|
||||||
unsigned int keylen);
|
unsigned int keylen);
|
||||||
|
int (*init_tfm)(struct crypto_ahash *tfm);
|
||||||
|
void (*exit_tfm)(struct crypto_ahash *tfm);
|
||||||
|
|
||||||
struct hash_alg_common halg;
|
struct hash_alg_common halg;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user