mirror of https://github.com/torvalds/linux.git
crypto: ahash - Add support for drivers with no fallback
Some drivers cannot have a fallback, e.g., because the key is held in hardware. Allow these to be used with ahash by adding the bit CRYPTO_ALG_NO_FALLBACK. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Tested-by: Harald Freudenberger <freude@linux.ibm.com>
This commit is contained in:
parent
40a98e702b
commit
4ccd065a69
|
|
@ -347,6 +347,9 @@ static int ahash_do_req_chain(struct ahash_request *req,
|
||||||
if (crypto_ahash_statesize(tfm) > HASH_MAX_STATESIZE)
|
if (crypto_ahash_statesize(tfm) > HASH_MAX_STATESIZE)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
|
if (!crypto_ahash_need_fallback(tfm))
|
||||||
|
return -ENOSYS;
|
||||||
|
|
||||||
{
|
{
|
||||||
u8 state[HASH_MAX_STATESIZE];
|
u8 state[HASH_MAX_STATESIZE];
|
||||||
|
|
||||||
|
|
@ -952,6 +955,10 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
|
||||||
base->cra_reqsize > MAX_SYNC_HASH_REQSIZE)
|
base->cra_reqsize > MAX_SYNC_HASH_REQSIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (base->cra_flags & CRYPTO_ALG_NEED_FALLBACK &&
|
||||||
|
base->cra_flags & CRYPTO_ALG_NO_FALLBACK)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
err = hash_prepare_alg(&alg->halg);
|
err = hash_prepare_alg(&alg->halg);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
@ -960,7 +967,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
|
||||||
base->cra_flags |= CRYPTO_ALG_TYPE_AHASH;
|
base->cra_flags |= CRYPTO_ALG_TYPE_AHASH;
|
||||||
|
|
||||||
if ((base->cra_flags ^ CRYPTO_ALG_REQ_VIRT) &
|
if ((base->cra_flags ^ CRYPTO_ALG_REQ_VIRT) &
|
||||||
(CRYPTO_ALG_ASYNC | CRYPTO_ALG_REQ_VIRT))
|
(CRYPTO_ALG_ASYNC | CRYPTO_ALG_REQ_VIRT) &&
|
||||||
|
!(base->cra_flags & CRYPTO_ALG_NO_FALLBACK))
|
||||||
base->cra_flags |= CRYPTO_ALG_NEED_FALLBACK;
|
base->cra_flags |= CRYPTO_ALG_NEED_FALLBACK;
|
||||||
|
|
||||||
if (!alg->setkey)
|
if (!alg->setkey)
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,9 @@
|
||||||
/* Set if the algorithm supports virtual addresses. */
|
/* Set if the algorithm supports virtual addresses. */
|
||||||
#define CRYPTO_ALG_REQ_VIRT 0x00040000
|
#define CRYPTO_ALG_REQ_VIRT 0x00040000
|
||||||
|
|
||||||
|
/* Set if the algorithm cannot have a fallback (e.g., phmac). */
|
||||||
|
#define CRYPTO_ALG_NO_FALLBACK 0x00080000
|
||||||
|
|
||||||
/* The high bits 0xff000000 are reserved for type-specific flags. */
|
/* The high bits 0xff000000 are reserved for type-specific flags. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue